Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1970)

Unified Diff: chrome/browser/install_verification/win/module_list.cc

Issue 1902563004: Add module name to module_list to aid debugging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/install_verification/win/module_list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
« no previous file with comments | « chrome/browser/install_verification/win/module_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698