OLD | NEW |
(Empty) | |
| 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 // This file contains the interface for an iterator over a portable executable |
| 6 // file's resources. |
| 7 |
| 8 #ifndef CHROME_INSTALLER_TEST_PE_IMAGE_RESOURCES_H__ |
| 9 #define CHROME_INSTALLER_TEST_PE_IMAGE_RESOURCES_H__ |
| 10 #pragma once |
| 11 |
| 12 #include <windows.h> |
| 13 |
| 14 #include <string> |
| 15 #include <vector> |
| 16 |
| 17 #include "base/basictypes.h" |
| 18 #include "base/logging.h" |
| 19 |
| 20 namespace base { namespace win { class PEImage; } } |
| 21 |
| 22 namespace upgrade_test { |
| 23 |
| 24 // A CopyConstructible and Assignable identifier for resource directory |
| 25 // entries. |
| 26 class EntryId { |
| 27 public: |
| 28 explicit EntryId(WORD number) : number_(number) { } |
| 29 explicit EntryId(const std::wstring& name) : name_(name), number_() { |
| 30 DCHECK_NE(static_cast<std::wstring::size_type>(0), name.size()); |
| 31 } |
| 32 bool IsNamed() const { return !name_.empty(); } |
| 33 WORD number() const { return number_; } |
| 34 const std::wstring& name() const { return name_; } |
| 35 private: |
| 36 std::wstring name_; |
| 37 WORD number_; |
| 38 }; // class EntryId |
| 39 |
| 40 // A sequence of identifiers comprising the path from the root of an image's |
| 41 // resource directory to an individual resource. |
| 42 typedef std::vector<EntryId> EntryPath; |
| 43 |
| 44 // A callback function invoked once for each data entry in the image's |
| 45 // directory of resources. |
| 46 // |path| - the full path of the data entry, |
| 47 // |data| - the address of the entry's data. |
| 48 // |size| - the size, in bytes, of the entry's data. |
| 49 // |code_page| - the code page to be used to interpret string data in the |
| 50 // entry's data. |
| 51 // |context| - the context given to EnumResources. |
| 52 typedef void (*EnumResource_Fn)(const EntryPath& path, uint8* data, |
| 53 DWORD size, DWORD code_page, uintptr_t context); |
| 54 |
| 55 // Enumerates all data entries in |image|'s resource directory. |function| is |
| 56 // invoked (and provided with |context|) once per entry. Returns false if |
| 57 // some or all of the resource directory could not be parsed. |
| 58 bool EnumResources(const base::win::PEImage& image, EnumResource_Fn function, |
| 59 uintptr_t context); |
| 60 |
| 61 } // namespace upgrade_test |
| 62 |
| 63 #endif // CHROME_INSTALLER_TEST_PE_IMAGE_RESOURCES_H__ |
OLD | NEW |