Chromium Code Reviews| Index: chrome/browser/install_verification/win/module_list.cc |
| diff --git a/chrome/browser/install_verification/win/module_list.cc b/chrome/browser/install_verification/win/module_list.cc |
| index 7a31bf17eaf06b569caa2528a6711cbdd7feef23..72078a3dadc5393714ee5f739a956bd2abfbde58 100644 |
| --- a/chrome/browser/install_verification/win/module_list.cc |
| +++ b/chrome/browser/install_verification/win/module_list.cc |
| @@ -11,23 +11,19 @@ |
| #include "base/logging.h" |
| #include "chrome/browser/install_verification/win/module_info.h" |
| -namespace { |
| - |
| -void CheckFreeLibrary(HMODULE module) { |
| - BOOL result = ::FreeLibrary(module); |
| - DCHECK(result); |
| -} |
| - |
| -} // namespace |
| - |
| ModuleList::~ModuleList() { |
| - std::for_each(modules_.begin(), modules_.end(), &CheckFreeLibrary); |
| + for (const auto& module : modules_) { |
| + BOOL result = ::FreeLibrary(std::get<HMODULE>(module)); |
| + DCHECK(result) << std::get<std::wstring>(module); |
| + } |
| } |
| scoped_ptr<ModuleList> ModuleList::FromLoadedModuleSnapshot( |
| const std::vector<HMODULE>& snapshot) { |
| scoped_ptr<ModuleList> instance(new ModuleList); |
| + wchar_t module_name[MAX_PATH] = {0}; |
|
robertshield
2016/04/19 00:54:23
nit: {}
|
| + |
| for (size_t i = 0; i < snapshot.size(); ++i) { |
| HMODULE module = NULL; |
| // ::GetModuleHandleEx add-ref's the module if successful. |
| @@ -35,7 +31,11 @@ scoped_ptr<ModuleList> ModuleList::FromLoadedModuleSnapshot( |
| GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, |
| reinterpret_cast<LPCWSTR>(snapshot[i]), |
| &module)) { |
| - instance->modules_.push_back(module); |
| + if (::GetModuleFileNameW(module, module_name, MAX_PATH)) { |
| + instance->modules_.push_back(std::make_tuple(module, module_name)); |
| + } else { |
| + instance->modules_.push_back(std::make_tuple(module, std::wstring())); |
| + } |
| } |
| } |
| @@ -48,12 +48,13 @@ void ModuleList::GetModuleInfoSet(std::set<ModuleInfo>* module_info_set) { |
| wchar_t filename[MAX_PATH]; |
|
robertshield
2016/04/19 00:54:23
looks like this should have an = {} on the end?
|
| // Simply ignore modules where GetModuleFileName or GetModuleInformation |
| // failed, they might have been unloaded. |
| - if (::GetModuleFileName(modules_[i], filename, MAX_PATH) && |
| + if (::GetModuleFileName(std::get<HMODULE>(modules_[i]), filename, |
| + MAX_PATH) && |
|
robertshield
2016/04/19 00:54:22
Many of the entries in modules_ will already have
Will Harris
2016/04/19 00:59:05
yes I found that later, I think I should change ho
|
| filename[0]) { |
| MODULEINFO sys_module_info = {}; |
| - if (::GetModuleInformation( |
| - current_process, modules_[i], |
| - &sys_module_info, sizeof(sys_module_info))) { |
| + if (::GetModuleInformation(current_process, |
| + std::get<HMODULE>(modules_[i]), |
| + &sys_module_info, sizeof(sys_module_info))) { |
| module_info_set->insert(ModuleInfo( |
| filename, |
| reinterpret_cast<uintptr_t>(sys_module_info.lpBaseOfDll), |