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 


[SOLVED] [C++] WriteProcessMemory Error 998 (ERROR_NOACCESS)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Pasukaru
How do I cheat?
Reputation: 0

Joined: 15 Dec 2011
Posts: 8

PostPosted: Sat Dec 17, 2011 7:42 pm    Post subject: [SOLVED] [C++] WriteProcessMemory Error 998 (ERROR_NOACCESS) Reply with quote

Hello again!

Now that I managed to successfully read and write memory with static pointers, I'm trying to go one step further and change Opcode.

I currently try this:
Code:
   HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
   //NOP32 is defined as 0x90909090   
   printf("Writing 0x%08x to 0x%08X\n", NOP32, ammoAddress);
   BOOL success = WriteProcessMemory(handle, (LPVOID)ammoAddress, (LPCVOID)NOP32, 4, NULL);
   if( !success )
      cout << "Error: " << GetLastError() << endl;
It always results in error #998(ERROR_NOACCESS).

However, if I add 'ammoAddress' in CheatEngine as 4 Byte and change it to 0x90909090 it works without problems.

#Edit
I also tried do add this:
Code:
VirtualProtectEx(handle, (LPVOID)ammoAddress, 4, PAGE_EXECUTE_READWRITE, NULL);
But it results in a 998 error as well.
#/Edit

What do I have to change to make this work?

Thanks in advance. Smile

#EDIT
Fixed it.
The error code was replaced with #299(ERROR_PARTIAL_COPY) at some point... I'm not sure why. But at least I knew how to fix this one.

I had to change this:
Code:
   DWORD nop32 = NOP32;
   BOOL success = WriteProcessMemory(handle, (LPVOID)ammoAddress, (LPCVOID)&nop32, 4, NULL);


Last edited by Pasukaru on Sat Dec 17, 2011 11:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Dec 17, 2011 11:25 pm    Post subject: Reply with quote

Its been a while , but this is from an old project i pulled up.

Code:
hWindow = FindWindow(NULL, L"Plants vs. Zombies");

if (hWindow) {
cout<<"window found"<<endl;
GetWindowThreadProcessId(hWindow, &pid);
}

hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_QUERY_INFORMATION, 0, pid);
VirtualProtectEx(hProcess,(LPVOID)address,256,PAGE_EXECUTE_READWRITE, NULL);

ReadProcessMemory(hProcess,(LPCVOID)address,&valueAtAddress,sizeof(valueAtAddress),NULL);
cout << "the current sunpoint value is " << valueAtAddress << endl;
DWORD value = valueAtAddress + 500;
WriteProcessMemory(hProcess,(LPVOID)address,&value,sizeof(value),NULL);
CloseHandle(hProcess);

_________________
clawtheclouds.com
Back to top
View user's profile Send private message
Pasukaru
How do I cheat?
Reputation: 0

Joined: 15 Dec 2011
Posts: 8

PostPosted: Sat Dec 17, 2011 11:35 pm    Post subject: Reply with quote

I just found out what my problem was. (I didn't use a pointer in WriteProcessMemory)

Thanks anyways. Smile
Back to top
View user's profile Send private message
Kavvman
Master Cheater
Reputation: 2

Joined: 17 Apr 2004
Posts: 316

PostPosted: Wed Dec 21, 2011 10:33 am    Post subject: Reply with quote

Just fyi

I also tried do add this: Code:
VirtualProtectEx(handle, (LPVOID)ammoAddress, 4, PAGE_EXECUTE_READWRITE, NULL);

But it results in a 998 error as well.
#/Edit

This is because you are putting the last param as NULL, the old access parameters variable and it fails.

_________________
...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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