OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/install_verification/win/module_list.h" | 5 #include "chrome/browser/install_verification/win/module_list.h" |
6 | 6 |
7 #include <Psapi.h> | 7 #include <Psapi.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 HMODULE module = NULL; | 32 HMODULE module = NULL; |
33 // ::GetModuleHandleEx add-ref's the module if successful. | 33 // ::GetModuleHandleEx add-ref's the module if successful. |
34 if (::GetModuleHandleEx( | 34 if (::GetModuleHandleEx( |
35 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, | 35 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, |
36 reinterpret_cast<LPCWSTR>(snapshot[i]), | 36 reinterpret_cast<LPCWSTR>(snapshot[i]), |
37 &module)) { | 37 &module)) { |
38 instance->modules_.push_back(module); | 38 instance->modules_.push_back(module); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 return instance.Pass(); | 42 return instance; |
43 } | 43 } |
44 | 44 |
45 void ModuleList::GetModuleInfoSet(std::set<ModuleInfo>* module_info_set) { | 45 void ModuleList::GetModuleInfoSet(std::set<ModuleInfo>* module_info_set) { |
46 HANDLE current_process = ::GetCurrentProcess(); | 46 HANDLE current_process = ::GetCurrentProcess(); |
47 for (size_t i = 0; i < modules_.size(); ++i) { | 47 for (size_t i = 0; i < modules_.size(); ++i) { |
48 wchar_t filename[MAX_PATH]; | 48 wchar_t filename[MAX_PATH]; |
49 // Simply ignore modules where GetModuleFileName or GetModuleInformation | 49 // Simply ignore modules where GetModuleFileName or GetModuleInformation |
50 // failed, they might have been unloaded. | 50 // failed, they might have been unloaded. |
51 if (::GetModuleFileName(modules_[i], filename, MAX_PATH) && | 51 if (::GetModuleFileName(modules_[i], filename, MAX_PATH) && |
52 filename[0]) { | 52 filename[0]) { |
53 MODULEINFO sys_module_info = {}; | 53 MODULEINFO sys_module_info = {}; |
54 if (::GetModuleInformation( | 54 if (::GetModuleInformation( |
55 current_process, modules_[i], | 55 current_process, modules_[i], |
56 &sys_module_info, sizeof(sys_module_info))) { | 56 &sys_module_info, sizeof(sys_module_info))) { |
57 module_info_set->insert(ModuleInfo( | 57 module_info_set->insert(ModuleInfo( |
58 filename, | 58 filename, |
59 reinterpret_cast<uintptr_t>(sys_module_info.lpBaseOfDll), | 59 reinterpret_cast<uintptr_t>(sys_module_info.lpBaseOfDll), |
60 sys_module_info.SizeOfImage)); | 60 sys_module_info.SizeOfImage)); |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 ModuleList::ModuleList() {} | 66 ModuleList::ModuleList() {} |
OLD | NEW |