Elmegaard How do I cheat?
Reputation: 0
Joined: 03 Feb 2010 Posts: 1
|
Posted: Tue Aug 06, 2013 9:23 pm Post subject: [C#] Stuck writing a pointer scanner |
|
|
I started writing a simple pointer scanner in C#. It is not exactly a C# question, more like a VirtualQueryEx / pointers in general question. I followed this: pinvoke.net/default.aspx/kernel32/VirtualQueryEx to try and find a list of all addresses in any program, like CE can do. So far my code is pretty much the same as in the link:
Code: | private void newScan()
{
long MaxAddress = 0x7fffffff;
long address = 0;
List<memTest> memTests = new List<memTest>();
do
{
MEMORY_BASIC_INFORMATION m;
int result = VirtualQueryEx(StaticValues.SelectedProcess.Handle, (IntPtr)address, out m, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION)));
memTests.Add(new memTest() { BaseAddress = m.BaseAddress, EndAddress = (uint)m.BaseAddress + (uint)m.RegionSize - 1, RegionSize = m.RegionSize, Result = result });
if (address == (long)m.BaseAddress + (long)m.RegionSize)
break;
address = (long)m.BaseAddress + (long)m.RegionSize;
} while (address <= MaxAddress);
} |
The only exeption is, I use windows forms and add the result to a list instead of printing it to the console. Just to add everything, here is the object I use to create the list:
Code: | public class memTest
{
public IntPtr BaseAddress;
public uint EndAddress;
public IntPtr RegionSize;
public int Result;
} |
Now, this solution finds the first address just fine (I use CE to test this). To make an example, I am scanning my sound card, which has the base address of 0x570000 right now, this is the same in both my program and CE. Now, if I take the next region/base address my program finds it is 0x571000, which doesn't exist according to CE.
EDIT:
I am using a 64-bit windows 8 and the application I am testing is 64-bit. I tried earlier with a 32-bit application and that did not work at all, just ended up with an infinite loop.
|
|
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25774 Location: The netherlands
|
Posted: Wed Aug 07, 2013 2:24 am Post subject: |
|
|
VirtualQueryEx also returns unallocated memory regions, so check if it is committed or not
Also, in visual c++ a long is only 32-bit
_________________
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 |
|