Release 20030408.
[wine/gsoc-2012-control.git] / include / imagehlp.h
blob38ec91f46786ec5e8702c50e822732ee17c497bb
1 /*
2 * Declarations for IMAGEHLP
4 * Copyright (C) 1998 Patrik Stridvall
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_IMAGEHLP_H
22 #define __WINE_IMAGEHLP_H
24 #include "windef.h"
25 #include "winbase.h"
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* defined(__cplusplus) */
31 /***********************************************************************
32 * Types
35 typedef PVOID DIGEST_HANDLE;
37 /***********************************************************************
38 * Enums/Defines
41 typedef enum _IMAGEHLP_STATUS_REASON {
42 BindOutOfMemory,
43 BindRvaToVaFailed,
44 BindNoRoomInImage,
45 BindImportModuleFailed,
46 BindImportProcedureFailed,
47 BindImportModule,
48 BindImportProcedure,
49 BindForwarder,
50 BindForwarderNOT,
51 BindImageModified,
52 BindExpandFileHeaders,
53 BindImageComplete,
54 BindMismatchedSymbols,
55 BindSymbolsNotUpdated
56 } IMAGEHLP_STATUS_REASON;
58 #define BIND_NO_BOUND_IMPORTS 0x00000001
59 #define BIND_NO_UPDATE 0x00000002
60 #define BIND_ALL_IMAGES 0x00000004
61 #define BIND_CACHE_IMPORT_DLLS 0x00000008
63 #define CERT_PE_IMAGE_DIGEST_DEBUG_INFO 0x01
64 #define CERT_PE_IMAGE_DIGEST_RESOURCES 0x02
65 #define CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO 0x04
66 #define CERT_PE_IMAGE_DIGEST_NON_PE_INFO 0x08
68 #define CERT_SECTION_TYPE_ANY 0xFF
70 #define WIN_CERT_REVISION_1_0 0x0100
71 #define WIN_CERT_REVISION_2_0 0x0200
73 #define WIN_CERT_TYPE_X509 0x0001 /* X.509 Certificate */
74 #define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002 /* PKCS SignedData */
75 #define WIN_CERT_TYPE_RESERVED_1 0x0003 /* Reserved */
77 #define SPLITSYM_REMOVE_PRIVATE 0x00000001
78 #define SPLITSYM_EXTRACT_ALL 0x00000002
79 #define SPLITSYM_SYMBOLPATH_IS_SRC 0x00000004
81 #define FRAME_FPO 0
82 #define FRAME_TRAP 1
83 #define FRAME_TSS 2
84 #define FRAME_NONFPO 3
86 #define CHECKSUM_SUCCESS 0
87 #define CHECKSUM_OPEN_FAILURE 1
88 #define CHECKSUM_MAP_FAILURE 2
89 #define CHECKSUM_MAPVIEW_FAILURE 3
90 #define CHECKSUM_UNICODE_FAILURE 4
92 typedef enum _ADRESS_MODE {
93 AddrMode1616,
94 AddrMode1632,
95 AddrModeReal,
96 AddrModeFlat
97 } ADDRESS_MODE;
99 #define SYMOPT_CASE_INSENSITIVE 0x00000001
100 #define SYMOPT_UNDNAME 0x00000002
101 #define SYMOPT_DEFERRED_LOADS 0x00000004
102 #define SYMOPT_NO_CPP 0x00000008
103 #define SYMOPT_LOAD_LINES 0x00000010
104 #define SYMOPT_OMAP_FIND_NEAREST 0x00000020
106 #define SYMF_OMAP_GENERATED 0x00000001
107 #define SYMF_OMAP_MODIFIED 0x00000002
109 typedef enum {
110 SymNone,
111 SymCoff,
112 SymCv,
113 SymPdb,
114 SymExport,
115 SymDeferred,
116 SymSym /* .sym file */
117 } SYM_TYPE;
119 #define UNDNAME_COMPLETE 0x0000
120 #define UNDNAME_NO_LEADING_UNDERSCORES 0x0001
121 #define UNDNAME_NO_MS_KEYWORDS 0x0002
122 #define UNDNAME_NO_FUNCTION_RETURNS 0x0004
123 #define UNDNAME_NO_ALLOCATION_MODEL 0x0008
124 #define UNDNAME_NO_ALLOCATION_LANGUAGE 0x0010
125 #define UNDNAME_NO_MS_THISTYPE 0x0020
126 #define UNDNAME_NO_CV_THISTYPE 0x0040
127 #define UNDNAME_NO_THISTYPE 0x0060
128 #define UNDNAME_NO_ACCESS_SPECIFIERS 0x0080
129 #define UNDNAME_NO_THROW_SIGNATURES 0x0100
130 #define UNDNAME_NO_MEMBER_TYPE 0x0200
131 #define UNDNAME_NO_RETURN_UDT_MODEL 0x0400
132 #define UNDNAME_32_BIT_DECODE 0x0800
133 #define UNDNAME_NAME_ONLY 0x1000
134 #define UNDNAME_NO_ARGUMENTS 0x2000
135 #define UNDNAME_NO_SPECIAL_SYMS 0x4000
137 #define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
138 #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
139 #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
140 #define CBA_SYMBOLS_UNLOADED 0x00000004
141 #define CBA_DUPLICATE_SYMBOL 0x00000005
143 /***********************************************************************
144 * Structures
147 typedef struct _LOADED_IMAGE {
148 LPSTR ModuleName;
149 HANDLE hFile;
150 PUCHAR MappedAddress;
151 PIMAGE_NT_HEADERS FileHeader;
152 PIMAGE_SECTION_HEADER LastRvaSection;
153 ULONG NumberOfSections;
154 PIMAGE_SECTION_HEADER Sections;
155 ULONG Characteristics;
156 BOOLEAN fSystemImage;
157 BOOLEAN fDOSImage;
158 LIST_ENTRY Links;
159 ULONG SizeOfImage;
160 } LOADED_IMAGE, *PLOADED_IMAGE;
162 typedef struct _WIN_CERTIFICATE {
163 DWORD dwLength;
164 WORD wRevision; /* WIN_CERT_REVISON_xxx */
165 WORD wCertificateType; /* WIN_CERT_TYPE_xxx */
166 BYTE bCertificate[ANYSIZE_ARRAY];
167 } WIN_CERTIFICATE, *PWIN_CERTIFICATE;
169 typedef struct _API_VERSION {
170 USHORT MajorVersion;
171 USHORT MinorVersion;
172 USHORT Revision;
173 USHORT Reserved;
174 } API_VERSION, *PAPI_VERSION;
176 typedef struct _IMAGE_DEBUG_INFORMATION {
177 LIST_ENTRY List;
178 DWORD Size;
179 PVOID MappedBase;
180 USHORT Machine;
181 USHORT Characteristics;
182 DWORD CheckSum;
183 DWORD ImageBase;
184 DWORD SizeOfImage;
186 DWORD NumberOfSections;
187 PIMAGE_SECTION_HEADER Sections;
189 DWORD ExportedNamesSize;
190 LPSTR ExportedNames;
192 DWORD NumberOfFunctionTableEntries;
193 PIMAGE_FUNCTION_ENTRY FunctionTableEntries;
194 DWORD LowestFunctionStartingAddress;
195 DWORD HighestFunctionEndingAddress;
197 DWORD NumberOfFpoTableEntries;
198 PFPO_DATA FpoTableEntries;
200 DWORD SizeOfCoffSymbols;
201 PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
203 DWORD SizeOfCodeViewSymbols;
204 PVOID CodeViewSymbols;
206 LPSTR ImageFilePath;
207 LPSTR ImageFileName;
208 LPSTR DebugFilePath;
210 DWORD TimeDateStamp;
212 BOOL RomImage;
213 PIMAGE_DEBUG_DIRECTORY DebugDirectory;
214 DWORD NumberOfDebugDirectories;
216 DWORD Reserved[3];
217 } IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION;
219 typedef struct _ADDRESS {
220 DWORD Offset;
221 WORD Segment;
222 ADDRESS_MODE Mode;
223 } ADDRESS, *PADDRESS;
225 typedef struct _KDHELP {
226 DWORD Thread;
227 DWORD ThCallbackStack;
228 DWORD NextCallback;
229 DWORD FramePointer;
230 DWORD KiCallUserMode;
231 DWORD KeUserCallbackDispatcher;
232 DWORD SystemRangeStart;
233 } KDHELP, *PKDHELP;
235 typedef struct _STACKFRAME {
236 ADDRESS AddrPC;
237 ADDRESS AddrReturn;
238 ADDRESS AddrFrame;
239 ADDRESS AddrStack;
240 PVOID FuncTableEntry;
241 DWORD Params[4];
242 BOOL Far;
243 BOOL Virtual;
244 DWORD Reserved[3];
245 KDHELP KdHelp;
246 } STACKFRAME, *PSTACKFRAME, *LPSTACKFRAME;
248 typedef struct _IMAGEHLP_SYMBOL {
249 DWORD SizeOfStruct;
250 DWORD Address;
251 DWORD Size;
252 DWORD Flags;
253 DWORD MaxNameLength;
254 CHAR Name[ANYSIZE_ARRAY];
255 } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL;
257 typedef struct _IMAGEHLP_MODULE {
258 DWORD SizeOfStruct;
259 DWORD BaseOfImage;
260 DWORD ImageSize;
261 DWORD TimeDateStamp;
262 DWORD CheckSum;
263 DWORD NumSyms;
264 SYM_TYPE SymType;
265 CHAR ModuleName[32];
266 CHAR ImageName[256];
267 CHAR LoadedImageName[256];
268 } IMAGEHLP_MODULE, *PIMAGEHLP_MODULE;
270 typedef struct _IMAGEHLP_LINE {
271 DWORD SizeOfStruct;
272 DWORD Key;
273 DWORD LineNumber;
274 PCHAR FileName;
275 DWORD Address;
276 } IMAGEHLP_LINE, *PIMAGEHLP_LINE;
278 typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
279 DWORD SizeOfStruct;
280 DWORD BaseOfImage;
281 DWORD CheckSum;
282 DWORD TimeDateStamp;
283 CHAR FileName[MAX_PATH];
284 BOOLEAN Reparse;
285 } IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
287 typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
288 DWORD SizeOfStruct;
289 DWORD NumberOfDups;
290 PIMAGEHLP_SYMBOL Symbol;
291 ULONG SelectedSymbol;
292 } IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
294 /***********************************************************************
295 * Callbacks
298 typedef BOOL (CALLBACK *PIMAGEHLP_STATUS_ROUTINE)(
299 IMAGEHLP_STATUS_REASON Reason, LPSTR ImageName, LPSTR DllName,
300 ULONG Va, ULONG Parameter
303 typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
304 LPSTR ModuleName, ULONG BaseOfDll, PVOID UserContext
307 typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
308 LPSTR SymbolName, ULONG SymbolAddress, ULONG SymbolSize,
309 PVOID UserContext
312 typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
313 LPSTR ModuleName, ULONG ModuleBase, ULONG ModuleSize,
314 PVOID UserContext
317 typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
318 HANDLE hProcess, ULONG ActionCode, PVOID CallbackData,
319 PVOID UserContext
322 typedef BOOL (CALLBACK *DIGEST_FUNCTION)(
323 DIGEST_HANDLE refdata, PBYTE pData, DWORD dwLength
326 typedef BOOL (CALLBACK *PREAD_PROCESS_MEMORY_ROUTINE)(
327 HANDLE hProcess, LPCVOID lpBaseAddress, PVOID lpBuffer,
328 DWORD nSize, PDWORD lpNumberOfBytesRead
331 typedef PVOID (CALLBACK *PFUNCTION_TABLE_ACCESS_ROUTINE)(
332 HANDLE hProcess, DWORD AddrBase
335 typedef DWORD (CALLBACK *PGET_MODULE_BASE_ROUTINE)(
336 HANDLE hProcess, DWORD ReturnAddress);
338 typedef DWORD (CALLBACK *PTRANSLATE_ADDRESS_ROUTINE)(
339 HANDLE hProcess, HANDLE hThread, PADDRESS lpaddr
342 /***********************************************************************
343 * Functions
346 BOOL WINAPI BindImage(
347 LPSTR ImageName, LPSTR DllPath, LPSTR SymbolPath
349 BOOL WINAPI BindImageEx(
350 DWORD Flags, LPSTR ImageName, LPSTR DllPath, LPSTR SymbolPath,
351 PIMAGEHLP_STATUS_ROUTINE StatusRoutine
353 PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
354 LPVOID BaseAddress, DWORD FileLength,
355 LPDWORD HeaderSum, LPDWORD CheckSum
357 BOOL WINAPI EnumerateLoadedModules(
358 HANDLE hProcess,
359 PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
360 PVOID UserContext
362 HANDLE WINAPI FindDebugInfoFile(
363 LPSTR FileName, LPSTR SymbolPath, LPSTR DebugFilePath
365 HANDLE WINAPI FindExecutableImage(
366 LPSTR FileName, LPSTR SymbolPath, LPSTR ImageFilePath
368 BOOL WINAPI GetImageConfigInformation(
369 PLOADED_IMAGE LoadedImage,
370 PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigInformation
372 DWORD WINAPI GetImageUnusedHeaderBytes(
373 PLOADED_IMAGE LoadedImage,
374 LPDWORD SizeUnusedHeaderBytes
376 DWORD WINAPI GetTimestampForLoadedLibrary(
377 HMODULE Module
379 BOOL WINAPI ImageAddCertificate(
380 HANDLE FileHandle, PWIN_CERTIFICATE Certificate, PDWORD Index
382 PVOID WINAPI ImageDirectoryEntryToData(
383 PVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size
385 BOOL WINAPI ImageEnumerateCertificates(
386 HANDLE FileHandle, WORD TypeFilter, PDWORD CertificateCount,
387 PDWORD Indices, DWORD IndexCount
389 BOOL WINAPI ImageGetCertificateData(
390 HANDLE FileHandle, DWORD CertificateIndex,
391 PWIN_CERTIFICATE Certificate, PDWORD RequiredLength
393 BOOL WINAPI ImageGetCertificateHeader(
394 HANDLE FileHandle, DWORD CertificateIndex,
395 PWIN_CERTIFICATE Certificateheader
397 BOOL WINAPI ImageGetDigestStream(
398 HANDLE FileHandle, DWORD DigestLevel,
399 DIGEST_FUNCTION DigestFunction, DIGEST_HANDLE DigestHandle
401 PLOADED_IMAGE WINAPI ImageLoad(
402 LPSTR DllName, LPSTR DllPath
404 PIMAGE_NT_HEADERS WINAPI ImageNtHeader(
405 PVOID Base
407 BOOL WINAPI ImageRemoveCertificate(
408 HANDLE FileHandle, DWORD Index
410 PIMAGE_SECTION_HEADER WINAPI ImageRvaToSection(
411 PIMAGE_NT_HEADERS NtHeaders, PVOID Base, ULONG Rva
413 PVOID WINAPI ImageRvaToVa(
414 PIMAGE_NT_HEADERS NtHeaders, PVOID Base, ULONG Rva,
415 PIMAGE_SECTION_HEADER *LastRvaSection
417 BOOL WINAPI ImageUnload(
418 PLOADED_IMAGE LoadedImage
420 PAPI_VERSION WINAPI ImagehlpApiVersion(
421 void
423 PAPI_VERSION WINAPI ImagehlpApiVersionEx(
424 PAPI_VERSION AppVersion
426 BOOL WINAPI MakeSureDirectoryPathExists(
427 LPCSTR DirPath
429 BOOL WINAPI MapAndLoad(
430 LPSTR ImageName, LPSTR DllPath, PLOADED_IMAGE LoadedImage,
431 BOOL DotDll, BOOL ReadOnly
433 PIMAGE_DEBUG_INFORMATION WINAPI MapDebugInformation(
434 HANDLE FileHandle, LPSTR FileName,
435 LPSTR SymbolPath, DWORD ImageBase
437 DWORD WINAPI MapFileAndCheckSumA(
438 LPSTR Filename, LPDWORD HeaderSum, LPDWORD CheckSum
440 DWORD WINAPI MapFileAndCheckSumW(
441 LPWSTR Filename, LPDWORD HeaderSum, LPDWORD CheckSum
443 BOOL WINAPI ReBaseImage(
444 LPSTR CurrentImageName, LPSTR SymbolPath, BOOL fReBase,
445 BOOL fRebaseSysfileOk, BOOL fGoingDown, ULONG CheckImageSize,
446 ULONG *OldImageSize, ULONG *OldImageBase, ULONG *NewImageSize,
447 ULONG *NewImageBase, ULONG TimeStamp
449 BOOL WINAPI RemovePrivateCvSymbolic(
450 PCHAR DebugData, PCHAR *NewDebugData, ULONG *NewDebugSize
452 VOID WINAPI RemoveRelocations(
453 PCHAR ImageName
455 BOOL WINAPI SearchTreeForFile(
456 LPSTR RootPath, LPSTR InputPathName, LPSTR OutputPathBuffer
458 BOOL WINAPI SetImageConfigInformation(
459 PLOADED_IMAGE LoadedImage,
460 PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigInformation
462 BOOL WINAPI SplitSymbols(
463 LPSTR ImageName, LPSTR SymbolsPath,
464 LPSTR SymbolFilePath, DWORD Flags
466 BOOL WINAPI StackWalk(
467 DWORD MachineType, HANDLE hProcess, HANDLE hThread,
468 PSTACKFRAME StackFrame, PVOID ContextRecord,
469 PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
470 PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
471 PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
472 PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
474 BOOL WINAPI SymCleanup(
475 HANDLE hProcess
477 BOOL WINAPI SymEnumerateModules(
478 HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,
479 PVOID UserContext
481 BOOL WINAPI SymEnumerateSymbols(
482 HANDLE hProcess, DWORD BaseOfDll,
483 PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext
485 PVOID WINAPI SymFunctionTableAccess(
486 HANDLE hProcess, DWORD AddrBase
488 DWORD WINAPI SymGetModuleBase(
489 HANDLE hProcess, DWORD dwAddr
491 BOOL WINAPI SymGetModuleInfo(
492 HANDLE hProcess, DWORD dwAddr,
493 PIMAGEHLP_MODULE ModuleInfo
495 DWORD WINAPI SymGetOptions(
496 void
498 BOOL WINAPI SymGetSearchPath(
499 HANDLE hProcess, LPSTR szSearchPath, DWORD SearchPathLength
501 BOOL WINAPI SymGetSymFromAddr(
502 HANDLE hProcess, DWORD dwAddr,
503 PDWORD pdwDisplacement, PIMAGEHLP_SYMBOL Symbol
505 BOOL WINAPI SymGetSymFromName(
506 HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symbol
508 BOOL WINAPI SymGetSymNext(
509 HANDLE hProcess, PIMAGEHLP_SYMBOL Symbol
511 BOOL WINAPI SymGetSymPrev(
512 HANDLE hProcess, PIMAGEHLP_SYMBOL Symbol
514 BOOL WINAPI SymInitialize(
515 HANDLE hProcess, LPSTR UserSearchPath, BOOL fInvadeProcess
517 BOOL WINAPI SymLoadModule(
518 HANDLE hProcess, HANDLE hFile, LPSTR ImageName, LPSTR ModuleName,
519 DWORD BaseOfDll, DWORD SizeOfDll
521 BOOL WINAPI SymRegisterCallback(
522 HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK CallbackFunction,
523 PVOID UserContext
525 DWORD WINAPI SymSetOptions(
526 DWORD SymOptions
528 BOOL WINAPI SymSetSearchPath(
529 HANDLE hProcess, LPSTR szSearchPath
531 BOOL WINAPI SymUnDName(
532 PIMAGEHLP_SYMBOL sym, LPSTR UnDecName, DWORD UnDecNameLength
534 BOOL WINAPI SymUnloadModule(
535 HANDLE hProcess, DWORD BaseOfDll
537 BOOL WINAPI TouchFileTimes(
538 HANDLE FileHandle, LPSYSTEMTIME lpSystemTime
540 DWORD WINAPI UnDecorateSymbolName(
541 LPCSTR DecoratedName, LPSTR UnDecoratedName,
542 DWORD UndecoratedLength, DWORD Flags
544 BOOL WINAPI UnMapAndLoad(
545 PLOADED_IMAGE LoadedImage
547 BOOL WINAPI UnmapDebugInformation(
548 PIMAGE_DEBUG_INFORMATION DebugInfo
550 BOOL WINAPI UpdateDebugInfoFile(
551 LPSTR ImageFileName, LPSTR SymbolPath,
552 LPSTR DebugFilePath, PIMAGE_NT_HEADERS NtHeaders
554 BOOL WINAPI UpdateDebugInfoFileEx(
555 LPSTR ImageFileName, LPSTR SymbolPath, LPSTR DebugFilePath,
556 PIMAGE_NT_HEADERS NtHeaders, DWORD OldChecksum
559 /***********************************************************************
560 * Wine specific
563 extern HANDLE IMAGEHLP_hHeap;
565 #ifdef __cplusplus
566 } /* extern "C" */
567 #endif /* defined(__cplusplus) */
569 #endif /* __WINE_IMAGEHLP_H */