EDIT: Removed
EDIT: Removed
Last edited by anon145236; 02-22-2012 at 09:51 AM. Reason: EDIT: Removed
A couple of thoughts after a quick glance here. Firstly, I am surprised you are getting a result close to what you expect. You are stepping your search address by 8, instead of 4. Unless I'm crazy, this means you're skipping at least half of the possible locations. Secondly, I think that second if should be an else if. It looks as though you may be counting the same things twice. If it were me, I would redesign the first loop to work for all cases. It will run much faster if you locally buffer the data you're searching through.
EDIT: Removed
Last edited by anon145236; 02-22-2012 at 09:49 AM. Reason: EDIT: Removed
Ok...
1.) That's nonsense... even if you count in alignment, a struct with 3 pointers would be 16 bytes at max, and there would be pointers at j+4.
2.) it's performance wise perfectly possible, you can either load all bytes at once (just give it a try, if you have enough ram to spare this is the best solution)
or you do it like
Might be horrible mistakes in there, but you'll get it if you read it.Code:while (currentAddress < endAddress) { int memoryRange = endAddress - currentAddress; int toRead = Math.Min(memoryRange, YourConstantBufferSize); byte[] buffer = ReadBytesAtAddress(currentAddress, toRead); // process buffer currentAddress += toRead; }
For "stunning performance" you could even stackalloc that buffer, because your buffer size is already constant by definition.
Last edited by Bananenbrot; 11-26-2011 at 05:39 AM.
EDIT: Removed
Last edited by anon145236; 02-22-2012 at 09:49 AM. Reason: EDIT: Removed
Copying memory is never good for performance. The best* way is to create a scanning thread within wow's address space. Or if you are willing/able to write a kernel driver**, map wow's address space in to your own.
And before anyone claims the above to be overkill for a simple scanner.. Either you care about performance, and will do everything possible to maximize it. Or you don't care, and ReadProcessMemory()'ing 4 bytes at a time is acceptable. There is no middle ground imo
*) best as in highest performance
**) I don't think it's possible to do from user mode but I might be wrong
Even if you could allocate that big of a buffer ReadProcessMemory() would fail. You can't read pages that doesn't exist.
And no, you don't need all that redundant code. Bananenbrot's way is perfectly fine.
Again, you can't read pages that doesn't exist. Either blindly read just 1 at a time or make sure you can read them all first.even though i would love to simplify my code too, i think i have to stick on my "20480 bufferSize"-solution
Last edited by _Mike; 11-26-2011 at 07:52 PM.
i take back what i said
kestackattachprocess() too.
though I don't know how else the second method you mention _mike would be possible, unless you were feeding the information back through an mj_read or an ioctl. nothing i know about at least![]()
Last edited by sitnspinlock; 11-26-2011 at 08:27 PM.
I was thinking along the line of reversing how the memory manager works, and manually remap wow's pages in to both processes at once. I have no idea how to actually implement it, but now I feel like trying just for the fun of it
At first I thought of using KeStackAttachProcess, but I can't think of a way to use it without doing unnecessary data copies.
Last edited by sitnspinlock; 11-27-2011 at 03:22 PM.
EDIT: Removed
Last edited by anon145236; 02-22-2012 at 09:49 AM. Reason: EDIT: Removed
I only read through the code quickly so there might be things I've missed, but
Is definitely wrong.Code:currentAddress += (uint)mbi.BaseAddress + (uint)mbi.RegionSize;
Either assign (Base + Size), or increment by Size. Don't do both at the same time![]()
EDIT: Removed
Last edited by anon145236; 02-22-2012 at 09:49 AM. Reason: EDIT: Removed