// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_ZUCCHINI_TYPE_WIN_PE_H_ #define COMPONENTS_ZUCCHINI_TYPE_WIN_PE_H_ #include <stddef.h> #include <stdint.h> namespace zucchini { // Structures and constants taken from WINNT.h and following identical layout. // This is used for parsing of Portable Executable (PE) file format. namespace pe { // Supported by MSVC, g++, and clang++. Ensures no gaps in packing. #pragma pack(push, 1) // IMAGE_NUMBEROF_DIRECTORY_ENTRIES constexpr size_t kImageNumberOfDirectoryEntries = …; // IMAGE_FILE_BASE_RELOCATION_TABLE constexpr size_t kIndexOfBaseRelocationTable = …; constexpr uint32_t kImageScnMemExecute = …; // IMAGE_SCN_MEM_EXECUTE constexpr uint32_t kImageScnMemRead = …; // IMAGE_SCN_MEM_READ // IMAGE_DOS_HEADER struct ImageDOSHeader { … }; static_assert …; // IMAGE_SECTION_HEADER struct ImageSectionHeader { … }; static_assert …; // IMAGE_DATA_DIRECTORY struct ImageDataDirectory { … }; static_assert …; // IMAGE_FILE_HEADER struct ImageFileHeader { … }; static_assert …; // IMAGE_OPTIONAL_HEADER struct ImageOptionalHeader { … }; static_assert …; // IMAGE_OPTIONAL_HEADER64 struct ImageOptionalHeader64 { … }; static_assert …; struct RelocHeader { … }; static_assert …; #pragma pack(pop) } // namespace pe // Constants and offsets gleaned from WINNT.h and various articles on the // format of Windows PE executables. constexpr char const* kTextSectionName = …; // Bitfield with characteristics usually associated with code sections. const uint32_t kCodeCharacteristics = …; } // namespace zucchini #endif // COMPONENTS_ZUCCHINI_TYPE_WIN_PE_H_