Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
xbt_swag: remove duplicated code.
[simgrid.git] / src / include / xbt / wine_dbghelp.h
1 /*
2  * Declarations for DBGHELP
3  *
4  * Copyright (C) 2003 Eric Pouech
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  * 
20  * We need this file in SimGrid when cross-compiling with gcc for the windows target.
21  */
22
23 #ifndef __WINE_DBGHELP_H
24 #define __WINE_DBGHELP_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif                          /* defined(__cplusplus) */
29
30 #define IMAGEAPI WINAPI
31 #define DBHLPAPI IMAGEAPI
32
33   typedef struct _LOADED_IMAGE {
34     PSTR ModuleName;
35     HANDLE hFile;
36     PUCHAR MappedAddress;
37     PIMAGE_NT_HEADERS FileHeader;
38     PIMAGE_SECTION_HEADER LastRvaSection;
39     ULONG NumberOfSections;
40     PIMAGE_SECTION_HEADER Sections;
41     ULONG Characteristics;
42     BOOLEAN fSystemImage;
43     BOOLEAN fDOSImage;
44     BOOLEAN fReadOnly;
45     UCHAR Version;
46     LIST_ENTRY Links;
47     ULONG SizeOfImage;
48   } LOADED_IMAGE, *PLOADED_IMAGE;
49
50 /*************************
51  *    IMAGEHLP equiv     *
52  *************************/
53
54   typedef enum {
55     AddrMode1616,
56     AddrMode1632,
57     AddrModeReal,
58     AddrModeFlat
59   } ADDRESS_MODE;
60
61   typedef struct _tagADDRESS {
62     DWORD Offset;
63     WORD Segment;
64     ADDRESS_MODE Mode;
65   } ADDRESS, *LPADDRESS;
66
67   typedef struct _tagADDRESS64 {
68     DWORD64 Offset;
69     WORD Segment;
70     ADDRESS_MODE Mode;
71   } ADDRESS64, *LPADDRESS64;
72
73 #define SYMF_OMAP_GENERATED   0x00000001
74 #define SYMF_OMAP_MODIFIED    0x00000002
75 #define SYMF_USER_GENERATED   0x00000004
76 #define SYMF_REGISTER         0x00000008
77 #define SYMF_REGREL           0x00000010
78 #define SYMF_FRAMEREL         0x00000020
79 #define SYMF_PARAMETER        0x00000040
80 #define SYMF_LOCAL            0x00000080
81 #define SYMF_CONSTANT         0x00000100
82 #define SYMF_EXPORT           0x00000200
83 #define SYMF_FORWARDER        0x00000400
84 #define SYMF_FUNCTION         0x00000800
85 #define SYMF_VIRTUAL          0x00001000
86 #define SYMF_THUNK            0x00002000
87 #define SYMF_TLSREL           0x00004000
88
89   typedef enum {
90     SymNone = 0,
91     SymCoff,
92     SymCv,
93     SymPdb,
94     SymExport,
95     SymDeferred,
96     SymSym,
97     SymDia,
98     SymVirtual,
99     NumSymTypes
100   } SYM_TYPE;
101
102   typedef struct _IMAGEHLP_SYMBOL {
103     DWORD SizeOfStruct;
104     DWORD Address;
105     DWORD Size;
106     DWORD Flags;
107     DWORD MaxNameLength;
108     CHAR Name[1];
109   } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
110
111   typedef struct _IMAGEHLP_SYMBOL64 {
112     DWORD SizeOfStruct;
113     DWORD64 Address;
114     DWORD Size;
115     DWORD Flags;
116     DWORD MaxNameLength;
117     CHAR Name[1];
118   } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
119
120   typedef struct _IMAGEHLP_SYMBOLW64 {
121     DWORD SizeOfStruct;
122     DWORD64 Address;
123     DWORD Size;
124     DWORD Flags;
125     DWORD MaxNameLength;
126     WCHAR Name[1];
127   } IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64;
128
129   typedef struct _IMAGEHLP_MODULE {
130     DWORD SizeOfStruct;
131     DWORD BaseOfImage;
132     DWORD ImageSize;
133     DWORD TimeDateStamp;
134     DWORD CheckSum;
135     DWORD NumSyms;
136     SYM_TYPE SymType;
137     CHAR ModuleName[32];
138     CHAR ImageName[256];
139     CHAR LoadedImageName[256];
140   } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
141
142   typedef struct _IMAGEHLP_MODULEW {
143     DWORD SizeOfStruct;
144     DWORD BaseOfImage;
145     DWORD ImageSize;
146     DWORD TimeDateStamp;
147     DWORD CheckSum;
148     DWORD NumSyms;
149     SYM_TYPE SymType;
150     WCHAR ModuleName[32];
151     WCHAR ImageName[256];
152     WCHAR LoadedImageName[256];
153   } IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
154
155   typedef struct _IMAGEHLP_MODULE64 {
156     DWORD SizeOfStruct;
157     DWORD64 BaseOfImage;
158     DWORD ImageSize;
159     DWORD TimeDateStamp;
160     DWORD CheckSum;
161     DWORD NumSyms;
162     SYM_TYPE SymType;
163     CHAR ModuleName[32];
164     CHAR ImageName[256];
165     CHAR LoadedImageName[256];
166     CHAR LoadedPdbName[256];
167     DWORD CVSig;
168     CHAR CVData[MAX_PATH * 3];
169     DWORD PdbSig;
170     GUID PdbSig70;
171     DWORD PdbAge;
172     BOOL PdbUnmatched;
173     BOOL DbgUnmatched;
174     BOOL LineNumbers;
175     BOOL GlobalSymbols;
176     BOOL TypeInfo;
177     BOOL SourceIndexed;
178     BOOL Publics;
179   } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
180
181   typedef struct _IMAGEHLP_MODULEW64 {
182     DWORD SizeOfStruct;
183     DWORD64 BaseOfImage;
184     DWORD ImageSize;
185     DWORD TimeDateStamp;
186     DWORD CheckSum;
187     DWORD NumSyms;
188     SYM_TYPE SymType;
189     WCHAR ModuleName[32];
190     WCHAR ImageName[256];
191     WCHAR LoadedImageName[256];
192     WCHAR LoadedPdbName[256];
193     DWORD CVSig;
194     WCHAR CVData[MAX_PATH * 3];
195     DWORD PdbSig;
196     GUID PdbSig70;
197     DWORD PdbAge;
198     BOOL PdbUnmatched;
199     BOOL DbgUnmatched;
200     BOOL LineNumbers;
201     BOOL GlobalSymbols;
202     BOOL TypeInfo;
203     BOOL SourceIndexed;
204     BOOL Publics;
205   } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
206
207   typedef struct _IMAGEHLP_LINE {
208     DWORD SizeOfStruct;
209     PVOID Key;
210     DWORD LineNumber;
211     PCHAR FileName;
212     DWORD Address;
213   } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
214
215   typedef struct _IMAGEHLP_LINEW {
216     DWORD SizeOfStruct;
217     PVOID Key;
218     DWORD LineNumber;
219     PWSTR FileName;
220     DWORD Address;
221   } IMAGEHLP_LINEW, *PIMAGEHLP_LINEW;
222
223   typedef struct _IMAGEHLP_LINE64 {
224     DWORD SizeOfStruct;
225     PVOID Key;
226     DWORD LineNumber;
227     PCHAR FileName;
228     DWORD64 Address;
229   } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
230
231   typedef struct _IMAGEHLP_LINEW64 {
232     DWORD SizeOfStruct;
233     PVOID Key;
234     DWORD LineNumber;
235     PWSTR FileName;
236     DWORD64 Address;
237   } IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64;
238
239   typedef struct _SOURCEFILE {
240     DWORD64 ModBase;
241     PCHAR FileName;
242   } SOURCEFILE, *PSOURCEFILE;
243
244   typedef struct _SOURCEFILEW {
245     DWORD64 ModBase;
246     PWSTR FileName;
247   } SOURCEFILEW, *PSOURCEFILEW;
248
249 #define CBA_DEFERRED_SYMBOL_LOAD_START          0x00000001
250 #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE       0x00000002
251 #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE        0x00000003
252 #define CBA_SYMBOLS_UNLOADED                    0x00000004
253 #define CBA_DUPLICATE_SYMBOL                    0x00000005
254 #define CBA_READ_MEMORY                         0x00000006
255 #define CBA_DEFERRED_SYMBOL_LOAD_CANCEL         0x00000007
256 #define CBA_SET_OPTIONS                         0x00000008
257 #define CBA_EVENT                               0x00000010
258 #define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL        0x00000020
259 #define CBA_DEBUG_INFO                          0x10000000
260
261   typedef struct _IMAGEHLP_CBA_READ_MEMORY {
262     DWORD64 addr;
263     PVOID buf;
264     DWORD bytes;
265     DWORD *bytesread;
266   } IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;
267
268   enum {
269     sevInfo = 0,
270     sevProblem,
271     sevAttn,
272     sevFatal,
273     sevMax
274   };
275
276 #define EVENT_SRCSPEW_START 100
277 #define EVENT_SRCSPEW       100
278 #define EVENT_SRCSPEW_END   199
279
280   typedef struct _IMAGEHLP_CBA_EVENT {
281     DWORD severity;
282     DWORD code;
283     PCHAR desc;
284     PVOID object;
285   } IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT;
286
287   typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
288     DWORD SizeOfStruct;
289     DWORD BaseOfImage;
290     DWORD CheckSum;
291     DWORD TimeDateStamp;
292     CHAR FileName[MAX_PATH];
293     BOOLEAN Reparse;
294     HANDLE hFile;
295   } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
296
297   typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
298     DWORD SizeOfStruct;
299     DWORD64 BaseOfImage;
300     DWORD CheckSum;
301     DWORD TimeDateStamp;
302     CHAR FileName[MAX_PATH];
303     BOOLEAN Reparse;
304     HANDLE hFile;
305     DWORD Flags;
306   } IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
307
308   typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64 {
309     DWORD SizeOfStruct;
310     DWORD64 BaseOfImage;
311     DWORD CheckSum;
312     DWORD TimeDateStamp;
313     WCHAR FileName[MAX_PATH + 1];
314     BOOLEAN Reparse;
315     HANDLE hFile;
316     DWORD Flags;
317   } IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64;
318
319   typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
320     DWORD SizeOfStruct;
321     DWORD NumberOfDups;
322     PIMAGEHLP_SYMBOL Symbol;
323     DWORD SelectedSymbol;
324   } IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
325
326   typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
327     DWORD SizeOfStruct;
328     DWORD NumberOfDups;
329     PIMAGEHLP_SYMBOL64 Symbol;
330     DWORD SelectedSymbol;
331   } IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64;
332
333 #define SYMOPT_CASE_INSENSITIVE         0x00000001
334 #define SYMOPT_UNDNAME                  0x00000002
335 #define SYMOPT_DEFERRED_LOADS           0x00000004
336 #define SYMOPT_NO_CPP                   0x00000008
337 #define SYMOPT_LOAD_LINES               0x00000010
338 #define SYMOPT_OMAP_FIND_NEAREST        0x00000020
339 #define SYMOPT_LOAD_ANYTHING            0x00000040
340 #define SYMOPT_IGNORE_CVREC             0x00000080
341 #define SYMOPT_NO_UNQUALIFIED_LOADS     0x00000100
342 #define SYMOPT_FAIL_CRITICAL_ERRORS     0x00000200
343 #define SYMOPT_EXACT_SYMBOLS            0x00000400
344 #define SYMOPT_WILD_UNDERSCORE          0x00000800
345 #define SYMOPT_USE_DEFAULTS             0x00001000
346 /* latest SDK defines:
347 #define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS   0x00000800
348 #define SYMOPT_IGNORE_NT_SYMPATH        0x00001000
349 */
350 #define SYMOPT_INCLUDE_32BIT_MODULES    0x00002000
351 #define SYMOPT_PUBLICS_ONLY             0x00004000
352 #define SYMOPT_NO_PUBLICS               0x00008000
353 #define SYMOPT_AUTO_PUBLICS             0x00010000
354 #define SYMOPT_NO_IMAGE_SEARCH          0x00020000
355 #define SYMOPT_SECURE                   0x00040000
356 #define SYMOPT_NO_PROMPTS               0x00080000
357 #define SYMOPT_OVERWRITE                0x00100000
358 #define SYMOPT_IGNORE_IMAGEDIR          0x00200000
359
360 #define SYMOPT_DEBUG                    0x80000000
361
362   typedef struct _IMAGEHLP_STACK_FRAME {
363     ULONG64 InstructionOffset;
364     ULONG64 ReturnOffset;
365     ULONG64 FrameOffset;
366     ULONG64 StackOffset;
367     ULONG64 BackingStoreOffset;
368     ULONG64 FuncTableEntry;
369     ULONG64 Params[4];
370     ULONG64 Reserved[5];
371     BOOL Virtual;
372     ULONG Reserved2;
373   } IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME;
374
375   typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
376
377 #define DBHHEADER_DEBUGDIRS     0x1
378   typedef struct _DBGHELP_MODLOAD_DATA {
379     DWORD ssize;
380     DWORD ssig;
381     PVOID data;
382     DWORD size;
383     DWORD flags;
384   } MODLOAD_DATA, *PMODLOAD_DATA;
385
386 /*************************
387  *       MiniDUMP        *
388  *************************/
389
390 #include <pshpack4.h>
391 /* DebugHelp */
392
393 #define MINIDUMP_SIGNATURE 0x504D444D   /* 'MDMP' */
394 #define MINIDUMP_VERSION   (42899)
395
396   typedef DWORD RVA;
397   typedef ULONG64 RVA64;
398
399   typedef enum _MINIDUMP_TYPE {
400     MiniDumpNormal = 0x0000,
401     MiniDumpWithDataSegs = 0x0001,
402     MiniDumpWithFullMemory = 0x0002,
403     MiniDumpWithHandleData = 0x0004,
404     MiniDumpFilterMemory = 0x0008,
405     MiniDumpScanMemory = 0x0010,
406     MiniDumpWithUnloadedModules = 0x0020,
407     MiniDumpWithIndirectlyReferencedMemory = 0x0040,
408     MiniDumpFilterModulePaths = 0x0080,
409     MiniDumpWithProcessThreadData = 0x0100,
410     MiniDumpWithPrivateReadWriteMemory = 0x0200,
411     MiniDumpWithoutOptionalData = 0x0400,
412     MiniDumpWithFullMemoryInfo = 0x0800,
413     MiniDumpWithThreadInfo = 0x1000,
414     MiniDumpWithCodeSegs = 0x2000
415   } MINIDUMP_TYPE;
416
417   typedef enum _MINIDUMP_CALLBACK_TYPE {
418     ModuleCallback,
419     ThreadCallback,
420     ThreadExCallback,
421     IncludeThreadCallback,
422     IncludeModuleCallback,
423     MemoryCallback,
424   } MINIDUMP_CALLBACK_TYPE;
425
426   typedef struct _MINIDUMP_THREAD_CALLBACK {
427     ULONG ThreadId;
428     HANDLE ThreadHandle;
429     CONTEXT Context;
430     ULONG SizeOfContext;
431     ULONG64 StackBase;
432     ULONG64 StackEnd;
433   } MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK;
434
435   typedef struct _MINIDUMP_THREAD_EX_CALLBACK {
436     ULONG ThreadId;
437     HANDLE ThreadHandle;
438     CONTEXT Context;
439     ULONG SizeOfContext;
440     ULONG64 StackBase;
441     ULONG64 StackEnd;
442     ULONG64 BackingStoreBase;
443     ULONG64 BackingStoreEnd;
444   } MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK;
445
446   typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK {
447     ULONG ThreadId;
448   } MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK;
449
450   typedef enum _THREAD_WRITE_FLAGS {
451     ThreadWriteThread = 0x0001,
452     ThreadWriteStack = 0x0002,
453     ThreadWriteContext = 0x0004,
454     ThreadWriteBackingStore = 0x0008,
455     ThreadWriteInstructionWindow = 0x0010,
456     ThreadWriteThreadData = 0x0020,
457     ThreadWriteThreadInfo = 0x0040
458   } THREAD_WRITE_FLAGS;
459
460   typedef struct _MINIDUMP_MODULE_CALLBACK {
461     PWCHAR FullPath;
462     ULONG64 BaseOfImage;
463     ULONG SizeOfImage;
464     ULONG CheckSum;
465     ULONG TimeDateStamp;
466     VS_FIXEDFILEINFO VersionInfo;
467     PVOID CvRecord;
468     ULONG SizeOfCvRecord;
469     PVOID MiscRecord;
470     ULONG SizeOfMiscRecord;
471   } MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK;
472
473   typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK {
474     ULONG64 BaseOfImage;
475   } MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK;
476
477   typedef enum _MODULE_WRITE_FLAGS {
478     ModuleWriteModule = 0x0001,
479     ModuleWriteDataSeg = 0x0002,
480     ModuleWriteMiscRecord = 0x0004,
481     ModuleWriteCvRecord = 0x0008,
482     ModuleReferencedByMemory = 0x0010,
483     ModuleWriteTlsData = 0x0020,
484     ModuleWriteCodeSegs = 0x0040,
485   } MODULE_WRITE_FLAGS;
486
487   typedef struct _MINIDUMP_CALLBACK_INPUT {
488     ULONG ProcessId;
489     HANDLE ProcessHandle;
490     ULONG CallbackType;
491     union {
492       MINIDUMP_THREAD_CALLBACK Thread;
493       MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
494       MINIDUMP_MODULE_CALLBACK Module;
495       MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
496       MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
497     } DUMMYUNIONNAME;
498   } MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
499
500   typedef struct _MINIDUMP_CALLBACK_OUTPUT {
501     union {
502       ULONG ModuleWriteFlags;
503       ULONG ThreadWriteFlags;
504       struct {
505         ULONG64 MemoryBase;
506         ULONG MemorySize;
507       } DUMMYSTRUCTNAME;
508     } DUMMYUNIONNAME;
509   } MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT;
510
511   typedef BOOL(WINAPI * MINIDUMP_CALLBACK_ROUTINE) (PVOID,
512                                                     const
513                                                     PMINIDUMP_CALLBACK_INPUT,
514                                                     PMINIDUMP_CALLBACK_OUTPUT);
515
516   typedef struct _MINIDUMP_CALLBACK_INFORMATION {
517     MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;
518     void *CallbackParam;
519   } MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION;
520
521   typedef struct _MINIDUMP_LOCATION_DESCRIPTOR {
522     ULONG DataSize;
523     RVA Rva;
524   } MINIDUMP_LOCATION_DESCRIPTOR;
525
526   typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 {
527     ULONG64 DataSize;
528     RVA64 Rva;
529   } MINIDUMP_LOCATION_DESCRIPTOR64;
530
531   typedef struct _MINIDUMP_DIRECTORY {
532     ULONG StreamType;
533     MINIDUMP_LOCATION_DESCRIPTOR Location;
534   } MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY;
535
536   typedef struct _MINIDUMP_EXCEPTION {
537     ULONG ExceptionCode;
538     ULONG ExceptionFlags;
539     ULONG64 ExceptionRecord;
540     ULONG64 ExceptionAddress;
541     ULONG NumberParameters;
542     ULONG __unusedAlignment;
543     ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
544   } MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION;
545
546   typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
547     DWORD ThreadId;
548     PEXCEPTION_POINTERS ExceptionPointers;
549     BOOL ClientPointers;
550   } MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
551
552   typedef struct MINIDUMP_EXCEPTION_STREAM {
553     ULONG ThreadId;
554     ULONG __alignment;
555     MINIDUMP_EXCEPTION ExceptionRecord;
556     MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
557   } MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM;
558
559   typedef struct _MINIDUMP_HEADER {
560     DWORD Signature;
561     DWORD Version;
562     DWORD NumberOfStreams;
563     RVA StreamDirectoryRva;
564     DWORD CheckSum;
565     union {
566       DWORD Reserved;
567       DWORD TimeDateStamp;
568     } DUMMYUNIONNAME;
569     ULONG64 Flags;
570   } MINIDUMP_HEADER, *PMINIDUMP_HEADER;
571
572   typedef struct _MINIDUMP_MEMORY_DESCRIPTOR {
573     ULONG64 StartOfMemoryRange;
574     MINIDUMP_LOCATION_DESCRIPTOR Memory;
575   } MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR;
576
577   typedef struct _MINIDUMP_MEMORY_LIST {
578     ULONG NumberOfMemoryRanges;
579     MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[1]; /* FIXME: 0-sized array not supported */
580   } MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST;
581
582 #define MINIDUMP_MISC1_PROCESS_ID       0x00000001
583 #define MINIDUMP_MISC1_PROCESS_TIMES    0x00000002
584
585   typedef struct _MINIDUMP_MISC_INFO {
586     ULONG SizeOfInfo;
587     ULONG Flags1;
588     ULONG ProcessId;
589     ULONG ProcessCreateTime;
590     ULONG ProcessUserTime;
591     ULONG ProcessKernelTime;
592   } MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO;
593
594   typedef struct _MINIDUMP_MODULE {
595     ULONG64 BaseOfImage;
596     ULONG SizeOfImage;
597     ULONG CheckSum;
598     ULONG TimeDateStamp;
599     RVA ModuleNameRva;
600     VS_FIXEDFILEINFO VersionInfo;
601     MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
602     MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
603     ULONG64 Reserved0;
604     ULONG64 Reserved1;
605   } MINIDUMP_MODULE, *PMINIDUMP_MODULE;
606
607   typedef struct _MINIDUMP_MODULE_LIST {
608     ULONG NumberOfModules;
609     MINIDUMP_MODULE Modules[1]; /* FIXME: 0-sized array not supported */
610   } MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST;
611
612   typedef struct _MINIDUMP_STRING {
613     ULONG Length;
614     WCHAR Buffer[1];            /* FIXME: O-sized array not supported */
615   } MINIDUMP_STRING, *PMINIDUMP_STRING;
616
617   typedef struct _MINIDUMP_SYSTEM_INFO {
618     USHORT ProcessorArchitecture;
619     USHORT ProcessorLevel;
620     USHORT ProcessorRevision;
621     union {
622       USHORT Reserved0;
623       struct {
624         UCHAR NumberOfProcessors;
625         UCHAR ProductType;
626       } DUMMYSTRUCTNAME;
627     } DUMMYUNIONNAME;
628
629     ULONG MajorVersion;
630     ULONG MinorVersion;
631     ULONG BuildNumber;
632     ULONG PlatformId;
633
634     RVA CSDVersionRva;
635     union {
636       ULONG Reserved1;
637       struct {
638         USHORT SuiteMask;
639         USHORT Reserved2;
640       } DUMMYSTRUCTNAME;
641     } DUMMYUNIONNAME1;
642     union _CPU_INFORMATION {
643       struct {
644         ULONG VendorId[3];
645         ULONG VersionInformation;
646         ULONG FeatureInformation;
647         ULONG AMDExtendedCpuFeatures;
648       } X86CpuInfo;
649       struct {
650         ULONG64 ProcessorFeatures[2];
651       } OtherCpuInfo;
652     } Cpu;
653
654   } MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO;
655
656   typedef struct _MINIDUMP_THREAD {
657     ULONG ThreadId;
658     ULONG SuspendCount;
659     ULONG PriorityClass;
660     ULONG Priority;
661     ULONG64 Teb;
662     MINIDUMP_MEMORY_DESCRIPTOR Stack;
663     MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
664   } MINIDUMP_THREAD, *PMINIDUMP_THREAD;
665
666   typedef struct _MINIDUMP_THREAD_LIST {
667     ULONG NumberOfThreads;
668     MINIDUMP_THREAD Threads[1]; /* FIXME: no support of 0 sized array */
669   } MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST;
670
671   typedef struct _MINIDUMP_USER_STREAM {
672     ULONG Type;
673     ULONG BufferSize;
674     void *Buffer;
675   } MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM;
676
677   typedef struct _MINIDUMP_USER_STREAM_INFORMATION {
678     ULONG UserStreamCount;
679     PMINIDUMP_USER_STREAM UserStreamArray;
680   } MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION;
681
682   typedef enum _MINIDUMP_STREAM_TYPE {
683     UnusedStream = 0,
684     ReservedStream0 = 1,
685     ReservedStream1 = 2,
686     ThreadListStream = 3,
687     ModuleListStream = 4,
688     MemoryListStream = 5,
689     ExceptionStream = 6,
690     SystemInfoStream = 7,
691     ThreadExListStream = 8,
692     Memory64ListStream = 9,
693     CommentStreamA = 10,
694     CommentStreamW = 11,
695     HandleDataStream = 12,
696     FunctionTableStream = 13,
697     UnloadedModuleListStream = 14,
698     MiscInfoStream = 15,
699     MemoryInfoListStream = 16,
700     ThreadInfoListStream = 17,
701
702     LastReservedStream = 0xffff
703   } MINIDUMP_STREAM_TYPE;
704
705   BOOL WINAPI MiniDumpWriteDump(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
706                                 const PMINIDUMP_EXCEPTION_INFORMATION,
707                                 const PMINIDUMP_USER_STREAM_INFORMATION,
708                                 const PMINIDUMP_CALLBACK_INFORMATION);
709   BOOL WINAPI MiniDumpReadDumpStream(PVOID, ULONG, PMINIDUMP_DIRECTORY *,
710                                      PVOID *, ULONG *);
711
712 #include <poppack.h>
713
714 /*************************
715  *    MODULE handling    *
716  *************************/
717
718 /* flags for SymLoadModuleEx */
719 #define SLMFLAG_VIRTUAL         0x1
720 #define SLMFLAG_NO_SYMBOLS      0x4
721
722   typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACK) (PSTR, ULONG,
723                                                          ULONG, PVOID);
724   BOOL WINAPI EnumerateLoadedModules(HANDLE, PENUMLOADED_MODULES_CALLBACK,
725                                      PVOID);
726   typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACK64) (PCSTR, DWORD64,
727                                                            ULONG, PVOID);
728   BOOL WINAPI EnumerateLoadedModules64(HANDLE,
729                                        PENUMLOADED_MODULES_CALLBACK64,
730                                        PVOID);
731   typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACKW64) (PCWSTR,
732                                                             DWORD64, ULONG,
733                                                             PVOID);
734   BOOL WINAPI EnumerateLoadedModulesW64(HANDLE,
735                                         PENUMLOADED_MODULES_CALLBACKW64,
736                                         PVOID);
737   typedef BOOL(CALLBACK * PSYM_ENUMMODULES_CALLBACK) (PCSTR, ULONG, PVOID);
738   BOOL WINAPI SymEnumerateModules(HANDLE, PSYM_ENUMMODULES_CALLBACK,
739                                   PVOID);
740   typedef BOOL(CALLBACK * PSYM_ENUMMODULES_CALLBACK64) (PCSTR, DWORD64,
741                                                         PVOID);
742   BOOL WINAPI SymEnumerateModules64(HANDLE, PSYM_ENUMMODULES_CALLBACK64,
743                                     PVOID);
744   typedef BOOL(CALLBACK * PSYM_ENUMMODULES_CALLBACKW64) (PCWSTR, DWORD64,
745                                                          PVOID);
746   BOOL WINAPI SymEnumerateModulesW64(HANDLE, PSYM_ENUMMODULES_CALLBACKW64,
747                                      PVOID);
748   BOOL WINAPI SymGetModuleInfo(HANDLE, DWORD, PIMAGEHLP_MODULE);
749   BOOL WINAPI SymGetModuleInfoW(HANDLE, DWORD, PIMAGEHLP_MODULEW);
750   BOOL WINAPI SymGetModuleInfo64(HANDLE, DWORD64, PIMAGEHLP_MODULE64);
751   BOOL WINAPI SymGetModuleInfoW64(HANDLE, DWORD64, PIMAGEHLP_MODULEW64);
752   DWORD WINAPI SymGetModuleBase(HANDLE, DWORD);
753   DWORD64 WINAPI SymGetModuleBase64(HANDLE, DWORD64);
754   DWORD WINAPI SymLoadModule(HANDLE, HANDLE, PCSTR, PCSTR, DWORD, DWORD);
755   DWORD64 WINAPI SymLoadModule64(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64,
756                                  DWORD);
757   DWORD64 WINAPI SymLoadModuleEx(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64,
758                                  DWORD, PMODLOAD_DATA, DWORD);
759   DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64,
760                                   DWORD, PMODLOAD_DATA, DWORD);
761   BOOL WINAPI SymUnloadModule(HANDLE, DWORD);
762   BOOL WINAPI SymUnloadModule64(HANDLE, DWORD64);
763
764 /*************************
765  *    Symbol Handling    *
766  *************************/
767
768 #define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT          1
769 #define IMAGEHLP_SYMBOL_INFO_REGISTER              SYMF_REGISTER        /*  0x08 */
770 #define IMAGEHLP_SYMBOL_INFO_REGRELATIVE           SYMF_REGREL  /*  0x10 */
771 #define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE         SYMF_FRAMEREL        /*  0x20 */
772 #define IMAGEHLP_SYMBOL_INFO_PARAMETER             SYMF_PARAMETER       /*  0x40 */
773 #define IMAGEHLP_SYMBOL_INFO_LOCAL                 SYMF_LOCAL   /*  0x80 */
774 #define IMAGEHLP_SYMBOL_INFO_CONSTANT              SYMF_CONSTANT        /* 0x100 */
775 #define IMAGEHLP_SYMBOL_FUNCTION                   SYMF_FUNCTION        /* 0x800 */
776
777 #define SYMFLAG_VALUEPRESENT     0x00000001
778 #define SYMFLAG_REGISTER         0x00000008
779 #define SYMFLAG_REGREL           0x00000010
780 #define SYMFLAG_FRAMEREL         0x00000020
781 #define SYMFLAG_PARAMETER        0x00000040
782 #define SYMFLAG_LOCAL            0x00000080
783 #define SYMFLAG_CONSTANT         0x00000100
784 #define SYMFLAG_EXPORT           0x00000200
785 #define SYMFLAG_FORWARDER        0x00000400
786 #define SYMFLAG_FUNCTION         0x00000800
787 #define SYMFLAG_VIRTUAL          0x00001000
788 #define SYMFLAG_THUNK            0x00002000
789 #define SYMFLAG_TLSREL           0x00004000
790 #define SYMFLAG_SLOT             0x00008000
791
792 #define MAX_SYM_NAME    2000
793
794   typedef struct _SYMBOL_INFO {
795     ULONG SizeOfStruct;
796     ULONG TypeIndex;
797     ULONG64 Reserved[2];
798     ULONG info;                 /* sdk states info, while MSDN says it's Index... */
799     ULONG Size;
800     ULONG64 ModBase;
801     ULONG Flags;
802     ULONG64 Value;
803     ULONG64 Address;
804     ULONG Register;
805     ULONG Scope;
806     ULONG Tag;
807     ULONG NameLen;
808     ULONG MaxNameLen;
809     CHAR Name[1];
810   } SYMBOL_INFO, *PSYMBOL_INFO;
811
812   typedef struct _SYMBOL_INFOW {
813     ULONG SizeOfStruct;
814     ULONG TypeIndex;
815     ULONG64 Reserved[2];
816     ULONG Index;
817     ULONG Size;
818     ULONG64 ModBase;
819     ULONG Flags;
820     ULONG64 Value;
821     ULONG64 Address;
822     ULONG Register;
823     ULONG Scope;
824     ULONG Tag;
825     ULONG NameLen;
826     ULONG MaxNameLen;
827     WCHAR Name[1];
828   } SYMBOL_INFOW, *PSYMBOL_INFOW;
829
830   typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO {
831     TI_GET_SYMTAG,
832     TI_GET_SYMNAME,
833     TI_GET_LENGTH,
834     TI_GET_TYPE,
835     TI_GET_TYPEID,
836     TI_GET_BASETYPE,
837     TI_GET_ARRAYINDEXTYPEID,
838     TI_FINDCHILDREN,
839     TI_GET_DATAKIND,
840     TI_GET_ADDRESSOFFSET,
841     TI_GET_OFFSET,
842     TI_GET_VALUE,
843     TI_GET_COUNT,
844     TI_GET_CHILDRENCOUNT,
845     TI_GET_BITPOSITION,
846     TI_GET_VIRTUALBASECLASS,
847     TI_GET_VIRTUALTABLESHAPEID,
848     TI_GET_VIRTUALBASEPOINTEROFFSET,
849     TI_GET_CLASSPARENTID,
850     TI_GET_NESTED,
851     TI_GET_SYMINDEX,
852     TI_GET_LEXICALPARENT,
853     TI_GET_ADDRESS,
854     TI_GET_THISADJUST,
855     TI_GET_UDTKIND,
856     TI_IS_EQUIV_TO,
857     TI_GET_CALLING_CONVENTION,
858   } IMAGEHLP_SYMBOL_TYPE_INFO;
859
860 #define IMAGEHLP_GET_TYPE_INFO_UNCACHED            0x00000001
861 #define IMAGEHLP_GET_TYPE_INFO_CHILDREN            0x00000002
862   typedef struct _IMAGEHLP_GET_TYPE_INFO_PARAMS {
863     ULONG SizeOfStruct;
864     ULONG Flags;
865     ULONG NumIds;
866     PULONG TypeIds;
867     ULONG64 TagFilter;
868     ULONG NumReqs;
869     IMAGEHLP_SYMBOL_TYPE_INFO *ReqKinds;
870     PULONG_PTR ReqOffsets;
871     PULONG ReqSizes;
872     ULONG_PTR ReqStride;
873     ULONG_PTR BufferSize;
874     PVOID Buffer;
875     ULONG EntriesMatched;
876     ULONG EntriesFilled;
877     ULONG64 TagsFound;
878     ULONG64 AllReqsValid;
879     ULONG NumReqsValid;
880     PULONG64 ReqsValid;
881   } IMAGEHLP_GET_TYPE_INFO_PARAMS, *PIMAGEHLP_GET_TYPE_INFO_PARAMS;
882
883   typedef struct _TI_FINDCHILDREN_PARAMS {
884     ULONG Count;
885     ULONG Start;
886     ULONG ChildId[1];
887   } TI_FINDCHILDREN_PARAMS;
888
889 #define UNDNAME_COMPLETE                 (0x0000)
890 #define UNDNAME_NO_LEADING_UNDERSCORES   (0x0001)
891 #define UNDNAME_NO_MS_KEYWORDS           (0x0002)
892 #define UNDNAME_NO_FUNCTION_RETURNS      (0x0004)
893 #define UNDNAME_NO_ALLOCATION_MODEL      (0x0008)
894 #define UNDNAME_NO_ALLOCATION_LANGUAGE   (0x0010)
895 #define UNDNAME_NO_MS_THISTYPE           (0x0020)
896 #define UNDNAME_NO_CV_THISTYPE           (0x0040)
897 #define UNDNAME_NO_THISTYPE              (0x0060)
898 #define UNDNAME_NO_ACCESS_SPECIFIERS     (0x0080)
899 #define UNDNAME_NO_THROW_SIGNATURES      (0x0100)
900 #define UNDNAME_NO_MEMBER_TYPE           (0x0200)
901 #define UNDNAME_NO_RETURN_UDT_MODEL      (0x0400)
902 #define UNDNAME_32_BIT_DECODE            (0x0800)
903 #define UNDNAME_NAME_ONLY                (0x1000)
904 #define UNDNAME_NO_ARGUMENTS             (0x2000)
905 #define UNDNAME_NO_SPECIAL_SYMS          (0x4000)
906
907 #define SYMSEARCH_MASKOBJS              0x01
908 #define SYMSEARCH_RECURSE               0x02
909 #define SYMSEARCH_GLOBALSONLY           0x04
910
911   BOOL WINAPI SymGetTypeInfo(HANDLE, DWORD64, ULONG,
912                              IMAGEHLP_SYMBOL_TYPE_INFO, PVOID);
913   BOOL WINAPI SymGetTypeInfoEx(HANDLE, DWORD64,
914                                PIMAGEHLP_GET_TYPE_INFO_PARAMS);
915   typedef BOOL(CALLBACK * PSYM_ENUMERATESYMBOLS_CALLBACK) (PSYMBOL_INFO,
916                                                            ULONG, PVOID);
917   typedef BOOL(CALLBACK * PSYM_ENUMERATESYMBOLS_CALLBACKW) (PSYMBOL_INFOW,
918                                                             ULONG, PVOID);
919   BOOL WINAPI SymEnumTypes(HANDLE, ULONG64, PSYM_ENUMERATESYMBOLS_CALLBACK,
920                            PVOID);
921   BOOL WINAPI SymEnumTypesW(HANDLE, ULONG64,
922                             PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID);
923   BOOL WINAPI SymFromAddr(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *);
924   BOOL WINAPI SymFromAddrW(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFOW *);
925   BOOL WINAPI SymFromToken(HANDLE, DWORD64, DWORD, PSYMBOL_INFO);
926   BOOL WINAPI SymFromTokenW(HANDLE, DWORD64, DWORD, PSYMBOL_INFOW);
927   BOOL WINAPI SymFromName(HANDLE, PCSTR, PSYMBOL_INFO);
928   BOOL WINAPI SymFromNameW(HANDLE, PCWSTR, PSYMBOL_INFOW);
929   BOOL WINAPI SymGetSymFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL);
930   BOOL WINAPI SymGetSymFromAddr64(HANDLE, DWORD64, PDWORD64,
931                                   PIMAGEHLP_SYMBOL64);
932   BOOL WINAPI SymGetSymFromName(HANDLE, PCSTR, PIMAGEHLP_SYMBOL);
933   BOOL WINAPI SymGetSymFromName64(HANDLE, PCSTR, PIMAGEHLP_SYMBOL64);
934   BOOL WINAPI SymGetTypeFromName(HANDLE, ULONG64, PCSTR, PSYMBOL_INFO);
935   BOOL WINAPI SymGetTypeFromNameW(HANDLE, ULONG64, PCWSTR, PSYMBOL_INFOW);
936   BOOL WINAPI SymGetSymNext(HANDLE, PIMAGEHLP_SYMBOL);
937   BOOL WINAPI SymGetSymNext64(HANDLE, PIMAGEHLP_SYMBOL64);
938   BOOL WINAPI SymGetSymNextW64(HANDLE, PIMAGEHLP_SYMBOLW64);
939   BOOL WINAPI SymGetSymPrev(HANDLE, PIMAGEHLP_SYMBOL);
940   BOOL WINAPI SymGetSymPrev64(HANDLE, PIMAGEHLP_SYMBOL64);
941   BOOL WINAPI SymGetSymPrevW64(HANDLE, PIMAGEHLP_SYMBOLW64);
942   BOOL WINAPI SymEnumSymbols(HANDLE, ULONG64, PCSTR,
943                              PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
944   BOOL WINAPI SymEnumSymbolsW(HANDLE, ULONG64, PCWSTR,
945                               PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID);
946   typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK) (PCSTR, DWORD, ULONG,
947                                                       PVOID);
948   typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACKW) (PCWSTR, DWORD,
949                                                        ULONG, PVOID);
950   BOOL WINAPI SymEnumerateSymbols(HANDLE, ULONG, PSYM_ENUMSYMBOLS_CALLBACK,
951                                   PVOID);
952   BOOL WINAPI SymEnumerateSymbolsW(HANDLE, ULONG,
953                                    PSYM_ENUMSYMBOLS_CALLBACKW, PVOID);
954   typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK64) (PCSTR, DWORD64,
955                                                         ULONG, PVOID);
956   typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK64W) (PCWSTR, DWORD64,
957                                                          ULONG, PVOID);
958   BOOL WINAPI SymEnumerateSymbols64(HANDLE, ULONG64,
959                                     PSYM_ENUMSYMBOLS_CALLBACK64, PVOID);
960   BOOL WINAPI SymEnumerateSymbolsW64(HANDLE, ULONG64,
961                                      PSYM_ENUMSYMBOLS_CALLBACK64W, PVOID);
962   BOOL WINAPI SymEnumSymbolsForAddr(HANDLE, DWORD64,
963                                     PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
964   BOOL WINAPI SymEnumSymbolsForAddrW(HANDLE, DWORD64,
965                                      PSYM_ENUMERATESYMBOLS_CALLBACKW,
966                                      PVOID);
967   typedef BOOL(CALLBACK * PSYMBOL_REGISTERED_CALLBACK) (HANDLE, ULONG,
968                                                         PVOID, PVOID);
969   BOOL WINAPI SymRegisterCallback(HANDLE, PSYMBOL_REGISTERED_CALLBACK,
970                                   PVOID);
971   typedef BOOL(CALLBACK * PSYMBOL_REGISTERED_CALLBACK64) (HANDLE, ULONG,
972                                                           ULONG64,
973                                                           ULONG64);
974   BOOL WINAPI SymRegisterCallback64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64,
975                                     ULONG64);
976   BOOL WINAPI SymRegisterCallbackW64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64,
977                                      ULONG64);
978   BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL, PSTR, DWORD);
979   BOOL WINAPI SymUnDName64(PIMAGEHLP_SYMBOL64, PSTR, DWORD);
980   BOOL WINAPI SymMatchString(PCSTR, PCSTR, BOOL);
981   BOOL WINAPI SymMatchStringA(PCSTR, PCSTR, BOOL);
982   BOOL WINAPI SymMatchStringW(PCWSTR, PCWSTR, BOOL);
983   BOOL WINAPI SymSearch(HANDLE, ULONG64, DWORD, DWORD, PCSTR, DWORD64,
984                         PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID, DWORD);
985   BOOL WINAPI SymSearchW(HANDLE, ULONG64, DWORD, DWORD, PCWSTR, DWORD64,
986                          PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID, DWORD);
987   DWORD WINAPI UnDecorateSymbolName(PCSTR, PSTR, DWORD, DWORD);
988   DWORD WINAPI UnDecorateSymbolNameW(PCWSTR, PWSTR, DWORD, DWORD);
989   BOOL WINAPI SymGetScope(HANDLE, ULONG64, DWORD, PSYMBOL_INFO);
990   BOOL WINAPI SymGetScopeW(HANDLE, ULONG64, DWORD, PSYMBOL_INFOW);
991   BOOL WINAPI SymFromIndex(HANDLE, ULONG64, DWORD, PSYMBOL_INFO);
992   BOOL WINAPI SymFromIndexW(HANDLE, ULONG64, DWORD, PSYMBOL_INFOW);
993   BOOL WINAPI SymAddSymbol(HANDLE, ULONG64, PCSTR, DWORD64, DWORD, DWORD);
994   BOOL WINAPI SymAddSymbolW(HANDLE, ULONG64, PCWSTR, DWORD64, DWORD,
995                             DWORD);
996   BOOL WINAPI SymDeleteSymbol(HANDLE, ULONG64, PCSTR, DWORD64, DWORD);
997   BOOL WINAPI SymDeleteSymbolW(HANDLE, ULONG64, PCWSTR, DWORD64, DWORD);
998
999 /*************************
1000  *      Source Files     *
1001  *************************/
1002   typedef BOOL(CALLBACK * PSYM_ENUMSOURCEFILES_CALLBACK) (PSOURCEFILE,
1003                                                           PVOID);
1004   typedef BOOL(CALLBACK * PSYM_ENUMSOURCEFILES_CALLBACKW) (PSOURCEFILEW,
1005                                                            PVOID);
1006
1007   BOOL WINAPI SymEnumSourceFiles(HANDLE, ULONG64, PCSTR,
1008                                  PSYM_ENUMSOURCEFILES_CALLBACK, PVOID);
1009   BOOL WINAPI SymEnumSourceFilesW(HANDLE, ULONG64, PCWSTR,
1010                                   PSYM_ENUMSOURCEFILES_CALLBACKW, PVOID);
1011   BOOL WINAPI SymGetLineFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE);
1012   BOOL WINAPI SymGetLineFromAddrW(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINEW);
1013   BOOL WINAPI SymGetLineFromAddr64(HANDLE, DWORD64, PDWORD,
1014                                    PIMAGEHLP_LINE64);
1015   BOOL WINAPI SymGetLineFromAddrW64(HANDLE, DWORD64, PDWORD,
1016                                     PIMAGEHLP_LINEW64);
1017   BOOL WINAPI SymGetLinePrev(HANDLE, PIMAGEHLP_LINE);
1018   BOOL WINAPI SymGetLinePrevW(HANDLE, PIMAGEHLP_LINEW);
1019   BOOL WINAPI SymGetLinePrev64(HANDLE, PIMAGEHLP_LINE64);
1020   BOOL WINAPI SymGetLinePrevW64(HANDLE, PIMAGEHLP_LINEW64);
1021   BOOL WINAPI SymGetLineNext(HANDLE, PIMAGEHLP_LINE);
1022   BOOL WINAPI SymGetLineNextW(HANDLE, PIMAGEHLP_LINEW);
1023   BOOL WINAPI SymGetLineNext64(HANDLE, PIMAGEHLP_LINE64);
1024   BOOL WINAPI SymGetLineNextW64(HANDLE, PIMAGEHLP_LINEW64);
1025   BOOL WINAPI SymGetLineFromName(HANDLE, PCSTR, PCSTR, DWORD, PLONG,
1026                                  PIMAGEHLP_LINE);
1027   BOOL WINAPI SymGetLineFromName64(HANDLE, PCSTR, PCSTR, DWORD, PLONG,
1028                                    PIMAGEHLP_LINE64);
1029   BOOL WINAPI SymGetLineFromNameW64(HANDLE, PCWSTR, PCWSTR, DWORD, PLONG,
1030                                     PIMAGEHLP_LINEW64);
1031   ULONG WINAPI SymGetFileLineOffsets64(HANDLE, PCSTR, PCSTR, PDWORD64,
1032                                        ULONG);
1033   BOOL WINAPI SymGetSourceFile(HANDLE, ULONG64, PCSTR, PCSTR, PSTR, DWORD);
1034   BOOL WINAPI SymGetSourceFileW(HANDLE, ULONG64, PCWSTR, PCWSTR, PWSTR,
1035                                 DWORD);
1036   BOOL WINAPI SymGetSourceFileToken(HANDLE, ULONG64, PCSTR, PVOID *,
1037                                     DWORD *);
1038   BOOL WINAPI SymGetSourceFileTokenW(HANDLE, ULONG64, PCWSTR, PVOID *,
1039                                      DWORD *);
1040   BOOL WINAPI SymGetSourceFileFromToken(HANDLE, PVOID, PCSTR, PSTR, DWORD);
1041   BOOL WINAPI SymGetSourceFileFromTokenW(HANDLE, PVOID, PCWSTR, PWSTR,
1042                                          DWORD);
1043   BOOL WINAPI SymGetSourceVarFromToken(HANDLE, PVOID, PCSTR, PCSTR, PSTR,
1044                                        DWORD);
1045   BOOL WINAPI SymGetSourceVarFromTokenW(HANDLE, PVOID, PCWSTR, PCWSTR,
1046                                         PWSTR, DWORD);
1047
1048   typedef struct _SRCCODEINFO {
1049     DWORD SizeOfStruct;
1050     PVOID Key;
1051     DWORD64 ModBase;
1052     CHAR Obj[MAX_PATH + 1];
1053     CHAR FileName[MAX_PATH + 1];
1054     DWORD LineNumber;
1055     DWORD64 Address;
1056   } SRCCODEINFO, *PSRCCODEINFO;
1057
1058   typedef struct _SRCCODEINFOW {
1059     DWORD SizeOfStruct;
1060     PVOID Key;
1061     DWORD64 ModBase;
1062     WCHAR Obj[MAX_PATH + 1];
1063     WCHAR FileName[MAX_PATH + 1];
1064     DWORD LineNumber;
1065     DWORD64 Address;
1066   } SRCCODEINFOW, *PSRCCODEINFOW;
1067
1068   typedef BOOL(CALLBACK * PSYM_ENUMLINES_CALLBACK) (PSRCCODEINFO, PVOID);
1069   typedef BOOL(CALLBACK * PSYM_ENUMLINES_CALLBACKW) (PSRCCODEINFOW, PVOID);
1070   BOOL WINAPI SymEnumLines(HANDLE, ULONG64, PCSTR, PCSTR,
1071                            PSYM_ENUMLINES_CALLBACK, PVOID);
1072   BOOL WINAPI SymEnumLinesW(HANDLE, ULONG64, PCWSTR, PCWSTR,
1073                             PSYM_ENUMLINES_CALLBACKW, PVOID);
1074   BOOL WINAPI SymEnumSourceLines(HANDLE, ULONG64, PCSTR, PCSTR, DWORD,
1075                                  DWORD, PSYM_ENUMLINES_CALLBACK, PVOID);
1076   BOOL WINAPI SymEnumSourceLinesW(HANDLE, ULONG64, PCWSTR, PCWSTR, DWORD,
1077                                   DWORD, PSYM_ENUMLINES_CALLBACKW, PVOID);
1078
1079 /*************************
1080  * File & image handling *
1081  *************************/
1082   BOOL WINAPI SymInitialize(HANDLE, PCSTR, BOOL);
1083   BOOL WINAPI SymInitializeW(HANDLE, PCWSTR, BOOL);
1084   BOOL WINAPI SymCleanup(HANDLE);
1085
1086   HANDLE WINAPI FindDebugInfoFile(PCSTR, PCSTR, PSTR);
1087   typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACK) (HANDLE, PCSTR,
1088                                                       PVOID);
1089   typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACKW) (HANDLE, PCWSTR,
1090                                                        PVOID);
1091   HANDLE WINAPI FindDebugInfoFileEx(PCSTR, PCSTR, PSTR,
1092                                     PFIND_DEBUG_FILE_CALLBACK, PVOID);
1093   HANDLE WINAPI FindDebugInfoFileExW(PCWSTR, PCWSTR, PWSTR,
1094                                      PFIND_DEBUG_FILE_CALLBACKW, PVOID);
1095   HANDLE WINAPI SymFindDebugInfoFile(HANDLE, PCSTR, PSTR,
1096                                      PFIND_DEBUG_FILE_CALLBACK, PVOID);
1097   HANDLE WINAPI SymFindDebugInfoFileW(HANDLE, PCWSTR, PWSTR,
1098                                       PFIND_DEBUG_FILE_CALLBACKW, PVOID);
1099   typedef BOOL(CALLBACK * PFINDFILEINPATHCALLBACK) (PCSTR, PVOID);
1100   typedef BOOL(CALLBACK * PFINDFILEINPATHCALLBACKW) (PCWSTR, PVOID);
1101   BOOL WINAPI FindFileInPath(HANDLE, PCSTR, PCSTR, PVOID, DWORD, DWORD,
1102                              DWORD, PSTR, PFINDFILEINPATHCALLBACK, PVOID);
1103   BOOL WINAPI SymFindFileInPath(HANDLE, PCSTR, PCSTR, PVOID, DWORD, DWORD,
1104                                 DWORD, PSTR, PFINDFILEINPATHCALLBACK,
1105                                 PVOID);
1106   BOOL WINAPI SymFindFileInPathW(HANDLE, PCWSTR, PCWSTR, PVOID, DWORD,
1107                                  DWORD, DWORD, PWSTR,
1108                                  PFINDFILEINPATHCALLBACKW, PVOID);
1109   HANDLE WINAPI FindExecutableImage(PCSTR, PCSTR, PSTR);
1110   typedef BOOL(CALLBACK * PFIND_EXE_FILE_CALLBACK) (HANDLE, PCSTR, PVOID);
1111   typedef BOOL(CALLBACK * PFIND_EXE_FILE_CALLBACKW) (HANDLE, PCWSTR,
1112                                                      PVOID);
1113   HANDLE WINAPI FindExecutableImageEx(PCSTR, PCSTR, PSTR,
1114                                       PFIND_EXE_FILE_CALLBACK, PVOID);
1115   HANDLE WINAPI FindExecutableImageExW(PCWSTR, PCWSTR, PWSTR,
1116                                        PFIND_EXE_FILE_CALLBACKW, PVOID);
1117   HANDLE WINAPI SymFindExecutableImage(HANDLE, PCSTR, PSTR,
1118                                        PFIND_EXE_FILE_CALLBACK, PVOID);
1119   HANDLE WINAPI SymFindExecutableImageW(HANDLE, PCWSTR, PWSTR,
1120                                         PFIND_EXE_FILE_CALLBACKW, PVOID);
1121   PIMAGE_NT_HEADERS WINAPI ImageNtHeader(PVOID);
1122   PVOID WINAPI ImageDirectoryEntryToDataEx(PVOID, BOOLEAN, USHORT, PULONG,
1123                                            PIMAGE_SECTION_HEADER *);
1124   PVOID WINAPI ImageDirectoryEntryToData(PVOID, BOOLEAN, USHORT, PULONG);
1125   PIMAGE_SECTION_HEADER WINAPI ImageRvaToSection(PIMAGE_NT_HEADERS, PVOID,
1126                                                  ULONG);
1127   PVOID WINAPI ImageRvaToVa(PIMAGE_NT_HEADERS, PVOID, ULONG,
1128                             PIMAGE_SECTION_HEADER *);
1129   BOOL WINAPI SymGetSearchPath(HANDLE, PSTR, DWORD);
1130   BOOL WINAPI SymGetSearchPathW(HANDLE, PWSTR, DWORD);
1131   BOOL WINAPI SymSetSearchPath(HANDLE, PCSTR);
1132   BOOL WINAPI SymSetSearchPathW(HANDLE, PCWSTR);
1133   DWORD WINAPI GetTimestampForLoadedLibrary(HMODULE);
1134   BOOL WINAPI MakeSureDirectoryPathExists(PCSTR);
1135   BOOL WINAPI SearchTreeForFile(PCSTR, PCSTR, PSTR);
1136   BOOL WINAPI SearchTreeForFileW(PCWSTR, PCWSTR, PWSTR);
1137   typedef BOOL(CALLBACK * PENUMDIRTREE_CALLBACK) (PCSTR, PVOID);
1138   typedef BOOL(CALLBACK * PENUMDIRTREE_CALLBACKW) (PCWSTR, PVOID);
1139   BOOL WINAPI EnumDirTree(HANDLE, PCSTR, PCSTR, PSTR,
1140                           PENUMDIRTREE_CALLBACK, PVOID);
1141   BOOL WINAPI EnumDirTreeW(HANDLE, PCWSTR, PCWSTR, PWSTR,
1142                            PENUMDIRTREE_CALLBACKW, PVOID);
1143   BOOL WINAPI SymMatchFileName(PCSTR, PCSTR, PSTR *, PSTR *);
1144   BOOL WINAPI SymMatchFileNameW(PCWSTR, PCWSTR, PWSTR *, PWSTR *);
1145   PCHAR WINAPI SymSetHomeDirectory(HANDLE, PCSTR);
1146   PWSTR WINAPI SymSetHomeDirectoryW(HANDLE, PCWSTR);
1147   PCHAR WINAPI SymGetHomeDirectory(DWORD, PSTR, size_t);
1148   PWSTR WINAPI SymGetHomeDirectoryW(DWORD, PWSTR, size_t);
1149 #define hdBase  0
1150 #define hdSym   1
1151 #define hdSrc   2
1152 #define hdMax   3
1153
1154 /*************************
1155  *   Context management  *
1156  *************************/
1157   BOOL WINAPI SymSetContext(HANDLE, PIMAGEHLP_STACK_FRAME,
1158                             PIMAGEHLP_CONTEXT);
1159
1160
1161 /*************************
1162  *    Stack management   *
1163  *************************/
1164
1165   typedef struct _KDHELP {
1166     DWORD Thread;
1167     DWORD ThCallbackStack;
1168     DWORD NextCallback;
1169     DWORD FramePointer;
1170     DWORD KiCallUserMode;
1171     DWORD KeUserCallbackDispatcher;
1172     DWORD SystemRangeStart;
1173   } KDHELP, *PKDHELP;
1174
1175   typedef struct _KDHELP64 {
1176     DWORD64 Thread;
1177     DWORD ThCallbackStack;
1178     DWORD ThCallbackBStore;
1179     DWORD NextCallback;
1180     DWORD FramePointer;
1181     DWORD64 KiCallUserMode;
1182     DWORD64 KeUserCallbackDispatcher;
1183     DWORD64 SystemRangeStart;
1184     DWORD64 Reserved[8];
1185   } KDHELP64, *PKDHELP64;
1186
1187   typedef struct _STACKFRAME {
1188     ADDRESS AddrPC;
1189     ADDRESS AddrReturn;
1190     ADDRESS AddrFrame;
1191     ADDRESS AddrStack;
1192     PVOID FuncTableEntry;
1193     DWORD Params[4];
1194     BOOL Far;
1195     BOOL Virtual;
1196     DWORD Reserved[3];
1197     KDHELP KdHelp;
1198     ADDRESS AddrBStore;
1199   } STACKFRAME, *LPSTACKFRAME;
1200
1201   typedef struct _STACKFRAME64 {
1202     ADDRESS64 AddrPC;
1203     ADDRESS64 AddrReturn;
1204     ADDRESS64 AddrFrame;
1205     ADDRESS64 AddrStack;
1206     ADDRESS64 AddrBStore;
1207     PVOID FuncTableEntry;
1208     DWORD64 Params[4];
1209     BOOL Far;
1210     BOOL Virtual;
1211     DWORD64 Reserved[3];
1212     KDHELP64 KdHelp;
1213   } STACKFRAME64, *LPSTACKFRAME64;
1214
1215   typedef BOOL(CALLBACK * PREAD_PROCESS_MEMORY_ROUTINE)
1216    (HANDLE, DWORD, PVOID, DWORD, PDWORD);
1217   typedef PVOID(CALLBACK * PFUNCTION_TABLE_ACCESS_ROUTINE) (HANDLE, DWORD);
1218   typedef DWORD(CALLBACK * PGET_MODULE_BASE_ROUTINE) (HANDLE, DWORD);
1219   typedef DWORD(CALLBACK * PTRANSLATE_ADDRESS_ROUTINE) (HANDLE, HANDLE,
1220                                                         LPADDRESS);
1221   BOOL WINAPI StackWalk(DWORD, HANDLE, HANDLE, LPSTACKFRAME, PVOID,
1222                         PREAD_PROCESS_MEMORY_ROUTINE,
1223                         PFUNCTION_TABLE_ACCESS_ROUTINE,
1224                         PGET_MODULE_BASE_ROUTINE,
1225                         PTRANSLATE_ADDRESS_ROUTINE);
1226
1227   typedef BOOL(CALLBACK * PREAD_PROCESS_MEMORY_ROUTINE64)
1228    (HANDLE, DWORD64, PVOID, DWORD, PDWORD);
1229   typedef PVOID(CALLBACK * PFUNCTION_TABLE_ACCESS_ROUTINE64) (HANDLE,
1230                                                               DWORD64);
1231   typedef DWORD64(CALLBACK * PGET_MODULE_BASE_ROUTINE64) (HANDLE, DWORD64);
1232   typedef DWORD64(CALLBACK * PTRANSLATE_ADDRESS_ROUTINE64) (HANDLE, HANDLE,
1233                                                             LPADDRESS64);
1234   BOOL WINAPI StackWalk64(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID,
1235                           PREAD_PROCESS_MEMORY_ROUTINE64,
1236                           PFUNCTION_TABLE_ACCESS_ROUTINE64,
1237                           PGET_MODULE_BASE_ROUTINE64,
1238                           PTRANSLATE_ADDRESS_ROUTINE64);
1239
1240   PVOID WINAPI SymFunctionTableAccess(HANDLE, DWORD);
1241   PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64);
1242
1243   typedef PVOID(CALLBACK * PSYMBOL_FUNCENTRY_CALLBACK) (HANDLE, DWORD,
1244                                                         PVOID);
1245   typedef PVOID(CALLBACK * PSYMBOL_FUNCENTRY_CALLBACK64) (HANDLE, ULONG64,
1246                                                           ULONG64);
1247
1248   BOOL WINAPI SymRegisterFunctionEntryCallback(HANDLE,
1249                                                PSYMBOL_FUNCENTRY_CALLBACK,
1250                                                PVOID);
1251   BOOL WINAPI SymRegisterFunctionEntryCallback64(HANDLE,
1252                                                  PSYMBOL_FUNCENTRY_CALLBACK64,
1253                                                  ULONG64);
1254
1255 /*************************
1256  * Version, global stuff *
1257  *************************/
1258
1259 #define API_VERSION_NUMBER 9
1260
1261   typedef struct API_VERSION {
1262     USHORT MajorVersion;
1263     USHORT MinorVersion;
1264     USHORT Revision;
1265     USHORT Reserved;
1266   } API_VERSION, *LPAPI_VERSION;
1267
1268   LPAPI_VERSION WINAPI ImagehlpApiVersion(void);
1269   LPAPI_VERSION WINAPI ImagehlpApiVersionEx(LPAPI_VERSION);
1270
1271   typedef struct _IMAGE_DEBUG_INFORMATION {
1272     LIST_ENTRY List;
1273     DWORD ReservedSize;
1274     PVOID ReservedMappedBase;
1275     USHORT ReservedMachine;
1276     USHORT ReservedCharacteristics;
1277     DWORD ReservedCheckSum;
1278     DWORD ImageBase;
1279     DWORD SizeOfImage;
1280     DWORD ReservedNumberOfSections;
1281     PIMAGE_SECTION_HEADER ReservedSections;
1282     DWORD ReservedExportedNamesSize;
1283     PSTR ReservedExportedNames;
1284     DWORD ReservedNumberOfFunctionTableEntries;
1285     PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
1286     DWORD ReservedLowestFunctionStartingAddress;
1287     DWORD ReservedHighestFunctionEndingAddress;
1288     DWORD ReservedNumberOfFpoTableEntries;
1289     PFPO_DATA ReservedFpoTableEntries;
1290     DWORD SizeOfCoffSymbols;
1291     PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
1292     DWORD ReservedSizeOfCodeViewSymbols;
1293     PVOID ReservedCodeViewSymbols;
1294     PSTR ImageFilePath;
1295     PSTR ImageFileName;
1296     PSTR ReservedDebugFilePath;
1297     DWORD ReservedTimeDateStamp;
1298     BOOL ReservedRomImage;
1299     PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
1300     DWORD ReservedNumberOfDebugDirectories;
1301     DWORD ReservedOriginalFunctionTableBaseAddress;
1302     DWORD Reserved[2];
1303   } IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
1304
1305
1306   PIMAGE_DEBUG_INFORMATION WINAPI MapDebugInformation(HANDLE, PCSTR, PCSTR,
1307                                                       ULONG);
1308
1309   BOOL WINAPI UnmapDebugInformation(PIMAGE_DEBUG_INFORMATION);
1310
1311   DWORD WINAPI SymGetOptions(void);
1312   DWORD WINAPI SymSetOptions(DWORD);
1313
1314   BOOL WINAPI SymSetParentWindow(HWND);
1315
1316 /*************************
1317  * Version, global stuff *
1318  *************************/
1319
1320   typedef BOOL(WINAPI * PSYMBOLSERVERPROC) (PCSTR, PCSTR, PVOID, DWORD,
1321                                             DWORD, PSTR);
1322   typedef BOOL(WINAPI * PSYMBOLSERVERPROCA) (PCSTR, PCSTR, PVOID, DWORD,
1323                                              DWORD, PSTR);
1324   typedef BOOL(WINAPI * PSYMBOLSERVERPROCW) (PCWSTR, PCWSTR, PVOID, DWORD,
1325                                              DWORD, PWSTR);
1326   typedef BOOL(WINAPI * PSYMBOLSERVEROPENPROC) (void);
1327   typedef BOOL(WINAPI * PSYMBOLSERVERCLOSEPROC) (void);
1328   typedef BOOL(WINAPI * PSYMBOLSERVERSETOPTIONSPROC) (UINT_PTR, ULONG64);
1329   typedef BOOL(CALLBACK * PSYMBOLSERVERCALLBACKPROC) (UINT_PTR, ULONG64,
1330                                                       ULONG64);
1331   typedef UINT_PTR(WINAPI * PSYMBOLSERVERGETOPTIONSPROC) (void);
1332   typedef BOOL(WINAPI * PSYMBOLSERVERPINGPROC) (PCSTR);
1333   typedef BOOL(WINAPI * PSYMBOLSERVERPINGPROCA) (PCSTR);
1334   typedef BOOL(WINAPI * PSYMBOLSERVERPINGPROCW) (PCWSTR);
1335
1336 #define SSRVOPT_CALLBACK            0x0001
1337 #define SSRVOPT_DWORD               0x0002
1338 #define SSRVOPT_DWORDPTR            0x0004
1339 #define SSRVOPT_GUIDPTR             0x0008
1340 #define SSRVOPT_OLDGUIDPTR          0x0010
1341 #define SSRVOPT_UNATTENDED          0x0020
1342 #define SSRVOPT_NOCOPY              0x0040
1343 #define SSRVOPT_PARENTWIN           0x0080
1344 #define SSRVOPT_PARAMTYPE           0x0100
1345 #define SSRVOPT_SECURE              0x0200
1346 #define SSRVOPT_TRACE               0x0400
1347 #define SSRVOPT_SETCONTEXT          0x0800
1348 #define SSRVOPT_PROXY               0x1000
1349 #define SSRVOPT_DOWNSTREAM_STORE    0x2000
1350 #define SSRVOPT_RESET               ((ULONG_PTR)-1)
1351
1352 #define SSRVACTION_TRACE        1
1353 #define SSRVACTION_QUERYCANCEL  2
1354 #define SSRVACTION_EVENT        3
1355
1356 #ifdef __cplusplus
1357 }                               /* extern "C" */
1358 #endif                          /* defined(__cplusplus) */
1359 #endif                          /* __WINE_DBGHELP_H */