I use wininet library and hook this to monitor internet requests.
The Hooking Function is "InternetConnectW", "HttpOpenRequestW" and "InternetReadFile".
First, I get a HINTERNET handle from "InternetConnectW".
And I get a second HINTERNET handle from "HttpOpenRequestW" with first handle.
When I hook "InternetReadFile", IN parameter include the second handle.
This is InternetReadFile Hooking Function.
BOOL
STDAPICALLTYPE
Hook_InternetReadFile(
__in HINTERNET hFile,
__out LPVOID lpBuffer,
__in DWORD dwNumberOfBytesToRead,
__out LPDWORD lpdwNumberOfBytesRead
)
{
// i want to get Internet http URL here!!!!!
return Origin_InternetReadFile(hFile, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead);
}
How to get URL from HINTERNET handle?