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