I want to know if it is possible, using C and the WindowsAPI, if there is a function that will get me the 32 bit(I think) memory address of a function in a dll. For example. How do I get the 32 bit $xxxxxxxx address of Beep() in kernel32.dll. Secondly, if I use the memory address instead of the function name in assembly, can I avoid linking. For example
mov eax, $xxxxxxxx
instead of
mov eax, Beep
This program will print the address of Beep
in kernel32:
#include <windows.h>
#include <stdio.h>
int main(void)
{
HMODULE hMod = GetModuleHandle("kernel32.dll");
void* fn = GetProcAddress(hMod, "Beep");
printf("%p", fn);
}
I omitted error checking for the sake of simplicity. In a real program you would not do so.
Yes. Look up 'GetProcAddress' on MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With