summaryrefslogtreecommitdiffstats
path: root/chrome/browser/install_verification/win/module_verification_test.cc
blob: efd072aeba475fa14660bbb80b9c10c3b3621c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/install_verification/win/module_verification_test.h"

#include <Windows.h>

#include <vector>

#include "base/win/win_util.h"
#include "chrome/browser/install_verification/win/module_list.h"

std::set<size_t> ModuleVerificationTest::reported_module_ids_;

void ModuleVerificationTest::SetUp() {
  reported_module_ids_.clear();
}

bool ModuleVerificationTest::GetLoadedModuleInfoSet(
    std::set<ModuleInfo>* loaded_module_info_set) {
  std::vector<HMODULE> snapshot;
  if (!base::win::GetLoadedModulesSnapshot(::GetCurrentProcess(), &snapshot))
    return false;
  ModuleList::FromLoadedModuleSnapshot(snapshot)->GetModuleInfoSet(
      loaded_module_info_set);
  return true;
}

// static
void ModuleVerificationTest::ReportModule(size_t module_id) {
  reported_module_ids_.insert(module_id);
}