Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

winnt.h

00001 /*
00002  * Win32 definitions for Windows NT
00003  *
00004  * Copyright 1996 Alexandre Julliard
00005  */
00006 
00007 #ifndef __WINE_WINNT_H
00008 #define __WINE_WINNT_H
00009 
00010 #include "windef.h"
00011 
00012 #ifndef RC_INVOKED
00013 #include <string.h>
00014 #endif
00015 
00016 #include "pshpack1.h"
00017 /* Defines */
00018 
00019 /* Argument 1 passed to the DllEntryProc. */
00020 #define DLL_PROCESS_DETACH      0       /* detach process (unload library) */
00021 #define DLL_PROCESS_ATTACH      1       /* attach process (load library) */
00022 #define DLL_THREAD_ATTACH       2       /* attach new thread */
00023 #define DLL_THREAD_DETACH       3       /* detach thread */
00024 
00025 
00026 /* u.x.wProcessorArchitecture (NT) */
00027 #define PROCESSOR_ARCHITECTURE_INTEL    0
00028 #define PROCESSOR_ARCHITECTURE_MIPS     1
00029 #define PROCESSOR_ARCHITECTURE_ALPHA    2
00030 #define PROCESSOR_ARCHITECTURE_PPC      3
00031 #define PROCESSOR_ARCHITECTURE_SHX      4
00032 #define PROCESSOR_ARCHITECTURE_ARM      5
00033 #define PROCESSOR_ARCHITECTURE_UNKNOWN  0xFFFF
00034 
00035 /* dwProcessorType */
00036 #define PROCESSOR_INTEL_386      386
00037 #define PROCESSOR_INTEL_486      486
00038 #define PROCESSOR_INTEL_PENTIUM  586
00039 #define PROCESSOR_INTEL_860      860
00040 #define PROCESSOR_MIPS_R2000     2000
00041 #define PROCESSOR_MIPS_R3000     3000
00042 #define PROCESSOR_MIPS_R4000     4000
00043 #define PROCESSOR_ALPHA_21064    21064
00044 #define PROCESSOR_PPC_601        601
00045 #define PROCESSOR_PPC_603        603
00046 #define PROCESSOR_PPC_604        604
00047 #define PROCESSOR_PPC_620        620
00048 #define PROCESSOR_HITACHI_SH3    10003
00049 #define PROCESSOR_HITACHI_SH3E   10004
00050 #define PROCESSOR_HITACHI_SH4    10005
00051 #define PROCESSOR_MOTOROLA_821   821
00052 #define PROCESSOR_SHx_SH3        103
00053 #define PROCESSOR_SHx_SH4        104
00054 #define PROCESSOR_STRONGARM      2577
00055 #define PROCESSOR_ARM720         1824    /* 0x720 */
00056 #define PROCESSOR_ARM820         2080    /* 0x820 */
00057 #define PROCESSOR_ARM920         2336    /* 0x920 */
00058 #define PROCESSOR_ARM_7TDMI      70001
00059 
00060 #define ANYSIZE_ARRAY 1
00061 
00062 #define MINCHAR       0x80
00063 #define MAXCHAR       0x7f
00064 #define MINSHORT      0x8000
00065 #define MAXSHORT      0x7fff
00066 #define MINLONG       0x80000000
00067 #define MAXLONG       0x7fffffff
00068 #define MAXBYTE       0xff
00069 #define MAXWORD       0xffff
00070 #define MAXDWORD      0xffffffff
00071 
00072 #define FIELD_OFFSET(type, field) \
00073   ((LONG)(INT)&(((type *)0)->field))
00074 
00075 #define CONTAINING_RECORD(address, type, field) \
00076   ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
00077 
00078 /* Types */
00079 
00080 /* TCHAR data types definitions for Winelib. */
00081 /* These types are _not_ defined for the emulator, because they */
00082 /* depend on the UNICODE macro that only exists in user's code. */
00083 
00084 //#ifndef __WINE__
00085 # ifdef UNICODE
00086 typedef WCHAR TCHAR, *PTCHAR;
00087 typedef LPWSTR PTSTR, LPTSTR;
00088 typedef LPCWSTR PCTSTR, LPCTSTR;
00089 #define __TEXT(string) L##string /*probably wrong */
00090 # else  /* UNICODE */
00091 typedef char TCHAR, *PTCHAR;
00092 typedef LPSTR PTSTR, LPTSTR;
00093 typedef LPCSTR PCTSTR, LPCTSTR;
00094 #define __TEXT(string) string
00095 # endif /* UNICODE */
00096 //#endif   /* __WINE__ */
00097 #define TEXT(quote) __TEXT(quote)
00098 
00099 typedef BYTE     BOOLEAN;
00100 typedef BOOLEAN *PBOOLEAN;
00101 
00102 typedef struct _LIST_ENTRY {
00103   struct _LIST_ENTRY *Flink;
00104   struct _LIST_ENTRY *Blink;
00105 } LIST_ENTRY, *PLIST_ENTRY;
00106 
00107 typedef struct _SINGLE_LIST_ENTRY {
00108   struct _SINGLE_LIST_ENTRY *Next;
00109 } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
00110 
00111 /* Heap flags */
00112 
00113 #define HEAP_NO_SERIALIZE               0x00000001
00114 #define HEAP_GROWABLE                   0x00000002
00115 #define HEAP_GENERATE_EXCEPTIONS        0x00000004
00116 #define HEAP_ZERO_MEMORY                0x00000008
00117 #define HEAP_REALLOC_IN_PLACE_ONLY      0x00000010
00118 #define HEAP_TAIL_CHECKING_ENABLED      0x00000020
00119 #define HEAP_FREE_CHECKING_ENABLED      0x00000040
00120 #define HEAP_DISABLE_COALESCE_ON_FREE   0x00000080
00121 #define HEAP_CREATE_ALIGN_16            0x00010000
00122 #define HEAP_CREATE_ENABLE_TRACING      0x00020000
00123 #define HEAP_WINE_SEGPTR                0x01000000  /* Not a Win32 flag */
00124 #define HEAP_WINE_CODESEG               0x02000000  /* Not a Win32 flag */
00125 #define HEAP_WINE_CODE16SEG             0x04000000  /* Not a Win32 flag */
00126 #define HEAP_WINE_SHARED                0x08000000  /* Not a Win32 flag */
00127 
00128 /* Processor feature flags.  */
00129 #define PF_FLOATING_POINT_PRECISION_ERRATA      0
00130 #define PF_FLOATING_POINT_EMULATED              1
00131 #define PF_COMPARE_EXCHANGE_DOUBLE              2
00132 #define PF_MMX_INSTRUCTIONS_AVAILABLE           3
00133 #define PF_PPC_MOVEMEM_64BIT_OK                 4
00134 #define PF_ALPHA_BYTE_INSTRUCTIONS              5
00135 /* based on wine-20010510 -- alex */
00136 #define PF_XMMI_INSTRUCTIONS_AVAILABLE          6
00137 #define PF_AMD3D_INSTRUCTIONS_AVAILABLE         7
00138 #define PF_RDTSC_INSTRUCTION_AVAILABLE          8
00139 
00140 /* The Win32 register context */
00141 
00142 /* CONTEXT is the CPU-dependent context; it should be used        */
00143 /* wherever a platform-specific context is needed (e.g. exception */
00144 /* handling, Win32 register functions). */
00145 
00146 /* CONTEXT86 is the i386-specific context; it should be used     */
00147 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
00148 /* Win16 register functions), so that this code can be compiled  */
00149 /* on all platforms. */
00150 
00151 #define SIZE_OF_80387_REGISTERS      80
00152 
00153 typedef struct _FLOATING_SAVE_AREA
00154 {
00155     DWORD   ControlWord;
00156     DWORD   StatusWord;
00157     DWORD   TagWord;    
00158     DWORD   ErrorOffset;
00159     DWORD   ErrorSelector;
00160     DWORD   DataOffset;
00161     DWORD   DataSelector;    
00162     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
00163     DWORD   Cr0NpxState;
00164 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
00165 
00166 typedef struct _CONTEXT86
00167 {
00168     DWORD   ContextFlags;
00169 
00170     /* These are selected by CONTEXT_DEBUG_REGISTERS */
00171     DWORD   Dr0;
00172     DWORD   Dr1;
00173     DWORD   Dr2;
00174     DWORD   Dr3;
00175     DWORD   Dr6;
00176     DWORD   Dr7;
00177 
00178     /* These are selected by CONTEXT_FLOATING_POINT */
00179     FLOATING_SAVE_AREA FloatSave;
00180 
00181     /* These are selected by CONTEXT_SEGMENTS */
00182     DWORD   SegGs;
00183     DWORD   SegFs;
00184     DWORD   SegEs;
00185     DWORD   SegDs;    
00186 
00187     /* These are selected by CONTEXT_INTEGER */
00188     DWORD   Edi;
00189     DWORD   Esi;
00190     DWORD   Ebx;
00191     DWORD   Edx;    
00192     DWORD   Ecx;
00193     DWORD   Eax;
00194 
00195     /* These are selected by CONTEXT_CONTROL */
00196     DWORD   Ebp;    
00197     DWORD   Eip;
00198     DWORD   SegCs;
00199     DWORD   EFlags;
00200     DWORD   Esp;
00201     DWORD   SegSs;
00202 } CONTEXT86;
00203 
00204 #define CONTEXT_X86       0x00010000
00205 #define CONTEXT_i386      CONTEXT_X86
00206 #define CONTEXT_i486      CONTEXT_X86
00207 
00208 #define CONTEXT86_CONTROL   (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
00209 #define CONTEXT86_INTEGER   (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
00210 #define CONTEXT86_SEGMENTS  (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
00211 #define CONTEXT86_FLOATING_POINT  (CONTEXT_i386 | 0x0008L) /* 387 state */
00212 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
00213 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
00214 
00215 /* i386 context definitions */
00216 #ifdef __i386__
00217 
00218 #define CONTEXT_CONTROL         CONTEXT86_CONTROL
00219 #define CONTEXT_INTEGER         CONTEXT86_INTEGER
00220 #define CONTEXT_SEGMENTS        CONTEXT86_SEGMENTS
00221 #define CONTEXT_FLOATING_POINT  CONTEXT86_FLOATING_POINT
00222 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
00223 #define CONTEXT_FULL            CONTEXT86_FULL
00224 
00225 typedef CONTEXT86 CONTEXT;
00226 
00227 #endif  /* __i386__ */
00228 
00229 /* Alpha context definitions */
00230 #if defined(_ALPHA_) || defined(__alpha__)
00231 
00232 #define CONTEXT_ALPHA   0x00020000
00233  
00234 #define CONTEXT_CONTROL         (CONTEXT_ALPHA | 0x00000001L)
00235 #define CONTEXT_FLOATING_POINT  (CONTEXT_ALPHA | 0x00000002L)
00236 #define CONTEXT_INTEGER         (CONTEXT_ALPHA | 0x00000004L)
00237 #define CONTEXT_FULL  (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
00238 
00239 typedef struct _CONTEXT
00240 {
00241     /* selected by CONTEXT_FLOATING_POINT */
00242     ULONGLONG FltF0;
00243     ULONGLONG FltF1;
00244     ULONGLONG FltF2;
00245     ULONGLONG FltF3;
00246     ULONGLONG FltF4;
00247     ULONGLONG FltF5;
00248     ULONGLONG FltF6;
00249     ULONGLONG FltF7;
00250     ULONGLONG FltF8;
00251     ULONGLONG FltF9;
00252     ULONGLONG FltF10;
00253     ULONGLONG FltF11;
00254     ULONGLONG FltF12;
00255     ULONGLONG FltF13;
00256     ULONGLONG FltF14;
00257     ULONGLONG FltF15;
00258     ULONGLONG FltF16;
00259     ULONGLONG FltF17;
00260     ULONGLONG FltF18;
00261     ULONGLONG FltF19;
00262     ULONGLONG FltF20;
00263     ULONGLONG FltF21;
00264     ULONGLONG FltF22;
00265     ULONGLONG FltF23;
00266     ULONGLONG FltF24;
00267     ULONGLONG FltF25;
00268     ULONGLONG FltF26;
00269     ULONGLONG FltF27;
00270     ULONGLONG FltF28;
00271     ULONGLONG FltF29;
00272     ULONGLONG FltF30;
00273     ULONGLONG FltF31;
00274 
00275     /* selected by CONTEXT_INTEGER */
00276     ULONGLONG IntV0;
00277     ULONGLONG IntT0;
00278     ULONGLONG IntT1;
00279     ULONGLONG IntT2;
00280     ULONGLONG IntT3;
00281     ULONGLONG IntT4;
00282     ULONGLONG IntT5;
00283     ULONGLONG IntT6;
00284     ULONGLONG IntT7;
00285     ULONGLONG IntS0;
00286     ULONGLONG IntS1;
00287     ULONGLONG IntS2;
00288     ULONGLONG IntS3;
00289     ULONGLONG IntS4;
00290     ULONGLONG IntS5;
00291     ULONGLONG IntFp;
00292     ULONGLONG IntA0;
00293     ULONGLONG IntA1;
00294     ULONGLONG IntA2;
00295     ULONGLONG IntA3;
00296     ULONGLONG IntA4;
00297     ULONGLONG IntA5;
00298     ULONGLONG IntT8;
00299     ULONGLONG IntT9;
00300     ULONGLONG IntT10;
00301     ULONGLONG IntT11;
00302     ULONGLONG IntRa;
00303     ULONGLONG IntT12;
00304     ULONGLONG IntAt;
00305     ULONGLONG IntGp;
00306     ULONGLONG IntSp;
00307     ULONGLONG IntZero;
00308 
00309     /* selected by CONTEXT_FLOATING_POINT */
00310     ULONGLONG Fpcr;
00311     ULONGLONG SoftFpcr;
00312 
00313     /* selected by CONTEXT_CONTROL */
00314     ULONGLONG Fir;
00315     DWORD Psr;
00316     DWORD ContextFlags;
00317     DWORD Fill[4];
00318 } CONTEXT;
00319 
00320 #define _QUAD_PSR_OFFSET   HighSoftFpcr
00321 #define _QUAD_FLAGS_OFFSET HighFir
00322 
00323 #endif  /* _ALPHA_ */
00324 
00325 /* Mips context definitions */
00326 #ifdef _MIPS_
00327 
00328 #define CONTEXT_R4000   0x00010000
00329 
00330 #define CONTEXT_CONTROL         (CONTEXT_R4000 | 0x00000001)
00331 #define CONTEXT_FLOATING_POINT  (CONTEXT_R4000 | 0x00000002)
00332 #define CONTEXT_INTEGER         (CONTEXT_R4000 | 0x00000004)
00333 
00334 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
00335 
00336 typedef struct _CONTEXT
00337 {
00338     DWORD Argument[4];
00339     /* These are selected by CONTEXT_FLOATING_POINT */
00340     DWORD FltF0;
00341     DWORD FltF1;
00342     DWORD FltF2;
00343     DWORD FltF3;
00344     DWORD FltF4;
00345     DWORD FltF5;
00346     DWORD FltF6;
00347     DWORD FltF7;
00348     DWORD FltF8;
00349     DWORD FltF9;
00350     DWORD FltF10;
00351     DWORD FltF11;
00352     DWORD FltF12;
00353     DWORD FltF13;
00354     DWORD FltF14;
00355     DWORD FltF15;
00356     DWORD FltF16;
00357     DWORD FltF17;
00358     DWORD FltF18;
00359     DWORD FltF19;
00360     DWORD FltF20;
00361     DWORD FltF21;
00362     DWORD FltF22;
00363     DWORD FltF23;
00364     DWORD FltF24;
00365     DWORD FltF25;
00366     DWORD FltF26;
00367     DWORD FltF27;
00368     DWORD FltF28;
00369     DWORD FltF29;
00370     DWORD FltF30;
00371     DWORD FltF31;
00372 
00373     /* These are selected by CONTEXT_INTEGER */
00374     DWORD IntZero;
00375     DWORD IntAt;
00376     DWORD IntV0;
00377     DWORD IntV1;
00378     DWORD IntA0;
00379     DWORD IntA1;
00380     DWORD IntA2;
00381     DWORD IntA3;
00382     DWORD IntT0;
00383     DWORD IntT1;
00384     DWORD IntT2;
00385     DWORD IntT3;
00386     DWORD IntT4;
00387     DWORD IntT5;
00388     DWORD IntT6;
00389     DWORD IntT7;
00390     DWORD IntS0;
00391     DWORD IntS1;
00392     DWORD IntS2;
00393     DWORD IntS3;
00394     DWORD IntS4;
00395     DWORD IntS5;
00396     DWORD IntS6;
00397     DWORD IntS7;
00398     DWORD IntT8;
00399     DWORD IntT9;
00400     DWORD IntK0;
00401     DWORD IntK1;
00402     DWORD IntGp;
00403     DWORD IntSp;
00404     DWORD IntS8;
00405     DWORD IntRa;
00406     DWORD IntLo;
00407     DWORD IntHi;
00408 
00409     /* These are selected by CONTEXT_FLOATING_POINT */
00410     DWORD Fsr;
00411 
00412     /* These are selected by CONTEXT_CONTROL */
00413     DWORD Fir;
00414     DWORD Psr;
00415 
00416     DWORD ContextFlags;
00417     DWORD Fill[2];
00418 } CONTEXT;
00419 
00420 #endif  /* _MIPS_ */
00421 
00422 /* PowerPC context definitions */
00423 #ifdef __PPC__
00424 
00425 #define CONTEXT_CONTROL         0x0001
00426 #define CONTEXT_FLOATING_POINT  0x0002
00427 #define CONTEXT_INTEGER         0x0004
00428 #define CONTEXT_DEBUG_REGISTERS 0x0008
00429 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
00430 
00431 typedef struct
00432 {
00433     /* These are selected by CONTEXT_FLOATING_POINT */
00434     double Fpr0;
00435     double Fpr1;
00436     double Fpr2;
00437     double Fpr3;
00438     double Fpr4;
00439     double Fpr5;
00440     double Fpr6;
00441     double Fpr7;
00442     double Fpr8;
00443     double Fpr9;
00444     double Fpr10;
00445     double Fpr11;
00446     double Fpr12;
00447     double Fpr13;
00448     double Fpr14;
00449     double Fpr15;
00450     double Fpr16;
00451     double Fpr17;
00452     double Fpr18;
00453     double Fpr19;
00454     double Fpr20;
00455     double Fpr21;
00456     double Fpr22;
00457     double Fpr23;
00458     double Fpr24;
00459     double Fpr25;
00460     double Fpr26;
00461     double Fpr27;
00462     double Fpr28;
00463     double Fpr29;
00464     double Fpr30;
00465     double Fpr31;
00466     double Fpscr;
00467 
00468     /* These are selected by CONTEXT_INTEGER */
00469     DWORD Gpr0;
00470     DWORD Gpr1;
00471     DWORD Gpr2;
00472     DWORD Gpr3;
00473     DWORD Gpr4;
00474     DWORD Gpr5;
00475     DWORD Gpr6;
00476     DWORD Gpr7;
00477     DWORD Gpr8;
00478     DWORD Gpr9;
00479     DWORD Gpr10;
00480     DWORD Gpr11;
00481     DWORD Gpr12;
00482     DWORD Gpr13;
00483     DWORD Gpr14;
00484     DWORD Gpr15;
00485     DWORD Gpr16;
00486     DWORD Gpr17;
00487     DWORD Gpr18;
00488     DWORD Gpr19;
00489     DWORD Gpr20;
00490     DWORD Gpr21;
00491     DWORD Gpr22;
00492     DWORD Gpr23;
00493     DWORD Gpr24;
00494     DWORD Gpr25;
00495     DWORD Gpr26;
00496     DWORD Gpr27;
00497     DWORD Gpr28;
00498     DWORD Gpr29;
00499     DWORD Gpr30;
00500     DWORD Gpr31;
00501 
00502     DWORD Cr;
00503     DWORD Xer;
00504 
00505     /* These are selected by CONTEXT_CONTROL */
00506     DWORD Msr;
00507     DWORD Iar;
00508     DWORD Lr;
00509     DWORD Ctr;
00510 
00511     DWORD ContextFlags;
00512     DWORD Fill[3];
00513 
00514     /* These are selected by CONTEXT_DEBUG_REGISTERS */
00515     DWORD Dr0;
00516     DWORD Dr1;
00517     DWORD Dr2;
00518     DWORD Dr3;
00519     DWORD Dr4;
00520     DWORD Dr5;
00521     DWORD Dr6;
00522     DWORD Dr7;
00523 } CONTEXT;
00524 
00525 typedef struct _STACK_FRAME_HEADER
00526 {
00527     DWORD BackChain;
00528     DWORD GlueSaved1;
00529     DWORD GlueSaved2;
00530     DWORD Reserved1;
00531     DWORD Spare1;
00532     DWORD Spare2;
00533 
00534     DWORD Parameter0;
00535     DWORD Parameter1;
00536     DWORD Parameter2;
00537     DWORD Parameter3;
00538     DWORD Parameter4;
00539     DWORD Parameter5;
00540     DWORD Parameter6;
00541     DWORD Parameter7;
00542 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
00543 
00544 #endif  /* __PPC__ */
00545 
00546 #ifdef __sparc__
00547 
00548 /* 
00549  * FIXME:  
00550  *
00551  * There is no official CONTEXT structure defined for the SPARC 
00552  * architecture, so I just made one up.
00553  *
00554  * This structure is valid only for 32-bit SPARC architectures,
00555  * not for 64-bit SPARC.
00556  *
00557  * Note that this structure contains only the 'top-level' registers;
00558  * the rest of the register window chain is not visible.
00559  *
00560  * The layout follows the Solaris 'prgregset_t' structure.
00561  * 
00562  */ 
00563 
00564 #define CONTEXT_SPARC            0x10000000
00565 
00566 #define CONTEXT_CONTROL         (CONTEXT_SPARC | 0x00000001)
00567 #define CONTEXT_FLOATING_POINT  (CONTEXT_SPARC | 0x00000002)
00568 #define CONTEXT_INTEGER         (CONTEXT_SPARC | 0x00000004)
00569 
00570 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
00571 
00572 typedef struct _CONTEXT
00573 {
00574     DWORD ContextFlags;
00575 
00576     /* These are selected by CONTEXT_INTEGER */
00577     DWORD g0;
00578     DWORD g1;
00579     DWORD g2;
00580     DWORD g3;
00581     DWORD g4;
00582     DWORD g5;
00583     DWORD g6;
00584     DWORD g7;
00585     DWORD o0;
00586     DWORD o1;
00587     DWORD o2;
00588     DWORD o3;
00589     DWORD o4;
00590     DWORD o5;
00591     DWORD o6;
00592     DWORD o7;
00593     DWORD l0;
00594     DWORD l1;
00595     DWORD l2;
00596     DWORD l3;
00597     DWORD l4;
00598     DWORD l5;
00599     DWORD l6;
00600     DWORD l7;
00601     DWORD i0;
00602     DWORD i1;
00603     DWORD i2;
00604     DWORD i3;
00605     DWORD i4;
00606     DWORD i5;
00607     DWORD i6;
00608     DWORD i7;
00609 
00610     /* These are selected by CONTEXT_CONTROL */
00611     DWORD psr;
00612     DWORD pc;
00613     DWORD npc;
00614     DWORD y;
00615     DWORD wim;
00616     DWORD tbr;
00617 
00618     /* FIXME: floating point registers missing */
00619 
00620 } CONTEXT;
00621 
00622 #endif  /* __sparc__ */
00623 
00624 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
00625 #error You need to define a CONTEXT for your CPU
00626 #endif
00627 
00628 typedef CONTEXT *PCONTEXT;
00629 typedef HANDLE *PHANDLE;
00630 
00631 #ifdef __WINE__
00632 
00633 /* Macros for easier access to i386 context registers */
00634 
00635 #define EAX_reg(context)     ((context)->Eax)
00636 #define EBX_reg(context)     ((context)->Ebx)
00637 #define ECX_reg(context)     ((context)->Ecx)
00638 #define EDX_reg(context)     ((context)->Edx)
00639 #define ESI_reg(context)     ((context)->Esi)
00640 #define EDI_reg(context)     ((context)->Edi)
00641 #define EBP_reg(context)     ((context)->Ebp)
00642 
00643 #define CS_reg(context)      ((context)->SegCs)
00644 #define DS_reg(context)      ((context)->SegDs)
00645 #define ES_reg(context)      ((context)->SegEs)
00646 #define FS_reg(context)      ((context)->SegFs)
00647 #define GS_reg(context)      ((context)->SegGs)
00648 #define SS_reg(context)      ((context)->SegSs)
00649 
00650 #define EFL_reg(context)     ((context)->EFlags)
00651 #define EIP_reg(context)     ((context)->Eip)
00652 #define ESP_reg(context)     ((context)->Esp)
00653 
00654 #define AX_reg(context)      (*(WORD*)&EAX_reg(context))
00655 #define BX_reg(context)      (*(WORD*)&EBX_reg(context))
00656 #define CX_reg(context)      (*(WORD*)&ECX_reg(context))
00657 #define DX_reg(context)      (*(WORD*)&EDX_reg(context))
00658 #define SI_reg(context)      (*(WORD*)&ESI_reg(context))
00659 #define DI_reg(context)      (*(WORD*)&EDI_reg(context))
00660 #define BP_reg(context)      (*(WORD*)&EBP_reg(context))
00661 
00662 #define AL_reg(context)      (*(BYTE*)&EAX_reg(context))
00663 #define AH_reg(context)      (*((BYTE*)&EAX_reg(context)+1))
00664 #define BL_reg(context)      (*(BYTE*)&EBX_reg(context))
00665 #define BH_reg(context)      (*((BYTE*)&EBX_reg(context)+1))
00666 #define CL_reg(context)      (*(BYTE*)&ECX_reg(context))
00667 #define CH_reg(context)      (*((BYTE*)&ECX_reg(context)+1))
00668 #define DL_reg(context)      (*(BYTE*)&EDX_reg(context))
00669 #define DH_reg(context)      (*((BYTE*)&EDX_reg(context)+1))
00670                             
00671 #define SET_CFLAG(context)   (EFL_reg(context) |= 0x0001)
00672 #define RESET_CFLAG(context) (EFL_reg(context) &= ~0x0001)
00673 #define SET_ZFLAG(context)   (EFL_reg(context) |= 0x0040)
00674 #define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040)
00675 
00676 #define ISV86(context)       (EFL_reg(context) & 0x00020000)
00677 #define V86BASE(context)     ((context)->Dr7) /* ugly */
00678 
00679 
00680 /* Macros to retrieve the current context */
00681 
00682 #ifdef __i386__
00683 
00684 #ifdef NEED_UNDERSCORE_PREFIX
00685 # define __ASM_NAME(name) "_" name
00686 #else
00687 # define __ASM_NAME(name) name
00688 #endif
00689 
00690 #ifdef __GNUC__
00691 # define __ASM_GLOBAL_FUNC(name,code) \
00692       __asm__( ".align 4\n\t" \
00693                ".globl " __ASM_NAME(#name) "\n\t" \
00694                ".type " __ASM_NAME(#name) ",@function\n" \
00695                __ASM_NAME(#name) ":\n\t" \
00696                code );
00697 #else  /* __GNUC__ */
00698 # define __ASM_GLOBAL_FUNC(name,code) \
00699       void __asm_dummy_##name(void) { \
00700           asm( ".align 4\n\t" \
00701                ".globl " __ASM_NAME(#name) "\n\t" \
00702                ".type " __ASM_NAME(#name) ",@function\n" \
00703                __ASM_NAME(#name) ":\n\t" \
00704                code ); \
00705       }
00706 #endif  /* __GNUC__ */
00707 
00708 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
00709     __ASM_GLOBAL_FUNC( name, \
00710                        "call " __ASM_NAME("CALL32_Regs") "\n\t" \
00711                        ".long " __ASM_NAME(#fn) "\n\t" \
00712                        ".byte " #args ", " #args )
00713 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
00714   _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
00715 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
00716   _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
00717 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
00718   _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
00719 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
00720   _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
00721 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
00722   _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
00723 
00724 #endif  /* __i386__ */
00725 
00726 #ifdef __sparc__
00727 /* FIXME: use getcontext() to retrieve full context */
00728 #define _GET_CONTEXT \
00729     CONTEXT context;   \
00730     do { memset(&context, 0, sizeof(CONTEXT));            \
00731          context.ContextFlags = CONTEXT_CONTROL;          \
00732          context.pc = (DWORD)__builtin_return_address(0); \
00733        } while (0)
00734 
00735 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
00736   void WINAPI name ( void ) \
00737   { _GET_CONTEXT; fn( &context ); }
00738 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
00739   void WINAPI name ( t1 a1 ) \
00740   { _GET_CONTEXT; fn( a1, &context ); }
00741 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
00742   void WINAPI name ( t1 a1, t2 a2 ) \
00743   { _GET_CONTEXT; fn( a1, a2, &context ); }
00744 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
00745   void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
00746   { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
00747 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
00748   void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
00749   { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
00750 
00751 #endif /* __sparc__ */
00752 
00753 #ifndef DEFINE_REGS_ENTRYPOINT_0
00754 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
00755 #endif
00756 
00757 #ifdef __i386__
00758 # define GET_IP(context) ((LPVOID)(context)->Eip)
00759 #endif
00760 #ifdef __sparc__
00761 # define GET_IP(context) ((LPVOID)(context)->pc)
00762 #endif
00763  
00764 #if !defined(GET_IP) && !defined(RC_INVOKED)
00765 # error You must define GET_IP for this CPU
00766 #endif
00767 
00768 #endif  /* __WINE__ */
00769 
00770 /*
00771  * Exception codes
00772  */
00773 
00774 #define STATUS_SUCCESS                   0x00000000
00775 #define STATUS_WAIT_0                    0x00000000
00776 #define STATUS_ABANDONED_WAIT_0          0x00000080
00777 #define STATUS_USER_APC                  0x000000C0
00778 #define STATUS_TIMEOUT                   0x00000102
00779 #define STATUS_PENDING                   0x00000103
00780 
00781 #define STATUS_GUARD_PAGE_VIOLATION      0x80000001    
00782 #define STATUS_DATATYPE_MISALIGNMENT     0x80000002
00783 #define STATUS_BREAKPOINT                0x80000003
00784 #define STATUS_SINGLE_STEP               0x80000004
00785 #define STATUS_BUFFER_OVERFLOW           0x80000005
00786 #define STATUS_NO_MORE_FILES             0x80000006
00787 #define STATUS_WAKE_SYSTEM_DEBUGGER      0x80000007
00788 
00789 #define STATUS_HANDLES_CLOSED            0x8000000A
00790 #define STATUS_NO_INHERITANCE            0x8000000B
00791 #define STATUS_GUID_SUBSTITUTION_MADE    0x8000000C
00792 #define STATUS_PARTIAL_COPY              0x8000000D
00793 #define STATUS_DEVICE_PAPER_EMPTY        0x8000000E
00794 #define STATUS_DEVICE_POWERED_OFF        0x8000000F
00795 #define STATUS_DEVICE_OFF_LINE           0x80000010
00796 #define STATUS_DEVICE_BUSY               0x80000011
00797 #define STATUS_NO_MORE_EAS               0x80000012
00798 #define STATUS_INVALID_EA_NAME           0x80000013
00799 #define STATUS_EA_LIST_INCONSISTENT      0x80000014
00800 #define STATUS_INVALID_EA_FLAG           0x80000015
00801 #define STATUS_VERIFY_REQUIRED           0x80000016
00802 #define STATUS_EXTRANEOUS_INFORMATION    0x80000017
00803 #define STATUS_RXACT_COMMIT_NECESSARY    0x80000018
00804 #define STATUS_NO_MORE_ENTRIES           0x8000001A
00805 #define STATUS_FILEMARK_DETECTED         0x8000001B
00806 #define STATUS_MEDIA_CHANGED             0x8000001C
00807 #define STATUS_BUS_RESET                 0x8000001D
00808 #define STATUS_END_OF_MEDIA              0x8000001E
00809 #define STATUS_BEGINNING_OF_MEDIA        0x8000001F
00810 #define STATUS_MEDIA_CHECK               0x80000020
00811 #define STATUS_SETMARK_DETECTED          0x80000021
00812 #define STATUS_NO_DATA_DETECTED          0x80000022
00813 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
00814 #define STATUS_SERVER_HAS_OPEN_HANDLES   0x80000024
00815 #define STATUS_ALREADY_DISCONNECTED      0x80000025
00816 #define STATUS_LONGJUMP                  0x80000026
00817 
00818 #define STATUS_UNSUCCESSFUL              0xC0000001
00819 #define STATUS_NOT_IMPLEMENTED           0xC0000002
00820 #define STATUS_INVALID_INFO_CLASS        0xC0000003
00821 #define STATUS_INFO_LENGTH_MISMATCH      0xC0000004
00822 #define STATUS_ACCESS_VIOLATION          0xC0000005
00823 #define STATUS_IN_PAGE_ERROR             0xC0000006
00824 #define STATUS_PAGEFILE_QUOTA            0xC0000007
00825 #define STATUS_INVALID_HANDLE            0xC0000008
00826 #define STATUS_BAD_INITIAL_STACK         0xC0000009
00827 #define STATUS_BAD_INITIAL_PC            0xC000000A
00828 #define STATUS_INVALID_CID               0xC000000B
00829 #define STATUS_TIMER_NOT_CANCELED        0xC000000C
00830 #define STATUS_INVALID_PARAMETER         0xC000000D
00831 #define STATUS_NO_SUCH_DEVICE            0xC000000E
00832 #define STATUS_NO_SUCH_FILE              0xC000000F
00833 #define STATUS_INVALID_DEVICE_REQUEST    0xC0000010
00834 #define STATUS_END_OF_FILE               0xC0000011
00835 #define STATUS_WRONG_VOLUME              0xC0000012
00836 #define STATUS_NO_MEDIA_IN_DEVICE        0xC0000013
00837 #define STATUS_UNRECOGNIZED_MEDIA        0xC0000014
00838 #define STATUS_NONEXISTENT_SECTOR        0xC0000015
00839 #define STATUS_MORE_PROCESSING_REQUIRED  0xC0000016
00840 #define STATUS_NO_MEMORY                 0xC0000017
00841 #define STATUS_CONFLICTING_ADDRESSES     0xC0000018
00842 #define STATUS_NOT_MAPPED_VIEW           0xC0000019
00843 #define STATUS_UNABLE_TO_FREE_VM         0xC000001A
00844 #define STATUS_UNABLE_TO_DELETE_SECTION  0xC000001B
00845 #define STATUS_INVALID_SYSTEM_SERVICE    0xC000001C
00846 #define STATUS_ILLEGAL_INSTRUCTION       0xC000001D
00847 #define STATUS_INVALID_LOCK_SEQUENCE     0xC000001E
00848 #define STATUS_INVALID_VIEW_SIZE         0xC000001F
00849 #define STATUS_INVALID_FILE_FOR_SECTION  0xC0000020
00850 #define STATUS_ALREADY_COMMITTED         0xC0000021
00851 #define STATUS_ACCESS_DENIED             0xC0000022
00852 #define STATUS_BUFFER_TOO_SMALL          0xC0000023
00853 #define STATUS_OBJECT_TYPE_MISMATCH      0xC0000024
00854 #define STATUS_NONCONTINUABLE_EXCEPTION  0xC0000025
00855 #define STATUS_INVALID_DISPOSITION       0xC0000026
00856 #define STATUS_UNWIND                    0xC0000027
00857 #define STATUS_BAD_STACK                 0xC0000028
00858 #define STATUS_INVALID_UNWIND_TARGET     0xC0000029
00859 #define STATUS_NOT_LOCKED                0xC000002A
00860 #define STATUS_PARITY_ERROR              0xC000002B
00861 #define STATUS_UNABLE_TO_DECOMMIT_VM     0xC000002C
00862 #define STATUS_NOT_COMMITTED             0xC000002D
00863 #define STATUS_INVALID_PORT_ATTRIBUTES   0xC000002E
00864 #define STATUS_PORT_MESSAGE_TOO_LONG     0xC000002F
00865 #define STATUS_INVALID_PARAMETER_MIX     0xC0000030
00866 #define STATUS_INVALID_QUOTA_LOWER       0xC0000031
00867 #define STATUS_DISK_CORRUPT_ERROR        0xC0000032
00868 #define STATUS_OBJECT_NAME_INVALID       0xC0000033
00869 #define STATUS_OBJECT_NAME_NOT_FOUND     0xC0000034
00870 #define STATUS_OBJECT_NAME_COLLISION     0xC0000035
00871 #define STATUS_PORT_DISCONNECTED         0xC0000037
00872 #define STATUS_DEVICE_ALREADY_ATTACHED   0xC0000038
00873 #define STATUS_OBJECT_PATH_INVALID       0xC0000039
00874 #define STATUS_OBJECT_PATH_NOT_FOUND     0xC000003A
00875 #define STATUS_PATH_SYNTAX_BAD           0xC000003B
00876 #define STATUS_DATA_OVERRUN              0xC000003C
00877 #define STATUS_DATA_LATE_ERROR           0xC000003D
00878 #define STATUS_DATA_ERROR                0xC000003E
00879 #define STATUS_CRC_ERROR                 0xC000003F
00880 #define STATUS_SECTION_TOO_BIG           0xC0000040
00881 #define STATUS_PORT_CONNECTION_REFUSED   0xC0000041
00882 #define STATUS_INVALID_PORT_HANDLE       0xC0000042
00883 #define STATUS_SHARING_VIOLATION         0xC0000043
00884 #define STATUS_QUOTA_EXCEEDED            0xC0000044
00885 #define STATUS_INVALID_PAGE_PROTECTION   0xC0000045
00886 #define STATUS_MUTANT_NOT_OWNED          0xC0000046
00887 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED  0xC0000047
00888 #define STATUS_PORT_ALREADY_SET          0xC0000048
00889 #define STATUS_SUSPEND_COUNT_EXCEEDED    0xC000004A
00890 #define STATUS_LOCK_NOT_GRANTED          0xC0000054  /* FIXME: not sure */
00891 #define STATUS_FILE_LOCK_CONFLICT        0xC0000055  /* FIXME: not sure */
00892 #define STATUS_UNKNOWN_REVISION          0xC0000058
00893 #define STATUS_INVALID_SECURITY_DESCR    0xC0000079
00894 #define STATUS_DISK_FULL                 0xC000007F 
00895 #define STATUS_SECTION_NOT_EXTENDED      0xC0000087
00896 #define STATUS_ARRAY_BOUNDS_EXCEEDED     0xC000008C
00897 #define STATUS_FLOAT_DENORMAL_OPERAND    0xC000008D
00898 #define STATUS_FLOAT_DIVIDE_BY_ZERO      0xC000008E
00899 #define STATUS_FLOAT_INEXACT_RESULT      0xC000008F
00900 #define STATUS_FLOAT_INVALID_OPERATION   0xC0000090
00901 #define STATUS_FLOAT_OVERFLOW            0xC0000091
00902 #define STATUS_FLOAT_STACK_CHECK         0xC0000092
00903 #define STATUS_FLOAT_UNDERFLOW           0xC0000093
00904 #define STATUS_INTEGER_DIVIDE_BY_ZERO    0xC0000094
00905 #define STATUS_INTEGER_OVERFLOW          0xC0000095
00906 #define STATUS_PRIVILEGED_INSTRUCTION    0xC0000096
00907 #define STATUS_MEDIA_WRITE_PROTECTED     0XC00000A2
00908 #define STATUS_INVALID_PARAMETER_2       0xC00000F0
00909 #define STATUS_STACK_OVERFLOW            0xC00000FD
00910 #define STATUS_DIRECTORY_NOT_EMPTY       0xC0000101
00911 #define STATUS_TOO_MANY_OPENED_FILES     0xC000011F
00912 #define STATUS_CONTROL_C_EXIT            0xC000013A
00913 #define STATUS_PIPE_BROKEN               0xC000014B
00914 #define STATUS_NOT_REGISTRY_FILE         0xC000015C
00915 #define STATUS_PARTITION_FAILURE         0xC0000172
00916 #define STATUS_INVALID_BLOCK_LENGTH      0xC0000173
00917 #define STATUS_DEVICE_NOT_PARTITIONED    0xC0000174
00918 #define STATUS_UNABLE_TO_LOCK_MEDIA      0xC0000175
00919 #define STATUS_UNABLE_TO_UNLOAD_MEDIA    0xC0000176
00920 #define STATUS_EOM_OVERFLOW              0xC0000177
00921 #define STATUS_NO_MEDIA                  0xC0000178
00922 #define STATUS_NO_SUCH_MEMBER            0xC000017A
00923 #define STATUS_INVALID_MEMBER            0xC000017B
00924 #define STATUS_KEY_DELETED               0xC000017C
00925 #define STATUS_NO_LOG_SPACE              0xC000017D
00926 #define STATUS_TOO_MANY_SIDS             0xC000017E
00927 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
00928 #define STATUS_KEY_HAS_CHILDREN          0xC0000180
00929 #define STATUS_CHILD_MUST_BE_VOLATILE    0xC0000181
00930 #define STATUS_DEVICE_CONFIGURATION_ERROR0xC0000182
00931 #define STATUS_DRIVER_INTERNAL_ERROR     0xC0000183
00932 #define STATUS_INVALID_DEVICE_STATE      0xC0000184
00933 #define STATUS_IO_DEVICE_ERROR           0xC0000185
00934 #define STATUS_DEVICE_PROTOCOL_ERROR     0xC0000186
00935 #define STATUS_BACKUP_CONTROLLER         0xC0000187
00936 #define STATUS_LOG_FILE_FULL             0xC0000188
00937 #define STATUS_TOO_LATE                  0xC0000189
00938 #define STATUS_NO_TRUST_LSA_SECRET       0xC000018A
00939 #define STATUS_NO_TRUST_SAM_ACCOUNT      0xC000018B
00940 #define STATUS_TRUSTED_DOMAIN_FAILURE    0xC000018C
00941 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
00942 #define STATUS_EVENTLOG_FILE_CORRUPT     0xC000018E
00943 #define STATUS_EVENTLOG_CANT_START       0xC000018F
00944 #define STATUS_TRUST_FAILURE             0xC0000190
00945 #define STATUS_MUTANT_LIMIT_EXCEEDED     0xC0000191
00946 #define STATUS_NETLOGON_NOT_STARTED      0xC0000192
00947 #define STATUS_ACCOUNT_EXPIRED           0xC0000193
00948 #define STATUS_POSSIBLE_DEADLOCK         0xC0000194
00949 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
00950 #define STATUS_REMOTE_SESSION_LIMIT      0xC0000196
00951 #define STATUS_EVENTLOG_FILE_CHANGED     0xC0000197
00952 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
00953 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
00954 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
00955 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
00956 #define STATUS_FS_DRIVER_REQUIRED        0xC000019C
00957 
00958 #define STATUS_RESOURCE_LANG_NOT_FOUND   0xC0000204
00959 
00960 #define MAXIMUM_WAIT_OBJECTS 64
00961 #define MAXIMUM_SUSPEND_COUNT 127
00962 
00963 
00964 /*
00965  * Return values from the actual exception handlers
00966  */
00967 
00968 #define ExceptionContinueExecution 0
00969 #define ExceptionContinueSearch    1
00970 #define ExceptionNestedException   2
00971 #define ExceptionCollidedUnwind    3
00972  
00973 /*
00974  * Return values from filters in except() and from UnhandledExceptionFilter
00975  */
00976  
00977 #define EXCEPTION_EXECUTE_HANDLER        1
00978 #define EXCEPTION_CONTINUE_SEARCH        0
00979 #define EXCEPTION_CONTINUE_EXECUTION    -1
00980 
00981 /*
00982  * From OS/2 2.0 exception handling
00983  * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
00984  */
00985 
00986 #define EH_NONCONTINUABLE   0x01
00987 #define EH_UNWINDING        0x02
00988 #define EH_EXIT_UNWIND      0x04
00989 #define EH_STACK_INVALID    0x08
00990 #define EH_NESTED_CALL      0x10
00991 
00992 #define EXCEPTION_CONTINUABLE        0
00993 #define EXCEPTION_NONCONTINUABLE     EH_NONCONTINUABLE
00994  
00995 /*
00996  * The exception record used by Win32 to give additional information 
00997  * about exception to exception handlers.
00998  */
00999 
01000 #define EXCEPTION_MAXIMUM_PARAMETERS 15
01001 
01002 typedef struct __EXCEPTION_RECORD
01003 {
01004     DWORD    ExceptionCode;
01005     DWORD    ExceptionFlags;
01006     struct __EXCEPTION_RECORD *ExceptionRecord;
01007 
01008     LPVOID   ExceptionAddress;
01009     DWORD    NumberParameters;
01010     DWORD    ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
01011 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
01012 
01013 /*
01014  * The exception pointers structure passed to exception filters
01015  * in except() and the UnhandledExceptionFilter().
01016  */
01017  
01018 typedef struct _EXCEPTION_POINTERS 
01019 {
01020   PEXCEPTION_RECORD  ExceptionRecord;
01021   PCONTEXT           ContextRecord;
01022 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
01023 
01024 
01025 /*
01026  * The exception frame, used for registering exception handlers 
01027  * Win32 cares only about this, but compilers generally emit 
01028  * larger exception frames for their own use.
01029  */
01030 
01031 struct __EXCEPTION_FRAME;
01032 
01033 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
01034                                     PCONTEXT,struct __EXCEPTION_FRAME **);
01035 
01036 typedef struct __EXCEPTION_FRAME
01037 {
01038   struct __EXCEPTION_FRAME *Prev;
01039   PEXCEPTION_HANDLER       Handler;
01040 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
01041 
01042 #include "poppack.h"
01043 
01044 /*
01045  * function pointer to a exception filter
01046  */
01047 
01048 typedef LONG CALLBACK (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
01049 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
01050 
01051 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
01052 LPTOP_LEVEL_EXCEPTION_FILTER
01053 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
01054 
01055 /* status values for ContinueDebugEvent */
01056 #define DBG_CONTINUE                0x00010002
01057 #define DBG_TERMINATE_THREAD        0x40010003
01058 #define DBG_TERMINATE_PROCESS       0x40010004
01059 #define DBG_CONTROL_C               0x40010005
01060 #define DBG_CONTROL_BREAK           0x40010008
01061 #define DBG_EXCEPTION_NOT_HANDLED   0x80010001
01062 
01063 typedef struct _NT_TIB 
01064 {
01065         struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
01066         PVOID StackBase;
01067         PVOID StackLimit;
01068         PVOID SubSystemTib;
01069         union {
01070           PVOID FiberData;
01071           DWORD Version;
01072         } DUMMYUNIONNAME;
01073         PVOID ArbitraryUserPointer;
01074         struct _NT_TIB *Self;
01075 } NT_TIB, *PNT_TIB;
01076 
01077 struct _TEB;
01078 /*
01079 #if defined(__i386__) && defined(__GNUC__)
01080 extern inline struct _TEB * WINAPI NtCurrentTeb(void);
01081 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
01082 {
01083     struct _TEB *teb;
01084     __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
01085     return teb;
01086 }
01087 #else
01088 extern struct _TEB * WINAPI NtCurrentTeb(void);
01089 #endif
01090 */
01091 
01092 /*
01093  * File formats definitions
01094  */
01095 
01096 typedef struct _IMAGE_DOS_HEADER {
01097     WORD  e_magic;      /* 00: MZ Header signature */
01098     WORD  e_cblp;       /* 02: Bytes on last page of file */
01099     WORD  e_cp;         /* 04: Pages in file */
01100     WORD  e_crlc;       /* 06: Relocations */
01101     WORD  e_cparhdr;    /* 08: Size of header in paragraphs */
01102     WORD  e_minalloc;   /* 0a: Minimum extra paragraphs needed */
01103     WORD  e_maxalloc;   /* 0c: Maximum extra paragraphs needed */
01104     WORD  e_ss;         /* 0e: Initial (relative) SS value */
01105     WORD  e_sp;         /* 10: Initial SP value */
01106     WORD  e_csum;       /* 12: Checksum */
01107     WORD  e_ip;         /* 14: Initial IP value */
01108     WORD  e_cs;         /* 16: Initial (relative) CS value */
01109     WORD  e_lfarlc;     /* 18: File address of relocation table */
01110     WORD  e_ovno;       /* 1a: Overlay number */
01111     WORD  e_res[4];     /* 1c: Reserved words */
01112     WORD  e_oemid;      /* 24: OEM identifier (for e_oeminfo) */
01113     WORD  e_oeminfo;    /* 26: OEM information; e_oemid specific */
01114     WORD  e_res2[10];   /* 28: Reserved words */
01115     DWORD e_lfanew;     /* 3c: Offset to extended header */
01116 } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
01117 
01118 #define IMAGE_DOS_SIGNATURE    0x5A4D     /* MZ   */
01119 #define IMAGE_OS2_SIGNATURE    0x454E     /* NE   */
01120 #define IMAGE_OS2_SIGNATURE_LE 0x454C     /* LE   */
01121 #define IMAGE_OS2_SIGNATURE_LX 0x584C     /* LX */
01122 #define IMAGE_VXD_SIGNATURE    0x454C     /* LE   */
01123 #define IMAGE_NT_SIGNATURE     0x00004550 /* PE00 */
01124 
01125 /*
01126  * This is the Windows executable (NE) header.
01127  * the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
01128  */
01129 typedef struct 
01130 {
01131     WORD  ne_magic;             /* 00 NE signature 'NE' */
01132     BYTE  ne_ver;               /* 02 Linker version number */
01133     BYTE  ne_rev;               /* 03 Linker revision number */
01134     WORD  ne_enttab;            /* 04 Offset to entry table relative to NE */
01135     WORD  ne_cbenttab;          /* 06 Length of entry table in bytes */
01136     LONG  ne_crc;               /* 08 Checksum */
01137     WORD  ne_flags;             /* 0c Flags about segments in this file */
01138     WORD  ne_autodata;          /* 0e Automatic data segment number */
01139     WORD  ne_heap;              /* 10 Initial size of local heap */
01140     WORD  ne_stack;             /* 12 Initial size of stack */
01141     DWORD ne_csip;              /* 14 Initial CS:IP */
01142     DWORD ne_sssp;              /* 18 Initial SS:SP */
01143     WORD  ne_cseg;              /* 1c # of entries in segment table */
01144     WORD  ne_cmod;              /* 1e # of entries in module reference tab. */
01145     WORD  ne_cbnrestab;         /* 20 Length of nonresident-name table     */
01146     WORD  ne_segtab;            /* 22 Offset to segment table */
01147     WORD  ne_rsrctab;           /* 24 Offset to resource table */
01148     WORD  ne_restab;            /* 26 Offset to resident-name table */
01149     WORD  ne_modtab;            /* 28 Offset to module reference table */
01150     WORD  ne_imptab;            /* 2a Offset to imported name table */
01151     DWORD ne_nrestab;           /* 2c Offset to nonresident-name table */
01152     WORD  ne_cmovent;           /* 30 # of movable entry points */
01153     WORD  ne_align;             /* 32 Logical sector alignment shift count */
01154     WORD  ne_cres;              /* 34 # of resource segments */
01155     BYTE  ne_exetyp;            /* 36 Flags indicating target OS */
01156     BYTE  ne_flagsothers;       /* 37 Additional information flags */
01157     WORD  fastload_offset;      /* 38 Offset to fast load area (should be ne_pretthunks)*/
01158     WORD  fastload_length;      /* 3a Length of fast load area (should be ne_psegrefbytes) */
01159     WORD  ne_swaparea;          /* 3c Reserved by Microsoft */
01160     WORD  ne_expver;            /* 3e Expected Windows version number */
01161 } IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
01162 
01163 typedef struct _IMAGE_VXD_HEADER {
01164   WORD  e32_magic;
01165   BYTE  e32_border;
01166   BYTE  e32_worder;
01167   DWORD e32_level;
01168   WORD  e32_cpu;
01169   WORD  e32_os;
01170   DWORD e32_ver;
01171   DWORD e32_mflags;
01172   DWORD e32_mpages;
01173   DWORD e32_startobj;
01174   DWORD e32_eip;
01175   DWORD e32_stackobj;
01176   DWORD e32_esp;
01177   DWORD e32_pagesize;
01178   DWORD e32_lastpagesize;
01179   DWORD e32_fixupsize;
01180   DWORD e32_fixupsum;
01181   DWORD e32_ldrsize;
01182   DWORD e32_ldrsum;
01183   DWORD e32_objtab;
01184   DWORD e32_objcnt;
01185   DWORD e32_objmap;
01186   DWORD e32_itermap;
01187   DWORD e32_rsrctab;
01188   DWORD e32_rsrccnt;
01189   DWORD e32_restab;
01190   DWORD e32_enttab;
01191   DWORD e32_dirtab;
01192   DWORD e32_dircnt;
01193   DWORD e32_fpagetab;
01194   DWORD e32_frectab;
01195   DWORD e32_impmod;
01196   DWORD e32_impmodcnt;
01197   DWORD e32_impproc;
01198   DWORD e32_pagesum;
01199   DWORD e32_datapage;
01200   DWORD e32_preload;
01201   DWORD e32_nrestab;
01202   DWORD e32_cbnrestab;
01203   DWORD e32_nressum;
01204   DWORD e32_autodata;
01205   DWORD e32_debuginfo;
01206   DWORD e32_debuglen;
01207   DWORD e32_instpreload;
01208   DWORD e32_instdemand;
01209   DWORD e32_heapsize;
01210   BYTE   e32_res3[12];
01211   DWORD e32_winresoff;
01212   DWORD e32_winreslen;
01213   WORD  e32_devid;
01214   WORD  e32_ddkver;
01215 } IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
01216 
01217 
01218 /* These defines describe the meanings of the bits in the Characteristics
01219    field */
01220 
01221 #define IMAGE_FILE_RELOCS_STRIPPED      0x0001 /* No relocation info */
01222 #define IMAGE_FILE_EXECUTABLE_IMAGE     0x0002
01223 #define IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004
01224 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
01225 #define IMAGE_FILE_16BIT_MACHINE        0x0040
01226 #define IMAGE_FILE_BYTES_REVERSED_LO    0x0080
01227 #define IMAGE_FILE_32BIT_MACHINE        0x0100
01228 #define IMAGE_FILE_DEBUG_STRIPPED       0x0200
01229 #define IMAGE_FILE_SYSTEM               0x1000
01230 #define IMAGE_FILE_DLL                  0x2000
01231 #define IMAGE_FILE_BYTES_REVERSED_HI    0x8000
01232 
01233 /* These are the settings of the Machine field. */
01234 #define IMAGE_FILE_MACHINE_UNKNOWN      0
01235 #define IMAGE_FILE_MACHINE_I860         0x14d
01236 #define IMAGE_FILE_MACHINE_I386         0x14c
01237 #define IMAGE_FILE_MACHINE_R3000        0x162
01238 #define IMAGE_FILE_MACHINE_R4000        0x166
01239 #define IMAGE_FILE_MACHINE_R10000       0x168
01240 #define IMAGE_FILE_MACHINE_ALPHA        0x184
01241 #define IMAGE_FILE_MACHINE_POWERPC      0x1F0  
01242 
01243 #define IMAGE_SIZEOF_FILE_HEADER        20
01244 
01245 /* Possible Magic values */
01246 #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
01247 #define IMAGE_ROM_OPTIONAL_HDR_MAGIC       0x107
01248 
01249 /* These are indexes into the DataDirectory array */
01250 #define IMAGE_FILE_EXPORT_DIRECTORY             0
01251 #define IMAGE_FILE_IMPORT_DIRECTORY             1
01252 #define IMAGE_FILE_RESOURCE_DIRECTORY           2
01253 #define IMAGE_FILE_EXCEPTION_DIRECTORY          3
01254 #define IMAGE_FILE_SECURITY_DIRECTORY           4
01255 #define IMAGE_FILE_BASE_RELOCATION_TABLE        5
01256 #define IMAGE_FILE_DEBUG_DIRECTORY              6
01257 #define IMAGE_FILE_DESCRIPTION_STRING           7
01258 #define IMAGE_FILE_MACHINE_VALUE                8  /* Mips */
01259 #define IMAGE_FILE_THREAD_LOCAL_STORAGE         9
01260 #define IMAGE_FILE_CALLBACK_DIRECTORY           10
01261 
01262 /* Directory Entries, indices into the DataDirectory array */
01263 
01264 #define IMAGE_DIRECTORY_ENTRY_EXPORT            0
01265 #define IMAGE_DIRECTORY_ENTRY_IMPORT            1
01266 #define IMAGE_DIRECTORY_ENTRY_RESOURCE          2
01267 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION         3
01268 #define IMAGE_DIRECTORY_ENTRY_SECURITY          4
01269 #define IMAGE_DIRECTORY_ENTRY_BASERELOC         5
01270 #define IMAGE_DIRECTORY_ENTRY_DEBUG             6
01271 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT         7
01272 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR         8   /* (MIPS GP) */
01273 #define IMAGE_DIRECTORY_ENTRY_TLS               9
01274 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG       10
01275 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT      11
01276 #define IMAGE_DIRECTORY_ENTRY_IAT               12  /* Import Address Table */
01277 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT      13
01278 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    14
01279 
01280 /* Subsystem Values */
01281 
01282 #define IMAGE_SUBSYSTEM_UNKNOWN         0
01283 #define IMAGE_SUBSYSTEM_NATIVE          1
01284 #define IMAGE_SUBSYSTEM_WINDOWS_GUI     2       /* Windows GUI subsystem */
01285 #define IMAGE_SUBSYSTEM_WINDOWS_CUI     3       /* Windows character subsystem*/
01286 #define IMAGE_SUBSYSTEM_OS2_CUI         5
01287 #define IMAGE_SUBSYSTEM_POSIX_CUI       7
01288 
01289 typedef struct _IMAGE_FILE_HEADER {
01290   WORD  Machine;
01291   WORD  NumberOfSections;
01292   DWORD TimeDateStamp;
01293   DWORD PointerToSymbolTable;
01294   DWORD NumberOfSymbols;
01295   WORD  SizeOfOptionalHeader;
01296   WORD  Characteristics;
01297 } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
01298 
01299 typedef struct _IMAGE_DATA_DIRECTORY {
01300   DWORD VirtualAddress;
01301   DWORD Size;
01302 } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
01303 
01304 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
01305 
01306 typedef struct _IMAGE_OPTIONAL_HEADER {
01307 
01308   /* Standard fields */
01309 
01310   WORD  Magic;
01311   BYTE  MajorLinkerVersion;
01312   BYTE  MinorLinkerVersion;
01313   DWORD SizeOfCode;
01314   DWORD SizeOfInitializedData;
01315   DWORD SizeOfUninitializedData;
01316   DWORD AddressOfEntryPoint;
01317   DWORD BaseOfCode;
01318   DWORD BaseOfData;
01319 
01320   /* NT additional fields */
01321 
01322   DWORD ImageBase;
01323   DWORD SectionAlignment;
01324   DWORD FileAlignment;
01325   WORD  MajorOperatingSystemVersion;
01326   WORD  MinorOperatingSystemVersion;
01327   WORD  MajorImageVersion;
01328   WORD  MinorImageVersion;
01329   WORD  MajorSubsystemVersion;
01330   WORD  MinorSubsystemVersion;
01331   DWORD Win32VersionValue;
01332   DWORD SizeOfImage;
01333   DWORD SizeOfHeaders;
01334   DWORD CheckSum;
01335   WORD  Subsystem;
01336   WORD  DllCharacteristics;
01337   DWORD SizeOfStackReserve;
01338   DWORD SizeOfStackCommit;
01339   DWORD SizeOfHeapReserve;
01340   DWORD SizeOfHeapCommit;
01341   DWORD LoaderFlags;
01342   DWORD NumberOfRvaAndSizes;
01343   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
01344 } IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
01345 
01346 typedef struct _IMAGE_NT_HEADERS {
01347   DWORD Signature;
01348   IMAGE_FILE_HEADER FileHeader;
01349   IMAGE_OPTIONAL_HEADER OptionalHeader;
01350 } IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
01351 
01352 #define IMAGE_SIZEOF_SHORT_NAME 8
01353 
01354 typedef struct _IMAGE_SECTION_HEADER {
01355   BYTE  Name[IMAGE_SIZEOF_SHORT_NAME];
01356   union {
01357     DWORD PhysicalAddress;
01358     DWORD VirtualSize;
01359   } Misc;
01360   DWORD VirtualAddress;
01361   DWORD SizeOfRawData;
01362   DWORD PointerToRawData;
01363   DWORD PointerToRelocations;
01364   DWORD PointerToLinenumbers;
01365   WORD  NumberOfRelocations;
01366   WORD  NumberOfLinenumbers;
01367   DWORD Characteristics;
01368 } IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
01369 
01370 #define IMAGE_SIZEOF_SECTION_HEADER 40
01371 
01372 #define IMAGE_FIRST_SECTION(ntheader) \
01373   ((PIMAGE_SECTION_HEADER)((LPBYTE)&((PIMAGE_NT_HEADERS)(ntheader))->OptionalHeader + \
01374                            ((PIMAGE_NT_HEADERS)(ntheader))->FileHeader.SizeOfOptionalHeader))
01375 
01376 /* These defines are for the Characteristics bitfield. */
01377 /* #define IMAGE_SCN_TYPE_REG                   0x00000000 - Reserved */
01378 /* #define IMAGE_SCN_TYPE_DSECT                 0x00000001 - Reserved */
01379 /* #define IMAGE_SCN_TYPE_NOLOAD                0x00000002 - Reserved */
01380 /* #define IMAGE_SCN_TYPE_GROUP                 0x00000004 - Reserved */
01381 /* #define IMAGE_SCN_TYPE_NO_PAD                0x00000008 - Reserved */
01382 /* #define IMAGE_SCN_TYPE_COPY                  0x00000010 - Reserved */
01383 
01384 #define IMAGE_SCN_CNT_CODE                      0x00000020
01385 #define IMAGE_SCN_CNT_INITIALIZED_DATA          0x00000040
01386 #define IMAGE_SCN_CNT_UNINITIALIZED_DATA        0x00000080
01387 
01388 #define IMAGE_SCN_LNK_OTHER                     0x00000100 
01389 #define IMAGE_SCN_LNK_INFO                      0x00000200  
01390 /* #define      IMAGE_SCN_TYPE_OVER             0x00000400 - Reserved */
01391 #define IMAGE_SCN_LNK_REMOVE                    0x00000800
01392 #define IMAGE_SCN_LNK_COMDAT                    0x00001000
01393 
01394 /*                                              0x00002000 - Reserved */
01395 /* #define IMAGE_SCN_MEM_PROTECTED              0x00004000 - Obsolete */
01396 #define IMAGE_SCN_MEM_FARDATA                   0x00008000
01397 
01398 /* #define IMAGE_SCN_MEM_SYSHEAP                0x00010000 - Obsolete */
01399 #define IMAGE_SCN_MEM_PURGEABLE                 0x00020000
01400 #define IMAGE_SCN_MEM_16BIT                     0x00020000
01401 #define IMAGE_SCN_MEM_LOCKED                    0x00040000
01402 #define IMAGE_SCN_MEM_PRELOAD                   0x00080000
01403 
01404 #define IMAGE_SCN_ALIGN_1BYTES                  0x00100000
01405 #define IMAGE_SCN_ALIGN_2BYTES                  0x00200000
01406 #define IMAGE_SCN_ALIGN_4BYTES                  0x00300000
01407 #define IMAGE_SCN_ALIGN_8BYTES                  0x00400000
01408 #define IMAGE_SCN_ALIGN_16BYTES                 0x00500000  /* Default */
01409 #define IMAGE_SCN_ALIGN_32BYTES                 0x00600000
01410 #define IMAGE_SCN_ALIGN_64BYTES                 0x00700000
01411 /*                                              0x00800000 - Unused */
01412 
01413 #define IMAGE_SCN_LNK_NRELOC_OVFL               0x01000000
01414 
01415 
01416 #define IMAGE_SCN_MEM_DISCARDABLE               0x02000000
01417 #define IMAGE_SCN_MEM_NOT_CACHED                0x04000000
01418 #define IMAGE_SCN_MEM_NOT_PAGED                 0x08000000
01419 #define IMAGE_SCN_MEM_SHARED                    0x10000000
01420 #define IMAGE_SCN_MEM_EXECUTE                   0x20000000
01421 #define IMAGE_SCN_MEM_READ                      0x40000000
01422 #define IMAGE_SCN_MEM_WRITE                     0x80000000
01423 
01424 #include "pshpack2.h"
01425 
01426 typedef struct _IMAGE_SYMBOL {
01427     union {
01428         BYTE    ShortName[8];
01429         struct {
01430             DWORD   Short;
01431             DWORD   Long;
01432         } Name;
01433         DWORD   LongName[2];
01434     } N;
01435     DWORD   Value;
01436     SHORT   SectionNumber;
01437     WORD    Type;
01438     BYTE    StorageClass;
01439     BYTE    NumberOfAuxSymbols;
01440 } IMAGE_SYMBOL;
01441 typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
01442 
01443 #define IMAGE_SIZEOF_SYMBOL 18
01444 
01445 typedef struct _IMAGE_LINENUMBER {
01446     union {
01447         DWORD   SymbolTableIndex;
01448         DWORD   VirtualAddress;
01449     } Type;
01450     WORD    Linenumber;
01451 } IMAGE_LINENUMBER;
01452 typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
01453 
01454 #define IMAGE_SIZEOF_LINENUMBER  6
01455 
01456 typedef union _IMAGE_AUX_SYMBOL {
01457     struct {
01458         DWORD    TagIndex;
01459         union {
01460             struct {
01461                 WORD    Linenumber;
01462                 WORD    Size;
01463             } LnSz;
01464            DWORD    TotalSize;
01465         } Misc;
01466         union {
01467             struct {
01468                 DWORD    PointerToLinenumber;
01469                 DWORD    PointerToNextFunction;
01470             } Function;
01471             struct {
01472                 WORD     Dimension[4];
01473             } Array;
01474         } FcnAry;
01475         WORD    TvIndex;
01476     } Sym;
01477     struct {
01478         BYTE    Name[IMAGE_SIZEOF_SYMBOL];
01479     } File;
01480     struct {
01481         DWORD   Length;
01482         WORD    NumberOfRelocations;
01483         WORD    NumberOfLinenumbers;
01484         DWORD   CheckSum;
01485         SHORT   Number;
01486         BYTE    Selection;
01487     } Section;
01488 } IMAGE_AUX_SYMBOL;
01489 typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
01490 
01491 #define IMAGE_SIZEOF_AUX_SYMBOL 18
01492 
01493 #include "poppack.h"
01494 
01495 #define IMAGE_SYM_UNDEFINED           (SHORT)0
01496 #define IMAGE_SYM_ABSOLUTE            (SHORT)-1
01497 #define IMAGE_SYM_DEBUG               (SHORT)-2
01498 
01499 #define IMAGE_SYM_TYPE_NULL                 0x0000
01500 #define IMAGE_SYM_TYPE_VOID                 0x0001
01501 #define IMAGE_SYM_TYPE_CHAR                 0x0002
01502 #define IMAGE_SYM_TYPE_SHORT                0x0003
01503 #define IMAGE_SYM_TYPE_INT                  0x0004
01504 #define IMAGE_SYM_TYPE_LONG                 0x0005
01505 #define IMAGE_SYM_TYPE_FLOAT                0x0006
01506 #define IMAGE_SYM_TYPE_DOUBLE               0x0007
01507 #define IMAGE_SYM_TYPE_STRUCT               0x0008
01508 #define IMAGE_SYM_TYPE_UNION                0x0009
01509 #define IMAGE_SYM_TYPE_ENUM                 0x000A
01510 #define IMAGE_SYM_TYPE_MOE                  0x000B
01511 #define IMAGE_SYM_TYPE_BYTE                 0x000C
01512 #define IMAGE_SYM_TYPE_WORD                 0x000D
01513 #define IMAGE_SYM_TYPE_UINT                 0x000E
01514 #define IMAGE_SYM_TYPE_DWORD                0x000F
01515 #define IMAGE_SYM_TYPE_PCODE                0x8000
01516 
01517 #define IMAGE_SYM_DTYPE_NULL                0
01518 #define IMAGE_SYM_DTYPE_POINTER             1
01519 #define IMAGE_SYM_DTYPE_FUNCTION            2
01520 #define IMAGE_SYM_DTYPE_ARRAY               3
01521 
01522 #define IMAGE_SYM_CLASS_END_OF_FUNCTION     (BYTE )-1
01523 #define IMAGE_SYM_CLASS_NULL                0x0000
01524 #define IMAGE_SYM_CLASS_AUTOMATIC           0x0001
01525 #define IMAGE_SYM_CLASS_EXTERNAL            0x0002
01526 #define IMAGE_SYM_CLASS_STATIC              0x0003
01527 #define IMAGE_SYM_CLASS_REGISTER            0x0004
01528 #define IMAGE_SYM_CLASS_EXTERNAL_DEF        0x0005
01529 #define IMAGE_SYM_CLASS_LABEL               0x0006
01530 #define IMAGE_SYM_CLASS_UNDEFINED_LABEL     0x0007
01531 #define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    0x0008
01532 #define IMAGE_SYM_CLASS_ARGUMENT            0x0009
01533 #define IMAGE_SYM_CLASS_STRUCT_TAG          0x000A
01534 #define IMAGE_SYM_CLASS_MEMBER_OF_UNION     0x000B
01535 #define IMAGE_SYM_CLASS_UNION_TAG           0x000C
01536 #define IMAGE_SYM_CLASS_TYPE_DEFINITION     0x000D
01537 #define IMAGE_SYM_CLASS_UNDEFINED_STATIC    0x000E
01538 #define IMAGE_SYM_CLASS_ENUM_TAG            0x000F
01539 #define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      0x0010
01540 #define IMAGE_SYM_CLASS_REGISTER_PARAM      0x0011
01541 #define IMAGE_SYM_CLASS_BIT_FIELD           0x0012
01542 
01543 #define IMAGE_SYM_CLASS_FAR_EXTERNAL        0x0044
01544 #define IMAGE_SYM_CLASS_BLOCK               0x0064
01545 #define IMAGE_SYM_CLASS_FUNCTION            0x0065
01546 #define IMAGE_SYM_CLASS_END_OF_STRUCT       0x0066
01547 #define IMAGE_SYM_CLASS_FILE                0x0067
01548 #define IMAGE_SYM_CLASS_SECTION             0x0068
01549 #define IMAGE_SYM_CLASS_WEAK_EXTERNAL       0x0069
01550 
01551 #define N_BTMASK                            0x000F
01552 #define N_TMASK                             0x0030
01553 #define N_TMASK1                            0x00C0
01554 #define N_TMASK2                            0x00F0
01555 #define N_BTSHFT                            4
01556 #define N_TSHIFT                            2
01557 
01558 #define BTYPE(x) ((x) & N_BTMASK)
01559 
01560 #ifndef ISPTR
01561 #define ISPTR(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT))
01562 #endif
01563 
01564 #ifndef ISFCN
01565 #define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
01566 #endif
01567 
01568 #ifndef ISARY
01569 #define ISARY(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT))
01570 #endif
01571 
01572 #ifndef ISTAG
01573 #define ISTAG(x) ((x)==IMAGE_SYM_CLASS_STRUCT_TAG || (x)==IMAGE_SYM_CLASS_UNION_TAG || (x)==IMAGE_SYM_CLASS_ENUM_TAG)
01574 #endif
01575 
01576 #ifndef INCREF
01577 #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(IMAGE_SYM_DTYPE_POINTER<<N_BTSHFT)|((x)&N_BTMASK))
01578 #endif
01579 #ifndef DECREF
01580 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
01581 #endif
01582 
01583 #define IMAGE_COMDAT_SELECT_NODUPLICATES    1
01584 #define IMAGE_COMDAT_SELECT_ANY             2
01585 #define IMAGE_COMDAT_SELECT_SAME_SIZE       3
01586 #define IMAGE_COMDAT_SELECT_EXACT_MATCH     4
01587 #define IMAGE_COMDAT_SELECT_ASSOCIATIVE     5
01588 #define IMAGE_COMDAT_SELECT_LARGEST         6
01589 #define IMAGE_COMDAT_SELECT_NEWEST          7
01590 
01591 #define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1
01592 #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2
01593 #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3
01594 
01595 /* Export module directory */
01596 
01597 typedef struct _IMAGE_EXPORT_DIRECTORY {
01598         DWORD   Characteristics;
01599         DWORD   TimeDateStamp;
01600         WORD    MajorVersion;
01601         WORD    MinorVersion;
01602         DWORD   Name;
01603         DWORD   Base;
01604         DWORD   NumberOfFunctions;
01605         DWORD   NumberOfNames;
01606         LPDWORD *AddressOfFunctions;
01607         LPDWORD *AddressOfNames;
01608         LPWORD  *AddressOfNameOrdinals;
01609 } IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
01610 
01611 /* Import name entry */
01612 typedef struct _IMAGE_IMPORT_BY_NAME {
01613         WORD    Hint;
01614         BYTE    Name[1];
01615 } IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME;
01616 
01617 /* Import thunk */
01618 typedef struct _IMAGE_THUNK_DATA {
01619         union {
01620                 LPBYTE    ForwarderString;
01621                 FARPROC Function;
01622                 DWORD     Ordinal;
01623                 PIMAGE_IMPORT_BY_NAME   AddressOfData;
01624         } u1;
01625 } IMAGE_THUNK_DATA,*PIMAGE_THUNK_DATA;
01626 
01627 /* Import module directory */
01628 
01629 typedef struct _IMAGE_IMPORT_DESCRIPTOR {
01630         union {
01631                 DWORD   Characteristics; /* 0 for terminating null import descriptor  */
01632                 PIMAGE_THUNK_DATA OriginalFirstThunk;   /* RVA to original unbound IAT */
01633         } u;
01634         DWORD   TimeDateStamp;  /* 0 if not bound,
01635                                  * -1 if bound, and real date\time stamp
01636                                  *    in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT
01637                                  * (new BIND)
01638                                  * otherwise date/time stamp of DLL bound to
01639                                  * (Old BIND)
01640                                  */
01641         DWORD   ForwarderChain; /* -1 if no forwarders */
01642         DWORD   Name;
01643         /* RVA to IAT (if bound this IAT has actual addresses) */
01644         PIMAGE_THUNK_DATA FirstThunk;   
01645 } IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR;
01646 
01647 #define IMAGE_ORDINAL_FLAG              0x80000000
01648 #define IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
01649 #define IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)
01650 
01651 typedef struct _IMAGE_BOUND_IMPORT_DESCRIPTOR
01652 {
01653     DWORD   TimeDateStamp;
01654     WORD    OffsetModuleName;
01655     WORD    NumberOfModuleForwarderRefs;
01656 /* Array of zero or more IMAGE_BOUND_FORWARDER_REF follows */
01657 } IMAGE_BOUND_IMPORT_DESCRIPTOR,  *PIMAGE_BOUND_IMPORT_DESCRIPTOR;
01658 
01659 typedef struct _IMAGE_BOUND_FORWARDER_REF
01660 {
01661     DWORD   TimeDateStamp;
01662     WORD    OffsetModuleName;
01663     WORD    Reserved;
01664 } IMAGE_BOUND_FORWARDER_REF, *PIMAGE_BOUND_FORWARDER_REF;
01665 
01666 typedef struct _IMAGE_BASE_RELOCATION
01667 {
01668         DWORD   VirtualAddress;
01669         DWORD   SizeOfBlock;
01670         WORD    TypeOffset[1];
01671 } IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION;
01672 
01673 typedef struct _IMAGE_RELOCATION
01674 {
01675     union {
01676         DWORD   VirtualAddress;
01677         DWORD   RelocCount;
01678     } u;
01679     DWORD   SymbolTableIndex;
01680     WORD    Type;
01681 } IMAGE_RELOCATION;
01682 typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
01683 
01684 #define IMAGE_SIZEOF_RELOCATION 10
01685 
01686 /* generic relocation types */
01687 #define IMAGE_REL_BASED_ABSOLUTE                0
01688 #define IMAGE_REL_BASED_HIGH                    1
01689 #define IMAGE_REL_BASED_LOW                     2
01690 #define IMAGE_REL_BASED_HIGHLOW                 3
01691 #define IMAGE_REL_BASED_HIGHADJ                 4
01692 #define IMAGE_REL_BASED_MIPS_JMPADDR            5
01693 #define IMAGE_REL_BASED_SECTION                 6
01694 #define IMAGE_REL_BASED_REL                     7
01695 #define IMAGE_REL_BASED_MIPS_JMPADDR16          9
01696 #define IMAGE_REL_BASED_IA64_IMM64              9 /* yes, 9 too */
01697 #define IMAGE_REL_BASED_DIR64                   10
01698 #define IMAGE_REL_BASED_HIGH3ADJ                11
01699 
01700 /* I386 relocation types */
01701 #define IMAGE_REL_I386_ABSOLUTE                 0
01702 #define IMAGE_REL_I386_DIR16                    1
01703 #define IMAGE_REL_I386_REL16                    2
01704 #define IMAGE_REL_I386_DIR32                    6
01705 #define IMAGE_REL_I386_DIR32NB                  7
01706 #define IMAGE_REL_I386_SEG12                    9
01707 #define IMAGE_REL_I386_SECTION                  10
01708 #define IMAGE_REL_I386_SECREL                   11
01709 #define IMAGE_REL_I386_REL32                    20
01710 
01711 /* MIPS relocation types */
01712 #define IMAGE_REL_MIPS_ABSOLUTE         0x0000
01713 #define IMAGE_REL_MIPS_REFHALF          0x0001
01714 #define IMAGE_REL_MIPS_REFWORD          0x0002
01715 #define IMAGE_REL_MIPS_JMPADDR          0x0003
01716 #define IMAGE_REL_MIPS_REFHI            0x0004
01717 #define IMAGE_REL_MIPS_REFLO            0x0005
01718 #define IMAGE_REL_MIPS_GPREL            0x0006
01719 #define IMAGE_REL_MIPS_LITERAL          0x0007
01720 #define IMAGE_REL_MIPS_SECTION          0x000A
01721 #define IMAGE_REL_MIPS_SECREL           0x000B
01722 #define IMAGE_REL_MIPS_SECRELLO         0x000C
01723 #define IMAGE_REL_MIPS_SECRELHI         0x000D
01724 #define IMAGE_REL_MIPS_JMPADDR16        0x0010
01725 #define IMAGE_REL_MIPS_REFWORDNB        0x0022
01726 #define IMAGE_REL_MIPS_PAIR             0x0025
01727 
01728 /* ALPHA relocation types */
01729 #define IMAGE_REL_ALPHA_ABSOLUTE        0x0000
01730 #define IMAGE_REL_ALPHA_REFLONG         0x0001
01731 #define IMAGE_REL_ALPHA_REFQUAD         0x0002
01732 #define IMAGE_REL_ALPHA_GPREL           0x0003
01733 #define IMAGE_REL_ALPHA_LITERAL         0x0004
01734 #define IMAGE_REL_ALPHA_LITUSE          0x0005
01735 #define IMAGE_REL_ALPHA_GPDISP          0x0006
01736 #define IMAGE_REL_ALPHA_BRADDR          0x0007
01737 #define IMAGE_REL_ALPHA_HINT            0x0008
01738 #define IMAGE_REL_ALPHA_INLINE_REFLONG  0x0009
01739 #define IMAGE_REL_ALPHA_REFHI           0x000A
01740 #define IMAGE_REL_ALPHA_REFLO           0x000B
01741 #define IMAGE_REL_ALPHA_PAIR            0x000C
01742 #define IMAGE_REL_ALPHA_MATCH           0x000D
01743 #define IMAGE_REL_ALPHA_SECTION         0x000E
01744 #define IMAGE_REL_ALPHA_SECREL          0x000F
01745 #define IMAGE_REL_ALPHA_REFLONGNB       0x0010
01746 #define IMAGE_REL_ALPHA_SECRELLO        0x0011
01747 #define IMAGE_REL_ALPHA_SECRELHI        0x0012
01748 #define IMAGE_REL_ALPHA_REFQ3           0x0013
01749 #define IMAGE_REL_ALPHA_REFQ2           0x0014
01750 #define IMAGE_REL_ALPHA_REFQ1           0x0015
01751 #define IMAGE_REL_ALPHA_GPRELLO         0x0016
01752 #define IMAGE_REL_ALPHA_GPRELHI         0x0017
01753 
01754 /* PowerPC relocation types */
01755 #define IMAGE_REL_PPC_ABSOLUTE          0x0000
01756 #define IMAGE_REL_PPC_ADDR64            0x0001
01757 #define IMAGE_REL_PPC_ADDR            0x0002
01758 #define IMAGE_REL_PPC_ADDR24            0x0003
01759 #define IMAGE_REL_PPC_ADDR16            0x0004
01760 #define IMAGE_REL_PPC_ADDR14            0x0005
01761 #define IMAGE_REL_PPC_REL24             0x0006
01762 #define IMAGE_REL_PPC_REL14             0x0007
01763 #define IMAGE_REL_PPC_TOCREL16          0x0008
01764 #define IMAGE_REL_PPC_TOCREL14          0x0009
01765 #define IMAGE_REL_PPC_ADDR32NB          0x000A
01766 #define IMAGE_REL_PPC_SECREL            0x000B
01767 #define IMAGE_REL_PPC_SECTION           0x000C
01768 #define IMAGE_REL_PPC_IFGLUE            0x000D
01769 #define IMAGE_REL_PPC_IMGLUE            0x000E
01770 #define IMAGE_REL_PPC_SECREL16          0x000F
01771 #define IMAGE_REL_PPC_REFHI             0x0010
01772 #define IMAGE_REL_PPC_REFLO             0x0011
01773 #define IMAGE_REL_PPC_PAIR              0x0012
01774 #define IMAGE_REL_PPC_SECRELLO          0x0013
01775 #define IMAGE_REL_PPC_SECRELHI          0x0014
01776 #define IMAGE_REL_PPC_GPREL             0x0015
01777 #define IMAGE_REL_PPC_TYPEMASK          0x00FF
01778 /* modifier bits */
01779 #define IMAGE_REL_PPC_NEG               0x0100
01780 #define IMAGE_REL_PPC_BRTAKEN           0x0200
01781 #define IMAGE_REL_PPC_BRNTAKEN          0x0400
01782 #define IMAGE_REL_PPC_TOCDEFN           0x0800
01783 
01784 /* SH3 ? relocation type */
01785 #define IMAGE_REL_SH3_ABSOLUTE          0x0000
01786 #define IMAGE_REL_SH3_DIRECT16          0x0001
01787 #define IMAGE_REL_SH3_DIRECT          0x0002
01788 #define IMAGE_REL_SH3_DIRECT8           0x0003
01789 #define IMAGE_REL_SH3_DIRECT8_WORD      0x0004
01790 #define IMAGE_REL_SH3_DIRECT8_LONG      0x0005
01791 #define IMAGE_REL_SH3_DIRECT4           0x0006
01792 #define IMAGE_REL_SH3_DIRECT4_WORD      0x0007
01793 #define IMAGE_REL_SH3_DIRECT4_LONG      0x0008
01794 #define IMAGE_REL_SH3_PCREL8_WORD       0x0009
01795 #define IMAGE_REL_SH3_PCREL8_LONG       0x000A
01796 #define IMAGE_REL_SH3_PCREL12_WORD      0x000B
01797 #define IMAGE_REL_SH3_STARTOF_SECTION   0x000C
01798 #define IMAGE_REL_SH3_SIZEOF_SECTION    0x000D
01799 #define IMAGE_REL_SH3_SECTION           0x000E
01800 #define IMAGE_REL_SH3_SECREL            0x000F
01801 #define IMAGE_REL_SH3_DIRECT32_NB       0x0010
01802 
01803 /* ARM (Archimedes?) relocation types */
01804 #define IMAGE_REL_ARM_ABSOLUTE          0x0000
01805 #define IMAGE_REL_ARM_ADDR              0x0001
01806 #define IMAGE_REL_ARM_ADDR32NB          0x0002
01807 #define IMAGE_REL_ARM_BRANCH24          0x0003
01808 #define IMAGE_REL_ARM_BRANCH11          0x0004
01809 #define IMAGE_REL_ARM_SECTION           0x000E
01810 #define IMAGE_REL_ARM_SECREL            0x000F
01811 
01812 /* IA64 relocation types */
01813 #define IMAGE_REL_IA64_ABSOLUTE         0x0000
01814 #define IMAGE_REL_IA64_IMM14            0x0001
01815 #define IMAGE_REL_IA64_IMM22            0x0002
01816 #define IMAGE_REL_IA64_IMM64            0x0003
01817 #define IMAGE_REL_IA64_DIR              0x0004
01818 #define IMAGE_REL_IA64_DIR64            0x0005
01819 #define IMAGE_REL_IA64_PCREL21B         0x0006
01820 #define IMAGE_REL_IA64_PCREL21M         0x0007
01821 #define IMAGE_REL_IA64_PCREL21F         0x0008
01822 #define IMAGE_REL_IA64_GPREL22          0x0009
01823 #define IMAGE_REL_IA64_LTOFF22          0x000A
01824 #define IMAGE_REL_IA64_SECTION          0x000B
01825 #define IMAGE_REL_IA64_SECREL22         0x000C
01826 #define IMAGE_REL_IA64_SECREL64I        0x000D
01827 #define IMAGE_REL_IA64_SECREL           0x000E
01828 #define IMAGE_REL_IA64_LTOFF64          0x000F
01829 #define IMAGE_REL_IA64_DIR32NB          0x0010
01830 #define IMAGE_REL_IA64_RESERVED_11      0x0011
01831 #define IMAGE_REL_IA64_RESERVED_12      0x0012
01832 #define IMAGE_REL_IA64_RESERVED_13      0x0013
01833 #define IMAGE_REL_IA64_RESERVED_14      0x0014
01834 #define IMAGE_REL_IA64_RESERVED_15      0x0015
01835 #define IMAGE_REL_IA64_RESERVED_16      0x0016
01836 #define IMAGE_REL_IA64_ADDEND           0x001F
01837 
01838 /* archive format */
01839 
01840 #define IMAGE_ARCHIVE_START_SIZE             8
01841 #define IMAGE_ARCHIVE_START                  "!<arch>\n"
01842 #define IMAGE_ARCHIVE_END                    "`\n"
01843 #define IMAGE_ARCHIVE_PAD                    "\n"
01844 #define IMAGE_ARCHIVE_LINKER_MEMBER          "/               "
01845 #define IMAGE_ARCHIVE_LONGNAMES_MEMBER       "//              "
01846 
01847 typedef struct _IMAGE_ARCHIVE_MEMBER_HEADER
01848 {
01849     BYTE     Name[16];
01850     BYTE     Date[12];
01851     BYTE     UserID[6];
01852     BYTE     GroupID[6];
01853     BYTE     Mode[8];
01854     BYTE     Size[10];
01855     BYTE     EndHeader[2];
01856 } IMAGE_ARCHIVE_MEMBER_HEADER, *PIMAGE_ARCHIVE_MEMBER_HEADER;
01857 
01858 #define IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
01859 
01860 /*
01861  * Resource directory stuff
01862  */
01863 typedef struct _IMAGE_RESOURCE_DIRECTORY {
01864         DWORD   Characteristics;
01865         DWORD   TimeDateStamp;
01866         WORD    MajorVersion;
01867         WORD    MinorVersion;
01868         WORD    NumberOfNamedEntries;
01869         WORD    NumberOfIdEntries;
01870         /*  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; */
01871 } IMAGE_RESOURCE_DIRECTORY,*PIMAGE_RESOURCE_DIRECTORY;
01872 
01873 #define IMAGE_RESOURCE_NAME_IS_STRING           0x80000000
01874 #define IMAGE_RESOURCE_DATA_IS_DIRECTORY        0x80000000
01875 
01876 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
01877         union {
01878                 struct {
01879                         unsigned NameOffset:31;
01880                         unsigned NameIsString:1;
01881                 } s;
01882                 DWORD   Name;
01883                 WORD    Id;
01884         } u1;
01885         union {
01886                 DWORD   OffsetToData;
01887                 struct {
01888                         unsigned OffsetToDirectory:31;
01889                         unsigned DataIsDirectory:1;
01890                 } s;
01891         } u2;
01892 } IMAGE_RESOURCE_DIRECTORY_ENTRY,*PIMAGE_RESOURCE_DIRECTORY_ENTRY;
01893 
01894 
01895 typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING {
01896         WORD    Length;
01897         CHAR    NameString[ 1 ];
01898 } IMAGE_RESOURCE_DIRECTORY_STRING,*PIMAGE_RESOURCE_DIRECTORY_STRING;
01899 
01900 typedef struct _IMAGE_RESOURCE_DIR_STRING_U {
01901         WORD    Length;
01902         WCHAR   NameString[ 1 ];
01903 } IMAGE_RESOURCE_DIR_STRING_U,*PIMAGE_RESOURCE_DIR_STRING_U;
01904 
01905 typedef struct _IMAGE_RESOURCE_DATA_ENTRY {
01906         DWORD   OffsetToData;
01907         DWORD   Size;
01908         DWORD   CodePage;
01909         DWORD   ResourceHandle;
01910 } IMAGE_RESOURCE_DATA_ENTRY,*PIMAGE_RESOURCE_DATA_ENTRY;
01911 
01912 
01913 typedef VOID CALLBACK (*PIMAGE_TLS_CALLBACK)(
01914         LPVOID DllHandle,DWORD Reason,LPVOID Reserved
01915 );
01916 
01917 typedef struct _IMAGE_TLS_DIRECTORY {
01918         DWORD   StartAddressOfRawData;
01919         DWORD   EndAddressOfRawData;
01920         LPDWORD AddressOfIndex;
01921         PIMAGE_TLS_CALLBACK *AddressOfCallBacks;
01922         DWORD   SizeOfZeroFill;
01923         DWORD   Characteristics;
01924 } IMAGE_TLS_DIRECTORY,*PIMAGE_TLS_DIRECTORY;
01925 
01926 typedef struct _IMAGE_DEBUG_DIRECTORY {
01927   DWORD Characteristics;
01928   DWORD TimeDateStamp;
01929   WORD  MajorVersion;
01930   WORD  MinorVersion;
01931   DWORD Type;
01932   DWORD SizeOfData;
01933   DWORD AddressOfRawData;
01934   DWORD PointerToRawData;
01935 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
01936 
01937 #define IMAGE_DEBUG_TYPE_UNKNOWN        0
01938 #define IMAGE_DEBUG_TYPE_COFF           1
01939 #define IMAGE_DEBUG_TYPE_CODEVIEW       2
01940 #define IMAGE_DEBUG_TYPE_FPO            3
01941 #define IMAGE_DEBUG_TYPE_MISC           4
01942 #define IMAGE_DEBUG_TYPE_EXCEPTION      5
01943 #define IMAGE_DEBUG_TYPE_FIXUP          6
01944 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC    7
01945 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC  8
01946 #define IMAGE_DEBUG_TYPE_BORLAND        9
01947 #define IMAGE_DEBUG_TYPE_RESERVED10    10
01948 
01949 typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
01950   DWORD NumberOfSymbols;
01951   DWORD LvaToFirstSymbol;
01952   DWORD NumberOfLinenumbers;
01953   DWORD LvaToFirstLinenumber;
01954   DWORD RvaToFirstByteOfCode;
01955   DWORD RvaToLastByteOfCode;
01956   DWORD RvaToFirstByteOfData;
01957   DWORD RvaToLastByteOfData;
01958 } IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
01959 
01960 #define FRAME_FPO       0
01961 #define FRAME_TRAP      1
01962 #define FRAME_TSS       2
01963 #define FRAME_NONFPO    3
01964 
01965 typedef struct _FPO_DATA {
01966   DWORD ulOffStart;
01967   DWORD cbProcSize;
01968   DWORD cdwLocals;
01969   WORD  cdwParams;
01970   unsigned cbProlog : 8;
01971   unsigned cbRegs   : 3;
01972   unsigned fHasSEH  : 1;
01973   unsigned fUseBP   : 1;
01974   unsigned reserved : 1;
01975   unsigned cbFrame  : 2;
01976 } FPO_DATA, *PFPO_DATA;
01977 
01978 typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
01979   DWORD Characteristics;
01980   DWORD TimeDateStamp;
01981   WORD  MajorVersion;
01982   WORD  MinorVersion;
01983   DWORD GlobalFlagsClear;
01984   DWORD GlobalFlagsSet;
01985   DWORD CriticalSectionDefaultTimeout;
01986   DWORD DeCommitFreeBlockThreshold;
01987   DWORD DeCommitTotalFreeThreshold;
01988   PVOID LockPrefixTable;
01989   DWORD MaximumAllocationSize;
01990   DWORD VirtualMemoryThreshold;
01991   DWORD ProcessHeapFlags;
01992   DWORD ProcessAffinityMask;
01993   WORD  CSDVersion;
01994   WORD  Reserved1;
01995   PVOID EditList;
01996   DWORD Reserved[1];
01997 } IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
01998 
01999 typedef struct _IMAGE_FUNCTION_ENTRY {
02000   DWORD StartingAddress;
02001   DWORD EndingAddress;
02002   DWORD EndOfPrologue;
02003 } IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
02004 
02005 /* This is the structure that appears at the very start of a .DBG file. */
02006 
02007 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
02008         WORD    Signature;
02009         WORD    Flags;
02010         WORD    Machine;
02011         WORD    Characteristics;
02012         DWORD   TimeDateStamp;
02013         DWORD   CheckSum;
02014         DWORD   ImageBase;
02015         DWORD   SizeOfImage;
02016         DWORD   NumberOfSections;
02017         DWORD   ExportedNamesSize;
02018         DWORD   DebugDirectorySize;
02019         DWORD   SectionAlignment;
02020         DWORD   Reserved[ 2 ];
02021 } IMAGE_SEPARATE_DEBUG_HEADER,*PIMAGE_SEPARATE_DEBUG_HEADER;
02022 
02023 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
02024 
02025 
02026 typedef struct tagMESSAGE_RESOURCE_ENTRY {
02027         WORD    Length;
02028         WORD    Flags;
02029         BYTE    Text[1];
02030 } MESSAGE_RESOURCE_ENTRY,*PMESSAGE_RESOURCE_ENTRY;
02031 #define MESSAGE_RESOURCE_UNICODE        0x0001
02032 
02033 typedef struct tagMESSAGE_RESOURCE_BLOCK {
02034         DWORD   LowId;
02035         DWORD   HighId;
02036         DWORD   OffsetToEntries;
02037 } MESSAGE_RESOURCE_BLOCK,*PMESSAGE_RESOURCE_BLOCK;
02038 
02039 typedef struct tagMESSAGE_RESOURCE_DATA {
02040         DWORD                   NumberOfBlocks;
02041         MESSAGE_RESOURCE_BLOCK  Blocks[ 1 ];
02042 } MESSAGE_RESOURCE_DATA,*PMESSAGE_RESOURCE_DATA;
02043 
02044 /*
02045  * Here follows typedefs for security and tokens.
02046  */ 
02047 
02048 /*
02049  * First a constant for the following typdefs.
02050  */
02051 
02052 #define ANYSIZE_ARRAY   1
02053 
02054 /* FIXME:  Orphan.  What does it point to? */
02055 typedef PVOID PACCESS_TOKEN;
02056 
02057 /*
02058  * TOKEN_INFORMATION_CLASS
02059  */
02060 
02061 typedef enum _TOKEN_INFORMATION_CLASS {
02062   TokenUser = 1, 
02063   TokenGroups, 
02064   TokenPrivileges, 
02065   TokenOwner, 
02066   TokenPrimaryGroup, 
02067   TokenDefaultDacl, 
02068   TokenSource, 
02069   TokenType, 
02070   TokenImpersonationLevel, 
02071   TokenStatistics 
02072 } TOKEN_INFORMATION_CLASS; 
02073 
02074 #ifndef _SECURITY_DEFINED
02075 #define _SECURITY_DEFINED
02076 
02077 #include "pshpack1.h"
02078 
02079 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
02080 
02081 typedef struct _GENERIC_MAPPING {
02082     ACCESS_MASK GenericRead;
02083     ACCESS_MASK GenericWrite;
02084     ACCESS_MASK GenericExecute;
02085     ACCESS_MASK GenericAll;
02086 } GENERIC_MAPPING, *PGENERIC_MAPPING;
02087 
02088 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
02089 #define SID_IDENTIFIER_AUTHORITY_DEFINED
02090 typedef struct {
02091     BYTE Value[6];
02092 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
02093 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
02094 
02095 #ifndef SID_DEFINED
02096 #define SID_DEFINED
02097 typedef struct _SID {
02098     BYTE Revision;
02099     BYTE SubAuthorityCount;
02100     SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
02101     DWORD SubAuthority[1];
02102 } SID,*PSID;
02103 #endif /* !defined(SID_DEFINED) */
02104 
02105 #define SID_REVISION                    (1)     /* Current revision */
02106 #define SID_MAX_SUB_AUTHORITIES         (15)    /* current max subauths */
02107 #define SID_RECOMMENDED_SUB_AUTHORITIES (1)     /* recommended subauths */
02108 
02109 
02110 /* 
02111  * ACL 
02112  */
02113 
02114 #define ACL_REVISION1 1
02115 #define ACL_REVISION2 2
02116 #define ACL_REVISION3 3
02117 #define ACL_REVISION4 4
02118 
02119 #define MIN_ACL_REVISION ACL_REVISION2
02120 #define MAX_ACL_REVISION ACL_REVISION4
02121 
02122 typedef struct _ACL {
02123     BYTE AclRevision;
02124     BYTE Sbz1;
02125     WORD AclSize;
02126     WORD AceCount;
02127     WORD Sbz2;
02128 } ACL, *PACL;
02129 
02130 /* SECURITY_DESCRIPTOR */
02131 #define SECURITY_DESCRIPTOR_REVISION    1
02132 #define SECURITY_DESCRIPTOR_REVISION1   1
02133 
02134 
02135 #define SE_OWNER_DEFAULTED      0x0001
02136 #define SE_GROUP_DEFAULTED      0x0002
02137 #define SE_DACL_PRESENT         0x0004
02138 #define SE_DACL_DEFAULTED       0x0008
02139 #define SE_SACL_PRESENT         0x0010
02140 #define SE_SACL_DEFAULTED       0x0020
02141 #define SE_SELF_RELATIVE        0x8000
02142 
02143 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
02144 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
02145 
02146 /* The security descriptor structure */
02147 typedef struct {
02148     BYTE Revision;
02149     BYTE Sbz1;
02150     SECURITY_DESCRIPTOR_CONTROL Control;
02151     DWORD Owner;
02152     DWORD Group;
02153     DWORD Sacl;
02154     DWORD Dacl;
02155 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
02156 
02157 typedef struct {
02158     BYTE Revision;
02159     BYTE Sbz1;
02160     SECURITY_DESCRIPTOR_CONTROL Control;
02161     PSID Owner;
02162     PSID Group;
02163     PACL Sacl;
02164     PACL Dacl;
02165 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
02166 
02167 #define SECURITY_DESCRIPTOR_MIN_LENGTH   (sizeof(SECURITY_DESCRIPTOR)) 
02168 
02169 #include "poppack.h"
02170 
02171 #endif /* _SECURITY_DEFINED */
02172 
02173 #include "pshpack1.h"
02174 
02175 /* 
02176  * SID_AND_ATTRIBUTES
02177  */
02178 
02179 typedef struct _SID_AND_ATTRIBUTES {
02180   PSID  Sid; 
02181   DWORD Attributes; 
02182 } SID_AND_ATTRIBUTES ; 
02183  
02184 /* security entities */
02185 #define SECURITY_NULL_RID                       (0x00000000L)
02186 #define SECURITY_WORLD_RID                      (0x00000000L)
02187 #define SECURITY_LOCAL_RID                      (0X00000000L)
02188 
02189 #define SECURITY_NULL_SID_AUTHORITY             {0,0,0,0,0,0}
02190 
02191 /* S-1-1 */
02192 #define SECURITY_WORLD_SID_AUTHORITY            {0,0,0,0,0,1}
02193 
02194 /* S-1-2 */
02195 #define SECURITY_LOCAL_SID_AUTHORITY            {0,0,0,0,0,2}
02196 
02197 /* S-1-3 */
02198 #define SECURITY_CREATOR_SID_AUTHORITY          {0,0,0,0,0,3}
02199 #define SECURITY_CREATOR_OWNER_RID              (0x00000000L) 
02200 #define SECURITY_CREATOR_GROUP_RID              (0x00000001L)
02201 #define SECURITY_CREATOR_OWNER_SERVER_RID       (0x00000002L)
02202 #define SECURITY_CREATOR_GROUP_SERVER_RID       (0x00000003L)
02203 
02204 /* S-1-4 */
02205 #define SECURITY_NON_UNIQUE_AUTHORITY           {0,0,0,0,0,4}
02206 
02207 /* S-1-5 */
02208 #define SECURITY_NT_AUTHORITY                   {0,0,0,0,0,5} 
02209 #define SECURITY_DIALUP_RID                     0x00000001L
02210 #define SECURITY_NETWORK_RID                    0x00000002L
02211 #define SECURITY_BATCH_RID                      0x00000003L
02212 #define SECURITY_INTERACTIVE_RID                0x00000004L
02213 #define SECURITY_LOGON_IDS_RID                  0x00000005L
02214 #define SECURITY_SERVICE_RID                    0x00000006L
02215 #define SECURITY_ANONYMOUS_LOGON_RID            0x00000007L
02216 #define SECURITY_PROXY_RID                      0x00000008L
02217 #define SECURITY_ENTERPRISE_CONTROLLERS_RID     0x00000009L
02218 #define SECURITY_PRINCIPAL_SELF_RID             0x0000000AL
02219 #define SECURITY_AUTHENTICATED_USER_RID         0x0000000BL
02220 #define SECURITY_RESTRICTED_CODE_RID            0x0000000CL
02221 #define SECURITY_TERMINAL_SERVER_RID            0x0000000DL
02222 #define SECURITY_LOCAL_SYSTEM_RID               0x00000012L
02223 #define SECURITY_NT_NON_UNIQUE                  0x00000015L
02224 #define SECURITY_BUILTIN_DOMAIN_RID             0x00000020L
02225 
02226 #define DOMAIN_GROUP_RID_ADMINS                 0x00000200L
02227 #define DOMAIN_GROUP_RID_USERS                  0x00000201L
02228 #define DOMAIN_GROUP_RID_GUESTS                 0x00000202L
02229 
02230 #define DOMAIN_ALIAS_RID_ADMINS                 0x00000220L
02231 #define DOMAIN_ALIAS_RID_USERS                  0x00000221L
02232 #define DOMAIN_ALIAS_RID_GUESTS                 0x00000222L
02233 
02234 #define SECURITY_SERVER_LOGON_RID               SECURITY_ENTERPRISE_CONTROLLERS_RID
02235 
02236 #define SECURITY_LOGON_IDS_RID_COUNT            (3L)
02237 
02238 /*
02239  * TOKEN_USER
02240  */
02241 
02242 typedef struct _TOKEN_USER {
02243   SID_AND_ATTRIBUTES User; 
02244 } TOKEN_USER; 
02245 
02246 /*
02247  * TOKEN_GROUPS
02248  */
02249 
02250 typedef struct _TOKEN_GROUPS  {
02251   DWORD GroupCount; 
02252   SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; 
02253 } TOKEN_GROUPS; 
02254 
02255 /*
02256  * LUID_AND_ATTRIBUTES
02257  */
02258 
02259 typedef union _LARGE_INTEGER {
02260     struct {
02261         DWORD    LowPart;
02262         LONG     HighPart;
02263     } DUMMYSTRUCTNAME;
02264     LONGLONG QuadPart;
02265 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
02266 
02267 typedef union _ULARGE_INTEGER {
02268     struct {
02269         DWORD    LowPart;
02270         LONG     HighPart;
02271     } DUMMYSTRUCTNAME;
02272     LONGLONG QuadPart;
02273 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
02274 
02275 /*
02276  * Locally Unique Identifier
02277  */
02278 
02279 typedef LARGE_INTEGER LUID,*PLUID;
02280 
02281 typedef struct _LUID_AND_ATTRIBUTES {
02282   LUID   Luid; 
02283   DWORD  Attributes; 
02284 } LUID_AND_ATTRIBUTES; 
02285 
02286 /*
02287  * PRIVILEGE_SET
02288  */
02289 
02290 typedef struct _PRIVILEGE_SET {
02291     DWORD PrivilegeCount;
02292     DWORD Control;
02293     LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
02294 } PRIVILEGE_SET, *PPRIVILEGE_SET;
02295 
02296 /*
02297  * TOKEN_PRIVILEGES
02298  */
02299 
02300 typedef struct _TOKEN_PRIVILEGES {
02301   DWORD PrivilegeCount; 
02302   LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; 
02303 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES; 
02304 
02305 /*
02306  * TOKEN_OWNER
02307  */
02308 
02309 typedef struct _TOKEN_OWNER {
02310   PSID Owner; 
02311 } TOKEN_OWNER; 
02312 
02313 /*
02314  * TOKEN_PRIMARY_GROUP
02315  */
02316 
02317 typedef struct _TOKEN_PRIMARY_GROUP {
02318   PSID PrimaryGroup; 
02319 } TOKEN_PRIMARY_GROUP; 
02320 
02321 
02322 /*
02323  * TOKEN_DEFAULT_DACL
02324  */
02325 
02326 typedef struct _TOKEN_DEFAULT_DACL { 
02327   PACL DefaultDacl; 
02328 } TOKEN_DEFAULT_DACL; 
02329 
02330 /*
02331  * TOKEN_SOURCEL
02332  */
02333 
02334 typedef struct _TOKEN_SOURCE {
02335   char Sourcename[8]; 
02336   LUID SourceIdentifier; 
02337 } TOKEN_SOURCE; 
02338 
02339 /*
02340  * TOKEN_TYPE
02341  */
02342 
02343 typedef enum tagTOKEN_TYPE {
02344   TokenPrimary = 1, 
02345   TokenImpersonation 
02346 } TOKEN_TYPE; 
02347 
02348 /*
02349  * SECURITY_IMPERSONATION_LEVEL
02350  */
02351 
02352 typedef enum _SECURITY_IMPERSONATION_LEVEL {
02353   SecurityAnonymous, 
02354   SecurityIdentification, 
02355   SecurityImpersonation, 
02356   SecurityDelegation 
02357 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL; 
02358 
02359 
02360 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
02361         * PSECURITY_CONTEXT_TRACKING_MODE;
02362 /*
02363  *      Quality of Service
02364  */
02365 
02366 typedef struct _SECURITY_QUALITY_OF_SERVICE {
02367   DWORD                         Length;
02368   SECURITY_IMPERSONATION_LEVEL  ImpersonationLevel;
02369   SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
02370   WIN_BOOL                              EffectiveOnly;
02371 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
02372 
02373 /*
02374  * TOKEN_STATISTICS
02375  */
02376 
02377 typedef struct _TOKEN_STATISTICS {
02378   LUID  TokenId; 
02379   LUID  AuthenticationId; 
02380   LARGE_INTEGER ExpirationTime; 
02381   TOKEN_TYPE    TokenType; 
02382   SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 
02383   DWORD DynamicCharged; 
02384   DWORD DynamicAvailable; 
02385   DWORD GroupCount; 
02386   DWORD PrivilegeCount; 
02387   LUID  ModifiedId; 
02388 } TOKEN_STATISTICS; 
02389 
02390 /* 
02391  *      ACLs of NT 
02392  */
02393 
02394 #define ACL_REVISION    2
02395 
02396 #define ACL_REVISION1   1
02397 #define ACL_REVISION2   2
02398 
02399 /* ACEs, directly starting after an ACL */
02400 typedef struct _ACE_HEADER {
02401         BYTE    AceType;
02402         BYTE    AceFlags;
02403         WORD    AceSize;
02404 } ACE_HEADER,*PACE_HEADER;
02405 
02406 /* AceType */
02407 #define ACCESS_ALLOWED_ACE_TYPE         0
02408 #define ACCESS_DENIED_ACE_TYPE          1
02409 #define SYSTEM_AUDIT_ACE_TYPE           2
02410 #define SYSTEM_ALARM_ACE_TYPE           3
02411 
02412 /* inherit AceFlags */
02413 #define OBJECT_INHERIT_ACE              0x01
02414 #define CONTAINER_INHERIT_ACE           0x02
02415 #define NO_PROPAGATE_INHERIT_ACE        0x04
02416 #define INHERIT_ONLY_ACE                0x08
02417 #define VALID_INHERIT_FLAGS             0x0F
02418 
02419 /* AceFlags mask for what events we (should) audit */
02420 #define SUCCESSFUL_ACCESS_ACE_FLAG      0x40
02421 #define FAILED_ACCESS_ACE_FLAG          0x80
02422 
02423 /* different ACEs depending on AceType 
02424  * SidStart marks the begin of a SID
02425  * so the thing finally looks like this:
02426  * 0: ACE_HEADER
02427  * 4: ACCESS_MASK
02428  * 8... : SID
02429  */
02430 typedef struct _ACCESS_ALLOWED_ACE {
02431         ACE_HEADER      Header;
02432         DWORD           Mask;
02433         DWORD           SidStart;
02434 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
02435 
02436 typedef struct _ACCESS_DENIED_ACE {
02437         ACE_HEADER      Header;
02438         DWORD           Mask;
02439         DWORD           SidStart;
02440 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
02441 
02442 typedef struct _SYSTEM_AUDIT_ACE {
02443         ACE_HEADER      Header;
02444         DWORD           Mask;
02445         DWORD           SidStart;
02446 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
02447 
02448 typedef struct _SYSTEM_ALARM_ACE {
02449         ACE_HEADER      Header;
02450         DWORD           Mask;
02451         DWORD           SidStart;
02452 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
02453 
02454 typedef enum tagSID_NAME_USE {
02455         SidTypeUser = 1,
02456         SidTypeGroup,
02457         SidTypeDomain,
02458         SidTypeAlias,
02459         SidTypeWellKnownGroup,
02460         SidTypeDeletedAccount,
02461         SidTypeInvalid,
02462         SidTypeUnknown
02463 } SID_NAME_USE,*PSID_NAME_USE;
02464 
02465 /* Access rights */
02466 
02467 #define DELETE                     0x00010000
02468 #define READ_CONTROL               0x00020000
02469 #define WRITE_DAC                  0x00040000
02470 #define WRITE_OWNER                0x00080000
02471 #define SYNCHRONIZE                0x00100000
02472 #define STANDARD_RIGHTS_REQUIRED   0x000f0000
02473 
02474 #define STANDARD_RIGHTS_READ       READ_CONTROL
02475 #define STANDARD_RIGHTS_WRITE      READ_CONTROL
02476 #define STANDARD_RIGHTS_EXECUTE    READ_CONTROL
02477 
02478 #define STANDARD_RIGHTS_ALL        0x001f0000
02479 
02480 #define SPECIFIC_RIGHTS_ALL        0x0000ffff
02481 
02482 #define GENERIC_READ               0x80000000
02483 #define GENERIC_WRITE              0x40000000
02484 #define GENERIC_EXECUTE            0x20000000
02485 #define GENERIC_ALL                0x10000000
02486 
02487 #define MAXIMUM_ALLOWED            0x02000000
02488 #define ACCESS_SYSTEM_SECURITY     0x01000000
02489 
02490 #define EVENT_MODIFY_STATE         0x0002
02491 #define EVENT_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
02492 
02493 #define SEMAPHORE_MODIFY_STATE     0x0002
02494 #define SEMAPHORE_ALL_ACCESS       (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
02495 
02496 #define MUTEX_MODIFY_STATE         0x0001
02497 #define MUTEX_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
02498 
02499 #define PROCESS_TERMINATE          0x0001
02500 #define PROCESS_CREATE_THREAD      0x0002
02501 #define PROCESS_VM_OPERATION       0x0008
02502 #define PROCESS_VM_READ            0x0010
02503 #define PROCESS_VM_WRITE           0x0020
02504 #define PROCESS_DUP_HANDLE         0x0040
02505 #define PROCESS_CREATE_PROCESS     0x0080
02506 #define PROCESS_SET_QUOTA          0x0100
02507 #define PROCESS_SET_INFORMATION    0x0200
02508 #define PROCESS_QUERY_INFORMATION  0x0400
02509 #define PROCESS_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
02510 
02511 #define THREAD_TERMINATE           0x0001
02512 #define THREAD_SUSPEND_RESUME      0x0002
02513 #define THREAD_GET_CONTEXT         0x0008
02514 #define THREAD_SET_CONTEXT         0x0010
02515 #define THREAD_SET_INFORMATION     0x0020
02516 #define THREAD_QUERY_INFORMATION   0x0040
02517 #define THREAD_SET_THREAD_TOKEN    0x0080
02518 #define THREAD_IMPERSONATE         0x0100
02519 #define THREAD_DIRECT_IMPERSONATION 0x0200
02520 #define THREAD_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
02521 
02522 #define THREAD_BASE_PRIORITY_LOWRT  15 
02523 #define THREAD_BASE_PRIORITY_MAX    2 
02524 #define THREAD_BASE_PRIORITY_MIN   -2
02525 #define THREAD_BASE_PRIORITY_IDLE  -15
02526 
02527 #define FILE_READ_DATA            0x0001    /* file & pipe */
02528 #define FILE_LIST_DIRECTORY       0x0001    /* directory */
02529 #define FILE_WRITE_DATA           0x0002    /* file & pipe */
02530 #define FILE_ADD_FILE             0x0002    /* directory */
02531 #define FILE_APPEND_DATA          0x0004    /* file */
02532 #define FILE_ADD_SUBDIRECTORY     0x0004    /* directory */
02533 #define FILE_CREATE_PIPE_INSTANCE 0x0004    /* named pipe */
02534 #define FILE_READ_EA              0x0008    /* file & directory */
02535 #define FILE_READ_PROPERTIES      FILE_READ_EA
02536 #define FILE_WRITE_EA             0x0010    /* file & directory */
02537 #define FILE_WRITE_PROPERTIES     FILE_WRITE_EA
02538 #define FILE_EXECUTE              0x0020    /* file */
02539 #define FILE_TRAVERSE             0x0020    /* directory */
02540 #define FILE_DELETE_CHILD         0x0040    /* directory */
02541 #define FILE_READ_ATTRIBUTES      0x0080    /* all */
02542 #define FILE_WRITE_ATTRIBUTES     0x0100    /* all */
02543 #define FILE_ALL_ACCESS           (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
02544 
02545 #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
02546                                    FILE_READ_ATTRIBUTES | FILE_READ_EA | \
02547                                    SYNCHRONIZE)
02548 #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
02549                                    FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
02550                                    FILE_APPEND_DATA | SYNCHRONIZE)
02551 #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
02552                                    FILE_READ_ATTRIBUTES | SYNCHRONIZE)
02553 
02554 
02555 /* File attribute flags
02556  */
02557 #define FILE_SHARE_READ                 0x00000001L
02558 #define FILE_SHARE_WRITE                0x00000002L
02559 #define FILE_SHARE_DELETE               0x00000004L
02560 #define FILE_ATTRIBUTE_READONLY         0x00000001L
02561 #define FILE_ATTRIBUTE_HIDDEN           0x00000002L
02562 #define FILE_ATTRIBUTE_SYSTEM           0x00000004L
02563 #define FILE_ATTRIBUTE_LABEL            0x00000008L  /* Not in Windows API */
02564 #define FILE_ATTRIBUTE_DIRECTORY        0x00000010L
02565 #define FILE_ATTRIBUTE_ARCHIVE          0x00000020L
02566 #define FILE_ATTRIBUTE_NORMAL           0x00000080L
02567 #define FILE_ATTRIBUTE_TEMPORARY        0x00000100L
02568 #define FILE_ATTRIBUTE_ATOMIC_WRITE     0x00000200L
02569 #define FILE_ATTRIBUTE_XACTION_WRITE    0x00000400L
02570 #define FILE_ATTRIBUTE_COMPRESSED       0x00000800L
02571 #define FILE_ATTRIBUTE_OFFLINE          0x00001000L
02572 
02573 /* File alignments (NT) */
02574 #define FILE_BYTE_ALIGNMENT             0x00000000
02575 #define FILE_WORD_ALIGNMENT             0x00000001
02576 #define FILE_LONG_ALIGNMENT             0x00000003
02577 #define FILE_QUAD_ALIGNMENT             0x00000007
02578 #define FILE_OCTA_ALIGNMENT             0x0000000f
02579 #define FILE_32_BYTE_ALIGNMENT          0x0000001f
02580 #define FILE_64_BYTE_ALIGNMENT          0x0000003f
02581 #define FILE_128_BYTE_ALIGNMENT         0x0000007f
02582 #define FILE_256_BYTE_ALIGNMENT         0x000000ff
02583 #define FILE_512_BYTE_ALIGNMENT         0x000001ff
02584 
02585 #define REG_NONE                0       /* no type */
02586 #define REG_SZ                  1       /* string type (ASCII) */
02587 #define REG_EXPAND_SZ           2       /* string, includes %ENVVAR% (expanded by caller) (ASCII) */
02588 #define REG_BINARY              3       /* binary format, callerspecific */
02589 /* YES, REG_DWORD == REG_DWORD_LITTLE_ENDIAN */
02590 #define REG_DWORD               4       /* DWORD in little endian format */
02591 #define REG_DWORD_LITTLE_ENDIAN 4       /* DWORD in little endian format */
02592 #define REG_DWORD_BIG_ENDIAN    5       /* DWORD in big endian format  */
02593 #define REG_LINK                6       /* symbolic link (UNICODE) */
02594 #define REG_MULTI_SZ            7       /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
02595 #define REG_RESOURCE_LIST       8       /* resource list? huh? */
02596 #define REG_FULL_RESOURCE_DESCRIPTOR    9       /* full resource descriptor? huh? */
02597 #define REG_RESOURCE_REQUIREMENTS_LIST  10
02598 
02599 /* ----------------------------- begin registry ----------------------------- */
02600 
02601 /* Registry security values */
02602 #define OWNER_SECURITY_INFORMATION      0x00000001
02603 #define GROUP_SECURITY_INFORMATION      0x00000002
02604 #define DACL_SECURITY_INFORMATION       0x00000004
02605 #define SACL_SECURITY_INFORMATION       0x00000008
02606 
02607 #define REG_OPTION_RESERVED             0x00000000
02608 #define REG_OPTION_NON_VOLATILE         0x00000000
02609 #define REG_OPTION_VOLATILE             0x00000001
02610 #define REG_OPTION_CREATE_LINK          0x00000002
02611 #define REG_OPTION_BACKUP_RESTORE       0x00000004 /* FIXME */
02612 #define REG_OPTION_OPEN_LINK            0x00000008
02613 #define REG_LEGAL_OPTION               (REG_OPTION_RESERVED|  \
02614                                         REG_OPTION_NON_VOLATILE|  \
02615                                         REG_OPTION_VOLATILE|  \
02616                                         REG_OPTION_CREATE_LINK|  \
02617                                         REG_OPTION_BACKUP_RESTORE|  \
02618                                         REG_OPTION_OPEN_LINK)
02619 
02620 
02621 #define REG_CREATED_NEW_KEY     0x00000001
02622 #define REG_OPENED_EXISTING_KEY 0x00000002
02623 
02624 /* For RegNotifyChangeKeyValue */
02625 #define REG_NOTIFY_CHANGE_NAME  0x1
02626 
02627 #define KEY_QUERY_VALUE         0x00000001
02628 #define KEY_SET_VALUE           0x00000002
02629 #define KEY_CREATE_SUB_KEY      0x00000004
02630 #define KEY_ENUMERATE_SUB_KEYS  0x00000008
02631 #define KEY_NOTIFY              0x00000010
02632 #define KEY_CREATE_LINK         0x00000020
02633 
02634 #define KEY_READ              ((STANDARD_RIGHTS_READ|  \
02635                                 KEY_QUERY_VALUE|  \
02636                                 KEY_ENUMERATE_SUB_KEYS|  \
02637                                 KEY_NOTIFY)  \
02638                                 & (~SYNCHRONIZE)  \
02639                               )
02640 #define KEY_WRITE             ((STANDARD_RIGHTS_WRITE|  \
02641                                 KEY_SET_VALUE|  \
02642                                 KEY_CREATE_SUB_KEY)  \
02643                                 & (~SYNCHRONIZE)  \
02644                               )
02645 #define KEY_EXECUTE           ((KEY_READ)  \
02646                                 & (~SYNCHRONIZE))  \
02647                               )
02648 #define KEY_ALL_ACCESS        ((STANDARD_RIGHTS_ALL|  \
02649                                 KEY_QUERY_VALUE|  \
02650                                 KEY_SET_VALUE|  \
02651                                 KEY_CREATE_SUB_KEY|  \
02652                                 KEY_ENUMERATE_SUB_KEYS|  \
02653                                 KEY_NOTIFY|  \
02654                                 KEY_CREATE_LINK)  \
02655                                 & (~SYNCHRONIZE)  \
02656                               )
02657 /* ------------------------------ end registry ------------------------------ */
02658 
02659 
02660 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
02661 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
02662 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
02663 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
02664 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
02665 
02666 #include "poppack.h"
02667 
02668 #endif  /* __WINE_WINNT_H */

Generated on Tue Dec 20 10:14:23 2005 for vlc-0.8.4a by  doxygen 1.4.2