| Index: chrome/common/conflicts/module_watcher_win.cc
|
| diff --git a/chrome/common/conflicts/module_watcher_win.cc b/chrome/common/conflicts/module_watcher_win.cc
|
| index 424fd134ec78875c4fae6e7443c1d6fe467579de..6b1c1dbfd1fb61e3f1dc144641e9aa5de82a87cc 100644
|
| --- a/chrome/common/conflicts/module_watcher_win.cc
|
| +++ b/chrome/common/conflicts/module_watcher_win.cc
|
| @@ -12,6 +12,7 @@
|
|
|
| #include "base/lazy_instance.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/strings/string_piece.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/win/scoped_handle.h"
|
| @@ -96,22 +97,19 @@ constexpr wchar_t kNtDll[] = L"ntdll.dll";
|
| constexpr char kLdrRegisterDllNotification[] = "LdrRegisterDllNotification";
|
| constexpr char kLdrUnregisterDllNotification[] = "LdrUnregisterDllNotification";
|
|
|
| -// Helper function for converting a UNICODE_STRING to a UTF8 std::string.
|
| -std::string ToString(const UNICODE_STRING* str) {
|
| - std::string s;
|
| - base::WideToUTF8(str->Buffer, str->Length / sizeof(wchar_t), &s);
|
| - return s;
|
| +// Helper function for converting a UNICODE_STRING to a FilePath.
|
| +base::FilePath ToFilePath(const UNICODE_STRING* str) {
|
| + return base::FilePath(
|
| + base::StringPiece16(str->Buffer, str->Length / sizeof(wchar_t)));
|
| }
|
|
|
| template <typename NotificationDataType>
|
| void OnModuleEvent(mojom::ModuleEventType event_type,
|
| const NotificationDataType& notification_data,
|
| const ModuleWatcher::OnModuleEventCallback& callback) {
|
| - mojom::ModuleEvent event;
|
| - event.event_type = event_type;
|
| - event.module_path = ToString(notification_data.FullDllName);
|
| - event.load_address = reinterpret_cast<uintptr_t>(notification_data.DllBase);
|
| - event.size = notification_data.SizeOfImage;
|
| + ModuleWatcher::ModuleEvent event(
|
| + event_type, ToFilePath(notification_data.FullDllName),
|
| + notification_data.DllBase, notification_data.SizeOfImage);
|
| callback.Run(event);
|
| }
|
|
|
| @@ -174,15 +172,11 @@ void ModuleWatcher::EnumerateAlreadyLoadedModules() {
|
|
|
| // Walk the module list.
|
| MODULEENTRY32 module = {sizeof(module)};
|
| - std::string path;
|
| for (BOOL result = ::Module32First(snap.Get(), &module); result != FALSE;
|
| result = ::Module32Next(snap.Get(), &module)) {
|
| - base::WideToUTF8(module.szExePath, ::wcslen(module.szExePath), &path);
|
| - mojom::ModuleEvent event;
|
| - event.event_type = mojom::ModuleEventType::MODULE_ALREADY_LOADED;
|
| - event.module_path = path;
|
| - event.load_address = reinterpret_cast<uintptr_t>(module.modBaseAddr);
|
| - event.size = module.modBaseSize;
|
| + ModuleEvent event(mojom::ModuleEventType::MODULE_ALREADY_LOADED,
|
| + base::FilePath(module.szExePath), module.modBaseAddr,
|
| + module.modBaseSize);
|
| callback_.Run(event);
|
| }
|
|
|
|
|