[HELP] Read/WriteProcessMemory

Need Help With an Existing Feature in Memory Hacking Software? Ask Here

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

[HELP] Read/WriteProcessMemory

Postby hileci » Fri Aug 22, 2008 12:30 am

I want my program to read a pointer whose adress is 0x111111 then add 0x111 to the adress which the pointer holds and write 0x0 to the new adress how can i do that with write and readmemory apis

Base Pointer : 0x111111
offset : 0x111
new value : 0x0

How can i do that?:rtfm:
Code: Select all
DWORD ProsesKimligi, Alan=0x111111, AlinanAlan, HedefAlan;
HANDLE Islem;
BYTE eDegistirilen[1]={0x0};


Islem = OpenProcess(PROCESS_ALL_ACCESS,0, ProsesKimligi);
ReadProcessMemory (Islem, (LPVOID)Alan, &AlinanAlan, 4, NULL);
HedefAlan = AlinanAlan + 0x111;
WriteProcessMemory(Islem, (LPVOID)HedefAlan, &eDegistirilen, 4 , NULL))
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby mezzo » Fri Aug 22, 2008 1:14 am

[moved]
- No thanks, I already have a penguin -
User avatar
mezzo
El Mariachi
 
Posts: 739
Joined: Mon Apr 30, 2007 10:27 pm
Location: Antwerp

Postby spunge » Fri Aug 22, 2008 3:13 am

You have to find the processID first. It isn't static.

There are 2 ways to do it, 1 by process name and 1 by window handle.

CreateToolHelp32Snapshot/Process32First/Process32Next.

FindWindow/GetWindowThreadProcessID.

If the pointer changes you have to constantly loop WPM.
spunge
NULL
 
Posts: 121
Joined: Sun Jul 27, 2008 4:58 am
Location: VEH callback

Thanks

Postby hileci » Fri Aug 22, 2008 5:16 am

Thanks Spunge, lets assume that process id is ProsesKimligi. What should i do now?
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby L. Spiro » Fri Aug 22, 2008 10:34 am

If the format you want is [0x111111]+0x111 then you are done, except for one bug.


BYTE eDegistirilen[4]={0x0};


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby hileci » Fri Aug 22, 2008 11:13 pm

At ReadProcessMemory line GetLastError() is 5, access is denied. How can i fix that?
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby L. Spiro » Fri Aug 22, 2008 11:35 pm

Open the process with the correct access/permissions.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby hileci » Sat Aug 23, 2008 12:26 am

I am running my .exe as administrator. And in the exe, i am opening the target process with PROCESS_ALL_ACCESS what can I do more?
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby spunge » Sat Aug 23, 2008 4:09 am

Tokens.

AdjustTokenPrivileges.
spunge
NULL
 
Posts: 121
Joined: Sun Jul 27, 2008 4:58 am
Location: VEH callback

Postby hileci » Sat Aug 23, 2008 6:13 am

Thanks Spunge, i have been working on it but it still fails. Have a look at my code:
Code: Select all
        TCHAR szMesg [256];
        HWND HedefTutmac;
        DWORD ProsesKimligi;
        HANDLE Islem, GirisBelgesi;
        LUID Yob;
        TOKEN_PRIVILEGES Belge;

OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &GirisBelgesi);
LookupPrivilegeValue(0, "seSecurityPrivilege", &Yob);
Belge.PrivilegeCount = 1;
Belge.Privileges[0].Luid = Yob;
Belge.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(GirisBelgesi, FALSE, &Belge, 0, 0, 0);
CloseHandle(GirisBelgesi);
                               
HedefTutmac = FindWindow (NULL,"Knight OnLine Client");
GetWindowThreadProcessId (HedefTutmac ,&ProsesKimligi);
Islem = OpenProcess(PROCESS_VM_READ, FALSE, ProsesKimligi );
                           

wsprintf (szMesg, " %d", GetLastError());
MessageBox (NULL, szMesg, "Error", MB_OK);

I am using Vista, BloodShed Dev C++, C language, XTRAP.
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby L. Spiro » Sat Aug 23, 2008 11:17 am

If X-Trap is running then your OpenProcess() is running into hooks which change the permissions you use to open the process.
I am going by what I have observed; I have never studied in-depth because I do not have it.

But removing permissions such as read/write from your call to OpenProcess() seems to be a very popular idea among nProtect Game Guard and X-Trap.

You will need to call the kernel-mode functions directly, or if they are hooked you will need to reconstruct the code overwritten by the hook and add a JMP to the next command in the real function, then call you reconstructed code instead.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby hileci » Sat Aug 23, 2008 11:25 pm

How can i do that? Can you send a tutorial page about kernel-mode functions?

I have checked the game and saw that my game is running as system process does that matter?
hileci
I Have A Few Questions
 
Posts: 6
Joined: Fri Aug 22, 2008 12:28 am

Postby spunge » Sun Aug 24, 2008 2:28 am

Use RKU to check what kernel hooks are in place. Or write a driver that checks for a hook.
spunge
NULL
 
Posts: 121
Joined: Sun Jul 27, 2008 4:58 am
Location: VEH callback

Postby L. Spiro » Sun Aug 24, 2008 2:37 pm

MHS can check for kernel hooks itself; the full script is in the help file (but theirs is more advanced).

http://www.catch22.net/ has a tutorial on how to get started making kernel-mode drivers (and I know James, the owner).
http://www.catch22.net/tuts/kernel1.asp


http://www.rootkit.com/index.php will help later, along with http://www.reactos.org/en/index.html which has samples of many kernel functions which you can use as a rough guide.
Search for the function. For example, http://www.reactos.org/generated/doxygen/db/dbb/winbase_8h.html#a764.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby w00t » Sun Oct 19, 2008 4:24 am

Hi!
I've the same problem, and I use EnableTokenPrivilege (SE_DEBUG_NAME), but still access denied.

I found some similar threads around the net, and some people think it's caused by SP3.

My process (war.exe egg warhammer online) run as a normal user, my tool is launched as administrator, and I use enabletokenprivilege, but still this problem.

I'm going crazy, I never had this problem before on others mmorpg :'(

PS: punkbuster is off

EDIT: Ok i just scanned my computer to find some hooks....and bingo:

Code: Select all
Service Name                                        Syscall  Hooked    Module            Product
NtAdjustPrivilegesToken, ZwAdjustPrivilegesToken    11        YES       klif.sys          Kaspersky Anti-Virus


I'll try without kaspersky ;)
w00t
I Have A Few Questions
 
Posts: 3
Joined: Sun Oct 19, 2008 4:00 am

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests