Function GetProcAddress

Source
pub fn GetProcAddress<T>(
    h_module: HMODULE,
    function: T,
    hash: Option<fn(&str) -> u32>,
) -> *mut c_void
where T: ToString,
Expand description

Retrieves the address of an exported function or variable from the specified module.

§Arguments

  • h_module - Handle to the module that contains the desired function or variable.
  • function - The function name hash, its ordinal, or a string representing the function name.
  • hash - An optional function that computes a u32 hash from a &str, used for name-based resolution.

§Returns

  • The address of the exported function if found.

§Notes

  • Supports resolving functions by both name, ordinal and hash.
  • Handles forwarded exports by recursively resolving the function in the forwarding module.

§Examples

  • Import By Name
use dinvk::{GetModuleHandle, GetProcAddress};
 
let h_module = GetModuleHandle("NTDLL.DLL", None);
let address = GetProcAddress(h_module, "NtProtectVirtualMemory", None);
  • Import By Hash
use dinvk::hash::jenkins;
use dinvk::{GetModuleHandle, GetProcAddress};
 
let h_module = GetModuleHandle(3547223233u32, Some(jenkins));
let address = GetProcAddress(h_module, 2193297120u32, Some(jenkins));
  • Import By Ordinal
use dinvk::{GetModuleHandle, GetProcAddress};
 
let h_module = GetModuleHandle("NTDLL.DLL", None);
let address = GetProcAddress(h_module, 473, None);