//ANTIPB.CPP BOOL InsertDetours() { orig_LoadLibrary = (struct HINSTANCE__ *(__stdcall *)(const char *)) \ DetourFunction((LPBYTE)LoadLibrary, (LPBYTE)LoadLibrary_Hook ); return TRUE; } HMODULE LoadFileModule( char name[] ) { char chCopyTo[512]=""; char chCopyFrom[512]=""; char newName[20]=""; HMODULE hDdrawmod = LoadLibraryEx( name,NULL, DONT_RESOLVE_DLL_REFERENCES ); if (hDdrawmod == NULL) hDdrawmod = GetModuleHandle( name ); if (hDdrawmod == NULL) return 0; GetModuleFileName( hDdrawmod, chCopyFrom, 512 ); strcpy( chCopyTo, dlldir ); strcat( chCopyTo, "DataFiles" ); CreateDirectory( chCopyTo, NULL ); strcat( chCopyTo, "\\" ); strcpy( newName, name ); newName[0] = 'b'; strcat( chCopyTo, newName ); CopyFile( chCopyFrom, chCopyTo, FALSE ); SetFileAttributes( chCopyTo, GetFileAttributes( chCopyFrom ) ); HMODULE ret = LoadLibrary( chCopyTo ); return ret; } //HOOK.CPP HMODULE (WINAPI *orig_LoadLibrary)( LPCSTR lpFileName ); HMODULE WINAPI LoadLibrary_Hook( LPCSTR lpFileName ) { HMODULE hModule = orig_LoadLibrary( lpFileName ); DWORD ret = (DWORD)orig_LoadLibrary(lpFileName); if( strstr( lpFileName, "gfx_d3d_mp_x86_s.dll" ) ) { //AddRefEntityToScene DWORD dwAddRef = ( ret + AddRefEntity ); pR_AddRefEntityToScene = (void (__cdecl *)(refEntity_t *,int,int)) \ DetourFunction( (PBYTE)dwAddRef,(PBYTE)R_AddRefEntityToScene ); __asm mov [ pR_AddRefEntityToScene ], eax; //RenderScene DWORD dwRender = ( ret + RenderScene ); pR_RenderScene = (void (__cdecl *)(refdef_t *)) \ DetourFunction( (PBYTE)dwRender, (PBYTE)R_RenderScene ); __asm mov [ pR_RenderScene ], eax; //Register Font DWORD dwFont = ( ret + RegisterFont ); pR_RegisterFont = (unsigned long (__cdecl *)(char *,int)) \ DetourFunction((PBYTE)dwFont, (PBYTE)R_RegisterFont ); __asm mov [ pR_RegisterFont ], eax; //DrawText DWORD dwText = ( ret + DrawMyText ); pR_DrawText = (void (__cdecl *)(char *,int,int,float,float,float,float,float *,int)) \ DetourFunction((PBYTE)dwText,(PBYTE)R_DrawText); __asm mov [ pR_DrawText ], eax; } return hModule; } BOOL WINAPI DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { switch ( fdwReason ) { case DLL_PROCESS_ATTACH: { DisableThreadLibraryCalls( hinstDLL ); GetModuleFileName( hinstDLL, dlldir, 512 ); for( int i = strlen( dlldir ); i > 0; i-- ) { if( dlldir[i] == '\\' ) { dlldir[i+1] = 0; break; } } InsertDetours(); return true; } } return false; }