I'm making a 'Counter Strike: Source' hack in C++. I thought it would be a good start since it doesn't use DMA (Dynamic Memory Allocation) as it holds all the memory in static addresses, which are easy to find since there is no DMA.
Anyway, I was wondering. How could I execute console commands? I heard something about PushToConsole() and SetConsoleVariable() being used for stuff like that.
You need to execute 'sv_cheats 1' to execute other commands on other people servers, I wanted to get that as well as 'noclip' working. It doesn't have to be undetectable or anything, I just want it for LAN and stuff.
(You will see sv_cheats in my code. I was trying to edit the memory for it, obviously it didn't work because it's local memory, it won't affect the server :\. Was worth a try anyway).
Preview code: (I've added a lot more, just not sure if I should release it or not since it's VAC-Proof).
Code:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
int main ()
{
HWND hWnd = FindWindow(0, L"Counter-Strike Source"); // Finds the window titled "Counter-Strike Source".
if (hWnd == 0) // If it can't find the window, then:
{
cout << "I could not locate the window, either you've opened this before you opened CS:S, or this program has a bug." << endl;
}
else
{
DWORD pr0c3zz;
GetWindowThreadProcessId(hWnd, &pr0c3zz); // Locates the process through the window.
HANDLE trollpr0c3zz = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pr0c3zz); // Gives access to process.
if (!trollpr0c3zz) // If it can't access the process, then:
{
cout << "Could not locate CS:S process (hl2.exe)" << endl;
}
else
{
int sv_cheats = 1; // Activate cheat mode..
int r_drawothermodels_on = 2, r_drawothermodels_off = 1; // Wallhack on/off.
int r_DrawModelLightOrigin_on = 1, r_DrawModelLightOrigin_off = 0; // Light region on/off.
int showdata_on = 2, showdata_off = 0; // Show network data on/off.
int cheatsAddr = 0x0FD0E764; // Cheat mode.
int wallhackAddr = 0x243AEC3C; // Wallhack.
int gravityAddr = 0x0FCD81FC; // Light region.
int ndataAddr = 0x243EBD8C; // Show network data/usage.
bool LightRegion = false, Wallhack = false, NDATA = false;
cout << "Welcome to Phizo's Counter Strike: Source hack: Version 1.0" << endl;
cout << "The hotkeys toggle on and off incase you want to turn them off.\n" << endl;
cout << "Open console: ~" << endl;
cout << "Draw light region: F3" << endl;
cout << "Enable wallhack: F6" << endl;
cout << "Show network data/usage: Delete" << endl;
while(1) // Loops so the memory keeps rewriting itself if it's changed.
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)cheatsAddr, &sv_cheats, sizeof(sv_cheats), NULL);
if (GetAsyncKeyState(VK_F3)&1) // If the "F3" hotkey is pressed then it will write the new data to the memory address.
LightRegion = !LightRegion;
if (LightRegion)
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)gravityAddr, &r_DrawModelLightOrigin_on, sizeof(r_DrawModelLightOrigin_on), NULL);
}
else
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)gravityAddr, &r_DrawModelLightOrigin_off, sizeof(r_DrawModelLightOrigin_off), NULL);
}
if (GetAsyncKeyState(VK_F6)&1)
Wallhack = !Wallhack;
if (Wallhack)
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)wallhackAddr, &r_drawothermodels_on, sizeof(r_drawothermodels_on), NULL);
}
else
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)wallhackAddr, &r_drawothermodels_off, sizeof(r_drawothermodels_off), NULL);
}
if (GetAsyncKeyState(VK_DELETE)&1)
NDATA = !NDATA;
if (NDATA)
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)ndataAddr, &showdata_on, sizeof(showdata_on), NULL);
}
else
{
WriteProcessMemory(trollpr0c3zz, (LPVOID)ndataAddr, &showdata_off, sizeof(showdata_off), NULL);
}
} // End of loop.
}
CloseHandle(trollpr0c3zz); // Removes access to the process when it is not needed.
}
system("pause");
return 0;
}
Thanks a lot

.