| 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_verification_common.h" | 5 #include "chrome/browser/install_verification/win/module_verification_common.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/install_verification/win/loaded_modules_snapshot.h" | 11 #include "chrome/browser/install_verification/win/loaded_modules_snapshot.h" |
| 12 #include "chrome/browser/install_verification/win/module_info.h" | 12 #include "chrome/browser/install_verification/win/module_info.h" |
| 13 #include "chrome/browser/install_verification/win/module_list.h" | 13 #include "chrome/browser/install_verification/win/module_list.h" |
| 14 | 14 |
| 15 std::string CalculateModuleNameDigest(const base::string16& module_name) { | 15 std::string CalculateModuleNameDigest(const base::string16& module_name) { |
| 16 return base::MD5String(base::StringToLowerASCII(base::UTF16ToUTF8( | 16 return base::MD5String(base::ToLowerASCII(base::UTF16ToUTF8( |
| 17 base::FilePath(module_name).BaseName().value()))); | 17 base::FilePath(module_name).BaseName().value()))); |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool GetLoadedModules(std::set<ModuleInfo>* loaded_modules) { | 20 bool GetLoadedModules(std::set<ModuleInfo>* loaded_modules) { |
| 21 std::vector<HMODULE> snapshot; | 21 std::vector<HMODULE> snapshot; |
| 22 if (!GetLoadedModulesSnapshot(&snapshot)) | 22 if (!GetLoadedModulesSnapshot(&snapshot)) |
| 23 return false; | 23 return false; |
| 24 | 24 |
| 25 ModuleList::FromLoadedModuleSnapshot(snapshot)->GetModuleInfoSet( | 25 ModuleList::FromLoadedModuleSnapshot(snapshot)->GetModuleInfoSet( |
| 26 loaded_modules); | 26 loaded_modules); |
| 27 return true; | 27 return true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ReportModuleMatches(const std::vector<std::string>& module_name_digests, | 30 void ReportModuleMatches(const std::vector<std::string>& module_name_digests, |
| 31 const ModuleIDs& module_ids, | 31 const ModuleIDs& module_ids, |
| 32 ModuleVerificationDelegate* delegate) { | 32 ModuleVerificationDelegate* delegate) { |
| 33 for (size_t i = 0; i < module_name_digests.size(); ++i) { | 33 for (size_t i = 0; i < module_name_digests.size(); ++i) { |
| 34 ModuleIDs::const_iterator entry = module_ids.find(module_name_digests[i]); | 34 ModuleIDs::const_iterator entry = module_ids.find(module_name_digests[i]); |
| 35 if (entry != module_ids.end()) | 35 if (entry != module_ids.end()) |
| 36 delegate(entry->second); | 36 delegate(entry->second); |
| 37 } | 37 } |
| 38 } | 38 } |
| OLD | NEW |