CrystalSpace

Public API Reference

csutil/win32/DbgHelpAPI.h

00001 /*
00002   DbgHelp API stuff.
00003   Unfortunately, dbghelp.h isn't included in MinGW. So all that's needed goes here.
00004  */
00005 
00006 #ifndef __CSUTIL_DEBGHELPAPI_H__
00007 #define __CSUTIL_DEBGHELPAPI_H__
00008 
00009 enum ADDRESS_MODE
00010 {
00011   AddrMode1616,
00012   AddrMode1632,
00013   AddrModeReal,
00014   AddrModeFlat
00015 };
00016 
00017 struct ADDRESS64 
00018 {
00019   uint64 Offset;
00020   WORD Segment;
00021   ADDRESS_MODE Mode;
00022 };
00023 typedef ADDRESS64* LPADDRESS64;
00024 
00025 struct KDHELP64 
00026 {  
00027   uint64 Thread;  
00028   DWORD ThCallbackStack;  
00029   DWORD ThCallbackBStore;  
00030   DWORD NextCallback;  
00031   DWORD FramePointer;  
00032   uint64 KiCallUserMode;  
00033   uint64 KeUserCallbackDispatcher;  
00034   uint64 SystemRangeStart;  
00035   uint64 Reserved[8];
00036 };
00037 typedef KDHELP64* PKDHELP64;
00038 
00039 struct STACKFRAME64 
00040 {  
00041   ADDRESS64 AddrPC;  
00042   ADDRESS64 AddrReturn;  
00043   ADDRESS64 AddrFrame;  
00044   ADDRESS64 AddrStack;  
00045   ADDRESS64 AddrBStore;  
00046   PVOID FuncTableEntry;  
00047   uint64 Params[4];  
00048   BOOL Far;  
00049   BOOL Virtual;  
00050   uint64 Reserved[3];  
00051   KDHELP64 KdHelp;
00052 };
00053 typedef STACKFRAME64* LPSTACKFRAME64;
00054 
00055 typedef BOOL (WINAPI* PREAD_PROCESS_MEMORY_ROUTINE64) (HANDLE hProcess,
00056   uint64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);
00057 typedef PVOID (WINAPI* PFUNCTION_TABLE_ACCESS_ROUTINE64) (HANDLE hProcess,
00058   uint64 AddrBase);
00059 typedef uint64 (WINAPI* PGET_MODULE_BASE_ROUTINE64) (HANDLE  hProcess, 
00060   uint64 Address);
00061 typedef uint64 (WINAPI* PTRANSLATE_ADDRESS_ROUTINE64) (HANDLE hProcess,
00062   HANDLE hThread, LPADDRESS64 lpaddr);
00063 
00064 struct SYMBOL_INFO 
00065 {  
00066   ULONG SizeOfStruct;  
00067   ULONG TypeIndex;  
00068   uint64 Reserved[2];  
00069   ULONG Reserved2;  
00070   ULONG Size;  
00071   uint64 ModBase;  
00072   ULONG Flags;  
00073   uint64 Value;  
00074   uint64 Address;  
00075   ULONG Register;  
00076   ULONG Scope;  
00077   ULONG Tag;  
00078   ULONG NameLen;  
00079   ULONG MaxNameLen;  
00080   CHAR Name[1];
00081 };
00082 typedef SYMBOL_INFO* PSYMBOL_INFO;
00083 
00084 struct SYMBOL_INFOW
00085 {  
00086   ULONG SizeOfStruct;  
00087   ULONG TypeIndex;  
00088   uint64 Reserved[2];  
00089   ULONG Reserved2;  
00090   ULONG Size;  
00091   uint64 ModBase;  
00092   ULONG Flags;  
00093   uint64 Value;  
00094   uint64 Address;  
00095   ULONG Register;  
00096   ULONG Scope;  
00097   ULONG Tag;  
00098   ULONG NameLen;  
00099   ULONG MaxNameLen;  
00100   WCHAR Name[1];
00101 };
00102 typedef SYMBOL_INFOW* PSYMBOL_INFOW;
00103 
00104 #define SYMFLAG_PARAMETER        0x00000040
00105 
00106 #define SYMOPT_UNDNAME                  0x00000002
00107 #define SYMOPT_DEFERRED_LOADS           0x00000004
00108 #define SYMOPT_LOAD_LINES               0x00000010
00109 #define SYMOPT_FAIL_CRITICAL_ERRORS     0x00000200
00110 
00111 enum SYM_TYPE
00112 {
00113     SymNone = 0,
00114     SymCoff,
00115     SymCv,
00116     SymPdb,
00117     SymExport,
00118     SymDeferred,
00119     SymSym,
00120     SymDia,
00121     SymVirtual,
00122     NumSymTypes
00123 };
00124 
00125 struct IMAGEHLP_MODULE64 
00126 {  
00127   DWORD SizeOfStruct;  
00128   uint64 BaseOfImage;  
00129   DWORD ImageSize;  
00130   DWORD TimeDateStamp;  
00131   DWORD CheckSum;  
00132   DWORD NumSyms;  
00133   SYM_TYPE SymType;  
00134   CHAR ModuleName[32];  
00135   CHAR ImageName[256];
00136   CHAR LoadedImageName[256];  
00137   /*
00138     The following fields are only supported on newer versions of dbghelp.dll,
00139     but the versions shipped with W2k resp. WXP lack them.
00140    */
00141   CHAR LoadedPdbName[256];  
00142   DWORD CVSig;  
00143   CHAR CVData[MAX_PATH*3];  
00144   DWORD PdbSig;  
00145   GUID PdbSig70;  
00146   DWORD PdbAge;  
00147   BOOL PdbUnmatched;  
00148   BOOL DbgUnmatched;  
00149   BOOL LineNumbers;  
00150   BOOL GlobalSymbols;  
00151   BOOL TypeInfo;
00152 };
00153 typedef IMAGEHLP_MODULE64* PIMAGEHLP_MODULE64;
00154 
00155 struct IMAGEHLP_MODULEW64
00156 {  
00157   DWORD SizeOfStruct;  
00158   uint64 BaseOfImage;  
00159   DWORD ImageSize;  
00160   DWORD TimeDateStamp;  
00161   DWORD CheckSum;  
00162   DWORD NumSyms;  
00163   SYM_TYPE SymType;  
00164   WCHAR ModuleName[32];  
00165   WCHAR ImageName[256];  
00166   WCHAR LoadedImageName[256];
00167   WCHAR LoadedPdbName[256];  
00168   DWORD CVSig;  
00169   WCHAR CVData[MAX_PATH*3];  
00170   DWORD PdbSig;  
00171   GUID PdbSig70;  
00172   DWORD PdbAge;  
00173   BOOL PdbUnmatched;  
00174   BOOL DbgUnmatched;  
00175   BOOL LineNumbers;  
00176   BOOL GlobalSymbols;  
00177   BOOL TypeInfo;
00178 };
00179 typedef IMAGEHLP_MODULEW64* PIMAGEHLP_MODULEW64;
00180 
00181 struct IMAGEHLP_LINE64
00182 {  
00183   DWORD SizeOfStruct;  
00184   PVOID Key;  
00185   DWORD LineNumber;  
00186   PCHAR FileName;  
00187   uint64 Address;
00188 };
00189 typedef IMAGEHLP_LINE64* PIMAGEHLP_LINE64;
00190 
00191 struct IMAGEHLP_LINEW64
00192 {  
00193   DWORD SizeOfStruct;  
00194   PVOID Key;  
00195   DWORD LineNumber;  
00196   PWCHAR FileName;  
00197   uint64 Address;
00198 };
00199 typedef IMAGEHLP_LINEW64* PIMAGEHLP_LINEW64;
00200 
00201 typedef BOOL (CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACK) (PSYMBOL_INFO pSymInfo,
00202   ULONG SymbolSize, PVOID UserContext);
00203 typedef BOOL (CALLBACK* PSYM_ENUMERATESYMBOLS_CALLBACKW) (PSYMBOL_INFOW pSymInfo,
00204   ULONG SymbolSize, PVOID UserContext);
00205 typedef BOOL (CALLBACK* PSYM_ENUMMODULES_CALLBACK64) (PSTR ModuleName,
00206   uint64 BaseOfDll, PVOID UserContext);
00207 typedef BOOL (CALLBACK* PSYM_ENUMMODULES_CALLBACKW64) (PWSTR ModuleName,
00208   uint64 BaseOfDll, PVOID UserContext);
00209 
00210 struct IMAGEHLP_STACK_FRAME 
00211 {  
00212   uint64 InstructionOffset;  
00213   uint64 ReturnOffset;  
00214   uint64 FrameOffset;  
00215   uint64 StackOffset;  
00216   uint64 BackingStoreOffset;  
00217   uint64 FuncTableEntry;  
00218   uint64 Params[4];  
00219   uint64 Reserved[5];  
00220   BOOL Virtual;  
00221   ULONG Reserved2;
00222 };
00223 typedef IMAGEHLP_STACK_FRAME* PIMAGEHLP_STACK_FRAME;
00224 typedef void* PIMAGEHLP_CONTEXT;
00225 
00226 struct MINIDUMP_EXCEPTION_INFORMATION 
00227 {  
00228   DWORD ThreadId;  
00229   PEXCEPTION_POINTERS ExceptionPointers;  
00230   BOOL ClientPointers;
00231 };
00232 typedef MINIDUMP_EXCEPTION_INFORMATION* PMINIDUMP_EXCEPTION_INFORMATION;
00233 
00234 struct MINIDUMP_USER_STREAM 
00235 {  
00236   ULONG32 Type;  
00237   ULONG BufferSize;  
00238   PVOID Buffer;
00239 };
00240 typedef MINIDUMP_USER_STREAM* PMINIDUMP_USER_STREAM;
00241                                                     
00242 struct MINIDUMP_USER_STREAM_INFORMATION 
00243 {  
00244   ULONG UserStreamCount;  
00245   PMINIDUMP_USER_STREAM UserStreamArray;
00246 };
00247 typedef MINIDUMP_USER_STREAM_INFORMATION* PMINIDUMP_USER_STREAM_INFORMATION;
00248 
00249 enum MINIDUMP_CALLBACK_TYPE
00250 {
00251   ModuleCallback, 
00252   ThreadCallback, 
00253   ThreadExCallback, 
00254   IncludeThreadCallback, 
00255   IncludeModuleCallback
00256 };
00257 
00258 struct MINIDUMP_THREAD_CALLBACK 
00259 {  
00260   ULONG ThreadId;  
00261   HANDLE ThreadHandle;  
00262   CONTEXT Context;  
00263   ULONG SizeOfContext;  
00264   ULONG64 StackBase;  
00265   ULONG64 StackEnd;
00266 };
00267 typedef MINIDUMP_THREAD_CALLBACK* PMINIDUMP_THREAD_CALLBACK;
00268 
00269 struct MINIDUMP_THREAD_EX_CALLBACK 
00270 {  
00271   ULONG ThreadId;  
00272   HANDLE ThreadHandle;  
00273   CONTEXT Context;  
00274   ULONG SizeOfContext;  
00275   ULONG64 StackBase;  
00276   ULONG64 StackEnd;  
00277   ULONG64 BackingStoreBase;  
00278   ULONG64 BackingStoreEnd;
00279 };
00280 typedef MINIDUMP_THREAD_EX_CALLBACK* PMINIDUMP_THREAD_EX_CALLBACK;
00281 
00282 #include <winver.h>
00283 #include "sanity.inc"
00284 
00285 struct MINIDUMP_MODULE_CALLBACK 
00286 {  
00287   PWCHAR FullPath;  
00288   ULONG64 BaseOfImage;  
00289   ULONG SizeOfImage;  
00290   ULONG CheckSum;  
00291   ULONG TimeDateStamp;  
00292   VS_FIXEDFILEINFO VersionInfo;  
00293   PVOID CvRecord;  
00294   ULONG SizeOfCvRecord;  
00295   PVOID MiscRecord;  
00296   ULONG SizeOfMiscRecord;
00297 };
00298 typedef MINIDUMP_MODULE_CALLBACK* PMINIDUMP_MODULE_CALLBACK;
00299 
00300 struct MINIDUMP_INCLUDE_THREAD_CALLBACK 
00301 {  
00302   ULONG ThreadId;
00303 };
00304 typedef MINIDUMP_INCLUDE_THREAD_CALLBACK* PMINIDUMP_INCLUDE_THREAD_CALLBACK;
00305 
00306 struct MINIDUMP_INCLUDE_MODULE_CALLBACK 
00307 {  
00308   ULONG64 BaseOfImage;
00309 };
00310 typedef MINIDUMP_INCLUDE_MODULE_CALLBACK* PMINIDUMP_INCLUDE_MODULE_CALLBACK;
00311 
00312 
00313 struct MINIDUMP_CALLBACK_INPUT       
00314 {  
00315   ULONG ProcessId;  
00316   HANDLE ProcessHandle;  
00317   ULONG CallbackType;  
00318   union 
00319   {    
00320     MINIDUMP_THREAD_CALLBACK Thread;    
00321     MINIDUMP_THREAD_EX_CALLBACK ThreadEx;    
00322     MINIDUMP_MODULE_CALLBACK Module;    
00323     MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;    
00324     MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;  
00325   };
00326 };
00327 typedef MINIDUMP_CALLBACK_INPUT* PMINIDUMP_CALLBACK_INPUT;
00328 
00329 enum MODULE_WRITE_FLAGS
00330 {
00331   ModuleWriteModule                     = 0x0001, 
00332   ModuleWriteDataSeg                    = 0x0002, 
00333   ModuleWriteMiscRecord                 = 0x0004, 
00334   ModuleWriteCvRecord                   = 0x0008, 
00335   ModuleReferencedByMemory              = 0x0010
00336 };
00337 
00338 enum THREAD_WRITE_FLAGS
00339 {
00340   ThreadWriteThread                     = 0x0001, 
00341   ThreadWriteStack                      = 0x0002, 
00342   ThreadWriteContext                    = 0x0004, 
00343   ThreadWriteBackingStore               = 0x0008, 
00344   ThreadWriteInstructionWindow          = 0x0010, 
00345   ThreadWriteThreadData                 = 0x0020
00346 };
00347 
00348 struct MINIDUMP_CALLBACK_OUTPUT 
00349 {  
00350   union 
00351   {    
00352     ULONG ModuleWriteFlags;    
00353     ULONG ThreadWriteFlags;  
00354   };
00355 }; 
00356 typedef MINIDUMP_CALLBACK_OUTPUT* PMINIDUMP_CALLBACK_OUTPUT;
00357 
00358 
00359 typedef BOOL (CALLBACK* MINIDUMP_CALLBACK_ROUTINE) (PVOID CallbackParam, 
00360   const PMINIDUMP_CALLBACK_INPUT CallbackInput, 
00361   PMINIDUMP_CALLBACK_OUTPUT CallbackOutput);
00362 
00363 struct MINIDUMP_CALLBACK_INFORMATION 
00364 {  
00365   MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;  
00366   PVOID CallbackParam;
00367 };
00368 typedef MINIDUMP_CALLBACK_INFORMATION* PMINIDUMP_CALLBACK_INFORMATION;
00369 
00370 enum MINIDUMP_TYPE
00371 {
00372   MiniDumpNormal                          = 0x0000, 
00373   MiniDumpWithDataSegs                    = 0x0001, 
00374   MiniDumpWithFullMemory                  = 0x0002, 
00375   MiniDumpWithHandleData                  = 0x0004, 
00376   MiniDumpFilterMemory                    = 0x0008, 
00377   MiniDumpScanMemory                      = 0x0010, 
00378   MiniDumpWithUnloadedModules             = 0x0020, 
00379   MiniDumpWithIndirectlyReferencedMemory  = 0x0040, 
00380   MiniDumpFilterModulePaths               = 0x0080, 
00381   MiniDumpWithProcessThreadData           = 0x0100, 
00382   MiniDumpWithPrivateReadWriteMemory      = 0x0200
00383 };
00384 
00385 enum MINIDUMP_STREAM_TYPE
00386 {
00387   UnusedStream             = 0, 
00388   ReservedStream0          = 1, 
00389   ReservedStream1          = 2, 
00390   ThreadListStream         = 3, 
00391   ModuleListStream         = 4, 
00392   MemoryListStream         = 5, 
00393   ExceptionStream          = 6, 
00394   SystemInfoStream         = 7, 
00395   ThreadExListStream       = 8, 
00396   Memory64ListStream       = 9, 
00397   CommentStreamA           = 10, 
00398   CommentStreamW           = 11, 
00399   HandleDataStream         = 12, 
00400   FunctionTableStream      = 13, 
00401   UnloadedModuleListStream = 14, 
00402   MiscInfoStream           = 15, 
00403   LastReservedStream = 0xffff
00404 };
00405 
00406 struct MINIDUMP_LOCATION_DESCRIPTOR 
00407 {  
00408   uint32 DataSize;  
00409   uint32 Rva;
00410 };
00411 
00412 struct MINIDUMP_MEMORY_DESCRIPTOR 
00413 {  
00414   uint64 StartOfMemoryRange;  
00415   MINIDUMP_LOCATION_DESCRIPTOR Memory;
00416 };
00417 typedef MINIDUMP_MEMORY_DESCRIPTOR* PMINIDUMP_MEMORY_DESCRIPTOR;
00418 
00419 struct MINIDUMP_MEMORY_LIST 
00420 {  
00421   ULONG32 NumberOfMemoryRanges;  
00422   /*MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[];*/
00423 };
00424 typedef MINIDUMP_MEMORY_LIST* PMINIDUMP_MEMORY_LIST;
00425 
00426 struct MINIDUMP_HEADER 
00427 {
00428   ULONG32 Signature;
00429   ULONG32 Version;
00430   ULONG32 NumberOfStreams;
00431   uint32 StreamDirectoryRva;
00432   ULONG32 CheckSum;
00433   union 
00434   {
00435     ULONG32 Reserved;
00436     ULONG32 TimeDateStamp;
00437   };
00438   uint64 Flags;
00439 };
00440 typedef MINIDUMP_HEADER* PMINIDUMP_HEADER;
00441 
00442 struct MINIDUMP_DIRECTORY 
00443 {
00444   ULONG32 StreamType;
00445   MINIDUMP_LOCATION_DESCRIPTOR Location;
00446 };
00447 typedef MINIDUMP_DIRECTORY* PMINIDUMP_DIRECTORY;
00448 
00449 #define CS_API_NAME             DbgHelp
00450 #define CS_API_FUNCTIONS        "csutil/win32/DbgHelpAPI.fun"
00451 
00452 #include "APIdeclare.inc"
00453 
00454 #endif //__CSUTIL_DEBGHELPAPI_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7