--- mstools/h/winnt.h 2018/08/09 18:20:25 1.1.1.2 +++ mstools/h/winnt.h 2018/08/09 18:21:01 1.1.1.3 @@ -1,4 +1,4 @@ -/*++ BUILD Version: 0078 // Increment this if a change has global effects +/*++ BUILD Version: 0082 // Increment this if a change has global effects Copyright (c) 1990-1992 Microsoft Corporation @@ -67,14 +67,20 @@ typedef CONST CHAR *LPCSTR, *PCSTR; // Neutral ANSI/UNICODE types and macros // #ifdef UNICODE -typedef WCHAR TCHAR; +#ifndef _TCHAR_DEFINED +typedef WCHAR TCHAR, *PTCHAR; +#define _TCHAR_DEFINED +#endif typedef LPWSTR LPTCH, PTCH; typedef LPWSTR PTSTR, LPTSTR; typedef LPCWSTR LPCTSTR; typedef LPWSTR LP; #define TEXT(quote) L##quote #else +#ifndef _TCHAR_DEFINED typedef char TCHAR, *PTCHAR; +#define _TCHAR_DEFINED +#endif typedef LPSTR LPTCH, PTCH; typedef LPSTR PTSTR, LPTSTR; typedef LPCSTR LPCTSTR; @@ -615,8 +621,10 @@ typedef struct _EXCEPTION_POINTERS { #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \ 0x3FF) #define TLS_MINIMUM_AVAILABLE 64 +#define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1 #define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost #define THREAD_BASE_PRIORITY_MIN -2 // minimum thread base priority boost +#define THREAD_BASE_PRIORITY_IDLE -15 // value that gets a thread to idle #define EVENT_MODIFY_STATE 0x0002 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) #define MUTANT_QUERY_STATE 0x0001 @@ -625,6 +633,9 @@ typedef struct _EXCEPTION_POINTERS { MUTANT_QUERY_STATE) #define SEMAPHORE_MODIFY_STATE 0x0002 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) +#define TIME_ZONE_ID_UNKNOWN 0 +#define TIME_ZONE_ID_STANDARD 1 +#define TIME_ZONE_ID_DAYLIGHT 2 #define PROCESSOR_INTEL_386 386 #define PROCESSOR_INTEL_486 486 @@ -633,18 +644,6 @@ typedef struct _EXCEPTION_POINTERS { #define PROCESSOR_MIPS_R3000 3000 #define PROCESSOR_MIPS_R4000 4000 -#define PROCESSOR_STEP_A0 0x00000000 -#define PROCESSOR_STEP_B0 0x00010000 -#define PROCESSOR_STEP_C0 0x00020000 -#define PROCESSOR_STEP_D0 0x00030000 -#define PROCESSOR_STEP_E0 0x00040000 -#define PROCESSOR_STEP_F0 0x00050000 -#define PROCESSOR_STEP_G0 0x00060000 -#define PROCESSOR_STEP_H0 0x00070000 -#define PROCESSOR_STEP_I0 0x00080000 - -#define PROCESSOR_OPTION_387 0x00000001 - typedef struct _MEMORY_BASIC_INFORMATION { PVOID BaseAddress; PVOID AllocationBase; @@ -694,6 +693,7 @@ typedef struct _MEMORY_BASIC_INFORMATION #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 #define FILE_CASE_PRESERVED_NAMES 0x00000002 #define FILE_UNICODE_ON_DISK 0x00000004 +#define FILE_PERSISTENT_ACLS 0x00000008 #define DUPLICATE_CLOSE_SOURCE 0x00000001 #define DUPLICATE_SAME_ACCESS 0x00000002 typedef PVOID PACCESS_TOKEN; @@ -1461,29 +1461,29 @@ typedef struct _PRIVILEGE_SET { // // //////////////////////////////////////////////////////////////////////// -#define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege" -#define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege" -#define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege" -#define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege" -#define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege" -#define SE_TCB_NAME L"SeTcbPrivilege" -#define SE_SECURITY_NAME L"SeSecurityPrivilege" -#define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege" -#define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege" -#define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege" -#define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege" -#define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege" -#define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege" -#define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege" -#define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege" -#define SE_BACKUP_NAME L"SeBackupPrivilege" -#define SE_RESTORE_NAME L"SeRestorePrivilege" -#define SE_SHUTDOWN_NAME L"SeShutdownPrivilege" -#define SE_DEBUG_NAME L"SeDebugPrivilege" -#define SE_AUDIT_NAME L"SeAuditPrivilege" -#define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege" -#define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege" -#define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege" +#define SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege") +#define SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege") +#define SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege") +#define SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege") +#define SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege") +#define SE_TCB_NAME TEXT("SeTcbPrivilege") +#define SE_SECURITY_NAME TEXT("SeSecurityPrivilege") +#define SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege") +#define SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege") +#define SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege") +#define SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege") +#define SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege") +#define SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege") +#define SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege") +#define SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege") +#define SE_BACKUP_NAME TEXT("SeBackupPrivilege") +#define SE_RESTORE_NAME TEXT("SeRestorePrivilege") +#define SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege") +#define SE_DEBUG_NAME TEXT("SeDebugPrivilege") +#define SE_AUDIT_NAME TEXT("SeAuditPrivilege") +#define SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege") +#define SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege") +#define SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege") //////////////////////////////////////////////////////////////////// @@ -1696,16 +1696,24 @@ typedef DWORD SECURITY_INFORMATION, *PSE #define GROUP_SECURITY_INFORMATION (0X00000002L) #define DACL_SECURITY_INFORMATION (0X00000004L) #define SACL_SECURITY_INFORMATION (0X00000008L) -#define HEAP_SERIALIZE 0x00000001 -typedef struct _RTL_CRITICAL_SECTION { +#define HEAP_SERIALIZE 0x00000001 -#if DEVL +typedef struct _RTL_CRITICAL_SECTION_DEBUG { WORD Type; - WORD Depth; - PVOID OwnerBackTrace[ 4 ]; - DWORD ContentionCount; + WORD CreatorBackTraceIndex; + struct _RTL_CRITICAL_SECTION *CriticalSection; LIST_ENTRY ProcessLocksList; -#endif // DEVL + DWORD EntryCount; + DWORD ContentionCount; + DWORD Depth; + PVOID OwnerBackTrace[ 5 ]; +} RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG; + +#define RTL_CRITSECT_TYPE 0 +#define RTL_RESOURCE_TYPE 1 + +typedef struct _RTL_CRITICAL_SECTION { + PRTL_CRITICAL_SECTION_DEBUG DebugInfo; // // The following three fields control entering and exiting the critical @@ -1716,14 +1724,7 @@ typedef struct _RTL_CRITICAL_SECTION { LONG RecursionCount; HANDLE OwningThread; // from the thread's ClientId->UniqueThread HANDLE LockSemaphore; - KSPIN_LOCK SpinLock; - -#if DEVL && defined(i386) - DWORD CreatorBackTraceIndex; -#else DWORD Reserved; -#endif // DEVL && defined(i386) - } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; #define DLL_PROCESS_ATTACH 1 #define DLL_THREAD_ATTACH 2 @@ -1979,26 +1980,27 @@ typedef enum _CM_ERROR_CONTROL_TYPE { // IOCTL_TAPE_ERASE definitions // -#define TAPE_ERASE_SHORT 0 -#define TAPE_ERASE_LONG 1 -#define TAPE_ERASE_SHORT_IMMED 2 -#define TAPE_ERASE_LONG_IMMED 3 +#define TAPE_ERASE_SHORT 0L +#define TAPE_ERASE_SHORT_IMMED 1L +#define TAPE_ERASE_LONG 2L +#define TAPE_ERASE_LONG_IMMED 3L typedef struct _TAPE_ERASE { - DWORD Partition; DWORD Type; } TAPE_ERASE, *PTAPE_ERASE; - // // IOCTL_TAPE_PREPARE definitions // -#define TAPE_UNLOAD 0 -#define TAPE_UNLOAD_IMMED 1 -#define TAPE_TENSION 2 -#define TAPE_LOCK 3 -#define TAPE_UNLOCK 4 +#define TAPE_LOAD 0L +#define TAPE_LOAD_IMMED 1L +#define TAPE_UNLOAD 2L +#define TAPE_UNLOAD_IMMED 3L +#define TAPE_TENSION 4L +#define TAPE_TENSION_IMMED 5L +#define TAPE_LOCK 6L +#define TAPE_UNLOCK 7L typedef struct _TAPE_PREPARE { DWORD Operation; @@ -2008,10 +2010,14 @@ typedef struct _TAPE_PREPARE { // IOCTL_TAPE_WRITE_MARKS definitions // -#define TAPE_SETMARKS 0 -#define TAPE_SHORT_FILEMARKS 1 -#define TAPE_LONG_FILEMARKS 2 -#define TAPE_SEQUENTIAL_FILEMARKS 3 +#define TAPE_SETMARKS 0L +#define TAPE_SETMARKS_IMMED 1L +#define TAPE_FILEMARKS 2L +#define TAPE_FILEMARKS_IMMED 3L +#define TAPE_SHORT_FILEMARKS 4L +#define TAPE_SHORT_FILEMARKS_IMMED 5L +#define TAPE_LONG_FILEMARKS 6L +#define TAPE_LONG_FILEMARKS_IMMED 7L typedef struct _TAPE_WRITE_MARKS { DWORD Type; @@ -2019,112 +2025,922 @@ typedef struct _TAPE_WRITE_MARKS { } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS; // -// IOCTL_TAPE_GET/SET_POSITION definitions +// IOCTL_TAPE_GET_POSITION definitions // -#define TAPE_REWIND (TAPE_SEQUENTIAL_FILEMARKS+1) -#define TAPE_REWIND_IMMED (TAPE_SEQUENTIAL_FILEMARKS+2) -#define TAPE_END_OF_DATA (TAPE_SEQUENTIAL_FILEMARKS+3) -#define TAPE_ABSOLUTE_BLOCK (TAPE_SEQUENTIAL_FILEMARKS+4) -#define TAPE_RELATIVE_BLOCK (TAPE_SEQUENTIAL_FILEMARKS+5) -#define TAPE_BLOCKS (TAPE_SEQUENTIAL_FILEMARKS+6) +#define TAPE_ABSOLUTE_POSITION 0L +#define TAPE_LOGICAL_POSITION 1L -typedef struct _TAPE_POSITION { +typedef struct _TAPE_GET_POSITION { + DWORD Type; + DWORD Partition; + DWORD OffsetLow; + DWORD OffsetHigh; +} TAPE_GET_POSITION, *PTAPE_GET_POSITION; + +// +// IOCTL_TAPE_SET_POSITION definitions +// + +#define TAPE_REWIND 0L +#define TAPE_REWIND_IMMED 1L +#define TAPE_ABSOLUTE_BLOCK 2L +#define TAPE_ABSOLUTE_BLOCK_IMMED 3L +#define TAPE_LOGICAL_BLOCK 4L +#define TAPE_LOGICAL_BLOCK_IMMED 5L +#define TAPE_SPACE_END_OF_DATA 6L +#define TAPE_SPACE_RELATIVE_BLOCKS 7L +#define TAPE_SPACE_FILEMARKS 8L +#define TAPE_SPACE_SEQUENTIAL_FMKS 9L +#define TAPE_SPACE_SETMARKS 10L +#define TAPE_SPACE_SEQUENTIAL_SMKS 11L + +typedef struct _TAPE_SET_POSITION { DWORD Method; DWORD Partition; - LARGE_INTEGER Position; -} TAPE_POSITION, *PTAPE_POSITION; + DWORD OffsetLow; + DWORD OffsetHigh; +} TAPE_SET_POSITION, *PTAPE_SET_POSITION; + +// +// IOCTL_TAPE_GET_DRIVE_PARAMS definitions +// // -// IOCTL_TAPE_GET_MEDIA_PARAMS definitions +// Definitions for FeaturesLow parameter +// + +#define TAPE_DRIVE_FIXED 0x00000001 +#define TAPE_DRIVE_SELECT 0x00000002 +#define TAPE_DRIVE_INITIATOR 0x00000004 + +#define TAPE_DRIVE_ERASE_SHORT 0x00000010 +#define TAPE_DRIVE_ERASE_LONG 0x00000020 +#define TAPE_DRIVE_ERASE_BOP_ONLY 0x00000040 + +#define TAPE_DRIVE_TAPE_CAPACITY 0x00000100 +#define TAPE_DRIVE_TAPE_REMAINING 0x00000200 +#define TAPE_DRIVE_FIXED_BLOCK 0x00000400 +#define TAPE_DRIVE_VARIABLE_BLOCK 0x00000800 +#define TAPE_DRIVE_WRITE_PROTECT 0x00001000 + +#define TAPE_DRIVE_ECC 0x00010000 +#define TAPE_DRIVE_COMPRESSION 0x00020000 +#define TAPE_DRIVE_PADDING 0x00040000 +#define TAPE_DRIVE_REPORT_SMKS 0x00080000 + +#define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000 +#define TAPE_DRIVE_GET_LOGICAL_BLK 0x00200000 + +// +// Definitions for FeaturesHigh parameter +// + +#define TAPE_DRIVE_LOAD_UNLOAD 0x00000001 +#define TAPE_DRIVE_TENSION 0x00000002 +#define TAPE_DRIVE_LOCK_UNLOCK 0x00000004 + +#define TAPE_DRIVE_SET_BLOCK_SIZE 0x00000010 + +#define TAPE_DRIVE_SET_ECC 0x00000100 +#define TAPE_DRIVE_SET_COMPRESSION 0x00000200 +#define TAPE_DRIVE_SET_PADDING 0x00000400 +#define TAPE_DRIVE_SET_REPORT_SMKS 0x00000800 + +#define TAPE_DRIVE_ABSOLUTE_BLK 0x00001000 +#define TAPE_DRIVE_ABS_BLK_IMMED 0x00002000 +#define TAPE_DRIVE_LOGICAL_BLK 0x00004000 +#define TAPE_DRIVE_LOG_BLK_IMMED 0x00008000 +#define TAPE_DRIVE_END_OF_DATA 0x00010000 +#define TAPE_DRIVE_RELATIVE_BLKS 0x00020000 +#define TAPE_DRIVE_FILEMARKS 0x00040000 +#define TAPE_DRIVE_SEQUENTIAL_FMKS 0x00080000 +#define TAPE_DRIVE_SETMARKS 0x00100000 +#define TAPE_DRIVE_SEQUENTIAL_SMKS 0x00200000 +#define TAPE_DRIVE_REVERSE_POSITION 0x00400000 + +#define TAPE_DRIVE_WRITE_SETMARKS 0x01000000 +#define TAPE_DRIVE_WRITE_FILEMARKS 0x02000000 +#define TAPE_DRIVE_WRITE_SHORT_FMKS 0x04000000 +#define TAPE_DRIVE_WRITE_LONG_FMKS 0x08000000 + +typedef struct _TAPE_GET_DRIVE_PARAMETERS { + BOOLEAN ECC; + BOOLEAN Compression; + BOOLEAN DataPadding; + BOOLEAN ReportSetmarks; + DWORD DefaultBlockSize; + DWORD MaximumBlockSize; + DWORD MinimumBlockSize; + DWORD MaximumPartitionCount; + DWORD FeaturesLow; + DWORD FeaturesHigh; +} TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS; + +// +// IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions +// + +typedef struct _TAPE_SET_DRIVE_PARAMETERS { + BOOLEAN ECC; + BOOLEAN Compression; + BOOLEAN DataPadding; + BOOLEAN ReportSetmarks; +} TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS; + +// +// IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions // typedef struct _TAPE_GET_MEDIA_PARAMETERS { - LARGE_INTEGER Capacity; - LARGE_INTEGER Remaining; - DWORD Type; - DWORD Density; + DWORD CapacityLow; + DWORD CapacityHigh; + DWORD RemainingLow; + DWORD RemainingHigh; DWORD BlockSize; - DWORD Partitions; + DWORD PartitionCount; BOOLEAN WriteProtected; } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS; - // -// IOCTL_TAPE_SET_MEDIA_PARAMS definitions +// IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions // typedef struct _TAPE_SET_MEDIA_PARAMETERS { DWORD BlockSize; } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS; +// +// IOCTL_TAPE_CREATE_PARTITION definitions +// + +#define TAPE_FIXED_PARTITIONS 0L +#define TAPE_SELECT_PARTITIONS 1L +#define TAPE_INITIATOR_PARTITIONS 2L + +typedef struct _TAPE_CREATE_PARTITION { + DWORD Method; + DWORD Count; + DWORD Size; +} TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION; + + // -// IOCTL_TAPE_GET_DRIVE_PARAMS definitions +// Image Format // -#define TAPE_DRIVE_SETMARKS 0x10000000 -#define TAPE_DRIVE_SHORT_FILEMARKS 0x20000000 -#define TAPE_DRIVE_LONG_FILEMARKS 0x40000000 - -#define TAPE_DRIVE_ECC 0x00000001 -#define TAPE_DRIVE_COMPRESSION 0x00000002 -#define TAPE_DRIVE_PADDING 0x00000004 - -typedef struct _TAPE_DRIVE_PARAMETERS { - DWORD Capabilities; - DWORD CurrentSettings; -} TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS; +#ifndef RC_INVOKED +#pragma pack (1) +#endif // !RC_INVOKED + +#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ +#define IMAGE_OS2_SIGNATURE 0x454E // NE +#define IMAGE_OS2_SIGNATURE_LE 0x454C // LE +#define IMAGE_NT_SIGNATURE 0x00004550 // PE00 + +typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header + WORD e_magic; // Magic number + WORD e_cblp; // Bytes on last page of file + WORD e_cp; // Pages in file + WORD e_crlc; // Relocations + WORD e_cparhdr; // Size of header in paragraphs + WORD e_minalloc; // Minimum extra paragraphs needed + WORD e_maxalloc; // Maximum extra paragraphs needed + WORD e_ss; // Initial (relative) SS value + WORD e_sp; // Initial SP value + WORD e_csum; // Checksum + WORD e_ip; // Initial IP value + WORD e_cs; // Initial (relative) CS value + WORD e_lfarlc; // File address of relocation table + WORD e_ovno; // Overlay number + WORD e_res[4]; // Reserved words + WORD e_oemid; // OEM identifier (for e_oeminfo) + WORD e_oeminfo; // OEM information; e_oemid specific + WORD e_res2[10]; // Reserved words + LONG e_lfanew; // File address of new exe header + } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; + +typedef struct _IMAGE_OS2_HEADER { // OS/2 .EXE header + WORD ne_magic; // Magic number + CHAR ne_ver; // Version number + CHAR ne_rev; // Revision number + WORD ne_enttab; // Offset of Entry Table + WORD ne_cbenttab; // Number of bytes in Entry Table + LONG ne_crc; // Checksum of whole file + WORD ne_flags; // Flag word + WORD ne_autodata; // Automatic data segment number + WORD ne_heap; // Initial heap allocation + WORD ne_stack; // Initial stack allocation + LONG ne_csip; // Initial CS:IP setting + LONG ne_sssp; // Initial SS:SP setting + WORD ne_cseg; // Count of file segments + WORD ne_cmod; // Entries in Module Reference Table + WORD ne_cbnrestab; // Size of non-resident name table + WORD ne_segtab; // Offset of Segment Table + WORD ne_rsrctab; // Offset of Resource Table + WORD ne_restab; // Offset of resident name table + WORD ne_modtab; // Offset of Module Reference Table + WORD ne_imptab; // Offset of Imported Names Table + LONG ne_nrestab; // Offset of Non-resident Names Table + WORD ne_cmovent; // Count of movable entries + WORD ne_align; // Segment alignment shift count + WORD ne_cres; // Count of resource segments + BYTE ne_exetyp; // Target Operating system + BYTE ne_flagsothers; // Other .EXE flags + WORD ne_pretthunks; // offset to return thunks + WORD ne_psegrefbytes; // offset to segment ref. bytes + WORD ne_swaparea; // Minimum code swap area size + WORD ne_expver; // Expected Windows version number + } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER; + +// +// File header format. +// + +typedef struct _IMAGE_FILE_HEADER { + WORD Machine; + WORD NumberOfSections; + DWORD TimeDateStamp; + DWORD PointerToSymbolTable; + DWORD NumberOfSymbols; + WORD SizeOfOptionalHeader; + WORD Characteristics; +} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; + +#define IMAGE_SIZEOF_FILE_HEADER 20 + +#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. +#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). +#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. +#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. +#define IMAGE_FILE_MINIMAL_OBJECT 0x0010 // Reserved. +#define IMAGE_FILE_UPDATE_OBJECT 0x0020 // Reserved. +#define IMAGE_FILE_16BIT_MACHINE 0x0040 // 16 bit word machine. +#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. +#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. +#define IMAGE_FILE_PATCH 0x0400 // Reserved. +#define IMAGE_FILE_SYSTEM 0x1000 // System File. +#define IMAGE_FILE_DLL 0x2000 // File is a DLL. +#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. + +#define IMAGE_FILE_MACHINE_UNKNOWN 0 +#define IMAGE_FILE_MACHINE_I860 0x14d // Intel 860. +#define IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. +#define IMAGE_FILE_MACHINE_R3000 0x162 // MIPS little-endian, 0540 big-endian +#define IMAGE_FILE_MACHINE_R4000 0x166 // MIPS little-endian + +// +// Directory format. +// + +typedef struct _IMAGE_DATA_DIRECTORY { + DWORD VirtualAddress; + DWORD Size; +} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; + +#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 + +// +// Optional header format. +// + +typedef struct _IMAGE_OPTIONAL_HEADER { + // + // Standard fields. + // + + WORD Magic; + BYTE MajorLinkerVersion; + BYTE MinorLinkerVersion; + DWORD SizeOfCode; + DWORD SizeOfInitializedData; + DWORD SizeOfUninitializedData; + DWORD AddressOfEntryPoint; + DWORD BaseOfCode; + DWORD BaseOfData; + + // + // NT additional fields. + // + + DWORD ImageBase; + DWORD SectionAlignment; + DWORD FileAlignment; + WORD MajorOperatingSystemVersion; + WORD MinorOperatingSystemVersion; + WORD MajorImageVersion; + WORD MinorImageVersion; + WORD MajorSubsystemVersion; + WORD MinorSubsystemVersion; + DWORD Reserved1; + DWORD SizeOfImage; + DWORD SizeOfHeaders; + DWORD CheckSum; + WORD Subsystem; + WORD DllCharacteristics; + DWORD SizeOfStackReserve; + DWORD SizeOfStackCommit; + DWORD SizeOfHeapReserve; + DWORD SizeOfHeapCommit; + DWORD AddressOfTlsIndex; + DWORD NumberOfRvaAndSizes; + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; +} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER; + +#define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28 +#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224 + +typedef struct _IMAGE_NT_HEADERS { + DWORD Signature; + IMAGE_FILE_HEADER FileHeader; + IMAGE_OPTIONAL_HEADER OptionalHeader; +} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS; + +#define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER) \ + ((DWORD)ntheader + \ + FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) + \ + ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader \ + )) + + +// Subsystem Values + +#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem. +#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem. +#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem. +#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. +#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. + +// Dll Characteristics + +#define IMAGE_LIBRARY_PROCESS_INIT 1 // Dll has a process initialization routine. +#define IMAGE_LIBRARY_PROCESS_TERM 2 // Dll has a thread termination routine. +#define IMAGE_LIBRARY_THREAD_INIT 4 // Dll has a thread initialization routine. +#define IMAGE_LIBRARY_THREAD_TERM 8 // Dll has a thread termination routine. + +// Directory Entries + +#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory +#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory +#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory +#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory +#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory +#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table +#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory +#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String +#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) +#define IMAGE_DIRECTORY_ENTRY_THREAD_SPACE 9 // Thread Local Storage +#define IMAGE_DIRECTORY_ENTRY_CALLBACKS 10 // Other interesting entrypoints + +// +// Section header format. +// + +#define IMAGE_SIZEOF_SHORT_NAME 8 + +typedef struct _IMAGE_SECTION_HEADER { + BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; + union { + DWORD PhysicalAddress; + DWORD VirtualSize; + } Misc; + DWORD VirtualAddress; + DWORD SizeOfRawData; + DWORD PointerToRawData; + DWORD PointerToRelocations; + DWORD PointerToLinenumbers; + WORD NumberOfRelocations; + WORD NumberOfLinenumbers; + DWORD Characteristics; +} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER; + +#define IMAGE_SIZEOF_SECTION_HEADER 40 + +#define IMAGE_SCN_TYPE_REGULAR 0x00000000 // +#define IMAGE_SCN_TYPE_DUMMY 0x00000001 // Reserved. +#define IMAGE_SCN_TYPE_NO_LOAD 0x00000002 // +#define IMAGE_SCN_TYPE_GROUPED 0x00000004 // Used for 16-bit offset code. +#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Specifies if section should not be padded to next boundary. +#define IMAGE_SCN_TYPE_COPY 0x00000010 // Reserved. +#define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code. +#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data. +#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data. +#define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. +#define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. +#define IMAGE_SCN_LNK_OVERLAY 0x00000400 // Section contains an overlay. +#define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. +#define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat. +#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded. +#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable. +#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable. +#define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable. +#define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable. +#define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable. +#define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable. // -// IOCTL_TAPE_SET_DRIVE_PARAMS definitions +// Symbol format. // -#define TAPE_DRIVE_SETMARKS 0x10000000 -#define TAPE_DRIVE_SHORT_FILEMARKS 0x20000000 -#define TAPE_DRIVE_LONG_FILEMARKS 0x40000000 +typedef struct _IMAGE_SYMBOL { + union { + BYTE ShortName[8]; + struct { + DWORD Short; // if 0, use LongName + DWORD Long; // offset into string table + } Name; + PBYTE LongName[2]; + } N; + DWORD Value; + SHORT SectionNumber; + WORD Type; + BYTE StorageClass; + BYTE NumberOfAuxSymbols; +} IMAGE_SYMBOL; +typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL; + +#define IMAGE_SIZEOF_SYMBOL 18 + +// +// Section values. +// +// Symbols have a section number of the section in which they are +// defined. Otherwise, section numbers have the following meanings: +// + +#define IMAGE_SYM_UNDEFINED (SHORT)0 // Symbol is undefined or is common. +#define IMAGE_SYM_ABSOLUTE (SHORT)-1 // Symbol is an absolute value. +#define IMAGE_SYM_DEBUG (SHORT)-2 // Symbol is a special debug item. + +// +// Type (fundamental) values. +// + +#define IMAGE_SYM_TYPE_NULL 0 // no type. +#define IMAGE_SYM_TYPE_VOID 1 // +#define IMAGE_SYM_TYPE_CHAR 2 // type character. +#define IMAGE_SYM_TYPE_SHORT 3 // type short integer. +#define IMAGE_SYM_TYPE_INT 4 // +#define IMAGE_SYM_TYPE_LONG 5 // +#define IMAGE_SYM_TYPE_FLOAT 6 // +#define IMAGE_SYM_TYPE_DOUBLE 7 // +#define IMAGE_SYM_TYPE_STRUCT 8 // +#define IMAGE_SYM_TYPE_UNION 9 // +#define IMAGE_SYM_TYPE_ENUM 10 // enumeration. +#define IMAGE_SYM_TYPE_MOE 11 // member of enumeration. +#define IMAGE_SYM_TYPE_BYTE 12 // +#define IMAGE_SYM_TYPE_WORD 13 // +#define IMAGE_SYM_TYPE_UINT 14 // +#define IMAGE_SYM_TYPE_DWORD 15 // + +// +// Type (derived) values. +// + +#define IMAGE_SYM_DTYPE_NULL 0 // no derived type. +#define IMAGE_SYM_DTYPE_POINTER 1 // pointer. +#define IMAGE_SYM_DTYPE_FUNCTION 2 // function. +#define IMAGE_SYM_DTYPE_ARRAY 3 // array. + +// +// Storage classes. +// + +#define IMAGE_SYM_CLASS_END_OF_FUNCTION (BYTE )-1 +#define IMAGE_SYM_CLASS_NULL 0 +#define IMAGE_SYM_CLASS_AUTOMATIC 1 +#define IMAGE_SYM_CLASS_EXTERNAL 2 +#define IMAGE_SYM_CLASS_STATIC 3 +#define IMAGE_SYM_CLASS_REGISTER 4 +#define IMAGE_SYM_CLASS_EXTERNAL_DEF 5 +#define IMAGE_SYM_CLASS_LABEL 6 +#define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 +#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 +#define IMAGE_SYM_CLASS_ARGUMENT 9 +#define IMAGE_SYM_CLASS_STRUCT_TAG 10 +#define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 +#define IMAGE_SYM_CLASS_UNION_TAG 12 +#define IMAGE_SYM_CLASS_TYPE_DEFINITION 13 +#define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 +#define IMAGE_SYM_CLASS_ENUM_TAG 15 +#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 +#define IMAGE_SYM_CLASS_REGISTER_PARAM 17 +#define IMAGE_SYM_CLASS_BIT_FIELD 18 +#define IMAGE_SYM_CLASS_BLOCK 100 +#define IMAGE_SYM_CLASS_FUNCTION 101 +#define IMAGE_SYM_CLASS_END_OF_STRUCT 102 +#define IMAGE_SYM_CLASS_FILE 103 +// new +#define IMAGE_SYM_CLASS_SECTION 104 +#define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 + +// type packing constants + +#define N_BTMASK 017 +#define N_TMASK 060 +#define N_TMASK1 0300 +#define N_TMASK2 0360 +#define N_BTSHFT 4 +#define N_TSHIFT 2 + +// MACROS + +// Basic Type of x +#define BTYPE(x) ((x) & N_BTMASK) + +// Is x a pointer? +#ifndef ISPTR +#define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT)) +#endif -#define TAPE_DRIVE_SHORT_ERASE 0x00000010 -#define TAPE_DRIVE_LONG_ERASE 0x00000020 +// Is x a function? +#ifndef ISFCN +#define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT)) +#endif -#define TAPE_DRIVE_ECC 0x00000001 -#define TAPE_DRIVE_COMPRESSION 0x00000002 -#define TAPE_DRIVE_PADDING 0x00000004 +// Is x an array? -typedef struct _TAPE_SET_DRIVE_PARAMETERS { - DWORD CurrentSettings; -} TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS; +#ifndef ISARY +#define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT)) +#endif + +// Is x a structure, union, or enumeration TAG? +#ifndef ISTAG +#define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG) +#endif + +#ifndef INCREF +#define INCREF(x) ((((x)&~N_BTMASK)<>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) +#endif // -// IOCTL_TAPE_GET_STATUS definitions +// Auxiliary entry format. // -#define TAPE_STATUS_DEVICE_READY 0x00000000 -#define TAPE_STATUS_NO_MEDIA 0x00000001 -#define TAPE_STATUS_WRITE_PROTECTED 0x00000002 -#define TAPE_STATUS_MEDIA_CHANGED 0x00000004 -#define TAPE_STATUS_RESET_DETECTED 0x00000008 -#define TAPE_STATUS_BEGINNING_OF_MEDIA 0x00000010 -#define TAPE_STATUS_END_OF_MEDIA 0x00000020 -#define TAPE_STATUS_DEVICE_NOT_READY 0x00000800 - -typedef struct _TAPE_STATUS { - DWORD Status; -} TAPE_STATUS, *PTAPE_STATUS; +typedef union _IMAGE_AUX_SYMBOL { + struct { + DWORD TagIndex; // struct, union, or enum tag index + union { + struct { + WORD Linenumber; // declaration line number + WORD Size; // size of struct, union, or enum + } LnSz; + DWORD TotalSize; + } Misc; + union { + struct { // if ISFCN, tag, or .bb + DWORD PointerToLinenumber; + DWORD PointerToNextFunction; + } Function; + struct { // if ISARY, up to 4 dimen. + WORD Dimension[4]; + } Array; + } FcnAry; + WORD TvIndex; // tv index + } Sym; + struct { + BYTE Name[IMAGE_SIZEOF_SYMBOL]; + } File; + struct { + DWORD Length; // section length + WORD NumberOfRelocations; // number of relocation entries + WORD NumberOfLinenumbers; // number of line numbers + DWORD CheckSum; // checksum for communal + SHORT Number; // section number to associate with + BYTE Selection; // communal selection type + } Section; +} IMAGE_AUX_SYMBOL; +typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL; + +#define IMAGE_SIZEOF_AUX_SYMBOL 18 // -// IOCTL_TAPE_CREATE_PARTITION definitions +// Communal selection types. // -#define TAPE_PARTITION_FIXED 0 -#define TAPE_PARTITION_SELECT 1 -#define TAPE_PARTITION_INITIATOR 2 +#define IMAGE_COMDAT_SELECT_UNKNOWN 0 +#define IMAGE_COMDAT_SELECT_NODUPLICATES 1 +#define IMAGE_COMDAT_SELECT_ANY 2 +#define IMAGE_COMDAT_SELECT_SAME_SIZE 3 +#define IMAGE_COMDAT_SELECT_EXACT_MATCH 4 +#define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 -typedef struct _TAPE_CREATE_PARTITION_PARAMETERS { - DWORD Type; - DWORD Count; - DWORD Size[1]; // variable length array, 0 terminates -} TAPE_CREATE_PARTITION_PARAMETERS, *PTAPE_CREATE_PARTITION_PARAMETERS; +#define IMAGE_WEAK_EXTERN_SEARCH_UNKNOWN 0 +#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 +#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 + + +// +// Relocation format. +// + +typedef struct _IMAGE_RELOCATION { + DWORD VirtualAddress; + DWORD SymbolTableIndex; + WORD Type; +} IMAGE_RELOCATION; +typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION; + +#define IMAGE_SIZEOF_RELOCATION 10 + +// +// I860 relocation types. +// + +#define IMAGE_REL_I860_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define IMAGE_REL_I860_DIR32 06 // Direct 32-bit reference to the symbols virtual address +#define IMAGE_REL_I860_DIR32NB 07 +#define IMAGE_REL_I860_SECTION 012 +#define IMAGE_REL_I860_SECREL 013 +#define IMAGE_REL_I860_PAIR 034 +#define IMAGE_REL_I860_HIGH 036 +#define IMAGE_REL_I860_LOW0 037 +#define IMAGE_REL_I860_LOW1 040 +#define IMAGE_REL_I860_LOW2 041 +#define IMAGE_REL_I860_LOW3 042 +#define IMAGE_REL_I860_LOW4 043 +#define IMAGE_REL_I860_SPLIT0 044 +#define IMAGE_REL_I860_SPLIT1 045 +#define IMAGE_REL_I860_SPLIT2 046 +#define IMAGE_REL_I860_HIGHADJ 047 +#define IMAGE_REL_I860_BRADDR 050 + +// +// I386 relocation types. +// + +#define IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address +#define IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address +#define IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address +#define IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included +#define IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address +#define IMAGE_REL_I386_SECTION 012 +#define IMAGE_REL_I386_SECREL 013 +#define IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address + +// +// MIPS relocation types. +// + +#define IMAGE_REL_MIPS_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define IMAGE_REL_MIPS_REFHALF 01 +#define IMAGE_REL_MIPS_REFWORD 02 +#define IMAGE_REL_MIPS_JMPADDR 03 +#define IMAGE_REL_MIPS_REFHI 04 +#define IMAGE_REL_MIPS_REFLO 05 +#define IMAGE_REL_MIPS_GPREL 06 +#define IMAGE_REL_MIPS_LITERAL 07 +#define IMAGE_REL_MIPS_SECTION 012 +#define IMAGE_REL_MIPS_SECREL 013 +#define IMAGE_REL_MIPS_REFWORDNB 042 +#define IMAGE_REL_MIPS_PAIR 045 + +// +// Based relocation format. +// + +typedef struct _IMAGE_BASE_RELOCATION { + DWORD VirtualAddress; + DWORD SizeOfBlock; +// WORD TypeOffset[1]; +} IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION; + +#define IMAGE_SIZEOF_BASE_RELOCATION 8 + +// +// Based relocation types. +// + +#define IMAGE_REL_BASED_ABSOLUTE 0 +#define IMAGE_REL_BASED_HIGH 1 +#define IMAGE_REL_BASED_LOW 2 +#define IMAGE_REL_BASED_HIGHLOW 3 +#define IMAGE_REL_BASED_HIGHADJ 4 +#define IMAGE_REL_BASED_MIPS_JMPADDR 5 +#define IMAGE_REL_BASED_I860_BRADDR 6 +#define IMAGE_REL_BASED_I860_SPLIT 7 + +// +// Line number format. +// + +typedef struct _IMAGE_LINENUMBER { + union { + DWORD SymbolTableIndex; // Symbol table index of function name if Linenumber is 0. + DWORD VirtualAddress; // Virtual address of line number. + } Type; + WORD Linenumber; // Line number. +} IMAGE_LINENUMBER; +typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER; + +#define IMAGE_SIZEOF_LINENUMBER 6 + +// +// Archive format. +// + +#define IMAGE_ARCHIVE_START_SIZE 8 +#define IMAGE_ARCHIVE_START "!\n" +#define IMAGE_ARCHIVE_END "`\n" +#define IMAGE_ARCHIVE_PAD "\n" +#define IMAGE_ARCHIVE_LINKER_MEMBER "/ " +#define IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " + +typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER { + BYTE Name[16]; // File member name - `/' terminated. + BYTE Date[12]; // File member date - decimal. + BYTE UserID[6]; // File member user id - decimal. + BYTE GroupID[6]; // File member group id - decimal. + BYTE Mode[8]; // File member mode - octal. + BYTE Size[10]; // File member size - decimal. + BYTE EndHeader[2]; // String to end header. +} IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER; + +#define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 + +// +// DLL support. +// + +// +// Export Format +// + +typedef struct _IMAGE_EXPORT_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD Name; + DWORD Base; + DWORD NumberOfFunctions; + DWORD NumberOfNames; + PDWORD *AddressOfFunctions; + PDWORD *AddressOfNames; + PWORD *AddressOfNameOrdinals; +} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY; + +// +// Import Format +// + +typedef struct _IMAGE_IMPORT_BY_NAME { + WORD Hint; + BYTE Name[1]; +} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME; + +typedef struct _IMAGE_THUNK_DATA { + union { + PDWORD Function; + DWORD Ordinal; + PIMAGE_IMPORT_BY_NAME AddressOfData; + } u1; +} IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA; + +#define IMAGE_ORDINAL_FLAG 0x80000000 +#define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0) +#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) + +typedef struct _IMAGE_IMPORT_DESCRIPTOR { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD Name; + PIMAGE_THUNK_DATA FirstThunk; +} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; + +// +// Resource Format. +// + +// +// Resource directory consists of two counts, following by a variable length +// array of directory entries. The first count is the number of entries at +// beginning of the array that have actual names associated with each entry. +// The entries are in ascending order, case insensitive strings. The second +// count is the number of entries that immediately follow the named entries. +// This second count identifies the number of entries that have 31-bit integer +// Ids as their name. These entries are also sorted in ascending order. +// +// This structure allows fast lookup by either name or number, but for any +// given resource entry only one form of lookup is supported, not both. +// This is consistant with the syntax of the .RC file and the .RES file. +// + +typedef struct _IMAGE_RESOURCE_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + WORD NumberOfNamedEntries; + WORD NumberOfIdEntries; +// IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; +} IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY; + +#define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000 +#define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000 + +// +// Each directory contains the 32-bit Name of the entry and an offset, +// relative to the beginning of the resource directory of the data associated +// with this directory entry. If the name of the entry is an actual text +// string instead of an integer Id, then the high order bit of the name field +// is set to one and the low order 31-bits are an offset, relative to the +// beginning of the resource directory of the string, which is of type +// IMAGE_RESOURCE_DIRECTORY_STRING. Otherwise the high bit is clear and the +// low-order 31-bits are the integer Id that identify this resource directory +// entry. If the directory entry is yet another resource directory (i.e. a +// subdirectory), then the high order bit of the offset field will be +// set to indicate this. Otherwise the high bit is clear and the offset +// field points to a resource data entry. +// + +typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY { + DWORD Name; + DWORD OffsetToData; +} IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY; + +// +// For resource directory entries that have actual string names, the Name +// field of the directory entry points to an object of the following type. +// All of these string objects are stored together after the last resource +// directory entry and before the first resource data object. This minimizes +// the impact of these variable length objects on the alignment of the fixed +// size directory entry objects. +// + +typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING { + WORD Length; + CHAR NameString[ 1 ]; +} IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING; + + +typedef struct _IMAGE_RESOURCE_DIR_STRING_U { + WORD Length; + WCHAR NameString[ 1 ]; +} IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U; + + +// +// Each resource data entry describes a leaf node in the resource directory +// tree. It contains an offset, relative to the beginning of the resource +// directory of the data for the resource, a size field that gives the number +// of bytes of data at that offset, a CodePage that should be used when +// decoding code point values within the resource data. Typically for new +// applications the code page would be the unicode code page. +// + +typedef struct _IMAGE_RESOURCE_DATA_ENTRY { + DWORD OffsetToData; + DWORD Size; + DWORD CodePage; + DWORD Reserved; +} IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY; + +// +// Debug Format +// + +typedef struct _IMAGE_DEBUG_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD Type; + DWORD SizeOfData; + DWORD AddressOfRawData; + DWORD PointerToRawData; +} IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY; + +#define IMAGE_DEBUG_TYPE_UNKNOWN 0 +#define IMAGE_DEBUG_TYPE_COFF 1 +#define IMAGE_DEBUG_TYPE_CODEVIEW 2 + +typedef struct _IMAGE_DEBUG_INFO { + DWORD NumberOfSymbols; + DWORD LvaToFirstSymbol; + DWORD NumberOfLinenumbers; + DWORD LvaToFirstLinenumber; + DWORD RvaToFirstByteOfCode; + DWORD RvaToLastByteOfCode; + DWORD RvaToFirstByteOfData; + DWORD RvaToLastByteOfData; +} IMAGE_DEBUG_INFO, *PIMAGE_DEBUG_INFO; + +#ifndef RC_INVOKED +#pragma pack () +#endif // !RC_INVOKED + +// +// End Image Format +// #endif // _WINNT_