Platform SDK: Debugging and Error Handling

ImageRvaToVa

The ImageRvaToVa function locates a relative virtual address (RVA) within the image header of a file that is mapped as a file and returns the virtual address of the corresponding byte in the file.

PVOID ImageRvaToVa(
  PIMAGE_NT_HEADERS NtHeaders, 
  PVOID Base, 
  ULONG Rva, 
  PIMAGE_SECTION_HEADER *LastRvaSection  
);

Parameters

NtHeaders
[in] Pointer to an IMAGE_NT_HEADERS structure. This structure can be obtained by calling the ImageNtHeader function.
Base
[in] Specifies the base address of an image that is mapped into memory through a call to the MapViewOfFile function.
Rva
[in] Specifies the relative virtual address to locate.
LastRvaSection
[in/out] Pointer to an IMAGE_SECTION_HEADER structure that specifies the last RVA section. This is an optional parameter. When specified, it points to a variable that contains the last section value used for the specified image to translate an RVA to a VA.

Return Values

If the function succeeds, the return value is the virtual address in the mapped file.

If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.

Remarks

The ImageRvaToVa function locates an RVA within the image header of a file that is mapped as a file and returns the virtual address of the corresponding byte in the file.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Dbghelp.h.
  Library: Use Dbghelp.lib.

See Also

Debug Help Library Overview, DbgHelp Functions, IMAGE_NT_HEADERS, IMAGE_SECTION_HEADER, ImageNtHeader, MapViewOfFile