VirtualBox

source: vbox/trunk/include/iprt/ldr.h@ 46023

Last change on this file since 46023 was 46023, checked in by vboxsync, 12 years ago

RTLdrOpen: Defined the first flag RTLDR_O_FOR_DEBUG for use with RTDbgMod.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.0 KB
Line 
1/** @file
2 * IPRT - Loader.
3 */
4
5/*
6 * Copyright (C) 2006-2011 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_ldr_h
27#define ___iprt_ldr_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32
33/** @defgroup grp_ldr RTLdr - Loader
34 * @ingroup grp_rt
35 * @{
36 */
37
38
39RT_C_DECLS_BEGIN
40
41/** Loader address (unsigned integer). */
42typedef RTUINTPTR RTLDRADDR;
43/** Pointer to a loader address. */
44typedef RTLDRADDR *PRTLDRADDR;
45/** Pointer to a const loader address. */
46typedef RTLDRADDR const *PCRTLDRADDR;
47/** The max loader address value. */
48#define RTLDRADDR_MAX RTUINTPTR_MAX
49/** NIL loader address value. */
50#define NIL_RTLDRADDR RTLDRADDR_MAX
51
52
53/**
54 * Gets the default file suffix for DLL/SO/DYLIB/whatever.
55 *
56 * @returns The stuff (readonly).
57 */
58RTDECL(const char *) RTLdrGetSuff(void);
59
60/**
61 * Checks if a library is loadable or not.
62 *
63 * This may attempt load and unload the library.
64 *
65 * @returns true/false accordingly.
66 * @param pszFilename Image filename.
67 */
68RTDECL(bool) RTLdrIsLoadable(const char *pszFilename);
69
70/**
71 * Loads a dynamic load library (/shared object) image file using native
72 * OS facilities.
73 *
74 * The filename will be appended the default DLL/SO extension of
75 * the platform if it have been omitted. This means that it's not
76 * possible to load DLLs/SOs with no extension using this interface,
77 * but that's not a bad tradeoff.
78 *
79 * If no path is specified in the filename, the OS will usually search it's library
80 * path to find the image file.
81 *
82 * @returns iprt status code.
83 * @param pszFilename Image filename.
84 * @param phLdrMod Where to store the handle to the loader module.
85 */
86RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod);
87
88/**
89 * Loads a dynamic load library (/shared object) image file using native
90 * OS facilities.
91 *
92 * The filename will be appended the default DLL/SO extension of
93 * the platform if it have been omitted. This means that it's not
94 * possible to load DLLs/SOs with no extension using this interface,
95 * but that's not a bad tradeoff.
96 *
97 * If no path is specified in the filename, the OS will usually search it's library
98 * path to find the image file.
99 *
100 * @returns iprt status code.
101 * @param pszFilename Image filename.
102 * @param phLdrMod Where to store the handle to the loader module.
103 * @param fFlags See RTLDRLOAD_FLAGS_XXX.
104 * @param pErrInfo Where to return extended error information. Optional.
105 */
106RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
107
108/** @defgroup RTLDRLOAD_FLAGS_XXX RTLdrLoadEx flags.
109 * @{ */
110/** Symbols defined in this library are not made available to resolve
111 * references in subsequently loaded libraries (default). */
112#define RTLDRLOAD_FLAGS_LOCAL UINT32_C(0)
113/** Symbols defined in this library will be made available for symbol
114 * resolution of subsequently loaded libraries. */
115#define RTLDRLOAD_FLAGS_GLOBAL RT_BIT_32(0)
116/** The mask of valid flag bits. */
117#define RTLDRLOAD_FLAGS_VALID_MASK UINT32_C(0x00000001)
118/** @} */
119
120/**
121 * Loads a dynamic load library (/shared object) image file residing in the
122 * RTPathAppPrivateArch() directory.
123 *
124 * Suffix is not required.
125 *
126 * @returns iprt status code.
127 * @param pszFilename Image filename. No path.
128 * @param phLdrMod Where to store the handle to the loaded module.
129 */
130RTDECL(int) RTLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod);
131
132/**
133 * Image architecuture specifier for RTLdrOpenEx.
134 */
135typedef enum RTLDRARCH
136{
137 RTLDRARCH_INVALID = 0,
138 /** Whatever. */
139 RTLDRARCH_WHATEVER,
140 /** The host architecture. */
141 RTLDRARCH_HOST,
142 /** 32-bit x86. */
143 RTLDRARCH_X86_32,
144 /** AMD64 (64-bit x86 if you like). */
145 RTLDRARCH_AMD64,
146 /** End of the valid values. */
147 RTLDRARCH_END,
148 /** Make sure the type is a full 32-bit. */
149 RTLDRARCH_32BIT_HACK = 0x7fffffff
150} RTLDRARCH;
151/** Pointer to a RTLDRARCH. */
152typedef RTLDRARCH *PRTLDRARCH;
153
154/** @name RTLDR_O_XXX - RTLdrOpen flags.
155 * @{ */
156/** Open for debugging or introspection reasons.
157 * This will skip a few of the stricter validations when loading images. */
158#define RTLDR_O_FOR_DEBUG RT_BIT_32(0)
159/** Mask of valid flags. */
160#define RTLDR_O_VALID_MASK UINT32_C(0x00000001)
161/** @} */
162
163/**
164 * Open a binary image file, extended version.
165 *
166 * @returns iprt status code.
167 * @param pszFilename Image filename.
168 * @param fFlags Valid RTLDR_O_XXX combination.
169 * @param enmArch CPU architecture specifier for the image to be loaded.
170 * @param phLdrMod Where to store the handle to the loader module.
171 */
172RTDECL(int) RTLdrOpen(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod);
173
174/**
175 * Opens a binary image file using kLdr.
176 *
177 * @returns iprt status code.
178 * @param pszFilename Image filename.
179 * @param phLdrMod Where to store the handle to the loaded module.
180 * @param fFlags Valid RTLDR_O_XXX combination.
181 * @param enmArch CPU architecture specifier for the image to be loaded.
182 * @remark Primarily for testing the loader.
183 */
184RTDECL(int) RTLdrOpenkLdr(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod);
185
186/**
187 * What to expect and do with the bits passed to RTLdrOpenBits().
188 */
189typedef enum RTLDROPENBITS
190{
191 /** The usual invalid 0 entry. */
192 RTLDROPENBITS_INVALID = 0,
193 /** The bits are readonly and will never be changed. */
194 RTLDROPENBITS_READONLY,
195 /** The bits are going to be changed and the loader will have to duplicate them
196 * when opening the image. */
197 RTLDROPENBITS_WRITABLE,
198 /** The bits are both the source and destination for the loader operation.
199 * This means that the loader may have to duplicate them prior to changing them. */
200 RTLDROPENBITS_SRC_AND_DST,
201 /** The end of the valid enums. This entry marks the
202 * first invalid entry.. */
203 RTLDROPENBITS_END,
204 RTLDROPENBITS_32BIT_HACK = 0x7fffffff
205} RTLDROPENBITS;
206
207/**
208 * Open a binary image from in-memory bits.
209 *
210 * @returns iprt status code.
211 * @param pvBits The start of the raw-image.
212 * @param cbBits The size of the raw-image.
213 * @param enmBits What to expect from the pvBits.
214 * @param pszLogName What to call the raw-image when logging.
215 * For RTLdrLoad and RTLdrOpen the filename is used for this.
216 * @param phLdrMod Where to store the handle to the loader module.
217 */
218RTDECL(int) RTLdrOpenBits(const void *pvBits, size_t cbBits, RTLDROPENBITS enmBits, const char *pszLogName, PRTLDRMOD phLdrMod);
219
220/**
221 * Closes a loader module handle.
222 *
223 * The handle can be obtained using any of the RTLdrLoad(), RTLdrOpen()
224 * and RTLdrOpenBits() functions.
225 *
226 * @returns iprt status code.
227 * @param hLdrMod The loader module handle.
228 */
229RTDECL(int) RTLdrClose(RTLDRMOD hLdrMod);
230
231/**
232 * Gets the address of a named exported symbol.
233 *
234 * @returns iprt status code.
235 * @param hLdrMod The loader module handle.
236 * @param pszSymbol Symbol name.
237 * @param ppvValue Where to store the symbol value. Note that this is restricted to the
238 * pointer size used on the host!
239 */
240RTDECL(int) RTLdrGetSymbol(RTLDRMOD hLdrMod, const char *pszSymbol, void **ppvValue);
241
242/**
243 * Gets the address of a named exported symbol.
244 *
245 * This function differs from the plain one in that it can deal with
246 * both GC and HC address sizes, and that it can calculate the symbol
247 * value relative to any given base address.
248 *
249 * @returns iprt status code.
250 * @param hLdrMod The loader module handle.
251 * @param pvBits Optional pointer to the loaded image.
252 * Set this to NULL if no RTLdrGetBits() processed image bits are available.
253 * Not supported for RTLdrLoad() images.
254 * @param BaseAddress Image load address.
255 * Not supported for RTLdrLoad() images.
256 * @param pszSymbol Symbol name.
257 * @param pValue Where to store the symbol value.
258 */
259RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress, const char *pszSymbol,
260 PRTLDRADDR pValue);
261
262/**
263 * Gets the size of the loaded image.
264 * This is only supported for modules which has been opened using RTLdrOpen() and RTLdrOpenBits().
265 *
266 * @returns image size (in bytes).
267 * @returns ~(size_t)0 on if not opened by RTLdrOpen().
268 * @param hLdrMod Handle to the loader module.
269 * @remark Not supported for RTLdrLoad() images.
270 */
271RTDECL(size_t) RTLdrSize(RTLDRMOD hLdrMod);
272
273/**
274 * Resolve an external symbol during RTLdrGetBits().
275 *
276 * @returns iprt status code.
277 * @param hLdrMod The loader module handle.
278 * @param pszModule Module name.
279 * @param pszSymbol Symbol name, NULL if uSymbol should be used.
280 * @param uSymbol Symbol ordinal, ~0 if pszSymbol should be used.
281 * @param pValue Where to store the symbol value (address).
282 * @param pvUser User argument.
283 */
284typedef DECLCALLBACK(int) RTLDRIMPORT(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol,
285 PRTLDRADDR pValue, void *pvUser);
286/** Pointer to a FNRTLDRIMPORT() callback function. */
287typedef RTLDRIMPORT *PFNRTLDRIMPORT;
288
289/**
290 * Loads the image into a buffer provided by the user and applies fixups
291 * for the given base address.
292 *
293 * @returns iprt status code.
294 * @param hLdrMod The load module handle.
295 * @param pvBits Where to put the bits.
296 * Must be as large as RTLdrSize() suggests.
297 * @param BaseAddress The base address.
298 * @param pfnGetImport Callback function for resolving imports one by one.
299 * @param pvUser User argument for the callback.
300 * @remark Not supported for RTLdrLoad() images.
301 */
302RTDECL(int) RTLdrGetBits(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
303
304/**
305 * Relocates bits after getting them.
306 * Useful for code which moves around a bit.
307 *
308 * @returns iprt status code.
309 * @param hLdrMod The loader module handle.
310 * @param pvBits Where the image bits are.
311 * Must have been passed to RTLdrGetBits().
312 * @param NewBaseAddress The new base address.
313 * @param OldBaseAddress The old base address.
314 * @param pfnGetImport Callback function for resolving imports one by one.
315 * @param pvUser User argument for the callback.
316 * @remark Not supported for RTLdrLoad() images.
317 */
318RTDECL(int) RTLdrRelocate(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR NewBaseAddress, RTLDRADDR OldBaseAddress,
319 PFNRTLDRIMPORT pfnGetImport, void *pvUser);
320
321/**
322 * Enumeration callback function used by RTLdrEnumSymbols().
323 *
324 * @returns iprt status code. Failure will stop the enumeration.
325 * @param hLdrMod The loader module handle.
326 * @param pszSymbol Symbol name. NULL if ordinal only.
327 * @param uSymbol Symbol ordinal, ~0 if not used.
328 * @param Value Symbol value.
329 * @param pvUser The user argument specified to RTLdrEnumSymbols().
330 */
331typedef DECLCALLBACK(int) RTLDRENUMSYMS(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol, RTLDRADDR Value, void *pvUser);
332/** Pointer to a RTLDRENUMSYMS() callback function. */
333typedef RTLDRENUMSYMS *PFNRTLDRENUMSYMS;
334
335/**
336 * Enumerates all symbols in a module.
337 *
338 * @returns iprt status code.
339 * @param hLdrMod The loader module handle.
340 * @param fFlags Flags indicating what to return and such.
341 * @param pvBits Optional pointer to the loaded image. (RTLDR_ENUM_SYMBOL_FLAGS_*)
342 * Set this to NULL if no RTLdrGetBits() processed image bits are available.
343 * @param BaseAddress Image load address.
344 * @param pfnCallback Callback function.
345 * @param pvUser User argument for the callback.
346 * @remark Not supported for RTLdrLoad() images.
347 */
348RTDECL(int) RTLdrEnumSymbols(RTLDRMOD hLdrMod, unsigned fFlags, const void *pvBits, RTLDRADDR BaseAddress, PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
349
350/** @name RTLdrEnumSymbols flags.
351 * @{ */
352/** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */
353#define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1)
354/** @} */
355
356
357/**
358 * Debug info type (as far the loader can tell).
359 */
360typedef enum RTLDRDBGINFOTYPE
361{
362 /** The invalid 0 value. */
363 RTLDRDBGINFOTYPE_INVALID = 0,
364 /** Unknown debug info format. */
365 RTLDRDBGINFOTYPE_UNKNOWN,
366 /** Stabs. */
367 RTLDRDBGINFOTYPE_STABS,
368 /** Debug With Arbitrary Record Format (DWARF). */
369 RTLDRDBGINFOTYPE_DWARF,
370 /** Debug With Arbitrary Record Format (DWARF), in external file (DWO). */
371 RTLDRDBGINFOTYPE_DWARF_DWO,
372 /** Microsoft Codeview debug info. */
373 RTLDRDBGINFOTYPE_CODEVIEW,
374 /** Microsoft Codeview debug info, in external v2.0+ program database (PDB). */
375 RTLDRDBGINFOTYPE_CODEVIEW_PDB20,
376 /** Microsoft Codeview debug info, in external v7.0+ program database (PDB). */
377 RTLDRDBGINFOTYPE_CODEVIEW_PDB70,
378 /** Microsoft Codeview debug info, in external file (DBG). */
379 RTLDRDBGINFOTYPE_CODEVIEW_DBG,
380 /** Watcom debug info. */
381 RTLDRDBGINFOTYPE_WATCOM,
382 /** IBM High Level Language debug info.. */
383 RTLDRDBGINFOTYPE_HLL,
384 /** The end of the valid debug info values (exclusive). */
385 RTLDRDBGINFOTYPE_END,
386 /** Blow the type up to 32-bits. */
387 RTLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
388} RTLDRDBGINFOTYPE;
389
390
391/**
392 * Debug info details for the enumeration callback.
393 */
394typedef struct RTLDRDBGINFO
395{
396 /** The kind of debug info. */
397 RTLDRDBGINFOTYPE enmType;
398 /** The debug info ordinal number / id. */
399 uint32_t iDbgInfo;
400 /** The file offset *if* this type has one specific location in the executable
401 * image file. This is -1 if there isn't any specific file location. */
402 RTFOFF offFile;
403 /** The link address of the debug info if it's loadable. NIL_RTLDRADDR if not
404 * loadable*/
405 RTLDRADDR LinkAddress;
406 /** The size of the debug information. -1 is used if this isn't applicable.*/
407 RTLDRADDR cb;
408 /** This is set if the debug information is found in an external file. NULL
409 * if no external file involved.
410 * @note Putting it outside the union to allow lazy callback implementation. */
411 const char *pszExtFile;
412 /** Type (enmType) specific information. */
413 union
414 {
415 /** RTLDRDBGINFOTYPE_DWARF */
416 struct
417 {
418 /** The section name. */
419 const char *pszSection;
420 } Dwarf;
421
422 /** RTLDRDBGINFOTYPE_DWARF_DWO */
423 struct
424 {
425 /** The CRC32 of the external file. */
426 uint32_t uCrc32;
427 } Dwo;
428
429 /** RTLDRDBGINFOTYPE_CODEVIEW_PDB20, RTLDRDBGINFOTYPE_CODEVIEW_DBG */
430 struct
431 {
432 /** The PE image size. */
433 uint32_t cbImage;
434 /** The timestamp. */
435 uint32_t uTimestamp;
436 /** The major version from the entry. */
437 uint32_t uMajorVer;
438 /** The minor version from the entry. */
439 uint32_t uMinorVer;
440 } Cv;
441
442 /** RTLDRDBGINFOTYPE_CODEVIEW_DBG */
443 struct
444 {
445 /** The PE image size. */
446 uint32_t cbImage;
447 /** The timestamp. */
448 uint32_t uTimestamp;
449 } Dbg;
450
451 /** RTLDRDBGINFOTYPE_CODEVIEW_PDB20*/
452 struct
453 {
454 /** The PE image size. */
455 uint32_t cbImage;
456 /** The timestamp. */
457 uint32_t uTimestamp;
458 /** The PDB age. */
459 uint32_t uAge;
460 } Pdb20;
461
462 /** RTLDRDBGINFOTYPE_CODEVIEW_PDB70 */
463 struct
464 {
465 /** The PE image size. */
466 uint32_t cbImage;
467 /** The PDB age. */
468 uint32_t uAge;
469 /** The UUID. */
470 RTUUID Uuid;
471 } Pdb70;
472 } u;
473} RTLDRDBGINFO;
474/** Pointer to debug info details. */
475typedef RTLDRDBGINFO *PRTLDRDBGINFO;
476/** Pointer to read only debug info details. */
477typedef RTLDRDBGINFO const *PCRTLDRDBGINFO;
478
479
480/**
481 * Debug info enumerator callback.
482 *
483 * @returns VINF_SUCCESS to continue the enumeration. Any other status code
484 * will cause RTLdrEnumDbgInfo to immediately return with that status.
485 *
486 * @param hLdrMod The module handle.
487 * @param pDbgInfo Pointer to a read only structure with the details.
488 * @param pvUser The user parameter specified to RTLdrEnumDbgInfo.
489 */
490typedef DECLCALLBACK(int) FNRTLDRENUMDBG(RTLDRMOD hLdrMod, PCRTLDRDBGINFO pDbgInfo, void *pvUser);
491/** Pointer to a debug info enumerator callback. */
492typedef FNRTLDRENUMDBG *PFNRTLDRENUMDBG;
493
494/**
495 * Enumerate the debug info contained in the executable image.
496 *
497 * @returns IPRT status code or whatever pfnCallback returns.
498 *
499 * @param hLdrMod The module handle.
500 * @param pvBits Optional pointer to bits returned by
501 * RTLdrGetBits(). This can be used by some module
502 * interpreters to reduce memory consumption.
503 * @param pfnCallback The callback function.
504 * @param pvUser The user argument.
505 */
506RTDECL(int) RTLdrEnumDbgInfo(RTLDRMOD hLdrMod, const void *pvBits, PFNRTLDRENUMDBG pfnCallback, void *pvUser);
507
508
509/**
510 * Loader segment.
511 */
512typedef struct RTLDRSEG
513{
514 /** The segment name. (Might not be zero terminated!) */
515 const char *pchName;
516 /** The length of the segment name. */
517 uint32_t cchName;
518 /** The flat selector to use for the segment (i.e. data/code).
519 * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
520 uint16_t SelFlat;
521 /** The 16-bit selector to use for the segment.
522 * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
523 uint16_t Sel16bit;
524 /** Segment flags. */
525 uint32_t fFlags;
526 /** The segment protection (RTMEM_PROT_XXX). */
527 uint32_t fProt;
528 /** The size of the segment. */
529 RTLDRADDR cb;
530 /** The required segment alignment.
531 * The to 0 if the segment isn't supposed to be mapped. */
532 RTLDRADDR Alignment;
533 /** The link address.
534 * Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped or if
535 * the image doesn't have link addresses. */
536 RTLDRADDR LinkAddress;
537 /** File offset of the segment.
538 * Set to -1 if no file backing (like BSS). */
539 RTFOFF offFile;
540 /** Size of the file bits of the segment.
541 * Set to -1 if no file backing (like BSS). */
542 RTFOFF cbFile;
543 /** The relative virtual address when mapped.
544 * Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped. */
545 RTLDRADDR RVA;
546 /** The size of the segment including the alignment gap up to the next segment when mapped.
547 * This is set to NIL_RTLDRADDR if not implemented. */
548 RTLDRADDR cbMapped;
549} RTLDRSEG;
550/** Pointer to a loader segment. */
551typedef RTLDRSEG *PRTLDRSEG;
552/** Pointer to a read only loader segment. */
553typedef RTLDRSEG const *PCRTLDRSEG;
554
555
556/** @name Segment flags
557 * @{ */
558/** The segment is 16-bit. When not set the default of the target architecture is assumed. */
559#define RTLDRSEG_FLAG_16BIT UINT32_C(1)
560/** The segment requires a 16-bit selector alias. (OS/2) */
561#define RTLDRSEG_FLAG_OS2_ALIAS16 UINT32_C(2)
562/** Conforming segment (x86 weirdness). (OS/2) */
563#define RTLDRSEG_FLAG_OS2_CONFORM UINT32_C(4)
564/** IOPL (ring-2) segment. (OS/2) */
565#define RTLDRSEG_FLAG_OS2_IOPL UINT32_C(8)
566/** @} */
567
568/**
569 * Segment enumerator callback.
570 *
571 * @returns VINF_SUCCESS to continue the enumeration. Any other status code
572 * will cause RTLdrEnumSegments to immediately return with that
573 * status.
574 *
575 * @param hLdrMod The module handle.
576 * @param pSeg The segment information.
577 * @param pvUser The user parameter specified to RTLdrEnumSegments.
578 */
579typedef DECLCALLBACK(int) FNRTLDRENUMSEGS(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser);
580/** Pointer to a segment enumerator callback. */
581typedef FNRTLDRENUMSEGS *PFNRTLDRENUMSEGS;
582
583/**
584 * Enumerate the debug info contained in the executable image.
585 *
586 * @returns IPRT status code or whatever pfnCallback returns.
587 *
588 * @param hLdrMod The module handle.
589 * @param pfnCallback The callback function.
590 * @param pvUser The user argument.
591 */
592RTDECL(int) RTLdrEnumSegments(RTLDRMOD hLdrMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser);
593
594/**
595 * Converts a link address to a segment:offset address.
596 *
597 * @returns IPRT status code.
598 *
599 * @param hLdrMod The module handle.
600 * @param LinkAddress The link address to convert.
601 * @param piSeg Where to return the segment index.
602 * @param poffSeg Where to return the segment offset.
603 */
604RTDECL(int) RTLdrLinkAddressToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, uint32_t *piSeg, PRTLDRADDR poffSeg);
605
606/**
607 * Converts a link address to an image relative virtual address (RVA).
608 *
609 * @returns IPRT status code.
610 *
611 * @param hLdrMod The module handle.
612 * @param LinkAddress The link address to convert.
613 * @param pRva Where to return the RVA.
614 */
615RTDECL(int) RTLdrLinkAddressToRva(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva);
616
617/**
618 * Converts an image relative virtual address (RVA) to a segment:offset.
619 *
620 * @returns IPRT status code.
621 *
622 * @param hLdrMod The module handle.
623 * @param Rva The link address to convert.
624 * @param piSeg Where to return the segment index.
625 * @param poffSeg Where to return the segment offset.
626 */
627RTDECL(int) RTLdrSegOffsetToRva(RTLDRMOD hLdrMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva);
628
629/**
630 * Converts a segment:offset into an image relative virtual address (RVA).
631 *
632 * @returns IPRT status code.
633 *
634 * @param hLdrMod The module handle.
635 * @param iSeg The segment index.
636 * @param offSeg The segment offset.
637 * @param pRva Where to return the RVA.
638 */
639RTDECL(int) RTLdrRvaToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg);
640
641RT_C_DECLS_END
642
643/** @} */
644
645#endif
646
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette