CSS writing to process problem
Hey MPGH, this is my first(?) post on the forums and I think that I will posting more useful stuff once I've got the hang of C++ and memory editing..
So, heres my problem.. I'm using the following code to read/write into the hl2 process memory in an attempt to create some sort of sv_cheats bypass. It works perfectly when reading memory (getting the current value of sv_cheats), but it plays up when writing to the memory. It says it does it and gets no error or anything, but when I checked CSS for change to the sv_cheats value, nothing, its the same as before.
Headers are all in the "stdafx.h"..
Could anyone help me please? And I have heard of something to do with the source SDK and using it to hook into CSS (or something, im noob :P). Thanks!
So, heres my problem.. I'm using the following code to read/write into the hl2 process memory in an attempt to create some sort of sv_cheats bypass. It works perfectly when reading memory (getting the current value of sv_cheats), but it plays up when writing to the memory. It says it does it and gets no error or anything, but when I checked CSS for change to the sv_cheats value, nothing, its the same as before.
Code:
#include "stdafx.h"
using namespace std;
int fWriteTo();
void EnableDebugPriv();
int main()
{
EnableDebugPriv();
HWND handle = FindWindow(0 ,TEXT("Counter-Strike Source"));
if(handle == 0)
{
MessageBox(0,TEXT("Failed to find window"),TEXT("Return"),MB_OK);
}
else
{
DWORD ID;
GetWindowThreadProcessId(handle,&ID);
HANDLE hProcess = OpenProcess( PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION , FALSE, ID);
if(!hProcess)
{
Beep(1000,1000);
}else {
int buffer;
if (ReadProcessMemory(hProcess,(void *)0x0DBBA8E8,&buffer,4,NULL))
{
cout << "Value of Address (sv_cheats): ";
cout << buffer << "\n";
// MessageBox(0,TEXT("Press OK To Close The Program."),TEXT("Return"),MB_OK);
cin.get();
}
else {
MessageBox(0,TEXT("Could not Read"),TEXT("Return"),MB_OK);
}
}CloseHandle(hProcess);
}
fWriteTo();
}
int fWriteTo()
{
EnableDebugPriv();
LONG address = 0x0DBBA8E8;
BYTE newvalue[] = {0x00, 0x00, 0x00, 0x00};
HWND hwnd;
HANDLE phandle;
DWORD pid;
hwnd = FindWindow(NULL, TEXT("Counter-Strike Source"));
if (hwnd != 0) {
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
} else {
cout << "Could not find the window.";
cin.get();
return 0;
}
if (phandle != 0) {
WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 2, 0);
cout << "Memory wrote successfully.\n";
cin.get();
} else {
cout << "Couldn't get a handle";
cin.get();
}
main();
}
void EnableDebugPriv() {
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &tkp, sizeof tkp, NULL, NULL);
CloseHandle(hToken);
}
Could anyone help me please? And I have heard of something to do with the source SDK and using it to hook into CSS (or something, im noob :P). Thanks!
