#include "stdafx.h" #include #include "MyTrace.H" #include "ApiProxy.H" LPCTSTR DEBUG_FILE_LOG = "c:\\winsock2.dll.log"; LPCTSTR DEBUG_FILE_FLAG = "c:\\winsock2.dll.var"; //-------------------------------------------------------------------------// VOID PrintBlock(PVOID start, ULONG offset) { ULONG i, j, m, n; PCHAR tmpstr; tmpstr = (PCHAR)start; if(start == 0 || start == (PVOID)0xFFFFFFFF) return; m = offset / 16; n = offset % 16; for(i = 0; i < m + (n == 0 ? 0 : 1); i++) { Log("0x%08X ", tmpstr + (i * 16)); Log("%04X ", i * 16); for (j = 0; j < (i < m ? 16 : n); j ++) { Log("%02X ", tmpstr[(i * 16) + j] & 0x00FF); } for(; j < 16; j++) Log((".. ")); for (j = 0; j < (i < m ? 16 : n); j ++) { if(tmpstr[(i * 16) + j] >= 32) Log("%c", tmpstr[(i * 16) + j]); else Log("."); } for(; j < 16; j++) Log(".. "); Log("\n"); } Log("\n"); } //-------------------------------------------------------------------------// BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpvReserved) // reserved { if ( fdwReason == DLL_PROCESS_ATTACH ) // When initializing.... { // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL, // which will end up in nearly every GUI process anyhow. DisableThreadLibraryCalls( hinstDLL ); char szRealWININET[ MAX_PATH ]; GetSystemDirectory( szRealWININET, sizeof(szRealWININET) ); strcat( szRealWININET, "\\ws2_32.DLL" ); HMODULE hModWininet = LoadLibrary( szRealWININET ); if ( 0 == hModWininet ) { MessageBox( 0, "Unable to load real ws2_32.DLL", 0, MB_OK ); return FALSE; } Log("Ok hooking winsock now\n"); // // Call GetProcAddress for each WININET function, and store the return // value into the appropriately named g_pfnXXX pointer // #define SPYMACRO( x ) \ g_pfn##x = GetProcAddress( hModWininet, #x ); #include "winsock2.inc" } else if ( fdwReason == DLL_PROCESS_DETACH ) // When shutting down... { } return TRUE; }