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 


"Something.exe"+C97321

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

Joined: 01 Jul 2012
Posts: 23

PostPosted: Sun Dec 01, 2013 7:52 pm    Post subject: "Something.exe"+C97321 Reply with quote

Well. I have weird problem that I'm wondering again.

I can use this easily to get always the correct value for everything I want to.
Code:
int AppMain = nProc.MainModule.BaseAddress.ToInt32();


If I read memory AppMain + Offset1 I get correct value, but why can't I write that value? WriteProcessMemory doesn't write there any changes, but CE is able to change the value.

Code:
[DllImport("kernel32.dll")]
        public static extern int WriteProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);

        [DllImport("kernel32.dll")]
        public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);

        [DllImport("kernel32.dll")]
        public static extern int ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead);


Code:
Process nProc = Process.GetProcessesByName("software")[0];
            IntPtr nProcHandle = OpenProcess(DEBUGGER, false, nProc.Id);

            int AppMain = nProc.MainModule.BaseAddress.ToInt32();

            int bytesWritten = 0;
            int bytesRead = 0;

            byte[] Buff = new byte[1024];

            int Offset1 = 0xC98F94;
            int BaseAddr1 = AppMain + Offset1;

            MessageBox.Show(BaseAddr1.ToString()); <- I get correct value always. Doesn't matter if I restart it.

            ReadProcessMemory((int)nProcHandle, BaseAddr1, Buff, Buff.Length, out bytesRead);

            byte[] Val1 = ASCIIEncoding.ASCII.GetBytes("400");
            WriteProcessMemory(nProcHandle, AppMain + 0xB82F92, Val1, Val1.Length, out bytesWritten); <- I don't know why this doesn't change the value as well as ReadProcessMemory can read it.


What's wrong? Surprised
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sun Dec 01, 2013 8:03 pm    Post subject: Reply with quote

The memory may be protected. Use VirtualProtectEx to adjust the permissions of the page.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Epz
Newbie cheater
Reputation: 0

Joined: 01 Jul 2012
Posts: 23

PostPosted: Mon Dec 02, 2013 6:57 am    Post subject: Reply with quote

Thank you. I've checked out about VirtualProtectEx and it works well Smile Thanks!
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 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