50115180d7f1835772d5c440315d90cdd0ed3d5a
[reactos.git] / reactos / include / psdk / imagehlp.h
1 /*
2 imagehlp.h - Include file for IMAGEHLP.DLL APIs
3
4 Written by Mumit Khan <khan@nanotech.wisc.edu>
5
6 This file is part of a free library for the Win32 API.
7
8 NOTE: This strictly does not belong in the Win32 API since it's
9 really part of Platform SDK. However,GDB needs it and we might
10 as well provide it here.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16 */
17
18 #ifndef _IMAGEHLP_H
19 #define _IMAGEHLP_H
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #include <wintrust.h>
26
27 #define API_VERSION_NUMBER 7
28 #define BIND_NO_BOUND_IMPORTS 0x00000001
29 #define BIND_NO_UPDATE 0x00000002
30 #define BIND_ALL_IMAGES 0x00000004
31 #define BIND_CACHE_IMPORT_DLLS 0x00000008
32 #define CBA_DEFERRED_SYMBOL_LOAD_START 1
33 #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 2
34 #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 3
35 #define CBA_SYMBOLS_UNLOADED 4
36 #define CBA_DUPLICATE_SYMBOL 5
37 #define CERT_PE_IMAGE_DIGEST_DEBUG_INFO 1
38 #define CERT_PE_IMAGE_DIGEST_RESOURCES 2
39 #define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO 4
40 #define CERT_PE_IMAGE_DIGEST_NON_PE_INFO 8
41 #define CERT_SECTION_TYPE_ANY 255
42 #define CHECKSUM_SUCCESS 0
43 #define CHECKSUM_OPEN_FAILURE 1
44 #define CHECKSUM_MAP_FAILURE 2
45 #define CHECKSUM_MAPVIEW_FAILURE 3
46 #define CHECKSUM_UNICODE_FAILURE 4
47 #define IMAGE_SEPARATION 65536
48 #define SPLITSYM_REMOVE_PRIVATE 1
49 #define SPLITSYM_EXTRACT_ALL 2
50 #define SPLITSYM_SYMBOLPATH_IS_SRC 4
51 #define SYMF_OMAP_GENERATED 1
52 #define SYMF_OMAP_MODIFIED 2
53 #define SYMOPT_CASE_INSENSITIVE 1
54 #define SYMOPT_UNDNAME 2
55 #define SYMOPT_DEFERRED_LOADS 4
56 #define SYMOPT_NO_CPP 8
57 #define SYMOPT_LOAD_LINES 16
58 #define SYMOPT_OMAP_FIND_NEAREST 32
59 #define UNDNAME_COMPLETE 0
60 #define UNDNAME_NO_LEADING_UNDERSCORES 1
61 #define UNDNAME_NO_MS_KEYWORDS 2
62 #define UNDNAME_NO_FUNCTION_RETURNS 4
63 #define UNDNAME_NO_ALLOCATION_MODEL 8
64 #define UNDNAME_NO_ALLOCATION_LANGUAGE 16
65 #define UNDNAME_NO_MS_THISTYPE 32
66 #define UNDNAME_NO_CV_THISTYPE 64
67 #define UNDNAME_NO_THISTYPE 96
68 #define UNDNAME_NO_ACCESS_SPECIFIERS 128
69 #define UNDNAME_NO_THROW_SIGNATURES 256
70 #define UNDNAME_NO_MEMBER_TYPE 512
71 #define UNDNAME_NO_RETURN_UDT_MODEL 1024
72 #define UNDNAME_32_BIT_DECODE 2048
73 #define UNDNAME_NAME_ONLY 4096
74 #define UNDNAME_NO_ARGUMENTS 8192
75 #define UNDNAME_NO_SPECIAL_SYMS 16384
76
77 #ifdef _IMAGEHLP_SOURCE_
78 #define IMAGEAPI __stdcall
79 #define DBHLP_DEPRECIATED
80 #else
81 #define IMAGEAPI DECLSPEC_IMPORT __stdcall
82 #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
83 #define DBHLP_DEPRECIATED __declspec(deprecated)
84 #else
85 #define DBHLP_DEPRECIATED
86 #endif
87 #endif
88
89 #define DBHLPAPI IMAGEAPI
90
91 #ifndef RC_INVOKED
92
93 typedef enum _IMAGEHLP_STATUS_REASON {
94 BindOutOfMemory,
95 BindRvaToVaFailed,
96 BindNoRoomInImage,
97 BindImportModuleFailed,
98 BindImportProcedureFailed,
99 BindImportModule,
100 BindImportProcedure,
101 BindForwarder,
102 BindForwarderNOT,
103 BindImageModified,
104 BindExpandFileHeaders,
105 BindImageComplete,
106 BindMismatchedSymbols,
107 BindSymbolsNotUpdated
108 } IMAGEHLP_STATUS_REASON;
109 typedef BOOL(WINAPI*PIMAGEHLP_STATUS_ROUTINE)(IMAGEHLP_STATUS_REASON,LPSTR,LPSTR,ULONG,ULONG);
110 typedef struct _LOADED_IMAGE {
111 PSTR ModuleName;
112 HANDLE hFile;
113 PUCHAR MappedAddress;
114 #ifdef _IMAGEHLP64
115 PIMAGE_NT_HEADERS64 FileHeader;
116 #else
117 PIMAGE_NT_HEADERS32 FileHeader;
118 #endif
119 PIMAGE_SECTION_HEADER LastRvaSection;
120 ULONG NumberOfSections;
121 PIMAGE_SECTION_HEADER Sections;
122 ULONG Characteristics;
123 BOOLEAN fSystemImage;
124 BOOLEAN fDOSImage;
125 BOOLEAN fReadOnly;
126 UCHAR Version;
127 LIST_ENTRY Links;
128 ULONG SizeOfImage;
129 } LOADED_IMAGE,*PLOADED_IMAGE;
130 typedef struct _IMAGE_DEBUG_INFORMATION {
131 LIST_ENTRY List;
132 DWORD Size;
133 PVOID MappedBase;
134 USHORT Machine;
135 USHORT Characteristics;
136 DWORD CheckSum;
137 DWORD ImageBase;
138 DWORD SizeOfImage;
139 DWORD NumberOfSections;
140 PIMAGE_SECTION_HEADER Sections;
141 DWORD ExportedNamesSize;
142 LPSTR ExportedNames;
143 DWORD NumberOfFunctionTableEntries;
144 PIMAGE_FUNCTION_ENTRY FunctionTableEntries;
145 DWORD LowestFunctionStartingAddress;
146 DWORD HighestFunctionEndingAddress;
147 DWORD NumberOfFpoTableEntries;
148 PFPO_DATA FpoTableEntries;
149 DWORD SizeOfCoffSymbols;
150 PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
151 DWORD SizeOfCodeViewSymbols;
152 PVOID CodeViewSymbols;
153 LPSTR ImageFilePath;
154 LPSTR ImageFileName;
155 LPSTR DebugFilePath;
156 DWORD TimeDateStamp;
157 BOOL RomImage;
158 PIMAGE_DEBUG_DIRECTORY DebugDirectory;
159 DWORD NumberOfDebugDirectories;
160 DWORD Reserved[3];
161 } IMAGE_DEBUG_INFORMATION,*PIMAGE_DEBUG_INFORMATION;
162 typedef enum {
163 AddrMode1616,
164 AddrMode1632,
165 AddrModeReal,
166 AddrModeFlat
167 } ADDRESS_MODE;
168 typedef struct _tagADDRESS {
169 DWORD Offset;
170 WORD Segment;
171 ADDRESS_MODE Mode;
172 } ADDRESS,*LPADDRESS;
173 typedef struct _KDHELP {
174 DWORD Thread;
175 DWORD ThCallbackStack;
176 DWORD NextCallback;
177 DWORD FramePointer;
178 DWORD KiCallUserMode;
179 DWORD KeUserCallbackDispatcher;
180 DWORD SystemRangeStart;
181 } KDHELP,*PKDHELP;
182 typedef struct _tagSTACKFRAME {
183 ADDRESS AddrPC;
184 ADDRESS AddrReturn;
185 ADDRESS AddrFrame;
186 ADDRESS AddrStack;
187 LPVOID FuncTableEntry;
188 DWORD Params[4];
189 BOOL Far;
190 BOOL Virtual;
191 DWORD Reserved[3];
192 KDHELP KdHelp;
193 } STACKFRAME,*LPSTACKFRAME;
194 typedef BOOL(WINAPI*PREAD_PROCESS_MEMORY_ROUTINE)(HANDLE ,LPCVOID,LPVOID,DWORD,LPDWORD);
195 typedef LPVOID(WINAPI*PFUNCTION_TABLE_ACCESS_ROUTINE)(HANDLE,DWORD);
196 typedef DWORD(WINAPI*PGET_MODULE_BASE_ROUTINE)(HANDLE,DWORD);
197 typedef DWORD(WINAPI*PTRANSLATE_ADDRESS_ROUTINE)(HANDLE,HANDLE,LPADDRESS);
198 typedef struct API_VERSION {
199 USHORT MajorVersion;
200 USHORT MinorVersion;
201 USHORT Revision;
202 USHORT Reserved;
203 } API_VERSION,*LPAPI_VERSION;
204 typedef BOOL(CALLBACK*PSYM_ENUMMODULES_CALLBACK)(LPSTR,ULONG,PVOID);
205 typedef BOOL(CALLBACK*PSYM_ENUMSYMBOLS_CALLBACK)(LPSTR,ULONG,ULONG,PVOID);
206 typedef BOOL(CALLBACK*PENUMLOADED_MODULES_CALLBACK)(LPSTR,ULONG,ULONG,PVOID);
207 typedef BOOL(CALLBACK*PSYMBOL_REGISTERED_CALLBACK)(HANDLE,ULONG,PVOID,PVOID);
208 typedef enum {
209 SymNone,
210 SymCoff,
211 SymCv,
212 SymPdb,
213 SymExport,
214 SymDeferred,
215 SymSym
216 } SYM_TYPE;
217 typedef struct _IMAGEHLP_SYMBOL {
218 DWORD SizeOfStruct;
219 DWORD Address;
220 DWORD Size;
221 DWORD Flags;
222 DWORD MaxNameLength;
223 CHAR Name[1];
224 } IMAGEHLP_SYMBOL,*PIMAGEHLP_SYMBOL;
225 typedef struct _IMAGEHLP_MODULE {
226 DWORD SizeOfStruct;
227 DWORD BaseOfImage;
228 DWORD ImageSize;
229 DWORD TimeDateStamp;
230 DWORD CheckSum;
231 DWORD NumSyms;
232 SYM_TYPE SymType;
233 CHAR ModuleName[32];
234 CHAR ImageName[256];
235 CHAR LoadedImageName[256];
236 } IMAGEHLP_MODULE,*PIMAGEHLP_MODULE;
237 typedef struct _IMAGEHLP_LINE {
238 DWORD SizeOfStruct;
239 DWORD Key;
240 DWORD LineNumber;
241 PCHAR FileName;
242 DWORD Address;
243 } IMAGEHLP_LINE,*PIMAGEHLP_LINE;
244 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
245 DWORD SizeOfStruct;
246 DWORD BaseOfImage;
247 DWORD CheckSum;
248 DWORD TimeDateStamp;
249 CHAR FileName[MAX_PATH];
250 BOOLEAN Reparse;
251 } IMAGEHLP_DEFERRED_SYMBOL_LOAD,*PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
252 typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
253 DWORD SizeOfStruct;
254 DWORD NumberOfDups;
255 PIMAGEHLP_SYMBOL Symbol;
256 ULONG SelectedSymbol;
257 } IMAGEHLP_DUPLICATE_SYMBOL,*PIMAGEHLP_DUPLICATE_SYMBOL;
258 typedef PVOID DIGEST_HANDLE;
259 typedef BOOL(WINAPI*DIGEST_FUNCTION)(DIGEST_HANDLE refdata,PBYTE pData,DWORD dwLength);
260
261 PIMAGE_NT_HEADERS IMAGEAPI CheckSumMappedFile(LPVOID,DWORD,LPDWORD,LPDWORD);
262 DWORD IMAGEAPI MapFileAndCheckSumA(PCSTR,LPDWORD,LPDWORD);
263 DWORD IMAGEAPI MapFileAndCheckSumW(PCWSTR,LPDWORD,LPDWORD);
264 BOOL IMAGEAPI TouchFileTimes(HANDLE,LPSYSTEMTIME);
265 BOOL IMAGEAPI SplitSymbols(PSTR,PCSTR,PSTR,DWORD);
266 HANDLE IMAGEAPI FindDebugInfoFile(PCSTR,PCSTR,PSTR);
267 HANDLE IMAGEAPI FindExecutableImage(PCSTR,PCSTR,PSTR);
268 BOOL IMAGEAPI UpdateDebugInfoFile(PCSTR,PCSTR,PSTR,PIMAGE_NT_HEADERS32);
269 BOOL IMAGEAPI UpdateDebugInfoFileEx(PCSTR,PCSTR,PSTR,PIMAGE_NT_HEADERS32,DWORD);
270 BOOL IMAGEAPI BindImage(IN PCSTR,IN PCSTR,IN PCSTR);
271 BOOL IMAGEAPI BindImageEx(IN DWORD,IN LPCSTR,IN LPCSTR,IN LPCSTR,IN PIMAGEHLP_STATUS_ROUTINE);
272 BOOL IMAGEAPI ReBaseImage(IN PCSTR,IN PCSTR,IN BOOL, IN BOOL,IN BOOL, IN ULONG, OUT ULONG*, OUT ULONG_PTR*, OUT ULONG*, IN OUT ULONG_PTR*, IN ULONG);
273
274 PLOADED_IMAGE IMAGEAPI ImageLoad(PCSTR,PCSTR);
275 BOOL IMAGEAPI ImageUnload(PLOADED_IMAGE);
276 PIMAGE_NT_HEADERS IMAGEAPI ImageNtHeader(IN PVOID);
277 PVOID IMAGEAPI ImageDirectoryEntryToData(IN PVOID,IN BOOLEAN,IN USHORT,OUT PULONG);
278 PVOID IMAGEAPI ImageDirectoryEntryToDataEx(IN PVOID Base, IN BOOLEAN MappedAsImage, IN USHORT DirectoryEntry, OUT PULONG Size, OUT PIMAGE_SECTION_HEADER *FoundSection OPTIONAL);
279 PVOID IMAGEAPI ImageDirectoryEntryToData32(PVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size, PIMAGE_SECTION_HEADER *FoundHeader OPTIONAL, PIMAGE_FILE_HEADER FileHeader, PIMAGE_OPTIONAL_HEADER OptionalHeader);
280 PIMAGE_SECTION_HEADER IMAGEAPI ImageRvaToSection(IN PIMAGE_NT_HEADERS,IN PVOID,IN ULONG);
281 PVOID IMAGEAPI ImageRvaToVa(IN PIMAGE_NT_HEADERS,IN PVOID,IN ULONG,IN OUT PIMAGE_SECTION_HEADER*);
282 BOOL IMAGEAPI MapAndLoad(PCSTR,PCSTR,PLOADED_IMAGE,BOOL,BOOL);
283 BOOL IMAGEAPI GetImageConfigInformation(PLOADED_IMAGE,PIMAGE_LOAD_CONFIG_DIRECTORY);
284 DWORD IMAGEAPI GetImageUnusedHeaderBytes(PLOADED_IMAGE,LPDWORD);
285 BOOL IMAGEAPI SetImageConfigInformation(PLOADED_IMAGE,PIMAGE_LOAD_CONFIG_DIRECTORY);
286 BOOL IMAGEAPI UnMapAndLoad(PLOADED_IMAGE);
287 PIMAGE_DEBUG_INFORMATION IMAGEAPI MapDebugInformation(HANDLE,PCSTR,PCSTR,DWORD);
288 BOOL IMAGEAPI UnmapDebugInformation(PIMAGE_DEBUG_INFORMATION);
289 BOOL IMAGEAPI SearchTreeForFile(PCSTR,PCSTR,PSTR);
290 BOOL IMAGEAPI MakeSureDirectoryPathExists(LPCSTR);
291 DWORD IMAGEAPI WINAPI UnDecorateSymbolName(LPCSTR,LPSTR,DWORD,DWORD);
292 BOOL
293 IMAGEAPI
294 StackWalk(DWORD,HANDLE,HANDLE,LPSTACKFRAME,LPVOID,PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,PGET_MODULE_BASE_ROUTINE,PTRANSLATE_ADDRESS_ROUTINE);
295 LPAPI_VERSION IMAGEAPI ImagehlpApiVersion(VOID);
296 LPAPI_VERSION IMAGEAPI ImagehlpApiVersionEx(LPAPI_VERSION);
297 DWORD IMAGEAPI GetTimestampForLoadedLibrary(HMODULE);
298 BOOL IMAGEAPI RemovePrivateCvSymbolic(PCHAR,PCHAR*,ULONG*);
299 VOID IMAGEAPI RemoveRelocations(PCHAR);
300 DWORD IMAGEAPI SymSetOptions(IN DWORD);
301 DWORD IMAGEAPI SymGetOptions(VOID);
302 BOOL IMAGEAPI SymCleanup(IN HANDLE);
303 BOOL IMAGEAPI SymEnumerateModules(IN HANDLE,IN PSYM_ENUMMODULES_CALLBACK,IN PVOID);
304 BOOL IMAGEAPI SymEnumerateSymbols(IN HANDLE,IN DWORD,IN PSYM_ENUMSYMBOLS_CALLBACK,IN PVOID);
305 BOOL IMAGEAPI EnumerateLoadedModules(IN HANDLE,IN PENUMLOADED_MODULES_CALLBACK,IN PVOID);
306 LPVOID IMAGEAPI SymFunctionTableAccess(HANDLE,DWORD);
307 BOOL IMAGEAPI SymGetModuleInfo(IN HANDLE,IN DWORD,OUT PIMAGEHLP_MODULE);
308 DWORD IMAGEAPI SymGetModuleBase(IN HANDLE,IN DWORD);
309 BOOL IMAGEAPI SymGetSymFromAddr(IN HANDLE,IN DWORD,OUT PDWORD,OUT PIMAGEHLP_SYMBOL);
310 BOOL IMAGEAPI SymGetSymFromName(IN HANDLE,IN LPSTR,OUT PIMAGEHLP_SYMBOL);
311 BOOL IMAGEAPI SymGetSymNext(IN HANDLE,IN OUT PIMAGEHLP_SYMBOL);
312 BOOL IMAGEAPI SymGetSymPrev(IN HANDLE,IN OUT PIMAGEHLP_SYMBOL);
313 BOOL IMAGEAPI SymGetLineFromAddr(IN HANDLE,IN DWORD,OUT PDWORD,OUT PIMAGEHLP_LINE);
314 BOOL IMAGEAPI SymGetLineFromName(IN HANDLE,IN LPSTR,IN LPSTR,IN DWORD,OUT PLONG,IN OUT PIMAGEHLP_LINE);
315 BOOL IMAGEAPI SymGetLineNext(IN HANDLE,IN OUT PIMAGEHLP_LINE);
316 BOOL IMAGEAPI SymGetLinePrev(IN HANDLE,IN OUT PIMAGEHLP_LINE);
317 BOOL IMAGEAPI SymMatchFileName(IN LPSTR,IN LPSTR,OUT LPSTR*,OUT LPSTR*);
318 BOOL IMAGEAPI SymInitialize(IN HANDLE,IN LPSTR,IN BOOL);
319 BOOL IMAGEAPI SymGetSearchPath(IN HANDLE,OUT LPSTR,IN DWORD);
320 BOOL IMAGEAPI SymSetSearchPath(IN HANDLE,IN LPSTR);
321 DWORD IMAGEAPI SymLoadModule(IN HANDLE,IN HANDLE,IN PSTR,IN PSTR,IN DWORD,IN DWORD);
322 BOOL IMAGEAPI SymUnloadModule(IN HANDLE,IN DWORD);
323 BOOL IMAGEAPI SymUnDName(IN PIMAGEHLP_SYMBOL,OUT LPSTR,IN DWORD);
324 BOOL IMAGEAPI SymRegisterCallback(IN HANDLE,IN PSYMBOL_REGISTERED_CALLBACK,IN PVOID);
325 BOOL IMAGEAPI ImageGetDigestStream(IN HANDLE,IN DWORD,IN DIGEST_FUNCTION,IN DIGEST_HANDLE);
326 BOOL IMAGEAPI ImageAddCertificate(IN HANDLE,IN LPWIN_CERTIFICATE,OUT PDWORD);
327 BOOL IMAGEAPI ImageRemoveCertificate(IN HANDLE,IN DWORD);
328 BOOL IMAGEAPI ImageEnumerateCertificates(IN HANDLE,IN WORD,OUT PDWORD,IN OUT PDWORD OPTIONAL,IN OUT DWORD OPTIONAL);
329 BOOL IMAGEAPI ImageGetCertificateData(IN HANDLE,IN DWORD,OUT LPWIN_CERTIFICATE,IN OUT PDWORD);
330 BOOL IMAGEAPI ImageGetCertificateHeader(IN HANDLE,IN DWORD,IN OUT LPWIN_CERTIFICATE);
331 BOOL IMAGEAPI CopyPdb(CHAR const*,CHAR const*,BOOL);
332 BOOL IMAGEAPI RemovePrivateCvSymbolicEx(PCHAR,ULONG,PCHAR*,ULONG*);
333
334 #endif /* RC_INVOKED */
335
336 #ifdef UNICODE
337 #define MapFileAndCheckSum MapFileAndCheckSumW
338 #else
339 #define MapFileAndCheckSum MapFileAndCheckSumA
340 #endif
341
342 #ifdef __cplusplus
343 }
344 #endif
345
346 #endif /* _IMAGEHLP_H */
347