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