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 


Reading memory chunks in C#

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

Joined: 03 Mar 2020
Posts: 6

PostPosted: Thu Apr 01, 2021 7:16 am    Post subject: Reading memory chunks in C# Reply with quote

Code:

List<byte[]> dumps = new List<byte[]>();
long max = (long)sys.maximumApplicationAddress;
long address = (long)sys.minimumApplicationAddress;

Natives.MEMORY_BASIC_INFORMATION mem;
while (address < max &&
         Natives.VirtualQueryEx(Memory.Process.Handle, (IntPtr)address,
         out mem, (uint)Marshal.SizeOf(typeof(Natives.MEMORY_BASIC_INFORMATION))) != 0)
            {
                if (mem.Protect == Natives.AllocationProtect.PAGE_READWRITE &&
                    mem.State == Natives.StateEnum.MEM_COMMIT)
                {
                    byte[] buffer = new byte[(int)mem.RegionSize];
                    IntPtr br;
                    if (Natives.ReadProcessMemory(Memory.ProcessHandle, (ulong)address,
                        buffer, (int)mem.RegionSize, out br) && br != IntPtr.Zero)
                    {
                        dumps.Add(buffer);
                    }
                }
                address = (long)mem.BaseAddress + (long)mem.RegionSize;
            }
            return dumps.ToArray(); //byte[][]


I'm trying to search for a value inside the process memory, for better performance I'm reading chunks of memory. How can I get the values inside this chunks ?
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