Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / chrome / browser / install_verification / win / module_verification_common.cc
blob0d28858f0aca443e6d1a6852e3ed6cd5db64665f
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
3 // found in the LICENSE file.
5 #include "chrome/browser/install_verification/win/module_verification_common.h"
7 #include "base/files/file_path.h"
8 #include "base/md5.h"
9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/install_verification/win/loaded_modules_snapshot.h"
12 #include "chrome/browser/install_verification/win/module_info.h"
13 #include "chrome/browser/install_verification/win/module_list.h"
15 std::string CalculateModuleNameDigest(const base::string16& module_name) {
16 return base::MD5String(base::StringToLowerASCII(base::UTF16ToUTF8(
17 base::FilePath(module_name).BaseName().value())));
20 bool GetLoadedModules(std::set<ModuleInfo>* loaded_modules) {
21 std::vector<HMODULE> snapshot;
22 if (!GetLoadedModulesSnapshot(&snapshot))
23 return false;
25 ModuleList::FromLoadedModuleSnapshot(snapshot)->GetModuleInfoSet(
26 loaded_modules);
27 return true;
30 void ReportModuleMatches(const std::vector<std::string>& module_name_digests,
31 const ModuleIDs& module_ids,
32 ModuleVerificationDelegate* delegate) {
33 for (size_t i = 0; i < module_name_digests.size(); ++i) {
34 ModuleIDs::const_iterator entry = module_ids.find(module_name_digests[i]);
35 if (entry != module_ids.end())
36 delegate(entry->second);