xref: /reactos/dll/win32/dbghelp/compat.h (revision 50cf16b3)
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 SYMFLAG_ILREL            0x00010000
659 #define SYMFLAG_METADATA         0x00020000
660 #define SYMFLAG_CLR_TOKEN        0x00040000
661 #define SYMFLAG_NULL             0x00080000
662 #define SYMFLAG_FUNC_NO_RETURN   0x00100000
663 #define SYMFLAG_SYNTHETIC_ZEROBASE 0x00200000
664 #define SYMFLAG_PUBLIC_CODE      0x00400000
665 #define UNDNAME_COMPLETE                 (0x0000)
666 #define UNDNAME_NAME_ONLY                (0x1000)
667 typedef struct _TI_FINDCHILDREN_PARAMS
668 {
669     ULONG Count;
670     ULONG Start;
671     ULONG ChildId[1];
672 } TI_FINDCHILDREN_PARAMS;
673 #define SYMSEARCH_GLOBALSONLY           0x04
674 /* flags for SymLoadModuleEx */
675 #define SLMFLAG_VIRTUAL         0x1
676 #define SLMFLAG_NO_SYMBOLS      0x4
677 typedef struct _DBGHELP_MODLOAD_DATA
678 {
679     DWORD               ssize;
680     DWORD               ssig;
681     PVOID               data;
682     DWORD               size;
683     DWORD               flags;
684 } MODLOAD_DATA, *PMODLOAD_DATA;
685 typedef struct _SYMBOL_INFO
686 {
687     ULONG       SizeOfStruct;
688     ULONG       TypeIndex;
689     ULONG64     Reserved[2];
690     ULONG       Index;
691     ULONG       Size;
692     ULONG64     ModBase;
693     ULONG       Flags;
694     ULONG64     Value;
695     ULONG64     Address;
696     ULONG       Register;
697     ULONG       Scope;
698     ULONG       Tag;
699     ULONG       NameLen;
700     ULONG       MaxNameLen;
701     CHAR        Name[1];
702 } SYMBOL_INFO, *PSYMBOL_INFO;
703 typedef enum
704 {
705     SymNone = 0,
706     SymCoff,
707     SymCv,
708     SymPdb,
709     SymExport,
710     SymDeferred,
711     SymSym,
712     SymDia,
713     SymVirtual,
714     NumSymTypes
715 } SYM_TYPE;
716 typedef struct _IMAGEHLP_MODULEW64
717 {
718     DWORD                       SizeOfStruct;
719     DWORD64                     BaseOfImage;
720     DWORD                       ImageSize;
721     DWORD                       TimeDateStamp;
722     DWORD                       CheckSum;
723     DWORD                       NumSyms;
724     SYM_TYPE                    SymType;
725     WCHAR                       ModuleName[32];
726     WCHAR                       ImageName[256];
727     WCHAR                       LoadedImageName[256];
728     WCHAR                       LoadedPdbName[256];
729     DWORD                       CVSig;
730     WCHAR                       CVData[MAX_PATH*3];
731     DWORD                       PdbSig;
732     GUID                        PdbSig70;
733     DWORD                       PdbAge;
734     BOOL                        PdbUnmatched;
735     BOOL                        DbgUnmatched;
736     BOOL                        LineNumbers;
737     BOOL                        GlobalSymbols;
738     BOOL                        TypeInfo;
739     BOOL                        SourceIndexed;
740     BOOL                        Publics;
741 } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
742 typedef struct _IMAGEHLP_LINE64
743 {
744     DWORD                       SizeOfStruct;
745     PVOID                       Key;
746     DWORD                       LineNumber;
747     PCHAR                       FileName;
748     DWORD64                     Address;
749 } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
750 typedef struct _SRCCODEINFO
751 {
752     DWORD       SizeOfStruct;
753     PVOID       Key;
754     DWORD64     ModBase;
755     CHAR        Obj[MAX_PATH+1];
756     CHAR        FileName[MAX_PATH+1];
757     DWORD       LineNumber;
758     DWORD64     Address;
759 } SRCCODEINFO, *PSRCCODEINFO;
760 typedef BOOL (CALLBACK* PSYM_ENUMLINES_CALLBACK)(PSRCCODEINFO, PVOID);
761 typedef BOOL (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(PSYMBOL_INFO, ULONG, PVOID);
762 BOOL WINAPI SymInitialize(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess);
763 BOOL WINAPI SymCleanup(HANDLE hProcess);
764 BOOL WINAPI SymAddSymbolW(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR name, DWORD64 addr, DWORD size, DWORD flags);
765 BOOL  WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo);
766 BOOL WINAPI SymMatchStringW(PCWSTR string, PCWSTR re, BOOL _case);
767 DWORD WINAPI SymLoadModule(HANDLE hProcess, HANDLE hFile, PCSTR ImageName,
768                            PCSTR ModuleName, DWORD BaseOfDll, DWORD SizeOfDll);
769 DWORD64 WINAPI SymLoadModuleEx(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64, DWORD,
770                                PMODLOAD_DATA, DWORD);
771 DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64, DWORD,
772                                 PMODLOAD_DATA, DWORD);
773 DWORD64 WINAPI SymGetModuleBase64(HANDLE, DWORD64);
774 BOOL WINAPI SymUnloadModule(HANDLE hProcess, DWORD BaseOfDll);
775 PVOID   WINAPI SymFunctionTableAccess(HANDLE, DWORD);
776 PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64);
777 BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64* Displacement, PSYMBOL_INFO Symbol);
778 BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland, PCSTR srcfile, PSYM_ENUMLINES_CALLBACK cb, PVOID user);
779 DWORD WINAPI SymSetOptions(DWORD opts);
780 BOOL WINAPI SymGetLineFromAddr64(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line);
781 typedef BOOL (CALLBACK *PFIND_EXE_FILE_CALLBACKW)(HANDLE, PCWSTR, PVOID);
782 #define FindExecutableImageExW __FindExecutableImageExW
783 HANDLE __FindExecutableImageExW(PCWSTR, PCWSTR, PWSTR, PFIND_EXE_FILE_CALLBACKW, PVOID);
784 DWORD WINAPI UnDecorateSymbolName(PCSTR, PSTR, DWORD, DWORD);
785 typedef enum _THREAD_WRITE_FLAGS
786 {
787     ThreadWriteThread            = 0x0001,
788     ThreadWriteStack             = 0x0002,
789     ThreadWriteContext           = 0x0004,
790     ThreadWriteBackingStore      = 0x0008,
791     ThreadWriteInstructionWindow = 0x0010,
792     ThreadWriteThreadData        = 0x0020,
793     ThreadWriteThreadInfo        = 0x0040
794 } THREAD_WRITE_FLAGS;
795 typedef enum
796 {
797     AddrMode1616,
798     AddrMode1632,
799     AddrModeReal,
800     AddrModeFlat
801 } ADDRESS_MODE;
802 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64
803 {
804     DWORD                       SizeOfStruct;
805     DWORD64                     BaseOfImage;
806     DWORD                       CheckSum;
807     DWORD                       TimeDateStamp;
808     WCHAR                       FileName[MAX_PATH + 1];
809     BOOLEAN                     Reparse;
810     HANDLE                      hFile;
811     DWORD                       Flags;
812 } IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64;
813 typedef struct _tagADDRESS64
814 {
815     DWORD64                     Offset;
816     WORD                        Segment;
817     ADDRESS_MODE                Mode;
818 } ADDRESS64, *LPADDRESS64;
819 typedef BOOL (CALLBACK *PENUMDIRTREE_CALLBACKW)(PCWSTR, PVOID);
820 typedef PVOID (CALLBACK *PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE, DWORD64);
821 typedef DWORD64 (CALLBACK *PGET_MODULE_BASE_ROUTINE64)(HANDLE, DWORD64);
822 typedef DWORD64 (CALLBACK *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE, HANDLE, LPADDRESS64);
823 typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(HANDLE, ULONG, ULONG64, ULONG64);
824 typedef BOOL (CALLBACK *PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE, DWORD64, PVOID, DWORD, PDWORD);
825 typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(PCSTR, DWORD64, PVOID);
826 typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(PCWSTR, DWORD64, PVOID);
827 typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(PCSTR, DWORD64, ULONG, PVOID);
828 typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(PCWSTR, DWORD64, ULONG, PVOID);
829 typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(PCSTR, DWORD64, ULONG, PVOID);
830 typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(PCWSTR, DWORD64, ULONG, PVOID);
831 
832 BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext);
833 
834 typedef struct _tagADDRESS
835 {
836     DWORD                       Offset;
837     WORD                        Segment;
838     ADDRESS_MODE                Mode;
839 } ADDRESS, *LPADDRESS;
840 
841 typedef struct _IMAGEHLP_MODULE
842 {
843     DWORD                       SizeOfStruct;
844     DWORD                       BaseOfImage;
845     DWORD                       ImageSize;
846     DWORD                       TimeDateStamp;
847     DWORD                       CheckSum;
848     DWORD                       NumSyms;
849     SYM_TYPE                    SymType;
850     CHAR                        ModuleName[32];
851     CHAR                        ImageName[256];
852     CHAR                        LoadedImageName[256];
853 } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
854 typedef struct _IMAGEHLP_MODULEW
855 {
856     DWORD                       SizeOfStruct;
857     DWORD                       BaseOfImage;
858     DWORD                       ImageSize;
859     DWORD                       TimeDateStamp;
860     DWORD                       CheckSum;
861     DWORD                       NumSyms;
862     SYM_TYPE                    SymType;
863     WCHAR                       ModuleName[32];
864     WCHAR                       ImageName[256];
865     WCHAR                       LoadedImageName[256];
866 } IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
867 typedef BOOL  (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(PCSTR, ULONG, ULONG, PVOID);
868 typedef BOOL  (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(HANDLE, ULONG, PVOID, PVOID);
869 typedef BOOL  (CALLBACK *PREAD_PROCESS_MEMORY_ROUTINE)(HANDLE, DWORD, PVOID, DWORD, PDWORD);
870 typedef DWORD (CALLBACK *PTRANSLATE_ADDRESS_ROUTINE)(HANDLE, HANDLE, LPADDRESS);
871 typedef PVOID (CALLBACK *PFUNCTION_TABLE_ACCESS_ROUTINE)(HANDLE, DWORD);
872 typedef DWORD (CALLBACK *PGET_MODULE_BASE_ROUTINE)(HANDLE, DWORD);
873 typedef BOOL  (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(PCSTR, ULONG, PVOID);
874 typedef BOOL  (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(PCSTR, ULONG, ULONG, PVOID);
875 typedef BOOL  (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(PCWSTR, ULONG, ULONG, PVOID);
876 
877 typedef struct _IMAGEHLP_MODULE64
878 {
879     DWORD                       SizeOfStruct;
880     DWORD64                     BaseOfImage;
881     DWORD                       ImageSize;
882     DWORD                       TimeDateStamp;
883     DWORD                       CheckSum;
884     DWORD                       NumSyms;
885     SYM_TYPE                    SymType;
886     CHAR                        ModuleName[32];
887     CHAR                        ImageName[256];
888     CHAR                        LoadedImageName[256];
889     CHAR                        LoadedPdbName[256];
890     DWORD                       CVSig;
891     CHAR                        CVData[MAX_PATH*3];
892     DWORD                       PdbSig;
893     GUID                        PdbSig70;
894     DWORD                       PdbAge;
895     BOOL                        PdbUnmatched;
896     BOOL                        DbgUnmatched;
897     BOOL                        LineNumbers;
898     BOOL                        GlobalSymbols;
899     BOOL                        TypeInfo;
900     BOOL                        SourceIndexed;
901     BOOL                        Publics;
902 } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
903 typedef DWORD   RVA;
904 typedef ULONG64 RVA64;
905 typedef enum _MINIDUMP_TYPE
906 {
907     MiniDumpNormal                              = 0x0000,
908     MiniDumpWithDataSegs                        = 0x0001,
909     MiniDumpWithFullMemory                      = 0x0002,
910     MiniDumpWithHandleData                      = 0x0004,
911     MiniDumpFilterMemory                        = 0x0008,
912     MiniDumpScanMemory                          = 0x0010,
913     MiniDumpWithUnloadedModules                 = 0x0020,
914     MiniDumpWithIndirectlyReferencedMemory      = 0x0040,
915     MiniDumpFilterModulePaths                   = 0x0080,
916     MiniDumpWithProcessThreadData               = 0x0100,
917     MiniDumpWithPrivateReadWriteMemory          = 0x0200,
918     MiniDumpWithoutOptionalData                 = 0x0400,
919     MiniDumpWithFullMemoryInfo                  = 0x0800,
920     MiniDumpWithThreadInfo                      = 0x1000,
921     MiniDumpWithCodeSegs                        = 0x2000
922 } MINIDUMP_TYPE;
923 typedef struct _MINIDUMP_THREAD_CALLBACK
924 {
925     ULONG                       ThreadId;
926     HANDLE                      ThreadHandle;
927     CONTEXT                     Context;
928     ULONG                       SizeOfContext;
929     ULONG64                     StackBase;
930     ULONG64                     StackEnd;
931 } MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK;
932 typedef struct _MINIDUMP_THREAD_EX_CALLBACK
933 {
934     ULONG                       ThreadId;
935     HANDLE                      ThreadHandle;
936     CONTEXT                     Context;
937     ULONG                       SizeOfContext;
938     ULONG64                     StackBase;
939     ULONG64                     StackEnd;
940     ULONG64                     BackingStoreBase;
941     ULONG64                     BackingStoreEnd;
942 } MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK;
943 typedef struct _MINIDUMP_MODULE_CALLBACK
944 {
945     PWCHAR                      FullPath;
946     ULONG64                     BaseOfImage;
947     ULONG                       SizeOfImage;
948     ULONG                       CheckSum;
949     ULONG                       TimeDateStamp;
950     VS_FIXEDFILEINFO            VersionInfo;
951     PVOID                       CvRecord;
952     ULONG                       SizeOfCvRecord;
953     PVOID                       MiscRecord;
954     ULONG                       SizeOfMiscRecord;
955 } MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK;
956 typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK
957 {
958     ULONG ThreadId;
959 } MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK;
960 typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK
961 {
962     ULONG64 BaseOfImage;
963 } MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK;
964 typedef struct _MINIDUMP_CALLBACK_INPUT
965 {
966     ULONG                       ProcessId;
967     HANDLE                      ProcessHandle;
968     ULONG                       CallbackType;
969     union
970     {
971         MINIDUMP_THREAD_CALLBACK        Thread;
972         MINIDUMP_THREAD_EX_CALLBACK     ThreadEx;
973         MINIDUMP_MODULE_CALLBACK        Module;
974         MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
975         MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
976     } DUMMYUNIONNAME;
977 } MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
978 typedef struct _MINIDUMP_CALLBACK_OUTPUT
979 {
980     union
981     {
982         ULONG                           ModuleWriteFlags;
983         ULONG                           ThreadWriteFlags;
984         struct
985         {
986             ULONG64                     MemoryBase;
987             ULONG                       MemorySize;
988         } DUMMYSTRUCTNAME;
989     } DUMMYUNIONNAME;
990 } MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT;
991 typedef BOOL (WINAPI* MINIDUMP_CALLBACK_ROUTINE)(PVOID, const PMINIDUMP_CALLBACK_INPUT, PMINIDUMP_CALLBACK_OUTPUT);
992 typedef struct _MINIDUMP_CALLBACK_INFORMATION
993 {
994     MINIDUMP_CALLBACK_ROUTINE   CallbackRoutine;
995     void*                       CallbackParam;
996 } MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION;
997 typedef struct _SYMBOL_INFOW
998 {
999     ULONG       SizeOfStruct;
1000     ULONG       TypeIndex;
1001     ULONG64     Reserved[2];
1002     ULONG       Index;
1003     ULONG       Size;
1004     ULONG64     ModBase;
1005     ULONG       Flags;
1006     ULONG64     Value;
1007     ULONG64     Address;
1008     ULONG       Register;
1009     ULONG       Scope;
1010     ULONG       Tag;
1011     ULONG       NameLen;
1012     ULONG       MaxNameLen;
1013     WCHAR       Name[1];
1014 } SYMBOL_INFOW, *PSYMBOL_INFOW;
1015 typedef struct _IMAGEHLP_STACK_FRAME
1016 {
1017     ULONG64     InstructionOffset;
1018     ULONG64     ReturnOffset;
1019     ULONG64     FrameOffset;
1020     ULONG64     StackOffset;
1021     ULONG64     BackingStoreOffset;
1022     ULONG64     FuncTableEntry;
1023     ULONG64     Params[4];
1024     ULONG64     Reserved[5];
1025     BOOL        Virtual;
1026     ULONG       Reserved2;
1027 } IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
1028 typedef struct _KDHELP64
1029 {
1030     DWORD64     Thread;
1031     DWORD       ThCallbackStack;
1032     DWORD       ThCallbackBStore;
1033     DWORD       NextCallback;
1034     DWORD       FramePointer;
1035     DWORD64     KiCallUserMode;
1036     DWORD64     KeUserCallbackDispatcher;
1037     DWORD64     SystemRangeStart;
1038     DWORD64     Reserved[8];
1039 } KDHELP64, *PKDHELP64;
1040 typedef struct _STACKFRAME64
1041 {
1042     ADDRESS64   AddrPC;
1043     ADDRESS64   AddrReturn;
1044     ADDRESS64   AddrFrame;
1045     ADDRESS64   AddrStack;
1046     ADDRESS64   AddrBStore;
1047     PVOID       FuncTableEntry;
1048     DWORD64     Params[4];
1049     BOOL        Far;
1050     BOOL        Virtual;
1051     DWORD64     Reserved[3];
1052     KDHELP64    KdHelp;
1053 } STACKFRAME64, *LPSTACKFRAME64;
1054 typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO
1055 {
1056     TI_GET_SYMTAG,
1057     TI_GET_SYMNAME,
1058     TI_GET_LENGTH,
1059     TI_GET_TYPE,
1060     TI_GET_TYPEID,
1061     TI_GET_BASETYPE,
1062     TI_GET_ARRAYINDEXTYPEID,
1063     TI_FINDCHILDREN,
1064     TI_GET_DATAKIND,
1065     TI_GET_ADDRESSOFFSET,
1066     TI_GET_OFFSET,
1067     TI_GET_VALUE,
1068     TI_GET_COUNT,
1069     TI_GET_CHILDRENCOUNT,
1070     TI_GET_BITPOSITION,
1071     TI_GET_VIRTUALBASECLASS,
1072     TI_GET_VIRTUALTABLESHAPEID,
1073     TI_GET_VIRTUALBASEPOINTEROFFSET,
1074     TI_GET_CLASSPARENTID,
1075     TI_GET_NESTED,
1076     TI_GET_SYMINDEX,
1077     TI_GET_LEXICALPARENT,
1078     TI_GET_ADDRESS,
1079     TI_GET_THISADJUST,
1080     TI_GET_UDTKIND,
1081     TI_IS_EQUIV_TO,
1082     TI_GET_CALLING_CONVENTION,
1083 } IMAGEHLP_SYMBOL_TYPE_INFO;
1084 typedef struct _SOURCEFILE
1085 {
1086     DWORD64                     ModBase;
1087     PCHAR                       FileName;
1088 } SOURCEFILE, *PSOURCEFILE;
1089 typedef struct _SOURCEFILEW
1090 {
1091     DWORD64                     ModBase;
1092     PWSTR                       FileName;
1093 } SOURCEFILEW, *PSOURCEFILEW;
1094 typedef BOOL (CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(PSOURCEFILE, PVOID);
1095 typedef BOOL (CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(PSOURCEFILEW, PVOID);
1096 typedef struct _SRCCODEINFOW
1097 {
1098     DWORD       SizeOfStruct;
1099     PVOID       Key;
1100     DWORD64     ModBase;
1101     WCHAR       Obj[MAX_PATH+1];
1102     WCHAR       FileName[MAX_PATH+1];
1103     DWORD       LineNumber;
1104     DWORD64     Address;
1105 } SRCCODEINFOW, *PSRCCODEINFOW;
1106 typedef BOOL (CALLBACK* PSYM_ENUMLINES_CALLBACKW)(PSRCCODEINFOW, PVOID);
1107 typedef BOOL (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)(PSYMBOL_INFOW, ULONG, PVOID);
1108 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1109 #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
1110 #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64
1111 #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
1112 #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64
1113 #else
1114 typedef struct _IMAGEHLP_SYMBOL
1115 {
1116     DWORD                       SizeOfStruct;
1117     DWORD                       Address;
1118     DWORD                       Size;
1119     DWORD                       Flags;
1120     DWORD                       MaxNameLength;
1121     CHAR                        Name[1];
1122 } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
1123 
1124 typedef struct _IMAGEHLP_SYMBOLW
1125 {
1126     DWORD                       SizeOfStruct;
1127     DWORD                       Address;
1128     DWORD                       Size;
1129     DWORD                       Flags;
1130     DWORD                       MaxNameLength;
1131     WCHAR                       Name[1];
1132 } IMAGEHLP_SYMBOLW, *PIMAGEHLP_SYMBOLW;
1133 #endif
1134 typedef struct _IMAGEHLP_SYMBOL64
1135 {
1136     DWORD                       SizeOfStruct;
1137     DWORD64                     Address;
1138     DWORD                       Size;
1139     DWORD                       Flags;
1140     DWORD                       MaxNameLength;
1141     CHAR                        Name[1];
1142 } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
1143 typedef struct _IMAGEHLP_SYMBOLW64
1144 {
1145     DWORD                       SizeOfStruct;
1146     DWORD64                     Address;
1147     DWORD                       Size;
1148     DWORD                       Flags;
1149     DWORD                       MaxNameLength;
1150     WCHAR                       Name[1];
1151 } IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64;
1152 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1153 #define IMAGEHLP_LINE IMAGEHLP_LINE64
1154 #define PIMAGEHLP_LINE PIMAGEHLP_LINE64
1155 #define IMAGEHLP_LINEW IMAGEHLP_LINEW64
1156 #define PIMAGEHLP_LINEW PIMAGEHLP_LINEW64
1157 #else
1158 typedef struct _IMAGEHLP_LINE
1159 {
1160     DWORD                       SizeOfStruct;
1161     PVOID                       Key;
1162     DWORD                       LineNumber;
1163     PCHAR                       FileName;
1164     DWORD                       Address;
1165 } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
1166 
1167 typedef struct _IMAGEHLP_LINEW
1168 {
1169     DWORD                       SizeOfStruct;
1170     PVOID                       Key;
1171     DWORD                       LineNumber;
1172     PWSTR                       FileName;
1173     DWORD                       Address;
1174 } IMAGEHLP_LINEW, *PIMAGEHLP_LINEW;
1175 #endif
1176 typedef struct _IMAGEHLP_LINEW64
1177 {
1178     DWORD                       SizeOfStruct;
1179     PVOID                       Key;
1180     DWORD                       LineNumber;
1181     PWSTR                       FileName;
1182     DWORD64                     Address;
1183 } IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64;
1184 #if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
1185 #define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
1186 #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
1187 #else
1188 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD
1189 {
1190     DWORD                       SizeOfStruct;
1191     DWORD                       BaseOfImage;
1192     DWORD                       CheckSum;
1193     DWORD                       TimeDateStamp;
1194     CHAR                        FileName[MAX_PATH];
1195     BOOLEAN                     Reparse;
1196     HANDLE                      hFile;
1197 } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
1198 #endif
1199 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64
1200 {
1201     DWORD                       SizeOfStruct;
1202     DWORD64                     BaseOfImage;
1203     DWORD                       CheckSum;
1204     DWORD                       TimeDateStamp;
1205     CHAR                        FileName[MAX_PATH];
1206     BOOLEAN                     Reparse;
1207     HANDLE                      hFile;
1208     DWORD                       Flags;
1209 } IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
1210 typedef struct API_VERSION
1211 {
1212     USHORT  MajorVersion;
1213     USHORT  MinorVersion;
1214     USHORT  Revision;
1215     USHORT  Reserved;
1216 } API_VERSION, *LPAPI_VERSION;
1217 
1218 // cvconst.h
1219 /* symbols & types enumeration */
1220 enum SymTagEnum
1221 {
1222    SymTagNull,
1223    SymTagExe,
1224    SymTagCompiland,
1225    SymTagCompilandDetails,
1226    SymTagCompilandEnv,
1227    SymTagFunction,
1228    SymTagBlock,
1229    SymTagData,
1230    SymTagAnnotation,
1231    SymTagLabel,
1232    SymTagPublicSymbol,
1233    SymTagUDT,
1234    SymTagEnum,
1235    SymTagFunctionType,
1236    SymTagPointerType,
1237    SymTagArrayType,
1238    SymTagBaseType,
1239    SymTagTypedef,
1240    SymTagBaseClass,
1241    SymTagFriend,
1242    SymTagFunctionArgType,
1243    SymTagFuncDebugStart,
1244    SymTagFuncDebugEnd,
1245    SymTagUsingNamespace,
1246    SymTagVTableShape,
1247    SymTagVTable,
1248    SymTagCustom,
1249    SymTagThunk,
1250    SymTagCustomType,
1251    SymTagManagedType,
1252    SymTagDimension,
1253    SymTagMax
1254 };
1255 
1256 enum BasicType
1257 {
1258     btNoType = 0,
1259     btVoid = 1,
1260     btChar = 2,
1261     btWChar = 3,
1262     btInt = 6,
1263     btUInt = 7,
1264     btFloat = 8,
1265     btBCD = 9,
1266     btBool = 10,
1267     btLong = 13,
1268     btULong = 14,
1269     btCurrency = 25,
1270     btDate = 26,
1271     btVariant = 27,
1272     btComplex = 28,
1273     btBit = 29,
1274     btBSTR = 30,
1275     btHresult = 31,
1276 };
1277 
1278 /* kind of UDT */
1279 enum UdtKind
1280 {
1281     UdtStruct,
1282     UdtClass,
1283     UdtUnion
1284 };
1285 
1286 /* kind of SymTagData */
1287 enum DataKind
1288 {
1289     DataIsUnknown,
1290     DataIsLocal,
1291     DataIsStaticLocal,
1292     DataIsParam,
1293     DataIsObjectPtr,
1294     DataIsFileStatic,
1295     DataIsGlobal,
1296     DataIsMember,
1297     DataIsStaticMember,
1298     DataIsConstant
1299 };
1300 
1301 /* values for registers (on different CPUs) */
1302 enum CV_HREG_e
1303 {
1304     /* those values are common to all supported CPUs (and CPU independent) */
1305     CV_ALLREG_ERR       = 30000,
1306     CV_ALLREG_TEB       = 30001,
1307     CV_ALLREG_TIMER     = 30002,
1308     CV_ALLREG_EFAD1     = 30003,
1309     CV_ALLREG_EFAD2     = 30004,
1310     CV_ALLREG_EFAD3     = 30005,
1311     CV_ALLREG_VFRAME    = 30006,
1312     CV_ALLREG_HANDLE    = 30007,
1313     CV_ALLREG_PARAMS    = 30008,
1314     CV_ALLREG_LOCALS    = 30009,
1315     CV_ALLREG_TID       = 30010,
1316     CV_ALLREG_ENV       = 30011,
1317     CV_ALLREG_CMDLN     = 30012,
1318 
1319     /* Intel x86 CPU */
1320     CV_REG_NONE         = 0,
1321     CV_REG_AL           = 1,
1322     CV_REG_CL           = 2,
1323     CV_REG_DL           = 3,
1324     CV_REG_BL           = 4,
1325     CV_REG_AH           = 5,
1326     CV_REG_CH           = 6,
1327     CV_REG_DH           = 7,
1328     CV_REG_BH           = 8,
1329     CV_REG_AX           = 9,
1330     CV_REG_CX           = 10,
1331     CV_REG_DX           = 11,
1332     CV_REG_BX           = 12,
1333     CV_REG_SP           = 13,
1334     CV_REG_BP           = 14,
1335     CV_REG_SI           = 15,
1336     CV_REG_DI           = 16,
1337     CV_REG_EAX          = 17,
1338     CV_REG_ECX          = 18,
1339     CV_REG_EDX          = 19,
1340     CV_REG_EBX          = 20,
1341     CV_REG_ESP          = 21,
1342     CV_REG_EBP          = 22,
1343     CV_REG_ESI          = 23,
1344     CV_REG_EDI          = 24,
1345     CV_REG_ES           = 25,
1346     CV_REG_CS           = 26,
1347     CV_REG_SS           = 27,
1348     CV_REG_DS           = 28,
1349     CV_REG_FS           = 29,
1350     CV_REG_GS           = 30,
1351     CV_REG_IP           = 31,
1352     CV_REG_FLAGS        = 32,
1353     CV_REG_EIP          = 33,
1354     CV_REG_EFLAGS       = 34,
1355 
1356     /* <pcode> */
1357     CV_REG_TEMP         = 40,
1358     CV_REG_TEMPH        = 41,
1359     CV_REG_QUOTE        = 42,
1360     CV_REG_PCDR3        = 43,   /* this includes PCDR4 to PCDR7 */
1361     CV_REG_CR0          = 80,   /* this includes CR1 to CR4 */
1362     CV_REG_DR0          = 90,   /* this includes DR1 to DR7 */
1363     /* </pcode> */
1364 
1365     CV_REG_GDTR         = 110,
1366     CV_REG_GDTL         = 111,
1367     CV_REG_IDTR         = 112,
1368     CV_REG_IDTL         = 113,
1369     CV_REG_LDTR         = 114,
1370     CV_REG_TR           = 115,
1371 
1372     CV_REG_PSEUDO1      = 116, /* this includes Pseudo02 to Pseudo09 */
1373     CV_REG_ST0          = 128, /* this includes ST1 to ST7 */
1374     CV_REG_CTRL         = 136,
1375     CV_REG_STAT         = 137,
1376     CV_REG_TAG          = 138,
1377     CV_REG_FPIP         = 139,
1378     CV_REG_FPCS         = 140,
1379     CV_REG_FPDO         = 141,
1380     CV_REG_FPDS         = 142,
1381     CV_REG_ISEM         = 143,
1382     CV_REG_FPEIP        = 144,
1383     CV_REG_FPEDO        = 145,
1384     CV_REG_MM0          = 146, /* this includes MM1 to MM7 */
1385     CV_REG_XMM0         = 154, /* this includes XMM1 to XMM7 */
1386     CV_REG_XMM00        = 162,
1387     CV_REG_XMM0L        = 194, /* this includes XMM1L to XMM7L */
1388     CV_REG_XMM0H        = 202, /* this includes XMM1H to XMM7H */
1389     CV_REG_MXCSR        = 211,
1390     CV_REG_EDXEAX       = 212,
1391     CV_REG_EMM0L        = 220,
1392     CV_REG_EMM0H        = 228,
1393     CV_REG_MM00         = 236,
1394     CV_REG_MM01         = 237,
1395     CV_REG_MM10         = 238,
1396     CV_REG_MM11         = 239,
1397     CV_REG_MM20         = 240,
1398     CV_REG_MM21         = 241,
1399     CV_REG_MM30         = 242,
1400     CV_REG_MM31         = 243,
1401     CV_REG_MM40         = 244,
1402     CV_REG_MM41         = 245,
1403     CV_REG_MM50         = 246,
1404     CV_REG_MM51         = 247,
1405     CV_REG_MM60         = 248,
1406     CV_REG_MM61         = 249,
1407     CV_REG_MM70         = 250,
1408     CV_REG_MM71         = 251,
1409 
1410     CV_REG_YMM0         = 252, /* this includes YMM1 to YMM7 */
1411     CV_REG_YMM0H        = 260, /* this includes YMM1H to YMM7H */
1412     CV_REG_YMM0I0       = 268, /* this includes YMM0I1 to YMM0I3 */
1413     CV_REG_YMM1I0       = 272, /* this includes YMM1I1 to YMM1I3 */
1414     CV_REG_YMM2I0       = 276, /* this includes YMM2I1 to YMM2I3 */
1415     CV_REG_YMM3I0       = 280, /* this includes YMM3I1 to YMM3I3 */
1416     CV_REG_YMM4I0       = 284, /* this includes YMM4I1 to YMM4I3 */
1417     CV_REG_YMM5I0       = 288, /* this includes YMM5I1 to YMM5I3 */
1418     CV_REG_YMM6I0       = 292, /* this includes YMM6I1 to YMM6I3 */
1419     CV_REG_YMM7I0       = 296, /* this includes YMM7I1 to YMM7I3 */
1420     CV_REG_YMM0F0       = 300, /* this includes YMM0F1 to YMM0F7 */
1421     CV_REG_YMM1F0       = 308, /* this includes YMM1F1 to YMM1F7 */
1422     CV_REG_YMM2F0       = 316, /* this includes YMM2F1 to YMM2F7 */
1423     CV_REG_YMM3F0       = 324, /* this includes YMM3F1 to YMM3F7 */
1424     CV_REG_YMM4F0       = 332, /* this includes YMM4F1 to YMM4F7 */
1425     CV_REG_YMM5F0       = 340, /* this includes YMM5F1 to YMM5F7 */
1426     CV_REG_YMM6F0       = 348, /* this includes YMM6F1 to YMM6F7 */
1427     CV_REG_YMM7F0       = 356, /* this includes YMM7F1 to YMM7F7 */
1428     CV_REG_YMM0D0       = 364, /* this includes YMM0D1 to YMM0D3 */
1429     CV_REG_YMM1D0       = 368, /* this includes YMM1D1 to YMM1D3 */
1430     CV_REG_YMM2D0       = 372, /* this includes YMM2D1 to YMM2D3 */
1431     CV_REG_YMM3D0       = 376, /* this includes YMM3D1 to YMM3D3 */
1432     CV_REG_YMM4D0       = 380, /* this includes YMM4D1 to YMM4D3 */
1433     CV_REG_YMM5D0       = 384, /* this includes YMM5D1 to YMM5D3 */
1434     CV_REG_YMM6D0       = 388, /* this includes YMM6D1 to YMM6D3 */
1435     CV_REG_YMM7D0       = 392, /* this includes YMM7D1 to YMM7D3 */
1436 
1437     /* Motorola 68K CPU */
1438     CV_R68_D0           = 0, /* this includes D1 to D7 too */
1439     CV_R68_A0           = 8, /* this includes A1 to A7 too */
1440     CV_R68_CCR          = 16,
1441     CV_R68_SR           = 17,
1442     CV_R68_USP          = 18,
1443     CV_R68_MSP          = 19,
1444     CV_R68_SFC          = 20,
1445     CV_R68_DFC          = 21,
1446     CV_R68_CACR         = 22,
1447     CV_R68_VBR          = 23,
1448     CV_R68_CAAR         = 24,
1449     CV_R68_ISP          = 25,
1450     CV_R68_PC           = 26,
1451     CV_R68_FPCR         = 28,
1452     CV_R68_FPSR         = 29,
1453     CV_R68_FPIAR        = 30,
1454     CV_R68_FP0          = 32, /* this includes FP1 to FP7 */
1455     CV_R68_MMUSR030     = 41,
1456     CV_R68_MMUSR        = 42,
1457     CV_R68_URP          = 43,
1458     CV_R68_DTT0         = 44,
1459     CV_R68_DTT1         = 45,
1460     CV_R68_ITT0         = 46,
1461     CV_R68_ITT1         = 47,
1462     CV_R68_PSR          = 51,
1463     CV_R68_PCSR         = 52,
1464     CV_R68_VAL          = 53,
1465     CV_R68_CRP          = 54,
1466     CV_R68_SRP          = 55,
1467     CV_R68_DRP          = 56,
1468     CV_R68_TC           = 57,
1469     CV_R68_AC           = 58,
1470     CV_R68_SCC          = 59,
1471     CV_R68_CAL          = 60,
1472     CV_R68_TT0          = 61,
1473     CV_R68_TT1          = 62,
1474     CV_R68_BAD0         = 64, /* this includes BAD1 to BAD7 */
1475     CV_R68_BAC0         = 72, /* this includes BAC1 to BAC7 */
1476 
1477     /* MIPS 4000 CPU */
1478     CV_M4_NOREG         = CV_REG_NONE,
1479     CV_M4_IntZERO       = 10,
1480     CV_M4_IntAT         = 11,
1481     CV_M4_IntV0         = 12,
1482     CV_M4_IntV1         = 13,
1483     CV_M4_IntA0         = 14, /* this includes IntA1 to IntA3 */
1484     CV_M4_IntT0         = 18, /* this includes IntT1 to IntT7 */
1485     CV_M4_IntS0         = 26, /* this includes IntS1 to IntS7 */
1486     CV_M4_IntT8         = 34,
1487     CV_M4_IntT9         = 35,
1488     CV_M4_IntKT0        = 36,
1489     CV_M4_IntKT1        = 37,
1490     CV_M4_IntGP         = 38,
1491     CV_M4_IntSP         = 39,
1492     CV_M4_IntS8         = 40,
1493     CV_M4_IntRA         = 41,
1494     CV_M4_IntLO         = 42,
1495     CV_M4_IntHI         = 43,
1496     CV_M4_Fir           = 50,
1497     CV_M4_Psr           = 51,
1498     CV_M4_FltF0         = 60, /* this includes FltF1 to Flt31 */
1499     CV_M4_FltFsr        = 92,
1500 
1501     /* Alpha AXP CPU */
1502     CV_ALPHA_NOREG      = CV_REG_NONE,
1503     CV_ALPHA_FltF0      = 10, /* this includes FltF1 to FltF31 */
1504     CV_ALPHA_IntV0      = 42,
1505     CV_ALPHA_IntT0      = 43, /* this includes T1 to T7 */
1506     CV_ALPHA_IntS0      = 51, /* this includes S1 to S5 */
1507     CV_ALPHA_IntFP      = 57,
1508     CV_ALPHA_IntA0      = 58, /* this includes A1 to A5 */
1509     CV_ALPHA_IntT8      = 64,
1510     CV_ALPHA_IntT9      = 65,
1511     CV_ALPHA_IntT10     = 66,
1512     CV_ALPHA_IntT11     = 67,
1513     CV_ALPHA_IntRA      = 68,
1514     CV_ALPHA_IntT12     = 69,
1515     CV_ALPHA_IntAT      = 70,
1516     CV_ALPHA_IntGP      = 71,
1517     CV_ALPHA_IntSP      = 72,
1518     CV_ALPHA_IntZERO    = 73,
1519     CV_ALPHA_Fpcr       = 74,
1520     CV_ALPHA_Fir        = 75,
1521     CV_ALPHA_Psr        = 76,
1522     CV_ALPHA_FltFsr     = 77,
1523     CV_ALPHA_SoftFpcr   = 78,
1524 
1525     /* Motorola & IBM PowerPC CPU */
1526     CV_PPC_GPR0         = 1, /* this includes GPR1 to GPR31 */
1527     CV_PPC_CR           = 33,
1528     CV_PPC_CR0          = 34, /* this includes CR1 to CR7 */
1529     CV_PPC_FPR0         = 42, /* this includes FPR1 to FPR31 */
1530 
1531     CV_PPC_FPSCR        = 74,
1532     CV_PPC_MSR          = 75,
1533     CV_PPC_SR0          = 76, /* this includes SR1 to SR15 */
1534     CV_PPC_PC           = 99,
1535     CV_PPC_MQ           = 100,
1536     CV_PPC_XER          = 101,
1537     CV_PPC_RTCU         = 104,
1538     CV_PPC_RTCL         = 105,
1539     CV_PPC_LR           = 108,
1540     CV_PPC_CTR          = 109,
1541     CV_PPC_COMPARE      = 110,
1542     CV_PPC_COUNT        = 111,
1543     CV_PPC_DSISR        = 118,
1544     CV_PPC_DAR          = 119,
1545     CV_PPC_DEC          = 122,
1546     CV_PPC_SDR1         = 125,
1547     CV_PPC_SRR0         = 126,
1548     CV_PPC_SRR1         = 127,
1549     CV_PPC_SPRG0        = 372, /* this includes SPRG1 to SPRG3 */
1550     CV_PPC_ASR          = 280,
1551     CV_PPC_EAR          = 382,
1552     CV_PPC_PVR          = 287,
1553     CV_PPC_BAT0U        = 628,
1554     CV_PPC_BAT0L        = 629,
1555     CV_PPC_BAT1U        = 630,
1556     CV_PPC_BAT1L        = 631,
1557     CV_PPC_BAT2U        = 632,
1558     CV_PPC_BAT2L        = 633,
1559     CV_PPC_BAT3U        = 634,
1560     CV_PPC_BAT3L        = 635,
1561     CV_PPC_DBAT0U       = 636,
1562     CV_PPC_DBAT0L       = 637,
1563     CV_PPC_DBAT1U       = 638,
1564     CV_PPC_DBAT1L       = 639,
1565     CV_PPC_DBAT2U       = 640,
1566     CV_PPC_DBAT2L       = 641,
1567     CV_PPC_DBAT3U       = 642,
1568     CV_PPC_DBAT3L       = 643,
1569     CV_PPC_PMR0         = 1044, /* this includes PMR1 to PMR15 */
1570     CV_PPC_DMISS        = 1076,
1571     CV_PPC_DCMP         = 1077,
1572     CV_PPC_HASH1        = 1078,
1573     CV_PPC_HASH2        = 1079,
1574     CV_PPC_IMISS        = 1080,
1575     CV_PPC_ICMP         = 1081,
1576     CV_PPC_RPA          = 1082,
1577     CV_PPC_HID0         = 1108, /* this includes HID1 to HID15 */
1578 
1579     /* Java */
1580     CV_JAVA_PC          = 1,
1581 
1582     /* Hitachi SH3 CPU */
1583     CV_SH3_NOREG        = CV_REG_NONE,
1584     CV_SH3_IntR0        = 10, /* this include R1 to R13 */
1585     CV_SH3_IntFp        = 24,
1586     CV_SH3_IntSp        = 25,
1587     CV_SH3_Gbr          = 38,
1588     CV_SH3_Pr           = 39,
1589     CV_SH3_Mach         = 40,
1590     CV_SH3_Macl         = 41,
1591     CV_SH3_Pc           = 50,
1592     CV_SH3_Sr           = 51,
1593     CV_SH3_BarA         = 60,
1594     CV_SH3_BasrA        = 61,
1595     CV_SH3_BamrA        = 62,
1596     CV_SH3_BbrA         = 63,
1597     CV_SH3_BarB         = 64,
1598     CV_SH3_BasrB        = 65,
1599     CV_SH3_BamrB        = 66,
1600     CV_SH3_BbrB         = 67,
1601     CV_SH3_BdrB         = 68,
1602     CV_SH3_BdmrB        = 69,
1603     CV_SH3_Brcr         = 70,
1604     CV_SH_Fpscr         = 75,
1605     CV_SH_Fpul          = 76,
1606     CV_SH_FpR0          = 80, /* this includes FpR1 to FpR15 */
1607     CV_SH_XFpR0         = 96, /* this includes XFpR1 to XXFpR15 */
1608 
1609     /* ARM CPU */
1610     CV_ARM_NOREG        = CV_REG_NONE,
1611     CV_ARM_R0           = 10, /* this includes R1 to R12 */
1612     CV_ARM_SP           = 23,
1613     CV_ARM_LR           = 24,
1614     CV_ARM_PC           = 25,
1615     CV_ARM_CPSR         = 26,
1616     CV_ARM_ACC0         = 27,
1617     CV_ARM_FPSCR        = 40,
1618     CV_ARM_FPEXC        = 41,
1619     CV_ARM_FS0          = 50, /* this includes FS1 to FS31 */
1620     CV_ARM_FPEXTRA0     = 90, /* this includes FPEXTRA1 to FPEXTRA7 */
1621     CV_ARM_WR0          = 128, /* this includes WR1 to WR15 */
1622     CV_ARM_WCID         = 144,
1623     CV_ARM_WCON         = 145,
1624     CV_ARM_WCSSF        = 146,
1625     CV_ARM_WCASF        = 147,
1626     CV_ARM_WC4          = 148,
1627     CV_ARM_WC5          = 149,
1628     CV_ARM_WC6          = 150,
1629     CV_ARM_WC7          = 151,
1630     CV_ARM_WCGR0        = 152, /* this includes WCGR1 to WCGR3 */
1631     CV_ARM_WC12         = 156,
1632     CV_ARM_WC13         = 157,
1633     CV_ARM_WC14         = 158,
1634     CV_ARM_WC15         = 159,
1635     CV_ARM_FS32         = 200, /* this includes FS33 to FS63 */
1636     CV_ARM_ND0          = 300, /* this includes ND1 to ND31 */
1637     CV_ARM_NQ0          = 400, /* this includes NQ1 to NQ15 */
1638 
1639     /* Intel IA64 CPU */
1640     CV_IA64_NOREG       = CV_REG_NONE,
1641     CV_IA64_Br0         = 512, /* this includes Br1 to Br7 */
1642     CV_IA64_P0          = 704, /* this includes P1 to P63 */
1643     CV_IA64_Preds       = 768,
1644     CV_IA64_IntH0       = 832, /* this includes H1 to H15 */
1645     CV_IA64_Ip          = 1016,
1646     CV_IA64_Umask       = 1017,
1647     CV_IA64_Cfm         = 1018,
1648     CV_IA64_Psr         = 1019,
1649     CV_IA64_Nats        = 1020,
1650     CV_IA64_Nats2       = 1021,
1651     CV_IA64_Nats3       = 1022,
1652     CV_IA64_IntR0       = 1024, /* this includes R1 to R127 */
1653     CV_IA64_FltF0       = 2048, /* this includes FltF1 to FltF127 */
1654     /* some IA64 registers missing */
1655 
1656     /* TriCore CPU */
1657     CV_TRI_NOREG        = CV_REG_NONE,
1658     CV_TRI_D0           = 10, /* includes D1 to D15 */
1659     CV_TRI_A0           = 26, /* includes A1 to A15 */
1660     CV_TRI_E0           = 42,
1661     CV_TRI_E2           = 43,
1662     CV_TRI_E4           = 44,
1663     CV_TRI_E6           = 45,
1664     CV_TRI_E8           = 46,
1665     CV_TRI_E10          = 47,
1666     CV_TRI_E12          = 48,
1667     CV_TRI_E14          = 49,
1668     CV_TRI_EA0          = 50,
1669     CV_TRI_EA2          = 51,
1670     CV_TRI_EA4          = 52,
1671     CV_TRI_EA6          = 53,
1672     CV_TRI_EA8          = 54,
1673     CV_TRI_EA10         = 55,
1674     CV_TRI_EA12         = 56,
1675     CV_TRI_EA14         = 57,
1676     CV_TRI_PSW          = 58,
1677     CV_TRI_PCXI         = 59,
1678     CV_TRI_PC           = 60,
1679     CV_TRI_FCX          = 61,
1680     CV_TRI_LCX          = 62,
1681     CV_TRI_ISP          = 63,
1682     CV_TRI_ICR          = 64,
1683     CV_TRI_BIV          = 65,
1684     CV_TRI_BTV          = 66,
1685     CV_TRI_SYSCON       = 67,
1686     CV_TRI_DPRx_0       = 68, /* includes DPRx_1 to DPRx_3 */
1687     CV_TRI_CPRx_0       = 68, /* includes CPRx_1 to CPRx_3 */
1688     CV_TRI_DPMx_0       = 68, /* includes DPMx_1 to DPMx_3 */
1689     CV_TRI_CPMx_0       = 68, /* includes CPMx_1 to CPMx_3 */
1690     CV_TRI_DBGSSR       = 72,
1691     CV_TRI_EXEVT        = 73,
1692     CV_TRI_SWEVT        = 74,
1693     CV_TRI_CREVT        = 75,
1694     CV_TRI_TRnEVT       = 76,
1695     CV_TRI_MMUCON       = 77,
1696     CV_TRI_ASI          = 78,
1697     CV_TRI_TVA          = 79,
1698     CV_TRI_TPA          = 80,
1699     CV_TRI_TPX          = 81,
1700     CV_TRI_TFA          = 82,
1701 
1702     /* AM33 (and the likes) CPU */
1703     CV_AM33_NOREG       = CV_REG_NONE,
1704     CV_AM33_E0          = 10, /* this includes E1 to E7 */
1705     CV_AM33_A0          = 20, /* this includes A1 to A3 */
1706     CV_AM33_D0          = 30, /* this includes D1 to D3 */
1707     CV_AM33_FS0         = 40, /* this includes FS1 to FS31 */
1708     CV_AM33_SP          = 80,
1709     CV_AM33_PC          = 81,
1710     CV_AM33_MDR         = 82,
1711     CV_AM33_MDRQ        = 83,
1712     CV_AM33_MCRH        = 84,
1713     CV_AM33_MCRL        = 85,
1714     CV_AM33_MCVF        = 86,
1715     CV_AM33_EPSW        = 87,
1716     CV_AM33_FPCR        = 88,
1717     CV_AM33_LIR         = 89,
1718     CV_AM33_LAR         = 90,
1719 
1720     /* Mitsubishi M32R CPU */
1721     CV_M32R_NOREG       = CV_REG_NONE,
1722     CV_M32R_R0          = 10, /* this includes R1 to R11 */
1723     CV_M32R_R12         = 22,
1724     CV_M32R_R13         = 23,
1725     CV_M32R_R14         = 24,
1726     CV_M32R_R15         = 25,
1727     CV_M32R_PSW         = 26,
1728     CV_M32R_CBR         = 27,
1729     CV_M32R_SPI         = 28,
1730     CV_M32R_SPU         = 29,
1731     CV_M32R_SPO         = 30,
1732     CV_M32R_BPC         = 31,
1733     CV_M32R_ACHI        = 32,
1734     CV_M32R_ACLO        = 33,
1735     CV_M32R_PC          = 34,
1736 
1737     /* AMD/Intel x86_64 CPU */
1738     CV_AMD64_NONE       = CV_REG_NONE,
1739     CV_AMD64_AL         = CV_REG_AL,
1740     CV_AMD64_CL         = CV_REG_CL,
1741     CV_AMD64_DL         = CV_REG_DL,
1742     CV_AMD64_BL         = CV_REG_BL,
1743     CV_AMD64_AH         = CV_REG_AH,
1744     CV_AMD64_CH         = CV_REG_CH,
1745     CV_AMD64_DH         = CV_REG_DH,
1746     CV_AMD64_BH         = CV_REG_BH,
1747     CV_AMD64_AX         = CV_REG_AX,
1748     CV_AMD64_CX         = CV_REG_CX,
1749     CV_AMD64_DX         = CV_REG_DX,
1750     CV_AMD64_BX         = CV_REG_BX,
1751     CV_AMD64_SP         = CV_REG_SP,
1752     CV_AMD64_BP         = CV_REG_BP,
1753     CV_AMD64_SI         = CV_REG_SI,
1754     CV_AMD64_DI         = CV_REG_DI,
1755     CV_AMD64_EAX        = CV_REG_EAX,
1756     CV_AMD64_ECX        = CV_REG_ECX,
1757     CV_AMD64_EDX        = CV_REG_EDX,
1758     CV_AMD64_EBX        = CV_REG_EBX,
1759     CV_AMD64_ESP        = CV_REG_ESP,
1760     CV_AMD64_EBP        = CV_REG_EBP,
1761     CV_AMD64_ESI        = CV_REG_ESI,
1762     CV_AMD64_EDI        = CV_REG_EDI,
1763     CV_AMD64_ES         = CV_REG_ES,
1764     CV_AMD64_CS         = CV_REG_CS,
1765     CV_AMD64_SS         = CV_REG_SS,
1766     CV_AMD64_DS         = CV_REG_DS,
1767     CV_AMD64_FS         = CV_REG_FS,
1768     CV_AMD64_GS         = CV_REG_GS,
1769     CV_AMD64_FLAGS      = CV_REG_FLAGS,
1770     CV_AMD64_RIP        = CV_REG_EIP,
1771     CV_AMD64_EFLAGS     = CV_REG_EFLAGS,
1772 
1773     /* <pcode> */
1774     CV_AMD64_TEMP       = CV_REG_TEMP,
1775     CV_AMD64_TEMPH      = CV_REG_TEMPH,
1776     CV_AMD64_QUOTE      = CV_REG_QUOTE,
1777     CV_AMD64_PCDR3      = CV_REG_PCDR3, /* this includes PCDR4 to PCDR7 */
1778     CV_AMD64_CR0        = CV_REG_CR0,   /* this includes CR1 to CR4 */
1779     CV_AMD64_DR0        = CV_REG_DR0,   /* this includes DR1 to DR7 */
1780     /* </pcode> */
1781 
1782     CV_AMD64_GDTR       = CV_REG_GDTR,
1783     CV_AMD64_GDTL       = CV_REG_GDTL,
1784     CV_AMD64_IDTR       = CV_REG_IDTR,
1785     CV_AMD64_IDTL       = CV_REG_IDTL,
1786     CV_AMD64_LDTR       = CV_REG_LDTR,
1787     CV_AMD64_TR         = CV_REG_TR,
1788 
1789     CV_AMD64_PSEUDO1    = CV_REG_PSEUDO1, /* this includes Pseudo02 to Pseudo09 */
1790     CV_AMD64_ST0        = CV_REG_ST0,     /* this includes ST1 to ST7 */
1791     CV_AMD64_CTRL       = CV_REG_CTRL,
1792     CV_AMD64_STAT       = CV_REG_STAT,
1793     CV_AMD64_TAG        = CV_REG_TAG,
1794     CV_AMD64_FPIP       = CV_REG_FPIP,
1795     CV_AMD64_FPCS       = CV_REG_FPCS,
1796     CV_AMD64_FPDO       = CV_REG_FPDO,
1797     CV_AMD64_FPDS       = CV_REG_FPDS,
1798     CV_AMD64_ISEM       = CV_REG_ISEM,
1799     CV_AMD64_FPEIP      = CV_REG_FPEIP,
1800     CV_AMD64_FPEDO      = CV_REG_FPEDO,
1801     CV_AMD64_MM0        = CV_REG_MM0,     /* this includes MM1 to MM7 */
1802     CV_AMD64_XMM0       = CV_REG_XMM0,    /* this includes XMM1 to XMM7 */
1803     CV_AMD64_XMM00      = CV_REG_XMM00,
1804     CV_AMD64_XMM0L      = CV_REG_XMM0L,   /* this includes XMM1L to XMM7L */
1805     CV_AMD64_XMM0H      = CV_REG_XMM0H,   /* this includes XMM1H to XMM7H */
1806     CV_AMD64_MXCSR      = CV_REG_MXCSR,
1807     CV_AMD64_EDXEAX     = CV_REG_EDXEAX,
1808     CV_AMD64_EMM0L      = CV_REG_EMM0L,
1809     CV_AMD64_EMM0H      = CV_REG_EMM0H,
1810     CV_AMD64_MM00       = CV_REG_MM00,
1811     CV_AMD64_MM01       = CV_REG_MM01,
1812     CV_AMD64_MM10       = CV_REG_MM10,
1813     CV_AMD64_MM11       = CV_REG_MM11,
1814     CV_AMD64_MM20       = CV_REG_MM20,
1815     CV_AMD64_MM21       = CV_REG_MM21,
1816     CV_AMD64_MM30       = CV_REG_MM30,
1817     CV_AMD64_MM31       = CV_REG_MM31,
1818     CV_AMD64_MM40       = CV_REG_MM40,
1819     CV_AMD64_MM41       = CV_REG_MM41,
1820     CV_AMD64_MM50       = CV_REG_MM50,
1821     CV_AMD64_MM51       = CV_REG_MM51,
1822     CV_AMD64_MM60       = CV_REG_MM60,
1823     CV_AMD64_MM61       = CV_REG_MM61,
1824     CV_AMD64_MM70       = CV_REG_MM70,
1825     CV_AMD64_MM71       = CV_REG_MM71,
1826 
1827     CV_AMD64_XMM8       = 252,           /* this includes XMM9 to XMM15 */
1828 
1829     CV_AMD64_RAX        = 328,
1830     CV_AMD64_RBX        = 329,
1831     CV_AMD64_RCX        = 330,
1832     CV_AMD64_RDX        = 331,
1833     CV_AMD64_RSI        = 332,
1834     CV_AMD64_RDI        = 333,
1835     CV_AMD64_RBP        = 334,
1836     CV_AMD64_RSP        = 335,
1837 
1838     CV_AMD64_R8         = 336,
1839     CV_AMD64_R9         = 337,
1840     CV_AMD64_R10        = 338,
1841     CV_AMD64_R11        = 339,
1842     CV_AMD64_R12        = 340,
1843     CV_AMD64_R13        = 341,
1844     CV_AMD64_R14        = 342,
1845     CV_AMD64_R15        = 343,
1846 
1847     /* Wine extension */
1848     CV_ARM64_NOREG        = CV_REG_NONE,
1849     CV_ARM64_X0           = 10, /* this includes X0 to X30 */
1850     CV_ARM64_SP           = 41,
1851     CV_ARM64_PC           = 42,
1852     CV_ARM64_PSTATE       = 43,
1853 };
1854 
1855 typedef enum
1856 {
1857    THUNK_ORDINAL_NOTYPE,
1858    THUNK_ORDINAL_ADJUSTOR,
1859    THUNK_ORDINAL_VCALL,
1860    THUNK_ORDINAL_PCODE,
1861    THUNK_ORDINAL_LOAD
1862 } THUNK_ORDINAL;
1863 
1864 typedef enum CV_call_e
1865 {
1866     CV_CALL_NEAR_C,
1867     CV_CALL_FAR_C,
1868     CV_CALL_NEAR_PASCAL,
1869     CV_CALL_FAR_PASCAL,
1870     CV_CALL_NEAR_FAST,
1871     CV_CALL_FAR_FAST,
1872     CV_CALL_SKIPPED,
1873     CV_CALL_NEAR_STD,
1874     CV_CALL_FAR_STD,
1875     CV_CALL_NEAR_SYS,
1876     CV_CALL_FAR_SYS,
1877     CV_CALL_THISCALL,
1878     CV_CALL_MIPSCALL,
1879     CV_CALL_GENERIC,
1880     CV_CALL_ALPHACALL,
1881     CV_CALL_PPCCALL,
1882     CV_CALL_SHCALL,
1883     CV_CALL_ARMCALL,
1884     CV_CALL_AM33CALL,
1885     CV_CALL_TRICALL,
1886     CV_CALL_SH5CALL,
1887     CV_CALL_M32RCALL,
1888     CV_CALL_RESERVED,
1889 } CV_call_e;
1890 
1891 
1892 // wtypes.h
1893 typedef LONG SCODE;
1894 typedef double DATE;
1895 typedef unsigned short VARTYPE;
1896 typedef union tagCY {
1897     struct {
1898 #ifdef WORDS_BIGENDIAN
1899         LONG  Hi;
1900         ULONG Lo;
1901 #else
1902         ULONG Lo;
1903         LONG  Hi;
1904 #endif
1905     } DUMMYSTRUCTNAME;
1906     LONGLONG int64;
1907 } CY;
1908 typedef struct tagDEC {
1909   USHORT wReserved;
1910   union {
1911     struct {
1912       BYTE scale;
1913       BYTE sign;
1914     } DUMMYSTRUCTNAME;
1915     USHORT signscale;
1916   } DUMMYUNIONNAME;
1917   ULONG Hi32;
1918   union {
1919     struct {
1920 #ifdef WORDS_BIGENDIAN
1921       ULONG Mid32;
1922       ULONG Lo32;
1923 #else
1924       ULONG Lo32;
1925       ULONG Mid32;
1926 #endif
1927     } DUMMYSTRUCTNAME1;
1928     ULONGLONG Lo64;
1929   } DUMMYUNIONNAME1;
1930 } DECIMAL;
1931 typedef short VARIANT_BOOL;
1932 typedef VARIANT_BOOL _VARIANT_BOOL;
1933 typedef WCHAR OLECHAR;
1934 typedef OLECHAR *BSTR;
1935 enum VARENUM {
1936     VT_EMPTY = 0,
1937     VT_NULL = 1,
1938     VT_I2 = 2,
1939     VT_I4 = 3,
1940     VT_R4 = 4,
1941     VT_R8 = 5,
1942     VT_CY = 6,
1943     VT_DATE = 7,
1944     VT_BSTR = 8,
1945     VT_DISPATCH = 9,
1946     VT_ERROR = 10,
1947     VT_BOOL = 11,
1948     VT_VARIANT = 12,
1949     VT_UNKNOWN = 13,
1950     VT_DECIMAL = 14,
1951     VT_I1 = 16,
1952     VT_UI1 = 17,
1953     VT_UI2 = 18,
1954     VT_UI4 = 19,
1955     VT_I8 = 20,
1956     VT_UI8 = 21,
1957     VT_INT = 22,
1958     VT_UINT = 23,
1959     VT_VOID = 24,
1960     VT_HRESULT = 25,
1961     VT_PTR = 26,
1962     VT_SAFEARRAY = 27,
1963     VT_CARRAY = 28,
1964     VT_USERDEFINED = 29,
1965     VT_LPSTR = 30,
1966     VT_LPWSTR = 31,
1967     VT_RECORD = 36,
1968     VT_INT_PTR = 37,
1969     VT_UINT_PTR = 38,
1970     VT_FILETIME = 64,
1971     VT_BLOB = 65,
1972     VT_STREAM = 66,
1973     VT_STORAGE = 67,
1974     VT_STREAMED_OBJECT = 68,
1975     VT_STORED_OBJECT = 69,
1976     VT_BLOB_OBJECT = 70,
1977     VT_CF = 71,
1978     VT_CLSID = 72,
1979     VT_VERSIONED_STREAM = 73,
1980     VT_BSTR_BLOB = 0xfff,
1981     VT_VECTOR = 0x1000,
1982     VT_ARRAY = 0x2000,
1983     VT_BYREF = 0x4000,
1984     VT_RESERVED = 0x8000,
1985     VT_ILLEGAL = 0xffff,
1986     VT_ILLEGALMASKED = 0xfff,
1987     VT_TYPEMASK = 0xfff
1988 };
1989 
1990 // oaidl.h
1991 typedef struct tagSAFEARRAYBOUND {
1992     ULONG cElements;
1993     LONG lLbound;
1994 } SAFEARRAYBOUND;
1995 typedef struct tagSAFEARRAY {
1996     USHORT cDims;
1997     USHORT fFeatures;
1998     ULONG cbElements;
1999     ULONG cLocks;
2000     PVOID pvData;
2001     SAFEARRAYBOUND rgsabound[1];
2002 } SAFEARRAY;
2003 typedef SAFEARRAY *LPSAFEARRAY;
2004 
2005 #if (__STDC__ && !defined(_FORCENAMELESSUNION)) || defined(NONAMELESSUNION)
2006 #define __VARIANT_NAME_1 n1
2007 #define __VARIANT_NAME_2 n2
2008 #define __VARIANT_NAME_3 n3
2009 #define __VARIANT_NAME_4 brecVal
2010 #else
2011 #define __tagVARIANT
2012 #define __VARIANT_NAME_1
2013 #define __VARIANT_NAME_2
2014 #define __VARIANT_NAME_3
2015 #define __tagBRECORD
2016 #define __VARIANT_NAME_4
2017 #endif
2018 typedef struct tagVARIANT VARIANT;
2019 struct tagVARIANT {
2020     union {
2021         struct __tagVARIANT {
2022             VARTYPE vt;
2023             WORD wReserved1;
2024             WORD wReserved2;
2025             WORD wReserved3;
2026             union {
2027                 signed char cVal;
2028                 USHORT uiVal;
2029                 ULONG ulVal;
2030                 INT intVal;
2031                 UINT uintVal;
2032                 BYTE bVal;
2033                 SHORT iVal;
2034                 LONG lVal;
2035                 FLOAT fltVal;
2036                 DOUBLE dblVal;
2037                 VARIANT_BOOL boolVal;
2038                 SCODE scode;
2039                 DATE date;
2040                 BSTR bstrVal;
2041                 CY cyVal;
2042                 IUnknown *punkVal;
2043                 IDispatch *pdispVal;
2044                 SAFEARRAY *parray;
2045                 LONGLONG llVal;
2046                 ULONGLONG ullVal;
2047                 signed char *pcVal;
2048                 USHORT *puiVal;
2049                 ULONG *pulVal;
2050                 INT *pintVal;
2051                 UINT *puintVal;
2052                 BYTE *pbVal;
2053                 SHORT *piVal;
2054                 LONG *plVal;
2055                 FLOAT *pfltVal;
2056                 DOUBLE *pdblVal;
2057                 VARIANT_BOOL *pboolVal;
2058                 SCODE *pscode;
2059                 DATE *pdate;
2060                 BSTR *pbstrVal;
2061                 VARIANT *pvarVal;
2062                 PVOID byref;
2063                 CY *pcyVal;
2064                 DECIMAL *pdecVal;
2065                 IUnknown **ppunkVal;
2066                 IDispatch **ppdispVal;
2067                 SAFEARRAY **pparray;
2068                 LONGLONG *pllVal;
2069                 ULONGLONG *pullVal;
2070                 struct __tagBRECORD {
2071                     PVOID pvRecord;
2072                     IRecordInfo *pRecInfo;
2073                 } __VARIANT_NAME_4;
2074             } __VARIANT_NAME_3;
2075         } __VARIANT_NAME_2;
2076         DECIMAL decVal;
2077     } __VARIANT_NAME_1;
2078 };
2079 
2080 typedef VARIANT *LPVARIANT;
2081 typedef VARIANT VARIANTARG;
2082 typedef VARIANTARG *LPVARIANTARG;
2083 
2084 // wine/windef16.h
2085 typedef DWORD SEGPTR;
2086 
2087 // wine/winbase16.h
2088 typedef struct _STACK32FRAME
2089 {
2090     DWORD   restore_addr;   /* 00 return address for restoring code selector */
2091     DWORD   codeselector;   /* 04 code selector to restore */
2092     EXCEPTION_REGISTRATION_RECORD frame;  /* 08 Exception frame */
2093     SEGPTR  frame16;        /* 10 16-bit frame from last CallFrom16() */
2094     DWORD   edi;            /* 14 saved registers */
2095     DWORD   esi;            /* 18 */
2096     DWORD   ebx;            /* 1c */
2097     DWORD   ebp;            /* 20 saved 32-bit frame pointer */
2098     DWORD   retaddr;        /* 24 return address */
2099     DWORD   target;         /* 28 target address / CONTEXT86 pointer */
2100     DWORD   nb_args;        /* 2c number of 16-bit argument bytes */
2101 } STACK32FRAME;
2102 
2103 /* 16-bit stack layout after __wine_call_from_16() */
2104 typedef struct _STACK16FRAME
2105 {
2106     STACK32FRAME *frame32;        /* 00 32-bit frame from last CallTo16() */
2107     DWORD         edx;            /* 04 saved registers */
2108     DWORD         ecx;            /* 08 */
2109     DWORD         ebp;            /* 0c */
2110     WORD          ds;             /* 10 */
2111     WORD          es;             /* 12 */
2112     WORD          fs;             /* 14 */
2113     WORD          gs;             /* 16 */
2114     DWORD         callfrom_ip;    /* 18 callfrom tail IP */
2115     DWORD         module_cs;      /* 1c module code segment */
2116     DWORD         relay;          /* 20 relay function address */
2117     WORD          entry_ip;       /* 22 entry point IP */
2118     DWORD         entry_point;    /* 26 API entry point to call, reused as mutex count */
2119     WORD          bp;             /* 2a 16-bit stack frame chain */
2120     WORD          ip;             /* 2c return address */
2121     WORD          cs;             /* 2e */
2122 } STACK16FRAME;
2123