--- mstools/h/winnt.h 2018/08/09 18:20:25 1.1.1.2 +++ mstools/h/winnt.h 2018/08/09 18:22:55 1.1.1.4 @@ -1,6 +1,6 @@ -/*++ BUILD Version: 0078 // Increment this if a change has global effects +/*++ BUILD Version: 0093 Increment this if a change has global effects -Copyright (c) 1990-1992 Microsoft Corporation +Copyright (c) 1990-1993 Microsoft Corporation Module Name: @@ -18,20 +18,31 @@ Revision History: #ifndef _WINNT_ #define _WINNT_ +#ifdef __cplusplus +extern "C" { +#endif + +#include #define ANYSIZE_ARRAY 1 -#ifdef MIPS -#define UNALIGNED __unaligned -#else -#define UNALIGNED -#endif +#if defined(_MIPS_) || defined(_ALPHA_) +#define UNALIGNED __unaligned +#else +#define UNALIGNED +#endif typedef void *PVOID; +#if (_MSC_VER >= 800) +#define NTAPI __stdcall +#else +#define _cdecl +#define NTAPI +#endif // // Basics // #ifndef VOID -#define VOID void +#define VOID void typedef char CHAR; typedef short SHORT; typedef long LONG; @@ -41,7 +52,7 @@ typedef long LONG; // UNICODE (Wide Character) types // -typedef unsigned short WCHAR; // wc, 16-bit UNICODE character +typedef wchar_t WCHAR; // wc, 16-bit UNICODE character typedef WCHAR *PWCHAR; typedef WCHAR *LPWCH, *PWCH; @@ -62,38 +73,56 @@ typedef CHAR *NPSTR; typedef CHAR *LPSTR, *PSTR; typedef CONST CHAR *LPCSTR, *PCSTR; - // // Neutral ANSI/UNICODE types and macros // #ifdef UNICODE -typedef WCHAR TCHAR; + +#ifndef _TCHAR_DEFINED +typedef WCHAR TCHAR, *PTCHAR; +typedef WCHAR TBYTE , *PTBYTE ; +#define _TCHAR_DEFINED +#endif /* !_TCHAR_DEFINED */ + typedef LPWSTR LPTCH, PTCH; typedef LPWSTR PTSTR, LPTSTR; typedef LPCWSTR LPCTSTR; typedef LPWSTR LP; -#define TEXT(quote) L##quote -#else +#define __TEXT(quote) L##quote + +#else /* UNICODE */ + +#ifndef _TCHAR_DEFINED typedef char TCHAR, *PTCHAR; +typedef unsigned char TBYTE , *PTBYTE ; +#define _TCHAR_DEFINED +#endif /* !_TCHAR_DEFINED */ + typedef LPSTR LPTCH, PTCH; typedef LPSTR PTSTR, LPTSTR; typedef LPCSTR LPCTSTR; -#define TEXT(quote) quote -#endif +#define __TEXT(quote) quote + +#endif /* UNICODE */ +#define TEXT(quote) __TEXT(quote) typedef SHORT *PSHORT; typedef LONG *PLONG; -#ifdef STRICT -typedef const void *HANDLE; -#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef const struct name##__ *name - -#else -typedef PVOID HANDLE; -#define DECLARE_HANDLE(name) typedef HANDLE name -#endif -typedef HANDLE *PHANDLE; + +#ifdef STRICT +typedef void *HANDLE; +#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name +#else +typedef PVOID HANDLE; +#define DECLARE_HANDLE(name) typedef HANDLE name +#endif +typedef HANDLE *PHANDLE; + typedef char CCHAR; +typedef DWORD LCID; +typedef PDWORD PLCID; +typedef WORD LANGID; /*lint -e624 */ /*lint +e624 */ #define APPLICATION_ERROR_MASK 0x20000000 @@ -102,20 +131,71 @@ typedef char CCHAR; #define ERROR_SEVERITY_WARNING 0x80000000 #define ERROR_SEVERITY_ERROR 0xC0000000 +#if defined(MIDL_PASS) +typedef double LONGLONG; +typedef double DWORDLONG; +#else +#if defined(_M_IX86) +typedef double LONGLONG; +typedef double DWORDLONG; +#else +typedef double LONGLONG; +typedef double DWORDLONG; +#endif +#endif + +typedef LONGLONG *PLONGLONG; +typedef DWORDLONG *PDWORDLONG; + +#if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { - DWORD LowPart; - LONG HighPart; +#else // MIDL_PASS +typedef union _LARGE_INTEGER { +#if defined(_CFRONT_PASS_) + struct { + DWORD LowPart; + LONG HighPart; + } u; +#else + struct { + DWORD LowPart; + LONG HighPart; + }; +#endif +#endif //MIDL_PASS + LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; + +#if defined(MIDL_PASS) typedef struct _ULARGE_INTEGER { - DWORD LowPart; - DWORD HighPart; +#else // MIDL_PASS +typedef union _ULARGE_INTEGER { +#if defined(_CFRONT_PASS_) + struct { + DWORD LowPart; + DWORD HighPart; + } u; +#else + struct { + DWORD LowPart; + DWORD HighPart; + }; +#endif +#endif //MIDL_PASS + DWORDLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; -typedef LARGE_INTEGER LUID; -typedef LUID *PLUID; +// end_ntminiport + +// +// Locally Unique Identifier +// + +typedef LARGE_INTEGER LUID, *PLUID; + #define UNICODE_NULL ((WCHAR)0) -typedef CCHAR BOOLEAN; +typedef BYTE BOOLEAN; typedef BOOLEAN *PBOOLEAN; // // Doubly linked list structure. Can be used as either a list head, or @@ -145,6 +225,181 @@ typedef struct _SINGLE_LIST_ENTRY { #define MAXBYTE 0xff #define MAXWORD 0xffff #define MAXDWORD 0xffffffff +// +// Calculate the byte offset of a field in a structure of type type. +// + +#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) + + +// +// Calculate the address of the base of the structure given its type, and an +// address of a field within the structure. +// + +#define CONTAINING_RECORD(address, type, field) ((type *)( \ + (PCHAR)(address) - \ + (PCHAR)(&((type *)0)->field))) + +/* + * Language IDs. + * + * The following two combinations of primary language ID and + * sublanguage ID have special semantics: + * + * Primary Language ID Sublanguage ID Result + * ------------------- --------------- ------------------------ + * LANG_NEUTRAL SUBLANG_NEUTRAL Language neutral + * LANG_NEUTRAL SUBLANG_DEFAULT User default language + * LANG_NEUTRAL SUBLANG_SYS_DEFAULT System default language + */ + +/* + * Primary language IDs. + */ +#define LANG_NEUTRAL 0x00 + +#define LANG_ALBANIAN 0x1c +#define LANG_ARABIC 0x01 +#define LANG_BAHASA 0x21 +#define LANG_BULGARIAN 0x02 +#define LANG_CATALAN 0x03 +#define LANG_CHINESE 0x04 +#define LANG_CZECH 0x05 +#define LANG_DANISH 0x06 +#define LANG_DUTCH 0x13 +#define LANG_ENGLISH 0x09 +#define LANG_FINNISH 0x0b +#define LANG_FRENCH 0x0c +#define LANG_GERMAN 0x07 +#define LANG_GREEK 0x08 +#define LANG_HEBREW 0x0d +#define LANG_HUNGARIAN 0x0e +#define LANG_ICELANDIC 0x0f +#define LANG_ITALIAN 0x10 +#define LANG_JAPANESE 0x11 +#define LANG_KOREAN 0x12 +#define LANG_NORWEGIAN 0x14 +#define LANG_POLISH 0x15 +#define LANG_PORTUGUESE 0x16 +#define LANG_RHAETO_ROMAN 0x17 +#define LANG_ROMANIAN 0x18 +#define LANG_RUSSIAN 0x19 +#define LANG_SERBO_CROATIAN 0x1a +#define LANG_SLOVAK 0x1b +#define LANG_SPANISH 0x0a +#define LANG_SWEDISH 0x1d +#define LANG_THAI 0x1e +#define LANG_TURKISH 0x1f +#define LANG_URDU 0x20 + +/* + * Sublanguage IDs. + * + * The name immediately following SUBLANG_ dictates which primary + * language ID that sublanguage ID can be combined with to form a + * valid language ID. + */ +#define SUBLANG_NEUTRAL 0x00 /* language neutral */ +#define SUBLANG_DEFAULT 0x01 /* user default */ +#define SUBLANG_SYS_DEFAULT 0x02 /* system default */ + +#define SUBLANG_CHINESE_SIMPLIFIED 0x02 /* Chinese (Simplified) */ +#define SUBLANG_CHINESE_TRADITIONAL 0x01 /* Chinese (Traditional) */ +#define SUBLANG_DUTCH 0x01 /* Dutch */ +#define SUBLANG_DUTCH_BELGIAN 0x02 /* Dutch (Belgian) */ +#define SUBLANG_ENGLISH_US 0x01 /* English (USA) */ +#define SUBLANG_ENGLISH_UK 0x02 /* English (UK) */ +#define SUBLANG_ENGLISH_AUS 0x03 /* English (Australian) */ +#define SUBLANG_ENGLISH_CAN 0x04 /* English (Canadian) */ +#define SUBLANG_ENGLISH_NZ 0x05 /* English (New Zealand) */ +#define SUBLANG_ENGLISH_EIRE 0x06 /* English (Irish) */ +#define SUBLANG_FRENCH 0x01 /* French */ +#define SUBLANG_FRENCH_BELGIAN 0x02 /* French (Belgian) */ +#define SUBLANG_FRENCH_CANADIAN 0x03 /* French (Canadian) */ +#define SUBLANG_FRENCH_SWISS 0x04 /* French (Swiss) */ +#define SUBLANG_GERMAN 0x01 /* German */ +#define SUBLANG_GERMAN_SWISS 0x02 /* German (Swiss) */ +#define SUBLANG_GERMAN_AUSTRIAN 0x03 /* German (Austrian) */ +#define SUBLANG_ITALIAN 0x01 /* Italian */ +#define SUBLANG_ITALIAN_SWISS 0x02 /* Italian (Swiss) */ +#define SUBLANG_NORWEGIAN_BOKMAL 0x01 /* Norwegian (Bokmal) */ +#define SUBLANG_NORWEGIAN_NYNORSK 0x02 /* Norwegian (Nynorsk) */ +#define SUBLANG_PORTUGUESE 0x02 /* Portuguese */ +#define SUBLANG_PORTUGUESE_BRAZILIAN 0x01 /* Portuguese (Brazilian) */ +#define SUBLANG_SERBO_CROATIAN_CYRILLIC 0x02 /* Serbo-Croatian (Cyrillic) */ +#define SUBLANG_SERBO_CROATIAN_LATIN 0x01 /* Croato-Serbian (Latin) */ +#define SUBLANG_SPANISH 0x01 /* Spanish (Castilian) */ +#define SUBLANG_SPANISH_MEXICAN 0x02 /* Spanish (Mexican) */ +#define SUBLANG_SPANISH_MODERN 0x03 /* Spanish (Modern) */ + +/* + * Sorting IDs. + * + */ +#define SORT_DEFAULT 0x0 /* sorting default */ + + +/* + * A language ID is a 16 bit value which is the combination of a + * primary language ID and a secondary language ID. The bits are + * allocated as follows: + * + * +-----------------------+-------------------------+ + * | Sublanguage ID | Primary Language ID | + * +-----------------------+-------------------------+ + * 15 10 9 0 bit + * + * + * Language ID creation/extraction macros: + * + * MAKELANGID - construct language id from a primary language id and + * a sublanguage id. + * PRIMARYLANGID - extract primary language id from a language id. + * SUBLANGID - extract sublanguage id from a language id. + */ +#define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p)) +#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff) +#define SUBLANGID(lgid) ((WORD )(lgid) >> 10) + + +/* + * A locale ID is a 32 bit value which is the combination of a + * language ID, a sort ID, and a reserved area. The bits are + * allocated as follows: + * + * +-------------+---------+-------------------------+ + * | Reserved | Sort ID | Language ID | + * +-------------+---------+-------------------------+ + * 31 20 19 16 15 0 bit + * + * + * Locale ID creation/extraction macros: + * + * MAKELCID - construct locale id from a language id and a sort id. + * LANGIDFROMLCID - extract language id from a locale id. + * SORTIDFROMLCID - extract sort id from a locale id. + */ +#define NLS_VALID_LOCALE_MASK 0x000fffff + +#define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \ + ((DWORD)((WORD )(lgid))))) +#define LANGIDFROMLCID(lcid) ((WORD )(lcid)) +#define SORTIDFROMLCID(lcid) ((WORD )((((DWORD)(lcid)) & NLS_VALID_LOCALE_MASK) >> 16)) + + +/* + * Default System and User IDs for language and locale. + */ +#define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT)) +#define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)) + +#define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT)) +#define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT)) + + + +// begin_ntminiport // // Macros used to eliminate compiler warning generated when formal @@ -196,7 +451,7 @@ typedef struct _SINGLE_LIST_ENTRY { #endif // lint or _lint -/*lint -e767 */ +/*lint -save -e767 */ #define STATUS_WAIT_0 ((DWORD )0x00000000L) #define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L) #define STATUS_USER_APC ((DWORD )0x000000C0L) @@ -206,6 +461,8 @@ typedef struct _SINGLE_LIST_ENTRY { #define STATUS_BREAKPOINT ((DWORD )0x80000003L) #define STATUS_SINGLE_STEP ((DWORD )0x80000004L) #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L) +#define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L) +#define STATUS_NO_MEMORY ((DWORD )0xC0000017L) #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL) #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L) #define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L) @@ -222,13 +479,403 @@ typedef struct _SINGLE_LIST_ENTRY { #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L) #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL) #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL) -/*lint +e767 */ +/*lint -restore */ #define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended typedef DWORD KSPIN_LOCK; -#ifdef i386 +#ifdef _ALPHA_ + +// begin_ntddk begin_nthal +// +// The following flags control the contents of the CONTEXT structure. +// + +#define CONTEXT_PORTABLE_32BIT 0x00100000 +#define CONTEXT_ALPHA 0x00020000 + +#define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L) +#define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L) +#define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) + +#ifndef _PORTABLE_32BIT_CONTEXT + +// +// Context Frame +// +// This frame has a several purposes: 1) it is used as an argument to +// NtContinue, 2) it is used to construct a call frame for APC delivery, +// 3) it is used to construct a call frame for exception dispatching +// in user mode, 4) it is used in the user level thread creation +// routines, and 5) it is used to to pass thread state to debuggers. +// +// N.B. Because this record is used as a call frame, it must be EXACTLY +// a multiple of 16 bytes in length. +// +// There are two variations of the context structure. This is the real one. +// + +typedef struct _CONTEXT { + + // + // This section is specified/returned if the ContextFlags word contains + // the flag CONTEXT_FLOATING_POINT. + // + + DWORDLONG FltF0; + DWORDLONG FltF1; + DWORDLONG FltF2; + DWORDLONG FltF3; + DWORDLONG FltF4; + DWORDLONG FltF5; + DWORDLONG FltF6; + DWORDLONG FltF7; + DWORDLONG FltF8; + DWORDLONG FltF9; + DWORDLONG FltF10; + DWORDLONG FltF11; + DWORDLONG FltF12; + DWORDLONG FltF13; + DWORDLONG FltF14; + DWORDLONG FltF15; + DWORDLONG FltF16; + DWORDLONG FltF17; + DWORDLONG FltF18; + DWORDLONG FltF19; + DWORDLONG FltF20; + DWORDLONG FltF21; + DWORDLONG FltF22; + DWORDLONG FltF23; + DWORDLONG FltF24; + DWORDLONG FltF25; + DWORDLONG FltF26; + DWORDLONG FltF27; + DWORDLONG FltF28; + DWORDLONG FltF29; + DWORDLONG FltF30; + DWORDLONG FltF31; + + // + // This section is specified/returned if the ContextFlags word contains + // the flag CONTEXT_INTEGER. + // + // N.B. The registers gp, sp, and ra are defined in this section, but are + // considered part of the control context rather than part of the integer + // context. + // + + DWORDLONG IntV0; // $0: return value register, v0 + DWORDLONG IntT0; // $1: temporary registers, t0 - t7 + DWORDLONG IntT1; // $2: + DWORDLONG IntT2; // $3: + DWORDLONG IntT3; // $4: + DWORDLONG IntT4; // $5: + DWORDLONG IntT5; // $6: + DWORDLONG IntT6; // $7: + DWORDLONG IntT7; // $8: + DWORDLONG IntS0; // $9: nonvolatile registers, s0 - s5 + DWORDLONG IntS1; // $10: + DWORDLONG IntS2; // $11: + DWORDLONG IntS3; // $12: + DWORDLONG IntS4; // $13: + DWORDLONG IntS5; // $14: + DWORDLONG IntFp; // $15: frame pointer register, fp/s6 + DWORDLONG IntA0; // $16: argument registers, a0 - a5 + DWORDLONG IntA1; // $17: + DWORDLONG IntA2; // $18: + DWORDLONG IntA3; // $19: + DWORDLONG IntA4; // $20: + DWORDLONG IntA5; // $21: + DWORDLONG IntT8; // $22: temporary registers, t8 - t11 + DWORDLONG IntT9; // $23: + DWORDLONG IntT10; // $24: + DWORDLONG IntT11; // $25: + DWORDLONG IntRa; // $26: return address register, ra + DWORDLONG IntT12; // $27: temporary register, t12 + DWORDLONG IntAt; // $28: assembler temp register, at + DWORDLONG IntGp; // $29: global pointer register, gp + DWORDLONG IntSp; // $30: stack pointer register, sp + DWORDLONG IntZero; // $31: zero register, zero + + // + // This section is specified/returned if the ContextFlags word contains + // the flag CONTEXT_FLOATING_POINT. + // + + DWORDLONG Fpcr; // floating point control register + DWORDLONG SoftFpcr; // software extension to FPCR + + // + // This section is specified/returned if the ContextFlags word contains + // the flag CONTEXT_CONTROL. + // + // N.B. The registers gp, sp, and ra are defined in the integer section, + // but are considered part of the control context rather than part of + // the integer context. + // + + DWORDLONG Fir; // (fault instruction) continuation address + DWORD Psr; // processor status + + // + // The flags values within this flag control the contents of + // a CONTEXT record. + // + // If the context record is used as an input parameter, then + // for each portion of the context record controlled by a flag + // whose value is set, it is assumed that that portion of the + // context record contains valid context. If the context record + // is being used to modify a thread's context, then only that + // portion of the threads context will be modified. + // + // If the context record is used as an IN OUT parameter to capture + // the context of a thread, then only those portions of the thread's + // context corresponding to set flags will be returned. + // + // The context record is never used as an OUT only parameter. + // + + DWORD ContextFlags; + DWORD Fill[4]; // padding for 16-byte stack frame alignment + +} CONTEXT, *PCONTEXT; + +#else + +// +// 32-bit Context Frame +// +// This alternate version of the Alpha context structure parallels that +// of MIPS and IX86 in style for the first 64 entries: 32-bit machines +// can operate on the fields, and a value declared as a pointer to an +// array of int's can be used to index into the fields. This makes life +// with windbg and ntsd vastly easier. +// +// There are two parts: the first contains the lower 32-bits of each +// element in the 64-bit definition above. The second part contains +// the upper 32-bits of each 64-bit element above. +// +// The names in the first part are identical to the 64-bit names. +// The second part names are prefixed with "High". +// +// 1st half: at 32 bits each, (containing the low parts of 64-bit values) +// 32 floats, 32 ints, fpcrs, fir, psr, contextflags +// 2nd half: at 32 bits each +// 32 floats, 32 ints, fpcrs, fir, fill +// +// There is no external support for the 32-bit version of the context +// structure. It is only used internally by windbg and ntsd. +// +// This structure must be the same size as the 64-bit version above. +// + +typedef struct _CONTEXT { + + DWORD FltF0; + DWORD FltF1; + DWORD FltF2; + DWORD FltF3; + DWORD FltF4; + DWORD FltF5; + DWORD FltF6; + DWORD FltF7; + DWORD FltF8; + DWORD FltF9; + DWORD FltF10; + DWORD FltF11; + DWORD FltF12; + DWORD FltF13; + DWORD FltF14; + DWORD FltF15; + DWORD FltF16; + DWORD FltF17; + DWORD FltF18; + DWORD FltF19; + DWORD FltF20; + DWORD FltF21; + DWORD FltF22; + DWORD FltF23; + DWORD FltF24; + DWORD FltF25; + DWORD FltF26; + DWORD FltF27; + DWORD FltF28; + DWORD FltF29; + DWORD FltF30; + DWORD FltF31; + + DWORD IntV0; // $0: return value register, v0 + DWORD IntT0; // $1: temporary registers, t0 - t7 + DWORD IntT1; // $2: + DWORD IntT2; // $3: + DWORD IntT3; // $4: + DWORD IntT4; // $5: + DWORD IntT5; // $6: + DWORD IntT6; // $7: + DWORD IntT7; // $8: + DWORD IntS0; // $9: nonvolatile registers, s0 - s5 + DWORD IntS1; // $10: + DWORD IntS2; // $11: + DWORD IntS3; // $12: + DWORD IntS4; // $13: + DWORD IntS5; // $14: + DWORD IntFp; // $15: frame pointer register, fp/s6 + DWORD IntA0; // $16: argument registers, a0 - a5 + DWORD IntA1; // $17: + DWORD IntA2; // $18: + DWORD IntA3; // $19: + DWORD IntA4; // $20: + DWORD IntA5; // $21: + DWORD IntT8; // $22: temporary registers, t8 - t11 + DWORD IntT9; // $23: + DWORD IntT10; // $24: + DWORD IntT11; // $25: + DWORD IntRa; // $26: return address register, ra + DWORD IntT12; // $27: temporary register, t12 + DWORD IntAt; // $28: assembler temp register, at + DWORD IntGp; // $29: global pointer register, gp + DWORD IntSp; // $30: stack pointer register, sp + DWORD IntZero; // $31: zero register, zero + + DWORD Fpcr; // floating point control register + DWORD SoftFpcr; // software extension to FPCR + + DWORD Fir; // (fault instruction) continuation address + + DWORD Psr; // processor status + DWORD ContextFlags; + + // + // Beginning of the "second half". + // The name "High" parallels the HighPart of a LargeInteger. + // + + DWORD HighFltF0; + DWORD HighFltF1; + DWORD HighFltF2; + DWORD HighFltF3; + DWORD HighFltF4; + DWORD HighFltF5; + DWORD HighFltF6; + DWORD HighFltF7; + DWORD HighFltF8; + DWORD HighFltF9; + DWORD HighFltF10; + DWORD HighFltF11; + DWORD HighFltF12; + DWORD HighFltF13; + DWORD HighFltF14; + DWORD HighFltF15; + DWORD HighFltF16; + DWORD HighFltF17; + DWORD HighFltF18; + DWORD HighFltF19; + DWORD HighFltF20; + DWORD HighFltF21; + DWORD HighFltF22; + DWORD HighFltF23; + DWORD HighFltF24; + DWORD HighFltF25; + DWORD HighFltF26; + DWORD HighFltF27; + DWORD HighFltF28; + DWORD HighFltF29; + DWORD HighFltF30; + DWORD HighFltF31; + + DWORD HighIntV0; // $0: return value register, v0 + DWORD HighIntT0; // $1: temporary registers, t0 - t7 + DWORD HighIntT1; // $2: + DWORD HighIntT2; // $3: + DWORD HighIntT3; // $4: + DWORD HighIntT4; // $5: + DWORD HighIntT5; // $6: + DWORD HighIntT6; // $7: + DWORD HighIntT7; // $8: + DWORD HighIntS0; // $9: nonvolatile registers, s0 - s5 + DWORD HighIntS1; // $10: + DWORD HighIntS2; // $11: + DWORD HighIntS3; // $12: + DWORD HighIntS4; // $13: + DWORD HighIntS5; // $14: + DWORD HighIntFp; // $15: frame pointer register, fp/s6 + DWORD HighIntA0; // $16: argument registers, a0 - a5 + DWORD HighIntA1; // $17: + DWORD HighIntA2; // $18: + DWORD HighIntA3; // $19: + DWORD HighIntA4; // $20: + DWORD HighIntA5; // $21: + DWORD HighIntT8; // $22: temporary registers, t8 - t11 + DWORD HighIntT9; // $23: + DWORD HighIntT10; // $24: + DWORD HighIntT11; // $25: + DWORD HighIntRa; // $26: return address register, ra + DWORD HighIntT12; // $27: temporary register, t12 + DWORD HighIntAt; // $28: assembler temp register, at + DWORD HighIntGp; // $29: global pointer register, gp + DWORD HighIntSp; // $30: stack pointer register, sp + DWORD HighIntZero; // $31: zero register, zero + + DWORD HighFpcr; // floating point control register + DWORD HighSoftFpcr; // software extension to FPCR + DWORD HighFir; // processor status + + double DoNotUseThisField; // to force quadword structure alignment + DWORD HighFill[2]; // padding for 16-byte stack frame alignment + +} CONTEXT, *PCONTEXT; + +// +// These should name the fields in the _PORTABLE_32BIT structure +// that overlay the Psr and ContextFlags in the normal structure. +// + +#define _QUAD_PSR_OFFSET HighSoftFpcr +#define _QUAD_FLAGS_OFFSET HighFir + +#endif // _PORTABLE_32BIT_CONTEXT + +// end_ntddk end_nthal + +#endif // _ALPHA_ + + +#ifdef _ALPHA_ + +VOID +__jump_unwind ( + PVOID VirtualFramePointer, + PVOID TargetPc + ); + +#endif // _ALPHA_ + + +#ifdef _X86_ + +// +// Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver +// writers to not leave them inadvertantly in their code. +// + +#if !defined(MIDL_PASS) +#if !defined(_CFRONT_PASS_) +#if !defined(RC_INVOKED) + +#pragma warning(disable:4164) // disable C4164 warning so that apps that + // build with /Od don't get weird errors ! +#pragma function(_enable) +#pragma function(_disable) + +#pragma warning(default:4164) // reenable C4164 warning + +#endif +#endif +#endif + // // Define the size of the 80387 save area, which is in the context frame. @@ -358,7 +1005,10 @@ typedef struct _CONTEXT { typedef CONTEXT *PCONTEXT; -#endif // i386 +// begin_ntminiport + +#endif //_X86_ + typedef struct _LDT_ENTRY { WORD LimitLow; @@ -386,18 +1036,18 @@ typedef struct _LDT_ENTRY { } LDT_ENTRY, *PLDT_ENTRY; -#ifdef MIPS +#if defined(_MIPS_) +// begin_ntddk begin_nthal // // The following flags control the contents of the CONTEXT structure. // -#define CONTEXT_R3000 0x00010000 // this assumes that r3000 and -#define CONTEXT_R4000 0x00010000 // r4000 have identical context records +#define CONTEXT_R4000 0x00010000 // r4000 context -#define CONTEXT_CONTROL (CONTEXT_R3000 | 0x00000001L) -#define CONTEXT_FLOATING_POINT (CONTEXT_R3000 | 0x00000002L) -#define CONTEXT_INTEGER (CONTEXT_R3000 | 0x00000004L) +#define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001L) +#define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002L) +#define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004L) #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER) @@ -550,10 +1200,12 @@ typedef struct _CONTEXT { DWORD Fill[2]; } CONTEXT, *PCONTEXT; +// end_ntddk end_nthal + #endif // MIPS -#ifdef MIPS +#if defined(_MIPS_) VOID __jump_unwind ( @@ -612,11 +1264,17 @@ typedef struct _EXCEPTION_POINTERS { #define THREAD_SET_THREAD_TOKEN (0x0080) #define THREAD_IMPERSONATE (0x0100) #define THREAD_DIRECT_IMPERSONATION (0x0200) +// begin_ntddk + #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \ 0x3FF) + +// end_ntddk #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,25 +1283,18 @@ 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 +#define PROCESSOR_INTEL_PENTIUM 586 #define PROCESSOR_INTEL_860 860 #define PROCESSOR_MIPS_R2000 2000 #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 +#define PROCESSOR_ALPHA_21064 21064 typedef struct _MEMORY_BASIC_INFORMATION { PVOID BaseAddress; @@ -668,12 +1319,86 @@ typedef struct _MEMORY_BASIC_INFORMATION #define PAGE_NOACCESS 0x01 #define PAGE_READONLY 0x02 #define PAGE_READWRITE 0x04 +#define PAGE_WRITECOPY 0x08 +#define PAGE_EXECUTE 0x10 +#define PAGE_EXECUTE_READ 0x20 +#define PAGE_EXECUTE_READWRITE 0x40 +#define PAGE_EXECUTE_WRITECOPY 0x80 +#define PAGE_GUARD 0x100 +#define PAGE_NOCACHE 0x200 #define MEM_COMMIT 0x1000 #define MEM_RESERVE 0x2000 #define MEM_DECOMMIT 0x4000 #define MEM_RELEASE 0x8000 #define MEM_FREE 0x10000 #define MEM_PRIVATE 0x20000 +#define MEM_MAPPED 0x40000 +#define MEM_TOP_DOWN 0x100000 +#define SEC_FILE 0x800000 +#define SEC_IMAGE 0x1000000 +#define SEC_RESERVE 0x4000000 +#define SEC_COMMIT 0x8000000 +#define SEC_NOCACHE 0x10000000 +#define MEM_IMAGE SEC_IMAGE + +// +// Define access rights to files and directories +// + +// +// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in +// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these +// constants *MUST* always be in sync. +// The values are redefined in devioctl.h because they must be available to +// both DOS and NT. +// + +#define FILE_READ_DATA ( 0x0001 ) // file & pipe +#define FILE_LIST_DIRECTORY ( 0x0001 ) // directory + +#define FILE_WRITE_DATA ( 0x0002 ) // file & pipe +#define FILE_ADD_FILE ( 0x0002 ) // directory + +#define FILE_APPEND_DATA ( 0x0004 ) // file +#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory +#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe + +#define FILE_READ_EA ( 0x0008 ) // file & directory + +#define FILE_WRITE_EA ( 0x0010 ) // file & directory + +#define FILE_EXECUTE ( 0x0020 ) // file +#define FILE_TRAVERSE ( 0x0020 ) // directory + +#define FILE_DELETE_CHILD ( 0x0040 ) // directory + +#define FILE_READ_ATTRIBUTES ( 0x0080 ) // all + +#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all + +#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) + + +#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\ + FILE_READ_DATA |\ + FILE_READ_ATTRIBUTES |\ + FILE_READ_EA |\ + SYNCHRONIZE) + + +#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + FILE_WRITE_DATA |\ + FILE_WRITE_ATTRIBUTES |\ + FILE_WRITE_EA |\ + FILE_APPEND_DATA |\ + SYNCHRONIZE) + + +#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + FILE_READ_ATTRIBUTES |\ + FILE_EXECUTE |\ + SYNCHRONIZE) + #define FILE_SHARE_READ 0x00000001 #define FILE_SHARE_WRITE 0x00000002 #define FILE_ATTRIBUTE_READONLY 0x00000001 @@ -691,9 +1416,12 @@ typedef struct _MEMORY_BASIC_INFORMATION #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 +#define MAILSLOT_NO_MESSAGE ((DWORD)-1) +#define MAILSLOT_WAIT_FOREVER ((DWORD)-1) #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; @@ -730,13 +1458,14 @@ typedef PVOID PSID; // // but to make life simple for programmer's we'll allow them to specify // a desired access mask by simply OR'ing together mulitple single rights -// and treat an access mask as a ulong. For example +// and treat an access mask as a DWORD. For example // // DesiredAccess = DELETE | READ_CONTROL // // So we'll declare ACCESS_MASK as DWORD // +// begin_ntddk begin_nthal typedef DWORD ACCESS_MASK; typedef ACCESS_MASK *PACCESS_MASK; @@ -747,6 +1476,7 @@ typedef ACCESS_MASK *PACCESS_MASK; //////////////////////////////////////////////////////////////////////// +// begin_ntddk begin_nthal // // The following are masks for the predefined standard access types // @@ -813,14 +1543,21 @@ typedef GENERIC_MAPPING *PGENERIC_MAPPIN // +#ifndef RC_INVOKED +#pragma pack(4) +#endif + typedef struct _LUID_AND_ATTRIBUTES { LUID Luid; DWORD Attributes; } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES; - typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; +#ifndef RC_INVOKED +#pragma pack() +#endif + //////////////////////////////////////////////////////////////////////// // // @@ -866,11 +1603,6 @@ typedef struct _SID { } SID, *PISID; - - - - - #define SID_REVISION (1) // Current revision level #define SID_MAX_SUB_AUTHORITIES (15) #define SID_RECOMMENDED_SUB_AUTHORITIES (1) // Will change to around 6 @@ -897,12 +1629,6 @@ typedef SID_AND_ATTRIBUTES SID_AND_ATTRI typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY; - - - - - - ///////////////////////////////////////////////////////////////////////////// // // @@ -914,12 +1640,15 @@ typedef SID_AND_ATTRIBUTES_ARRAY *PSID_A // Creator Owner ID S-1-3-0 // // Creator Group ID S-1-3-1 // // // +// (Non-unique IDs) S-1-4 // +// // ///////////////////////////////////////////////////////////////////////////// #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0} #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2} #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3} +#define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4} #define SECURITY_NULL_RID (0x00000000L) #define SECURITY_WORLD_RID (0x00000000L) @@ -942,10 +1671,13 @@ typedef SID_AND_ATTRIBUTES_ARRAY *PSID_A // Batch S-1-5-3 // // Interactive S-1-5-4 // // Service S-1-5-6 // +// AnonymousLogon S-1-5-7 (aka null logon session) // // // // (Logon IDs) S-1-5-5-X-Y // // // -// (Built-in domain) s-1-5-20 // +// (NT non-unique IDs) S-1-5-0x15-... // +// // +// (Built-in domain) s-1-5-0x20 // // // ///////////////////////////////////////////////////////////////////////////// @@ -957,12 +1689,15 @@ typedef SID_AND_ATTRIBUTES_ARRAY *PSID_A #define SECURITY_BATCH_RID (0x00000003L) #define SECURITY_INTERACTIVE_RID (0x00000004L) #define SECURITY_SERVICE_RID (0x00000006L) +#define SECURITY_ANONYMOUS_LOGON_RID (0x00000007L) #define SECURITY_LOGON_IDS_RID (0x00000005L) #define SECURITY_LOGON_IDS_RID_COUNT (3L) #define SECURITY_LOCAL_SYSTEM_RID (0x00000012L) +#define SECURITY_NT_NON_UNIQUE (0x00000015L) + #define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L) @@ -1014,7 +1749,7 @@ typedef SID_AND_ATTRIBUTES_ARRAY *PSID_A // Use #999 here (0x3E7 = 999) // -#define SYSTEM_LUID {0x0, 0x3E7} +#define SYSTEM_LUID { 0x3E7, 0x0 } @@ -1072,6 +1807,7 @@ typedef SID_AND_ATTRIBUTES_ARRAY *PSID_A // AceCount is the number of ACES in the ACL. // +// begin_ntddk // This is the *current* ACL revision #define ACL_REVISION (2) @@ -1091,6 +1827,8 @@ typedef struct _ACL { } ACL; typedef ACL *PACL; +// end_ntddk + // // The structure of an ACE is a common ace header followed by ace type // specific data. Pictorally the structure of the common ace header is @@ -1264,6 +2002,7 @@ typedef ACL_SIZE_INFORMATION *PACL_SIZE_ // This is an opaque data structure. // +// begin_ntddk // // Current security descriptor revision value // @@ -1271,6 +2010,8 @@ typedef ACL_SIZE_INFORMATION *PACL_SIZE_ #define SECURITY_DESCRIPTOR_REVISION (1) #define SECURITY_DESCRIPTOR_REVISION1 (1) +// end_ntddk + // // Minimum length, in bytes, needed to build a security descriptor // (NOTE: This must manually be kept consistent with the) @@ -1421,6 +2162,7 @@ typedef struct _SECURITY_DESCRIPTOR { //////////////////////////////////////////////////////////////////////// +// begin_ntddk begin_nthal // // Privilege attributes // @@ -1429,16 +2171,12 @@ typedef struct _SECURITY_DESCRIPTOR { #define SE_PRIVILEGE_ENABLED (0x00000002L) #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L) - - - // // Privilege Set Control flags // #define PRIVILEGE_SET_ALL_NECESSARY (1) - // // Privilege Set - This is defined for a privilege set of one. // If more than one privilege is needed, then this structure @@ -1461,29 +2199,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") //////////////////////////////////////////////////////////////////// @@ -1493,6 +2231,7 @@ typedef struct _PRIVILEGE_SET { // // //////////////////////////////////////////////////////////////////// +// begin_ntddk begin_nthal // // Impersonation Level // @@ -1512,7 +2251,7 @@ typedef enum _SECURITY_IMPERSONATION_LEV #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation - +// end_nthal // // Security Tracking Mode // @@ -1590,8 +2329,7 @@ typedef struct _SE_IMPERSONATION_STATE { TOKEN_ADJUST_GROUPS |\ TOKEN_ADJUST_DEFAULT) -#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ - TOKEN_IMPERSONATE) +#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE) // @@ -1696,16 +2434,993 @@ 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 { -#if DEVL + +// +// Image Format +// + +#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_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file +#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 +#define IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP + +// +// 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 LoaderFlags; + 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. + +// +// Loader Flags +// + +#define IMAGE_LOADER_FLAGS_BREAK_ON_LOAD 0x00000001 +#define IMAGE_LOADER_FLAGS_DEBUG_ON_LOAD 0x00000002 + + +// 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_TLS 9 // TLS Directory +#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory + +// +// 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 // Reserved. +#define IMAGE_SCN_TYPE_GROUPED 0x00000004 // Used for 16-bit offset code. +#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. +#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_ALIGN_1BYTES 0x00100000 // +#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 // +#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 // +#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 // +#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified. +#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 // +#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 // + +#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. + +// +// Symbol format. +// + +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 + +// Is x a function? +#ifndef ISFCN +#define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT)) +#endif + +// Is x an array? + +#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 + +// +// Auxiliary entry format. +// + +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 + +// +// Communal selection types. +// + +#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 + +#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 + +// +// Alpha Relocation types. +// + +#define IMAGE_REL_ALPHA_ABSOLUTE 0x0 +#define IMAGE_REL_ALPHA_REFLONG 0x1 +#define IMAGE_REL_ALPHA_REFQUAD 0x2 +#define IMAGE_REL_ALPHA_GPREL32 0x3 +#define IMAGE_REL_ALPHA_LITERAL 0x4 +#define IMAGE_REL_ALPHA_LITUSE 0x5 +#define IMAGE_REL_ALPHA_GPDISP 0x6 +#define IMAGE_REL_ALPHA_BRADDR 0x7 +#define IMAGE_REL_ALPHA_HINT 0x8 +#define IMAGE_REL_ALPHA_INLINE_REFLONG 0x9 +#define IMAGE_REL_ALPHA_REFHI 0xA +#define IMAGE_REL_ALPHA_REFLO 0xB +#define IMAGE_REL_ALPHA_PAIR 0xC +#define IMAGE_REL_ALPHA_MATCH 0xD +#define IMAGE_REL_ALPHA_SECTION 0xE +#define IMAGE_REL_ALPHA_SECREL 0xF +#define IMAGE_REL_ALPHA_REFLONGNB 0x10 + +// +// 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; + DWORD ForwarderChain; + DWORD Name; + PIMAGE_THUNK_DATA FirstThunk; +} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR; + +// +// Thread Local Storage +// + +typedef VOID +(NTAPI *PIMAGE_TLS_CALLBACK) ( + PVOID DllHandle, + DWORD Reason, + PVOID Reserved + ); + +typedef struct _IMAGE_TLS_DIRECTORY { + DWORD StartAddressOfRawData; + DWORD EndAddressOfRawData; + PDWORD AddressOfIndex; + PIMAGE_TLS_CALLBACK *AddressOfCallBacks; + DWORD SizeOfZeroFill; + DWORD Characteristics; +} IMAGE_TLS_DIRECTORY, *PIMAGE_TLS_DIRECTORY; + + +// +// 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; + +// +// Load Configuration Directory Entry +// + +typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY { + DWORD Characteristics; + DWORD TimeDateStamp; + WORD MajorVersion; + WORD MinorVersion; + DWORD GlobalFlagsClear; + DWORD GlobalFlagsSet; + DWORD CriticalSectionDefaultTimeout; + DWORD DeCommitFreeBlockThreshold; + DWORD DeCommitTotalFreeThreshold; + DWORD Reserved[ 8 ]; +} IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY; + + +// +// Function table entry format for MIPS/ALPHA images. Function table is +// pointed to by the IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry. +// This definition duplicates ones in ntmips.h and ntalpha.h for use +// by portable image file mungers. +// + +typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY { + DWORD BeginAddress; + DWORD EndAddress; + PVOID ExceptionHandler; + PVOID HandlerData; + DWORD PrologEndAddress; +} IMAGE_RUNTIME_FUNCTION_ENTRY, *PIMAGE_RUNTIME_FUNCTION_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 +#define IMAGE_DEBUG_TYPE_FPO 3 +#define IMAGE_DEBUG_TYPE_MISC 4 +#define IMAGE_DEBUG_TYPE_EXCEPTION 5 +#define IMAGE_DEBUG_TYPE_FIXUP 6 +#define IMAGE_DEBUG_TYPE_RESERVED6 7 +#define IMAGE_DEBUG_TYPE_RESERVED7 8 + +typedef struct _IMAGE_COFF_SYMBOLS_HEADER { + DWORD NumberOfSymbols; + DWORD LvaToFirstSymbol; + DWORD NumberOfLinenumbers; + DWORD LvaToFirstLinenumber; + DWORD RvaToFirstByteOfCode; + DWORD RvaToLastByteOfCode; + DWORD RvaToFirstByteOfData; + DWORD RvaToLastByteOfData; +} IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER; + +#define FRAME_FPO 0 +#define FRAME_TRAP 1 +#define FRAME_TSS 2 + +typedef struct _FPO_DATA { + DWORD ulOffStart; // offset 1st byte of function code + DWORD cbProcSize; // # bytes in function + DWORD cdwLocals; // # bytes in locals/4 + WORD cdwParams; // # bytes in params/4 + WORD cbProlog : 8; // # bytes in prolog + WORD cbRegs : 3; // # regs saved + WORD fHasSEH : 1; // TRUE if SEH in func + WORD fUseBP : 1; // TRUE if EBP has been allocated + WORD reserved : 1; // reserved for future use + WORD cbFrame : 2; // frame type +} FPO_DATA, *PFPO_DATA; +#define SIZEOF_RFPO_DATA 16 + + +#define IMAGE_DEBUG_MISC_EXENAME 1 + +typedef struct _IMAGE_DEBUG_MISC { + DWORD DataType; // type of misc data, see defines + DWORD Length; // total length of record, rounded to four + // byte multiple. + BOOLEAN Unicode; // TRUE if data is unicode string + BYTE Reserved[ 3 ]; + BYTE Data[ 1 ]; // Actual data +} IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC; + + +// +// Debugging information can be stripped from an image file and placed +// in a separate .DBG file, whose file name part is the same as the +// image file name part (e.g. symbols for CMD.EXE could be stripped +// and placed in CMD.DBG). This is indicated by the IMAGE_FILE_DEBUG_STRIPPED +// flag in the Characteristics field of the file header. The beginning of +// the .DBG file contains the following structure which captures certain +// information from the image file. This allows a debug to proceed even if +// the original image file is not accessable. This header is followed by +// zero of more IMAGE_SECTION_HEADER structures, followed by zero or more +// IMAGE_DEBUG_DIRECTORY structures. The latter structures and those in +// the image file contain file offsets relative to the beginning of the +// .DBG file. +// +// If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure +// is left in the image file, but not mapped. This allows a debugger to +// compute the name of the .DBG file, from the name of the image in the +// IMAGE_DEBUG_MISC structure. +// + +typedef struct _IMAGE_SEPARATE_DEBUG_HEADER { + WORD Signature; + WORD Flags; + WORD Machine; + WORD Characteristics; + DWORD TimeDateStamp; + DWORD CheckSum; + DWORD ImageBase; + DWORD SizeOfImage; + DWORD NumberOfSections; + DWORD ExportedNamesSize; + DWORD DebugDirectorySize; + DWORD Reserved[ 3 ]; +} IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER; + +#define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944 + +#ifndef RC_INVOKED +#pragma pack () +#endif // !RC_INVOKED + +// +// End Image Format +// + +// +// for move macros +// +#include +#define HEAP_NO_SERIALIZE 0x00000001 +#define HEAP_GROWABLE 0x00000002 +#define HEAP_GENERATE_EXCEPTIONS 0x00000004 +#define HEAP_ZERO_MEMORY 0x00000008 +#define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010 +#define HEAP_TAIL_CHECKING_ENABLED 0x00000020 +#define HEAP_FREE_CHECKING_ENABLED 0x00000040 +#define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080 +#ifdef _M_IX86 +#define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length)) +#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length)) +#define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length)) +#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) +#else +#define RtlCopyMemory(Destination,Source,Length) RtlMoveMemory((Destination),(Source),(Length)) +VOID +NTAPI +RtlMoveMemory ( + PVOID Destination, + CONST VOID *Source, + DWORD Length + ); + +VOID +NTAPI +RtlFillMemory ( + PVOID Destination, + DWORD Length, + BYTE Fill + ); + +VOID +NTAPI +RtlZeroMemory ( + PVOID Destination, + DWORD Length + ); +#endif + +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 +3431,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 @@ -1757,7 +3465,7 @@ typedef struct _RTL_CRITICAL_SECTION { #define EVENTLOG_END_PAIRED_EVENT 0x0002 #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004 #define EVENTLOG_PAIRED_EVENT_ACTIVE 0x0008 -#define EVENTLOG_PAIRED_EVENT_INACTIVE 0x000C +#define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010 // // Structure that defines the header of the Eventlog record. This is the @@ -1802,9 +3510,11 @@ typedef struct _EVENTLOGRECORD { #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L) #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L) #define DBG_CONTROL_C ((DWORD )0x40010005L) +#define DBG_CONTROL_BREAK ((DWORD )0x40010008L) #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L) // +// begin_ntddk begin_nthal // // Registry Specific Access Rights. // @@ -1844,8 +3554,6 @@ typedef struct _EVENTLOGRECORD { & \ (~SYNCHRONIZE)) - - // // Open/Create Options // @@ -1861,6 +3569,17 @@ typedef struct _EVENTLOGRECORD { #define REG_OPTION_CREATE_LINK (0x00000002L) // Created key is a // symbolic link +#define REG_OPTION_BACKUP_RESTORE (0x00000004L) // open for backup or restore + // special access rules + // privilege required + +#define REG_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_NON_VOLATILE |\ + REG_OPTION_VOLATILE |\ + REG_OPTION_CREATE_LINK |\ + REG_OPTION_BACKUP_RESTORE) + // // Key creation/open disposition // @@ -1873,6 +3592,9 @@ typedef struct _EVENTLOGRECORD { // #define REG_WHOLE_HIVE_VOLATILE (0x00000001L) // Restore whole hive volatile +#define REG_REFRESH_HIVE (0x00000002L) // Unwind changes to last flush + +// end_ntddk end_nthal // // Notify filter values @@ -1890,8 +3612,6 @@ typedef struct _EVENTLOGRECORD { // // - -// // Predefined Value Types. // @@ -1908,16 +3628,20 @@ typedef struct _EVENTLOGRECORD { #define REG_RESOURCE_LIST ( 8 ) // Resource list in the resource map #define REG_FULL_RESOURCE_DESCRIPTOR ( 9 ) // Resource list in the hardware description +// end_ntddk end_nthal +// begin_ntddk begin_nthal // // Service Types (Bit Mask) // #define SERVICE_KERNEL_DRIVER 0x00000001 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 -#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ - SERVICE_FILE_SYSTEM_DRIVER) - #define SERVICE_ADAPTER 0x00000004 +#define SERVICE_RECOGNIZER_DRIVER 0x00000008 + +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER | \ + SERVICE_RECOGNIZER_DRIVER) #define SERVICE_WIN32_OWN_PROCESS 0x00000010 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020 @@ -1941,7 +3665,7 @@ typedef struct _EVENTLOGRECORD { // // Error control type // - +#define SERVICE_ERROR_IGNORE 0x00000000 #define SERVICE_ERROR_NORMAL 0x00000001 #define SERVICE_ERROR_SEVERE 0x00000002 #define SERVICE_ERROR_CRITICAL 0x00000003 @@ -1956,7 +3680,8 @@ typedef enum _CM_SERVICE_NODE_TYPE { FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, - AdapterType = SERVICE_ADAPTER + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER } SERVICE_NODE_TYPE; typedef enum _CM_SERVICE_LOAD_TYPE { @@ -1968,164 +3693,238 @@ typedef enum _CM_SERVICE_LOAD_TYPE { } SERVICE_LOAD_TYPE; typedef enum _CM_ERROR_CONTROL_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, NormalError = SERVICE_ERROR_NORMAL, SevereError = SERVICE_ERROR_SEVERE, CriticalError = SERVICE_ERROR_CRITICAL } SERVICE_ERROR_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_LONG 1L typedef struct _TAPE_ERASE { - DWORD Partition; - DWORD Type; + DWORD Type; + BOOLEAN Immediate; } 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_UNLOAD 1L +#define TAPE_TENSION 2L +#define TAPE_LOCK 3L +#define TAPE_UNLOCK 4L +#define TAPE_FORMAT 5L typedef struct _TAPE_PREPARE { DWORD Operation; + BOOLEAN Immediate; } TAPE_PREPARE, *PTAPE_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_FILEMARKS 1L +#define TAPE_SHORT_FILEMARKS 2L +#define TAPE_LONG_FILEMARKS 3L typedef struct _TAPE_WRITE_MARKS { DWORD Type; DWORD Count; + BOOLEAN Immediate; } 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 +#define TAPE_PSEUDO_LOGICAL_POSITION 2L -typedef struct _TAPE_POSITION { - DWORD Method; +typedef struct _TAPE_GET_POSITION { + DWORD Type; DWORD Partition; - LARGE_INTEGER Position; -} TAPE_POSITION, *PTAPE_POSITION; + LARGE_INTEGER Offset; +} TAPE_GET_POSITION, *PTAPE_GET_POSITION; // -// IOCTL_TAPE_GET_MEDIA_PARAMS definitions +// IOCTL_TAPE_SET_POSITION definitions // -typedef struct _TAPE_GET_MEDIA_PARAMETERS { - LARGE_INTEGER Capacity; - LARGE_INTEGER Remaining; - DWORD Type; - DWORD Density; - DWORD BlockSize; - DWORD Partitions; - BOOLEAN WriteProtected; -} TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS; +#define TAPE_REWIND 0L +#define TAPE_ABSOLUTE_BLOCK 1L +#define TAPE_LOGICAL_BLOCK 2L +#define TAPE_PSEUDO_LOGICAL_BLOCK 3L +#define TAPE_SPACE_END_OF_DATA 4L +#define TAPE_SPACE_RELATIVE_BLOCKS 5L +#define TAPE_SPACE_FILEMARKS 6L +#define TAPE_SPACE_SEQUENTIAL_FMKS 7L +#define TAPE_SPACE_SETMARKS 8L +#define TAPE_SPACE_SEQUENTIAL_SMKS 9L +typedef struct _TAPE_SET_POSITION { + DWORD Method; + DWORD Partition; + LARGE_INTEGER Offset; + BOOLEAN Immediate; +} TAPE_SET_POSITION, *PTAPE_SET_POSITION; // -// IOCTL_TAPE_SET_MEDIA_PARAMS definitions +// IOCTL_TAPE_GET_DRIVE_PARAMS definitions // -typedef struct _TAPE_SET_MEDIA_PARAMETERS { - DWORD BlockSize; -} TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS; - - // -// IOCTL_TAPE_GET_DRIVE_PARAMS definitions +// Definitions for FeaturesLow parameter // -#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; +#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_ERASE_IMMEDIATE 0x00000080 + +#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_EOT_WZ_SIZE 0x00002000 + +#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 +#define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x00400000 + +#define TAPE_DRIVE_RESERVED_BIT 0x80000000 //don't use this bit! +// //can't be a low features bit! +// //reserved; high features only + +// +// Definitions for FeaturesHigh parameter +// + +#define TAPE_DRIVE_LOAD_UNLOAD 0x80000001 +#define TAPE_DRIVE_TENSION 0x80000002 +#define TAPE_DRIVE_LOCK_UNLOCK 0x80000004 +#define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008 + +#define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010 +#define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020 +#define TAPE_DRIVE_TENSION_IMMED 0x80000040 +#define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080 + +#define TAPE_DRIVE_SET_ECC 0x80000100 +#define TAPE_DRIVE_SET_COMPRESSION 0x80000200 +#define TAPE_DRIVE_SET_PADDING 0x80000400 +#define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800 + +#define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000 +#define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000 +#define TAPE_DRIVE_LOGICAL_BLK 0x80004000 +#define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000 + +#define TAPE_DRIVE_END_OF_DATA 0x80010000 +#define TAPE_DRIVE_RELATIVE_BLKS 0x80020000 +#define TAPE_DRIVE_FILEMARKS 0x80040000 +#define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000 + +#define TAPE_DRIVE_SETMARKS 0x80100000 +#define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000 +#define TAPE_DRIVE_REVERSE_POSITION 0x80400000 +#define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000 + +#define TAPE_DRIVE_WRITE_SETMARKS 0x81000000 +#define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000 +#define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000 +#define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000 + +#define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000 +#define TAPE_DRIVE_FORMAT 0xA0000000 +#define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000 +#define TAPE_DRIVE_HIGH_FEATURES 0x80000000 //mask for high features flag + +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; + DWORD EOTWarningZoneSize; } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS; // -// IOCTL_TAPE_SET_DRIVE_PARAMS definitions +// IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions // -#define TAPE_DRIVE_SETMARKS 0x10000000 -#define TAPE_DRIVE_SHORT_FILEMARKS 0x20000000 -#define TAPE_DRIVE_LONG_FILEMARKS 0x40000000 - -#define TAPE_DRIVE_SHORT_ERASE 0x00000010 -#define TAPE_DRIVE_LONG_ERASE 0x00000020 - -#define TAPE_DRIVE_ECC 0x00000001 -#define TAPE_DRIVE_COMPRESSION 0x00000002 -#define TAPE_DRIVE_PADDING 0x00000004 - typedef struct _TAPE_SET_DRIVE_PARAMETERS { - DWORD CurrentSettings; + BOOLEAN ECC; + BOOLEAN Compression; + BOOLEAN DataPadding; + BOOLEAN ReportSetmarks; + DWORD EOTWarningZoneSize; } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS; // -// IOCTL_TAPE_GET_STATUS definitions +// IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions // -#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 struct _TAPE_GET_MEDIA_PARAMETERS { + LARGE_INTEGER Capacity; + LARGE_INTEGER Remaining; + DWORD BlockSize; + DWORD PartitionCount; + BOOLEAN WriteProtected; +} TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS; + +// +// 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_PARTITION_FIXED 0 -#define TAPE_PARTITION_SELECT 1 -#define TAPE_PARTITION_INITIATOR 2 +#define TAPE_FIXED_PARTITIONS 0L +#define TAPE_SELECT_PARTITIONS 1L +#define TAPE_INITIATOR_PARTITIONS 2L -typedef struct _TAPE_CREATE_PARTITION_PARAMETERS { - DWORD Type; +typedef struct _TAPE_CREATE_PARTITION { + DWORD Method; DWORD Count; - DWORD Size[1]; // variable length array, 0 terminates -} TAPE_CREATE_PARTITION_PARAMETERS, *PTAPE_CREATE_PARTITION_PARAMETERS; + DWORD Size; +} TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION; -#endif // _WINNT_ +#ifdef __cplusplus +} +#endif + +#endif /* _WINNT_ */