Perhaps something like this would work?
Code:
#include <windows.h>
bool IsGameReadyForHook()
{
if( GetModuleHandleA( "d3d9.dll" ) != NULL
&& GetModuleHandleA( "ClientFX.fxd" ) != NULL
&& GetModuleHandleA( "CShell.dll" ) != NULL )
return true;
return false;
}
void __cdecl PushToConsole(const char* szCommand )
{
HMODULE hMod = GetModuleHandleA("CShell.dll");
if(hMod == NULL)
return;
int* ltClientAddr = (int*) 0x377C4450;
typedef int (*ptc_t)(const char *);
ptc_t ptc = *(ptc_t*) (*ltClientAddr + 0x208);
ptc(szCommand);
}
void main()
{
while(true)
{
PushToConsole("SkelModelStencil 1");
PushToConsole("ShowFps 1");
PushToConsole("FogEnable 1" );
PushToConsole("FullBright 1" );
PushToConsole("KnockBack 0" );
PushToConsole("PerturbRotationEffect 0.000000" );
PushToConsole("PerturbIncreaseSpeed 0.000000" );
PushToConsole("PerturbWalkPercent 0.000000" );
PushToConsole("PerturbFiringIncreaseSpeed 0.000000" );
PushToConsole("PerturbRecoil 0.000000" );
PushToConsole("FireMovePerturb 0.000000" );
PushToConsole("ZoomedFireMoveDuckPerturb 0.000000" );
PushToConsole("ZoomedFireMovePerturb 0.000000" );
PushToConsole("ZoomedFireDuckPerturb 0.000000" );
}
}
DWORD WINAPI dwHackThread(LPVOID)
{
while( !IsGameReadyForHook() )
Sleep(100);
main();
return 0;
}
BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
DisableThreadLibraryCalls(hDll);
if ( dwReason == DLL_PROCESS_ATTACH )
{
CreateThread(NULL, NULL, dwHackThread, NULL, NULL, NULL);
}
return TRUE;
}