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