Solved[C++] GetAsyncKeyState. <DLL>

Posts 1–3 of 3 · Page 1 of 1
[C++] GetAsyncKeyState. <DLL>
Can anyone help me with this?
I want to F1 you have that particular value.

The Code :

Code:
#include <Windows.h>

#define ADR_HP ADDRESS

void WriteMemory(DWORD address, DWORD value)
{
    DWORD dwOldProt;
    VirtualProtect((LPVOID)address, 4, PAGE_READWRITE, &dwOldProt);
    *(DWORD *)address = value;
    VirtualProtect((LPVOID)address, 4, dwOldProt, &dwOldProt);
}

int __stdcall DllMain(HMODULE hModule, DWORD  dwReasons, LPVOID lpReserved)
{
    if(GetAsyncKeyState(VK_F1))
	{
		WriteMemory(ADR_HP, 0);
	}
}
Ex:

Code:
#include <Windows.h>
#include <process.h>

//Variables
INT Hack[100];

//Address
#define ADR_HP 0x000000
#define ADR_Ammo 0x000000

VOID WriteMemory(DWORD Address, DWORD Value)
{
    DWORD dwOldProt;
    VirtualProtect((LPVOID)Address, 4, PAGE_READWRITE, &dwOldProt);
    *(DWORD *)Address = Value;
    VirtualProtect((LPVOID)Address, 4, dwOldProt, &dwOldProt);
}

VOID Cheats()
{

  if(GetAsyncKeyState(VK_F1)&1) Hack[0] =! Hack[0];	
  if(GetAsyncKeyState(VK_F2)&1) Hack[1] =! Hack[1];	

   if(Hack[0])
   {
	   WriteMemory(ADR_HP, 100);
   }

   if(Hack[1])
   {
	   WriteMemory(ADR_Ammo, 999);
   }

}

UINT WINAPI Main(VOID *)
{
	while(!(DWORD)GetModuleHandleA("GameProcess.exe"))
		Sleep(100);

	__asm
	{
      CALL [Cheats]
	}

	return FALSE;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	DisableThreadLibraryCalls(hModule);
	if(dwReason == DLL_PROCESS_ATTACH) 
	{
		_beginthreadex(NULL, NULL, &Main, NULL, NULL, NULL);
	}
	return TRUE;
}
Before you start writing to the memory, you will have to hook a game function or the game module(like Felix showed you in the code he posted above).
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us