summaryrefslogtreecommitdiffstats
path: root/chrome/installer/test/resource_updater.h
blob: 32c9d0dfe877ab5f1e20675b9a0b26f1f10e52df (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
// 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 updating resources in portable executable files.

#ifndef CHROME_INSTALLER_TEST_RESOURCE_UPDATER_H_
#define CHROME_INSTALLER_TEST_RESOURCE_UPDATER_H_
#pragma once

#include <windows.h>

#include <string>
#include <utility>

#include "base/basictypes.h"

class FilePath;

namespace upgrade_test {

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

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

  // Replaces the contents of the resource |name| of |type| and |language_id|
  // with the contents of |input_file|, returning true on success.
  bool Update(const std::wstring& name, const std::wstring& type,
              WORD language_id, const FilePath& input_file);

  // Commits all updates to the file on disk.
  bool Commit();

 private:
  HANDLE handle_;
  DISALLOW_COPY_AND_ASSIGN(ResourceUpdater);
};  // class ResourceUpdater

}  // namespace upgrade_test

#endif  // CHROME_INSTALLER_TEST_RESOURCE_UPDATER_H_