-
Notifications
You must be signed in to change notification settings - Fork 11
Ingame Console
zeroKilo edited this page Dec 29, 2018
·
3 revisions
To activate the ingame console there needs to be the rendering of the hud aswell as the streaming of the input detoured (toggle with F12):
`
const BYTE JMP = 0xEB;
const BYTE JZ = 0x74;
const BYTE JNZ = 0x75;
DWORD* pOpenAddress;
BYTE* pAccept;
DWORD patch1 = 0x9EF9C7;
DWORD patch2 = 0x9EFA1F;
bool conIsOpen = false;
void EnableConsole(bool open)
{
DWORD oldProtect = 0;
VirtualProtect((LPVOID)pOpenAddress, 4, PAGE_EXECUTE_READWRITE, &oldProtect);
VirtualProtect((LPVOID)pAccept, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
if(open)
{
*pOpenAddress = 1;
*pAccept = 1;
}
else
{
*pOpenAddress = 0;
*pAccept = 0;
}
conIsOpen = open;
}
DWORD WINAPI InputThread(LPVOID)
{
while(true)
{
if(GetAsyncKeyState(VK_F12) & 1)
EnableConsole(!conIsOpen);
Sleep(10);
}
return 0;
}
DWORD WINAPI enable_ingame_console(LPVOID)
{
DWORD oldProtect = 0;
HANDLE hGame = OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessId());
VirtualProtect((LPVOID)patch1, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
VirtualProtect((LPVOID)patch2, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
WriteProcessMemory(hGame, (PVOID)patch1, &JMP, sizeof(JMP), NULL);
WriteProcessMemory(hGame, (PVOID)patch2, &JMP, sizeof(JMP), NULL);
DWORD dwClass = NULL;
DWORD dwOpen = NULL;
DWORD dwAccept = NULL;
DWORD dwOpenAddress = NULL;
DWORD dwInputAddress = NULL;
DWORD dwRendDx9Base = 0;
while(dwRendDx9Base == 0)
dwRendDx9Base = (DWORD)GetModuleHandle(L"RendDX9.dll");
DWORD dwReadAt = dwRendDx9Base + 0x62C13C;
while(!dwClass)
ReadProcessMemory(hGame, (PVOID)dwReadAt, &dwClass, 4, NULL);
pOpenAddress = (DWORD*)(dwClass + 4);
while(!dwInputAddress)
ReadProcessMemory(hGame, (PVOID)(dwClass + 696), &dwInputAddress, 4, NULL);
dwInputAddress = dwInputAddress + 20;
while(!dwAccept)
ReadProcessMemory(hGame, (PVOID)dwInputAddress, &dwAccept, 4, NULL);
pAccept = (BYTE*)dwAccept;
CloseHandle(hGame);
EnableConsole(false);
CreateThread(0, 0, InputThread, 0, 0, 0);
return 0;
}
CreateThread(0, 0, enable_ingame_console, 0, 0, 0);`