xref: /reactos/dll/win32/dbghelp/compat.h (revision 465745b6)
1 #pragma once
2 
3 #include <typedefs.h>
4 #include <guiddef.h>
5 #include <pecoff.h>
6 #include <wine/unicode.h>
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <wchar.h>
11 #include <ctype.h>
12 
13 typedef HANDLE HWND;
14 
15 #define min(x, y) (((x) < (y)) ? (x) : (y))
16 #define max(x, y) (((x) > (y)) ? (x) : (y))
17 
18 #ifdef __i386__
19 #define CDECL __cdecl
20 #else
21 #define CDECL
22 #endif
23 typedef PVOID IUnknown, IDispatch, IRecordInfo;
24 
25 // windef.h
26 #define MAX_PATH 260
27 #define CALLBACK
28 typedef int (*FARPROC)();
29 
30 // bytesex.h
31 #define SWAPD(x) x
32 #define SWAPW(x) x
33 
34 // Wine stuff
35 #define DECLSPEC_HIDDEN
36 #define WINE_DEFAULT_DEBUG_CHANNEL(x)
37 #define WINE_DECLARE_DEBUG_CHANNEL(x)
38 extern const char *wine_dbgstr_an( const char * s, int n );
39 extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
40 extern const char *wine_dbg_sprintf( const char *format, ... );
41 static __inline const char *wine_dbgstr_longlong( ULONGLONG ll )
42 {
43     if (/*sizeof(ll) > sizeof(unsigned long) &&*/ ll >> 32) /* ULONGLONG is always > long in ReactOS */
44         return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
45     else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
46 }
47 static __inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
48 static __inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
49 static __inline const char *debugstr_a( const char *s )  { return wine_dbgstr_an( s, -1 ); }
50 static __inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
51 static __inline const char *wine_dbgstr_w( const WCHAR *s ){return wine_dbgstr_wn( s, -1 );}
52 
53 #if 0
54 #define WARN(fmt, ...) fprintf(stderr, "WARN %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
55 #define FIXME(fmt, ...) fprintf(stderr, "FIXME %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
56 #define TRACE(fmt, ...) fprintf(stderr, "TRACE %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
57 #define ERR(fmt, ...) fprintf(stderr, "ERR %s: " fmt, __FUNCTION__, ##__VA_ARGS__)
58 #else
59 #define WARN(fmt, ...)
60 #define FIXME(fmt, ...)
61 #define TRACE(fmt, ...)
62 #define ERR(fmt, ...)
63 #endif
64 
65 #define TRACE_ON(x) FALSE
66 #define TRACE_(x) TRACE
67 #define FIXME_(x) FIXME
68 const char *wine_dbg_sprintf( const char *format, ... );
69 #define CP_UNIXCP CP_ACP
70 #define __TRY if(1)
71 #define __EXCEPT_PAGE_FAULT else
72 #define __ENDTRY
73 
74 // basetsd.h
75 typedef ULONG_PTR KAFFINITY;
76 
77 // excpt.h
78 typedef enum _EXCEPTION_DISPOSITION
79 {
80     ExceptionContinueExecution,
81     ExceptionContinueSearch,
82     ExceptionNestedException,
83     ExceptionCollidedUnwind,
84 } EXCEPTION_DISPOSITION;
85 
86 // winerror.h
87 #define ERROR_ACCESS_DENIED                                5
88 #define ERROR_INVALID_HANDLE                               6
89 #define ERROR_OUTOFMEMORY                                  14
90 #define ERROR_NOT_SUPPORTED                                50
91 #define ERROR_INVALID_PARAMETER                            87
92 #define ERROR_CALL_NOT_IMPLEMENTED                         120
93 #define ERROR_INVALID_NAME                                 123
94 #define ERROR_MOD_NOT_FOUND                                126
95 #define ERROR_NO_MORE_ITEMS                                259
96 #define ERROR_INVALID_ADDRESS                              487
97 
98 // winnls.h
99 #define CP_ACP 0
100 #define MultiByteToWideChar __MultiByteToWideChar
101 #define WideCharToMultiByte __WideCharToMultiByte
102 INT __MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen, LPWSTR dst, INT dstlen );
103 INT __WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen, LPSTR dst, INT dstlen, LPCSTR defchar, BOOL *used );
104 
105 // #define strlenW(s) wcslen((s))
106 // #define strcpyW(d,s) wcscpy((d),(s))
107 // #define strchrW(s,c) wcschr((s),(c))
108 // #define strcatW(d,s) wcscat((d),(s))
109 // #define strncmpiW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
110 // #define strcmpW(s1,s2) wcscmp((s1),(s2))
111 // #define strcmpiW(s1,s2) _wcsicmp((s1),(s2))
112 // #define tolowerW(n) towlower((n))
113 // #define toupperW(n) towupper((n))
114 
115 // winnt.h
116 #define IMAGE_FILE_MACHINE_ARMNT      0x1c4
117 #define IMAGE_FILE_MACHINE_POWERPC    0x1f0
118 #define IMAGE_FILE_MACHINE_ARM64      0xaa64
119 #define DLL_PROCESS_DETACH	0
120 #define DLL_PROCESS_ATTACH	1
121 #define DLL_THREAD_ATTACH	2
122 #define DLL_THREAD_DETACH	3
123 #define HEAP_ZERO_MEMORY 8
124 #define GENERIC_READ	0x80000000
125 #define FILE_SHARE_READ			0x00000001
126 #define FILE_ATTRIBUTE_NORMAL			0x00000080
127 #define PAGE_READONLY	0x0002
128 #define SECTION_MAP_READ 4
129 #define IMAGE_DEBUG_TYPE_UNKNOWN 0
130 #define IMAGE_DEBUG_TYPE_COFF 1
131 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
132 #define IMAGE_DEBUG_TYPE_FPO 3
133 #define IMAGE_DEBUG_TYPE_MISC 4
134 #define IMAGE_DEBUG_TYPE_EXCEPTION 5
135 #define IMAGE_DEBUG_TYPE_FIXUP 6
136 #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
137 #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
138 #define IMAGE_SYM_CLASS_EXTERNAL 2
139 #define IMAGE_SYM_CLASS_FILE 103
140 #define IMAGE_DIRECTORY_ENTRY_EXPORT	0
141 #define IMAGE_DIRECTORY_ENTRY_DEBUG	6
142 #define IMAGE_DEBUG_MISC_EXENAME 1
143 #define IMAGE_SEPARATE_DEBUG_SIGNATURE 0x4944
144 typedef struct _IMAGE_EXPORT_DIRECTORY {
145   DWORD Characteristics;
146   DWORD TimeDateStamp;
147   WORD MajorVersion;
148   WORD MinorVersion;
149   DWORD Name;
150   DWORD Base;
151   DWORD NumberOfFunctions;
152   DWORD NumberOfNames;
153   DWORD AddressOfFunctions;
154   DWORD AddressOfNames;
155   DWORD AddressOfNameOrdinals;
156 } IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
157 typedef struct _IMAGE_DEBUG_MISC {
158   DWORD DataType;
159   DWORD Length;
160   BOOLEAN Unicode;
161   BYTE Reserved[3];
162   BYTE Data[1];
163 } IMAGE_DEBUG_MISC, *PIMAGE_DEBUG_MISC;
164 typedef struct _IMAGE_SEPARATE_DEBUG_HEADER {
165   WORD Signature;
166   WORD Flags;
167   WORD Machine;
168   WORD Characteristics;
169   DWORD TimeDateStamp;
170   DWORD CheckSum;
171   DWORD ImageBase;
172   DWORD SizeOfImage;
173   DWORD NumberOfSections;
174   DWORD ExportedNamesSize;
175   DWORD DebugDirectorySize;
176   DWORD SectionAlignment;
177   DWORD Reserved[2];
178 } IMAGE_SEPARATE_DEBUG_HEADER, *PIMAGE_SEPARATE_DEBUG_HEADER;
179 typedef struct _SECURITY_ATTRIBUTES {
180 	DWORD nLength;
181 	LPVOID lpSecurityDescriptor;
182 	BOOL bInheritHandle;
183 } SECURITY_ATTRIBUTES,*PSECURITY_ATTRIBUTES,*LPSECURITY_ATTRIBUTES;
184 typedef struct _IMAGE_DEBUG_DIRECTORY {
185   DWORD Characteristics;
186   DWORD TimeDateStamp;
187   WORD MajorVersion;
188   WORD MinorVersion;
189   DWORD Type;
190   DWORD SizeOfData;
191   DWORD AddressOfRawData;
192   DWORD PointerToRawData;
193 } IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
194 #define EXCEPTION_MAXIMUM_PARAMETERS   15
195 typedef struct _EXCEPTION_RECORD {
196   DWORD ExceptionCode;
197   DWORD ExceptionFlags;
198   struct _EXCEPTION_RECORD *ExceptionRecord;
199   PVOID ExceptionAddress;
200   DWORD NumberParameters;
201   ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
202 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
203 #if defined(TARGET_i386)
204 #define SIZE_OF_80387_REGISTERS	80
205 #define CONTEXT_i386	0x10000
206 #define CONTEXT_i486	0x10000
207 #define CONTEXT_CONTROL	(CONTEXT_i386|0x00000001L)
208 #define CONTEXT_INTEGER	(CONTEXT_i386|0x00000002L)
209 #define CONTEXT_SEGMENTS	(CONTEXT_i386|0x00000004L)
210 #define CONTEXT_FLOATING_POINT	(CONTEXT_i386|0x00000008L)
211 #define CONTEXT_DEBUG_REGISTERS	(CONTEXT_i386|0x00000010L)
212 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
213 #define CONTEXT_FULL	(CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
214 #define MAXIMUM_SUPPORTED_EXTENSION  512
215 
216 #define EXCEPTION_READ_FAULT    0
217 #define EXCEPTION_WRITE_FAULT   1
218 #define EXCEPTION_EXECUTE_FAULT 8
219 
220 typedef struct _FLOATING_SAVE_AREA {
221   DWORD ControlWord;
222   DWORD StatusWord;
223   DWORD TagWord;
224   DWORD ErrorOffset;
225   DWORD ErrorSelector;
226   DWORD DataOffset;
227   DWORD DataSelector;
228   BYTE RegisterArea[80];
229   DWORD Cr0NpxState;
230 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
231 
232 typedef struct _CONTEXT {
233   DWORD ContextFlags;
234   DWORD Dr0;
235   DWORD Dr1;
236   DWORD Dr2;
237   DWORD Dr3;
238   DWORD Dr6;
239   DWORD Dr7;
240   FLOATING_SAVE_AREA FloatSave;
241   DWORD SegGs;
242   DWORD SegFs;
243   DWORD SegEs;
244   DWORD SegDs;
245   DWORD Edi;
246   DWORD Esi;
247   DWORD Ebx;
248   DWORD Edx;
249   DWORD Ecx;
250   DWORD Eax;
251   DWORD Ebp;
252   DWORD Eip;
253   DWORD SegCs;
254   DWORD EFlags;
255   DWORD Esp;
256   DWORD SegSs;
257   BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
258 } CONTEXT, *PCONTEXT;
259 
260 #elif defined TARGET_amd64
261 
262 #error "Please define the CONTEXT structure for amd64 platform"
263 
264 #elif defined TARGET_arm /* ARM? */
265 
266 /* The following flags control the contents of the CONTEXT structure. */
267 
268 #define CONTEXT_ARM    0x0200000
269 #define CONTEXT_CONTROL         (CONTEXT_ARM | 0x00000001)
270 #define CONTEXT_INTEGER         (CONTEXT_ARM | 0x00000002)
271 #define CONTEXT_FLOATING_POINT  (CONTEXT_ARM | 0x00000004)
272 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008)
273 
274 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
275 
276 #define EXCEPTION_READ_FAULT    0
277 #define EXCEPTION_WRITE_FAULT   1
278 #define EXCEPTION_EXECUTE_FAULT 8
279 
280 typedef struct _RUNTIME_FUNCTION
281 {
282     DWORD BeginAddress;
283     union {
284         DWORD UnwindData;
285         struct {
286             DWORD Flag : 2;
287             DWORD FunctionLength : 11;
288             DWORD Ret : 2;
289             DWORD H : 1;
290             DWORD Reg : 3;
291             DWORD R : 1;
292             DWORD L : 1;
293             DWORD C : 1;
294             DWORD StackAdjust : 10;
295         } DUMMYSTRUCTNAME;
296     } DUMMYUNIONNAME;
297 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
298 
299 #define UNWIND_HISTORY_TABLE_SIZE 12
300 typedef struct _UNWIND_HISTORY_TABLE_ENTRY
301 {
302     DWORD ImageBase;
303     PRUNTIME_FUNCTION FunctionEntry;
304 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
305 
306 typedef struct _UNWIND_HISTORY_TABLE
307 {
308     DWORD Count;
309     BYTE  LocalHint;
310     BYTE  GlobalHint;
311     BYTE  Search;
312     BYTE  Once;
313     DWORD LowAddress;
314     DWORD HighAddress;
315     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
316 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
317 
318 typedef struct _CONTEXT {
319         /* The flags values within this flag control the contents of
320            a CONTEXT record.
321 
322            If the context record is used as an input parameter, then
323            for each portion of the context record controlled by a flag
324            whose value is set, it is assumed that that portion of the
325            context record contains valid context. If the context record
326            is being used to modify a thread's context, then only that
327            portion of the threads context will be modified.
328 
329            If the context record is used as an IN OUT parameter to capture
330            the context of a thread, then only those portions of the thread's
331            context corresponding to set flags will be returned.
332 
333            The context record is never used as an OUT only parameter. */
334 
335         ULONG ContextFlags;
336 
337         /* This section is specified/returned if the ContextFlags word contains
338            the flag CONTEXT_INTEGER. */
339         ULONG R0;
340         ULONG R1;
341         ULONG R2;
342         ULONG R3;
343         ULONG R4;
344         ULONG R5;
345         ULONG R6;
346         ULONG R7;
347         ULONG R8;
348         ULONG R9;
349         ULONG R10;
350         ULONG Fp;
351         ULONG Ip;
352 
353         /* These are selected by CONTEXT_CONTROL */
354         ULONG Sp;
355         ULONG Lr;
356         ULONG Pc;
357         ULONG Cpsr;
358 } CONTEXT;
359 
360 BOOLEAN CDECL            RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD);
361 BOOLEAN CDECL            RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
362 PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,DWORD*,UNWIND_HISTORY_TABLE*);
363 #else
364 
365 #error "Unknown target platform"
366 
367 #endif
368 
369 typedef
370 EXCEPTION_DISPOSITION
371 NTAPI
372 EXCEPTION_ROUTINE(
373   struct _EXCEPTION_RECORD *ExceptionRecord,
374   PVOID EstablisherFrame,
375   struct _CONTEXT *ContextRecord,
376   PVOID DispatcherContext);
377 typedef EXCEPTION_ROUTINE *PEXCEPTION_ROUTINE;
378 typedef struct _NT_TIB {
379   struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
380   PVOID StackBase;
381   PVOID StackLimit;
382   PVOID SubSystemTib;
383   union {
384     PVOID FiberData;
385     DWORD Version;
386   } DUMMYUNIONNAME;
387   PVOID ArbitraryUserPointer;
388   struct _NT_TIB *Self;
389 } NT_TIB,*PNT_TIB;
390 
391 // rtltypes.h
392 typedef struct _EXCEPTION_REGISTRATION_RECORD
393 {
394     struct _EXCEPTION_REGISTRATION_RECORD *Next;
395     PEXCEPTION_ROUTINE Handler;
396 } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
397 
398 // winbase.h
399 #define INVALID_HANDLE_VALUE (HANDLE)(-1)
400 #define HeapAlloc __HeapAlloc
401 #define HeapReAlloc __HeapReAlloc
402 #define HeapFree(x,y,z) free(z)
403 #define GetProcessHeap() 1
404 #define GetProcessId(x) 8
405 #define lstrcpynW __lstrcpynW
406 #define CloseHandle __CloseHandle
407 #define CreateFileA(a,b,c,d,e,f,g) fopen(a, "rb")
408 #define CreateFileW __CreateFileW
409 #define CreateFileMappingW(a,b,c,d,e,f) a
410 #define MapViewOfFile __MapViewOfFile
411 #define UnmapViewOfFile __UnmapViewOfFile
412 #define LoadLibraryW(x) 0
413 #define FreeLibrary(x) 0
414 #define lstrcpyW strcpyW // Forward this to wine unicode inline function
415 #define lstrlenW strlenW // ditto
416 #define lstrcpynA __lstrcpynA
417 #define SetLastError(x)
418 #define GetProcAddress(x,y) 0
419 #define GetEnvironmentVariableA(x, y, z) 0
420 #define GetEnvironmentVariableW(x, y, z) 0
421 #define GetCurrentDirectoryW(x, y) 0
422 #define GetFileSizeEx __GetFileSizeEx
423 #define ReadProcessMemory(a,b,c,d,e) 0
424 
425 void* __HeapAlloc(int heap, int flags, size_t size);
426 void* __HeapReAlloc(int heap, DWORD d2, void *slab, SIZE_T newsize);
427 WCHAR* __lstrcpynW(WCHAR* lpString1, const WCHAR* lpString2, int iMaxLength);
428 BOOL __CloseHandle(HANDLE handle);
429 HANDLE __CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
430 void* __MapViewOfFile(HANDLE file,DWORD d1,DWORD d2,DWORD d3,SIZE_T s);
431 BOOL __UnmapViewOfFile(const void*);
432 LPSTR __lstrcpynA(LPSTR,LPCSTR,int);
433 BOOL __GetFileSizeEx(HANDLE,PLARGE_INTEGER);
434 #define OPEN_EXISTING	3
435 #define FILE_MAP_READ SECTION_MAP_READ
436 typedef struct _LDT_ENTRY {
437 	WORD LimitLow;
438 	WORD BaseLow;
439 	union {
440 		struct {
441 			BYTE BaseMid;
442 			BYTE Flags1;
443 			BYTE Flags2;
444 			BYTE BaseHi;
445 		} Bytes;
446 		struct {
447 			DWORD BaseMid:8;
448 			DWORD Type:5;
449 			DWORD Dpl:2;
450 			DWORD Pres:1;
451 			DWORD LimitHi:4;
452 			DWORD Sys:1;
453 			DWORD Reserved_0:1;
454 			DWORD Default_Big:1;
455 			DWORD Granularity:1;
456 			DWORD BaseHi:8;
457 		} Bits;
458 	} HighWord;
459 } LDT_ENTRY,*PLDT_ENTRY,*LPLDT_ENTRY;
460 
461 // umtypes.h
462 typedef LONG KPRIORITY;
463 
464 // winternl.h
465 #define RtlImageNtHeader __RtlImageNtHeader
466 #define RtlImageRvaToVa __RtlImageRvaToVa
467 #define RtlImageRvaToSection __RtlImageRvaToSection
468 #define RtlImageDirectoryEntryToData __RtlImageDirectoryEntryToData
469 
470 #ifdef _MSC_VER
471 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
472 #else
473 #define RtlUlongByteSwap(_x) __builtin_bswap32((_x))
474 #endif
475 
476 PIMAGE_NT_HEADERS __RtlImageNtHeader(void *data);
477 PVOID __RtlImageRvaToVa (const IMAGE_NT_HEADERS* NtHeader, PVOID BaseAddress, ULONG Rva, PIMAGE_SECTION_HEADER *SectionHeader);
478 PVOID __RtlImageDirectoryEntryToData(PVOID BaseAddress, BOOLEAN MappedAsImage, USHORT Directory, PULONG Size);
479 
480 typedef struct _CLIENT_ID
481 {
482    HANDLE UniqueProcess;
483    HANDLE UniqueThread;
484 } CLIENT_ID, *PCLIENT_ID;
485 #define GDI_BATCH_BUFFER_SIZE 0x136
486 typedef struct _GDI_TEB_BATCH
487 {
488     ULONG Offset;
489     HANDLE HDC;
490     ULONG Buffer[GDI_BATCH_BUFFER_SIZE];
491 } GDI_TEB_BATCH, *PGDI_TEB_BATCH;
492 typedef struct _TEB
493 {
494     NT_TIB          Tib;                        /* 000 */
495     PVOID           EnvironmentPointer;         /* 01c */
496     CLIENT_ID       ClientId;                   /* 020 */
497     PVOID           ActiveRpcHandle;            /* 028 */
498     PVOID           ThreadLocalStoragePointer;  /* 02c */
499     PVOID           Peb;                        /* 030 */
500     ULONG           LastErrorValue;             /* 034 */
501     ULONG           CountOfOwnedCriticalSections;/* 038 */
502     PVOID           CsrClientThread;            /* 03c */
503     PVOID           Win32ThreadInfo;            /* 040 */
504     ULONG           Win32ClientInfo[31];        /* 044 used for user32 private data in Wine */
505     PVOID           WOW32Reserved;              /* 0c0 */
506     ULONG           CurrentLocale;              /* 0c4 */
507     ULONG           FpSoftwareStatusRegister;   /* 0c8 */
508     PVOID           SystemReserved1[54];        /* 0cc used for kernel32 private data in Wine */
509     PVOID           Spare1;                     /* 1a4 */
510     LONG            ExceptionCode;              /* 1a8 */
511     PVOID     ActivationContextStackPointer;            /* 1a8/02c8 */
512     BYTE            SpareBytes1[36];            /* 1ac */
513     PVOID           SystemReserved2[10];        /* 1d4 used for ntdll private data in Wine */
514     GDI_TEB_BATCH   GdiTebBatch;                /* 1fc */
515     ULONG           gdiRgn;                     /* 6dc */
516     ULONG           gdiPen;                     /* 6e0 */
517     ULONG           gdiBrush;                   /* 6e4 */
518     CLIENT_ID       RealClientId;               /* 6e8 */
519     HANDLE          GdiCachedProcessHandle;     /* 6f0 */
520     ULONG           GdiClientPID;               /* 6f4 */
521     ULONG           GdiClientTID;               /* 6f8 */
522     PVOID           GdiThreadLocaleInfo;        /* 6fc */
523     PVOID           UserReserved[5];            /* 700 */
524     PVOID           glDispatchTable[280];        /* 714 */
525     ULONG           glReserved1[26];            /* b74 */
526     PVOID           glReserved2;                /* bdc */
527     PVOID           glSectionInfo;              /* be0 */
528     PVOID           glSection;                  /* be4 */
529     PVOID           glTable;                    /* be8 */
530     PVOID           glCurrentRC;                /* bec */
531     PVOID           glContext;                  /* bf0 */
532     ULONG           LastStatusValue;            /* bf4 */
533     UNICODE_STRING  StaticUnicodeString;        /* bf8 used by advapi32 */
534     WCHAR           StaticUnicodeBuffer[261];   /* c00 used by advapi32 */
535     PVOID           DeallocationStack;          /* e0c */
536     PVOID           TlsSlots[64];               /* e10 */
537     LIST_ENTRY      TlsLinks;                   /* f10 */
538     PVOID           Vdm;                        /* f18 */
539     PVOID           ReservedForNtRpc;           /* f1c */
540     PVOID           DbgSsReserved[2];           /* f20 */
541     ULONG           HardErrorDisabled;          /* f28 */
542     PVOID           Instrumentation[16];        /* f2c */
543     PVOID           WinSockData;                /* f6c */
544     ULONG           GdiBatchCount;              /* f70 */
545     ULONG           Spare2;                     /* f74 */
546     ULONG           Spare3;                     /* f78 */
547     ULONG           Spare4;                     /* f7c */
548     PVOID           ReservedForOle;             /* f80 */
549     ULONG           WaitingOnLoaderLock;        /* f84 */
550     PVOID           Reserved5[3];               /* f88 */
551     PVOID          *TlsExpansionSlots;          /* f94 */
552 } TEB, *PTEB;
553 
554 
555 // winver.h
556 typedef struct tagVS_FIXEDFILEINFO {
557 	DWORD dwSignature;
558 	DWORD dwStrucVersion;
559 	DWORD dwFileVersionMS;
560 	DWORD dwFileVersionLS;
561 	DWORD dwProductVersionMS;
562 	DWORD dwProductVersionLS;
563 	DWORD dwFileFlagsMask;
564 	DWORD dwFileFlags;
565 	DWORD dwFileOS;
566 	DWORD dwFileType;
567 	DWORD dwFileSubtype;
568 	DWORD dwFileDateMS;
569 	DWORD dwFileDateLS;
570 } VS_FIXEDFILEINFO;
571 
572 
573 // psapi.h
574 typedef struct _MODULEINFO {
575 	LPVOID lpBaseOfDll;
576 	DWORD SizeOfImage;
577 	LPVOID EntryPoint;
578 } MODULEINFO,*LPMODULEINFO;
579 #define GetModuleFileNameExW(w, x, y, z) 0
580 
581 // pstypes.h
582 typedef struct _THREAD_BASIC_INFORMATION
583 {
584     NTSTATUS ExitStatus;
585     PVOID TebBaseAddress;
586     CLIENT_ID ClientId;
587     KAFFINITY AffinityMask;
588     KPRIORITY Priority;
589     KPRIORITY BasePriority;
590 } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
591 typedef enum _THREADINFOCLASS {
592   ThreadBasicInformation,
593   ThreadTimes,
594   ThreadPriority,
595   ThreadBasePriority,
596   ThreadAffinityMask,
597   ThreadImpersonationToken,
598   ThreadDescriptorTableEntry,
599   ThreadEnableAlignmentFaultFixup,
600   ThreadEventPair_Reusable,
601   ThreadQuerySetWin32StartAddress,
602   ThreadZeroTlsCell,
603   ThreadPerformanceCount,
604   ThreadAmILastThread,
605   ThreadIdealProcessor,
606   ThreadPriorityBoost,
607   ThreadSetTlsArrayAddress,
608   ThreadIsIoPending,
609   ThreadHideFromDebugger,
610   ThreadBreakOnTermination,
611   ThreadSwitchLegacyState,
612   ThreadIsTerminated,
613   ThreadLastSystemCall,
614   ThreadIoPriority,
615   ThreadCycleTime,
616   ThreadPagePriority,
617   ThreadActualBasePriority,
618   ThreadTebInformation,
619   ThreadCSwitchMon,
620   ThreadCSwitchPmu,
621   ThreadWow64Context,
622   ThreadGroupInformation,
623   ThreadUmsInformation,
624   ThreadCounterProfiling,
625   ThreadIdealProcessorEx,
626   MaxThreadInfoClass
627 } THREADINFOCLASS;
628 
629 
630 // dbghelp.h
631 typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
632 #define MAX_SYM_NAME    2000
633 #define CBA_DEFERRED_SYMBOL_LOAD_START          0x00000001
634 #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE       0x00000002
635 #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE        0x00000003
636 #define CBA_SYMBOLS_UNLOADED                    0x00000004
637 #define CBA_DUPLICATE_SYMBOL                    0x00000005
638 #define CBA_READ_MEMORY                         0x00000006
639 #define CBA_DEFERRED_SYMBOL_LOAD_CANCEL         0x00000007
640 #define CBA_SET_OPTIONS                         0x00000008
641 #define CBA_EVENT                               0x00000010
642 #define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL        0x00000020
643 #define CBA_DEBUG_INFO                          0x10000000
644 #define SYMOPT_CASE_INSENSITIVE         0x00000001
645 #define SYMOPT_UNDNAME                  0x00000002
646 #define SYMOPT_DEFERRED_LOADS           0x00000004
647 #define SYMOPT_LOAD_LINES               0x00000010
648 #define SYMOPT_LOAD_ANYTHING            0x00000040
649 #define SYMOPT_PUBLICS_ONLY             0x00004000
650 #define SYMOPT_NO_PUBLICS               0x00008000
651 #define SYMOPT_AUTO_PUBLICS             0x00010000
652 #define SYMFLAG_VALUEPRESENT     0x00000001
653 #define SYMFLAG_REGISTER         0x00000008
654 #define SYMFLAG_REGREL           0x00000010
655 #define SYMFLAG_FRAMEREL         0x00000020
656 #define SYMFLAG_PARAMETER        0x00000040
657 #define SYMFLAG_LOCAL            0x00000080
658 #define SYMFLAG_CONSTANT         0x00000100
659 #define SYMFLAG_EXPORT           0x00000200
660 #define SYMFLAG_FORWARDER        0x00000400
661 #define SYMFLAG_FUNCTION         0x00000800
662 #define SYMFLAG_VIRTUAL          0x00001000
663 #define SYMFLAG_THUNK            0x00002000
664 #define SYMFLAG_TLSREL           0x00004000
665 #define SYMFLAG_SLOT             0x00008000
666 #define SYMFLAG_ILREL            0x00010000
667 #define SYMFLAG_METADATA         0x00020000
668 #define SYMFLAG_CLR_TOKEN        0x00040000
669 #define SYMFLAG_NULL             0x00080000
670 #define SYMFLAG_FUNC_NO_RETURN   0x00100000
671 #define SYMFLAG_SYNTHETIC_ZEROBASE 0x00200000
672 #define SYMFLAG_PUBLIC_CODE      0x00400000
673 #define UNDNAME_COMPLETE                 (0x0000)
674 #define UNDNAME_NAME_ONLY                (0x1000)
675 typedef struct _TI_FINDCHILDREN_PARAMS
676 {
677     ULONG Count;
678     ULONG Start;
679     ULONG ChildId[1];
680 } TI_FINDCHILDREN_PARAMS;
681 #define SYMSEARCH_GLOBALSONLY           0x04
682 /* flags for SymLoadModuleEx */
683 #define SLMFLAG_VIRTUAL         0x1
684 #define SLMFLAG_NO_SYMBOLS      0x4
685 typedef struct _DBGHELP_MODLOAD_DATA
686 {
687     DWORD               ssize;
688     DWORD               ssig;
689     PVOID               data;
690     DWORD               size;
691     DWORD               flags;
692 } MODLOAD_DATA, *PMODLOAD_DATA;
693 typedef struct _SYMBOL_INFO
694 {
695     ULONG       SizeOfStruct;
696     ULONG       TypeIndex;
697     ULONG64     Reserved[2];
698     ULONG       Index;
699     ULONG       Size;
700     ULONG64     ModBase;
701     ULONG       Flags;
702     ULONG64     Value;
703     ULONG64     Address;
704     ULONG       Register;
705     ULONG       Scope;
706     ULONG       Tag;
707     ULONG       NameLen;
708     ULONG       MaxNameLen;
709     CHAR        Name[1];
710 } SYMBOL_INFO, *PSYMBOL_INFO;
711 typedef enum
712 {
713     SymNone = 0,
714     SymCoff,
715     SymCv,
716     SymPdb,
717     SymExport,
718     SymDeferred,
719     SymSym,
720     SymDia,
721     SymVirtual,
722     NumSymTypes
723 } SYM_TYPE;
724 typedef struct _IMAGEHLP_MODULEW64
725 {
726     DWORD                       SizeOfStruct;
727     DWORD64                     BaseOfImage;
728     DWORD                       ImageSize;
729     DWORD                       TimeDateStamp;
730     DWORD                       CheckSum;
731     DWORD                       NumSyms;
732     SYM_TYPE                    SymType;
733     WCHAR                       ModuleName[32];
734     WCHAR                       ImageName[256];
735     WCHAR                       LoadedImageName[256];
736     WCHAR                       LoadedPdbName[256];
737     DWORD                       CVSig;
738     WCHAR                       CVData[MAX_PATH*3];
739     DWORD                       PdbSig;
740     GUID                        PdbSig70;
741     DWORD                       PdbAge;
742     BOOL                        PdbUnmatched;
743     BOOL                        DbgUnmatched;
744     BOOL                        LineNumbers;
745     BOOL                        GlobalSymbols;
746     BOOL                        TypeInfo;
747     BOOL                        SourceIndexed;
748     BOOL                        Publics;
749 } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
750 typedef struct _IMAGEHLP_LINE64
751 {
752     DWORD                       SizeOfStruct;
753     PVOID                       Key;
754     DWORD                       LineNumber;
755     PCHAR                       FileName;
756     DWORD64                     Address;
757 } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
758 typedef struct _SRCCODEINFO
759 {
760     DWORD       SizeOfStruct;
761     PVOID       Key;
762     DWORD64     ModBase;
763     CHAR        Obj[MAX_PATH+1];
764     CHAR        FileName[MAX_PATH+1];
765     DWORD       LineNumber;
766     DWORD64     Address;
767 } SRCCODEINFO, *PSRCCODEINFO;
768 typedef BOOL (CALLBACK* PSYM_ENUMLINES_CALLBACK)(PSRCCODEINFO, PVOID);
769 typedef BOOL (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(PSYMBOL_INFO, ULONG, PVOID);
770 BOOL WINAPI SymInitialize(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess);
771 BOOL WINAPI SymCleanup(HANDLE hProcess);
772 BOOL WINAPI SymAddSymbolW(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR name, DWORD64 addr, DWORD size, DWORD flags);
773 BOOL  WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo);
774 BOOL WINAPI SymMatchStringW(PCWSTR string, PCWSTR re, BOOL _case);
775 DWORD WINAPI SymLoadModule(HANDLE hProcess, HANDLE hFile, PCSTR ImageName,
776                            PCSTR ModuleName, DWORD BaseOfDll, DWORD SizeOfDll);
777 DWORD64 WINAPI SymLoadModuleEx(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64, DWORD,
778                                PMODLOAD_DATA, DWORD);
779 DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64, DWORD,
780                                 PMODLOAD_DATA, DWORD);
781 DWORD64 WINAPI SymGetModuleBase64(HANDLE, DWORD64);
782 BOOL WINAPI SymUnloadModule(HANDLE hProcess, DWORD BaseOfDll);
783 PVOID   WINAPI SymFunctionTableAccess(HANDLE, DWORD);
784 PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64);
785 BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64* Displacement, PSYMBOL_INFO Symbol);
786 BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland, PCSTR srcfile, PSYM_ENUMLINES_CALLBACK cb, PVOID user);
787 DWORD WINAPI SymSetOptions(DWORD opts);
788 BOOL WINAPI SymGetLineFromAddr64(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line);
789 typedef BOOL (CALLBACK *PFIND_EXE_FILE_CALLBACKW)(HANDLE, PCWSTR, PVOID);
790 #define FindExecutableImageExW __FindExecutableImageExW
791 HANDLE __FindExecutableImageExW(PCWSTR, PCWSTR, PWSTR, PFIND_EXE_FILE_CALLBACKW, PVOID);
792 DWORD WINAPI UnDecorateSymbolName(PCSTR, PSTR, DWORD, DWORD);
793 typedef enum _THREAD_WRITE_FLAGS
794 {
795     ThreadWriteThread            = 0x0001,
796     ThreadWriteStack             = 0x0002,
797     ThreadWriteContext           = 0x0004,
798     ThreadWriteBackingStore      = 0x0008,
799     ThreadWriteInstructionWindow = 0x0010,
800     ThreadWriteThreadData        = 0x0020,
801     ThreadWriteThreadInfo        = 0x0040
802 } THREAD_WRITE_FLAGS;
803 typedef enum
804 {
805     AddrMode1616,
806     AddrMode1632,
807     AddrModeReal,
808     AddrModeFlat
809 } ADDRESS_MODE;
810 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64
811 {
812     DWORD                       SizeOfStruct;
813     DWORD64                     BaseOfImage;
814     DWORD                       CheckSum;
815     DWORD                       TimeDateStamp;
816     WCHAR                       FileName[MAX_PATH + 1];
817     BOOLEAN                     Reparse;
818     HANDLE                      hFile;
819     DWORD                       Flags;
820 } IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64;
821 typedef struct _tagADDRESS64
822 {
823     DWORD64                     Offset;
824     WORD                        Segment;
825     ADDRESS_MODE                Mode;
826 } ADDRESS64, *LPADDRESS64;
827 typedef BOOL (CALLBACK *PENUMDIRTREE_CALLBACKW)(PCWSTR, PVOID);
828 typedef PVOID (CALLBACK *PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE, DWORD64);
829 typedef DWORD64 (CALLBACK *PGET_MODULE_BASE_ROUTINE64)(HANDLE, DWORD64);
830 typedef DWORD64 (CALLBACK *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE, HANDLE, LPADDRESS64);
831 typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(HANDLE, ULONG, ULONG64, ULONG64);
832 typedef BOOL (CALLBACK *PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE, DWORD64, PVOID, DWORD, PDWORD);
833 typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(PCSTR, DWORD64, PVOID);
834 typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(PCWSTR, DWORD64, PVOID);
835 typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(PCSTR, DWORD64, ULONG, PVOID);
836 typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(PCWSTR, DWORD64, ULONG, PVOID);
837 typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(PCSTR, DWORD64, ULONG, PVOID);
838 typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(PCWSTR, DWORD64, ULONG, PVOID);
839 
840 BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext);
841 
842 typedef struct _tagADDRESS
843 {
844     DWORD                       Offset;
845     WORD                        Segment;
846     ADDRESS_MODE                Mode;
847 } ADDRESS, *LPADDRESS;
848 
849 typedef struct _IMAGEHLP_MODULE
850 {
851     DWORD                       SizeOfStruct;
852     DWORD                       BaseOfImage;
853     DWORD                       ImageSize;
854     DWORD                       TimeDateStamp;
855     DWORD                       CheckSum;
856     DWORD                       NumSyms;
857     SYM_TYPE                    SymType;
858     CHAR                        ModuleName[32];
859     CHAR                        ImageName[256];
860     CHAR                        LoadedImageName[256];
861 } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
862 typedef struct _IMAGEHLP_MODULEW
863 {
864     DWORD                       SizeOfStruct;
865     DWORD                       BaseOfImage;
866     DWORD                       ImageSize;
867     DWORD                       TimeDateStamp;
868     DWORD                       CheckSum;
869     DWORD                       NumSyms;
870     SYM_TYPE                    SymType;
871     WCHAR                       ModuleName[32];
872     WCHAR                       ImageName[256];
873     WCHAR                       LoadedImageName[256];
874 } IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
875 typedef BOOL  (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(PCSTR, ULONG, ULONG, PVOID);
876 typedef BOOL  (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(HANDLE, ULONG, PVOID, PVOID);
877 typedef BOOL  (CALLBACK *PREAD_PROCESS_MEMORY_ROUTINE)(HANDLE, DWORD, PVOID, DWORD, PDWORD);
878 typedef DWORD (CALLBACK *PTRANSLATE_ADDRESS_ROUTINE)(HANDLE, HANDLE, LPADDRESS);
879 typedef PVOID (CALLBACK *PFUNCTION_TABLE_ACCESS_ROUTINE)(HANDLE, DWORD);
880 typedef DWORD (CALLBACK *PGET_MODULE_BASE_ROUTINE)(HANDLE, DWORD);
881 typedef BOOL  (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(PCSTR, ULONG, PVOID);
882 typedef BOOL  (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(PCSTR, ULONG, ULONG, PVOID);
883 typedef BOOL  (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(PCWSTR, ULONG, ULONG, PVOID);
884 
885 typedef struct _IMAGEHLP_MODULE64
886 {
887     DWORD                       SizeOfStruct;
888     DWORD64                     BaseOfImage;
889     DWORD                       ImageSize;
890     DWORD                       TimeDateStamp;
891     DWORD                       CheckSum;
892     DWORD                       NumSyms;
893     SYM_TYPE                    SymType;
894     CHAR                        ModuleName[32];
895     CHAR                        ImageName[256];
896     CHAR                        LoadedImageName[256];
897     CHAR                        LoadedPdbName[256];
898     DWORD                       CVSig;
899     CHAR                        CVData[MAX_PATH*3];
900     DWORD                       PdbSig;
901     GUID                        PdbSig70;
902     DWORD                       PdbAge;
903     BOOL                        PdbUnmatched;
904     BOOL                        DbgUnmatched;
905     BOOL                        LineNumbers;
906     BOOL                        GlobalSymbols;
907     BOOL                        TypeInfo;
908     BOOL                        SourceIndexed;
909     BOOL                        Publics;
910 } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
911 typedef DWORD   RVA;
912 typedef ULONG64 RVA64;
913 typedef enum _MINIDUMP_TYPE
914 {
915     MiniDumpNormal                              = 0x0000,
916     MiniDumpWithDataSegs                        = 0x0001,
917     MiniDumpWithFullMemory                      = 0x0002,
918     MiniDumpWithHandleData                      = 0x0004,
919     MiniDumpFilterMemory                        = 0x0008,
920     MiniDumpScanMemory                          = 0x0010,
921     MiniDumpWithUnloadedModules                 = 0x0020,
922     MiniDumpWithIndirectlyReferencedMemory      = 0x0040,
923     MiniDumpFilterModulePaths                   = 0x0080,
924     MiniDumpWithProcessThreadData               = 0x0100,
925     MiniDumpWithPrivateReadWriteMemory          = 0x0200,
926     MiniDumpWithoutOptionalData                 = 0x0400,
927     MiniDumpWithFullMemoryInfo                  = 0x0800,
928     MiniDumpWithThreadInfo                      = 0x1000,
929     MiniDumpWithCodeSegs                        = 0x2000
930 } MINIDUMP_TYPE;
931 typedef struct _MINIDUMP_THREAD_CALLBACK
932 {
933     ULONG                       ThreadId;
934     HANDLE                      ThreadHandle;
935     CONTEXT                     Context;
936     ULONG                       SizeOfContext;
937     ULONG64                     StackBase;
938     ULONG64                     StackEnd;
939 } MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK;
940 typedef struct _MINIDUMP_THREAD_EX_CALLBACK
941 {
942     ULONG                       ThreadId;
943     HANDLE                      ThreadHandle;
944     CONTEXT                     Context;
945     ULONG                       SizeOfContext;
946     ULONG64                     StackBase;
947     ULONG64                     StackEnd;
948     ULONG64                     BackingStoreBase;
949     ULONG64                     BackingStoreEnd;
950 } MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK;
951 typedef struct _MINIDUMP_MODULE_CALLBACK
952 {
953     PWCHAR                      FullPath;
954     ULONG64                     BaseOfImage;
955     ULONG                       SizeOfImage;
956     ULONG                       CheckSum;
957     ULONG                       TimeDateStamp;
958     VS_FIXEDFILEINFO            VersionInfo;
959     PVOID                       CvRecord;
960     ULONG                       SizeOfCvRecord;
961     PVOID                       MiscRecord;
962     ULONG                       SizeOfMiscRecord;
963 } MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK;
964 typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK
965 {
966     ULONG ThreadId;
967 } MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK;
968 typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK
969 {
970     ULONG64 BaseOfImage;
971 } MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK;
972 typedef struct _MINIDUMP_CALLBACK_INPUT
973 {
974     ULONG                       ProcessId;
975     HANDLE                      ProcessHandle;
976     ULONG                       CallbackType;
977     union
978     {
979         MINIDUMP_THREAD_CALLBACK        Thread;
980         MINIDUMP_THREAD_EX_CALLBACK     ThreadEx;
981         MINIDUMP_MODULE_CALLBACK        Module;
982         MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
983         MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
984     } DUMMYUNIONNAME;
985 } MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
986 typedef struct _MINIDUMP_CALLBACK_OUTPUT
987 {
988     union
989     {
990         ULONG                           ModuleWriteFlags;
991         ULONG                           ThreadWriteFlags;
992         struct
993         {
994             ULONG64                     MemoryBase;
995             ULONG                       MemorySize;
996         } DUMMYSTRUCTNAME;
997     } DUMMYUNIONNAME;
998 } MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT;
999 typedef BOOL (WINAPI* MINIDUMP_CALLBACK_ROUTINE)(PVOID, const PMINIDUMP_CALLBACK_INPUT, PMINIDUMP_CALLBACK_OUTPUT);
1000 typedef struct _MINIDUMP_CALLBACK_INFORMATION
1001 {
1002     MINIDUMP_CALLBACK_ROUTINE   CallbackRoutine;
1003     void*                       CallbackParam;
1004 } MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION;
1005 typedef struct _SYMBOL_INFOW
1006 {
1007     ULONG       SizeOfStruct;
1008     ULONG       TypeIndex;
1009     ULONG64     Reserved[2];
1010     ULONG       Index;
1011     ULONG       Size;
1012     ULONG64     ModBase;
1013     ULONG       Flags;
1014     ULONG64     Value;
1015     ULONG64     Address;
1016     ULONG       Register;
1017     ULONG       Scope;
1018     ULONG       Tag;
1019     ULONG       NameLen;
1020     ULONG       MaxNameLen;
1021     WCHAR       Name[1];
1022 } SYMBOL_INFOW, *PSYMBOL_INFOW;
1023 typedef struct _IMAGEHLP_STACK_FRAME
1024 {
1025     ULONG64     InstructionOffset;
1026     ULONG64     ReturnOffset;
1027     ULONG64     FrameOffset;
1028     ULONG64     StackOffset;
1029     ULONG64     BackingStoreOffset;
1030     ULONG64     FuncTableEntry;
1031     ULONG64     Params[4];
1032     ULONG64     Reserved[5];
1033     BOOL        Virtual;
1034     ULONG       Reserved2;
1035 } IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
1036 typedef struct _KDHELP64
1037 {
1038     DWORD64     Thread;
1039     DWORD       ThCallbackStack;
1040     DWORD       ThCallbackBStore;
1041     DWORD       NextCallback;
1042     DWORD       FramePointer;
1043     DWORD64     KiCallUserMode;
1044     DWORD64     KeUserCallbackDispatcher;
1045     DWORD64     SystemRangeStart;
1046     DWORD64     Reserved[8];
1047 } KDHELP64, *PKDHELP64;
1048 typedef struct _STACKFRAME64
1049 {
1050     ADDRESS64   AddrPC;
1051     ADDRESS64   AddrReturn;
1052     ADDRESS64   AddrFrame;
1053     ADDRESS64   AddrStack;
1054     ADDRESS64   AddrBStore;
1055     PVOID       FuncTableEntry;
1056     DWORD64     Params[4];
1057     BOOL        Far;
1058     BOOL        Virtual;
1059     DWORD64     Reserved[3];
1060     KDHELP64    KdHelp;
1061 } STACKFRAME64, *LPSTACKFRAME64;
1062 typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO
1063 {
1064     TI_GET_SYMTAG,
1065     TI_GET_SYMNAME,
1066     TI_GET_LENGTH,
1067     TI_GET_TYPE,
1068     TI_GET_TYPEID,
1069     TI_GET_BASETYPE,
1070     TI_GET_ARRAYINDEXTYPEID,
1071     TI_FINDCHILDREN,
1072     TI_GET_DATAKIND,
1073     TI_GET_ADDRESSOFFSET,
1074     TI_GET_OFFSET,
1075     TI_GET_VALUE,
1076     TI_GET_COUNT,
1077     TI_GET_CHILDRENCOUNT,
1078     TI_GET_BITPOSITION,
1079     TI_GET_VIRTUALBASECLASS,
1080     TI_GET_VIRTUALTABLESHAPEID,
1081     TI_GET_VIRTUALBASEPOINTEROFFSET,
1082     TI_GET_CLASSPARENTID,
1083     TI_GET_NESTED,
1084     TI_GET_SYMINDEX,
1085     TI_GET_LEXICALPARENT,
1086     TI_GET_ADDRESS,
1087     TI_GET_THISADJUST,
1088     TI_GET_UDTKIND,
1089     TI_IS_EQUIV_TO,
1090     TI_GET_CALLING_CONVENTION,
1091 } IMAGEHLP_SYMBOL_TYPE_INFO;
1092 typedef struct _SOURCEFILE
1093 {
1094     DWORD64                     ModBase;
1095     PCHAR                       FileName;
1096 } SOURCEFILE, *PSOURCEFILE;
1097 typedef struct _SOURCEFILEW
1098 {
1099     DWORD64                     ModBase;
1100     PWSTR                       FileName;
1101 } SOURCEFILEW, *PSOURCEFILEW;
1102 typedef BOOL (CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(PSOURCEFILE, PVOID);
1103 typedef BOOL (CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(PSOURCEFILEW, PVOID);
1104 typedef struct _SRCCODEINFOW
1105 {
1106     DWORD       SizeOfStruct;
1107     PVOID       Key;
1108     DWORD64     ModBase;
1109     WCHAR       Obj[MAX_PATH+1];
1110     WCHAR       FileName[MAX_PATH+1];
1111     DWORD       LineNumber;
1112     DWORD64     Address;
1113 } SRCCODEINFOW, *PSRCCODEINFOW;
1114 typedef BOOL (CALLBACK* PSYM_ENUMLINES_CALLBACKW)(PSRCCODEINFOW, PVOID);
1115 typedef BOOL (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)(PSYMBOL_INFOW, ULONG, PVOID);
1116 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1117 #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
1118 #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64
1119 #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
1120 #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64
1121 #else
1122 typedef struct _IMAGEHLP_SYMBOL
1123 {
1124     DWORD                       SizeOfStruct;
1125     DWORD                       Address;
1126     DWORD                       Size;
1127     DWORD                       Flags;
1128     DWORD                       MaxNameLength;
1129     CHAR                        Name[1];
1130 } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
1131 
1132 typedef struct _IMAGEHLP_SYMBOLW
1133 {
1134     DWORD                       SizeOfStruct;
1135     DWORD                       Address;
1136     DWORD                       Size;
1137     DWORD                       Flags;
1138     DWORD                       MaxNameLength;
1139     WCHAR                       Name[1];
1140 } IMAGEHLP_SYMBOLW, *PIMAGEHLP_SYMBOLW;
1141 #endif
1142 typedef struct _IMAGEHLP_SYMBOL64
1143 {
1144     DWORD                       SizeOfStruct;
1145     DWORD64                     Address;
1146     DWORD                       Size;
1147     DWORD                       Flags;
1148     DWORD                       MaxNameLength;
1149     CHAR                        Name[1];
1150 } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
1151 typedef struct _IMAGEHLP_SYMBOLW64
1152 {
1153     DWORD                       SizeOfStruct;
1154     DWORD64                     Address;
1155     DWORD                       Size;
1156     DWORD                       Flags;
1157     DWORD                       MaxNameLength;
1158     WCHAR                       Name[1];
1159 } IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64;
1160 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1161 #define IMAGEHLP_LINE IMAGEHLP_LINE64
1162 #define PIMAGEHLP_LINE PIMAGEHLP_LINE64
1163 #define IMAGEHLP_LINEW IMAGEHLP_LINEW64
1164 #define PIMAGEHLP_LINEW PIMAGEHLP_LINEW64
1165 #else
1166 typedef struct _IMAGEHLP_LINE
1167 {
1168     DWORD                       SizeOfStruct;
1169     PVOID                       Key;
1170     DWORD                       LineNumber;
1171     PCHAR                       FileName;
1172     DWORD                       Address;
1173 } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
1174 
1175 typedef struct _IMAGEHLP_LINEW
1176 {
1177     DWORD                       SizeOfStruct;
1178     PVOID                       Key;
1179     DWORD                       LineNumber;
1180     PWSTR                       FileName;
1181     DWORD                       Address;
1182 } IMAGEHLP_LINEW, *PIMAGEHLP_LINEW;
1183 #endif
1184 typedef struct _IMAGEHLP_LINEW64
1185 {
1186     DWORD                       SizeOfStruct;
1187     PVOID                       Key;
1188     DWORD                       LineNumber;
1189     PWSTR                       FileName;
1190     DWORD64                     Address;
1191 } IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64;
1192 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1193 #define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
1194 #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
1195 #else
1196 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD
1197 {
1198     DWORD                       SizeOfStruct;
1199     DWORD                       BaseOfImage;
1200     DWORD                       CheckSum;
1201     DWORD                       TimeDateStamp;
1202     CHAR                        FileName[MAX_PATH];
1203     BOOLEAN                     Reparse;
1204     HANDLE                      hFile;
1205 } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
1206 #endif
1207 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64
1208 {
1209     DWORD                       SizeOfStruct;
1210     DWORD64                     BaseOfImage;
1211     DWORD                       CheckSum;
1212     DWORD                       TimeDateStamp;
1213     CHAR                        FileName[MAX_PATH];
1214     BOOLEAN                     Reparse;
1215     HANDLE                      hFile;
1216     DWORD                       Flags;
1217 } IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
1218 typedef struct API_VERSION
1219 {
1220     USHORT  MajorVersion;
1221     USHORT  MinorVersion;
1222     USHORT  Revision;
1223     USHORT  Reserved;
1224 } API_VERSION, *LPAPI_VERSION;
1225 
1226 // cvconst.h
1227 /* symbols & types enumeration */
1228 enum SymTagEnum
1229 {
1230    SymTagNull,
1231    SymTagExe,
1232    SymTagCompiland,
1233    SymTagCompilandDetails,
1234    SymTagCompilandEnv,
1235    SymTagFunction,
1236    SymTagBlock,
1237    SymTagData,
1238    SymTagAnnotation,
1239    SymTagLabel,
1240    SymTagPublicSymbol,
1241    SymTagUDT,
1242    SymTagEnum,
1243    SymTagFunctionType,
1244    SymTagPointerType,
1245    SymTagArrayType,
1246    SymTagBaseType,
1247    SymTagTypedef,
1248    SymTagBaseClass,
1249    SymTagFriend,
1250    SymTagFunctionArgType,
1251    SymTagFuncDebugStart,
1252    SymTagFuncDebugEnd,
1253    SymTagUsingNamespace,
1254    SymTagVTableShape,
1255    SymTagVTable,
1256    SymTagCustom,
1257    SymTagThunk,
1258    SymTagCustomType,
1259    SymTagManagedType,
1260    SymTagDimension,
1261    SymTagMax
1262 };
1263 
1264 enum BasicType
1265 {
1266     btNoType = 0,
1267     btVoid = 1,
1268     btChar = 2,
1269     btWChar = 3,
1270     btInt = 6,
1271     btUInt = 7,
1272     btFloat = 8,
1273     btBCD = 9,
1274     btBool = 10,
1275     btLong = 13,
1276     btULong = 14,
1277     btCurrency = 25,
1278     btDate = 26,
1279     btVariant = 27,
1280     btComplex = 28,
1281     btBit = 29,
1282     btBSTR = 30,
1283     btHresult = 31,
1284 };
1285 
1286 /* kind of UDT */
1287 enum UdtKind
1288 {
1289     UdtStruct,
1290     UdtClass,
1291     UdtUnion
1292 };
1293 
1294 /* kind of SymTagData */
1295 enum DataKind
1296 {
1297     DataIsUnknown,
1298     DataIsLocal,
1299     DataIsStaticLocal,
1300     DataIsParam,
1301     DataIsObjectPtr,
1302     DataIsFileStatic,
1303     DataIsGlobal,
1304     DataIsMember,
1305     DataIsStaticMember,
1306     DataIsConstant
1307 };
1308 
1309 /* values for registers (on different CPUs) */
1310 enum CV_HREG_e
1311 {
1312     /* those values are common to all supported CPUs (and CPU independent) */
1313     CV_ALLREG_ERR       = 30000,
1314     CV_ALLREG_TEB       = 30001,
1315     CV_ALLREG_TIMER     = 30002,
1316     CV_ALLREG_EFAD1     = 30003,
1317     CV_ALLREG_EFAD2     = 30004,
1318     CV_ALLREG_EFAD3     = 30005,
1319     CV_ALLREG_VFRAME    = 30006,
1320     CV_ALLREG_HANDLE    = 30007,
1321     CV_ALLREG_PARAMS    = 30008,
1322     CV_ALLREG_LOCALS    = 30009,
1323     CV_ALLREG_TID       = 30010,
1324     CV_ALLREG_ENV       = 30011,
1325     CV_ALLREG_CMDLN     = 30012,
1326 
1327     /* Intel x86 CPU */
1328     CV_REG_NONE         = 0,
1329     CV_REG_AL           = 1,
1330     CV_REG_CL           = 2,
1331     CV_REG_DL           = 3,
1332     CV_REG_BL           = 4,
1333     CV_REG_AH           = 5,
1334     CV_REG_CH           = 6,
1335     CV_REG_DH           = 7,
1336     CV_REG_BH           = 8,
1337     CV_REG_AX           = 9,
1338     CV_REG_CX           = 10,
1339     CV_REG_DX           = 11,
1340     CV_REG_BX           = 12,
1341     CV_REG_SP           = 13,
1342     CV_REG_BP           = 14,
1343     CV_REG_SI           = 15,
1344     CV_REG_DI           = 16,
1345     CV_REG_EAX          = 17,
1346     CV_REG_ECX          = 18,
1347     CV_REG_EDX          = 19,
1348     CV_REG_EBX          = 20,
1349     CV_REG_ESP          = 21,
1350     CV_REG_EBP          = 22,
1351     CV_REG_ESI          = 23,
1352     CV_REG_EDI          = 24,
1353     CV_REG_ES           = 25,
1354     CV_REG_CS           = 26,
1355     CV_REG_SS           = 27,
1356     CV_REG_DS           = 28,
1357     CV_REG_FS           = 29,
1358     CV_REG_GS           = 30,
1359     CV_REG_IP           = 31,
1360     CV_REG_FLAGS        = 32,
1361     CV_REG_EIP          = 33,
1362     CV_REG_EFLAGS       = 34,
1363 
1364     /* <pcode> */
1365     CV_REG_TEMP         = 40,
1366     CV_REG_TEMPH        = 41,
1367     CV_REG_QUOTE        = 42,
1368     CV_REG_PCDR3        = 43,   /* this includes PCDR4 to PCDR7 */
1369     CV_REG_CR0          = 80,   /* this includes CR1 to CR4 */
1370     CV_REG_DR0          = 90,   /* this includes DR1 to DR7 */
1371     /* </pcode> */
1372 
1373     CV_REG_GDTR         = 110,
1374     CV_REG_GDTL         = 111,
1375     CV_REG_IDTR         = 112,
1376     CV_REG_IDTL         = 113,
1377     CV_REG_LDTR         = 114,
1378     CV_REG_TR           = 115,
1379 
1380     CV_REG_PSEUDO1      = 116, /* this includes Pseudo02 to Pseudo09 */
1381     CV_REG_ST0          = 128, /* this includes ST1 to ST7 */
1382     CV_REG_CTRL         = 136,
1383     CV_REG_STAT         = 137,
1384     CV_REG_TAG          = 138,
1385     CV_REG_FPIP         = 139,
1386     CV_REG_FPCS         = 140,
1387     CV_REG_FPDO         = 141,
1388     CV_REG_FPDS         = 142,
1389     CV_REG_ISEM         = 143,
1390     CV_REG_FPEIP        = 144,
1391     CV_REG_FPEDO        = 145,
1392     CV_REG_MM0          = 146, /* this includes MM1 to MM7 */
1393     CV_REG_XMM0         = 154, /* this includes XMM1 to XMM7 */
1394     CV_REG_XMM00        = 162,
1395     CV_REG_XMM0L        = 194, /* this includes XMM1L to XMM7L */
1396     CV_REG_XMM0H        = 202, /* this includes XMM1H to XMM7H */
1397     CV_REG_MXCSR        = 211,
1398     CV_REG_EDXEAX       = 212,
1399     CV_REG_EMM0L        = 220,
1400     CV_REG_EMM0H        = 228,
1401     CV_REG_MM00         = 236,
1402     CV_REG_MM01         = 237,
1403     CV_REG_MM10         = 238,
1404     CV_REG_MM11         = 239,
1405     CV_REG_MM20         = 240,
1406     CV_REG_MM21         = 241,
1407     CV_REG_MM30         = 242,
1408     CV_REG_MM31         = 243,
1409     CV_REG_MM40         = 244,
1410     CV_REG_MM41         = 245,
1411     CV_REG_MM50         = 246,
1412     CV_REG_MM51         = 247,
1413     CV_REG_MM60         = 248,
1414     CV_REG_MM61         = 249,
1415     CV_REG_MM70         = 250,
1416     CV_REG_MM71         = 251,
1417 
1418     CV_REG_YMM0         = 252, /* this includes YMM1 to YMM7 */
1419     CV_REG_YMM0H        = 260, /* this includes YMM1H to YMM7H */
1420     CV_REG_YMM0I0       = 268, /* this includes YMM0I1 to YMM0I3 */
1421     CV_REG_YMM1I0       = 272, /* this includes YMM1I1 to YMM1I3 */
1422     CV_REG_YMM2I0       = 276, /* this includes YMM2I1 to YMM2I3 */
1423     CV_REG_YMM3I0       = 280, /* this includes YMM3I1 to YMM3I3 */
1424     CV_REG_YMM4I0       = 284, /* this includes YMM4I1 to YMM4I3 */
1425     CV_REG_YMM5I0       = 288, /* this includes YMM5I1 to YMM5I3 */
1426     CV_REG_YMM6I0       = 292, /* this includes YMM6I1 to YMM6I3 */
1427     CV_REG_YMM7I0       = 296, /* this includes YMM7I1 to YMM7I3 */
1428     CV_REG_YMM0F0       = 300, /* this includes YMM0F1 to YMM0F7 */
1429     CV_REG_YMM1F0       = 308, /* this includes YMM1F1 to YMM1F7 */
1430     CV_REG_YMM2F0       = 316, /* this includes YMM2F1 to YMM2F7 */
1431     CV_REG_YMM3F0       = 324, /* this includes YMM3F1 to YMM3F7 */
1432     CV_REG_YMM4F0       = 332, /* this includes YMM4F1 to YMM4F7 */
1433     CV_REG_YMM5F0       = 340, /* this includes YMM5F1 to YMM5F7 */
1434     CV_REG_YMM6F0       = 348, /* this includes YMM6F1 to YMM6F7 */
1435     CV_REG_YMM7F0       = 356, /* this includes YMM7F1 to YMM7F7 */
1436     CV_REG_YMM0D0       = 364, /* this includes YMM0D1 to YMM0D3 */
1437     CV_REG_YMM1D0       = 368, /* this includes YMM1D1 to YMM1D3 */
1438     CV_REG_YMM2D0       = 372, /* this includes YMM2D1 to YMM2D3 */
1439     CV_REG_YMM3D0       = 376, /* this includes YMM3D1 to YMM3D3 */
1440     CV_REG_YMM4D0       = 380, /* this includes YMM4D1 to YMM4D3 */
1441     CV_REG_YMM5D0       = 384, /* this includes YMM5D1 to YMM5D3 */
1442     CV_REG_YMM6D0       = 388, /* this includes YMM6D1 to YMM6D3 */
1443     CV_REG_YMM7D0       = 392, /* this includes YMM7D1 to YMM7D3 */
1444 
1445     /* Motorola 68K CPU */
1446     CV_R68_D0           = 0, /* this includes D1 to D7 too */
1447     CV_R68_A0           = 8, /* this includes A1 to A7 too */
1448     CV_R68_CCR          = 16,
1449     CV_R68_SR           = 17,
1450     CV_R68_USP          = 18,
1451     CV_R68_MSP          = 19,
1452     CV_R68_SFC          = 20,
1453     CV_R68_DFC          = 21,
1454     CV_R68_CACR         = 22,
1455     CV_R68_VBR          = 23,
1456     CV_R68_CAAR         = 24,
1457     CV_R68_ISP          = 25,
1458     CV_R68_PC           = 26,
1459     CV_R68_FPCR         = 28,
1460     CV_R68_FPSR         = 29,
1461     CV_R68_FPIAR        = 30,
1462     CV_R68_FP0          = 32, /* this includes FP1 to FP7 */
1463     CV_R68_MMUSR030     = 41,
1464     CV_R68_MMUSR        = 42,
1465     CV_R68_URP          = 43,
1466     CV_R68_DTT0         = 44,
1467     CV_R68_DTT1         = 45,
1468     CV_R68_ITT0         = 46,
1469     CV_R68_ITT1         = 47,
1470     CV_R68_PSR          = 51,
1471     CV_R68_PCSR         = 52,
1472     CV_R68_VAL          = 53,
1473     CV_R68_CRP          = 54,
1474     CV_R68_SRP          = 55,
1475     CV_R68_DRP          = 56,
1476     CV_R68_TC           = 57,
1477     CV_R68_AC           = 58,
1478     CV_R68_SCC          = 59,
1479     CV_R68_CAL          = 60,
1480     CV_R68_TT0          = 61,
1481     CV_R68_TT1          = 62,
1482     CV_R68_BAD0         = 64, /* this includes BAD1 to BAD7 */
1483     CV_R68_BAC0         = 72, /* this includes BAC1 to BAC7 */
1484 
1485     /* MIPS 4000 CPU */
1486     CV_M4_NOREG         = CV_REG_NONE,
1487     CV_M4_IntZERO       = 10,
1488     CV_M4_IntAT         = 11,
1489     CV_M4_IntV0         = 12,
1490     CV_M4_IntV1         = 13,
1491     CV_M4_IntA0         = 14, /* this includes IntA1 to IntA3 */
1492     CV_M4_IntT0         = 18, /* this includes IntT1 to IntT7 */
1493     CV_M4_IntS0         = 26, /* this includes IntS1 to IntS7 */
1494     CV_M4_IntT8         = 34,
1495     CV_M4_IntT9         = 35,
1496     CV_M4_IntKT0        = 36,
1497     CV_M4_IntKT1        = 37,
1498     CV_M4_IntGP         = 38,
1499     CV_M4_IntSP         = 39,
1500     CV_M4_IntS8         = 40,
1501     CV_M4_IntRA         = 41,
1502     CV_M4_IntLO         = 42,
1503     CV_M4_IntHI         = 43,
1504     CV_M4_Fir           = 50,
1505     CV_M4_Psr           = 51,
1506     CV_M4_FltF0         = 60, /* this includes FltF1 to Flt31 */
1507     CV_M4_FltFsr        = 92,
1508 
1509     /* Alpha AXP CPU */
1510     CV_ALPHA_NOREG      = CV_REG_NONE,
1511     CV_ALPHA_FltF0      = 10, /* this includes FltF1 to FltF31 */
1512     CV_ALPHA_IntV0      = 42,
1513     CV_ALPHA_IntT0      = 43, /* this includes T1 to T7 */
1514     CV_ALPHA_IntS0      = 51, /* this includes S1 to S5 */
1515     CV_ALPHA_IntFP      = 57,
1516     CV_ALPHA_IntA0      = 58, /* this includes A1 to A5 */
1517     CV_ALPHA_IntT8      = 64,
1518     CV_ALPHA_IntT9      = 65,
1519     CV_ALPHA_IntT10     = 66,
1520     CV_ALPHA_IntT11     = 67,
1521     CV_ALPHA_IntRA      = 68,
1522     CV_ALPHA_IntT12     = 69,
1523     CV_ALPHA_IntAT      = 70,
1524     CV_ALPHA_IntGP      = 71,
1525     CV_ALPHA_IntSP      = 72,
1526     CV_ALPHA_IntZERO    = 73,
1527     CV_ALPHA_Fpcr       = 74,
1528     CV_ALPHA_Fir        = 75,
1529     CV_ALPHA_Psr        = 76,
1530     CV_ALPHA_FltFsr     = 77,
1531     CV_ALPHA_SoftFpcr   = 78,
1532 
1533     /* Motorola & IBM PowerPC CPU */
1534     CV_PPC_GPR0         = 1, /* this includes GPR1 to GPR31 */
1535     CV_PPC_CR           = 33,
1536     CV_PPC_CR0          = 34, /* this includes CR1 to CR7 */
1537     CV_PPC_FPR0         = 42, /* this includes FPR1 to FPR31 */
1538 
1539     CV_PPC_FPSCR        = 74,
1540     CV_PPC_MSR          = 75,
1541     CV_PPC_SR0          = 76, /* this includes SR1 to SR15 */
1542     CV_PPC_PC           = 99,
1543     CV_PPC_MQ           = 100,
1544     CV_PPC_XER          = 101,
1545     CV_PPC_RTCU         = 104,
1546     CV_PPC_RTCL         = 105,
1547     CV_PPC_LR           = 108,
1548     CV_PPC_CTR          = 109,
1549     CV_PPC_COMPARE      = 110,
1550     CV_PPC_COUNT        = 111,
1551     CV_PPC_DSISR        = 118,
1552     CV_PPC_DAR          = 119,
1553     CV_PPC_DEC          = 122,
1554     CV_PPC_SDR1         = 125,
1555     CV_PPC_SRR0         = 126,
1556     CV_PPC_SRR1         = 127,
1557     CV_PPC_SPRG0        = 372, /* this includes SPRG1 to SPRG3 */
1558     CV_PPC_ASR          = 280,
1559     CV_PPC_EAR          = 382,
1560     CV_PPC_PVR          = 287,
1561     CV_PPC_BAT0U        = 628,
1562     CV_PPC_BAT0L        = 629,
1563     CV_PPC_BAT1U        = 630,
1564     CV_PPC_BAT1L        = 631,
1565     CV_PPC_BAT2U        = 632,
1566     CV_PPC_BAT2L        = 633,
1567     CV_PPC_BAT3U        = 634,
1568     CV_PPC_BAT3L        = 635,
1569     CV_PPC_DBAT0U       = 636,
1570     CV_PPC_DBAT0L       = 637,
1571     CV_PPC_DBAT1U       = 638,
1572     CV_PPC_DBAT1L       = 639,
1573     CV_PPC_DBAT2U       = 640,
1574     CV_PPC_DBAT2L       = 641,
1575     CV_PPC_DBAT3U       = 642,
1576     CV_PPC_DBAT3L       = 643,
1577     CV_PPC_PMR0         = 1044, /* this includes PMR1 to PMR15 */
1578     CV_PPC_DMISS        = 1076,
1579     CV_PPC_DCMP         = 1077,
1580     CV_PPC_HASH1        = 1078,
1581     CV_PPC_HASH2        = 1079,
1582     CV_PPC_IMISS        = 1080,
1583     CV_PPC_ICMP         = 1081,
1584     CV_PPC_RPA          = 1082,
1585     CV_PPC_HID0         = 1108, /* this includes HID1 to HID15 */
1586 
1587     /* Java */
1588     CV_JAVA_PC          = 1,
1589 
1590     /* Hitachi SH3 CPU */
1591     CV_SH3_NOREG        = CV_REG_NONE,
1592     CV_SH3_IntR0        = 10, /* this include R1 to R13 */
1593     CV_SH3_IntFp        = 24,
1594     CV_SH3_IntSp        = 25,
1595     CV_SH3_Gbr          = 38,
1596     CV_SH3_Pr           = 39,
1597     CV_SH3_Mach         = 40,
1598     CV_SH3_Macl         = 41,
1599     CV_SH3_Pc           = 50,
1600     CV_SH3_Sr           = 51,
1601     CV_SH3_BarA         = 60,
1602     CV_SH3_BasrA        = 61,
1603     CV_SH3_BamrA        = 62,
1604     CV_SH3_BbrA         = 63,
1605     CV_SH3_BarB         = 64,
1606     CV_SH3_BasrB        = 65,
1607     CV_SH3_BamrB        = 66,
1608     CV_SH3_BbrB         = 67,
1609     CV_SH3_BdrB         = 68,
1610     CV_SH3_BdmrB        = 69,
1611     CV_SH3_Brcr         = 70,
1612     CV_SH_Fpscr         = 75,
1613     CV_SH_Fpul          = 76,
1614     CV_SH_FpR0          = 80, /* this includes FpR1 to FpR15 */
1615     CV_SH_XFpR0         = 96, /* this includes XFpR1 to XXFpR15 */
1616 
1617     /* ARM CPU */
1618     CV_ARM_NOREG        = CV_REG_NONE,
1619     CV_ARM_R0           = 10, /* this includes R1 to R12 */
1620     CV_ARM_SP           = 23,
1621     CV_ARM_LR           = 24,
1622     CV_ARM_PC           = 25,
1623     CV_ARM_CPSR         = 26,
1624     CV_ARM_ACC0         = 27,
1625     CV_ARM_FPSCR        = 40,
1626     CV_ARM_FPEXC        = 41,
1627     CV_ARM_FS0          = 50, /* this includes FS1 to FS31 */
1628     CV_ARM_FPEXTRA0     = 90, /* this includes FPEXTRA1 to FPEXTRA7 */
1629     CV_ARM_WR0          = 128, /* this includes WR1 to WR15 */
1630     CV_ARM_WCID         = 144,
1631     CV_ARM_WCON         = 145,
1632     CV_ARM_WCSSF        = 146,
1633     CV_ARM_WCASF        = 147,
1634     CV_ARM_WC4          = 148,
1635     CV_ARM_WC5          = 149,
1636     CV_ARM_WC6          = 150,
1637     CV_ARM_WC7          = 151,
1638     CV_ARM_WCGR0        = 152, /* this includes WCGR1 to WCGR3 */
1639     CV_ARM_WC12         = 156,
1640     CV_ARM_WC13         = 157,
1641     CV_ARM_WC14         = 158,
1642     CV_ARM_WC15         = 159,
1643     CV_ARM_FS32         = 200, /* this includes FS33 to FS63 */
1644     CV_ARM_ND0          = 300, /* this includes ND1 to ND31 */
1645     CV_ARM_NQ0          = 400, /* this includes NQ1 to NQ15 */
1646 
1647     /* Intel IA64 CPU */
1648     CV_IA64_NOREG       = CV_REG_NONE,
1649     CV_IA64_Br0         = 512, /* this includes Br1 to Br7 */
1650     CV_IA64_P0          = 704, /* this includes P1 to P63 */
1651     CV_IA64_Preds       = 768,
1652     CV_IA64_IntH0       = 832, /* this includes H1 to H15 */
1653     CV_IA64_Ip          = 1016,
1654     CV_IA64_Umask       = 1017,
1655     CV_IA64_Cfm         = 1018,
1656     CV_IA64_Psr         = 1019,
1657     CV_IA64_Nats        = 1020,
1658     CV_IA64_Nats2       = 1021,
1659     CV_IA64_Nats3       = 1022,
1660     CV_IA64_IntR0       = 1024, /* this includes R1 to R127 */
1661     CV_IA64_FltF0       = 2048, /* this includes FltF1 to FltF127 */
1662     /* some IA64 registers missing */
1663 
1664     /* TriCore CPU */
1665     CV_TRI_NOREG        = CV_REG_NONE,
1666     CV_TRI_D0           = 10, /* includes D1 to D15 */
1667     CV_TRI_A0           = 26, /* includes A1 to A15 */
1668     CV_TRI_E0           = 42,
1669     CV_TRI_E2           = 43,
1670     CV_TRI_E4           = 44,
1671     CV_TRI_E6           = 45,
1672     CV_TRI_E8           = 46,
1673     CV_TRI_E10          = 47,
1674     CV_TRI_E12          = 48,
1675     CV_TRI_E14          = 49,
1676     CV_TRI_EA0          = 50,
1677     CV_TRI_EA2          = 51,
1678     CV_TRI_EA4          = 52,
1679     CV_TRI_EA6          = 53,
1680     CV_TRI_EA8          = 54,
1681     CV_TRI_EA10         = 55,
1682     CV_TRI_EA12         = 56,
1683     CV_TRI_EA14         = 57,
1684     CV_TRI_PSW          = 58,
1685     CV_TRI_PCXI         = 59,
1686     CV_TRI_PC           = 60,
1687     CV_TRI_FCX          = 61,
1688     CV_TRI_LCX          = 62,
1689     CV_TRI_ISP          = 63,
1690     CV_TRI_ICR          = 64,
1691     CV_TRI_BIV          = 65,
1692     CV_TRI_BTV          = 66,
1693     CV_TRI_SYSCON       = 67,
1694     CV_TRI_DPRx_0       = 68, /* includes DPRx_1 to DPRx_3 */
1695     CV_TRI_CPRx_0       = 68, /* includes CPRx_1 to CPRx_3 */
1696     CV_TRI_DPMx_0       = 68, /* includes DPMx_1 to DPMx_3 */
1697     CV_TRI_CPMx_0       = 68, /* includes CPMx_1 to CPMx_3 */
1698     CV_TRI_DBGSSR       = 72,
1699     CV_TRI_EXEVT        = 73,
1700     CV_TRI_SWEVT        = 74,
1701     CV_TRI_CREVT        = 75,
1702     CV_TRI_TRnEVT       = 76,
1703     CV_TRI_MMUCON       = 77,
1704     CV_TRI_ASI          = 78,
1705     CV_TRI_TVA          = 79,
1706     CV_TRI_TPA          = 80,
1707     CV_TRI_TPX          = 81,
1708     CV_TRI_TFA          = 82,
1709 
1710     /* AM33 (and the likes) CPU */
1711     CV_AM33_NOREG       = CV_REG_NONE,
1712     CV_AM33_E0          = 10, /* this includes E1 to E7 */
1713     CV_AM33_A0          = 20, /* this includes A1 to A3 */
1714     CV_AM33_D0          = 30, /* this includes D1 to D3 */
1715     CV_AM33_FS0         = 40, /* this includes FS1 to FS31 */
1716     CV_AM33_SP          = 80,
1717     CV_AM33_PC          = 81,
1718     CV_AM33_MDR         = 82,
1719     CV_AM33_MDRQ        = 83,
1720     CV_AM33_MCRH        = 84,
1721     CV_AM33_MCRL        = 85,
1722     CV_AM33_MCVF        = 86,
1723     CV_AM33_EPSW        = 87,
1724     CV_AM33_FPCR        = 88,
1725     CV_AM33_LIR         = 89,
1726     CV_AM33_LAR         = 90,
1727 
1728     /* Mitsubishi M32R CPU */
1729     CV_M32R_NOREG       = CV_REG_NONE,
1730     CV_M32R_R0          = 10, /* this includes R1 to R11 */
1731     CV_M32R_R12         = 22,
1732     CV_M32R_R13         = 23,
1733     CV_M32R_R14         = 24,
1734     CV_M32R_R15         = 25,
1735     CV_M32R_PSW         = 26,
1736     CV_M32R_CBR         = 27,
1737     CV_M32R_SPI         = 28,
1738     CV_M32R_SPU         = 29,
1739     CV_M32R_SPO         = 30,
1740     CV_M32R_BPC         = 31,
1741     CV_M32R_ACHI        = 32,
1742     CV_M32R_ACLO        = 33,
1743     CV_M32R_PC          = 34,
1744 
1745     /* AMD/Intel x86_64 CPU */
1746     CV_AMD64_NONE       = CV_REG_NONE,
1747     CV_AMD64_AL         = CV_REG_AL,
1748     CV_AMD64_CL         = CV_REG_CL,
1749     CV_AMD64_DL         = CV_REG_DL,
1750     CV_AMD64_BL         = CV_REG_BL,
1751     CV_AMD64_AH         = CV_REG_AH,
1752     CV_AMD64_CH         = CV_REG_CH,
1753     CV_AMD64_DH         = CV_REG_DH,
1754     CV_AMD64_BH         = CV_REG_BH,
1755     CV_AMD64_AX         = CV_REG_AX,
1756     CV_AMD64_CX         = CV_REG_CX,
1757     CV_AMD64_DX         = CV_REG_DX,
1758     CV_AMD64_BX         = CV_REG_BX,
1759     CV_AMD64_SP         = CV_REG_SP,
1760     CV_AMD64_BP         = CV_REG_BP,
1761     CV_AMD64_SI         = CV_REG_SI,
1762     CV_AMD64_DI         = CV_REG_DI,
1763     CV_AMD64_EAX        = CV_REG_EAX,
1764     CV_AMD64_ECX        = CV_REG_ECX,
1765     CV_AMD64_EDX        = CV_REG_EDX,
1766     CV_AMD64_EBX        = CV_REG_EBX,
1767     CV_AMD64_ESP        = CV_REG_ESP,
1768     CV_AMD64_EBP        = CV_REG_EBP,
1769     CV_AMD64_ESI        = CV_REG_ESI,
1770     CV_AMD64_EDI        = CV_REG_EDI,
1771     CV_AMD64_ES         = CV_REG_ES,
1772     CV_AMD64_CS         = CV_REG_CS,
1773     CV_AMD64_SS         = CV_REG_SS,
1774     CV_AMD64_DS         = CV_REG_DS,
1775     CV_AMD64_FS         = CV_REG_FS,
1776     CV_AMD64_GS         = CV_REG_GS,
1777     CV_AMD64_FLAGS      = CV_REG_FLAGS,
1778     CV_AMD64_RIP        = CV_REG_EIP,
1779     CV_AMD64_EFLAGS     = CV_REG_EFLAGS,
1780 
1781     /* <pcode> */
1782     CV_AMD64_TEMP       = CV_REG_TEMP,
1783     CV_AMD64_TEMPH      = CV_REG_TEMPH,
1784     CV_AMD64_QUOTE      = CV_REG_QUOTE,
1785     CV_AMD64_PCDR3      = CV_REG_PCDR3, /* this includes PCDR4 to PCDR7 */
1786     CV_AMD64_CR0        = CV_REG_CR0,   /* this includes CR1 to CR4 */
1787     CV_AMD64_DR0        = CV_REG_DR0,   /* this includes DR1 to DR7 */
1788     /* </pcode> */
1789 
1790     CV_AMD64_GDTR       = CV_REG_GDTR,
1791     CV_AMD64_GDTL       = CV_REG_GDTL,
1792     CV_AMD64_IDTR       = CV_REG_IDTR,
1793     CV_AMD64_IDTL       = CV_REG_IDTL,
1794     CV_AMD64_LDTR       = CV_REG_LDTR,
1795     CV_AMD64_TR         = CV_REG_TR,
1796 
1797     CV_AMD64_PSEUDO1    = CV_REG_PSEUDO1, /* this includes Pseudo02 to Pseudo09 */
1798     CV_AMD64_ST0        = CV_REG_ST0,     /* this includes ST1 to ST7 */
1799     CV_AMD64_CTRL       = CV_REG_CTRL,
1800     CV_AMD64_STAT       = CV_REG_STAT,
1801     CV_AMD64_TAG        = CV_REG_TAG,
1802     CV_AMD64_FPIP       = CV_REG_FPIP,
1803     CV_AMD64_FPCS       = CV_REG_FPCS,
1804     CV_AMD64_FPDO       = CV_REG_FPDO,
1805     CV_AMD64_FPDS       = CV_REG_FPDS,
1806     CV_AMD64_ISEM       = CV_REG_ISEM,
1807     CV_AMD64_FPEIP      = CV_REG_FPEIP,
1808     CV_AMD64_FPEDO      = CV_REG_FPEDO,
1809     CV_AMD64_MM0        = CV_REG_MM0,     /* this includes MM1 to MM7 */
1810     CV_AMD64_XMM0       = CV_REG_XMM0,    /* this includes XMM1 to XMM7 */
1811     CV_AMD64_XMM00      = CV_REG_XMM00,
1812     CV_AMD64_XMM0L      = CV_REG_XMM0L,   /* this includes XMM1L to XMM7L */
1813     CV_AMD64_XMM0H      = CV_REG_XMM0H,   /* this includes XMM1H to XMM7H */
1814     CV_AMD64_MXCSR      = CV_REG_MXCSR,
1815     CV_AMD64_EDXEAX     = CV_REG_EDXEAX,
1816     CV_AMD64_EMM0L      = CV_REG_EMM0L,
1817     CV_AMD64_EMM0H      = CV_REG_EMM0H,
1818     CV_AMD64_MM00       = CV_REG_MM00,
1819     CV_AMD64_MM01       = CV_REG_MM01,
1820     CV_AMD64_MM10       = CV_REG_MM10,
1821     CV_AMD64_MM11       = CV_REG_MM11,
1822     CV_AMD64_MM20       = CV_REG_MM20,
1823     CV_AMD64_MM21       = CV_REG_MM21,
1824     CV_AMD64_MM30       = CV_REG_MM30,
1825     CV_AMD64_MM31       = CV_REG_MM31,
1826     CV_AMD64_MM40       = CV_REG_MM40,
1827     CV_AMD64_MM41       = CV_REG_MM41,
1828     CV_AMD64_MM50       = CV_REG_MM50,
1829     CV_AMD64_MM51       = CV_REG_MM51,
1830     CV_AMD64_MM60       = CV_REG_MM60,
1831     CV_AMD64_MM61       = CV_REG_MM61,
1832     CV_AMD64_MM70       = CV_REG_MM70,
1833     CV_AMD64_MM71       = CV_REG_MM71,
1834 
1835     CV_AMD64_XMM8       = 252,           /* this includes XMM9 to XMM15 */
1836 
1837     CV_AMD64_RAX        = 328,
1838     CV_AMD64_RBX        = 329,
1839     CV_AMD64_RCX        = 330,
1840     CV_AMD64_RDX        = 331,
1841     CV_AMD64_RSI        = 332,
1842     CV_AMD64_RDI        = 333,
1843     CV_AMD64_RBP        = 334,
1844     CV_AMD64_RSP        = 335,
1845 
1846     CV_AMD64_R8         = 336,
1847     CV_AMD64_R9         = 337,
1848     CV_AMD64_R10        = 338,
1849     CV_AMD64_R11        = 339,
1850     CV_AMD64_R12        = 340,
1851     CV_AMD64_R13        = 341,
1852     CV_AMD64_R14        = 342,
1853     CV_AMD64_R15        = 343,
1854 
1855     /* Wine extension */
1856     CV_ARM64_NOREG        = CV_REG_NONE,
1857     CV_ARM64_X0           = 10, /* this includes X0 to X30 */
1858     CV_ARM64_SP           = 41,
1859     CV_ARM64_PC           = 42,
1860     CV_ARM64_PSTATE       = 43,
1861 };
1862 
1863 typedef enum
1864 {
1865    THUNK_ORDINAL_NOTYPE,
1866    THUNK_ORDINAL_ADJUSTOR,
1867    THUNK_ORDINAL_VCALL,
1868    THUNK_ORDINAL_PCODE,
1869    THUNK_ORDINAL_LOAD
1870 } THUNK_ORDINAL;
1871 
1872 typedef enum CV_call_e
1873 {
1874     CV_CALL_NEAR_C,
1875     CV_CALL_FAR_C,
1876     CV_CALL_NEAR_PASCAL,
1877     CV_CALL_FAR_PASCAL,
1878     CV_CALL_NEAR_FAST,
1879     CV_CALL_FAR_FAST,
1880     CV_CALL_SKIPPED,
1881     CV_CALL_NEAR_STD,
1882     CV_CALL_FAR_STD,
1883     CV_CALL_NEAR_SYS,
1884     CV_CALL_FAR_SYS,
1885     CV_CALL_THISCALL,
1886     CV_CALL_MIPSCALL,
1887     CV_CALL_GENERIC,
1888     CV_CALL_ALPHACALL,
1889     CV_CALL_PPCCALL,
1890     CV_CALL_SHCALL,
1891     CV_CALL_ARMCALL,
1892     CV_CALL_AM33CALL,
1893     CV_CALL_TRICALL,
1894     CV_CALL_SH5CALL,
1895     CV_CALL_M32RCALL,
1896     CV_CALL_RESERVED,
1897 } CV_call_e;
1898 
1899 
1900 // wtypes.h
1901 typedef LONG SCODE;
1902 typedef double DATE;
1903 typedef unsigned short VARTYPE;
1904 typedef union tagCY {
1905     struct {
1906 #ifdef WORDS_BIGENDIAN
1907         LONG  Hi;
1908         ULONG Lo;
1909 #else
1910         ULONG Lo;
1911         LONG  Hi;
1912 #endif
1913     } DUMMYSTRUCTNAME;
1914     LONGLONG int64;
1915 } CY;
1916 typedef struct tagDEC {
1917   USHORT wReserved;
1918   union {
1919     struct {
1920       BYTE scale;
1921       BYTE sign;
1922     } DUMMYSTRUCTNAME;
1923     USHORT signscale;
1924   } DUMMYUNIONNAME;
1925   ULONG Hi32;
1926   union {
1927     struct {
1928 #ifdef WORDS_BIGENDIAN
1929       ULONG Mid32;
1930       ULONG Lo32;
1931 #else
1932       ULONG Lo32;
1933       ULONG Mid32;
1934 #endif
1935     } DUMMYSTRUCTNAME1;
1936     ULONGLONG Lo64;
1937   } DUMMYUNIONNAME1;
1938 } DECIMAL;
1939 typedef short VARIANT_BOOL;
1940 typedef VARIANT_BOOL _VARIANT_BOOL;
1941 typedef WCHAR OLECHAR;
1942 typedef OLECHAR *BSTR;
1943 enum VARENUM {
1944     VT_EMPTY = 0,
1945     VT_NULL = 1,
1946     VT_I2 = 2,
1947     VT_I4 = 3,
1948     VT_R4 = 4,
1949     VT_R8 = 5,
1950     VT_CY = 6,
1951     VT_DATE = 7,
1952     VT_BSTR = 8,
1953     VT_DISPATCH = 9,
1954     VT_ERROR = 10,
1955     VT_BOOL = 11,
1956     VT_VARIANT = 12,
1957     VT_UNKNOWN = 13,
1958     VT_DECIMAL = 14,
1959     VT_I1 = 16,
1960     VT_UI1 = 17,
1961     VT_UI2 = 18,
1962     VT_UI4 = 19,
1963     VT_I8 = 20,
1964     VT_UI8 = 21,
1965     VT_INT = 22,
1966     VT_UINT = 23,
1967     VT_VOID = 24,
1968     VT_HRESULT = 25,
1969     VT_PTR = 26,
1970     VT_SAFEARRAY = 27,
1971     VT_CARRAY = 28,
1972     VT_USERDEFINED = 29,
1973     VT_LPSTR = 30,
1974     VT_LPWSTR = 31,
1975     VT_RECORD = 36,
1976     VT_INT_PTR = 37,
1977     VT_UINT_PTR = 38,
1978     VT_FILETIME = 64,
1979     VT_BLOB = 65,
1980     VT_STREAM = 66,
1981     VT_STORAGE = 67,
1982     VT_STREAMED_OBJECT = 68,
1983     VT_STORED_OBJECT = 69,
1984     VT_BLOB_OBJECT = 70,
1985     VT_CF = 71,
1986     VT_CLSID = 72,
1987     VT_VERSIONED_STREAM = 73,
1988     VT_BSTR_BLOB = 0xfff,
1989     VT_VECTOR = 0x1000,
1990     VT_ARRAY = 0x2000,
1991     VT_BYREF = 0x4000,
1992     VT_RESERVED = 0x8000,
1993     VT_ILLEGAL = 0xffff,
1994     VT_ILLEGALMASKED = 0xfff,
1995     VT_TYPEMASK = 0xfff
1996 };
1997 
1998 // oaidl.h
1999 typedef struct tagSAFEARRAYBOUND {
2000     ULONG cElements;
2001     LONG lLbound;
2002 } SAFEARRAYBOUND;
2003 typedef struct tagSAFEARRAY {
2004     USHORT cDims;
2005     USHORT fFeatures;
2006     ULONG cbElements;
2007     ULONG cLocks;
2008     PVOID pvData;
2009     SAFEARRAYBOUND rgsabound[1];
2010 } SAFEARRAY;
2011 typedef SAFEARRAY *LPSAFEARRAY;
2012 
2013 #if (__STDC__ && !defined(_FORCENAMELESSUNION)) || defined(NONAMELESSUNION)
2014 #define __VARIANT_NAME_1 n1
2015 #define __VARIANT_NAME_2 n2
2016 #define __VARIANT_NAME_3 n3
2017 #define __VARIANT_NAME_4 brecVal
2018 #else
2019 #define __tagVARIANT
2020 #define __VARIANT_NAME_1
2021 #define __VARIANT_NAME_2
2022 #define __VARIANT_NAME_3
2023 #define __tagBRECORD
2024 #define __VARIANT_NAME_4
2025 #endif
2026 typedef struct tagVARIANT VARIANT;
2027 struct tagVARIANT {
2028     union {
2029         struct __tagVARIANT {
2030             VARTYPE vt;
2031             WORD wReserved1;
2032             WORD wReserved2;
2033             WORD wReserved3;
2034             union {
2035                 signed char cVal;
2036                 USHORT uiVal;
2037                 ULONG ulVal;
2038                 INT intVal;
2039                 UINT uintVal;
2040                 BYTE bVal;
2041                 SHORT iVal;
2042                 LONG lVal;
2043                 FLOAT fltVal;
2044                 DOUBLE dblVal;
2045                 VARIANT_BOOL boolVal;
2046                 SCODE scode;
2047                 DATE date;
2048                 BSTR bstrVal;
2049                 CY cyVal;
2050                 IUnknown *punkVal;
2051                 IDispatch *pdispVal;
2052                 SAFEARRAY *parray;
2053                 LONGLONG llVal;
2054                 ULONGLONG ullVal;
2055                 signed char *pcVal;
2056                 USHORT *puiVal;
2057                 ULONG *pulVal;
2058                 INT *pintVal;
2059                 UINT *puintVal;
2060                 BYTE *pbVal;
2061                 SHORT *piVal;
2062                 LONG *plVal;
2063                 FLOAT *pfltVal;
2064                 DOUBLE *pdblVal;
2065                 VARIANT_BOOL *pboolVal;
2066                 SCODE *pscode;
2067                 DATE *pdate;
2068                 BSTR *pbstrVal;
2069                 VARIANT *pvarVal;
2070                 PVOID byref;
2071                 CY *pcyVal;
2072                 DECIMAL *pdecVal;
2073                 IUnknown **ppunkVal;
2074                 IDispatch **ppdispVal;
2075                 SAFEARRAY **pparray;
2076                 LONGLONG *pllVal;
2077                 ULONGLONG *pullVal;
2078                 struct __tagBRECORD {
2079                     PVOID pvRecord;
2080                     IRecordInfo *pRecInfo;
2081                 } __VARIANT_NAME_4;
2082             } __VARIANT_NAME_3;
2083         } __VARIANT_NAME_2;
2084         DECIMAL decVal;
2085     } __VARIANT_NAME_1;
2086 };
2087 
2088 typedef VARIANT *LPVARIANT;
2089 typedef VARIANT VARIANTARG;
2090 typedef VARIANTARG *LPVARIANTARG;
2091 
2092 // wine/windef16.h
2093 typedef DWORD SEGPTR;
2094 
2095 // wine/winbase16.h
2096 typedef struct _STACK32FRAME
2097 {
2098     DWORD   restore_addr;   /* 00 return address for restoring code selector */
2099     DWORD   codeselector;   /* 04 code selector to restore */
2100     EXCEPTION_REGISTRATION_RECORD frame;  /* 08 Exception frame */
2101     SEGPTR  frame16;        /* 10 16-bit frame from last CallFrom16() */
2102     DWORD   edi;            /* 14 saved registers */
2103     DWORD   esi;            /* 18 */
2104     DWORD   ebx;            /* 1c */
2105     DWORD   ebp;            /* 20 saved 32-bit frame pointer */
2106     DWORD   retaddr;        /* 24 return address */
2107     DWORD   target;         /* 28 target address / CONTEXT86 pointer */
2108     DWORD   nb_args;        /* 2c number of 16-bit argument bytes */
2109 } STACK32FRAME;
2110 
2111 /* 16-bit stack layout after __wine_call_from_16() */
2112 typedef struct _STACK16FRAME
2113 {
2114     STACK32FRAME *frame32;        /* 00 32-bit frame from last CallTo16() */
2115     DWORD         edx;            /* 04 saved registers */
2116     DWORD         ecx;            /* 08 */
2117     DWORD         ebp;            /* 0c */
2118     WORD          ds;             /* 10 */
2119     WORD          es;             /* 12 */
2120     WORD          fs;             /* 14 */
2121     WORD          gs;             /* 16 */
2122     DWORD         callfrom_ip;    /* 18 callfrom tail IP */
2123     DWORD         module_cs;      /* 1c module code segment */
2124     DWORD         relay;          /* 20 relay function address */
2125     WORD          entry_ip;       /* 22 entry point IP */
2126     DWORD         entry_point;    /* 26 API entry point to call, reused as mutex count */
2127     WORD          bp;             /* 2a 16-bit stack frame chain */
2128     WORD          ip;             /* 2c return address */
2129     WORD          cs;             /* 2e */
2130 } STACK16FRAME;
2131