Chromium Code Reviews| 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/imported_module_verification.h " | 5 #include "chrome/browser/install_verification/win/imported_module_verification.h " |
| 6 | 6 |
| 7 #include <Windows.h> | 7 #include <Windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/install_verification/win/module_info.h" | 15 #include "chrome/browser/install_verification/win/module_info.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 #if !defined(_WIN64) | |
| 19 // We must make sure not to include modules here that are likely to get unloaded | 20 // We must make sure not to include modules here that are likely to get unloaded |
| 20 // because the scanning of the module is not done within a loader lock, so is | 21 // because the scanning of the module is not done within a loader lock, so is |
| 21 // not resilient to changes made to the modules list. | 22 // not resilient to changes made to the modules list. |
| 22 const wchar_t* const kModulesToScan[] = { | 23 const wchar_t* const kModulesToScan[] = { |
| 23 L"chrome.dll", | 24 L"chrome.dll", |
| 24 L"kernel32.dll", | 25 L"kernel32.dll", |
| 25 L"user32.dll" | 26 L"user32.dll" |
| 26 }; | 27 }; |
| 28 #endif // !defined(_WIN64) | |
| 27 | 29 |
| 28 bool AddressBeyondRange(const ModuleInfo& module, uintptr_t address) { | 30 bool AddressBeyondRange(const ModuleInfo& module, uintptr_t address) { |
| 29 return module.base_address + module.size < address; | 31 return module.base_address + module.size < address; |
| 30 } | 32 } |
| 31 | 33 |
| 32 void ScanImportAddressTable( | 34 void ScanImportAddressTable( |
| 33 HMODULE module_handle, | 35 HMODULE module_handle, |
| 34 const std::set<ModuleInfo>& loaded_modules, | 36 const std::set<ModuleInfo>& loaded_modules, |
| 35 std::set<base::string16>* imported_modules) { | 37 std::set<base::string16>* imported_modules) { |
| 36 DCHECK(module_handle); | 38 DCHECK(module_handle); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 image_descriptor += sizeof(image_descriptor) / sizeof(uintptr_t); | 73 image_descriptor += sizeof(image_descriptor) / sizeof(uintptr_t); |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace | 77 } // namespace |
| 76 | 78 |
| 77 void VerifyImportedModules(const std::set<ModuleInfo>& loaded_modules, | 79 void VerifyImportedModules(const std::set<ModuleInfo>& loaded_modules, |
| 78 const ModuleIDs& module_ids, | 80 const ModuleIDs& module_ids, |
| 79 ModuleVerificationDelegate* delegate){ | 81 ModuleVerificationDelegate* delegate){ |
| 80 // Note that module verification is temporarily disabled for 64-bit builds. | 82 // Note that module verification is temporarily disabled for 64-bit builds. |
| 81 // See crbug.com/316274. | 83 // See crbug.com/316274. |
|
cpu_(ooo_6.6-7.5)
2015/07/07 17:39:24
I see no reason for this... looking for somebody t
Matt Giuca
2015/07/08 02:51:28
Acknowledged.
| |
| 82 #if !defined(_WIN64) | 84 #if !defined(_WIN64) |
| 83 std::set<base::string16> imported_module_names; | 85 std::set<base::string16> imported_module_names; |
| 84 for (size_t i = 0; i < arraysize(kModulesToScan); ++i) { | 86 for (size_t i = 0; i < arraysize(kModulesToScan); ++i) { |
| 85 HMODULE module_handle = ::GetModuleHandle(kModulesToScan[i]); | 87 HMODULE module_handle = ::GetModuleHandle(kModulesToScan[i]); |
| 86 if (module_handle) { | 88 if (module_handle) { |
| 87 ScanImportAddressTable(module_handle, | 89 ScanImportAddressTable(module_handle, |
| 88 loaded_modules, | 90 loaded_modules, |
| 89 &imported_module_names); | 91 &imported_module_names); |
| 90 } | 92 } |
| 91 } | 93 } |
| 92 | 94 |
| 93 std::vector<std::string> module_name_digests; | 95 std::vector<std::string> module_name_digests; |
| 94 std::transform(imported_module_names.begin(), | 96 std::transform(imported_module_names.begin(), |
| 95 imported_module_names.end(), | 97 imported_module_names.end(), |
| 96 std::back_inserter(module_name_digests), | 98 std::back_inserter(module_name_digests), |
| 97 &CalculateModuleNameDigest); | 99 &CalculateModuleNameDigest); |
| 98 ReportModuleMatches(module_name_digests, module_ids, delegate); | 100 ReportModuleMatches(module_name_digests, module_ids, delegate); |
| 99 #endif | 101 #endif |
| 100 } | 102 } |
| OLD | NEW |