Annotation of mstools/h/winnt.h, revision 1.1.1.5

1.1.1.4   root        1: /*++ BUILD Version: 0093     Increment this if a change has global effects
1.1       root        2: 
1.1.1.4   root        3: Copyright (c) 1990-1993  Microsoft Corporation
1.1       root        4: 
                      5: Module Name:
                      6: 
                      7:     winnt.h
                      8: 
                      9: Abstract:
                     10: 
                     11:     This module defines the 32-Bit Windows types and constants that are
                     12:     defined by NT, but exposed through the Win32 API.
                     13: 
                     14: Revision History:
                     15: 
                     16: --*/
                     17: 
                     18: #ifndef _WINNT_
                     19: #define _WINNT_
                     20: 
1.1.1.4   root       21: #ifdef __cplusplus
                     22: extern "C" {
                     23: #endif
                     24: 
                     25: #include <ctype.h>  
1.1.1.2   root       26: #define ANYSIZE_ARRAY 1       
1.1.1.4   root       27: #if defined(_MIPS_) || defined(_ALPHA_)     
                     28: #define UNALIGNED __unaligned               
                     29: #else                                       
                     30: #define UNALIGNED                           
                     31: #endif                                      
1.1       root       32: typedef void *PVOID;    
1.1.1.4   root       33: #if (_MSC_VER >= 800)                                                    
                     34: #define NTAPI __stdcall                                                  
                     35: #else                                                                    
                     36: #define _cdecl                                                           
                     37: #define NTAPI                                                            
                     38: #endif                                                                   
1.1       root       39: 
                     40: //
                     41: // Basics
                     42: //
                     43: 
                     44: #ifndef VOID
1.1.1.4   root       45: #define VOID void
1.1       root       46: typedef char CHAR;
                     47: typedef short SHORT;
                     48: typedef long LONG;
                     49: #endif
                     50: 
                     51: //
1.1.1.2   root       52: // UNICODE (Wide Character) types
1.1       root       53: //
                     54: 
1.1.1.4   root       55: typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
1.1       root       56: 
1.1.1.2   root       57: typedef WCHAR *PWCHAR;
                     58: typedef WCHAR *LPWCH, *PWCH;
                     59: typedef CONST WCHAR *LPCWCH, *PCWCH;
                     60: typedef WCHAR *NWPSTR;
                     61: typedef WCHAR *LPWSTR, *PWSTR;
                     62: 
                     63: typedef CONST WCHAR *LPCWSTR, *PCWSTR;
1.1       root       64: 
                     65: //
1.1.1.2   root       66: // ANSI (Multi-byte Character) types
1.1       root       67: //
1.1.1.2   root       68: typedef CHAR *PCHAR;
                     69: typedef CHAR *LPCH, *PCH;
                     70: 
                     71: typedef CONST CHAR *LPCCH, *PCCH;
                     72: typedef CHAR *NPSTR;
                     73: typedef CHAR *LPSTR, *PSTR;
                     74: typedef CONST CHAR *LPCSTR, *PCSTR;
1.1       root       75: 
1.1.1.2   root       76: //
                     77: // Neutral ANSI/UNICODE types and macros
                     78: //
1.1       root       79: #ifdef  UNICODE
1.1.1.4   root       80: 
1.1.1.3   root       81: #ifndef _TCHAR_DEFINED
                     82: typedef WCHAR TCHAR, *PTCHAR;
1.1.1.4   root       83: typedef WCHAR TBYTE , *PTBYTE ;
1.1.1.3   root       84: #define _TCHAR_DEFINED
1.1.1.4   root       85: #endif /* !_TCHAR_DEFINED */
                     86: 
1.1.1.2   root       87: typedef LPWSTR LPTCH, PTCH;
                     88: typedef LPWSTR PTSTR, LPTSTR;
                     89: typedef LPCWSTR LPCTSTR;
                     90: typedef LPWSTR LP;
1.1.1.4   root       91: #define __TEXT(quote) L##quote
                     92: 
                     93: #else   /* UNICODE */
                     94: 
1.1.1.3   root       95: #ifndef _TCHAR_DEFINED
1.1.1.2   root       96: typedef char TCHAR, *PTCHAR;
1.1.1.4   root       97: typedef unsigned char TBYTE , *PTBYTE ;
1.1.1.3   root       98: #define _TCHAR_DEFINED
1.1.1.4   root       99: #endif /* !_TCHAR_DEFINED */
                    100: 
1.1.1.2   root      101: typedef LPSTR LPTCH, PTCH;
                    102: typedef LPSTR PTSTR, LPTSTR;
                    103: typedef LPCSTR LPCTSTR;
1.1.1.4   root      104: #define __TEXT(quote) quote
                    105: 
                    106: #endif /* UNICODE */
                    107: #define TEXT(quote) __TEXT(quote)
1.1       root      108: 
                    109: 
                    110: typedef SHORT *PSHORT;  
                    111: typedef LONG *PLONG;    
1.1.1.4   root      112: 
                    113: #ifdef STRICT
                    114: typedef void *HANDLE;
                    115: #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
                    116: #else
                    117: typedef PVOID HANDLE;
                    118: #define DECLARE_HANDLE(name) typedef HANDLE name
                    119: #endif
                    120: typedef HANDLE *PHANDLE;
                    121: 
1.1.1.2   root      122: typedef char CCHAR;          
1.1.1.4   root      123: typedef DWORD LCID;         
                    124: typedef PDWORD PLCID;       
                    125: typedef WORD   LANGID;      
1.1.1.2   root      126: /*lint -e624 */  
                    127: /*lint +e624 */  
                    128: #define APPLICATION_ERROR_MASK       0x20000000
                    129: #define ERROR_SEVERITY_SUCCESS       0x00000000
                    130: #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
                    131: #define ERROR_SEVERITY_WARNING       0x80000000
                    132: #define ERROR_SEVERITY_ERROR         0xC0000000
                    133: 
1.1.1.5 ! root      134: #if defined(MIDL_PASS) || defined(_CFRONT_PASS_)
1.1.1.4   root      135: typedef double LONGLONG;
                    136: typedef double DWORDLONG;
                    137: #else
                    138: #if defined(_M_IX86)
                    139: typedef double LONGLONG;
                    140: typedef double DWORDLONG;
1.1.1.5 ! root      141: #elif defined(_M_MRX000)
        !           142: typedef double LONGLONG;
        !           143: typedef double DWORDLONG;
        !           144: #elif defined(_ALPHA_)
        !           145: typedef __int64 LONGLONG;
        !           146: typedef unsigned __int64 DWORDLONG;
1.1.1.4   root      147: #else
                    148: typedef double LONGLONG;
                    149: typedef double DWORDLONG;
                    150: #endif
                    151: #endif
                    152: 
                    153: typedef LONGLONG *PLONGLONG;
                    154: typedef DWORDLONG *PDWORDLONG;
                    155: 
                    156: #if defined(MIDL_PASS)
1.1.1.2   root      157: typedef struct _LARGE_INTEGER {
1.1.1.4   root      158: #else // MIDL_PASS
                    159: typedef union _LARGE_INTEGER {
                    160: #if defined(_CFRONT_PASS_)
                    161:     struct {
                    162:         DWORD LowPart;
                    163:         LONG HighPart;
                    164:     } u;
                    165: #else
                    166:     struct {
                    167:         DWORD LowPart;
                    168:         LONG HighPart;
                    169:     };
                    170: #endif
                    171: #endif //MIDL_PASS
                    172:     LONGLONG QuadPart;
1.1.1.2   root      173: } LARGE_INTEGER, *PLARGE_INTEGER;
                    174: 
1.1.1.4   root      175: 
                    176: #if defined(MIDL_PASS)
1.1.1.2   root      177: typedef struct _ULARGE_INTEGER {
1.1.1.4   root      178: #else // MIDL_PASS
                    179: typedef union _ULARGE_INTEGER {
                    180: #if defined(_CFRONT_PASS_)
                    181:     struct {
                    182:         DWORD LowPart;
                    183:         DWORD HighPart;
                    184:     } u;
                    185: #else
                    186:     struct {
                    187:         DWORD LowPart;
                    188:         DWORD HighPart;
                    189:     };
                    190: #endif
                    191: #endif //MIDL_PASS
                    192:     DWORDLONG QuadPart;
1.1.1.2   root      193: } ULARGE_INTEGER, *PULARGE_INTEGER;
                    194: 
1.1.1.4   root      195: // end_ntminiport
                    196: 
                    197: //
                    198: // Locally Unique Identifier
                    199: //
                    200: 
                    201: typedef LARGE_INTEGER LUID, *PLUID;
                    202: 
1.1       root      203: #define UNICODE_NULL ((WCHAR)0) 
1.1.1.4   root      204: typedef BYTE  BOOLEAN;           
1.1.1.2   root      205: typedef BOOLEAN *PBOOLEAN;       
                    206: //
                    207: //  Doubly linked list structure.  Can be used as either a list head, or
                    208: //  as link words.
                    209: //
                    210: 
                    211: typedef struct _LIST_ENTRY {
                    212:    struct _LIST_ENTRY *Flink;
                    213:    struct _LIST_ENTRY *Blink;
                    214: } LIST_ENTRY;
                    215: typedef LIST_ENTRY *PLIST_ENTRY;
                    216: 
                    217: //
                    218: //  Singly linked list structure. Can be used as either a list head, or
                    219: //  as link words.
                    220: //
                    221: 
                    222: typedef struct _SINGLE_LIST_ENTRY {
                    223:     struct _SINGLE_LIST_ENTRY *Next;
                    224: } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
1.1       root      225: #define MINCHAR     0x80        
                    226: #define MAXCHAR     0x7f        
                    227: #define MINSHORT    0x8000      
                    228: #define MAXSHORT    0x7fff      
                    229: #define MINLONG     0x80000000  
                    230: #define MAXLONG     0x7fffffff  
                    231: #define MAXBYTE     0xff        
                    232: #define MAXWORD     0xffff      
                    233: #define MAXDWORD    0xffffffff  
1.1.1.4   root      234: //
                    235: // Calculate the byte offset of a field in a structure of type type.
                    236: //
                    237: 
                    238: #define FIELD_OFFSET(type, field)    ((LONG)&(((type *)0)->field))
                    239: 
                    240: 
                    241: //
                    242: // Calculate the address of the base of the structure given its type, and an
                    243: // address of a field within the structure.
                    244: //
                    245: 
                    246: #define CONTAINING_RECORD(address, type, field) ((type *)( \
                    247:                                                   (PCHAR)(address) - \
                    248:                                                   (PCHAR)(&((type *)0)->field)))
                    249: 
                    250: /*
                    251:  *  Language IDs.
                    252:  *
                    253:  *  The following two combinations of primary language ID and
                    254:  *  sublanguage ID have special semantics:
                    255:  *
                    256:  *    Primary Language ID   Sublanguage ID      Result
                    257:  *    -------------------   ---------------     ------------------------
                    258:  *    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
                    259:  *    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
                    260:  *    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
                    261:  */
                    262: 
                    263: /*
                    264:  *  Primary language IDs.
                    265:  */
                    266: #define LANG_NEUTRAL                     0x00
                    267: 
                    268: #define LANG_ALBANIAN                    0x1c
                    269: #define LANG_ARABIC                      0x01
                    270: #define LANG_BAHASA                      0x21
                    271: #define LANG_BULGARIAN                   0x02
                    272: #define LANG_CATALAN                     0x03
                    273: #define LANG_CHINESE                     0x04
                    274: #define LANG_CZECH                       0x05
                    275: #define LANG_DANISH                      0x06
                    276: #define LANG_DUTCH                       0x13
                    277: #define LANG_ENGLISH                     0x09
                    278: #define LANG_FINNISH                     0x0b
                    279: #define LANG_FRENCH                      0x0c
                    280: #define LANG_GERMAN                      0x07
                    281: #define LANG_GREEK                       0x08
                    282: #define LANG_HEBREW                      0x0d
                    283: #define LANG_HUNGARIAN                   0x0e
                    284: #define LANG_ICELANDIC                   0x0f
                    285: #define LANG_ITALIAN                     0x10
                    286: #define LANG_JAPANESE                    0x11
                    287: #define LANG_KOREAN                      0x12
                    288: #define LANG_NORWEGIAN                   0x14
                    289: #define LANG_POLISH                      0x15
                    290: #define LANG_PORTUGUESE                  0x16
                    291: #define LANG_RHAETO_ROMAN                0x17
                    292: #define LANG_ROMANIAN                    0x18
                    293: #define LANG_RUSSIAN                     0x19
                    294: #define LANG_SERBO_CROATIAN              0x1a
                    295: #define LANG_SLOVAK                      0x1b
                    296: #define LANG_SPANISH                     0x0a
                    297: #define LANG_SWEDISH                     0x1d
                    298: #define LANG_THAI                        0x1e
                    299: #define LANG_TURKISH                     0x1f
                    300: #define LANG_URDU                        0x20
                    301: 
                    302: /*
                    303:  *  Sublanguage IDs.
                    304:  *
                    305:  *  The name immediately following SUBLANG_ dictates which primary
                    306:  *  language ID that sublanguage ID can be combined with to form a
                    307:  *  valid language ID.
                    308:  */
                    309: #define SUBLANG_NEUTRAL                  0x00    /* language neutral */
                    310: #define SUBLANG_DEFAULT                  0x01    /* user default */
                    311: #define SUBLANG_SYS_DEFAULT              0x02    /* system default */
                    312: 
                    313: #define SUBLANG_CHINESE_SIMPLIFIED       0x02    /* Chinese (Simplified) */
                    314: #define SUBLANG_CHINESE_TRADITIONAL      0x01    /* Chinese (Traditional) */
                    315: #define SUBLANG_DUTCH                    0x01    /* Dutch */
                    316: #define SUBLANG_DUTCH_BELGIAN            0x02    /* Dutch (Belgian) */
                    317: #define SUBLANG_ENGLISH_US               0x01    /* English (USA) */
                    318: #define SUBLANG_ENGLISH_UK               0x02    /* English (UK) */
                    319: #define SUBLANG_ENGLISH_AUS              0x03    /* English (Australian) */
                    320: #define SUBLANG_ENGLISH_CAN              0x04    /* English (Canadian) */
                    321: #define SUBLANG_ENGLISH_NZ               0x05    /* English (New Zealand) */
                    322: #define SUBLANG_ENGLISH_EIRE             0x06    /* English (Irish) */
                    323: #define SUBLANG_FRENCH                   0x01    /* French */
                    324: #define SUBLANG_FRENCH_BELGIAN           0x02    /* French (Belgian) */
                    325: #define SUBLANG_FRENCH_CANADIAN          0x03    /* French (Canadian) */
                    326: #define SUBLANG_FRENCH_SWISS             0x04    /* French (Swiss) */
                    327: #define SUBLANG_GERMAN                   0x01    /* German */
                    328: #define SUBLANG_GERMAN_SWISS             0x02    /* German (Swiss) */
                    329: #define SUBLANG_GERMAN_AUSTRIAN          0x03    /* German (Austrian) */
                    330: #define SUBLANG_ITALIAN                  0x01    /* Italian */
                    331: #define SUBLANG_ITALIAN_SWISS            0x02    /* Italian (Swiss) */
                    332: #define SUBLANG_NORWEGIAN_BOKMAL         0x01    /* Norwegian (Bokmal) */
                    333: #define SUBLANG_NORWEGIAN_NYNORSK        0x02    /* Norwegian (Nynorsk) */
                    334: #define SUBLANG_PORTUGUESE               0x02    /* Portuguese */
                    335: #define SUBLANG_PORTUGUESE_BRAZILIAN     0x01    /* Portuguese (Brazilian) */
                    336: #define SUBLANG_SERBO_CROATIAN_CYRILLIC  0x02    /* Serbo-Croatian (Cyrillic) */
                    337: #define SUBLANG_SERBO_CROATIAN_LATIN     0x01    /* Croato-Serbian (Latin) */
                    338: #define SUBLANG_SPANISH                  0x01    /* Spanish (Castilian) */
                    339: #define SUBLANG_SPANISH_MEXICAN          0x02    /* Spanish (Mexican) */
                    340: #define SUBLANG_SPANISH_MODERN           0x03    /* Spanish (Modern) */
                    341: 
                    342: /*
                    343:  *  Sorting IDs.
                    344:  *
                    345:  */
                    346: #define SORT_DEFAULT                     0x0     /* sorting default */
                    347: 
                    348: 
                    349: /*
                    350:  *  A language ID is a 16 bit value which is the combination of a
                    351:  *  primary language ID and a secondary language ID.  The bits are
                    352:  *  allocated as follows:
                    353:  *
                    354:  *       +-----------------------+-------------------------+
                    355:  *       |     Sublanguage ID    |   Primary Language ID   |
                    356:  *       +-----------------------+-------------------------+
                    357:  *        15                   10 9                       0   bit
                    358:  *
                    359:  *
                    360:  *  Language ID creation/extraction macros:
                    361:  *
                    362:  *    MAKELANGID    - construct language id from a primary language id and
                    363:  *                    a sublanguage id.
                    364:  *    PRIMARYLANGID - extract primary language id from a language id.
                    365:  *    SUBLANGID     - extract sublanguage id from a language id.
                    366:  */
                    367: #define MAKELANGID(p, s)       ((((WORD  )(s)) << 10) | (WORD  )(p))
                    368: #define PRIMARYLANGID(lgid)    ((WORD  )(lgid) & 0x3ff)
                    369: #define SUBLANGID(lgid)        ((WORD  )(lgid) >> 10)
                    370: 
                    371: 
                    372: /*
                    373:  *  A locale ID is a 32 bit value which is the combination of a
                    374:  *  language ID, a sort ID, and a reserved area.  The bits are
                    375:  *  allocated as follows:
                    376:  *
                    377:  *       +-------------+---------+-------------------------+
                    378:  *       |   Reserved  | Sort ID |      Language ID        |
                    379:  *       +-------------+---------+-------------------------+
                    380:  *        31         20 19     16 15                      0   bit
                    381:  *
                    382:  *
                    383:  *  Locale ID creation/extraction macros:
                    384:  *
                    385:  *    MAKELCID       - construct locale id from a language id and a sort id.
                    386:  *    LANGIDFROMLCID - extract language id from a locale id.
                    387:  *    SORTIDFROMLCID - extract sort id from a locale id.
                    388:  */
                    389: #define NLS_VALID_LOCALE_MASK  0x000fffff
                    390: 
                    391: #define MAKELCID(lgid, srtid)  ((DWORD)((((DWORD)((WORD  )(srtid))) << 16) |  \
                    392:                                          ((DWORD)((WORD  )(lgid)))))
                    393: #define LANGIDFROMLCID(lcid)   ((WORD  )(lcid))
                    394: #define SORTIDFROMLCID(lcid)   ((WORD  )((((DWORD)(lcid)) & NLS_VALID_LOCALE_MASK) >> 16))
                    395: 
                    396: 
                    397: /*
                    398:  *  Default System and User IDs for language and locale.
                    399:  */
                    400: #define LANG_SYSTEM_DEFAULT    (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
                    401: #define LANG_USER_DEFAULT      (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
                    402: 
                    403: #define LOCALE_SYSTEM_DEFAULT  (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
                    404: #define LOCALE_USER_DEFAULT    (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
                    405: 
                    406: 
                    407: 
                    408: // begin_ntminiport
1.1       root      409: 
                    410: //
                    411: // Macros used to eliminate compiler warning generated when formal
                    412: // parameters or local variables are not declared.
                    413: //
                    414: // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
                    415: // referenced but will be once the module is completely developed.
                    416: //
                    417: // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
                    418: // referenced but will be once the module is completely developed.
                    419: //
                    420: // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
                    421: //
                    422: // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
                    423: // eventually be made into a null macro to help determine whether there
                    424: // is unfinished work.
                    425: //
                    426: 
                    427: #if ! (defined(lint) || defined(_lint))
                    428: #define UNREFERENCED_PARAMETER(P)          (P)
                    429: #define DBG_UNREFERENCED_PARAMETER(P)      (P)
                    430: #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
                    431: 
                    432: #else // lint or _lint
                    433: 
                    434: // Note: lint -e530 says don't complain about uninitialized variables for
                    435: // this.  line +e530 turns that checking back on.  Error 527 has to do with
                    436: // unreachable code.
                    437: 
                    438: #define UNREFERENCED_PARAMETER(P)          \
                    439:     /*lint -e527 -e530 */ \
                    440:     { \
                    441:         (P) = (P); \
                    442:     } \
                    443:     /*lint +e527 +e530 */
                    444: #define DBG_UNREFERENCED_PARAMETER(P)      \
                    445:     /*lint -e527 -e530 */ \
                    446:     { \
                    447:         (P) = (P); \
                    448:     } \
                    449:     /*lint +e527 +e530 */
                    450: #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
                    451:     /*lint -e527 -e530 */ \
                    452:     { \
                    453:         (V) = (V); \
                    454:     } \
                    455:     /*lint +e527 +e530 */
                    456: 
                    457: #endif // lint or _lint
                    458: 
                    459: 
1.1.1.4   root      460: /*lint -save -e767 */  
1.1       root      461: #define STATUS_WAIT_0                    ((DWORD   )0x00000000L)    
                    462: #define STATUS_ABANDONED_WAIT_0          ((DWORD   )0x00000080L)    
1.1.1.2   root      463: #define STATUS_USER_APC                  ((DWORD   )0x000000C0L)    
1.1       root      464: #define STATUS_TIMEOUT                   ((DWORD   )0x00000102L)    
                    465: #define STATUS_PENDING                   ((DWORD   )0x00000103L)    
                    466: #define STATUS_DATATYPE_MISALIGNMENT     ((DWORD   )0x80000002L)    
                    467: #define STATUS_BREAKPOINT                ((DWORD   )0x80000003L)    
                    468: #define STATUS_SINGLE_STEP               ((DWORD   )0x80000004L)    
                    469: #define STATUS_ACCESS_VIOLATION          ((DWORD   )0xC0000005L)    
1.1.1.4   root      470: #define STATUS_IN_PAGE_ERROR             ((DWORD   )0xC0000006L)    
                    471: #define STATUS_NO_MEMORY                 ((DWORD   )0xC0000017L)    
1.1.1.2   root      472: #define STATUS_ILLEGAL_INSTRUCTION       ((DWORD   )0xC000001DL)    
1.1       root      473: #define STATUS_NONCONTINUABLE_EXCEPTION  ((DWORD   )0xC0000025L)    
1.1.1.2   root      474: #define STATUS_INVALID_DISPOSITION       ((DWORD   )0xC0000026L)    
                    475: #define STATUS_ARRAY_BOUNDS_EXCEEDED     ((DWORD   )0xC000008CL)    
                    476: #define STATUS_FLOAT_DENORMAL_OPERAND    ((DWORD   )0xC000008DL)    
                    477: #define STATUS_FLOAT_DIVIDE_BY_ZERO      ((DWORD   )0xC000008EL)    
                    478: #define STATUS_FLOAT_INEXACT_RESULT      ((DWORD   )0xC000008FL)    
                    479: #define STATUS_FLOAT_INVALID_OPERATION   ((DWORD   )0xC0000090L)    
                    480: #define STATUS_FLOAT_OVERFLOW            ((DWORD   )0xC0000091L)    
                    481: #define STATUS_FLOAT_STACK_CHECK         ((DWORD   )0xC0000092L)    
                    482: #define STATUS_FLOAT_UNDERFLOW           ((DWORD   )0xC0000093L)    
                    483: #define STATUS_INTEGER_DIVIDE_BY_ZERO    ((DWORD   )0xC0000094L)    
                    484: #define STATUS_INTEGER_OVERFLOW          ((DWORD   )0xC0000095L)    
                    485: #define STATUS_PRIVILEGED_INSTRUCTION    ((DWORD   )0xC0000096L)    
                    486: #define STATUS_STACK_OVERFLOW            ((DWORD   )0xC00000FDL)    
1.1       root      487: #define STATUS_CONTROL_C_EXIT            ((DWORD   )0xC000013AL)    
1.1.1.4   root      488: /*lint -restore */  
1.1       root      489: #define MAXIMUM_WAIT_OBJECTS 64     // Maximum number of wait objects
                    490: 
                    491: #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended
                    492: typedef DWORD KSPIN_LOCK;  
                    493: 
1.1.1.4   root      494: #ifdef _ALPHA_
                    495: 
                    496: // begin_ntddk begin_nthal
                    497: //
                    498: // The following flags control the contents of the CONTEXT structure.
                    499: //
                    500: 
                    501: #define CONTEXT_PORTABLE_32BIT     0x00100000
                    502: #define CONTEXT_ALPHA              0x00020000
                    503: 
                    504: #define CONTEXT_CONTROL         (CONTEXT_ALPHA | 0x00000001L)
                    505: #define CONTEXT_FLOATING_POINT  (CONTEXT_ALPHA | 0x00000002L)
                    506: #define CONTEXT_INTEGER         (CONTEXT_ALPHA | 0x00000004L)
                    507: 
                    508: #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
                    509: 
                    510: #ifndef _PORTABLE_32BIT_CONTEXT
                    511: 
                    512: //
                    513: // Context Frame
                    514: //
                    515: //  This frame has a several purposes: 1) it is used as an argument to
                    516: //  NtContinue, 2) it is used to construct a call frame for APC delivery,
                    517: //  3) it is used to construct a call frame for exception dispatching
                    518: //  in user mode, 4) it is used in the user level thread creation
                    519: //  routines, and 5) it is used to to pass thread state to debuggers.
                    520: //
                    521: //  N.B. Because this record is used as a call frame, it must be EXACTLY
                    522: //  a multiple of 16 bytes in length.
                    523: //
                    524: //  There are two variations of the context structure. This is the real one.
                    525: //
                    526: 
                    527: typedef struct _CONTEXT {
                    528: 
                    529:     //
                    530:     // This section is specified/returned if the ContextFlags word contains
                    531:     // the flag CONTEXT_FLOATING_POINT.
                    532:     //
                    533: 
                    534:     DWORDLONG FltF0;
                    535:     DWORDLONG FltF1;
                    536:     DWORDLONG FltF2;
                    537:     DWORDLONG FltF3;
                    538:     DWORDLONG FltF4;
                    539:     DWORDLONG FltF5;
                    540:     DWORDLONG FltF6;
                    541:     DWORDLONG FltF7;
                    542:     DWORDLONG FltF8;
                    543:     DWORDLONG FltF9;
                    544:     DWORDLONG FltF10;
                    545:     DWORDLONG FltF11;
                    546:     DWORDLONG FltF12;
                    547:     DWORDLONG FltF13;
                    548:     DWORDLONG FltF14;
                    549:     DWORDLONG FltF15;
                    550:     DWORDLONG FltF16;
                    551:     DWORDLONG FltF17;
                    552:     DWORDLONG FltF18;
                    553:     DWORDLONG FltF19;
                    554:     DWORDLONG FltF20;
                    555:     DWORDLONG FltF21;
                    556:     DWORDLONG FltF22;
                    557:     DWORDLONG FltF23;
                    558:     DWORDLONG FltF24;
                    559:     DWORDLONG FltF25;
                    560:     DWORDLONG FltF26;
                    561:     DWORDLONG FltF27;
                    562:     DWORDLONG FltF28;
                    563:     DWORDLONG FltF29;
                    564:     DWORDLONG FltF30;
                    565:     DWORDLONG FltF31;
                    566: 
                    567:     //
                    568:     // This section is specified/returned if the ContextFlags word contains
                    569:     // the flag CONTEXT_INTEGER.
                    570:     //
                    571:     // N.B. The registers gp, sp, and ra are defined in this section, but are
                    572:     //  considered part of the control context rather than part of the integer
                    573:     //  context.
                    574:     //
                    575: 
                    576:     DWORDLONG IntV0;    //  $0: return value register, v0
                    577:     DWORDLONG IntT0;    //  $1: temporary registers, t0 - t7
                    578:     DWORDLONG IntT1;    //  $2:
                    579:     DWORDLONG IntT2;    //  $3:
                    580:     DWORDLONG IntT3;    //  $4:
                    581:     DWORDLONG IntT4;    //  $5:
                    582:     DWORDLONG IntT5;    //  $6:
                    583:     DWORDLONG IntT6;    //  $7:
                    584:     DWORDLONG IntT7;    //  $8:
                    585:     DWORDLONG IntS0;    //  $9: nonvolatile registers, s0 - s5
                    586:     DWORDLONG IntS1;    // $10:
                    587:     DWORDLONG IntS2;    // $11:
                    588:     DWORDLONG IntS3;    // $12:
                    589:     DWORDLONG IntS4;    // $13:
                    590:     DWORDLONG IntS5;    // $14:
                    591:     DWORDLONG IntFp;    // $15: frame pointer register, fp/s6
                    592:     DWORDLONG IntA0;    // $16: argument registers, a0 - a5
                    593:     DWORDLONG IntA1;    // $17:
                    594:     DWORDLONG IntA2;    // $18:
                    595:     DWORDLONG IntA3;    // $19:
                    596:     DWORDLONG IntA4;    // $20:
                    597:     DWORDLONG IntA5;    // $21:
                    598:     DWORDLONG IntT8;    // $22: temporary registers, t8 - t11
                    599:     DWORDLONG IntT9;    // $23:
                    600:     DWORDLONG IntT10;   // $24:
                    601:     DWORDLONG IntT11;   // $25:
                    602:     DWORDLONG IntRa;    // $26: return address register, ra
                    603:     DWORDLONG IntT12;   // $27: temporary register, t12
                    604:     DWORDLONG IntAt;    // $28: assembler temp register, at
                    605:     DWORDLONG IntGp;    // $29: global pointer register, gp
                    606:     DWORDLONG IntSp;    // $30: stack pointer register, sp
                    607:     DWORDLONG IntZero;  // $31: zero register, zero
                    608: 
                    609:     //
                    610:     // This section is specified/returned if the ContextFlags word contains
                    611:     // the flag CONTEXT_FLOATING_POINT.
                    612:     //
                    613: 
                    614:     DWORDLONG Fpcr;     // floating point control register
                    615:     DWORDLONG SoftFpcr; // software extension to FPCR
                    616: 
                    617:     //
                    618:     // This section is specified/returned if the ContextFlags word contains
                    619:     // the flag CONTEXT_CONTROL.
                    620:     //
                    621:     // N.B. The registers gp, sp, and ra are defined in the integer section,
                    622:     //   but are considered part of the control context rather than part of
                    623:     //   the integer context.
                    624:     //
                    625: 
                    626:     DWORDLONG Fir;      // (fault instruction) continuation address
                    627:     DWORD Psr;          // processor status
                    628: 
                    629:     //
                    630:     // The flags values within this flag control the contents of
                    631:     // a CONTEXT record.
                    632:     //
                    633:     // If the context record is used as an input parameter, then
                    634:     // for each portion of the context record controlled by a flag
                    635:     // whose value is set, it is assumed that that portion of the
                    636:     // context record contains valid context. If the context record
                    637:     // is being used to modify a thread's context, then only that
                    638:     // portion of the threads context will be modified.
                    639:     //
                    640:     // If the context record is used as an IN OUT parameter to capture
                    641:     // the context of a thread, then only those portions of the thread's
                    642:     // context corresponding to set flags will be returned.
                    643:     //
                    644:     // The context record is never used as an OUT only parameter.
                    645:     //
                    646: 
                    647:     DWORD ContextFlags;
                    648:     DWORD Fill[4];      // padding for 16-byte stack frame alignment
                    649: 
                    650: } CONTEXT, *PCONTEXT;
                    651: 
                    652: #else
                    653: 
                    654: //
                    655: // 32-bit Context Frame
                    656: //
                    657: //  This alternate version of the Alpha context structure parallels that
                    658: //  of MIPS and IX86 in style for the first 64 entries: 32-bit machines
                    659: //  can operate on the fields, and a value declared as a pointer to an
                    660: //  array of int's can be used to index into the fields.  This makes life
                    661: //  with windbg and ntsd vastly easier.
                    662: //
                    663: //  There are two parts: the first contains the lower 32-bits of each
                    664: //  element in the 64-bit definition above.  The second part contains
                    665: //  the upper 32-bits of each 64-bit element above.
                    666: //
                    667: //  The names in the first part are identical to the 64-bit names.
                    668: //  The second part names are prefixed with "High".
                    669: //
                    670: //  1st half: at 32 bits each, (containing the low parts of 64-bit values)
                    671: //      32 floats, 32 ints, fpcrs, fir, psr, contextflags
                    672: //  2nd half: at 32 bits each
                    673: //      32 floats, 32 ints, fpcrs, fir, fill
                    674: //
                    675: //  There is no external support for the 32-bit version of the context
                    676: //  structure.  It is only used internally by windbg and ntsd.
                    677: //
                    678: //  This structure must be the same size as the 64-bit version above.
                    679: //
                    680: 
                    681: typedef struct _CONTEXT {
                    682: 
                    683:     DWORD FltF0;
                    684:     DWORD FltF1;
                    685:     DWORD FltF2;
                    686:     DWORD FltF3;
                    687:     DWORD FltF4;
                    688:     DWORD FltF5;
                    689:     DWORD FltF6;
                    690:     DWORD FltF7;
                    691:     DWORD FltF8;
                    692:     DWORD FltF9;
                    693:     DWORD FltF10;
                    694:     DWORD FltF11;
                    695:     DWORD FltF12;
                    696:     DWORD FltF13;
                    697:     DWORD FltF14;
                    698:     DWORD FltF15;
                    699:     DWORD FltF16;
                    700:     DWORD FltF17;
                    701:     DWORD FltF18;
                    702:     DWORD FltF19;
                    703:     DWORD FltF20;
                    704:     DWORD FltF21;
                    705:     DWORD FltF22;
                    706:     DWORD FltF23;
                    707:     DWORD FltF24;
                    708:     DWORD FltF25;
                    709:     DWORD FltF26;
                    710:     DWORD FltF27;
                    711:     DWORD FltF28;
                    712:     DWORD FltF29;
                    713:     DWORD FltF30;
                    714:     DWORD FltF31;
                    715: 
                    716:     DWORD IntV0;        //  $0: return value register, v0
                    717:     DWORD IntT0;        //  $1: temporary registers, t0 - t7
                    718:     DWORD IntT1;        //  $2:
                    719:     DWORD IntT2;        //  $3:
                    720:     DWORD IntT3;        //  $4:
                    721:     DWORD IntT4;        //  $5:
                    722:     DWORD IntT5;        //  $6:
                    723:     DWORD IntT6;        //  $7:
                    724:     DWORD IntT7;        //  $8:
                    725:     DWORD IntS0;        //  $9: nonvolatile registers, s0 - s5
                    726:     DWORD IntS1;        // $10:
                    727:     DWORD IntS2;        // $11:
                    728:     DWORD IntS3;        // $12:
                    729:     DWORD IntS4;        // $13:
                    730:     DWORD IntS5;        // $14:
                    731:     DWORD IntFp;        // $15: frame pointer register, fp/s6
                    732:     DWORD IntA0;        // $16: argument registers, a0 - a5
                    733:     DWORD IntA1;        // $17:
                    734:     DWORD IntA2;        // $18:
                    735:     DWORD IntA3;        // $19:
                    736:     DWORD IntA4;        // $20:
                    737:     DWORD IntA5;        // $21:
                    738:     DWORD IntT8;        // $22: temporary registers, t8 - t11
                    739:     DWORD IntT9;        // $23:
                    740:     DWORD IntT10;       // $24:
                    741:     DWORD IntT11;       // $25:
                    742:     DWORD IntRa;        // $26: return address register, ra
                    743:     DWORD IntT12;       // $27: temporary register, t12
                    744:     DWORD IntAt;        // $28: assembler temp register, at
                    745:     DWORD IntGp;        // $29: global pointer register, gp
                    746:     DWORD IntSp;        // $30: stack pointer register, sp
                    747:     DWORD IntZero;      // $31: zero register, zero
                    748: 
                    749:     DWORD Fpcr;         // floating point control register
                    750:     DWORD SoftFpcr;     // software extension to FPCR
                    751: 
                    752:     DWORD Fir;          // (fault instruction) continuation address
                    753: 
                    754:     DWORD Psr;          // processor status
                    755:     DWORD ContextFlags;
                    756: 
                    757:     //
                    758:     // Beginning of the "second half".
                    759:     // The name "High" parallels the HighPart of a LargeInteger.
                    760:     //
                    761: 
                    762:     DWORD HighFltF0;
                    763:     DWORD HighFltF1;
                    764:     DWORD HighFltF2;
                    765:     DWORD HighFltF3;
                    766:     DWORD HighFltF4;
                    767:     DWORD HighFltF5;
                    768:     DWORD HighFltF6;
                    769:     DWORD HighFltF7;
                    770:     DWORD HighFltF8;
                    771:     DWORD HighFltF9;
                    772:     DWORD HighFltF10;
                    773:     DWORD HighFltF11;
                    774:     DWORD HighFltF12;
                    775:     DWORD HighFltF13;
                    776:     DWORD HighFltF14;
                    777:     DWORD HighFltF15;
                    778:     DWORD HighFltF16;
                    779:     DWORD HighFltF17;
                    780:     DWORD HighFltF18;
                    781:     DWORD HighFltF19;
                    782:     DWORD HighFltF20;
                    783:     DWORD HighFltF21;
                    784:     DWORD HighFltF22;
                    785:     DWORD HighFltF23;
                    786:     DWORD HighFltF24;
                    787:     DWORD HighFltF25;
                    788:     DWORD HighFltF26;
                    789:     DWORD HighFltF27;
                    790:     DWORD HighFltF28;
                    791:     DWORD HighFltF29;
                    792:     DWORD HighFltF30;
                    793:     DWORD HighFltF31;
                    794: 
                    795:     DWORD HighIntV0;        //  $0: return value register, v0
                    796:     DWORD HighIntT0;        //  $1: temporary registers, t0 - t7
                    797:     DWORD HighIntT1;        //  $2:
                    798:     DWORD HighIntT2;        //  $3:
                    799:     DWORD HighIntT3;        //  $4:
                    800:     DWORD HighIntT4;        //  $5:
                    801:     DWORD HighIntT5;        //  $6:
                    802:     DWORD HighIntT6;        //  $7:
                    803:     DWORD HighIntT7;        //  $8:
                    804:     DWORD HighIntS0;        //  $9: nonvolatile registers, s0 - s5
                    805:     DWORD HighIntS1;        // $10:
                    806:     DWORD HighIntS2;        // $11:
                    807:     DWORD HighIntS3;        // $12:
                    808:     DWORD HighIntS4;        // $13:
                    809:     DWORD HighIntS5;        // $14:
                    810:     DWORD HighIntFp;        // $15: frame pointer register, fp/s6
                    811:     DWORD HighIntA0;        // $16: argument registers, a0 - a5
                    812:     DWORD HighIntA1;        // $17:
                    813:     DWORD HighIntA2;        // $18:
                    814:     DWORD HighIntA3;        // $19:
                    815:     DWORD HighIntA4;        // $20:
                    816:     DWORD HighIntA5;        // $21:
                    817:     DWORD HighIntT8;        // $22: temporary registers, t8 - t11
                    818:     DWORD HighIntT9;        // $23:
                    819:     DWORD HighIntT10;       // $24:
                    820:     DWORD HighIntT11;       // $25:
                    821:     DWORD HighIntRa;        // $26: return address register, ra
                    822:     DWORD HighIntT12;       // $27: temporary register, t12
                    823:     DWORD HighIntAt;        // $28: assembler temp register, at
                    824:     DWORD HighIntGp;        // $29: global pointer register, gp
                    825:     DWORD HighIntSp;        // $30: stack pointer register, sp
                    826:     DWORD HighIntZero;      // $31: zero register, zero
                    827: 
                    828:     DWORD HighFpcr;         // floating point control register
                    829:     DWORD HighSoftFpcr;     // software extension to FPCR
                    830:     DWORD HighFir;          // processor status
                    831: 
                    832:     double DoNotUseThisField; // to force quadword structure alignment
                    833:     DWORD HighFill[2];      // padding for 16-byte stack frame alignment
                    834: 
                    835: } CONTEXT, *PCONTEXT;
                    836: 
                    837: //
                    838: // These should name the fields in the _PORTABLE_32BIT structure
                    839: // that overlay the Psr and ContextFlags in the normal structure.
                    840: //
                    841: 
                    842: #define _QUAD_PSR_OFFSET   HighSoftFpcr
                    843: #define _QUAD_FLAGS_OFFSET HighFir
                    844: 
                    845: #endif // _PORTABLE_32BIT_CONTEXT
                    846: 
                    847: // end_ntddk end_nthal
                    848: 
                    849: #endif // _ALPHA_
                    850: 
                    851: 
                    852: #ifdef _ALPHA_
                    853: 
                    854: VOID
                    855: __jump_unwind (
                    856:     PVOID VirtualFramePointer,
                    857:     PVOID TargetPc
                    858:     );
                    859: 
                    860: #endif // _ALPHA_
                    861: 
                    862: 
                    863: #ifdef _X86_
                    864: 
                    865: //
                    866: // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
                    867: // writers to not leave them inadvertantly in their code.
                    868: //
                    869: 
                    870: #if !defined(MIDL_PASS)
                    871: #if !defined(_CFRONT_PASS_)
                    872: #if !defined(RC_INVOKED)
                    873: 
                    874: #pragma warning(disable:4164)   // disable C4164 warning so that apps that
                    875:                                 // build with /Od don't get weird errors !
                    876: #pragma function(_enable)
                    877: #pragma function(_disable)
                    878: 
                    879: #pragma warning(default:4164)   // reenable C4164 warning
                    880: 
                    881: #endif
                    882: #endif
                    883: #endif
                    884: 
1.1       root      885: 
                    886: //
                    887: //  Define the size of the 80387 save area, which is in the context frame.
                    888: //
                    889: 
                    890: #define SIZE_OF_80387_REGISTERS      80
                    891: 
                    892: //
                    893: // The following flags control the contents of the CONTEXT structure.
                    894: //
                    895: 
                    896: #define CONTEXT_i386    0x00010000    // this assumes that i386 and
1.1.1.2   root      897: #define CONTEXT_i486    0x00010000    // i486 have identical context records
1.1       root      898: 
                    899: #define CONTEXT_CONTROL         (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
                    900: #define CONTEXT_INTEGER         (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
                    901: #define CONTEXT_SEGMENTS        (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
                    902: #define CONTEXT_FLOATING_POINT  (CONTEXT_i386 | 0x00000008L) // 387 state
                    903: #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
                    904: 
                    905: #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER |\
1.1.1.2   root      906:                       CONTEXT_SEGMENTS)
1.1       root      907: 
                    908: typedef struct _FLOATING_SAVE_AREA {
                    909:     DWORD   ControlWord;
                    910:     DWORD   StatusWord;
                    911:     DWORD   TagWord;
                    912:     DWORD   ErrorOffset;
                    913:     DWORD   ErrorSelector;
                    914:     DWORD   DataOffset;
                    915:     DWORD   DataSelector;
                    916:     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
1.1.1.2   root      917:     DWORD   Cr0NpxState;
1.1       root      918: } FLOATING_SAVE_AREA;
                    919: 
                    920: typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
                    921: 
                    922: //
                    923: // Context Frame
                    924: //
                    925: //  This frame has a several purposes: 1) it is used as an argument to
                    926: //  NtContinue, 2) is is used to constuct a call frame for APC delivery,
                    927: //  and 3) it is used in the user level thread creation routines.
                    928: //
                    929: //  The layout of the record conforms to a standard call frame.
                    930: //
                    931: 
                    932: typedef struct _CONTEXT {
                    933: 
                    934:     //
                    935:     // The flags values within this flag control the contents of
                    936:     // a CONTEXT record.
                    937:     //
                    938:     // If the context record is used as an input parameter, then
                    939:     // for each portion of the context record controlled by a flag
                    940:     // whose value is set, it is assumed that that portion of the
                    941:     // context record contains valid context. If the context record
                    942:     // is being used to modify a threads context, then only that
                    943:     // portion of the threads context will be modified.
                    944:     //
                    945:     // If the context record is used as an IN OUT parameter to capture
                    946:     // the context of a thread, then only those portions of the thread's
                    947:     // context corresponding to set flags will be returned.
                    948:     //
                    949:     // The context record is never used as an OUT only parameter.
                    950:     //
                    951: 
                    952:     DWORD ContextFlags;
                    953: 
                    954:     //
                    955:     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
                    956:     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
                    957:     // included in CONTEXT_FULL.
                    958:     //
                    959: 
                    960:     DWORD   Dr0;
                    961:     DWORD   Dr1;
                    962:     DWORD   Dr2;
                    963:     DWORD   Dr3;
                    964:     DWORD   Dr6;
                    965:     DWORD   Dr7;
                    966: 
                    967:     //
                    968:     // This section is specified/returned if the
                    969:     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
                    970:     //
                    971: 
                    972:     FLOATING_SAVE_AREA FloatSave;
                    973: 
                    974:     //
                    975:     // This section is specified/returned if the
                    976:     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
                    977:     //
                    978: 
                    979:     DWORD   SegGs;
                    980:     DWORD   SegFs;
                    981:     DWORD   SegEs;
                    982:     DWORD   SegDs;
                    983: 
                    984:     //
                    985:     // This section is specified/returned if the
                    986:     // ContextFlags word contians the flag CONTEXT_INTEGER.
                    987:     //
                    988: 
                    989:     DWORD   Edi;
                    990:     DWORD   Esi;
                    991:     DWORD   Ebx;
                    992:     DWORD   Edx;
                    993:     DWORD   Ecx;
                    994:     DWORD   Eax;
                    995: 
                    996:     //
                    997:     // This section is specified/returned if the
                    998:     // ContextFlags word contians the flag CONTEXT_CONTROL.
                    999:     //
                   1000: 
                   1001:     DWORD   Ebp;
                   1002:     DWORD   Eip;
                   1003:     DWORD   SegCs;              // MUST BE SANITIZED
                   1004:     DWORD   EFlags;             // MUST BE SANITIZED
                   1005:     DWORD   Esp;
                   1006:     DWORD   SegSs;
                   1007: 
                   1008: } CONTEXT;
                   1009: 
                   1010: 
                   1011: 
                   1012: typedef CONTEXT *PCONTEXT;
                   1013: 
1.1.1.4   root     1014: // begin_ntminiport
                   1015: 
                   1016: #endif //_X86_
                   1017: 
1.1       root     1018: 
                   1019: typedef struct _LDT_ENTRY {
                   1020:     WORD    LimitLow;
                   1021:     WORD    BaseLow;
                   1022:     union {
                   1023:         struct {
                   1024:             BYTE    BaseMid;
                   1025:             BYTE    Flags1;     // Declare as bytes to avoid alignment
                   1026:             BYTE    Flags2;     // Problems.
                   1027:             BYTE    BaseHi;
                   1028:         } Bytes;
                   1029:         struct {
                   1030:             DWORD   BaseMid : 8;
                   1031:             DWORD   Type : 5;
                   1032:             DWORD   Dpl : 2;
                   1033:             DWORD   Pres : 1;
                   1034:             DWORD   LimitHi : 4;
                   1035:             DWORD   Sys : 1;
                   1036:             DWORD   Reserved_0 : 1;
                   1037:             DWORD   Default_Big : 1;
                   1038:             DWORD   Granularity : 1;
                   1039:             DWORD   BaseHi : 8;
                   1040:         } Bits;
                   1041:     } HighWord;
                   1042: } LDT_ENTRY, *PLDT_ENTRY;
                   1043: 
                   1044: 
1.1.1.4   root     1045: #if defined(_MIPS_)
1.1       root     1046: 
1.1.1.4   root     1047: // begin_ntddk begin_nthal
1.1       root     1048: //
                   1049: // The following flags control the contents of the CONTEXT structure.
                   1050: //
                   1051: 
1.1.1.4   root     1052: #define CONTEXT_R4000   0x00010000    // r4000 context
1.1       root     1053: 
1.1.1.4   root     1054: #define CONTEXT_CONTROL         (CONTEXT_R4000 | 0x00000001L)
                   1055: #define CONTEXT_FLOATING_POINT  (CONTEXT_R4000 | 0x00000002L)
                   1056: #define CONTEXT_INTEGER         (CONTEXT_R4000 | 0x00000004L)
1.1       root     1057: 
                   1058: #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
                   1059: 
                   1060: //
                   1061: // Context Frame
                   1062: //
                   1063: //  N.B. This frame must be exactly a multiple of 16 bytes in length.
                   1064: //
                   1065: //  This frame has a several purposes: 1) it is used as an argument to
                   1066: //  NtContinue, 2) it is used to constuct a call frame for APC delivery,
                   1067: //  3) it is used to construct a call frame for exception dispatching
                   1068: //  in user mode, and 4) it is used in the user level thread creation
                   1069: //  routines.
                   1070: //
                   1071: //  The layout of the record conforms to a standard call frame.
                   1072: //
                   1073: 
                   1074: typedef struct _CONTEXT {
                   1075: 
                   1076:     //
                   1077:     // This section is always present and is used as an argument build
                   1078:     // area.
                   1079:     //
                   1080: 
                   1081:     DWORD Argument[4];
                   1082: 
                   1083:     //
                   1084:     // This section is specified/returned if the ContextFlags word contains
                   1085:     // the flag CONTEXT_FLOATING_POINT.
                   1086:     //
                   1087: 
                   1088:     DWORD FltF0;
                   1089:     DWORD FltF1;
                   1090:     DWORD FltF2;
                   1091:     DWORD FltF3;
                   1092:     DWORD FltF4;
                   1093:     DWORD FltF5;
                   1094:     DWORD FltF6;
                   1095:     DWORD FltF7;
                   1096:     DWORD FltF8;
                   1097:     DWORD FltF9;
                   1098:     DWORD FltF10;
                   1099:     DWORD FltF11;
                   1100:     DWORD FltF12;
                   1101:     DWORD FltF13;
                   1102:     DWORD FltF14;
                   1103:     DWORD FltF15;
                   1104:     DWORD FltF16;
                   1105:     DWORD FltF17;
                   1106:     DWORD FltF18;
                   1107:     DWORD FltF19;
                   1108:     DWORD FltF20;
                   1109:     DWORD FltF21;
                   1110:     DWORD FltF22;
                   1111:     DWORD FltF23;
                   1112:     DWORD FltF24;
                   1113:     DWORD FltF25;
                   1114:     DWORD FltF26;
                   1115:     DWORD FltF27;
                   1116:     DWORD FltF28;
                   1117:     DWORD FltF29;
                   1118:     DWORD FltF30;
                   1119:     DWORD FltF31;
                   1120: 
                   1121:     //
                   1122:     // This section is specified/returned if the ContextFlags word contains
                   1123:     // the flag CONTEXT_INTEGER.
                   1124:     //
                   1125:     // N.B. The registers gp, sp, and ra are defined in this section, but are
                   1126:     //  considered part of the control context rather than part of the integer
                   1127:     //  context.
                   1128:     //
                   1129:     // N.B. Register zero is not stored in the frame.
                   1130:     //
                   1131: 
                   1132:     DWORD IntZero;
                   1133:     DWORD IntAt;
                   1134:     DWORD IntV0;
                   1135:     DWORD IntV1;
                   1136:     DWORD IntA0;
                   1137:     DWORD IntA1;
                   1138:     DWORD IntA2;
                   1139:     DWORD IntA3;
                   1140:     DWORD IntT0;
                   1141:     DWORD IntT1;
                   1142:     DWORD IntT2;
                   1143:     DWORD IntT3;
                   1144:     DWORD IntT4;
                   1145:     DWORD IntT5;
                   1146:     DWORD IntT6;
                   1147:     DWORD IntT7;
                   1148:     DWORD IntS0;
                   1149:     DWORD IntS1;
                   1150:     DWORD IntS2;
                   1151:     DWORD IntS3;
                   1152:     DWORD IntS4;
                   1153:     DWORD IntS5;
                   1154:     DWORD IntS6;
                   1155:     DWORD IntS7;
                   1156:     DWORD IntT8;
                   1157:     DWORD IntT9;
                   1158:     DWORD IntK0;
                   1159:     DWORD IntK1;
                   1160:     DWORD IntGp;
                   1161:     DWORD IntSp;
                   1162:     DWORD IntS8;
                   1163:     DWORD IntRa;
                   1164:     DWORD IntLo;
                   1165:     DWORD IntHi;
                   1166: 
                   1167:     //
                   1168:     // This section is specified/returned if the ContextFlags word contains
                   1169:     // the flag CONTEXT_FLOATING_POINT.
                   1170:     //
                   1171: 
                   1172:     DWORD Fsr;
                   1173: 
                   1174:     //
                   1175:     // This section is specified/returned if the ContextFlags word contains
                   1176:     // the flag CONTEXT_CONTROL.
                   1177:     //
                   1178:     // N.B. The registers gp, sp, and ra are defined in the integer section,
                   1179:     //   but are considered part of the control context rather than part of
                   1180:     //   the integer context.
                   1181:     //
                   1182: 
                   1183:     DWORD Fir;
                   1184:     DWORD Psr;
                   1185: 
                   1186:     //
                   1187:     // The flags values within this flag control the contents of
                   1188:     // a CONTEXT record.
                   1189:     //
                   1190:     // If the context record is used as an input parameter, then
                   1191:     // for each portion of the context record controlled by a flag
                   1192:     // whose value is set, it is assumed that that portion of the
                   1193:     // context record contains valid context. If the context record
                   1194:     // is being used to modify a thread's context, then only that
                   1195:     // portion of the threads context will be modified.
                   1196:     //
                   1197:     // If the context record is used as an IN OUT parameter to capture
                   1198:     // the context of a thread, then only those portions of the thread's
                   1199:     // context corresponding to set flags will be returned.
                   1200:     //
                   1201:     // The context record is never used as an OUT only parameter.
                   1202:     //
                   1203: 
                   1204:     DWORD ContextFlags;
                   1205: 
                   1206:     DWORD Fill[2];
                   1207: } CONTEXT, *PCONTEXT;
                   1208: 
1.1.1.4   root     1209: // end_ntddk end_nthal
                   1210: 
1.1       root     1211: #endif // MIPS
                   1212: 
                   1213: 
1.1.1.4   root     1214: #if defined(_MIPS_)
1.1       root     1215: 
                   1216: VOID
                   1217: __jump_unwind (
                   1218:     PVOID Fp,
                   1219:     PVOID TargetPc
                   1220:     );
                   1221: 
                   1222: #endif // MIPS
                   1223: 
                   1224: #define EXCEPTION_NONCONTINUABLE 0x1    // Noncontinuable exception
1.1.1.2   root     1225: #define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters
1.1       root     1226: 
                   1227: //
                   1228: // Exception record definition.
                   1229: //
                   1230: 
                   1231: typedef struct _EXCEPTION_RECORD {
1.1.1.2   root     1232:     /*lint -e18 */  // Don't complain about different definitions
1.1       root     1233:     DWORD    ExceptionCode;
1.1.1.2   root     1234:     /*lint +e18 */  // Resume checking for different definitions
1.1       root     1235:     DWORD ExceptionFlags;
                   1236:     struct _EXCEPTION_RECORD *ExceptionRecord;
                   1237:     PVOID ExceptionAddress;
                   1238:     DWORD NumberParameters;
                   1239:     DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
                   1240:     } EXCEPTION_RECORD;
                   1241: 
                   1242: typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
                   1243: 
                   1244: //
                   1245: // Typedef for pointer returned by exception_info()
                   1246: //
                   1247: 
                   1248: typedef struct _EXCEPTION_POINTERS {
                   1249:     PEXCEPTION_RECORD ExceptionRecord;
                   1250:     PCONTEXT ContextRecord;
                   1251: } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
                   1252: #define PROCESS_TERMINATE         (0x0001)  
1.1.1.2   root     1253: #define PROCESS_CREATE_THREAD     (0x0002)  
                   1254: #define PROCESS_VM_OPERATION      (0x0008)  
1.1       root     1255: #define PROCESS_VM_READ           (0x0010)  
                   1256: #define PROCESS_VM_WRITE          (0x0020)  
                   1257: #define PROCESS_DUP_HANDLE        (0x0040)  
                   1258: #define PROCESS_CREATE_PROCESS    (0x0080)  
                   1259: #define PROCESS_SET_INFORMATION   (0x0200)  
                   1260: #define PROCESS_QUERY_INFORMATION (0x0400)  
                   1261: #define PROCESS_ALL_ACCESS        (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
                   1262:                                    0xFFF)
1.1.1.2   root     1263: 
1.1       root     1264: #define THREAD_TERMINATE               (0x0001)  
                   1265: #define THREAD_SUSPEND_RESUME          (0x0002)  
                   1266: #define THREAD_GET_CONTEXT             (0x0008)  
                   1267: #define THREAD_SET_CONTEXT             (0x0010)  
                   1268: #define THREAD_SET_INFORMATION         (0x0020)  
                   1269: #define THREAD_QUERY_INFORMATION       (0x0040)  
                   1270: #define THREAD_SET_THREAD_TOKEN        (0x0080)
                   1271: #define THREAD_IMPERSONATE             (0x0100)
                   1272: #define THREAD_DIRECT_IMPERSONATION    (0x0200)
1.1.1.4   root     1273: // begin_ntddk
                   1274: 
1.1       root     1275: #define THREAD_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
                   1276:                                    0x3FF)
1.1.1.4   root     1277: 
                   1278: // end_ntddk
1.1       root     1279: #define TLS_MINIMUM_AVAILABLE 64    
1.1.1.3   root     1280: #define THREAD_BASE_PRIORITY_LOWRT  15  // value that gets a thread to LowRealtime-1
1.1       root     1281: #define THREAD_BASE_PRIORITY_MAX    2   // maximum thread base priority boost
                   1282: #define THREAD_BASE_PRIORITY_MIN    -2  // minimum thread base priority boost
1.1.1.3   root     1283: #define THREAD_BASE_PRIORITY_IDLE   -15 // value that gets a thread to idle
1.1       root     1284: #define EVENT_MODIFY_STATE      0x0002  
                   1285: #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 
                   1286: #define MUTANT_QUERY_STATE      0x0001
                   1287: 
                   1288: #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
                   1289:                           MUTANT_QUERY_STATE)
                   1290: #define SEMAPHORE_MODIFY_STATE      0x0002  
                   1291: #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 
1.1.1.3   root     1292: #define TIME_ZONE_ID_UNKNOWN  0
                   1293: #define TIME_ZONE_ID_STANDARD 1
                   1294: #define TIME_ZONE_ID_DAYLIGHT 2
1.1       root     1295: 
                   1296: #define PROCESSOR_INTEL_386     386
                   1297: #define PROCESSOR_INTEL_486     486
1.1.1.4   root     1298: #define PROCESSOR_INTEL_PENTIUM 586
1.1       root     1299: #define PROCESSOR_INTEL_860     860
                   1300: #define PROCESSOR_MIPS_R2000    2000
                   1301: #define PROCESSOR_MIPS_R3000    3000
                   1302: #define PROCESSOR_MIPS_R4000    4000
1.1.1.4   root     1303: #define PROCESSOR_ALPHA_21064   21064
1.1       root     1304: 
                   1305: typedef struct _MEMORY_BASIC_INFORMATION {
                   1306:     PVOID BaseAddress;
                   1307:     PVOID AllocationBase;
                   1308:     DWORD AllocationProtect;
                   1309:     DWORD RegionSize;
                   1310:     DWORD State;
                   1311:     DWORD Protect;
                   1312:     DWORD Type;
1.1.1.2   root     1313: } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
1.1       root     1314: #define SECTION_QUERY       0x0001
                   1315: #define SECTION_MAP_WRITE   0x0002
                   1316: #define SECTION_MAP_READ    0x0004
                   1317: #define SECTION_MAP_EXECUTE 0x0008
                   1318: #define SECTION_EXTEND_SIZE 0x0010
                   1319: 
                   1320: #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
                   1321:                             SECTION_MAP_WRITE |      \
                   1322:                             SECTION_MAP_READ |       \
                   1323:                             SECTION_MAP_EXECUTE |    \
                   1324:                             SECTION_EXTEND_SIZE)
                   1325: #define PAGE_NOACCESS          0x01     
                   1326: #define PAGE_READONLY          0x02     
                   1327: #define PAGE_READWRITE         0x04     
1.1.1.4   root     1328: #define PAGE_WRITECOPY         0x08     
                   1329: #define PAGE_EXECUTE           0x10     
                   1330: #define PAGE_EXECUTE_READ      0x20     
                   1331: #define PAGE_EXECUTE_READWRITE 0x40     
                   1332: #define PAGE_EXECUTE_WRITECOPY 0x80     
                   1333: #define PAGE_GUARD            0x100     
                   1334: #define PAGE_NOCACHE          0x200     
1.1       root     1335: #define MEM_COMMIT           0x1000     
                   1336: #define MEM_RESERVE          0x2000     
                   1337: #define MEM_DECOMMIT         0x4000     
                   1338: #define MEM_RELEASE          0x8000     
                   1339: #define MEM_FREE            0x10000     
                   1340: #define MEM_PRIVATE         0x20000     
1.1.1.4   root     1341: #define MEM_MAPPED          0x40000     
                   1342: #define MEM_TOP_DOWN       0x100000     
                   1343: #define SEC_FILE           0x800000     
                   1344: #define SEC_IMAGE         0x1000000     
                   1345: #define SEC_RESERVE       0x4000000     
                   1346: #define SEC_COMMIT        0x8000000     
                   1347: #define SEC_NOCACHE      0x10000000     
                   1348: #define MEM_IMAGE         SEC_IMAGE     
                   1349: 
                   1350: //
                   1351: // Define access rights to files and directories
                   1352: //
                   1353: 
                   1354: //
                   1355: // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
                   1356: // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
                   1357: // constants *MUST* always be in sync.
                   1358: // The values are redefined in devioctl.h because they must be available to
                   1359: // both DOS and NT.
                   1360: //
                   1361: 
                   1362: #define FILE_READ_DATA            ( 0x0001 )    // file & pipe
                   1363: #define FILE_LIST_DIRECTORY       ( 0x0001 )    // directory
                   1364: 
                   1365: #define FILE_WRITE_DATA           ( 0x0002 )    // file & pipe
                   1366: #define FILE_ADD_FILE             ( 0x0002 )    // directory
                   1367: 
                   1368: #define FILE_APPEND_DATA          ( 0x0004 )    // file
                   1369: #define FILE_ADD_SUBDIRECTORY     ( 0x0004 )    // directory
                   1370: #define FILE_CREATE_PIPE_INSTANCE ( 0x0004 )    // named pipe
                   1371: 
                   1372: #define FILE_READ_EA              ( 0x0008 )    // file & directory
                   1373: 
                   1374: #define FILE_WRITE_EA             ( 0x0010 )    // file & directory
                   1375: 
                   1376: #define FILE_EXECUTE              ( 0x0020 )    // file
                   1377: #define FILE_TRAVERSE             ( 0x0020 )    // directory
                   1378: 
                   1379: #define FILE_DELETE_CHILD         ( 0x0040 )    // directory
                   1380: 
                   1381: #define FILE_READ_ATTRIBUTES      ( 0x0080 )    // all
                   1382: 
                   1383: #define FILE_WRITE_ATTRIBUTES     ( 0x0100 )    // all
                   1384: 
                   1385: #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
                   1386: 
                   1387: 
                   1388: #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ     |\
                   1389:                                    FILE_READ_DATA           |\
                   1390:                                    FILE_READ_ATTRIBUTES     |\
                   1391:                                    FILE_READ_EA             |\
                   1392:                                    SYNCHRONIZE)
                   1393: 
                   1394: 
                   1395: #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE    |\
                   1396:                                    FILE_WRITE_DATA          |\
                   1397:                                    FILE_WRITE_ATTRIBUTES    |\
                   1398:                                    FILE_WRITE_EA            |\
                   1399:                                    FILE_APPEND_DATA         |\
                   1400:                                    SYNCHRONIZE)
                   1401: 
                   1402: 
                   1403: #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE  |\
                   1404:                                    FILE_READ_ATTRIBUTES     |\
                   1405:                                    FILE_EXECUTE             |\
                   1406:                                    SYNCHRONIZE)
                   1407: 
1.1       root     1408: #define FILE_SHARE_READ                 0x00000001  
                   1409: #define FILE_SHARE_WRITE                0x00000002  
                   1410: #define FILE_ATTRIBUTE_READONLY         0x00000001  
                   1411: #define FILE_ATTRIBUTE_HIDDEN           0x00000002  
                   1412: #define FILE_ATTRIBUTE_SYSTEM           0x00000004  
1.1.1.2   root     1413: #define FILE_ATTRIBUTE_DIRECTORY        0x00000010  
1.1       root     1414: #define FILE_ATTRIBUTE_ARCHIVE          0x00000020  
                   1415: #define FILE_ATTRIBUTE_NORMAL           0x00000080  
1.1.1.2   root     1416: #define FILE_ATTRIBUTE_TEMPORARY        0x00000100  
                   1417: #define FILE_ATTRIBUTE_ATOMIC_WRITE     0x00000200  
                   1418: #define FILE_ATTRIBUTE_XACTION_WRITE    0x00000400  
                   1419: #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001   
                   1420: #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002   
                   1421: #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004   
                   1422: #define FILE_NOTIFY_CHANGE_SIZE         0x00000008   
                   1423: #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010   
                   1424: #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100   
1.1.1.4   root     1425: #define MAILSLOT_NO_MESSAGE             ((DWORD)-1) 
                   1426: #define MAILSLOT_WAIT_FOREVER           ((DWORD)-1) 
1.1       root     1427: #define FILE_CASE_SENSITIVE_SEARCH      0x00000001  
                   1428: #define FILE_CASE_PRESERVED_NAMES       0x00000002  
                   1429: #define FILE_UNICODE_ON_DISK            0x00000004  
1.1.1.3   root     1430: #define FILE_PERSISTENT_ACLS            0x00000008  
1.1       root     1431: #define DUPLICATE_CLOSE_SOURCE      0x00000001  
                   1432: #define DUPLICATE_SAME_ACCESS       0x00000002  
1.1.1.2   root     1433: typedef PVOID PACCESS_TOKEN;            
1.1       root     1434: typedef PVOID PSECURITY_DESCRIPTOR;     
                   1435: typedef PVOID PSID;     
1.1.1.2   root     1436: ////////////////////////////////////////////////////////////////////////
                   1437: //                                                                    //
                   1438: //                             ACCESS MASK                            //
                   1439: //                                                                    //
                   1440: ////////////////////////////////////////////////////////////////////////
                   1441: 
                   1442: //
                   1443: //  Define the access mask as a longword sized structure divided up as
                   1444: //  follows:
                   1445: //
                   1446: //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
                   1447: //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
                   1448: //      +---------------+---------------+-------------------------------+
                   1449: //      |G|G|G|G|Res'd|A| StandardRights|         SpecificRights        |
                   1450: //      |R|W|E|A|     |S|               |                               |
                   1451: //      +-+-------------+---------------+-------------------------------+
                   1452: //
                   1453: //      typedef struct _ACCESS_MASK {
                   1454: //          WORD   SpecificRights;
                   1455: //          BYTE  StandardRights;
                   1456: //          BYTE  AccessSystemAcl : 1;
                   1457: //          BYTE  Reserved : 3;
                   1458: //          BYTE  GenericAll : 1;
                   1459: //          BYTE  GenericExecute : 1;
                   1460: //          BYTE  GenericWrite : 1;
                   1461: //          BYTE  GenericRead : 1;
                   1462: //      } ACCESS_MASK;
                   1463: //      typedef ACCESS_MASK *PACCESS_MASK;
                   1464: //
                   1465: //  but to make life simple for programmer's we'll allow them to specify
                   1466: //  a desired access mask by simply OR'ing together mulitple single rights
1.1.1.4   root     1467: //  and treat an access mask as a DWORD.  For example
1.1.1.2   root     1468: //
                   1469: //      DesiredAccess = DELETE | READ_CONTROL
                   1470: //
                   1471: //  So we'll declare ACCESS_MASK as DWORD
                   1472: //
                   1473: 
1.1.1.4   root     1474: // begin_ntddk begin_nthal
1.1.1.2   root     1475: typedef DWORD ACCESS_MASK;
                   1476: typedef ACCESS_MASK *PACCESS_MASK;
                   1477: 
                   1478: ////////////////////////////////////////////////////////////////////////
                   1479: //                                                                    //
                   1480: //                             ACCESS TYPES                           //
                   1481: //                                                                    //
                   1482: ////////////////////////////////////////////////////////////////////////
                   1483: 
                   1484: 
1.1.1.4   root     1485: // begin_ntddk begin_nthal
1.1.1.2   root     1486: //
                   1487: //  The following are masks for the predefined standard access types
                   1488: //
                   1489: 
1.1       root     1490: #define DELETE                           (0x00010000L)
                   1491: #define READ_CONTROL                     (0x00020000L)
                   1492: #define WRITE_DAC                        (0x00040000L)
                   1493: #define WRITE_OWNER                      (0x00080000L)
                   1494: #define SYNCHRONIZE                      (0x00100000L)
                   1495: 
                   1496: #define STANDARD_RIGHTS_REQUIRED         (0x000F0000L)
                   1497: 
                   1498: #define STANDARD_RIGHTS_READ             (READ_CONTROL)
                   1499: #define STANDARD_RIGHTS_WRITE            (READ_CONTROL)
                   1500: #define STANDARD_RIGHTS_EXECUTE          (READ_CONTROL)
                   1501: 
                   1502: #define STANDARD_RIGHTS_ALL              (0x001F0000L)
                   1503: 
                   1504: #define SPECIFIC_RIGHTS_ALL              (0x0000FFFFL)
                   1505: 
                   1506: //
                   1507: // AccessSystemAcl access type
                   1508: //
                   1509: 
                   1510: #define ACCESS_SYSTEM_SECURITY           (0x01000000L)
                   1511: 
                   1512: //
                   1513: // MaximumAllowed access type
                   1514: //
                   1515: 
                   1516: #define MAXIMUM_ALLOWED                  (0x02000000L)
                   1517: 
                   1518: //
                   1519: //  These are the generic rights.
                   1520: //
                   1521: 
                   1522: #define GENERIC_READ                     (0x80000000L)
                   1523: #define GENERIC_WRITE                    (0x40000000L)
                   1524: #define GENERIC_EXECUTE                  (0x20000000L)
                   1525: #define GENERIC_ALL                      (0x10000000L)
1.1.1.2   root     1526: 
                   1527: 
                   1528: //
                   1529: //  Define the generic mapping array.  This is used to denote the
                   1530: //  mapping of each generic access right to a specific access mask.
                   1531: //
                   1532: 
                   1533: typedef struct _GENERIC_MAPPING {
                   1534:     ACCESS_MASK GenericRead;
                   1535:     ACCESS_MASK GenericWrite;
                   1536:     ACCESS_MASK GenericExecute;
                   1537:     ACCESS_MASK GenericAll;
                   1538: } GENERIC_MAPPING;
                   1539: typedef GENERIC_MAPPING *PGENERIC_MAPPING;
                   1540: 
                   1541: 
                   1542: 
                   1543: ////////////////////////////////////////////////////////////////////////
                   1544: //                                                                    //
                   1545: //                        LUID_AND_ATTRIBUTES                         //
                   1546: //                                                                    //
                   1547: ////////////////////////////////////////////////////////////////////////
                   1548: //
                   1549: //
                   1550: 
                   1551: 
1.1.1.4   root     1552: #ifndef RC_INVOKED
                   1553: #pragma pack(4)
                   1554: #endif
                   1555: 
1.1.1.2   root     1556: typedef struct _LUID_AND_ATTRIBUTES {
                   1557:     LUID Luid;
                   1558:     DWORD Attributes;
                   1559:     } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
                   1560: typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
                   1561: typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
                   1562: 
1.1.1.4   root     1563: #ifndef RC_INVOKED
                   1564: #pragma pack()
                   1565: #endif
                   1566: 
1.1.1.2   root     1567: 
                   1568: ////////////////////////////////////////////////////////////////////////
                   1569: //                                                                    //
                   1570: //              Security Id     (SID)                                 //
                   1571: //                                                                    //
                   1572: ////////////////////////////////////////////////////////////////////////
                   1573: //
                   1574: //
                   1575: // Pictorially the structure of an SID is as follows:
                   1576: //
                   1577: //         1   1   1   1   1   1
                   1578: //         5   4   3   2   1   0   9   8   7   6   5   4   3   2   1   0
                   1579: //      +---------------------------------------------------------------+
                   1580: //      |      SubAuthorityCount        |Reserved1 (SBZ)|   Revision    |
                   1581: //      +---------------------------------------------------------------+
                   1582: //      |                   IdentifierAuthority[0]                      |
                   1583: //      +---------------------------------------------------------------+
                   1584: //      |                   IdentifierAuthority[1]                      |
                   1585: //      +---------------------------------------------------------------+
                   1586: //      |                   IdentifierAuthority[2]                      |
                   1587: //      +---------------------------------------------------------------+
                   1588: //      |                                                               |
                   1589: //      +- -  -  -  -  -  -  -  SubAuthority[]  -  -  -  -  -  -  -  - -+
                   1590: //      |                                                               |
                   1591: //      +---------------------------------------------------------------+
                   1592: //
                   1593: //
                   1594: 
                   1595: typedef struct _SID_IDENTIFIER_AUTHORITY {
                   1596:     BYTE  Value[6];
                   1597: } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
                   1598: 
                   1599: 
                   1600: typedef struct _SID {
                   1601:    BYTE  Revision;
                   1602:    BYTE  SubAuthorityCount;
                   1603:    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
                   1604: #ifdef MIDL_PASS
                   1605:    [size_is(SubAuthorityCount)] DWORD SubAuthority[*];
                   1606: #else // MIDL_PASS
                   1607:    DWORD SubAuthority[ANYSIZE_ARRAY];
                   1608: #endif // MIDL_PASS
                   1609: } SID, *PISID;
                   1610: 
                   1611: 
                   1612: #define SID_REVISION                     (1)    // Current revision level
                   1613: #define SID_MAX_SUB_AUTHORITIES          (15)
                   1614: #define SID_RECOMMENDED_SUB_AUTHORITIES  (1)    // Will change to around 6
                   1615:                                                 // in a future release.
                   1616: 
                   1617: typedef enum _SID_NAME_USE {
                   1618:     SidTypeUser = 1,
                   1619:     SidTypeGroup,
                   1620:     SidTypeDomain,
                   1621:     SidTypeAlias,
                   1622:     SidTypeWellKnownGroup,
                   1623:     SidTypeDeletedAccount,
                   1624:     SidTypeInvalid,
                   1625:     SidTypeUnknown
                   1626: } SID_NAME_USE, *PSID_NAME_USE;
                   1627: 
                   1628: 
                   1629: typedef struct _SID_AND_ATTRIBUTES {
                   1630:     PSID Sid;
                   1631:     DWORD Attributes;
                   1632:     } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
                   1633: 
                   1634: typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
                   1635: typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
                   1636: 
                   1637: 
                   1638: 
                   1639: /////////////////////////////////////////////////////////////////////////////
                   1640: //                                                                         //
                   1641: // Universal well-known SIDs                                               //
                   1642: //                                                                         //
                   1643: //     Null SID              S-1-0-0                                       //
                   1644: //     World                 S-1-1-0                                       //
                   1645: //     Local                 S-1-2-0                                       //
                   1646: //     Creator Owner ID      S-1-3-0                                       //
                   1647: //     Creator Group ID      S-1-3-1                                       //
                   1648: //                                                                         //
1.1.1.4   root     1649: //     (Non-unique IDs)      S-1-4                                         //
                   1650: //                                                                         //
1.1.1.2   root     1651: /////////////////////////////////////////////////////////////////////////////
                   1652: 
                   1653: #define SECURITY_NULL_SID_AUTHORITY     {0,0,0,0,0,0}
                   1654: #define SECURITY_WORLD_SID_AUTHORITY    {0,0,0,0,0,1}
                   1655: #define SECURITY_LOCAL_SID_AUTHORITY    {0,0,0,0,0,2}
                   1656: #define SECURITY_CREATOR_SID_AUTHORITY  {0,0,0,0,0,3}
1.1.1.4   root     1657: #define SECURITY_NON_UNIQUE_AUTHORITY   {0,0,0,0,0,4}
1.1.1.2   root     1658: 
                   1659: #define SECURITY_NULL_RID               (0x00000000L)
                   1660: #define SECURITY_WORLD_RID              (0x00000000L)
                   1661: #define SECURITY_LOCAL_RID              (0X00000000L)
                   1662: 
                   1663: #define SECURITY_CREATOR_OWNER_RID      (0x00000000L)
                   1664: #define SECURITY_CREATOR_GROUP_RID      (0x00000001L)
                   1665: 
                   1666: 
                   1667: 
                   1668: 
                   1669: /////////////////////////////////////////////////////////////////////////////
                   1670: //                                                                         //
                   1671: // NT well-known SIDs                                                      //
                   1672: //                                                                         //
                   1673: //     NT Authority          S-1-5                                         //
                   1674: //     Dialup                S-1-5-1                                       //
                   1675: //                                                                         //
                   1676: //     Network               S-1-5-2                                       //
                   1677: //     Batch                 S-1-5-3                                       //
                   1678: //     Interactive           S-1-5-4                                       //
                   1679: //     Service               S-1-5-6                                       //
1.1.1.4   root     1680: //     AnonymousLogon        S-1-5-7       (aka null logon session)        //
1.1.1.2   root     1681: //                                                                         //
                   1682: //     (Logon IDs)           S-1-5-5-X-Y                                   //
                   1683: //                                                                         //
1.1.1.4   root     1684: //     (NT non-unique IDs)   S-1-5-0x15-...                                //
                   1685: //                                                                         //
                   1686: //     (Built-in domain)     s-1-5-0x20                                    //
1.1.1.2   root     1687: //                                                                         //
                   1688: /////////////////////////////////////////////////////////////////////////////
                   1689: 
                   1690: 
                   1691: #define SECURITY_NT_AUTHORITY           {0,0,0,0,0,5}
                   1692: 
                   1693: #define SECURITY_DIALUP_RID             (0x00000001L)
                   1694: #define SECURITY_NETWORK_RID            (0x00000002L)
                   1695: #define SECURITY_BATCH_RID              (0x00000003L)
                   1696: #define SECURITY_INTERACTIVE_RID        (0x00000004L)
                   1697: #define SECURITY_SERVICE_RID            (0x00000006L)
1.1.1.4   root     1698: #define SECURITY_ANONYMOUS_LOGON_RID    (0x00000007L)
1.1.1.2   root     1699: 
                   1700: #define SECURITY_LOGON_IDS_RID          (0x00000005L)
                   1701: #define SECURITY_LOGON_IDS_RID_COUNT    (3L)
                   1702: 
                   1703: #define SECURITY_LOCAL_SYSTEM_RID       (0x00000012L)
                   1704: 
1.1.1.4   root     1705: #define SECURITY_NT_NON_UNIQUE          (0x00000015L)
                   1706: 
1.1.1.2   root     1707: #define SECURITY_BUILTIN_DOMAIN_RID     (0x00000020L)
                   1708: 
                   1709: 
                   1710: 
                   1711: 
                   1712: 
                   1713: /////////////////////////////////////////////////////////////////////////////
                   1714: //                                                                         //
                   1715: // well-known domain relative sub-authority values (RIDs)...               //
                   1716: //                                                                         //
                   1717: /////////////////////////////////////////////////////////////////////////////
                   1718: 
                   1719: // Well-known users ...
                   1720: 
                   1721: #define DOMAIN_USER_RID_ADMIN          (0x000001F4L)
                   1722: #define DOMAIN_USER_RID_GUEST          (0x000001F5L)
                   1723: 
                   1724: 
                   1725: 
                   1726: // well-known groups ...
                   1727: 
                   1728: #define DOMAIN_GROUP_RID_ADMINS        (0x00000200L)
                   1729: #define DOMAIN_GROUP_RID_USERS         (0x00000201L)
                   1730: 
                   1731: 
                   1732: 
                   1733: 
                   1734: // well-known aliases ...
                   1735: 
                   1736: #define DOMAIN_ALIAS_RID_ADMINS        (0x00000220L)
                   1737: #define DOMAIN_ALIAS_RID_USERS         (0x00000221L)
                   1738: #define DOMAIN_ALIAS_RID_GUESTS        (0x00000222L)
                   1739: #define DOMAIN_ALIAS_RID_POWER_USERS   (0x00000223L)
                   1740: 
                   1741: #define DOMAIN_ALIAS_RID_ACCOUNT_OPS   (0x00000224L)
                   1742: #define DOMAIN_ALIAS_RID_SYSTEM_OPS    (0x00000225L)
                   1743: #define DOMAIN_ALIAS_RID_PRINT_OPS     (0x00000226L)
                   1744: #define DOMAIN_ALIAS_RID_BACKUP_OPS    (0x00000227L)
                   1745: 
                   1746: #define DOMAIN_ALIAS_RID_REPLICATOR    (0x00000228L)
                   1747: 
                   1748: 
                   1749: 
                   1750: 
                   1751: 
                   1752: 
                   1753: //
                   1754: // Allocate the System Luid.  The first 1000 LUIDs are reserved.
                   1755: // Use #999 here (0x3E7 = 999)
                   1756: //
                   1757: 
1.1.1.4   root     1758: #define SYSTEM_LUID                     { 0x3E7, 0x0 }
1.1.1.2   root     1759: 
                   1760: 
                   1761: 
                   1762: ////////////////////////////////////////////////////////////////////////
                   1763: //                                                                    //
                   1764: //                          User and Group related SID attributes     //
                   1765: //                                                                    //
                   1766: ////////////////////////////////////////////////////////////////////////
                   1767: 
                   1768: //
                   1769: // Group attributes
                   1770: //
                   1771: 
                   1772: #define SE_GROUP_MANDATORY              (0x00000001L)
                   1773: #define SE_GROUP_ENABLED_BY_DEFAULT     (0x00000002L)
                   1774: #define SE_GROUP_ENABLED                (0x00000004L)
                   1775: #define SE_GROUP_OWNER                  (0x00000008L)
                   1776: #define SE_GROUP_LOGON_ID               (0xC0000000L)
                   1777: 
                   1778: 
                   1779: 
                   1780: //
                   1781: // User attributes
                   1782: //
                   1783: 
                   1784: // (None yet defined.)
                   1785: 
                   1786: 
                   1787: 
                   1788: 
                   1789: ////////////////////////////////////////////////////////////////////////
                   1790: //                                                                    //
                   1791: //                         ACL  and  ACE                              //
                   1792: //                                                                    //
                   1793: ////////////////////////////////////////////////////////////////////////
                   1794: 
                   1795: //
                   1796: //  Define an ACL and the ACE format.  The structure of an ACL header
                   1797: //  followed by one or more ACEs.  Pictorally the structure of an ACL header
                   1798: //  is as follows:
                   1799: //
                   1800: //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
                   1801: //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
                   1802: //      +-------------------------------+---------------+---------------+
                   1803: //      |            AclSize            |      Sbz1     |  AclRevision  |
                   1804: //      +-------------------------------+---------------+---------------+
                   1805: //      |              Sbz2             |           AceCount            |
                   1806: //      +-------------------------------+-------------------------------+
                   1807: //
                   1808: //  The current AclRevision is defined to be ACL_REVISION.
                   1809: //
                   1810: //  AclSize is the size, in bytes, allocated for the ACL.  This includes
                   1811: //  the ACL header, ACES, and remaining free space in the buffer.
                   1812: //
                   1813: //  AceCount is the number of ACES in the ACL.
                   1814: //
                   1815: 
1.1.1.4   root     1816: // begin_ntddk
1.1.1.2   root     1817: // This is the *current* ACL revision
                   1818: 
                   1819: #define ACL_REVISION     (2)
                   1820: 
                   1821: // This is the history of ACL revisions.  Add a new one whenever
                   1822: // ACL_REVISION is updated
                   1823: 
                   1824: #define ACL_REVISION1   (1)
                   1825: #define ACL_REVISION2   (2)
                   1826: 
                   1827: typedef struct _ACL {
                   1828:     BYTE  AclRevision;
                   1829:     BYTE  Sbz1;
                   1830:     WORD   AclSize;
                   1831:     WORD   AceCount;
                   1832:     WORD   Sbz2;
                   1833: } ACL;
                   1834: typedef ACL *PACL;
                   1835: 
1.1.1.4   root     1836: // end_ntddk
                   1837: 
1.1.1.2   root     1838: //
                   1839: //  The structure of an ACE is a common ace header followed by ace type
                   1840: //  specific data.  Pictorally the structure of the common ace header is
                   1841: //  as follows:
                   1842: //
                   1843: //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
                   1844: //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
                   1845: //      +---------------+-------+-------+---------------+---------------+
                   1846: //      |            AceSize            |    AceFlags   |     AceType   |
                   1847: //      +---------------+-------+-------+---------------+---------------+
                   1848: //
                   1849: //  AceType denotes the type of the ace, there are some predefined ace
                   1850: //  types
                   1851: //
                   1852: //  AceSize is the size, in bytes, of ace.
                   1853: //
                   1854: //  AceFlags are the Ace flags for audit and inheritance, defined shortly.
                   1855: 
                   1856: typedef struct _ACE_HEADER {
                   1857:     BYTE  AceType;
                   1858:     BYTE  AceFlags;
                   1859:     WORD   AceSize;
                   1860: } ACE_HEADER;
                   1861: typedef ACE_HEADER *PACE_HEADER;
                   1862: 
                   1863: //
                   1864: //  The following are the predefined ace types that go into the AceType
                   1865: //  field of an Ace header.
                   1866: //
                   1867: 
                   1868: #define ACCESS_ALLOWED_ACE_TYPE          (0x0)
                   1869: #define ACCESS_DENIED_ACE_TYPE           (0x1)
                   1870: #define SYSTEM_AUDIT_ACE_TYPE            (0x2)
                   1871: #define SYSTEM_ALARM_ACE_TYPE            (0x3)
                   1872: 
                   1873: //
                   1874: //  The following are the inherit flags that go into the AceFlags field
                   1875: //  of an Ace header.
                   1876: //
                   1877: 
                   1878: #define OBJECT_INHERIT_ACE                (0x1)
                   1879: #define CONTAINER_INHERIT_ACE             (0x2)
                   1880: #define NO_PROPAGATE_INHERIT_ACE          (0x4)
                   1881: #define INHERIT_ONLY_ACE                  (0x8)
                   1882: #define VALID_INHERIT_FLAGS               (0xF)
                   1883: 
                   1884: 
                   1885: //  The following are the currently defined ACE flags that go into the
                   1886: //  AceFlags field of an ACE header.  Each ACE type has its own set of
                   1887: //  AceFlags.
                   1888: //
                   1889: //  SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
                   1890: //  types to indicate that a message is generated for successful accesses.
                   1891: //
                   1892: //  FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
                   1893: //  to indicate that a message is generated for failed accesses.
                   1894: //
                   1895: 
                   1896: //
                   1897: //  SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
                   1898: //
                   1899: //  These control the signaling of audit and alarms for success or failure.
                   1900: //
                   1901: 
                   1902: #define SUCCESSFUL_ACCESS_ACE_FLAG       (0x40)
                   1903: #define FAILED_ACCESS_ACE_FLAG           (0x80)
                   1904: 
                   1905: 
                   1906: //
                   1907: //  We'll define the structure of the predefined ACE types.  Pictorally
                   1908: //  the structure of the predefined ACE's is as follows:
                   1909: //
                   1910: //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
                   1911: //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
                   1912: //      +---------------+-------+-------+---------------+---------------+
                   1913: //      |    AceFlags   | Resd  |Inherit|    AceSize    |     AceType   |
                   1914: //      +---------------+-------+-------+---------------+---------------+
                   1915: //      |                              Mask                             |
                   1916: //      +---------------------------------------------------------------+
                   1917: //      |                                                               |
                   1918: //      +                                                               +
                   1919: //      |                                                               |
                   1920: //      +                              Sid                              +
                   1921: //      |                                                               |
                   1922: //      +                                                               +
                   1923: //      |                                                               |
                   1924: //      +---------------------------------------------------------------+
                   1925: //
                   1926: //  Mask is the access mask associated with the ACE.  This is either the
                   1927: //  access allowed, access denied, audit, or alarm mask.
                   1928: //
                   1929: //  Sid is the Sid associated with the ACE.
                   1930: //
                   1931: 
                   1932: //  The following are the four predefined ACE types.
                   1933: 
                   1934: //  Examine the AceType field in the Header to determine
                   1935: //  which structure is appropriate to use for casting.
                   1936: 
                   1937: typedef struct _ACCESS_ALLOWED_ACE {
                   1938:     ACE_HEADER Header;
                   1939:     ACCESS_MASK Mask;
                   1940:     DWORD SidStart;
                   1941: } ACCESS_ALLOWED_ACE;
                   1942: 
                   1943: typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE;
                   1944: 
                   1945: typedef struct _ACCESS_DENIED_ACE {
                   1946:     ACE_HEADER Header;
                   1947:     ACCESS_MASK Mask;
                   1948:     DWORD SidStart;
                   1949: } ACCESS_DENIED_ACE;
                   1950: typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE;
                   1951: 
                   1952: typedef struct _SYSTEM_AUDIT_ACE {
                   1953:     ACE_HEADER Header;
                   1954:     ACCESS_MASK Mask;
                   1955:     DWORD SidStart;
                   1956: } SYSTEM_AUDIT_ACE;
                   1957: typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
                   1958: 
                   1959: typedef struct _SYSTEM_ALARM_ACE {
                   1960:     ACE_HEADER Header;
                   1961:     ACCESS_MASK Mask;
                   1962:     DWORD SidStart;
                   1963: } SYSTEM_ALARM_ACE;
                   1964: typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE;
                   1965: 
                   1966: 
                   1967: 
                   1968: //
                   1969: //  The following declarations are used for setting and querying information
                   1970: //  about and ACL.  First are the various information classes available to
                   1971: //  the user.
                   1972: //
                   1973: 
                   1974: typedef enum _ACL_INFORMATION_CLASS {
                   1975:     AclRevisionInformation = 1,
                   1976:     AclSizeInformation
                   1977: } ACL_INFORMATION_CLASS;
                   1978: 
                   1979: //
                   1980: //  This record is returned/sent if the user is requesting/setting the
                   1981: //  AclRevisionInformation
                   1982: //
                   1983: 
                   1984: typedef struct _ACL_REVISION_INFORMATION {
                   1985:     DWORD AclRevision;
                   1986: } ACL_REVISION_INFORMATION;
                   1987: typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
                   1988: 
                   1989: //
                   1990: //  This record is returned if the user is requesting AclSizeInformation
                   1991: //
                   1992: 
                   1993: typedef struct _ACL_SIZE_INFORMATION {
                   1994:     DWORD AceCount;
                   1995:     DWORD AclBytesInUse;
                   1996:     DWORD AclBytesFree;
                   1997: } ACL_SIZE_INFORMATION;
                   1998: typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
                   1999: 
                   2000: 
                   2001: ////////////////////////////////////////////////////////////////////////
                   2002: //                                                                    //
                   2003: //                             SECURITY_DESCRIPTOR                    //
                   2004: //                                                                    //
                   2005: ////////////////////////////////////////////////////////////////////////
                   2006: //
                   2007: //  Define the Security Descriptor and related data types.
                   2008: //  This is an opaque data structure.
                   2009: //
                   2010: 
1.1.1.4   root     2011: // begin_ntddk
1.1.1.2   root     2012: //
                   2013: // Current security descriptor revision value
                   2014: //
                   2015: 
                   2016: #define SECURITY_DESCRIPTOR_REVISION     (1)
                   2017: #define SECURITY_DESCRIPTOR_REVISION1    (1)
                   2018: 
1.1.1.4   root     2019: // end_ntddk
                   2020: 
1.1.1.2   root     2021: //
                   2022: // Minimum length, in bytes, needed to build a security descriptor
                   2023: // (NOTE: This must manually be kept consistent with the)
                   2024: // (sizeof(SECURITY_DESCRIPTOR)                         )
                   2025: //
                   2026: 
                   2027: #define SECURITY_DESCRIPTOR_MIN_LENGTH   (20)
                   2028: 
                   2029: 
                   2030: typedef WORD   SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
                   2031: 
                   2032: #define SE_OWNER_DEFAULTED               (0x0001)
                   2033: #define SE_GROUP_DEFAULTED               (0x0002)
                   2034: #define SE_DACL_PRESENT                  (0x0004)
                   2035: #define SE_DACL_DEFAULTED                (0x0008)
                   2036: #define SE_SACL_PRESENT                  (0x0010)
                   2037: #define SE_SACL_DEFAULTED                (0x0020)
                   2038: #define SE_SELF_RELATIVE                 (0x8000)
                   2039: 
                   2040: //
                   2041: //  Where:
                   2042: //
                   2043: //      SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
                   2044: //          SID pointed to by the Owner field was provided by a
                   2045: //          defaulting mechanism rather than explicitly provided by the
                   2046: //          original provider of the security descriptor.  This may
                   2047: //          affect the treatment of the SID with respect to inheritence
                   2048: //          of an owner.
                   2049: //
                   2050: //      SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
                   2051: //          SID in the Group field was provided by a defaulting mechanism
                   2052: //          rather than explicitly provided by the original provider of
                   2053: //          the security descriptor.  This may affect the treatment of
                   2054: //          the SID with respect to inheritence of a primary group.
                   2055: //
                   2056: //      SE_DACL_PRESENT - This boolean flag, when set, indicates that the
                   2057: //          security descriptor contains a discretionary ACL.  If this
                   2058: //          flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
                   2059: //          null, then a null ACL is explicitly being specified.
                   2060: //
                   2061: //      SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
                   2062: //          ACL pointed to by the Dacl field was provided by a defaulting
                   2063: //          mechanism rather than explicitly provided by the original
                   2064: //          provider of the security descriptor.  This may affect the
                   2065: //          treatment of the ACL with respect to inheritence of an ACL.
                   2066: //          This flag is ignored if the DaclPresent flag is not set.
                   2067: //
                   2068: //      SE_SACL_PRESENT - This boolean flag, when set,  indicates that the
                   2069: //          security descriptor contains a system ACL pointed to by the
                   2070: //          Sacl field.  If this flag is set and the Sacl field of the
                   2071: //          SECURITY_DESCRIPTOR is null, then an empty (but present)
                   2072: //          ACL is being specified.
                   2073: //
                   2074: //      SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
                   2075: //          ACL pointed to by the Sacl field was provided by a defaulting
                   2076: //          mechanism rather than explicitly provided by the original
                   2077: //          provider of the security descriptor.  This may affect the
                   2078: //          treatment of the ACL with respect to inheritence of an ACL.
                   2079: //          This flag is ignored if the SaclPresent flag is not set.
                   2080: //
                   2081: //      SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
                   2082: //          security descriptor is in self-relative form.  In this form,
                   2083: //          all fields of the security descriptor are contiguous in memory
                   2084: //          and all pointer fields are expressed as offsets from the
                   2085: //          beginning of the security descriptor.  This form is useful
                   2086: //          for treating security descriptors as opaque data structures
                   2087: //          for transmission in communication protocol or for storage on
                   2088: //          secondary media.
                   2089: //
                   2090: //
                   2091: //
                   2092: // Pictorially the structure of a security descriptor is as follows:
                   2093: //
                   2094: //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
                   2095: //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
                   2096: //      +---------------------------------------------------------------+
                   2097: //      |            Control            |Reserved1 (SBZ)|   Revision    |
                   2098: //      +---------------------------------------------------------------+
                   2099: //      |                            Owner                              |
                   2100: //      +---------------------------------------------------------------+
                   2101: //      |                            Group                              |
                   2102: //      +---------------------------------------------------------------+
                   2103: //      |                            Sacl                               |
                   2104: //      +---------------------------------------------------------------+
                   2105: //      |                            Dacl                               |
                   2106: //      +---------------------------------------------------------------+
                   2107: //
                   2108: // In general, this data structure should be treated opaquely to ensure future
                   2109: // compatibility.
                   2110: //
                   2111: //
                   2112: 
                   2113: typedef struct _SECURITY_DESCRIPTOR {
                   2114:    BYTE  Revision;
                   2115:    BYTE  Sbz1;
                   2116:    SECURITY_DESCRIPTOR_CONTROL Control;
                   2117:    PSID Owner;
                   2118:    PSID Group;
                   2119:    PACL Sacl;
                   2120:    PACL Dacl;
                   2121:    } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
                   2122: 
                   2123: 
                   2124: // Where:
                   2125: //
                   2126: //     Revision - Contains the revision level of the security
                   2127: //         descriptor.  This allows this structure to be passed between
                   2128: //         systems or stored on disk even though it is expected to
                   2129: //         change in the future.
                   2130: //
                   2131: //     Control - A set of flags which qualify the meaning of the
                   2132: //         security descriptor or individual fields of the security
                   2133: //         descriptor.
                   2134: //
                   2135: //     Owner - is a pointer to an SID representing an object's owner.
                   2136: //         If this field is null, then no owner SID is present in the
                   2137: //         security descriptor.  If the security descriptor is in
                   2138: //         self-relative form, then this field contains an offset to
                   2139: //         the SID, rather than a pointer.
                   2140: //
                   2141: //     Group - is a pointer to an SID representing an object's primary
                   2142: //         group.  If this field is null, then no primary group SID is
                   2143: //         present in the security descriptor.  If the security descriptor
                   2144: //         is in self-relative form, then this field contains an offset to
                   2145: //         the SID, rather than a pointer.
                   2146: //
                   2147: //     Sacl - is a pointer to a system ACL.  This field value is only
                   2148: //         valid if the DaclPresent control flag is set.  If the
                   2149: //         SaclPresent flag is set and this field is null, then a null
                   2150: //         ACL  is specified.  If the security descriptor is in
                   2151: //         self-relative form, then this field contains an offset to
                   2152: //         the ACL, rather than a pointer.
                   2153: //
                   2154: //     Dacl - is a pointer to a discretionary ACL.  This field value is
                   2155: //         only valid if the DaclPresent control flag is set.  If the
                   2156: //         DaclPresent flag is set and this field is null, then a null
                   2157: //         ACL (unconditionally granting access) is specified.  If the
                   2158: //         security descriptor is in self-relative form, then this field
                   2159: //         contains an offset to the ACL, rather than a pointer.
                   2160: //
                   2161: 
                   2162: 
                   2163: 
                   2164: ////////////////////////////////////////////////////////////////////////
                   2165: //                                                                    //
                   2166: //               Privilege Related Data Structures                    //
                   2167: //                                                                    //
                   2168: ////////////////////////////////////////////////////////////////////////
                   2169: 
                   2170: 
1.1.1.4   root     2171: // begin_ntddk begin_nthal
1.1.1.2   root     2172: //
                   2173: // Privilege attributes
                   2174: //
                   2175: 
                   2176: #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
                   2177: #define SE_PRIVILEGE_ENABLED            (0x00000002L)
                   2178: #define SE_PRIVILEGE_USED_FOR_ACCESS    (0x80000000L)
                   2179: 
                   2180: //
                   2181: // Privilege Set Control flags
                   2182: //
                   2183: 
                   2184: #define PRIVILEGE_SET_ALL_NECESSARY    (1)
                   2185: 
                   2186: //
                   2187: //  Privilege Set - This is defined for a privilege set of one.
                   2188: //                  If more than one privilege is needed, then this structure
                   2189: //                  will need to be allocated with more space.
                   2190: //
                   2191: //  Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
                   2192: //  structure (defined in se.h)
                   2193: //
                   2194: 
                   2195: typedef struct _PRIVILEGE_SET {
                   2196:     DWORD PrivilegeCount;
                   2197:     DWORD Control;
                   2198:     LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
                   2199:     } PRIVILEGE_SET, * PPRIVILEGE_SET;
                   2200: 
                   2201: 
                   2202: ////////////////////////////////////////////////////////////////////////
                   2203: //                                                                    //
                   2204: //               NT Defined Privileges                                //
                   2205: //                                                                    //
                   2206: ////////////////////////////////////////////////////////////////////////
                   2207: 
1.1.1.3   root     2208: #define SE_CREATE_TOKEN_NAME              TEXT("SeCreateTokenPrivilege")
                   2209: #define SE_ASSIGNPRIMARYTOKEN_NAME        TEXT("SeAssignPrimaryTokenPrivilege")
                   2210: #define SE_LOCK_MEMORY_NAME               TEXT("SeLockMemoryPrivilege")
                   2211: #define SE_INCREASE_QUOTA_NAME            TEXT("SeIncreaseQuotaPrivilege")
                   2212: #define SE_UNSOLICITED_INPUT_NAME         TEXT("SeUnsolicitedInputPrivilege")
                   2213: #define SE_TCB_NAME                       TEXT("SeTcbPrivilege")
                   2214: #define SE_SECURITY_NAME                  TEXT("SeSecurityPrivilege")
                   2215: #define SE_TAKE_OWNERSHIP_NAME            TEXT("SeTakeOwnershipPrivilege")
                   2216: #define SE_LOAD_DRIVER_NAME               TEXT("SeLoadDriverPrivilege")
                   2217: #define SE_SYSTEM_PROFILE_NAME            TEXT("SeSystemProfilePrivilege")
                   2218: #define SE_SYSTEMTIME_NAME                TEXT("SeSystemtimePrivilege")
                   2219: #define SE_PROF_SINGLE_PROCESS_NAME       TEXT("SeProfileSingleProcessPrivilege")
                   2220: #define SE_INC_BASE_PRIORITY_NAME         TEXT("SeIncreaseBasePriorityPrivilege")
                   2221: #define SE_CREATE_PAGEFILE_NAME           TEXT("SeCreatePagefilePrivilege")
                   2222: #define SE_CREATE_PERMANENT_NAME          TEXT("SeCreatePermanentPrivilege")
                   2223: #define SE_BACKUP_NAME                    TEXT("SeBackupPrivilege")
                   2224: #define SE_RESTORE_NAME                   TEXT("SeRestorePrivilege")
                   2225: #define SE_SHUTDOWN_NAME                  TEXT("SeShutdownPrivilege")
                   2226: #define SE_DEBUG_NAME                     TEXT("SeDebugPrivilege")
                   2227: #define SE_AUDIT_NAME                     TEXT("SeAuditPrivilege")
                   2228: #define SE_SYSTEM_ENVIRONMENT_NAME        TEXT("SeSystemEnvironmentPrivilege")
                   2229: #define SE_CHANGE_NOTIFY_NAME             TEXT("SeChangeNotifyPrivilege")
                   2230: #define SE_REMOTE_SHUTDOWN_NAME           TEXT("SeRemoteShutdownPrivilege")
1.1.1.2   root     2231: 
                   2232: 
                   2233: ////////////////////////////////////////////////////////////////////
                   2234: //                                                                //
                   2235: //           Security Quality Of Service                          //
                   2236: //                                                                //
                   2237: //                                                                //
                   2238: ////////////////////////////////////////////////////////////////////
                   2239: 
1.1.1.4   root     2240: // begin_ntddk begin_nthal
1.1.1.2   root     2241: //
                   2242: // Impersonation Level
                   2243: //
                   2244: // Impersonation level is represented by a pair of bits in Windows.
                   2245: // If a new impersonation level is added or lowest value is changed from
                   2246: // 0 to something else, fix the Windows CreateFile call.
                   2247: //
                   2248: 
                   2249: typedef enum _SECURITY_IMPERSONATION_LEVEL {
                   2250:     SecurityAnonymous,
                   2251:     SecurityIdentification,
                   2252:     SecurityImpersonation,
                   2253:     SecurityDelegation
                   2254:     } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
                   2255: 
                   2256: #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
                   2257: 
                   2258: #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
                   2259: 
1.1.1.4   root     2260: // end_nthal
1.1.1.2   root     2261: //
                   2262: // Security Tracking Mode
                   2263: //
                   2264: 
                   2265: #define SECURITY_DYNAMIC_TRACKING      (TRUE)
                   2266: #define SECURITY_STATIC_TRACKING       (FALSE)
                   2267: 
                   2268: typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
                   2269:                     * PSECURITY_CONTEXT_TRACKING_MODE;
                   2270: 
                   2271: 
                   2272: 
                   2273: //
                   2274: // Quality Of Service
                   2275: //
                   2276: 
                   2277: typedef struct _SECURITY_QUALITY_OF_SERVICE {
                   2278:     DWORD Length;
                   2279:     SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
                   2280:     SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
                   2281:     BOOLEAN EffectiveOnly;
                   2282:     } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE;
                   2283: 
                   2284: 
                   2285: //
                   2286: // Used to represent information related to a thread impersonation
                   2287: //
                   2288: 
                   2289: typedef struct _SE_IMPERSONATION_STATE {
                   2290:     PACCESS_TOKEN Token;
                   2291:     BOOLEAN CopyOnOpen;
                   2292:     BOOLEAN EffectiveOnly;
                   2293:     SECURITY_IMPERSONATION_LEVEL Level;
                   2294: } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
                   2295: 
                   2296: 
                   2297: ////////////////////////////////////////////////////////////////////
                   2298: //                                                                //
                   2299: //           Token Object Definitions                             //
                   2300: //                                                                //
                   2301: //                                                                //
                   2302: ////////////////////////////////////////////////////////////////////
                   2303: 
                   2304: 
                   2305: //
                   2306: // Token Specific Access Rights.
                   2307: //
                   2308: 
                   2309: #define TOKEN_ASSIGN_PRIMARY    (0x0001)
                   2310: #define TOKEN_DUPLICATE         (0x0002)
                   2311: #define TOKEN_IMPERSONATE       (0x0004)
                   2312: #define TOKEN_QUERY             (0x0008)
                   2313: #define TOKEN_QUERY_SOURCE      (0x0010)
                   2314: #define TOKEN_ADJUST_PRIVILEGES (0x0020)
                   2315: #define TOKEN_ADJUST_GROUPS     (0x0040)
                   2316: #define TOKEN_ADJUST_DEFAULT    (0x0080)
                   2317: 
                   2318: #define TOKEN_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED  |\
                   2319:                           TOKEN_ASSIGN_PRIMARY      |\
                   2320:                           TOKEN_DUPLICATE           |\
                   2321:                           TOKEN_IMPERSONATE         |\
                   2322:                           TOKEN_QUERY               |\
                   2323:                           TOKEN_QUERY_SOURCE        |\
                   2324:                           TOKEN_ADJUST_PRIVILEGES   |\
                   2325:                           TOKEN_ADJUST_GROUPS       |\
                   2326:                           TOKEN_ADJUST_DEFAULT)
                   2327: 
                   2328: 
                   2329: #define TOKEN_READ       (STANDARD_RIGHTS_READ      |\
                   2330:                           TOKEN_QUERY)
                   2331: 
                   2332: 
                   2333: #define TOKEN_WRITE      (STANDARD_RIGHTS_WRITE     |\
                   2334:                           TOKEN_ADJUST_PRIVILEGES   |\
                   2335:                           TOKEN_ADJUST_GROUPS       |\
                   2336:                           TOKEN_ADJUST_DEFAULT)
                   2337: 
1.1.1.4   root     2338: #define TOKEN_EXECUTE    (STANDARD_RIGHTS_EXECUTE)
1.1.1.2   root     2339: 
                   2340: 
                   2341: //
                   2342: // Token Types
                   2343: //
                   2344: 
                   2345: typedef enum _TOKEN_TYPE {
                   2346:     TokenPrimary = 1,
                   2347:     TokenImpersonation
                   2348:     } TOKEN_TYPE;
                   2349: typedef TOKEN_TYPE *PTOKEN_TYPE;
                   2350: 
                   2351: 
                   2352: //
                   2353: // Token Information Classes.
                   2354: //
                   2355: 
                   2356: 
                   2357: typedef enum _TOKEN_INFORMATION_CLASS {
                   2358:     TokenUser = 1,
                   2359:     TokenGroups,
                   2360:     TokenPrivileges,
                   2361:     TokenOwner,
                   2362:     TokenPrimaryGroup,
                   2363:     TokenDefaultDacl,
                   2364:     TokenSource,
                   2365:     TokenType,
                   2366:     TokenImpersonationLevel,
                   2367:     TokenStatistics
                   2368: } TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS;
                   2369: 
                   2370: //
                   2371: // Token information class structures
                   2372: //
                   2373: 
                   2374: typedef struct _TOKEN_USER {
                   2375:     SID_AND_ATTRIBUTES User;
                   2376: } TOKEN_USER, *PTOKEN_USER;
                   2377: 
                   2378: 
                   2379: typedef struct _TOKEN_GROUPS {
                   2380:     DWORD GroupCount;
                   2381:     SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
                   2382: } TOKEN_GROUPS, *PTOKEN_GROUPS;
                   2383: 
                   2384: 
                   2385: typedef struct _TOKEN_PRIVILEGES {
                   2386:     DWORD PrivilegeCount;
                   2387:     LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
                   2388: } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
                   2389: 
                   2390: 
                   2391: typedef struct _TOKEN_OWNER {
                   2392:     PSID Owner;
                   2393: } TOKEN_OWNER, *PTOKEN_OWNER;
                   2394: 
                   2395: 
                   2396: typedef struct _TOKEN_PRIMARY_GROUP {
                   2397:     PSID PrimaryGroup;
                   2398: } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
                   2399: 
                   2400: 
                   2401: typedef struct _TOKEN_DEFAULT_DACL {
                   2402:     PACL DefaultDacl;
                   2403: } TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL;
                   2404: 
                   2405: 
                   2406: 
                   2407: #define TOKEN_SOURCE_LENGTH 8
                   2408: 
                   2409: typedef struct _TOKEN_SOURCE {
                   2410:     CHAR SourceName[TOKEN_SOURCE_LENGTH];
                   2411:     LUID SourceIdentifier;
                   2412: } TOKEN_SOURCE, *PTOKEN_SOURCE;
                   2413: 
                   2414: 
                   2415: typedef struct _TOKEN_STATISTICS {
                   2416:     LUID TokenId;
                   2417:     LUID AuthenticationId;
                   2418:     LARGE_INTEGER ExpirationTime;
                   2419:     TOKEN_TYPE TokenType;
                   2420:     SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
                   2421:     DWORD DynamicCharged;
                   2422:     DWORD DynamicAvailable;
                   2423:     DWORD GroupCount;
                   2424:     DWORD PrivilegeCount;
                   2425:     LUID ModifiedId;
                   2426: } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
                   2427: 
                   2428: 
                   2429: typedef struct _TOKEN_CONTROL {
                   2430:     LUID TokenId;
                   2431:     LUID AuthenticationId;
                   2432:     LUID ModifiedId;
                   2433:     TOKEN_SOURCE TokenSource;
                   2434:     } TOKEN_CONTROL, *PTOKEN_CONTROL;
1.1       root     2435: 
                   2436: 
                   2437: typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
                   2438: 
                   2439: #define OWNER_SECURITY_INFORMATION       (0X00000001L)
                   2440: #define GROUP_SECURITY_INFORMATION       (0X00000002L)
                   2441: #define DACL_SECURITY_INFORMATION        (0X00000004L)
                   2442: #define SACL_SECURITY_INFORMATION        (0X00000008L)
                   2443: 
1.1.1.2   root     2444: 
                   2445: //
1.1.1.4   root     2446: // Image Format
1.1.1.2   root     2447: //
                   2448: 
1.1.1.4   root     2449: #ifndef RC_INVOKED
                   2450: #pragma pack (1)
                   2451: #endif // !RC_INVOKED
1.1.1.2   root     2452: 
1.1.1.4   root     2453: #define IMAGE_DOS_SIGNATURE                 0x5A4D      // MZ
                   2454: #define IMAGE_OS2_SIGNATURE                 0x454E      // NE
                   2455: #define IMAGE_OS2_SIGNATURE_LE              0x454C      // LE
                   2456: #define IMAGE_NT_SIGNATURE                  0x00004550  // PE00
1.1.1.2   root     2457: 
1.1.1.4   root     2458: typedef struct _IMAGE_DOS_HEADER {      // DOS .EXE header
                   2459:     WORD   e_magic;                     // Magic number
                   2460:     WORD   e_cblp;                      // Bytes on last page of file
                   2461:     WORD   e_cp;                        // Pages in file
                   2462:     WORD   e_crlc;                      // Relocations
                   2463:     WORD   e_cparhdr;                   // Size of header in paragraphs
                   2464:     WORD   e_minalloc;                  // Minimum extra paragraphs needed
                   2465:     WORD   e_maxalloc;                  // Maximum extra paragraphs needed
                   2466:     WORD   e_ss;                        // Initial (relative) SS value
                   2467:     WORD   e_sp;                        // Initial SP value
                   2468:     WORD   e_csum;                      // Checksum
                   2469:     WORD   e_ip;                        // Initial IP value
                   2470:     WORD   e_cs;                        // Initial (relative) CS value
                   2471:     WORD   e_lfarlc;                    // File address of relocation table
                   2472:     WORD   e_ovno;                      // Overlay number
                   2473:     WORD   e_res[4];                    // Reserved words
                   2474:     WORD   e_oemid;                     // OEM identifier (for e_oeminfo)
                   2475:     WORD   e_oeminfo;                   // OEM information; e_oemid specific
                   2476:     WORD   e_res2[10];                  // Reserved words
                   2477:     LONG   e_lfanew;                    // File address of new exe header
                   2478:   } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
1.1       root     2479: 
1.1.1.4   root     2480: typedef struct _IMAGE_OS2_HEADER {      // OS/2 .EXE header
                   2481:     WORD   ne_magic;                    // Magic number
                   2482:     CHAR   ne_ver;                      // Version number
                   2483:     CHAR   ne_rev;                      // Revision number
                   2484:     WORD   ne_enttab;                   // Offset of Entry Table
                   2485:     WORD   ne_cbenttab;                 // Number of bytes in Entry Table
                   2486:     LONG   ne_crc;                      // Checksum of whole file
                   2487:     WORD   ne_flags;                    // Flag word
                   2488:     WORD   ne_autodata;                 // Automatic data segment number
                   2489:     WORD   ne_heap;                     // Initial heap allocation
                   2490:     WORD   ne_stack;                    // Initial stack allocation
                   2491:     LONG   ne_csip;                     // Initial CS:IP setting
                   2492:     LONG   ne_sssp;                     // Initial SS:SP setting
                   2493:     WORD   ne_cseg;                     // Count of file segments
                   2494:     WORD   ne_cmod;                     // Entries in Module Reference Table
                   2495:     WORD   ne_cbnrestab;                // Size of non-resident name table
                   2496:     WORD   ne_segtab;                   // Offset of Segment Table
                   2497:     WORD   ne_rsrctab;                  // Offset of Resource Table
                   2498:     WORD   ne_restab;                   // Offset of resident name table
                   2499:     WORD   ne_modtab;                   // Offset of Module Reference Table
                   2500:     WORD   ne_imptab;                   // Offset of Imported Names Table
                   2501:     LONG   ne_nrestab;                  // Offset of Non-resident Names Table
                   2502:     WORD   ne_cmovent;                  // Count of movable entries
                   2503:     WORD   ne_align;                    // Segment alignment shift count
                   2504:     WORD   ne_cres;                     // Count of resource segments
                   2505:     BYTE   ne_exetyp;                   // Target Operating system
                   2506:     BYTE   ne_flagsothers;              // Other .EXE flags
                   2507:     WORD   ne_pretthunks;               // offset to return thunks
                   2508:     WORD   ne_psegrefbytes;             // offset to segment ref. bytes
                   2509:     WORD   ne_swaparea;                 // Minimum code swap area size
                   2510:     WORD   ne_expver;                   // Expected Windows version number
                   2511:   } IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
1.1.1.2   root     2512: 
                   2513: //
1.1.1.4   root     2514: // File header format.
1.1.1.2   root     2515: //
                   2516: 
1.1.1.4   root     2517: typedef struct _IMAGE_FILE_HEADER {
                   2518:     WORD    Machine;
                   2519:     WORD    NumberOfSections;
                   2520:     DWORD   TimeDateStamp;
                   2521:     DWORD   PointerToSymbolTable;
                   2522:     DWORD   NumberOfSymbols;
                   2523:     WORD    SizeOfOptionalHeader;
                   2524:     WORD    Characteristics;
                   2525: } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
1.1.1.2   root     2526: 
1.1.1.4   root     2527: #define IMAGE_SIZEOF_FILE_HEADER             20
1.1.1.2   root     2528: 
1.1.1.4   root     2529: #define IMAGE_FILE_RELOCS_STRIPPED           0x0001  // Relocation info stripped from file.
                   2530: #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002  // File is executable  (i.e. no unresolved externel references).
                   2531: #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004  // Line nunbers stripped from file.
                   2532: #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008  // Local symbols stripped from file.
                   2533: #define IMAGE_FILE_MINIMAL_OBJECT            0x0010  // Reserved.
                   2534: #define IMAGE_FILE_UPDATE_OBJECT             0x0020  // Reserved.
                   2535: #define IMAGE_FILE_16BIT_MACHINE             0x0040  // 16 bit word machine.
                   2536: #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080  // Bytes of machine word are reversed.
                   2537: #define IMAGE_FILE_32BIT_MACHINE             0x0100  // 32 bit word machine.
                   2538: #define IMAGE_FILE_DEBUG_STRIPPED            0x0200  // Debugging info stripped from file in .DBG file
                   2539: #define IMAGE_FILE_PATCH                     0x0400  // Reserved.
                   2540: #define IMAGE_FILE_SYSTEM                    0x1000  // System File.
                   2541: #define IMAGE_FILE_DLL                       0x2000  // File is a DLL.
                   2542: #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000  // Bytes of machine word are reversed.
1.1.1.2   root     2543: 
1.1.1.4   root     2544: #define IMAGE_FILE_MACHINE_UNKNOWN           0
                   2545: #define IMAGE_FILE_MACHINE_I860              0x14d   // Intel 860.
                   2546: #define IMAGE_FILE_MACHINE_I386              0x14c   // Intel 386.
                   2547: #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
                   2548: #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
                   2549: #define IMAGE_FILE_MACHINE_ALPHA             0x184   // Alpha_AXP
1.1.1.2   root     2550: 
                   2551: //
1.1.1.4   root     2552: // Directory format.
1.1.1.2   root     2553: //
                   2554: 
1.1.1.4   root     2555: typedef struct _IMAGE_DATA_DIRECTORY {
                   2556:     DWORD   VirtualAddress;
                   2557:     DWORD   Size;
                   2558: } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
1.1.1.2   root     2559: 
1.1.1.4   root     2560: #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES    16
1.1.1.2   root     2561: 
                   2562: //
1.1.1.4   root     2563: // Optional header format.
1.1.1.2   root     2564: //
                   2565: 
1.1.1.4   root     2566: typedef struct _IMAGE_OPTIONAL_HEADER {
                   2567:     //
                   2568:     // Standard fields.
                   2569:     //
1.1.1.2   root     2570: 
1.1.1.4   root     2571:     WORD    Magic;
                   2572:     BYTE    MajorLinkerVersion;
                   2573:     BYTE    MinorLinkerVersion;
                   2574:     DWORD   SizeOfCode;
                   2575:     DWORD   SizeOfInitializedData;
                   2576:     DWORD   SizeOfUninitializedData;
                   2577:     DWORD   AddressOfEntryPoint;
                   2578:     DWORD   BaseOfCode;
                   2579:     DWORD   BaseOfData;
1.1.1.2   root     2580: 
1.1.1.4   root     2581:     //
                   2582:     // NT additional fields.
                   2583:     //
1.1.1.2   root     2584: 
1.1.1.4   root     2585:     DWORD   ImageBase;
                   2586:     DWORD   SectionAlignment;
                   2587:     DWORD   FileAlignment;
                   2588:     WORD    MajorOperatingSystemVersion;
                   2589:     WORD    MinorOperatingSystemVersion;
                   2590:     WORD    MajorImageVersion;
                   2591:     WORD    MinorImageVersion;
                   2592:     WORD    MajorSubsystemVersion;
                   2593:     WORD    MinorSubsystemVersion;
                   2594:     DWORD   Reserved1;
                   2595:     DWORD   SizeOfImage;
                   2596:     DWORD   SizeOfHeaders;
                   2597:     DWORD   CheckSum;
                   2598:     WORD    Subsystem;
                   2599:     WORD    DllCharacteristics;
                   2600:     DWORD   SizeOfStackReserve;
                   2601:     DWORD   SizeOfStackCommit;
                   2602:     DWORD   SizeOfHeapReserve;
                   2603:     DWORD   SizeOfHeapCommit;
                   2604:     DWORD   LoaderFlags;
                   2605:     DWORD   NumberOfRvaAndSizes;
                   2606:     IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
                   2607: } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
1.1.1.2   root     2608: 
1.1.1.4   root     2609: #define IMAGE_SIZEOF_STD_OPTIONAL_HEADER      28
                   2610: #define IMAGE_SIZEOF_NT_OPTIONAL_HEADER      224
1.1.1.2   root     2611: 
1.1.1.4   root     2612: typedef struct _IMAGE_NT_HEADERS {
                   2613:     DWORD Signature;
                   2614:     IMAGE_FILE_HEADER FileHeader;
                   2615:     IMAGE_OPTIONAL_HEADER OptionalHeader;
                   2616: } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
1.1.1.2   root     2617: 
1.1.1.4   root     2618: #define IMAGE_FIRST_SECTION( ntheader ) ((PIMAGE_SECTION_HEADER)        \
                   2619:     ((DWORD)ntheader +                                                  \
                   2620:      FIELD_OFFSET( IMAGE_NT_HEADERS, OptionalHeader ) +                 \
                   2621:      ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader   \
                   2622:     ))
1.1.1.2   root     2623: 
                   2624: 
1.1.1.4   root     2625: // Subsystem Values
1.1.1.2   root     2626: 
1.1.1.4   root     2627: #define IMAGE_SUBSYSTEM_UNKNOWN              0   // Unknown subsystem.
                   2628: #define IMAGE_SUBSYSTEM_NATIVE               1   // Image doesn't require a subsystem.
                   2629: #define IMAGE_SUBSYSTEM_WINDOWS_GUI          2   // Image runs in the Windows GUI subsystem.
                   2630: #define IMAGE_SUBSYSTEM_WINDOWS_CUI          3   // Image runs in the Windows character subsystem.
                   2631: #define IMAGE_SUBSYSTEM_OS2_CUI              5   // image runs in the OS/2 character subsystem.
                   2632: #define IMAGE_SUBSYSTEM_POSIX_CUI            7   // image run  in the Posix character subsystem.
1.1.1.2   root     2633: 
1.1.1.4   root     2634: // Dll Characteristics
1.1.1.2   root     2635: 
1.1.1.4   root     2636: #define IMAGE_LIBRARY_PROCESS_INIT           1   // Dll has a process initialization routine.
                   2637: #define IMAGE_LIBRARY_PROCESS_TERM           2   // Dll has a thread termination routine.
                   2638: #define IMAGE_LIBRARY_THREAD_INIT            4   // Dll has a thread initialization routine.
                   2639: #define IMAGE_LIBRARY_THREAD_TERM            8   // Dll has a thread termination routine.
1.1.1.2   root     2640: 
                   2641: //
1.1.1.4   root     2642: // Loader Flags
1.1.1.2   root     2643: //
                   2644: 
1.1.1.4   root     2645: #define IMAGE_LOADER_FLAGS_BREAK_ON_LOAD    0x00000001
                   2646: #define IMAGE_LOADER_FLAGS_DEBUG_ON_LOAD    0x00000002
1.1.1.2   root     2647: 
                   2648: 
1.1.1.4   root     2649: // Directory Entries
                   2650: 
                   2651: #define IMAGE_DIRECTORY_ENTRY_EXPORT         0   // Export Directory
                   2652: #define IMAGE_DIRECTORY_ENTRY_IMPORT         1   // Import Directory
                   2653: #define IMAGE_DIRECTORY_ENTRY_RESOURCE       2   // Resource Directory
                   2654: #define IMAGE_DIRECTORY_ENTRY_EXCEPTION      3   // Exception Directory
                   2655: #define IMAGE_DIRECTORY_ENTRY_SECURITY       4   // Security Directory
                   2656: #define IMAGE_DIRECTORY_ENTRY_BASERELOC      5   // Base Relocation Table
                   2657: #define IMAGE_DIRECTORY_ENTRY_DEBUG          6   // Debug Directory
                   2658: #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT      7   // Description String
                   2659: #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR      8   // Machine Value (MIPS GP)
                   2660: #define IMAGE_DIRECTORY_ENTRY_TLS            9   // TLS Directory
                   2661: #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG   10   // Load Configuration Directory
1.1.1.2   root     2662: 
                   2663: //
1.1.1.4   root     2664: // Section header format.
1.1.1.2   root     2665: //
                   2666: 
1.1.1.4   root     2667: #define IMAGE_SIZEOF_SHORT_NAME              8
1.1.1.2   root     2668: 
1.1.1.4   root     2669: typedef struct _IMAGE_SECTION_HEADER {
                   2670:     BYTE    Name[IMAGE_SIZEOF_SHORT_NAME];
                   2671:     union {
                   2672:             DWORD   PhysicalAddress;
                   2673:             DWORD   VirtualSize;
                   2674:     } Misc;
                   2675:     DWORD   VirtualAddress;
                   2676:     DWORD   SizeOfRawData;
                   2677:     DWORD   PointerToRawData;
                   2678:     DWORD   PointerToRelocations;
                   2679:     DWORD   PointerToLinenumbers;
                   2680:     WORD    NumberOfRelocations;
                   2681:     WORD    NumberOfLinenumbers;
                   2682:     DWORD   Characteristics;
                   2683: } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
1.1.1.2   root     2684: 
1.1.1.4   root     2685: #define IMAGE_SIZEOF_SECTION_HEADER          40
1.1.1.2   root     2686: 
1.1.1.4   root     2687: #define IMAGE_SCN_TYPE_REGULAR               0x00000000  //
                   2688: #define IMAGE_SCN_TYPE_DUMMY                 0x00000001  // Reserved.
                   2689: #define IMAGE_SCN_TYPE_NO_LOAD               0x00000002  // Reserved.
                   2690: #define IMAGE_SCN_TYPE_GROUPED               0x00000004  // Used for 16-bit offset code.
                   2691: #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  // Reserved.
                   2692: #define IMAGE_SCN_TYPE_COPY                  0x00000010  // Reserved.
1.1.1.2   root     2693: 
1.1.1.4   root     2694: #define IMAGE_SCN_CNT_CODE                   0x00000020  // Section contains code.
                   2695: #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  // Section contains initialized data.
                   2696: #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  // Section contains uninitialized data.
1.1.1.2   root     2697: 
1.1.1.4   root     2698: #define IMAGE_SCN_LNK_OTHER                  0x00000100  // Reserved.
                   2699: #define IMAGE_SCN_LNK_INFO                   0x00000200  // Section contains comments or some other type of information.
                   2700: #define IMAGE_SCN_LNK_OVERLAY                0x00000400  // Section contains an overlay.
                   2701: #define IMAGE_SCN_LNK_REMOVE                 0x00000800  // Section contents will not become part of image.
                   2702: #define IMAGE_SCN_LNK_COMDAT                 0x00001000  // Section contents comdat.
1.1.1.2   root     2703: 
1.1.1.4   root     2704: #define IMAGE_SCN_ALIGN_1BYTES               0x00100000  //
                   2705: #define IMAGE_SCN_ALIGN_2BYTES               0x00200000  //
                   2706: #define IMAGE_SCN_ALIGN_4BYTES               0x00300000  //
                   2707: #define IMAGE_SCN_ALIGN_8BYTES               0x00400000  //
                   2708: #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  // Default alignment if no others are specified.
                   2709: #define IMAGE_SCN_ALIGN_32BYTES              0x00600000  //
                   2710: #define IMAGE_SCN_ALIGN_64BYTES              0x00700000  //
                   2711: 
                   2712: #define IMAGE_SCN_MEM_DISCARDABLE            0x02000000  // Section can be discarded.
                   2713: #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  // Section is not cachable.
                   2714: #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  // Section is not pageable.
                   2715: #define IMAGE_SCN_MEM_SHARED                 0x10000000  // Section is shareable.
                   2716: #define IMAGE_SCN_MEM_EXECUTE                0x20000000  // Section is executable.
                   2717: #define IMAGE_SCN_MEM_READ                   0x40000000  // Section is readable.
                   2718: #define IMAGE_SCN_MEM_WRITE                  0x80000000  // Section is writeable.
1.1.1.2   root     2719: 
                   2720: //
1.1.1.4   root     2721: // Symbol format.
1.1.1.2   root     2722: //
                   2723: 
1.1.1.4   root     2724: typedef struct _IMAGE_SYMBOL {
                   2725:     union {
                   2726:         BYTE    ShortName[8];
                   2727:         struct {
                   2728:             DWORD   Short;     // if 0, use LongName
                   2729:             DWORD   Long;      // offset into string table
                   2730:         } Name;
                   2731:         PBYTE   LongName[2];
                   2732:     } N;
                   2733:     DWORD   Value;
                   2734:     SHORT   SectionNumber;
                   2735:     WORD    Type;
                   2736:     BYTE    StorageClass;
                   2737:     BYTE    NumberOfAuxSymbols;
                   2738: } IMAGE_SYMBOL;
                   2739: typedef IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
1.1.1.2   root     2740: 
1.1.1.4   root     2741: #define IMAGE_SIZEOF_SYMBOL                  18
1.1.1.2   root     2742: 
                   2743: //
1.1.1.4   root     2744: // Section values.
                   2745: //
                   2746: // Symbols have a section number of the section in which they are
                   2747: // defined. Otherwise, section numbers have the following meanings:
1.1.1.2   root     2748: //
                   2749: 
1.1.1.4   root     2750: #define IMAGE_SYM_UNDEFINED           (SHORT)0           // Symbol is undefined or is common.
                   2751: #define IMAGE_SYM_ABSOLUTE            (SHORT)-1          // Symbol is an absolute value.
                   2752: #define IMAGE_SYM_DEBUG               (SHORT)-2          // Symbol is a special debug item.
1.1.1.2   root     2753: 
                   2754: //
1.1.1.4   root     2755: // Type (fundamental) values.
1.1.1.2   root     2756: //
                   2757: 
1.1.1.4   root     2758: #define IMAGE_SYM_TYPE_NULL                  0           // no type.
                   2759: #define IMAGE_SYM_TYPE_VOID                  1           //
                   2760: #define IMAGE_SYM_TYPE_CHAR                  2           // type character.
                   2761: #define IMAGE_SYM_TYPE_SHORT                 3           // type short integer.
                   2762: #define IMAGE_SYM_TYPE_INT                   4           //
                   2763: #define IMAGE_SYM_TYPE_LONG                  5           //
                   2764: #define IMAGE_SYM_TYPE_FLOAT                 6           //
                   2765: #define IMAGE_SYM_TYPE_DOUBLE                7           //
                   2766: #define IMAGE_SYM_TYPE_STRUCT                8           //
                   2767: #define IMAGE_SYM_TYPE_UNION                 9           //
                   2768: #define IMAGE_SYM_TYPE_ENUM                  10          // enumeration.
                   2769: #define IMAGE_SYM_TYPE_MOE                   11          // member of enumeration.
                   2770: #define IMAGE_SYM_TYPE_BYTE                  12          //
                   2771: #define IMAGE_SYM_TYPE_WORD                  13          //
                   2772: #define IMAGE_SYM_TYPE_UINT                  14          //
                   2773: #define IMAGE_SYM_TYPE_DWORD                 15          //
1.1.1.3   root     2774: 
                   2775: //
1.1.1.4   root     2776: // Type (derived) values.
1.1.1.3   root     2777: //
                   2778: 
1.1.1.4   root     2779: #define IMAGE_SYM_DTYPE_NULL                 0           // no derived type.
                   2780: #define IMAGE_SYM_DTYPE_POINTER              1           // pointer.
                   2781: #define IMAGE_SYM_DTYPE_FUNCTION             2           // function.
                   2782: #define IMAGE_SYM_DTYPE_ARRAY                3           // array.
1.1.1.3   root     2783: 
                   2784: //
1.1.1.4   root     2785: // Storage classes.
1.1.1.3   root     2786: //
1.1.1.2   root     2787: 
1.1.1.4   root     2788: #define IMAGE_SYM_CLASS_END_OF_FUNCTION      (BYTE )-1
                   2789: #define IMAGE_SYM_CLASS_NULL                 0
                   2790: #define IMAGE_SYM_CLASS_AUTOMATIC            1
                   2791: #define IMAGE_SYM_CLASS_EXTERNAL             2
                   2792: #define IMAGE_SYM_CLASS_STATIC               3
                   2793: #define IMAGE_SYM_CLASS_REGISTER             4
                   2794: #define IMAGE_SYM_CLASS_EXTERNAL_DEF         5
                   2795: #define IMAGE_SYM_CLASS_LABEL                6
                   2796: #define IMAGE_SYM_CLASS_UNDEFINED_LABEL      7
                   2797: #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT     8
                   2798: #define IMAGE_SYM_CLASS_ARGUMENT             9
                   2799: #define IMAGE_SYM_CLASS_STRUCT_TAG           10
                   2800: #define IMAGE_SYM_CLASS_MEMBER_OF_UNION      11
                   2801: #define IMAGE_SYM_CLASS_UNION_TAG            12
                   2802: #define IMAGE_SYM_CLASS_TYPE_DEFINITION      13
                   2803: #define IMAGE_SYM_CLASS_UNDEFINED_STATIC     14
                   2804: #define IMAGE_SYM_CLASS_ENUM_TAG             15
                   2805: #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM       16
                   2806: #define IMAGE_SYM_CLASS_REGISTER_PARAM       17
                   2807: #define IMAGE_SYM_CLASS_BIT_FIELD            18
                   2808: #define IMAGE_SYM_CLASS_BLOCK                100
                   2809: #define IMAGE_SYM_CLASS_FUNCTION             101
                   2810: #define IMAGE_SYM_CLASS_END_OF_STRUCT        102
                   2811: #define IMAGE_SYM_CLASS_FILE                 103
                   2812: // new
                   2813: #define IMAGE_SYM_CLASS_SECTION              104
                   2814: #define IMAGE_SYM_CLASS_WEAK_EXTERNAL        105
                   2815: 
                   2816: // type packing constants
                   2817: 
                   2818: #define N_BTMASK                            017
                   2819: #define N_TMASK                             060
                   2820: #define N_TMASK1                            0300
                   2821: #define N_TMASK2                            0360
                   2822: #define N_BTSHFT                            4
                   2823: #define N_TSHIFT                            2
                   2824: 
                   2825: // MACROS
                   2826: 
                   2827: // Basic Type of  x
                   2828: #define BTYPE(x) ((x) & N_BTMASK)
                   2829: 
                   2830: // Is x a pointer?
                   2831: #ifndef ISPTR
                   2832: #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
                   2833: #endif
                   2834: 
                   2835: // Is x a function?
                   2836: #ifndef ISFCN
                   2837: #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
                   2838: #endif
                   2839: 
                   2840: // Is x an array?
                   2841: 
                   2842: #ifndef ISARY
                   2843: #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
                   2844: #endif
                   2845: 
                   2846: // Is x a structure, union, or enumeration TAG?
                   2847: #ifndef ISTAG
                   2848: #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
                   2849: #endif
                   2850: 
                   2851: #ifndef INCREF
                   2852: #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
                   2853: #endif
                   2854: #ifndef DECREF
                   2855: #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
                   2856: #endif
                   2857: 
1.1.1.2   root     2858: //
1.1.1.4   root     2859: // Auxiliary entry format.
1.1.1.3   root     2860: //
                   2861: 
1.1.1.4   root     2862: typedef union _IMAGE_AUX_SYMBOL {
                   2863:     struct {
                   2864:         DWORD    TagIndex;                      // struct, union, or enum tag index
                   2865:         union {
                   2866:             struct {
                   2867:                 WORD    Linenumber;             // declaration line number
                   2868:                 WORD    Size;                   // size of struct, union, or enum
                   2869:             } LnSz;
                   2870:            DWORD    TotalSize;
                   2871:         } Misc;
                   2872:         union {
                   2873:             struct {                            // if ISFCN, tag, or .bb
                   2874:                 DWORD    PointerToLinenumber;
                   2875:                 DWORD    PointerToNextFunction;
                   2876:             } Function;
                   2877:             struct {                            // if ISARY, up to 4 dimen.
                   2878:                 WORD     Dimension[4];
                   2879:             } Array;
                   2880:         } FcnAry;
                   2881:         WORD    TvIndex;                        // tv index
                   2882:     } Sym;
                   2883:     struct {
                   2884:         BYTE    Name[IMAGE_SIZEOF_SYMBOL];
                   2885:     } File;
                   2886:     struct {
                   2887:         DWORD   Length;                         // section length
                   2888:         WORD    NumberOfRelocations;            // number of relocation entries
                   2889:         WORD    NumberOfLinenumbers;            // number of line numbers
                   2890:         DWORD   CheckSum;                       // checksum for communal
                   2891:         SHORT   Number;                         // section number to associate with
                   2892:         BYTE    Selection;                      // communal selection type
                   2893:     } Section;
                   2894: } IMAGE_AUX_SYMBOL;
                   2895: typedef IMAGE_AUX_SYMBOL UNALIGNED *PIMAGE_AUX_SYMBOL;
1.1.1.3   root     2896: 
1.1.1.4   root     2897: #define IMAGE_SIZEOF_AUX_SYMBOL              18
1.1.1.3   root     2898: 
1.1.1.4   root     2899: //
                   2900: // Communal selection types.
                   2901: //
1.1.1.3   root     2902: 
1.1.1.4   root     2903: #define IMAGE_COMDAT_SELECT_UNKNOWN        0
                   2904: #define IMAGE_COMDAT_SELECT_NODUPLICATES   1
                   2905: #define IMAGE_COMDAT_SELECT_ANY            2
                   2906: #define IMAGE_COMDAT_SELECT_SAME_SIZE      3
                   2907: #define IMAGE_COMDAT_SELECT_EXACT_MATCH    4
                   2908: #define IMAGE_COMDAT_SELECT_ASSOCIATIVE    5
                   2909: 
                   2910: #define IMAGE_WEAK_EXTERN_SEARCH_UNKNOWN   0
                   2911: #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
                   2912: #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY   2
1.1.1.3   root     2913: 
                   2914: 
                   2915: //
1.1.1.4   root     2916: // Relocation format.
1.1.1.3   root     2917: //
                   2918: 
1.1.1.4   root     2919: typedef struct _IMAGE_RELOCATION {
                   2920:     DWORD   VirtualAddress;
                   2921:     DWORD   SymbolTableIndex;
                   2922:     WORD    Type;
                   2923: } IMAGE_RELOCATION;
                   2924: typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
1.1.1.3   root     2925: 
1.1.1.4   root     2926: #define IMAGE_SIZEOF_RELOCATION              10
1.1.1.3   root     2927: 
                   2928: //
1.1.1.4   root     2929: // I860 relocation types.
1.1.1.3   root     2930: //
                   2931: 
1.1.1.4   root     2932: #define IMAGE_REL_I860_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
                   2933: #define IMAGE_REL_I860_DIR32                 06          // Direct 32-bit reference to the symbols virtual address
                   2934: #define IMAGE_REL_I860_DIR32NB               07
                   2935: #define IMAGE_REL_I860_SECTION               012
                   2936: #define IMAGE_REL_I860_SECREL                013
                   2937: #define IMAGE_REL_I860_PAIR                  034
                   2938: #define IMAGE_REL_I860_HIGH                  036
                   2939: #define IMAGE_REL_I860_LOW0                  037
                   2940: #define IMAGE_REL_I860_LOW1                  040
                   2941: #define IMAGE_REL_I860_LOW2                  041
                   2942: #define IMAGE_REL_I860_LOW3                  042
                   2943: #define IMAGE_REL_I860_LOW4                  043
                   2944: #define IMAGE_REL_I860_SPLIT0                044
                   2945: #define IMAGE_REL_I860_SPLIT1                045
                   2946: #define IMAGE_REL_I860_SPLIT2                046
                   2947: #define IMAGE_REL_I860_HIGHADJ               047
                   2948: #define IMAGE_REL_I860_BRADDR                050
1.1.1.3   root     2949: 
                   2950: //
1.1.1.4   root     2951: // I386 relocation types.
1.1.1.2   root     2952: //
                   2953: 
1.1.1.4   root     2954: #define IMAGE_REL_I386_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
                   2955: #define IMAGE_REL_I386_DIR16                 01          // Direct 16-bit reference to the symbols virtual address
                   2956: #define IMAGE_REL_I386_REL16                 02          // PC-relative 16-bit reference to the symbols virtual address
                   2957: #define IMAGE_REL_I386_DIR32                 06          // Direct 32-bit reference to the symbols virtual address
                   2958: #define IMAGE_REL_I386_DIR32NB               07          // Direct 32-bit reference to the symbols virtual address, base not included
                   2959: #define IMAGE_REL_I386_SEG12                 011         // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
                   2960: #define IMAGE_REL_I386_SECTION               012
                   2961: #define IMAGE_REL_I386_SECREL                013
                   2962: #define IMAGE_REL_I386_REL32                 024         // PC-relative 32-bit reference to the symbols virtual address
1.1.1.2   root     2963: 
                   2964: //
1.1.1.4   root     2965: // MIPS relocation types.
1.1.1.2   root     2966: //
                   2967: 
1.1.1.4   root     2968: #define IMAGE_REL_MIPS_ABSOLUTE              0           // Reference is absolute, no relocation is necessary
                   2969: #define IMAGE_REL_MIPS_REFHALF               01
                   2970: #define IMAGE_REL_MIPS_REFWORD               02
                   2971: #define IMAGE_REL_MIPS_JMPADDR               03
                   2972: #define IMAGE_REL_MIPS_REFHI                 04
                   2973: #define IMAGE_REL_MIPS_REFLO                 05
                   2974: #define IMAGE_REL_MIPS_GPREL                 06
                   2975: #define IMAGE_REL_MIPS_LITERAL               07
                   2976: #define IMAGE_REL_MIPS_SECTION               012
                   2977: #define IMAGE_REL_MIPS_SECREL                013
                   2978: #define IMAGE_REL_MIPS_REFWORDNB             042
                   2979: #define IMAGE_REL_MIPS_PAIR                  045
1.1.1.2   root     2980: 
1.1.1.3   root     2981: //
1.1.1.4   root     2982: // Alpha Relocation types.
1.1.1.3   root     2983: //
                   2984: 
1.1.1.4   root     2985: #define IMAGE_REL_ALPHA_ABSOLUTE             0x0
                   2986: #define IMAGE_REL_ALPHA_REFLONG              0x1
                   2987: #define IMAGE_REL_ALPHA_REFQUAD              0x2
                   2988: #define IMAGE_REL_ALPHA_GPREL32              0x3
                   2989: #define IMAGE_REL_ALPHA_LITERAL              0x4
                   2990: #define IMAGE_REL_ALPHA_LITUSE               0x5
                   2991: #define IMAGE_REL_ALPHA_GPDISP               0x6
                   2992: #define IMAGE_REL_ALPHA_BRADDR               0x7
                   2993: #define IMAGE_REL_ALPHA_HINT                 0x8
                   2994: #define IMAGE_REL_ALPHA_INLINE_REFLONG       0x9
                   2995: #define IMAGE_REL_ALPHA_REFHI                0xA
                   2996: #define IMAGE_REL_ALPHA_REFLO                0xB
                   2997: #define IMAGE_REL_ALPHA_PAIR                 0xC
                   2998: #define IMAGE_REL_ALPHA_MATCH                0xD
                   2999: #define IMAGE_REL_ALPHA_SECTION              0xE
                   3000: #define IMAGE_REL_ALPHA_SECREL               0xF
                   3001: #define IMAGE_REL_ALPHA_REFLONGNB            0x10
1.1.1.3   root     3002: 
1.1.1.4   root     3003: //
                   3004: // Based relocation format.
                   3005: //
1.1.1.3   root     3006: 
1.1.1.4   root     3007: typedef struct _IMAGE_BASE_RELOCATION {
                   3008:     DWORD   VirtualAddress;
                   3009:     DWORD   SizeOfBlock;
                   3010: //  WORD    TypeOffset[1];
                   3011: } IMAGE_BASE_RELOCATION, *PIMAGE_BASE_RELOCATION;
1.1.1.3   root     3012: 
1.1.1.4   root     3013: #define IMAGE_SIZEOF_BASE_RELOCATION         8
1.1.1.2   root     3014: 
                   3015: //
1.1.1.4   root     3016: // Based relocation types.
1.1.1.2   root     3017: //
                   3018: 
1.1.1.4   root     3019: #define IMAGE_REL_BASED_ABSOLUTE              0
                   3020: #define IMAGE_REL_BASED_HIGH                  1
                   3021: #define IMAGE_REL_BASED_LOW                   2
                   3022: #define IMAGE_REL_BASED_HIGHLOW               3
                   3023: #define IMAGE_REL_BASED_HIGHADJ               4
                   3024: #define IMAGE_REL_BASED_MIPS_JMPADDR          5
                   3025: #define IMAGE_REL_BASED_I860_BRADDR           6
                   3026: #define IMAGE_REL_BASED_I860_SPLIT            7
1.1.1.3   root     3027: 
1.1.1.4   root     3028: //
                   3029: // Line number format.
                   3030: //
1.1.1.3   root     3031: 
1.1.1.4   root     3032: typedef struct _IMAGE_LINENUMBER {
                   3033:     union {
                   3034:         DWORD   SymbolTableIndex;                       // Symbol table index of function name if Linenumber is 0.
                   3035:         DWORD   VirtualAddress;                         // Virtual address of line number.
                   3036:     } Type;
                   3037:     WORD    Linenumber;                                 // Line number.
                   3038: } IMAGE_LINENUMBER;
                   3039: typedef IMAGE_LINENUMBER UNALIGNED *PIMAGE_LINENUMBER;
1.1.1.3   root     3040: 
1.1.1.4   root     3041: #define IMAGE_SIZEOF_LINENUMBER              6
1.1.1.3   root     3042: 
                   3043: //
1.1.1.4   root     3044: // Archive format.
1.1.1.3   root     3045: //
                   3046: 
1.1.1.4   root     3047: #define IMAGE_ARCHIVE_START_SIZE             8
                   3048: #define IMAGE_ARCHIVE_START                  "!<arch>\n"
                   3049: #define IMAGE_ARCHIVE_END                    "`\n"
                   3050: #define IMAGE_ARCHIVE_PAD                    "\n"
                   3051: #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
                   3052: #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
                   3053: 
                   3054: typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER {
                   3055:     BYTE     Name[16];                                  // File member name - `/' terminated.
                   3056:     BYTE     Date[12];                                  // File member date - decimal.
                   3057:     BYTE     UserID[6];                                 // File member user id - decimal.
                   3058:     BYTE     GroupID[6];                                // File member group id - decimal.
                   3059:     BYTE     Mode[8];                                   // File member mode - octal.
                   3060:     BYTE     Size[10];                                  // File member size - decimal.
                   3061:     BYTE     EndHeader[2];                              // String to end header.
                   3062: } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
                   3063: 
                   3064: #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR      60
                   3065: 
                   3066: //
                   3067: // DLL support.
                   3068: //
                   3069: 
                   3070: //
                   3071: // Export Format
                   3072: //
                   3073: 
                   3074: typedef struct _IMAGE_EXPORT_DIRECTORY {
                   3075:     DWORD   Characteristics;
1.1.1.3   root     3076:     DWORD   TimeDateStamp;
1.1.1.4   root     3077:     WORD    MajorVersion;
                   3078:     WORD    MinorVersion;
                   3079:     DWORD   Name;
                   3080:     DWORD   Base;
                   3081:     DWORD   NumberOfFunctions;
                   3082:     DWORD   NumberOfNames;
                   3083:     PDWORD  *AddressOfFunctions;
                   3084:     PDWORD  *AddressOfNames;
                   3085:     PWORD   *AddressOfNameOrdinals;
                   3086: } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
1.1.1.3   root     3087: 
1.1.1.4   root     3088: //
                   3089: // Import Format
                   3090: //
1.1.1.3   root     3091: 
1.1.1.4   root     3092: typedef struct _IMAGE_IMPORT_BY_NAME {
                   3093:     WORD    Hint;
                   3094:     BYTE    Name[1];
                   3095: } IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
1.1.1.3   root     3096: 
1.1.1.4   root     3097: typedef struct _IMAGE_THUNK_DATA {
                   3098:     union {
                   3099:         PDWORD Function;
                   3100:         DWORD Ordinal;
                   3101:         PIMAGE_IMPORT_BY_NAME AddressOfData;
                   3102:     } u1;
                   3103: } IMAGE_THUNK_DATA, *PIMAGE_THUNK_DATA;
                   3104: 
                   3105: #define IMAGE_ORDINAL_FLAG 0x80000000
                   3106: #define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
                   3107: #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
                   3108: 
                   3109: typedef struct _IMAGE_IMPORT_DESCRIPTOR {
                   3110:     DWORD   Characteristics;
                   3111:     DWORD   TimeDateStamp;
                   3112:     DWORD   ForwarderChain;
                   3113:     DWORD   Name;
                   3114:     PIMAGE_THUNK_DATA FirstThunk;
                   3115: } IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR;
1.1.1.3   root     3116: 
                   3117: //
1.1.1.4   root     3118: // Thread Local Storage
1.1.1.3   root     3119: //
                   3120: 
1.1.1.4   root     3121: typedef VOID
                   3122: (NTAPI *PIMAGE_TLS_CALLBACK) (
                   3123:     PVOID DllHandle,
                   3124:     DWORD Reason,
                   3125:     PVOID Reserved
                   3126:     );
                   3127: 
                   3128: typedef struct _IMAGE_TLS_DIRECTORY {
                   3129:     DWORD   StartAddressOfRawData;
                   3130:     DWORD   EndAddressOfRawData;
                   3131:     PDWORD  AddressOfIndex;
                   3132:     PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
                   3133:     DWORD   SizeOfZeroFill;
                   3134:     DWORD   Characteristics;
                   3135: } IMAGE_TLS_DIRECTORY, *PIMAGE_TLS_DIRECTORY;
1.1.1.3   root     3136: 
                   3137: 
                   3138: //
1.1.1.4   root     3139: // Resource Format.
1.1.1.3   root     3140: //
                   3141: 
1.1.1.4   root     3142: //
                   3143: // Resource directory consists of two counts, following by a variable length
                   3144: // array of directory entries.  The first count is the number of entries at
                   3145: // beginning of the array that have actual names associated with each entry.
                   3146: // The entries are in ascending order, case insensitive strings.  The second
                   3147: // count is the number of entries that immediately follow the named entries.
                   3148: // This second count identifies the number of entries that have 31-bit integer
                   3149: // Ids as their name.  These entries are also sorted in ascending order.
                   3150: //
                   3151: // This structure allows fast lookup by either name or number, but for any
                   3152: // given resource entry only one form of lookup is supported, not both.
                   3153: // This is consistant with the syntax of the .RC file and the .RES file.
                   3154: //
1.1.1.3   root     3155: 
1.1.1.4   root     3156: typedef struct _IMAGE_RESOURCE_DIRECTORY {
                   3157:     DWORD   Characteristics;
                   3158:     DWORD   TimeDateStamp;
                   3159:     WORD    MajorVersion;
                   3160:     WORD    MinorVersion;
                   3161:     WORD    NumberOfNamedEntries;
                   3162:     WORD    NumberOfIdEntries;
                   3163: //  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
                   3164: } IMAGE_RESOURCE_DIRECTORY, *PIMAGE_RESOURCE_DIRECTORY;
1.1.1.3   root     3165: 
1.1.1.4   root     3166: #define IMAGE_RESOURCE_NAME_IS_STRING        0x80000000
                   3167: #define IMAGE_RESOURCE_DATA_IS_DIRECTORY     0x80000000
1.1.1.3   root     3168: 
1.1.1.4   root     3169: //
                   3170: // Each directory contains the 32-bit Name of the entry and an offset,
                   3171: // relative to the beginning of the resource directory of the data associated
                   3172: // with this directory entry.  If the name of the entry is an actual text
                   3173: // string instead of an integer Id, then the high order bit of the name field
                   3174: // is set to one and the low order 31-bits are an offset, relative to the
                   3175: // beginning of the resource directory of the string, which is of type
                   3176: // IMAGE_RESOURCE_DIRECTORY_STRING.  Otherwise the high bit is clear and the
                   3177: // low-order 31-bits are the integer Id that identify this resource directory
                   3178: // entry. If the directory entry is yet another resource directory (i.e. a
                   3179: // subdirectory), then the high order bit of the offset field will be
                   3180: // set to indicate this.  Otherwise the high bit is clear and the offset
                   3181: // field points to a resource data entry.
                   3182: //
1.1.1.3   root     3183: 
1.1.1.4   root     3184: typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
                   3185:     DWORD   Name;
                   3186:     DWORD   OffsetToData;
                   3187: } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
1.1.1.3   root     3188: 
1.1.1.4   root     3189: //
                   3190: // For resource directory entries that have actual string names, the Name
                   3191: // field of the directory entry points to an object of the following type.
                   3192: // All of these string objects are stored together after the last resource
                   3193: // directory entry and before the first resource data object.  This minimizes
                   3194: // the impact of these variable length objects on the alignment of the fixed
                   3195: // size directory entry objects.
                   3196: //
1.1.1.3   root     3197: 
1.1.1.4   root     3198: typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
                   3199:     WORD    Length;
                   3200:     CHAR    NameString[ 1 ];
                   3201: } IMAGE_RESOURCE_DIRECTORY_STRING, *PIMAGE_RESOURCE_DIRECTORY_STRING;
                   3202: 
                   3203: 
                   3204: typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
                   3205:     WORD    Length;
                   3206:     WCHAR   NameString[ 1 ];
                   3207: } IMAGE_RESOURCE_DIR_STRING_U, *PIMAGE_RESOURCE_DIR_STRING_U;
1.1.1.3   root     3208: 
                   3209: 
1.1.1.4   root     3210: //
                   3211: // Each resource data entry describes a leaf node in the resource directory
                   3212: // tree.  It contains an offset, relative to the beginning of the resource
                   3213: // directory of the data for the resource, a size field that gives the number
                   3214: // of bytes of data at that offset, a CodePage that should be used when
                   3215: // decoding code point values within the resource data.  Typically for new
                   3216: // applications the code page would be the unicode code page.
                   3217: //
                   3218: 
                   3219: typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
                   3220:     DWORD   OffsetToData;
                   3221:     DWORD   Size;
                   3222:     DWORD   CodePage;
                   3223:     DWORD   Reserved;
                   3224: } IMAGE_RESOURCE_DATA_ENTRY, *PIMAGE_RESOURCE_DATA_ENTRY;
                   3225: 
                   3226: //
                   3227: // Load Configuration Directory Entry
                   3228: //
                   3229: 
                   3230: typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
                   3231:     DWORD   Characteristics;
                   3232:     DWORD   TimeDateStamp;
                   3233:     WORD    MajorVersion;
                   3234:     WORD    MinorVersion;
                   3235:     DWORD   GlobalFlagsClear;
                   3236:     DWORD   GlobalFlagsSet;
                   3237:     DWORD   CriticalSectionDefaultTimeout;
                   3238:     DWORD   DeCommitFreeBlockThreshold;
                   3239:     DWORD   DeCommitTotalFreeThreshold;
                   3240:     DWORD   Reserved[ 8 ];
                   3241: } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
                   3242: 
                   3243: 
                   3244: //
                   3245: // Function table entry format for MIPS/ALPHA images.  Function table is
                   3246: // pointed to by the IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.
                   3247: // This definition duplicates ones in ntmips.h and ntalpha.h for use
                   3248: // by portable image file mungers.
                   3249: //
                   3250: 
                   3251: typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY {
                   3252:     DWORD BeginAddress;
                   3253:     DWORD EndAddress;
                   3254:     PVOID ExceptionHandler;
                   3255:     PVOID HandlerData;
                   3256:     DWORD PrologEndAddress;
                   3257: } IMAGE_RUNTIME_FUNCTION_ENTRY, *PIMAGE_RUNTIME_FUNCTION_ENTRY;
                   3258: 
                   3259: //
                   3260: // Debug Format
                   3261: //
                   3262: 
                   3263: typedef struct _IMAGE_DEBUG_DIRECTORY {
                   3264:     DWORD   Characteristics;
                   3265:     DWORD   TimeDateStamp;
                   3266:     WORD    MajorVersion;
                   3267:     WORD    MinorVersion;
                   3268:     DWORD   Type;
                   3269:     DWORD   SizeOfData;
                   3270:     DWORD   AddressOfRawData;
                   3271:     DWORD   PointerToRawData;
                   3272: } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
                   3273: 
                   3274: #define IMAGE_DEBUG_TYPE_UNKNOWN          0
                   3275: #define IMAGE_DEBUG_TYPE_COFF             1
                   3276: #define IMAGE_DEBUG_TYPE_CODEVIEW         2
                   3277: #define IMAGE_DEBUG_TYPE_FPO              3
                   3278: #define IMAGE_DEBUG_TYPE_MISC             4
                   3279: #define IMAGE_DEBUG_TYPE_EXCEPTION        5
                   3280: #define IMAGE_DEBUG_TYPE_FIXUP            6
                   3281: #define IMAGE_DEBUG_TYPE_RESERVED6        7
                   3282: #define IMAGE_DEBUG_TYPE_RESERVED7        8
1.1.1.3   root     3283: 
1.1.1.4   root     3284: typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
                   3285:     DWORD   NumberOfSymbols;
                   3286:     DWORD   LvaToFirstSymbol;
                   3287:     DWORD   NumberOfLinenumbers;
                   3288:     DWORD   LvaToFirstLinenumber;
                   3289:     DWORD   RvaToFirstByteOfCode;
                   3290:     DWORD   RvaToLastByteOfCode;
                   3291:     DWORD   RvaToFirstByteOfData;
                   3292:     DWORD   RvaToLastByteOfData;
                   3293: } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
1.1.1.3   root     3294: 
1.1.1.4   root     3295: #define FRAME_FPO   0
                   3296: #define FRAME_TRAP  1
                   3297: #define FRAME_TSS   2
                   3298: 
                   3299: typedef struct _FPO_DATA {
                   3300:     DWORD       ulOffStart;             // offset 1st byte of function code
                   3301:     DWORD       cbProcSize;             // # bytes in function
                   3302:     DWORD       cdwLocals;              // # bytes in locals/4
                   3303:     WORD        cdwParams;              // # bytes in params/4
                   3304:     WORD        cbProlog : 8;           // # bytes in prolog
                   3305:     WORD        cbRegs   : 3;           // # regs saved
                   3306:     WORD        fHasSEH  : 1;           // TRUE if SEH in func
                   3307:     WORD        fUseBP   : 1;           // TRUE if EBP has been allocated
                   3308:     WORD        reserved : 1;           // reserved for future use
                   3309:     WORD        cbFrame  : 2;           // frame type
                   3310: } FPO_DATA, *PFPO_DATA;
                   3311: #define SIZEOF_RFPO_DATA 16
                   3312: 
                   3313: 
                   3314: #define IMAGE_DEBUG_MISC_EXENAME    1
                   3315: 
                   3316: typedef struct _IMAGE_DEBUG_MISC {
                   3317:     DWORD       DataType;               // type of misc data, see defines
                   3318:     DWORD       Length;                 // total length of record, rounded to four
                   3319:                                         // byte multiple.
                   3320:     BOOLEAN     Unicode;                // TRUE if data is unicode string
                   3321:     BYTE        Reserved[ 3 ];
                   3322:     BYTE        Data[ 1 ];              // Actual data
                   3323: } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
                   3324: 
                   3325: 
                   3326: //
                   3327: // Debugging information can be stripped from an image file and placed
                   3328: // in a separate .DBG file, whose file name part is the same as the
                   3329: // image file name part (e.g. symbols for CMD.EXE could be stripped
                   3330: // and placed in CMD.DBG).  This is indicated by the IMAGE_FILE_DEBUG_STRIPPED
                   3331: // flag in the Characteristics field of the file header.  The beginning of
                   3332: // the .DBG file contains the following structure which captures certain
                   3333: // information from the image file.  This allows a debug to proceed even if
                   3334: // the original image file is not accessable.  This header is followed by
                   3335: // zero of more IMAGE_SECTION_HEADER structures, followed by zero or more
                   3336: // IMAGE_DEBUG_DIRECTORY structures.  The latter structures and those in
                   3337: // the image file contain file offsets relative to the beginning of the
                   3338: // .DBG file.
                   3339: //
                   3340: // If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure
                   3341: // is left in the image file, but not mapped.  This allows a debugger to
                   3342: // compute the name of the .DBG file, from the name of the image in the
                   3343: // IMAGE_DEBUG_MISC structure.
                   3344: //
                   3345: 
                   3346: typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
                   3347:     WORD        Signature;
                   3348:     WORD        Flags;
                   3349:     WORD        Machine;
                   3350:     WORD        Characteristics;
                   3351:     DWORD       TimeDateStamp;
                   3352:     DWORD       CheckSum;
                   3353:     DWORD       ImageBase;
                   3354:     DWORD       SizeOfImage;
                   3355:     DWORD       NumberOfSections;
                   3356:     DWORD       ExportedNamesSize;
                   3357:     DWORD       DebugDirectorySize;
                   3358:     DWORD       Reserved[ 3 ];
                   3359: } IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;
1.1.1.3   root     3360: 
1.1.1.4   root     3361: #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
1.1.1.3   root     3362: 
1.1.1.4   root     3363: #ifndef RC_INVOKED
                   3364: #pragma pack ()
                   3365: #endif  // !RC_INVOKED
1.1.1.3   root     3366: 
1.1.1.4   root     3367: //
                   3368: // End Image Format
                   3369: //
1.1.1.3   root     3370: 
                   3371: //
1.1.1.4   root     3372: // for move macros
1.1.1.3   root     3373: //
1.1.1.4   root     3374: #include <string.h>
                   3375: #define HEAP_NO_SERIALIZE               0x00000001      
                   3376: #define HEAP_GROWABLE                   0x00000002      
                   3377: #define HEAP_GENERATE_EXCEPTIONS        0x00000004      
                   3378: #define HEAP_ZERO_MEMORY                0x00000008      
                   3379: #define HEAP_REALLOC_IN_PLACE_ONLY      0x00000010      
                   3380: #define HEAP_TAIL_CHECKING_ENABLED      0x00000020      
                   3381: #define HEAP_FREE_CHECKING_ENABLED      0x00000040      
                   3382: #define HEAP_DISABLE_COALESCE_ON_FREE   0x00000080      
                   3383: #ifdef _M_IX86
                   3384: #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
                   3385: #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
                   3386: #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
                   3387: #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
                   3388: #else
                   3389: #define RtlCopyMemory(Destination,Source,Length) RtlMoveMemory((Destination),(Source),(Length))
                   3390: VOID
                   3391: NTAPI
                   3392: RtlMoveMemory (
                   3393:    PVOID Destination,
                   3394:    CONST VOID *Source,
                   3395:    DWORD Length
                   3396:    );
1.1.1.3   root     3397: 
1.1.1.4   root     3398: VOID
                   3399: NTAPI
                   3400: RtlFillMemory (
                   3401:    PVOID Destination,
                   3402:    DWORD Length,
                   3403:    BYTE  Fill
                   3404:    );
1.1.1.3   root     3405: 
1.1.1.4   root     3406: VOID
                   3407: NTAPI
                   3408: RtlZeroMemory (
                   3409:    PVOID Destination,
                   3410:    DWORD Length
                   3411:    );
                   3412: #endif
1.1.1.3   root     3413: 
1.1.1.4   root     3414: typedef struct _RTL_CRITICAL_SECTION_DEBUG {
                   3415:     WORD   Type;
                   3416:     WORD   CreatorBackTraceIndex;
                   3417:     struct _RTL_CRITICAL_SECTION *CriticalSection;
                   3418:     LIST_ENTRY ProcessLocksList;
                   3419:     DWORD EntryCount;
                   3420:     DWORD ContentionCount;
                   3421:     DWORD Depth;
                   3422:     PVOID OwnerBackTrace[ 5 ];
                   3423: } RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG;
1.1.1.3   root     3424: 
1.1.1.4   root     3425: #define RTL_CRITSECT_TYPE 0
                   3426: #define RTL_RESOURCE_TYPE 1
1.1.1.2   root     3427: 
1.1.1.4   root     3428: typedef struct _RTL_CRITICAL_SECTION {
                   3429:     PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
1.1.1.2   root     3430: 
1.1.1.4   root     3431:     //
                   3432:     //  The following three fields control entering and exiting the critical
                   3433:     //  section for the resource
                   3434:     //
1.1.1.3   root     3435: 
1.1.1.4   root     3436:     LONG LockCount;
                   3437:     LONG RecursionCount;
                   3438:     HANDLE OwningThread;        // from the thread's ClientId->UniqueThread
                   3439:     HANDLE LockSemaphore;
                   3440:     DWORD Reserved;
                   3441: } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
                   3442: #define DLL_PROCESS_ATTACH 1    
                   3443: #define DLL_THREAD_ATTACH  2    
                   3444: #define DLL_THREAD_DETACH  3    
                   3445: #define DLL_PROCESS_DETACH 0    
1.1.1.3   root     3446: 
                   3447: //
1.1.1.4   root     3448: // Defines for the READ flags for Eventlogging
1.1.1.3   root     3449: //
1.1.1.4   root     3450: #define EVENTLOG_SEQUENTIAL_READ        0X0001
                   3451: #define EVENTLOG_SEEK_READ              0X0002
                   3452: #define EVENTLOG_FORWARDS_READ          0X0004
                   3453: #define EVENTLOG_BACKWARDS_READ         0X0008
1.1.1.3   root     3454: 
1.1.1.4   root     3455: //
                   3456: // The types of events that can be logged.
                   3457: //
                   3458: #define EVENTLOG_SUCCESS                0X0000
                   3459: #define EVENTLOG_ERROR_TYPE             0x0001
                   3460: #define EVENTLOG_WARNING_TYPE           0x0002
                   3461: #define EVENTLOG_INFORMATION_TYPE       0x0004
                   3462: #define EVENTLOG_AUDIT_SUCCESS          0x0008
                   3463: #define EVENTLOG_AUDIT_FAILURE          0x0010
1.1.1.3   root     3464: 
                   3465: //
1.1.1.4   root     3466: // Defines for the WRITE flags used by Auditing for paired events
                   3467: // These are not implemented in Product 1
1.1.1.3   root     3468: //
                   3469: 
1.1.1.4   root     3470: #define EVENTLOG_START_PAIRED_EVENT    0x0001
                   3471: #define EVENTLOG_END_PAIRED_EVENT      0x0002
                   3472: #define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004
                   3473: #define EVENTLOG_PAIRED_EVENT_ACTIVE   0x0008
                   3474: #define EVENTLOG_PAIRED_EVENT_INACTIVE 0x0010
1.1.1.3   root     3475: 
                   3476: //
1.1.1.4   root     3477: // Structure that defines the header of the Eventlog record. This is the
                   3478: // fixed-sized portion before all the variable-length strings, binary
                   3479: // data and pad bytes.
                   3480: //
                   3481: // TimeGenerated is the time it was generated at the client.
                   3482: // TimeWritten is the time it was put into the log at the server end.
1.1.1.3   root     3483: //
                   3484: 
1.1.1.4   root     3485: typedef struct _EVENTLOGRECORD {
                   3486:     DWORD  Length;        // Length of full record
                   3487:     DWORD  Reserved;      // Used by the service
                   3488:     DWORD  RecordNumber;  // Absolute record number
                   3489:     DWORD  TimeGenerated; // Seconds since 1-1-1970
                   3490:     DWORD  TimeWritten;   // Seconds since 1-1-1970
                   3491:     DWORD  EventID;
                   3492:     WORD   EventType;
                   3493:     WORD   NumStrings;
                   3494:     WORD   EventCategory;
                   3495:     WORD   ReservedFlags; // For use with paired events (auditing)
                   3496:     DWORD  ClosingRecordNumber; // For use with paired events (auditing)
                   3497:     DWORD  StringOffset;  // Offset from beginning of record
                   3498:     DWORD  UserSidLength;
                   3499:     DWORD  UserSidOffset;
                   3500:     DWORD  DataLength;
                   3501:     DWORD  DataOffset;    // Offset from beginning of record
                   3502:     //
                   3503:     // Then follow:
                   3504:     //
                   3505:     // WCHAR SourceName[]
                   3506:     // WCHAR Computername[]
                   3507:     // SID   UserSid
                   3508:     // WCHAR Strings[]
                   3509:     // BYTE  Data[]
                   3510:     // CHAR  Pad[]
                   3511:     // DWORD Length;
                   3512:     //
                   3513: } EVENTLOGRECORD, *PEVENTLOGRECORD;
                   3514: 
                   3515: #define DBG_CONTINUE                    ((DWORD   )0x00010002L) 
                   3516: #define DBG_TERMINATE_THREAD            ((DWORD   )0x40010003L) 
                   3517: #define DBG_TERMINATE_PROCESS           ((DWORD   )0x40010004L) 
                   3518: #define DBG_CONTROL_C                   ((DWORD   )0x40010005L) 
                   3519: #define DBG_CONTROL_BREAK               ((DWORD   )0x40010008L) 
                   3520: #define DBG_EXCEPTION_NOT_HANDLED       ((DWORD   )0x80010001L) 
                   3521: //
1.1.1.3   root     3522: 
1.1.1.4   root     3523: // begin_ntddk begin_nthal
1.1.1.3   root     3524: //
1.1.1.4   root     3525: // Registry Specific Access Rights.
1.1.1.3   root     3526: //
                   3527: 
1.1.1.4   root     3528: #define KEY_QUERY_VALUE         (0x0001)
                   3529: #define KEY_SET_VALUE           (0x0002)
                   3530: #define KEY_CREATE_SUB_KEY      (0x0004)
                   3531: #define KEY_ENUMERATE_SUB_KEYS  (0x0008)
                   3532: #define KEY_NOTIFY              (0x0010)
                   3533: #define KEY_CREATE_LINK         (0x0020)
                   3534: 
                   3535: #define KEY_READ                ((STANDARD_RIGHTS_READ       |\
                   3536:                                   KEY_QUERY_VALUE            |\
                   3537:                                   KEY_ENUMERATE_SUB_KEYS     |\
                   3538:                                   KEY_NOTIFY)                 \
                   3539:                                   &                           \
                   3540:                                  (~SYNCHRONIZE))
1.1.1.3   root     3541: 
                   3542: 
1.1.1.4   root     3543: #define KEY_WRITE               ((STANDARD_RIGHTS_WRITE      |\
                   3544:                                   KEY_SET_VALUE              |\
                   3545:                                   KEY_CREATE_SUB_KEY)         \
                   3546:                                   &                           \
                   3547:                                  (~SYNCHRONIZE))
1.1.1.3   root     3548: 
1.1.1.4   root     3549: #define KEY_EXECUTE             ((KEY_READ)                   \
                   3550:                                   &                           \
                   3551:                                  (~SYNCHRONIZE))
1.1.1.3   root     3552: 
1.1.1.4   root     3553: #define KEY_ALL_ACCESS          ((STANDARD_RIGHTS_ALL        |\
                   3554:                                   KEY_QUERY_VALUE            |\
                   3555:                                   KEY_SET_VALUE              |\
                   3556:                                   KEY_CREATE_SUB_KEY         |\
                   3557:                                   KEY_ENUMERATE_SUB_KEYS     |\
                   3558:                                   KEY_NOTIFY                 |\
                   3559:                                   KEY_CREATE_LINK)            \
                   3560:                                   &                           \
                   3561:                                  (~SYNCHRONIZE))
1.1.1.3   root     3562: 
1.1.1.4   root     3563: //
                   3564: // Open/Create Options
                   3565: //
1.1.1.2   root     3566: 
1.1.1.4   root     3567: #define REG_OPTION_RESERVED         (0x00000000L)   // Parameter is reserved
1.1.1.2   root     3568: 
1.1.1.4   root     3569: #define REG_OPTION_NON_VOLATILE     (0x00000000L)   // Key is preserved
                   3570:                                                     // when system is rebooted
1.1.1.2   root     3571: 
1.1.1.4   root     3572: #define REG_OPTION_VOLATILE         (0x00000001L)   // Key is not preserved
                   3573:                                                     // when system is rebooted
1.1.1.3   root     3574: 
1.1.1.4   root     3575: #define REG_OPTION_CREATE_LINK      (0x00000002L)   // Created key is a
                   3576:                                                     // symbolic link
1.1.1.3   root     3577: 
1.1.1.4   root     3578: #define REG_OPTION_BACKUP_RESTORE   (0x00000004L)   // open for backup or restore
                   3579:                                                     // special access rules
                   3580:                                                     // privilege required
                   3581: 
                   3582: #define REG_LEGAL_OPTION            \
                   3583:                 (REG_OPTION_RESERVED            |\
                   3584:                  REG_OPTION_NON_VOLATILE        |\
                   3585:                  REG_OPTION_VOLATILE            |\
                   3586:                  REG_OPTION_CREATE_LINK         |\
                   3587:                  REG_OPTION_BACKUP_RESTORE)
1.1.1.2   root     3588: 
                   3589: //
1.1.1.4   root     3590: // Key creation/open disposition
1.1.1.2   root     3591: //
                   3592: 
1.1.1.4   root     3593: #define REG_CREATED_NEW_KEY         (0x00000001L)   // New Registry Key created
                   3594: #define REG_OPENED_EXISTING_KEY     (0x00000002L)   // Existing Key opened
1.1.1.2   root     3595: 
                   3596: //
1.1.1.4   root     3597: // Key restore flags
1.1.1.2   root     3598: //
                   3599: 
1.1.1.4   root     3600: #define REG_WHOLE_HIVE_VOLATILE     (0x00000001L)   // Restore whole hive volatile
                   3601: #define REG_REFRESH_HIVE            (0x00000002L)   // Unwind changes to last flush
1.1.1.3   root     3602: 
1.1.1.4   root     3603: // end_ntddk end_nthal
1.1.1.3   root     3604: 
                   3605: //
1.1.1.4   root     3606: // Notify filter values
1.1.1.3   root     3607: //
1.1.1.4   root     3608: #define REG_NOTIFY_CHANGE_NAME          (0x00000001L) // Create or delete (child)
                   3609: #define REG_NOTIFY_CHANGE_ATTRIBUTES    (0x00000002L)
                   3610: #define REG_NOTIFY_CHANGE_LAST_SET      (0x00000004L) // time stamp
                   3611: #define REG_NOTIFY_CHANGE_SECURITY      (0x00000008L)
1.1.1.3   root     3612: 
1.1.1.4   root     3613: #define REG_LEGAL_CHANGE_FILTER                 \
                   3614:                 (REG_NOTIFY_CHANGE_NAME          |\
                   3615:                  REG_NOTIFY_CHANGE_ATTRIBUTES    |\
                   3616:                  REG_NOTIFY_CHANGE_LAST_SET      |\
                   3617:                  REG_NOTIFY_CHANGE_SECURITY)
1.1.1.3   root     3618: 
                   3619: //
1.1.1.4   root     3620: //
                   3621: // Predefined Value Types.
1.1.1.3   root     3622: //
                   3623: 
1.1.1.4   root     3624: #define REG_NONE                    ( 0 )   // No value type
                   3625: #define REG_SZ                      ( 1 )   // Unicode nul terminated string
                   3626: #define REG_EXPAND_SZ               ( 2 )   // Unicode nul terminated string
                   3627:                                             // (with environment variable references)
                   3628: #define REG_BINARY                  ( 3 )   // Free form binary
                   3629: #define REG_DWORD                   ( 4 )   // 32-bit number
                   3630: #define REG_DWORD_LITTLE_ENDIAN     ( 4 )   // 32-bit number (same as REG_DWORD)
                   3631: #define REG_DWORD_BIG_ENDIAN        ( 5 )   // 32-bit number
                   3632: #define REG_LINK                    ( 6 )   // Symbolic Link (unicode)
                   3633: #define REG_MULTI_SZ                ( 7 )   // Multiple Unicode strings
                   3634: #define REG_RESOURCE_LIST           ( 8 )   // Resource list in the resource map
                   3635: #define REG_FULL_RESOURCE_DESCRIPTOR ( 9 )  // Resource list in the hardware description
1.1.1.3   root     3636: 
1.1.1.4   root     3637: // end_ntddk end_nthal
                   3638: 
                   3639: // begin_ntddk begin_nthal
1.1.1.3   root     3640: //
1.1.1.4   root     3641: // Service Types (Bit Mask)
1.1.1.3   root     3642: //
1.1.1.4   root     3643: #define SERVICE_KERNEL_DRIVER          0x00000001
                   3644: #define SERVICE_FILE_SYSTEM_DRIVER     0x00000002
                   3645: #define SERVICE_ADAPTER                0x00000004
                   3646: #define SERVICE_RECOGNIZER_DRIVER      0x00000008
1.1.1.3   root     3647: 
1.1.1.4   root     3648: #define SERVICE_DRIVER                 (SERVICE_KERNEL_DRIVER | \
                   3649:                                         SERVICE_FILE_SYSTEM_DRIVER | \
                   3650:                                         SERVICE_RECOGNIZER_DRIVER)
1.1.1.3   root     3651: 
1.1.1.4   root     3652: #define SERVICE_WIN32_OWN_PROCESS      0x00000010
                   3653: #define SERVICE_WIN32_SHARE_PROCESS    0x00000020
                   3654: #define SERVICE_WIN32                  (SERVICE_WIN32_OWN_PROCESS | \
                   3655:                                         SERVICE_WIN32_SHARE_PROCESS)
1.1.1.3   root     3656: 
1.1.1.4   root     3657: #define SERVICE_TYPE_ALL               (SERVICE_WIN32  | \
                   3658:                                         SERVICE_ADAPTER | \
                   3659:                                         SERVICE_DRIVER)
1.1.1.3   root     3660: 
                   3661: //
1.1.1.4   root     3662: // Start Type
1.1.1.3   root     3663: //
                   3664: 
1.1.1.4   root     3665: #define SERVICE_BOOT_START             0x00000000
                   3666: #define SERVICE_SYSTEM_START           0x00000001
                   3667: #define SERVICE_AUTO_START             0x00000002
                   3668: #define SERVICE_DEMAND_START           0x00000003
                   3669: #define SERVICE_DISABLED               0x00000004
1.1.1.3   root     3670: 
1.1.1.4   root     3671: //
                   3672: // Error control type
                   3673: //
                   3674: #define SERVICE_ERROR_IGNORE           0x00000000
                   3675: #define SERVICE_ERROR_NORMAL           0x00000001
                   3676: #define SERVICE_ERROR_SEVERE           0x00000002
                   3677: #define SERVICE_ERROR_CRITICAL         0x00000003
1.1.1.3   root     3678: 
                   3679: //
1.1.1.4   root     3680: //
                   3681: // Define the registry driver node enumerations
1.1.1.3   root     3682: //
                   3683: 
1.1.1.4   root     3684: typedef enum _CM_SERVICE_NODE_TYPE {
                   3685:     DriverType               = SERVICE_KERNEL_DRIVER,
                   3686:     FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER,
                   3687:     Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS,
                   3688:     Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
                   3689:     AdapterType              = SERVICE_ADAPTER,
                   3690:     RecognizerType           = SERVICE_RECOGNIZER_DRIVER
                   3691: } SERVICE_NODE_TYPE;
                   3692: 
                   3693: typedef enum _CM_SERVICE_LOAD_TYPE {
                   3694:     BootLoad    = SERVICE_BOOT_START,
                   3695:     SystemLoad  = SERVICE_SYSTEM_START,
                   3696:     AutoLoad    = SERVICE_AUTO_START,
                   3697:     DemandLoad  = SERVICE_DEMAND_START,
                   3698:     DisableLoad = SERVICE_DISABLED
                   3699: } SERVICE_LOAD_TYPE;
                   3700: 
                   3701: typedef enum _CM_ERROR_CONTROL_TYPE {
                   3702:     IgnoreError   = SERVICE_ERROR_IGNORE,
                   3703:     NormalError   = SERVICE_ERROR_NORMAL,
                   3704:     SevereError   = SERVICE_ERROR_SEVERE,
                   3705:     CriticalError = SERVICE_ERROR_CRITICAL
                   3706: } SERVICE_ERROR_TYPE;
                   3707: 
1.1.1.3   root     3708: 
                   3709: //
1.1.1.4   root     3710: // IOCTL_TAPE_ERASE definitions
1.1.1.3   root     3711: //
                   3712: 
1.1.1.4   root     3713: #define TAPE_ERASE_SHORT            0L
                   3714: #define TAPE_ERASE_LONG             1L
1.1.1.3   root     3715: 
1.1.1.4   root     3716: typedef struct _TAPE_ERASE {
                   3717:     DWORD Type;
                   3718:     BOOLEAN Immediate;
                   3719: } TAPE_ERASE, *PTAPE_ERASE;
1.1.1.3   root     3720: 
                   3721: //
1.1.1.4   root     3722: // IOCTL_TAPE_PREPARE definitions
1.1.1.3   root     3723: //
                   3724: 
1.1.1.4   root     3725: #define TAPE_LOAD                   0L
                   3726: #define TAPE_UNLOAD                 1L
                   3727: #define TAPE_TENSION                2L
                   3728: #define TAPE_LOCK                   3L
                   3729: #define TAPE_UNLOCK                 4L
                   3730: #define TAPE_FORMAT                 5L
1.1.1.3   root     3731: 
1.1.1.4   root     3732: typedef struct _TAPE_PREPARE {
                   3733:     DWORD Operation;
                   3734:     BOOLEAN Immediate;
                   3735: } TAPE_PREPARE, *PTAPE_PREPARE;
1.1.1.3   root     3736: 
                   3737: //
1.1.1.4   root     3738: // IOCTL_TAPE_WRITE_MARKS definitions
1.1.1.3   root     3739: //
                   3740: 
1.1.1.4   root     3741: #define TAPE_SETMARKS               0L
                   3742: #define TAPE_FILEMARKS              1L
                   3743: #define TAPE_SHORT_FILEMARKS        2L
                   3744: #define TAPE_LONG_FILEMARKS         3L
1.1.1.3   root     3745: 
1.1.1.4   root     3746: typedef struct _TAPE_WRITE_MARKS {
                   3747:     DWORD Type;
                   3748:     DWORD Count;
                   3749:     BOOLEAN Immediate;
                   3750: } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
1.1.1.3   root     3751: 
                   3752: //
1.1.1.4   root     3753: // IOCTL_TAPE_GET_POSITION definitions
1.1.1.3   root     3754: //
                   3755: 
1.1.1.4   root     3756: #define TAPE_ABSOLUTE_POSITION       0L
                   3757: #define TAPE_LOGICAL_POSITION        1L
                   3758: #define TAPE_PSEUDO_LOGICAL_POSITION 2L
1.1.1.3   root     3759: 
1.1.1.4   root     3760: typedef struct _TAPE_GET_POSITION {
                   3761:     DWORD Type;
                   3762:     DWORD Partition;
                   3763:     LARGE_INTEGER Offset;
                   3764: } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
1.1.1.3   root     3765: 
1.1.1.4   root     3766: //
                   3767: // IOCTL_TAPE_SET_POSITION definitions
                   3768: //
1.1.1.3   root     3769: 
1.1.1.4   root     3770: #define TAPE_REWIND                 0L
                   3771: #define TAPE_ABSOLUTE_BLOCK         1L
                   3772: #define TAPE_LOGICAL_BLOCK          2L
                   3773: #define TAPE_PSEUDO_LOGICAL_BLOCK   3L
                   3774: #define TAPE_SPACE_END_OF_DATA      4L
                   3775: #define TAPE_SPACE_RELATIVE_BLOCKS  5L
                   3776: #define TAPE_SPACE_FILEMARKS        6L
                   3777: #define TAPE_SPACE_SEQUENTIAL_FMKS  7L
                   3778: #define TAPE_SPACE_SETMARKS         8L
                   3779: #define TAPE_SPACE_SEQUENTIAL_SMKS  9L
                   3780: 
                   3781: typedef struct _TAPE_SET_POSITION {
                   3782:     DWORD Method;
                   3783:     DWORD Partition;
                   3784:     LARGE_INTEGER Offset;
                   3785:     BOOLEAN Immediate;
                   3786: } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
1.1.1.3   root     3787: 
                   3788: //
1.1.1.4   root     3789: // IOCTL_TAPE_GET_DRIVE_PARAMS definitions
1.1.1.3   root     3790: //
                   3791: 
                   3792: //
1.1.1.4   root     3793: // Definitions for FeaturesLow parameter
1.1.1.3   root     3794: //
                   3795: 
1.1.1.4   root     3796: #define TAPE_DRIVE_FIXED            0x00000001
                   3797: #define TAPE_DRIVE_SELECT           0x00000002
                   3798: #define TAPE_DRIVE_INITIATOR        0x00000004
1.1.1.3   root     3799: 
1.1.1.4   root     3800: #define TAPE_DRIVE_ERASE_SHORT      0x00000010
                   3801: #define TAPE_DRIVE_ERASE_LONG       0x00000020
                   3802: #define TAPE_DRIVE_ERASE_BOP_ONLY   0x00000040
                   3803: #define TAPE_DRIVE_ERASE_IMMEDIATE  0x00000080
1.1.1.3   root     3804: 
1.1.1.4   root     3805: #define TAPE_DRIVE_TAPE_CAPACITY    0x00000100
                   3806: #define TAPE_DRIVE_TAPE_REMAINING   0x00000200
                   3807: #define TAPE_DRIVE_FIXED_BLOCK      0x00000400
                   3808: #define TAPE_DRIVE_VARIABLE_BLOCK   0x00000800
1.1.1.3   root     3809: 
1.1.1.4   root     3810: #define TAPE_DRIVE_WRITE_PROTECT    0x00001000
                   3811: #define TAPE_DRIVE_EOT_WZ_SIZE      0x00002000
                   3812: 
                   3813: #define TAPE_DRIVE_ECC              0x00010000
                   3814: #define TAPE_DRIVE_COMPRESSION      0x00020000
                   3815: #define TAPE_DRIVE_PADDING          0x00040000
                   3816: #define TAPE_DRIVE_REPORT_SMKS      0x00080000
                   3817: 
                   3818: #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
                   3819: #define TAPE_DRIVE_GET_LOGICAL_BLK  0x00200000
                   3820: #define TAPE_DRIVE_SET_EOT_WZ_SIZE  0x00400000
                   3821: 
                   3822: #define TAPE_DRIVE_RESERVED_BIT     0x80000000  //don't use this bit!
                   3823: //                                              //can't be a low features bit!
                   3824: //                                              //reserved; high features only
1.1.1.3   root     3825: 
                   3826: //
1.1.1.4   root     3827: // Definitions for FeaturesHigh parameter
1.1.1.3   root     3828: //
                   3829: 
1.1.1.4   root     3830: #define TAPE_DRIVE_LOAD_UNLOAD      0x80000001
                   3831: #define TAPE_DRIVE_TENSION          0x80000002
                   3832: #define TAPE_DRIVE_LOCK_UNLOCK      0x80000004
                   3833: #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
                   3834: 
                   3835: #define TAPE_DRIVE_SET_BLOCK_SIZE   0x80000010
                   3836: #define TAPE_DRIVE_LOAD_UNLD_IMMED  0x80000020
                   3837: #define TAPE_DRIVE_TENSION_IMMED    0x80000040
                   3838: #define TAPE_DRIVE_LOCK_UNLK_IMMED  0x80000080
                   3839: 
                   3840: #define TAPE_DRIVE_SET_ECC          0x80000100
                   3841: #define TAPE_DRIVE_SET_COMPRESSION  0x80000200
                   3842: #define TAPE_DRIVE_SET_PADDING      0x80000400
                   3843: #define TAPE_DRIVE_SET_REPORT_SMKS  0x80000800
                   3844: 
                   3845: #define TAPE_DRIVE_ABSOLUTE_BLK     0x80001000
                   3846: #define TAPE_DRIVE_ABS_BLK_IMMED    0x80002000
                   3847: #define TAPE_DRIVE_LOGICAL_BLK      0x80004000
                   3848: #define TAPE_DRIVE_LOG_BLK_IMMED    0x80008000
                   3849: 
                   3850: #define TAPE_DRIVE_END_OF_DATA      0x80010000
                   3851: #define TAPE_DRIVE_RELATIVE_BLKS    0x80020000
                   3852: #define TAPE_DRIVE_FILEMARKS        0x80040000
                   3853: #define TAPE_DRIVE_SEQUENTIAL_FMKS  0x80080000
                   3854: 
                   3855: #define TAPE_DRIVE_SETMARKS         0x80100000
                   3856: #define TAPE_DRIVE_SEQUENTIAL_SMKS  0x80200000
                   3857: #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
                   3858: #define TAPE_DRIVE_SPACE_IMMEDIATE  0x80800000
                   3859: 
                   3860: #define TAPE_DRIVE_WRITE_SETMARKS   0x81000000
                   3861: #define TAPE_DRIVE_WRITE_FILEMARKS  0x82000000
                   3862: #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
                   3863: #define TAPE_DRIVE_WRITE_LONG_FMKS  0x88000000
                   3864: 
                   3865: #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
                   3866: #define TAPE_DRIVE_FORMAT           0xA0000000
                   3867: #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
                   3868: #define TAPE_DRIVE_HIGH_FEATURES    0x80000000  //mask for high features flag
1.1.1.3   root     3869: 
1.1.1.4   root     3870: typedef struct _TAPE_GET_DRIVE_PARAMETERS {
                   3871:     BOOLEAN ECC;
                   3872:     BOOLEAN Compression;
                   3873:     BOOLEAN DataPadding;
                   3874:     BOOLEAN ReportSetmarks;
                   3875:     DWORD DefaultBlockSize;
                   3876:     DWORD MaximumBlockSize;
                   3877:     DWORD MinimumBlockSize;
                   3878:     DWORD MaximumPartitionCount;
                   3879:     DWORD FeaturesLow;
                   3880:     DWORD FeaturesHigh;
                   3881:     DWORD EOTWarningZoneSize;
                   3882: } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
1.1.1.3   root     3883: 
1.1.1.4   root     3884: //
                   3885: // IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions
                   3886: //
1.1.1.3   root     3887: 
1.1.1.4   root     3888: typedef struct _TAPE_SET_DRIVE_PARAMETERS {
                   3889:     BOOLEAN ECC;
                   3890:     BOOLEAN Compression;
                   3891:     BOOLEAN DataPadding;
                   3892:     BOOLEAN ReportSetmarks;
                   3893:     DWORD EOTWarningZoneSize;
                   3894: } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
1.1.1.3   root     3895: 
                   3896: //
1.1.1.4   root     3897: // IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions
1.1.1.3   root     3898: //
                   3899: 
1.1.1.4   root     3900: typedef struct _TAPE_GET_MEDIA_PARAMETERS {
                   3901:     LARGE_INTEGER Capacity;
                   3902:     LARGE_INTEGER Remaining;
                   3903:     DWORD BlockSize;
                   3904:     DWORD PartitionCount;
                   3905:     BOOLEAN WriteProtected;
                   3906: } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
1.1.1.3   root     3907: 
                   3908: //
1.1.1.4   root     3909: // IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions
1.1.1.3   root     3910: //
                   3911: 
1.1.1.4   root     3912: typedef struct _TAPE_SET_MEDIA_PARAMETERS {
                   3913:     DWORD BlockSize;
                   3914: } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
1.1.1.3   root     3915: 
1.1.1.4   root     3916: //
                   3917: // IOCTL_TAPE_CREATE_PARTITION definitions
                   3918: //
1.1.1.3   root     3919: 
1.1.1.4   root     3920: #define TAPE_FIXED_PARTITIONS       0L
                   3921: #define TAPE_SELECT_PARTITIONS      1L
                   3922: #define TAPE_INITIATOR_PARTITIONS   2L
1.1.1.3   root     3923: 
1.1.1.4   root     3924: typedef struct _TAPE_CREATE_PARTITION {
                   3925:     DWORD Method;
                   3926:     DWORD Count;
                   3927:     DWORD Size;
                   3928: } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
1.1.1.3   root     3929: 
1.1.1.2   root     3930: 
1.1.1.4   root     3931: #ifdef __cplusplus
                   3932: }
                   3933: #endif
1.1.1.2   root     3934: 
1.1.1.4   root     3935: #endif /* _WINNT_ */
1.1       root     3936: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.