summaryrefslogtreecommitdiffstats
path: root/chrome/installer/test/resource_loader.h
blob: b43056c42899528db770dbd465eb239b809e73ed (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2010 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.

// A helper class for loading resources out of portable executable files.

#ifndef CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_
#define CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_

#include <windows.h>

#include <string>
#include <utility>

#include "base/basictypes.h"

namespace base {
class FilePath;
}

namespace upgrade_test {

// Loads resources in a PE image file.
class ResourceLoader {
 public:
  ResourceLoader();
  ~ResourceLoader();

  // Loads |pe_image_path| in preparation for loading its resources.
  bool Initialize(const base::FilePath& pe_image_path);

  // Places the address and size of the resource |name| of |type| into
  // |resource_data|, returning true on success.  The address of the resource is
  // valid only until this instance is destroyed.
  bool Load(const std::wstring& name, const std::wstring& type,
            std::pair<const uint8*, DWORD>* resource_data);

  // Places the address and size of the resource |id| of |type| into
  // |resource_data|, returning true on success.  The address of the resource is
  // valid only until this instance is destroyed.
  bool Load(WORD id, WORD type, std::pair<const uint8*, DWORD>* resource_data);

 private:
  HMODULE module_;
  DISALLOW_COPY_AND_ASSIGN(ResourceLoader);
};  // class ResourceLoader

}  // namespace upgrade_test

#endif  // CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_