this is for console??? how about in dll??
i try this and got error....hahhahahha sori i'm very nob...tnx for answering
i am use msvc++ 2008
Code:
#include <windows.h>
#define BASE_PLAYER 0x4C7FC0
#define OFS_RANK 0xAA5
DWORD WINAPI Thread( LPVOID )
{
HWND hWnd;
for( ;; )
{
DWORD a;
GetWindowThreadProcessId( ( hWnd = GetActiveWindow() ), &a );
if ( ( a != GetCurrentProcessId() ) )
{
hWnd = NULL;
continue;
}
}
return NULL;
}
DWORD getModuleBaseAddress(TCHAR * lpsBaseName, DWORD offset, HANDLE hProcess)
{
HMODULE hMods[1024];
DWORD cbNeeded;
if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded) )
{
for(unsigned int i=0; i < (cbNeeded / sizeof(HMODULE) );i++)
{
TCHAR szModName[200];
if(GetModuleBaseName(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR)))
{
if(_tcscmp(lpsBaseName,szModName) == 0)
{
return (DWORD)hMods[i] + offset;
}
}
}
}
}
DWORD proc_id = FindProcessId(L"Game.exe");
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
DWORD BaseAddr = getModuleBaseAddress(L"GameModule.dll", 0, hProcess);
BOOL WriteMemory( DWORD dwAddress, const void* cpvPatch, DWORD dwSize )
{
DWORD dwProtect;
if( VirtualProtect( (void*)dwAddress, dwSize, PAGE_READWRITE, &dwProtect ) ) //Unprotect the memory
memcpy( (void*)dwAddress, cpvPatch, dwSize ); //Write our patch
else
return false; //Failed to unprotect, so return false..
return VirtualProtect( (void*)dwAddress, dwSize, dwProtect, new DWORD ); //Reprotect the memory
}
DWORD WINAPI HackGame(LPVOID param)
{
while (1) {
if (GetAsyncKeyState(VK_F12)&1) {
DWORD BaseAddr = 0;
WriteMemory(GetCurrentProcess(), (LPCVOID) (dwBaseAddr + BASE_PLAYER), &dwBase, sizeof(dwBase), NULL);
MEMwrite((void *)(dwBaseAddr + OFS_RANK),(void*)(PBYTE)"\x32",1);
beep (500,100);
}
Sleep (10);
}
return (0);
}
BOOL WINAPI DllMain( HMODULE hModule, DWORD Reason, LPVOID lpvReserved )
{
if( Reason == DLL_PROCESS_ATTACH )
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HackGame, NULL, NULL, NULL);
return TRUE;
}