#ifndef _DBGHELP_H
#define _DBGHELP_H

/* Windows Debug Help library definitions */

#ifdef _WIN64
#ifndef _IMAGEHLP64
#define _IMAGEHLP64
#endif
#endif /* _WIN64 */

#ifdef __cplusplus
extern "C" {
#endif

#define IMAGEAPI  DECLSPEC_IMPORT __stdcall
#define IMAGE_SEPARATION  (64*1024)

#define UNDNAME_COMPLETE  0x0000
#define UNDNAME_NO_LEADING_UNDERSCORES  0x0001
#define UNDNAME_NO_MS_KEYWORDS  0x0002
#define UNDNAME_NO_FUNCTION_RETURNS  0x0004
#define UNDNAME_NO_ALLOCATION_MODEL  0x0008
#define UNDNAME_NO_ALLOCATION_LANGUAGE  0x0010
#define UNDNAME_NO_MS_THISTYPE  0x0020
#define UNDNAME_NO_CV_THISTYPE  0x0040
#define UNDNAME_NO_THISTYPE  0x0060
#define UNDNAME_NO_ACCESS_SPECIFIERS  0x0080
#define UNDNAME_NO_THROW_SIGNATURES  0x0100
#define UNDNAME_NO_MEMBER_TYPE  0x0200
#define UNDNAME_NO_RETURN_UDT_MODEL  0x0400
#define UNDNAME_32_BIT_DECODE  0x0800
#define UNDNAME_NAME_ONLY  0x1000
#define UNDNAME_NO_ARGUMENTS  0x2000
#define UNDNAME_NO_SPECIAL_SYMS  0x4000

#define API_VERSION_NUMBER  9

#define SYMF_OMAP_GENERATED  0x00000001
#define SYMF_OMAP_MODIFIED  0x00000002

#define CBA_DEFERRED_SYMBOL_LOAD_START  0x00000001
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE  0x00000002
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE  0x00000003
#define CBA_SYMBOLS_UNLOADED  0x00000004
#define CBA_DUPLICATE_SYMBOL  0x00000005
#define CBA_READ_MEMORY  0x00000006
#define CBA_DEBUG_INFO  0x10000000

#define SYMOPT_CASE_INSENSITIVE  0x00000001
#define SYMOPT_UNDNAME  0x00000002
#define SYMOPT_DEFERRED_LOADS  0x00000004
#define SYMOPT_NO_CPP  0x00000008
#define SYMOPT_LOAD_LINES  0x00000010
#define SYMOPT_OMAP_FIND_NEAREST  0x00000020
#define SYMOPT_DEBUG  0x80000000

typedef struct _LOADED_IMAGE {
    PSTR ModuleName;
    HANDLE hFile;
    PUCHAR MappedAddress;
#ifdef _IMAGEHLP64
    PIMAGE_NT_HEADERS64 FileHeader;
#else
    PIMAGE_NT_HEADERS32 FileHeader;
#endif
    PIMAGE_SECTION_HEADER LastRvaSection;
    ULONG NumberOfSections;
    PIMAGE_SECTION_HEADER Sections;
    ULONG Characteristics;
    BOOLEAN fSystemImage;
    BOOLEAN fDOSImage;
    LIST_ENTRY Links;
    ULONG SizeOfImage;
} LOADED_IMAGE, *PLOADED_IMAGE;

typedef BOOL(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(HANDLE,PSTR,PVOID);
typedef BOOL(CALLBACK *PFIND_EXE_FILE_CALLBACK)(HANDLE,PSTR,PVOID);
typedef BOOL(*PSYMBOLSERVERPROC)(LPCSTR,LPCSTR,DWORD,DWORD,DWORD,LPSTR);
typedef BOOL(*PSYMBOLSERVEROPENPROC)(VOID);
typedef BOOL(*PSYMBOLSERVERCLOSEPROC)(VOID);

HANDLE IMAGEAPI FindDebugInfoFile(PSTR,PSTR,PSTR);
HANDLE IMAGEAPI FindDebugInfoFileEx(PSTR,PSTR,PSTR,PFIND_DEBUG_FILE_CALLBACK,PVOID);
BOOL IMAGEAPI FindFileInSearchPath(HANDLE,LPSTR,LPSTR,DWORD,DWORD,DWORD,LPSTR);
HANDLE IMAGEAPI FindExecutableImage(PSTR,PSTR,PSTR);
HANDLE IMAGEAPI FindExecutableImageEx(PSTR,PSTR,PSTR,PFIND_EXE_FILE_CALLBACK,PVOID);
PIMAGE_NT_HEADERS IMAGEAPI ImageNtHeader(PVOID);
PVOID IMAGEAPI ImageDirectoryEntryToDataEx(PVOID,BOOLEAN,USHORT,PULONG,PIMAGE_SECTION_HEADER*);
PVOID IMAGEAPI ImageDirectoryEntryToData(PVOID,BOOLEAN,USHORT,PULONG);
PIMAGE_SECTION_HEADER IMAGEAPI ImageRvaToSection(PIMAGE_NT_HEADERS,PVOID,ULONG);
PVOID IMAGEAPI ImageRvaToVa(PIMAGE_NT_HEADERS,PVOID,ULONG,PIMAGE_SECTION_HEADER*);

#ifndef _WIN64
typedef struct _IMAGE_DEBUG_INFORMATION {
    LIST_ENTRY List;
    DWORD ReservedSize;
    PVOID ReservedMappedBase;
    USHORT ReservedMachine;
    USHORT ReservedCharacteristics;
    DWORD ReservedCheckSum;
    DWORD ImageBase;
    DWORD SizeOfImage;
    DWORD ReservedNumberOfSections;
    PIMAGE_SECTION_HEADER ReservedSections;
    DWORD ReservedExportedNamesSize;
    PSTR ReservedExportedNames;
    DWORD ReservedNumberOfFunctionTableEntries;
    PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
    DWORD ReservedLowestFunctionStartingAddress;
    DWORD ReservedHighestFunctionEndingAddress;
    DWORD ReservedNumberOfFpoTableEntries;
    PFPO_DATA ReservedFpoTableEntries;
    DWORD SizeOfCoffSymbols;
    PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
    DWORD ReservedSizeOfCodeViewSymbols;
    PVOID ReservedCodeViewSymbols;
    PSTR ImageFilePath;
    PSTR ImageFileName;
    PSTR ReservedDebugFilePath;
    DWORD ReservedTimeDateStamp;
    BOOL ReservedRomImage;
    PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
    DWORD ReservedNumberOfDebugDirectories;
    DWORD ReservedOriginalFunctionTableBaseAddress;
    DWORD Reserved[2];
} IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;

PIMAGE_DEBUG_INFORMATION IMAGEAPI MapDebugInformation(HANDLE,PSTR,PSTR,DWORD);
BOOL IMAGEAPI UnmapDebugInformation(PIMAGE_DEBUG_INFORMATION);
#endif /* _WIN64 */

BOOL IMAGEAPI SearchTreeForFile(PSTR,PSTR,PSTR);
BOOL IMAGEAPI MakeSureDirectoryPathExists(PCSTR);
DWORD IMAGEAPI UnDecorateSymbolName(PCSTR,PSTR,DWORD,DWORD);

typedef enum {
    AddrMode1616,
    AddrMode1632,
    AddrModeReal,
    AddrModeFlat
} ADDRESS_MODE;

typedef struct _tagADDRESS64 {
    DWORD64 Offset;
    WORD Segment;
    ADDRESS_MODE Mode;
} ADDRESS64, *LPADDRESS64;

#ifdef _IMAGEHLP64
#define ADDRESS  ADDRESS64
#define LPADDRESS  LPADDRESS64
#else
typedef struct _tagADDRESS {
    DWORD Offset;
    WORD Segment;
    ADDRESS_MODE Mode;
} ADDRESS, *LPADDRESS;

__inline void Address32To64(LPADDRESS a32,LPADDRESS64 a64) { a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset; a64->Segment = a32->Segment; a64->Mode = a32->Mode; }
__inline void Address64To32(LPADDRESS64 a64,LPADDRESS a32) { a32->Offset = (ULONG)a64->Offset; a32->Segment = a64->Segment; a32->Mode = a64->Mode; }
#endif /* _IMAGEHLP64 */

typedef struct _KDHELP64 {
    DWORD64 Thread;
    DWORD ThCallbackStack;
    DWORD ThCallbackBStore;
    DWORD NextCallback;
    DWORD FramePointer;
    DWORD64 KiCallUserMode;
    DWORD64 KeUserCallbackDispatcher;
    DWORD64 SystemRangeStart;
    DWORD64 Reserved[8];
} KDHELP64, *PKDHELP64;

#ifdef _IMAGEHLP64
#define KDHELP  KDHELP64
#define PKDHELP  PKDHELP64
#else
typedef struct _KDHELP {
    DWORD Thread;
    DWORD ThCallbackStack;
    DWORD NextCallback;
    DWORD FramePointer;
    DWORD KiCallUserMode;
    DWORD KeUserCallbackDispatcher;
    DWORD SystemRangeStart;
    DWORD ThCallbackBStore;
    DWORD Reserved[8];
} KDHELP, *PKDHELP;

__inline void KdHelp32To64(PKDHELP p32, PKDHELP64 p64) {
    p64->Thread = p32->Thread;
    p64->ThCallbackStack = p32->ThCallbackStack;
    p64->NextCallback = p32->NextCallback;
    p64->FramePointer = p32->FramePointer;
    p64->KiCallUserMode = p32->KiCallUserMode;
    p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
    p64->SystemRangeStart = p32->SystemRangeStart;
}
#endif /* _IMAGEHLP64 */

typedef struct _tagSTACKFRAME64 {
    ADDRESS64 AddrPC;
    ADDRESS64 AddrReturn;
    ADDRESS64 AddrFrame;
    ADDRESS64 AddrStack;
    ADDRESS64 AddrBStore;
    PVOID FuncTableEntry;
    DWORD64 Params[4];
    BOOL Far;
    BOOL Virtual;
    DWORD64 Reserved[3];
    KDHELP64 KdHelp;
} STACKFRAME64, *LPSTACKFRAME64;

#ifdef _IMAGEHLP64
#define STACKFRAME  STACKFRAME64
#define LPSTACKFRAME  LPSTACKFRAME64
#else
typedef struct _tagSTACKFRAME {
    ADDRESS AddrPC;
    ADDRESS AddrReturn;
    ADDRESS AddrFrame;
    ADDRESS AddrStack;
    PVOID FuncTableEntry;
    DWORD Params[4];
    BOOL Far;
    BOOL Virtual;
    DWORD Reserved[3];
    KDHELP KdHelp;
    ADDRESS AddrBStore;
} STACKFRAME, *LPSTACKFRAME;
#endif /* _IMAGEHLP64 */

typedef BOOL(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64) (HANDLE,DWORD64,PVOID,DWORD,LPDWORD);
typedef PVOID(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE,DWORD64);
typedef DWORD64(__stdcall *PGET_MODULE_BASE_ROUTINE64)(HANDLE,DWORD64);
typedef DWORD64(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE,HANDLE,LPADDRESS64);

BOOL IMAGEAPI StackWalk64(DWORD,HANDLE,HANDLE,LPSTACKFRAME64,PVOID,PREAD_PROCESS_MEMORY_ROUTINE64,PFUNCTION_TABLE_ACCESS_ROUTINE64,PGET_MODULE_BASE_ROUTINE64,PTRANSLATE_ADDRESS_ROUTINE64);

#ifdef _IMAGEHLP64
#define PREAD_PROCESS_MEMORY_ROUTINE  PREAD_PROCESS_MEMORY_ROUTINE64
#define PFUNCTION_TABLE_ACCESS_ROUTINE  PFUNCTION_TABLE_ACCESS_ROUTINE64
#define PGET_MODULE_BASE_ROUTINE  PGET_MODULE_BASE_ROUTINE64
#define PTRANSLATE_ADDRESS_ROUTINE  PTRANSLATE_ADDRESS_ROUTINE64
#define StackWalk  StackWalk64
#else
typedef BOOL(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE) (HANDLE,DWORD,PVOID,DWORD,PDWORD);
typedef PVOID(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(HANDLE,DWORD);
typedef DWORD(__stdcall *PGET_MODULE_BASE_ROUTINE)(HANDLE,DWORD);
typedef DWORD(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(HANDLE,HANDLE,LPADDRESS);
BOOL IMAGEAPI StackWalk(DWORD,HANDLE,HANDLE,LPSTACKFRAME,PVOID,PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,PGET_MODULE_BASE_ROUTINE,PTRANSLATE_ADDRESS_ROUTINE);
#endif /* _IMAGEHLP64 */

typedef struct API_VERSION {
    USHORT MajorVersion;
    USHORT MinorVersion;
    USHORT Revision;
    USHORT Reserved;
} API_VERSION, *LPAPI_VERSION;

LPAPI_VERSION IMAGEAPI ImagehlpApiVersion(VOID);
LPAPI_VERSION IMAGEAPI ImagehlpApiVersionEx(LPAPI_VERSION);
DWORD IMAGEAPI GetTimestampForLoadedLibrary(HMODULE);

typedef BOOL(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(PSTR,DWORD64,PVOID);
typedef BOOL(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(PSTR,DWORD64,ULONG,PVOID);
typedef BOOL(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(PWSTR,DWORD64,ULONG,PVOID);
typedef BOOL(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(PSTR,DWORD64,ULONG,PVOID);
typedef BOOL(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(HANDLE,ULONG,ULONG64,ULONG64);
typedef PVOID(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(HANDLE,DWORD,PVOID);
typedef PVOID(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(HANDLE,ULONG64,ULONG64);

#ifdef _IMAGEHLP64
#define PSYM_ENUMMODULES_CALLBACK  PSYM_ENUMMODULES_CALLBACK64
#define PSYM_ENUMSYMBOLS_CALLBACK  PSYM_ENUMSYMBOLS_CALLBACK64
#define PSYM_ENUMSYMBOLS_CALLBACKW  PSYM_ENUMSYMBOLS_CALLBACK64W
#define PENUMLOADED_MODULES_CALLBACK  PENUMLOADED_MODULES_CALLBACK64
#define PSYMBOL_REGISTERED_CALLBACK  PSYMBOL_REGISTERED_CALLBACK64
#define PSYMBOL_FUNCENTRY_CALLBACK  PSYMBOL_FUNCENTRY_CALLBACK64
#else
typedef BOOL(CALLBACK *PSYM_ENUMMODULES_CALLBACK)(PSTR,ULONG,PVOID);
typedef BOOL(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(PSTR,ULONG,ULONG,PVOID);
typedef BOOL(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(PWSTR,ULONG,ULONG,PVOID);
typedef BOOL(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(PSTR,ULONG,ULONG,PVOID);
typedef BOOL(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(HANDLE,ULONG,PVOID,PVOID);
#endif /* _IMAGEHLP64 */

typedef enum {
    SymNone,
    SymCoff,
    SymCv,
    SymPdb,
    SymExport,
    SymDeferred,
    SymSym
} SYM_TYPE;

typedef struct _IMAGEHLP_SYMBOL64 {
    DWORD SizeOfStruct;
    DWORD64 Address;
    DWORD Size;
    DWORD Flags;
    DWORD MaxNameLength;
    CHAR Name[1];
} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;

#ifdef _IMAGEHLP64
#define IMAGEHLP_SYMBOL  IMAGEHLP_SYMBOL64
#define PIMAGEHLP_SYMBOL  PIMAGEHLP_SYMBOL64
#else
typedef struct _IMAGEHLP_SYMBOL {
    DWORD SizeOfStruct;
    DWORD Address;
    DWORD Size;
    DWORD Flags;
    DWORD MaxNameLength;
    CHAR Name[1];
} IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
#endif /* _IMAGEHLP64 */

typedef struct _IMAGEHLP_MODULE64 {
    DWORD SizeOfStruct;
    DWORD64 BaseOfImage;
    DWORD ImageSize;
    DWORD TimeDateStamp;
    DWORD CheckSum;
    DWORD NumSyms;
    SYM_TYPE SymType;
    CHAR ModuleName[32];
    CHAR ImageName[256];
    CHAR LoadedImageName[256];
} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;

typedef struct _IMAGEHLP_MODULE64W {
    DWORD SizeOfStruct;
    DWORD64 BaseOfImage;
    DWORD ImageSize;
    DWORD TimeDateStamp;
    DWORD CheckSum;
    DWORD NumSyms;
    SYM_TYPE SymType;
    WCHAR ModuleName[32];
    WCHAR ImageName[256];
    WCHAR LoadedImageName[256];
} IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;

#ifdef _IMAGEHLP64
#define IMAGEHLP_MODULE  IMAGEHLP_MODULE64
#define PIMAGEHLP_MODULE  PIMAGEHLP_MODULE64
#define IMAGEHLP_MODULEW  IMAGEHLP_MODULEW64
#define PIMAGEHLP_MODULEW  PIMAGEHLP_MODULEW64
#else
typedef struct _IMAGEHLP_MODULE {
    DWORD SizeOfStruct;
    DWORD BaseOfImage;
    DWORD ImageSize;
    DWORD TimeDateStamp;
    DWORD CheckSum;
    DWORD NumSyms;
    SYM_TYPE SymType;
    CHAR ModuleName[32];
    CHAR ImageName[256];
    CHAR LoadedImageName[256];
} IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;

typedef struct _IMAGEHLP_MODULEW {
    DWORD SizeOfStruct;
    DWORD BaseOfImage;
    DWORD ImageSize;
    DWORD TimeDateStamp;
    DWORD CheckSum;
    DWORD NumSyms;
    SYM_TYPE SymType;
    WCHAR ModuleName[32];
    WCHAR ImageName[256];
    WCHAR LoadedImageName[256];
} IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW;
#endif /* _IMAGEHLP64 */

typedef struct _IMAGEHLP_LINE64 {
    DWORD SizeOfStruct;
    PVOID Key;
    DWORD LineNumber;
    PCHAR FileName;
    DWORD64 Address;
} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;

#ifdef _IMAGEHLP64
#define IMAGEHLP_LINE  IMAGEHLP_LINE64
#define PIMAGEHLP_LINE  PIMAGEHLP_LINE64
#else
typedef struct _IMAGEHLP_LINE {
    DWORD SizeOfStruct;
    PVOID Key;
    DWORD LineNumber;
    PCHAR FileName;
    DWORD Address;
} IMAGEHLP_LINE, *PIMAGEHLP_LINE;
#endif /* _IMAGEHLP64 */

typedef struct _IMAGEHLP_CBA_READ_MEMORY {
    DWORD64 addr;
    PVOID buf;
    DWORD bytes;
    DWORD *bytesread;
} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY;

typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
    DWORD SizeOfStruct;
    DWORD64 BaseOfImage;
    DWORD CheckSum;
    DWORD TimeDateStamp;
    CHAR FileName[MAX_PATH];
    BOOLEAN Reparse;
} IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;

#ifdef _IMAGEHLP64
#define IMAGEHLP_DEFERRED_SYMBOL_LOAD  IMAGEHLP_DEFERRED_SYMBOL_LOAD64
#define PIMAGEHLP_DEFERRED_SYMBOL_LOAD  PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
#else
typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
    DWORD SizeOfStruct;
    DWORD BaseOfImage;
    DWORD CheckSum;
    DWORD TimeDateStamp;
    CHAR FileName[MAX_PATH];
    BOOLEAN Reparse;
} IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
#endif /* _IMAGEHLP64 */

typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
    DWORD SizeOfStruct;
    DWORD NumberOfDups;
    PIMAGEHLP_SYMBOL64 Symbol;
    DWORD SelectedSymbol;
} IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64;

#ifdef _IMAGEHLP64
#define IMAGEHLP_DUPLICATE_SYMBOL  IMAGEHLP_DUPLICATE_SYMBOL64
#define PIMAGEHLP_DUPLICATE_SYMBOL  PIMAGEHLP_DUPLICATE_SYMBOL64
#else
typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
    DWORD SizeOfStruct;
    DWORD NumberOfDups;
    PIMAGEHLP_SYMBOL Symbol;
    DWORD SelectedSymbol;
} IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
#endif /* _IMAGEHLP64 */

DWORD IMAGEAPI SymSetOptions(DWORD);
DWORD IMAGEAPI SymGetOptions(VOID);
BOOL IMAGEAPI SymCleanup(HANDLE);
BOOL IMAGEAPI SymEnumerateModules64(HANDLE,PSYM_ENUMMODULES_CALLBACK64,PVOID);
BOOL IMAGEAPI SymEnumerateSymbols64(HANDLE,DWORD64,PSYM_ENUMSYMBOLS_CALLBACK64,PVOID);
BOOL IMAGEAPI SymEnumerateSymbolsW64(HANDLE,DWORD64,PSYM_ENUMSYMBOLS_CALLBACK64W,PVOID);
BOOL IMAGEAPI EnumerateLoadedModules64(HANDLE,PENUMLOADED_MODULES_CALLBACK64,PVOID);
PVOID IMAGEAPI SymFunctionTableAccess64(HANDLE,DWORD64);
BOOL IMAGEAPI SymGetModuleInfo64(HANDLE,DWORD64,PIMAGEHLP_MODULE64);
BOOL IMAGEAPI SymGetModuleInfoW64(HANDLE,DWORD64,PIMAGEHLP_MODULEW64);
DWORD64 IMAGEAPI SymGetModuleBase64(HANDLE,DWORD64);
BOOL IMAGEAPI SymGetSymFromAddr64(HANDLE,DWORD64,PDWORD64,PIMAGEHLP_SYMBOL64);
BOOL IMAGEAPI SymGetSymFromName64(HANDLE,PSTR,PIMAGEHLP_SYMBOL64);
BOOL IMAGEAPI SymGetSymNext64(HANDLE,PIMAGEHLP_SYMBOL64);
BOOL IMAGEAPI SymGetSymPrev64(HANDLE,PIMAGEHLP_SYMBOL64);
BOOL IMAGEAPI SymGetLineFromAddr64(HANDLE,DWORD64,PDWORD,PIMAGEHLP_LINE64);
BOOL IMAGEAPI SymGetLineFromName64(HANDLE,PSTR,PSTR,DWORD,PLONG,PIMAGEHLP_LINE64);
BOOL IMAGEAPI SymGetLineNext64(HANDLE,PIMAGEHLP_LINE64);
BOOL IMAGEAPI SymGetLinePrev64(HANDLE,PIMAGEHLP_LINE64);
BOOL IMAGEAPI SymMatchFileName(PSTR,PSTR,PSTR*,PSTR*);
BOOL IMAGEAPI SymInitialize(HANDLE,PSTR,BOOL);
BOOL IMAGEAPI SymGetSearchPath(HANDLE,PSTR,DWORD);
BOOL IMAGEAPI SymSetSearchPath(HANDLE,PSTR);
DWORD64 IMAGEAPI SymLoadModule64(HANDLE,HANDLE,PSTR,PSTR,DWORD64,DWORD);
BOOL IMAGEAPI SymUnloadModule64(HANDLE,DWORD64);
BOOL IMAGEAPI SymUnDName64(PIMAGEHLP_SYMBOL64,PSTR,DWORD);
BOOL IMAGEAPI SymRegisterCallback64(HANDLE,PSYMBOL_REGISTERED_CALLBACK64,ULONG64);
BOOL IMAGEAPI SymRegisterFunctionEntryCallback64(HANDLE,PSYMBOL_FUNCENTRY_CALLBACK64,ULONG64);

#ifdef _IMAGEHLP64
#define SymEnumerateModules SymEnumerateModules64
#define SymEnumerateSymbols  SymEnumerateSymbols64
#define SymEnumerateSymbolsW  SymEnumerateSymbolsW64
#define EnumerateLoadedModules  EnumerateLoadedModules64
#define SymFunctionTableAccess  SymFunctionTableAccess64
#define SymGetModuleInfo  SymGetModuleInfo64
#define SymGetModuleInfoW  SymGetModuleInfoW64
#define SymGetModuleBase  SymGetModuleBase64
#define SymGetSymFromAddr  SymGetSymFromAddr64
#define SymGetSymFromName  SymGetSymFromName64
#define SymGetSymNext  SymGetSymNext64
#define SymGetSymPrev  SymGetSymPrev64
#define SymGetLineFromAddr  SymGetLineFromAddr64
#define SymGetLineFromName  SymGetLineFromName64
#define SymGetLineNext  SymGetLineNext64
#define SymGetLinePrev  SymGetLinePrev64
#define SymLoadModule  SymLoadModule64
#define SymUnloadModule SymUnloadModule64
#define SymUnDName  SymUnDName64
#define SymRegisterCallback  SymRegisterCallback64
#define SymRegisterFunctionEntryCallback  SymRegisterFunctionEntryCallback64
#else
BOOL IMAGEAPI SymEnumerateModules(HANDLE,PSYM_ENUMMODULES_CALLBACK,PVOID);
BOOL IMAGEAPI SymEnumerateSymbols(HANDLE,DWORD,PSYM_ENUMSYMBOLS_CALLBACK,PVOID);
BOOL IMAGEAPI SymEnumerateSymbolsW(HANDLE,DWORD,PSYM_ENUMSYMBOLS_CALLBACKW,PVOID);
BOOL IMAGEAPI EnumerateLoadedModules(HANDLE,PENUMLOADED_MODULES_CALLBACK,PVOID);
PVOID IMAGEAPI SymFunctionTableAccess(HANDLE,DWORD);
BOOL IMAGEAPI SymGetModuleInfo(HANDLE,DWORD,PIMAGEHLP_MODULE);
BOOL IMAGEAPI SymGetModuleInfoW(HANDLE,DWORD,PIMAGEHLP_MODULEW);
DWORD IMAGEAPI SymGetModuleBase(HANDLE,DWORD);
BOOL IMAGEAPI SymGetSymFromAddr(HANDLE,DWORD,PDWORD,PIMAGEHLP_SYMBOL);
BOOL IMAGEAPI SymGetSymFromName(HANDLE,PSTR,PIMAGEHLP_SYMBOL);
BOOL IMAGEAPI SymGetSymNext(HANDLE,PIMAGEHLP_SYMBOL);
BOOL IMAGEAPI SymGetSymPrev(HANDLE,PIMAGEHLP_SYMBOL);
BOOL IMAGEAPI SymGetLineFromAddr(HANDLE,DWORD,PDWORD,PIMAGEHLP_LINE);
BOOL IMAGEAPI SymGetLineFromName(HANDLE,PSTR,PSTR,DWORD,PLONG,PIMAGEHLP_LINE);
BOOL IMAGEAPI SymGetLineNext(HANDLE,PIMAGEHLP_LINE);
BOOL IMAGEAPI SymGetLinePrev(HANDLE,PIMAGEHLP_LINE);
DWORD IMAGEAPI SymLoadModule(HANDLE,HANDLE,PSTR,PSTR,DWORD,DWORD);
BOOL IMAGEAPI SymUnloadModule(HANDLE,DWORD);
BOOL IMAGEAPI SymUnDName(PIMAGEHLP_SYMBOL,PSTR,DWORD);
BOOL IMAGEAPI SymRegisterCallback(HANDLE,PSYMBOL_REGISTERED_CALLBACK,PVOID);
BOOL IMAGEAPI SymRegisterFunctionEntryCallback(HANDLE,PSYMBOL_FUNCENTRY_CALLBACK,PVOID);
#endif

#ifdef __cplusplus
}
#endif

typedef enum IMAGEHLP_TYPES {
    IMAGEHLP_TYPEID_INDEX = 1,
    IMAGEHLP_TYPEID_NAME,
    IMAGEHLP_TYPEID_IMAGEHLP_SYMBOL,
    IMAGEHLP_TYPEID_IMAGEHLP_SYMBOL64,
    IMAGEHLP_TYPEID_MODULE_TYPE_INFO,
    IMAGEHLP_TYPEID_TYPE_ENUM_INFO,
} IMAGEHLP_TYPES;

typedef struct _MODULE_TYPE_INFO {
    USHORT dataLength;
    USHORT leaf;
    BYTE data[1];
} MODULE_TYPE_INFO, *PMODULE_TYPE_INFO;

typedef BOOL(CALLBACK *PSYMBOL_TYPE_NAME_CALLBACK)(PSTR,ULONG,PVOID);

typedef struct _TYPE_ENUM_INFO {
    PVOID CallerData;
    PSYMBOL_TYPE_NAME_CALLBACK CallbackRoutine;
} TYPE_ENUM_INFO, *PTYPE_ENUM_INFO;

BOOL IMAGEAPI SymGetModuleInfoEx64(HANDLE,DWORD64,IMAGEHLP_TYPES,PBYTE,IMAGEHLP_TYPES,PULONG,PBYTE);
BOOL IMAGEAPI SymGetSymbolInfo64(HANDLE,DWORD64,IMAGEHLP_TYPES,PBYTE,IMAGEHLP_TYPES,PULONG,PBYTE);

#ifdef _IMAGEHLP64
#define SymGetModuleInfoEx  SymGetModuleInfoEx64
#define SymGetSymbolInfo  SymGetSymbolInfo64
#else
BOOL IMAGEAPI SymGetModuleInfoEx(HANDLE,DWORD,IMAGEHLP_TYPES,PBYTE,IMAGEHLP_TYPES,PULONG,PBYTE);
BOOL IMAGEAPI SymGetSymbolInfo(HANDLE,DWORD,IMAGEHLP_TYPES,PBYTE,IMAGEHLP_TYPES,PULONG,PBYTE);
#endif

#endif /* _DBGHELP_H */
