I rely on GetProcAddress()
to do some hooking of some functions. I get a terrible result though, and to be honest, I don't really know what's happening.
It seems that this code will output "WHAT THE HELL?":
int main(void)
{
HMODULE ws32 = LoadLibrary("WS2_32.DLL");
if (GetProcAddress(ws32, "ntohl") == GetProcAddress(ws32, "htonl"))
printf("WHAT THE HELL\n");
return 0;
}
Could someone explain me why ntohl and htonl have the same absolute addresses?
The problem is that, when I hook into a DLL and do some processing inside the DLL, it's clear that Inside the PE import table (I parse the PE IAT), ntohl()
and htonl()
have different addresses (Inside the IAT as said).
So this thing renders my program useless. ntohl()
is confounded with htonl()
, and the program cannot make the difference and goes crazy.
Any thoughts? Would there be a way to circumvent this? An explication?