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