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 


WriteProcessMemory on an Android VM

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Wed May 13, 2015 4:25 pm    Post subject: WriteProcessMemory on an Android VM Reply with quote

Hello,
I'm using Andy for Android VM on my PC.

After writing a memory scanner, I'm trying to edit the values of each found address.
My program finds all values correctly without issues.

However, I'm getting Access Denied on WriteProcessMemory.
I've also tried using VirtualProtectEx to change the rights of each address, but it still isn't working.

Code:
//...
phandle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, pid);
//...
MEMORY_BASIC_INFORMATION mBI;
DWORD OLDPROTECT;
double sResult;
int asz = val_size;
for (int xy = 0; xy < search_results[cur_result].size(); xy++) {
   if (ReadProcessMemory(phandle,(void*)search_results[cur_result][xy],&sResult,8,0) != 0) {
      if (sResult==double_val) {
         VirtualQueryEx(phandle, (void*)search_results[cur_result][xy], &mBI, sizeof(MEMORY_BASIC_INFORMATION));
         bool isWritable=(mBI.Protect == PAGE_READWRITE || mBI.Protect == PAGE_WRITECOPY || mBI.Protect == PAGE_EXECUTE_READWRITE || mBI.Protect == PAGE_EXECUTE_WRITECOPY);
         if (!isWritable) {
            VirtualProtectEx(phandle,(void*)search_results[cur_result][xy],8,PAGE_EXECUTE_READWRITE,&OLDPROTECT);
         }
         WriteProcessMemory(phandle,(void*)search_results[cur_result][xy],&double_ans,8,0);
         if (!isWritable) {
            VirtualProtectEx(phandle,(void*)search_results[cur_result][xy],8,OLDPROTECT,&OLDPROTECT);
         }
      }
   }
}


Any help is appreciated.
Back to top
View user's profile Send private message
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Thu May 14, 2015 11:37 am    Post subject: Reply with quote

Can anyone help with this??
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu May 14, 2015 12:43 pm    Post subject: Reply with quote

can cheat engine do it without activating kernelmode read/write process memory?
_________________
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
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Thu May 14, 2015 1:11 pm    Post subject: Reply with quote

Dark Byte wrote:
can cheat engine do it without activating kernelmode read/write process memory?


Yes, I checked my Cheat Engine settings, and Kernel mode is off.

As for the code posted above, VirtualProtectEx is failing with error 5 (Access Denied) even when running as administrator.
WriteProcessMemory then returns 0 (failed.)
The second VirtualProtectEx fails with error 87 (Incorrect Parameter.)

I don't see anything wrong, so I've no idea why this is happening.
Also tried just using PROCESS_ALL_ACCESS on OpenProcess, and no change in the program.

EDIT:
Trying
Code:
if (VirtualProtectEx(phandle,(void*)search_results[cur_result][xy],8,PAGE_EXECUTE_READWRITE,0)==0)
   cout << "  " << GetLastError() << endl;

prints Error 998 (ERROR_NOACCESS)
(using 0 as last param instead of a DWORD pointer)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu May 14, 2015 1:44 pm    Post subject: Reply with quote

try process_all_access instead for openprocess (be sure to run as admin and obtain SeDebugPrivileve
_________________
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
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Thu May 14, 2015 4:04 pm    Post subject: Reply with quote

Tried PROCESS_ALL_ACCESS, ran as admin, and also successfully set SeDebugPrivilege to true.
No change in program.

Ughhhh.......
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu May 14, 2015 4:14 pm    Post subject: Reply with quote

you're running any other security programs and forgot to whitelist your program? (e.g. something that prevents writing to other processes)
_________________
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
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Thu May 14, 2015 5:16 pm    Post subject: Reply with quote

I don't think so.
My tool works on PC apps and processes, but isn't working on any Android VM emulators.
Cheat Engine works fine, but it's a huge hassle changing certain values each time I start the game on Android.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu May 14, 2015 6:30 pm    Post subject: Reply with quote

no idea about your code, but try ce's lua functions to automate that
_________________
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
LunaRebirth
Newbie cheater
Reputation: 0

Joined: 05 Sep 2013
Posts: 20

PostPosted: Fri May 15, 2015 7:58 pm    Post subject: Reply with quote

Okay so I tried your idea, and found a Lua code you had posted on http://forum.cheatengine.org/viewtopic.php?p=5554658&sid=1b01a6ae7abff7c1c1dc5859f3d91e90
Code:

 function FindAndReplaceDouble(find, replace)
   ms=createMemScan()
   ms.firstScan(soValueBetween, vtDouble, rtTruncated, find,find,0,0xffffffffffffffff,'+W*X-C', fsmAligned,'4', false, false, false, false)
   fl=createFoundList(ms)
   ms.waitTillDone()
   fl.initialize()
   if fl.Count>0 then
     local i
     for i=0,fl.Count-1 do
       if readDouble(fl.Address[i])==find then
         writeDouble(fl.Address[i],replace)
       end
     end
   end

   fl.destroy()
   ms.destroy()
 end


I tried doing FindAndReplaceDouble(.75,3) and it crashed my entire PC with error WHEA_UNCORRECTABLE_ERROR
tried twice with the same result.
Quite an annoyance, though I assume maybe some functions from the code have been changed or no longer exist???

Edit:
Same result from trying with strings..
http://www.cheatengine.org/forum/viewtopic.php?p=5581806&sid=7505bc57fb9ca80718928776e64b2389:
Code:
ms=createMemScan()
 ms.firstScan(soExactValue,vtString,0,"3.6","",0, 0xffffffffffffffff, "", fsmNotAligned, "1", false, false, false, false)
 ms.waitTillDone()

 f=createFoundList(ms);
 f.initialize();

 resultToWrite=stringToByteTable("40.6"..string.char(0))

 for i=0,f.Count-1 do
   writeString(f.Address[i], "40.6")
   writeBytes(("0x"..f.Address[i])+4,0)
 end

 f.destroy()
 ms.destroy()


EDIT2:
Figured it out..
Had to change the start & end addresses to be smaller.
Thanks!

EDIT3:
Spoke too soon...
I created an entire window using Lua on Cheat Engine and tested everything on a test game. It was working wonderful and quick.
Then I loaded the Android VM to try on the actual game, and NOTHING HAPPENED.
Literally spent the past few hours learning Lua syntax and functions for it not to work.
I don't understand how the VM is filtering everything EXCEPT Cheat Engine's manual value changing???
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