Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++/Delphi Memory Editing Help.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kalookakoo
Expert Cheater
Reputation: 0

Joined: 03 Mar 2008
Posts: 117

PostPosted: Sun Aug 10, 2008 9:05 pm    Post subject: C++/Delphi Memory Editing Help. Reply with quote

My friend knows C++ and I know Delphi. We both know the basics, and can make a normal undetected bot blah blah blah. But how exactly do you get around memory editing and messing with addresses like CE does? My friend finds more tuts because hes cheating, and I can't find much more than a random guide on Gzn which just flings you into things without explaining things which I'd like to understand before attmepting anything. Does anyone know any good informational passages/ tutorials out there that could help understand how to do memory editing with both languages?


Thanks In advance? Seeing as not many people come in this forum, I'll be happy for any helpful answer.


I posted this in two sections to increase likeliness of answers and I didn't really know where it applied. I aplogize if I did something wrong, but I say truthfully I never intended spam.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Aug 10, 2008 9:27 pm    Post subject: Reply with quote

Well, either in Delphi or C++ your gonna have to use multiple API to modify memory of another process.

The first step would be to get the process id of the process you want.

You can do that via a few API and a bit of looping:

CreateToolhelp32Snapshot
Process32First
Process32Next

Then doing simple string compares to the PROCESSENTRY32.szExeFile.

Once you got the process id, the next step is getting the handle to that process.

You can do this via OpenProcess (Make sure you have the right access rights to read/write memory)

Finally once you have the handle to the process, you can use:

ReadProcessMemory
WriteProcessMemory

Be aware, if a process has some sort of protection (Like MapleStory's GameGuard) they will most likely hook these functions to stop you from modifying the memory.

Another thing is, some processes use memory right protection, which is just a memory protect assigned by VirtualProtect. To get by this, just use the API VirtualProtectEx to change the protect to PAGE_EXECUTE_READWRITE.

_________________
Back to top
View user's profile Send private message
Kalookakoo
Expert Cheater
Reputation: 0

Joined: 03 Mar 2008
Posts: 117

PostPosted: Sun Aug 10, 2008 10:29 pm    Post subject: Reply with quote

I understand what your saying, but I think I need a bit more understanding of hooks, handles, etc
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25832
Location: The netherlands

PostPosted: Mon Aug 11, 2008 2:16 am    Post subject: Reply with quote

Memory editing is done exactly the same in both languages. You just use a slightly different syntax

You call OpenProcess to open the target process, that gets you a handle
then you can use that handle on calls like VirtualProtectEx, VirtualAllocEx, ReadProcessMemory and WriteProcessMemory.

And a hook is just calling writeprocessmemory and replace a few bytes with a jump to a block of code you've created with VirtualAllocEx and filled with assembler code with WriteProcessMemory

_________________
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
Back to top
View user's profile Send private message MSN Messenger
Kalookakoo
Expert Cheater
Reputation: 0

Joined: 03 Mar 2008
Posts: 117

PostPosted: Mon Aug 11, 2008 8:28 am    Post subject: Reply with quote

Ok. So if im correct, first you get the process ID using

CreateToolhelp32Snapshot
Process32First
Process32Next


Never used it before, gonna research those. But the process ID im guessing isnt just the name I could find in task manager? Also, I understand about GG's "hooking" that blocks mem editing, and sending Virtual keys, because I remember having to use a .dll to get my bot to work. Does the same thing apply here, a .dll needed to mem edit past GG? obviously I'm not going to start mem editing on MMORPGs, and starting at basics like Pinball, just curiousity getting the best of me.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Aug 11, 2008 9:32 am    Post subject: Reply with quote

The process id is a 4 byte integer value that identifies the process. Well, I'm sure there is some way to use WPM/RPM on GG protected games but the reason's dynamic-link-libraries work is because when they get injected into a process it gives you direct access to the memory (because you are loaded into the memory of the executable). And here is an example of "attaching" to a process:

Code:

BOOL AttachProcess(char *szExe) {
   HANDLE hProcess;
   HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPSHOT, NULL);
   PROCESSENTRY32 pe32;
   pe32.dwSize = sizeof(PROCESSENTRY32);
   Process32First(hSnapshot, &pe32);
   do {
      if(strcmp(szExe, pe32.szExeFile) == 0) {
         hProcess = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_READ | PROCESS_VM_OPERATION, NULL, pe32.th32ProcessID);
         CloseHandle(hSnapshot);
         return TRUE;
      }
   } while(Process32Next(hSnapshot, &pe32));
   CloseHandle(hSnapshot);
   return FALSE;
}


You will want to set the access rights appropriately, you may also want to add a parameter of type DWORD that holds the access rights and you just pass that to the API. The ones I put in there are assuming you want to read, write, and use VirtualProtect.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Aug 12, 2008 4:44 am    Post subject: Reply with quote

Kalookakoo wrote:
Ok. So if im correct, first you get the process ID using

CreateToolhelp32Snapshot
Process32First
Process32Next


Never used it before, gonna research those. But the process ID im guessing isnt just the name I could find in task manager? Also, I understand about GG's "hooking" that blocks mem editing, and sending Virtual keys, because I remember having to use a .dll to get my bot to work. Does the same thing apply here, a .dll needed to mem edit past GG? obviously I'm not going to start mem editing on MMORPGs, and starting at basics like Pinball, just curiousity getting the best of me.


The three API you listed above are used to iterate the process list.

CreateToolhelp32Snapshot takes a 'snapshot' of data based on the parameters passed to it. TH32CS_SNAPPROCESS would take a snapshot of the current processes.

Process32First/Process32Next is used to iterate through the returned snapshot handle. You can locate the needed process using the name though while iterating through them.

The structure used for Process32First/Process32Next is PROCESSENTRY32, which contains various information on the current process you are at in the iteration. The process name is one of various pieces of information you can view while iterating the list. A small example, for a console application, to display the process list would be:

Code:
#include <windows.h>
#include <iostream>
#include <tlhelp32.h>
#include <tchar.h>
#include <stdio.h>

int main()
{
   PROCESSENTRY32 pe32 = { sizeof( PROCESSENTRY32 ) };
   HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
   if( hSnapshot == NULL )
      return 0;

   if( Process32First( hSnapshot, &pe32 ) )
   {
      while( Process32Next( hSnapshot, &pe32 ) )
      {
         _tprintf_s( _T("%s\n"), pe32.szExeFile );
      }
   }
   CloseHandle( hSnapshot );

   std::cin.sync();
   std::cin.ignore();
   return 0;
}


Inside the while loop is the print out of the current process name in the list. You can compare the name to a static name for any game, such as Minesweeper (winmine.exe) to ensure the process you need is found and such.

Keep in mind, processes can be hidden and can be removed from this list.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Tue Aug 12, 2008 10:42 am    Post subject: Reply with quote

If you wanna make a dll. YOu can forget about OP,WPM,RMP... etc

You can use(Delphi)

var
a:pbytearray;
begin
a:=pointer($addruwannaedit);
a[0]:=your byte;
messagebox(0,pansichar(inttohex(dword(a[1]),Cool),'',mb_ok);//this reads the 2nd byte from pointer.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Aug 13, 2008 9:46 am    Post subject: Reply with quote

dnsi0 wrote:
If you wanna make a dll. YOu can forget about OP,WPM,RMP... etc

You can use(Delphi)

var
a:pbytearray;
begin
a:=pointer($addruwannaedit);
a[0]:=your byte;
messagebox(0,pansichar(inttohex(dword(a[1]),Cool),'',mb_ok);//this reads the 2nd byte from pointer.


Going along with what dnsi0 is saying, for C++ the same thing would be:

Writing a byte to a specific address:
Code:
*(BYTE*)0x100B4EC = 0xE8;


Reading a byte from a specific address:
Code:
BYTE btVal = *(BYTE*)0x100B4EC;

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites