UnhappyHelpHelp with

Posts 1–10 of 10 · Page 1 of 1
Help with
Hello, what is wrong? The didn't write in Memory. Adresses are okay.

Code:
HANDLE hProcess = 0;
	HWND hWindow;
	DWORD pid = 0;

	//get window handle
	hWindow = FindWindow(NULL, TEXT("GAME NAME"));

	//get process id
	if (hWindow){
		GetWindowThreadProcessId(hWindow, &pid);
	}

	hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);

       WriteProcessMemory(hProcess, (LPVOID*)hProcess + 0x00811768 + 0x28 + 0x2c, "1337", sizeof(int), NULL);
Cheat Engine:
1. upload images on imgur or sth. like that.
2. try to add the offsets to the pointer and read that pointer out again with readprocessmemory...
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)

if (hProcess)
{
//OpenProcess called OK

}
else
{
//OpenProcess returned FAIL (possibly privilege issue?)

}


And why are you passing in a string as the 'lpBuffer' ..."1234" (string) is not the same as 1234 (integer).
1234 as 32 bit integer = 0000000000000000 0000 0100 1101 0010
"1234" as string = ascii value of "1" for first byte, "2" for second byte, etc
anyway, not the same bit representation.

msdn for WriteProcessMemory(): http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
BOOL WINAPI WriteProcessMemory(
_In_ HANDLE hProcess,
_In_ LPVOID lpBaseAddress,
_In_ LPCVOID lpBuffer,
_In_ SIZE_T nSize,
_Out_ SIZE_T *lpNumberOfBytesWritten
);

Check the return value from OpenProcess() and update post please.
^^if this is working, please try to change the value you're writing...the type should match (or match enough to be castable) the function declaration above (ie. a pointer type..not a string literal).

 
edit

Photo attachment hadn't been approved when I made my post.
The several small integers +'d together should have been a hint (...why not just combine them into 1 number..)
but who am I to tell you how to create your integers.

OP said "Adresses are okay" ...



obviously not, and I'm not explaining how to follow a pointer list for the millionth time, to someone who doesn't understand the basics.

GL op.
This is completely wrong:

Code:
hProcess + 0x00811768 + 0x28 + 0x2c
You should read the value at hProcess + 0x00811768 then add 0x2C to the value you read and read again, and only thne you add 0x28 and write the value you want.

"Pseudo"-code:
Code:
//OpenProcess and shit up here
if(hProcess){
     WriteString("1337", ReadInteger( ReadInteger( hProcess + 0x00811768 ) + 0x2C ) + 0x28 );
}
WriteString and ReadInteger are just wrappers for WriteProcessMemory and ReadProcessMemory, respectively.

EDIT: had too many ReadInteger's :P
Quote Originally Posted by MarkHC View Post

...
"Pseudo"-code:
Code:
//OpenProcess and shit up here
if(hProcess){
     WriteString("1337", ReadInteger( ReadInteger( hProcess + 0x00811768 ) + 0x2C ) + 0x28 );
}
WriteString and ReadInteger are just wrappers for WriteProcessMemory and ReadProcessMemory, respectively.

EDIT: had too many ReadInteger's :P

isn't hProcess a unique ID returned from OpenProcess(). A unique Number, not the "base address of the process" . ?
Quote Originally Posted by abuckau907 View Post
isn't hProcess a unique ID returned from OpenProcess(). A unique Number, not the "base address of the process" . ?
Yes it is. I don't know what I was thinking before.

EDIT: Fixed the code I posted above, but I can't edit the first one as it has been more than 1 day since I posted it.
hmm okay...
And why this not work?
Code:
int money = 1000;
HANDLE open = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
		ReadProcessMemory(open, (LPCVOID*)(0x00811768 + 0x28), &val, sizeof(val), NULL);
		ReadProcessMemory(open, (LPCVOID*)(0x00811768 + 0x2c), &val1, sizeof(val1), NULL);
		WriteProcessMemory(open, (LPCVOID*)val + val1, &money, 4, NULL);
		CloseHandle(open);
Quote Originally Posted by xter77 View Post
hmm okay...
And why this not work?
Code:
     int money = 1000;
     HANDLE open = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
     ReadProcessMemory(open, (LPCVOID*)(0x00811768 + 0x28), &val, sizeof(val), NULL);
     ReadProcessMemory(open, (LPCVOID*)(0x00811768 + 0x2c), &val1, sizeof(val1), NULL);
     WriteProcessMemory(open, (LPCVOID*)val + val1, &money, 4, NULL);
     CloseHandle(open);
Read what I wrote previously one more time. You're not doing what I told you.

Also, as @abuckau907 mentioned LPCVOID* => VOID** which is not what you want.

I'll not spoon feed you. I already wrote what you have to do, but you're still doing something completely different.

EDIT: Fuck it, i have nothing better to do anyways.

Code:
     //A simple wrapper function to read a integer on the target process
     //You should probably add a check for error when reading.
     int ReadInteger(HANDLE hProcess, int address){
          int iValue;
          ReadProcessMemory(hProcess, (DWORD*)address, &iValue, sizeof(iValue), NULL);
          return iValue;
     }

     //...
     //Somewhere on your code...

     HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, pid);
     if( hProcess ){
          int addy = ReadInteger( hProcess, ReadInteger( hProcess, 0x2D4B9A38 + 0x2C ) + 0x28 );
          char* szBuf = "string to write";
          WriteProcessMemory(hProcess, 
                       addy, 
                       szBuf, 
                       strlen(szBuf),
                       NULL); 
     }


I obviously didn't test the snippet above. If it doesn't work fix it yourself.
1) check the handle received from OpenProcess() , please.

2) what's the typedef for LPCVOID (hint: two stars vs 1)
Quote Originally Posted by abuckau907 View Post
1) check the handle received from OpenProcess() , please.

2) what's the typedef for LPCVOID (hint: two stars vs 1)
1.) Yes, the handle is right. (Checked with the Injector)
2.) ? | LPCVOID and DWORD not working...
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us