| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A helper class for loading resources out of portable executable files. | 5 // A helper class for loading resources out of portable executable files. |
| 6 | 6 |
| 7 #ifndef CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ | 7 #ifndef CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ |
| 8 #define CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ | 8 #define CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 | 16 |
| 17 namespace base { |
| 17 class FilePath; | 18 class FilePath; |
| 19 } |
| 18 | 20 |
| 19 namespace upgrade_test { | 21 namespace upgrade_test { |
| 20 | 22 |
| 21 // Loads resources in a PE image file. | 23 // Loads resources in a PE image file. |
| 22 class ResourceLoader { | 24 class ResourceLoader { |
| 23 public: | 25 public: |
| 24 ResourceLoader(); | 26 ResourceLoader(); |
| 25 ~ResourceLoader(); | 27 ~ResourceLoader(); |
| 26 | 28 |
| 27 // Loads |pe_image_path| in preparation for loading its resources. | 29 // Loads |pe_image_path| in preparation for loading its resources. |
| 28 bool Initialize(const FilePath& pe_image_path); | 30 bool Initialize(const base::FilePath& pe_image_path); |
| 29 | 31 |
| 30 // Places the address and size of the resource |name| of |type| into | 32 // Places the address and size of the resource |name| of |type| into |
| 31 // |resource_data|, returning true on success. The address of the resource is | 33 // |resource_data|, returning true on success. The address of the resource is |
| 32 // valid only until this instance is destroyed. | 34 // valid only until this instance is destroyed. |
| 33 bool Load(const std::wstring& name, const std::wstring& type, | 35 bool Load(const std::wstring& name, const std::wstring& type, |
| 34 std::pair<const uint8*, DWORD>* resource_data); | 36 std::pair<const uint8*, DWORD>* resource_data); |
| 35 | 37 |
| 36 // Places the address and size of the resource |id| of |type| into | 38 // Places the address and size of the resource |id| of |type| into |
| 37 // |resource_data|, returning true on success. The address of the resource is | 39 // |resource_data|, returning true on success. The address of the resource is |
| 38 // valid only until this instance is destroyed. | 40 // valid only until this instance is destroyed. |
| 39 bool Load(WORD id, WORD type, std::pair<const uint8*, DWORD>* resource_data); | 41 bool Load(WORD id, WORD type, std::pair<const uint8*, DWORD>* resource_data); |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 HMODULE module_; | 44 HMODULE module_; |
| 43 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 45 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 44 }; // class ResourceLoader | 46 }; // class ResourceLoader |
| 45 | 47 |
| 46 } // namespace upgrade_test | 48 } // namespace upgrade_test |
| 47 | 49 |
| 48 #endif // CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ | 50 #endif // CHROME_INSTALLER_TEST_RESOURCE_LOADER_H_ |
| OLD | NEW |