View previous topic :: View next topic |
Author |
Message |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Sun May 23, 2010 6:50 pm Post subject: c++ header file (memory.h) |
|
|
Hey everyone, this is my first post here. I am a beginner in game hacking and while I was messing with C++ API functions located in <windows.h> I found that It's a hard for a beginner to WriteProcessMemory() without struggling(I struggled to get it working). So I decided to make a simple header file that will recall WriteProcessMemory() in a simpler way..It's like a shortcut, I even included SetDebugPrivileges() to avoid GetLastError(5). Another handy function I did is isProcessRunning(windowName) that returns 1 if the window was found and 0 otherwise. Note that those functions aren't hard and I am not telling everyone to use it. I just wrote it and I thought some people MAY find it handy. Dont flame me for trying to help =). Any comments or corrections are greatly appreciated
memory.h
Code: | #include <windows.h>
#include <iostream>
#include <winuser.h>
using namespace std;
void SetDebugPrivileges(){
void* tokenHandle;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle);
TOKEN_PRIVILEGES privilegeToken;
LookupPrivilegeValue(0, SE_DEBUG_NAME, &privilegeToken.Privileges[0].Luid);
privilegeToken.PrivilegeCount = 1;
privilegeToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(tokenHandle, 0, &privilegeToken, sizeof(TOKEN_PRIVILEGES), 0, 0);
CloseHandle(tokenHandle);
}
int writeToAddress(char * windowName,int address,int data){
HWND window = 0;
DWORD PID;
HANDLE pHandle;
window = FindWindow(NULL,windowName);
if(!window) return 0;
GetWindowThreadProcessId(window, &PID);
SetDebugPrivileges();
pHandle = OpenProcess(PROCESS_ALL_ACCESS,0,PID);
if(!pHandle){
if(GetLastError()==5){
cout << "Access to " << windowName << " denied"<<endl;
}
}
else{
if(WriteProcessMemory(pHandle,(void*)address,&data,sizeof(data),NULL))
return 1;
}
return 0;
}
int isProcessRunning(char * windowName){ //Cleaned up by dark byte
return FindWindow(NULL,windowName);
}
|
usage examples:
Code: | #include "memory.h"
using namespace std;
int main(){
int found = isProcessRunning("Untitled - Notepad");
int success = writeToProcess("Untitled - Notepad",0x4D1FD4,1515); //1515 is the data to be written to 0x4D1FD4,1515
return 0;
}
|
Last edited by Vyrus on Sun May 23, 2010 8:40 pm; edited 2 times in total |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25779 Location: The netherlands
|
Posted: Sun May 23, 2010 6:58 pm Post subject: |
|
|
Quote: | int success = writeToProcess("Untitled - Notepad",0x4D1FD4,1515); //1515 is the data to be written to 0x4D1FD4,1515 |
I bet there WILL be people that actually try that and then reply here asking why it doesn't work
Anyhow, as a correction:
at least call CloseHandle in writeToAddress, or store the processhandle somewhere for re-use
else you're going to run out of handles when freezing an address
tip2: (Programmers tip)
you can rewrite
Code: |
int isProcessRunning(char * windowName){
HWND window;
window = FindWindow(NULL,windowName);
if(window) return 1;
return 0;
}
|
into
Code: |
int isProcessRunning(char * windowName){
return FindWindow(NULL,windowName);
}
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
Last edited by Dark Byte on Sun May 23, 2010 7:03 pm; edited 1 time in total |
|
Back to top |
|
 |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Sun May 23, 2010 7:01 pm Post subject: |
|
|
I forgot to close the process handle as you mentioned. I'll modify it. Thanks for the reply
Edit: Yes your programming's tip would work perfectly(You can find it in my main post now). I've been programming for a long time and I completely know that the code I have posted is so messy due to the fact that I didn't have enough time to revise the code. I'm new to C++,Game hacking..But I believe I learn fast because of my programming skillls and background.
|
|
Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Sun May 23, 2010 8:43 pm Post subject: |
|
|
It's funny how you as well made something like this. I made one today out of boredom(not completely finnished), and I might as well post it too.
http://pastebin.com/HVc44B3M
It isn't completely done or fully tested but I know that reading,writing and readpointer works, didn't find and oppurtunity to test writePointer yet.
Here's a sample use: Code: | #include "stdafx.h"
#include <iostream>
#include "MemManagement.h"
using namespace std;
int main(int argc, char* argv[])
{
jProc MineSweeper = findProcess( TEXT("winmine.exe") );
DWORD Timer = 0x0100579C;
if (MineSweeper.PID != 0) {
cout << "Found the process." << endl << "Timer = " << readMemory( MineSweeper, Timer, 4 ) << endl;
writeMemory( MineSweeper, Timer, (LPVOID)999 );
CloseHandle( MineSweeper.hProcess );
} else {
cout << "Couldn't find the process." << endl;
}
return 0;
} |
Feel free to use any of it in your own file if you want to.
//Edit
Forgot to mention you need Platform SDK to compile this.
|
|
Back to top |
|
 |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Sun May 23, 2010 10:12 pm Post subject: |
|
|
Lol, that was funny.(Great minds think alike)
I like your usage for structs, it's looking much more organised than mine. Although I don't fully understand your code due to my lack of knowledge of C++ and winAPI...
//edit
Have you forgotten to SetDebugPrivileges()?
Last edited by Vyrus on Sun May 23, 2010 10:15 pm; edited 2 times in total |
|
Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Sun May 23, 2010 10:14 pm Post subject: |
|
|
Ask about anything you're wondering about and I'll try to explain it as best I can.
|
|
Back to top |
|
 |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Sun May 23, 2010 10:16 pm Post subject: |
|
|
SwallowIt wrote: | Ask about anything you're wondering about and I'll try to explain it as best I can. |
Thanks, that would help alot =))
//edit
Code: | EnumProcesses( ProcessesIDs, sizeof(ProcessesIDs), &cbNeeded ) |
Would that line fill your array of IDs with all PIDs running on the system? If yes, why would you do that instead of using FindWindow()? Im wondering.
|
|
Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Sun May 23, 2010 10:24 pm Post subject: |
|
|
That it does. And I used that because not every process has a window that you can find.
|
|
Back to top |
|
 |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Sun May 23, 2010 10:32 pm Post subject: |
|
|
SwallowIt wrote: | That it does. And I used that because not every process has a window that you can find. |
I understand everything now..I even inferred that GetModuleBaseName() takes a process handle and sets your TCHAR variable to the corresponding process name. I feel I am doing some progress. Thanks for clarifying.
|
|
Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Sun May 23, 2010 10:46 pm Post subject: |
|
|
No problem, add me on msn if you want to(pm me for email).
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 23, 2010 11:33 pm Post subject: |
|
|
You two get this as well..
(Maybe I should finish it and make a post explaining it... I seem to be linking to this a lot...)
|
|
Back to top |
|
 |
Vyrus How do I cheat?
Reputation: 0
Joined: 23 May 2010 Posts: 8
|
Posted: Mon May 24, 2010 7:17 am Post subject: |
|
|
SwallowIt wrote: | No problem, add me on msn if you want to(pm me for email). |
I can't pm because I'm still new..pm me your msn if possible =))
Quote: | (Maybe I should finish it and make a post explaining it... I seem to be linking to this a lot...) |
It will help if you explain it more(I haven't mastered C++ yet ^^)
|
|
Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue May 25, 2010 5:00 am Post subject: |
|
|
SwallowIt wrote: | I made one today out of boredom(not completely finnished), and I might as well post it too. | I Finnish'ed it, here you go: Code: | /* Tehnyt SwallowIt Cheat Engine -foorumilta */
/* Prosessi, luettava osoite, luettavien tavujen määrä */
/* Prosessi, kirjoitettava osoite, kirjotettava puskuri */
/* Prosessi, osoitin osoitteeseen, luettavien tavujen määrä */
/* Prosessi, osoitin osoitteeseen, kirjotettava puskuri */ | No problems!
|
|
Back to top |
|
 |
Jesper Grandmaster Cheater Supreme
Reputation: 9
Joined: 21 Feb 2007 Posts: 1156
|
Posted: Tue May 25, 2010 5:03 am Post subject: |
|
|
Jani wrote: | SwallowIt wrote: | I made one today out of boredom(not completely finnished), and I might as well post it too. | I Finnish'ed it, here you go: Code: | /* Tehnyt SwallowIt Cheat Engine -foorumilta */
/* Prosessi, luettava osoite, luettavien tavujen määrä */
/* Prosessi, kirjoitettava osoite, kirjotettava puskuri */
/* Prosessi, osoitin osoitteeseen, luettavien tavujen määrä */
/* Prosessi, osoitin osoitteeseen, kirjotettava puskuri */ | No problems! |
I don't speak finnish.
|
|
Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue May 25, 2010 5:34 am Post subject: |
|
|
SwallowIt wrote: | I don't speak finnish. | I do and you said you hadn't Finnish'ed it completely, so I thought I might help you. However, if you meant finished, my bad. SwallowIt wrote: | I made one today out of boredom(not completely finnished), and I might as well post it too. |
|
|
Back to top |
|
 |
|