Add your own alternative version
Stats
273K views 14.1K downloads 157 bookmarked
Posted
23 Sep 2006
|
Comments and Discussions
|
|
Your question is not clear but if you find the exact address that you are interested in, you can change the code to only freeze that address, it is the last step that my code does, you will understand it if you read the code (it is the code being called by the last form of the window.
But keep in mind that, the addresses in OllyDbg and other debuggers are offsets of real addresses! It means that the first address that has to be 0, will be something like 10000000, and so the code is the offset of 10000000.
Good luck.
Sojaner!
|
|
|
|
|
The way he has gone step by step, without jumping directly to the topic is good. The diagrams also help a great deal in making the logic clear. The way he has approached and explained the whole concept has made things look much simpler. All in all, a good article
|
|
|
|
|
I really happy that you liked it.
Sojaner!
|
|
|
|
|
how to scan a float value ??
ex: 2.52

|
|
|
|
|
For every variable type, first you need to know, how the value looks like in a byte array.
To do this, you have to use this method:
<br />
const float floatVariable = 2.52f;<br />
<br />
byte[] floatByteArray = System.BitConverter.GetBytes(floatVariable);<br />
Now you have a byte array that you can look for, in the memory.
Sojaner!
|
|
|
|
|
When i use ReadPrcoessMemory to scan the RAM,it dons't work,lasterror=0X0000012B :(.
PS: OS->win7 64bit
|
|
|
|
|
I used it good on WIN 7 64 bit
|
|
|
|
|
Never tried it on same OS but take care about the "User Account Control" in Windows Vista and higher, this API may be one of the Admin only APIs.
Sojaner!
|
|
|
|
|
Hello Sojaner!
I'm using your scanner in C#project for many purposes
I just wrote a nice trainer game for Settlers 4. it's workflow is the following:
- Reads resource informations
- Create a map and places resources in correct place
- Can select a resource and edit it through a simple UI
- I use a simple timer for "Freeze" option which means, that amount resources can be frozen (for eg. if a settler takes a stone for construction from a 7-stone storage slot, it remains 7 after pickup)
Resource read/write goes well, the only problem is gettin the list of resources.
The memory block where these informations are stored can be overflown, in this case, the program continues listing anywhere. So I have to scan wide area of memory (usually 0x07000000-0x30000000)
This takes much time even if scanning block's size is 20480. But this is the smaller problem, the greater problem is that I don't receive all the values. I tried other memory searchers, and I always get back more result than with this scanner. I think the problem is, that Settler's memory consist lots of block with RW permission of size from 0x4000 to 0x8000, separated with a 0x1000 sized block signed as "reserved". Maybe the reader can't read in such environment. The distance of identifiers I search is 128 bytes if they are in the same block (for eg. after loading a game).
I just want to know whether I can fix it with using another parameters in opening process, freezing memory before scan or etc.
Please tell me if you can advise anything.
Thanks in advance:
Cpt Balu
Hungary
|
|
|
|
|
Love it, but could u post something in vb.net? i can search and all, but i take 1 by one and its slow as hell 
|
|
|
|
|
that's really useful for me!thanks!!
|
|
|
|
|
I'm happy that you liked it.
Sojaner!
|
|
|
|
|
Your Memory Scanner , is work in Games On-line ? Grand Chase and Gunbound , Scan work's ?
|
|
|
|
|
The memory scanner can scan the memory of process you attach. For LAN/Online games, you can attach the client application, but remember, that some times the client application just gets informations from server. In this case, if you overwrite anything, it will be reset just after querying the server next time. If the server runs the main core for game, then your attempt to modify it will fail. The only way could help you is to attach it as remote process, but I think game server's techincal information are not published :-P
Or if you are hosting a multiplayer game, then just attach the hosting game's process.
|
|
|
|
|
I have spent 10 days looking for example source codes online that would show how to list strings contained in process's memory, but failed to do so...
Please, if someone knows how to do it, it would help me alot.. Thank you..
|
|
|
|
|
Sorry for delay!
I have been away for a long time!
Looking for strings are so tricky as strings may contain encodings and they vary in length, so looking for a predefined pattern will be so much easier.
This is my thought on listing the Strings in the memory.
Start reading the bytes from beginning till the first null byte (0x00), store the whole array and start doing the same from the next byte after the null byte...
After searching the whole memory for the arrays, examine every array with preferred String Decoder classes to see the results.
This may not be a perfect solution but it may help.
As much as I know, there are string detection algorithms out there on the web but I have never used them.
I hope my reply helps you.
Good luck.
Sojaner!
|
|
|
|
|
you know, you dont need to search the whole memory space of the program in memory. the values that you are looking for, say the health, etc.. are going to be stored in the .data section, which is only a small part of all the memory space the program is using. all you need to do is read the PE headers to get the virtual address of the .data section, then search that. A PE file starts with:
_IMAGE_DOS_HEADER(not important), followed by the _IMAGE_NT_HEADERS, then the Section Table(thats what you want) which is an array of Section Headers, there is one Section Header for each section (.text,.data,idata,etc). find the one for the .data section and it contains the virtual address. As defined in winnt.h:
typedef struct _IMAGE_SECTION_HEADER {
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union {
DWORD PhysicalAddress;
DWORD VirtualSize;
} Misc;
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
|
|
|
|
|
i need recovry file source 
|
|
|
|
|
Hello Sojaner!
I'm building a GPS program for my university project.
For that task, I have to write two applications - the GPS software and the GPS emulator, which will throw "GPS String" to my software at some constant rate.
I was looking for a good way to pass variable from one application to another, and the best solution to do that working on fast rates is to create a buffer in which my emulator will write data and the gps software will read from ten times a second.
In order to make it happen, I need to create 2 "double" variables X and Y to store coordinates, and to pass their addresses to the second application.
Because I pass the adresses only once, I can use file.
The problem is to get my variables physical addresses and once passed, to set pointer to them on the other side.
I write using C#.
...hope to get some help from You, since You know thing or two about memory managing!
Thank You for Your time!..
Pavel.
|
|
|
|
|
First of all, thanks a lot for this nice source code.
I read your code and all seems to logical to me. But I don't know how to search for string in a game, like "Charactername" and such things.
Can you give me a hint?
|
|
|
|
|
I'd like a similar feature but for searching an array of bytes.
|
|
|
|
|
You'll need to convert the string you're searching for into a byte array using an Encoder, then search for a matching byte array:
string search = "CharacterName";
byte[] sBytes = Encoding.ASCII.GetBytes(search);
This assumes your game stores the character's name in ASCII - it might also be Unicode, in which case you'll have to change the encoder on your end to match it. The only way to know though is to try different options and see which one picks up the right values.
Good luck =)
PS: This is what part of the alphabet would look like if the letters Q and R were removed.
|
|
|
|
|
|
|
Hi, I'm trying to use your article to build my own memory scanner / hex editor / game cheat thing etc. I already have such a tool but I wanted a challenge.
However I have run into a problem and after checking your code it appears your program would suffer from the same problem, although you don't even check for an error.
The problem is this: large areas of a processes memory are protected. ReadProcessMemory will fail when trying to read from such a place.
I will show an example of various desired and undesired results, and what both your code and my code do.
Here is my relevant VB code for reference, which I think improves on yours a bit, although the calling function has to do more checks on the returned data (ie IsNot Nothing, or != null):
Public Function ReadMemory(ByVal start As UInteger, ByVal length As UInteger) As Byte()<br />
Dim read As UInteger = 0<br />
Dim buffer(length - 1) As Byte<br />
WinAPI.ReadProcessMemory(_handle, start, buffer, length, read)<br />
<br />
If read = 0 Then<br />
Return Nothing<br />
End If<br />
<br />
If read <> length Then<br />
Array.Resize(Of Byte)(buffer, read)<br />
End If<br />
Return buffer<br />
End Function
Let's say we have a chunk of memory that looks like this starting at 0x00000000, where the Xs are protected:
01 23 45 67 89 AB CD EF XX XX XX XX XX 01 23 45 67 89 AB CD EF
We ReadProcessMemory the first three, everything is OK:
Your function: 01 23 45
Mine: 01 23 45
We read 10 bytes, and the last two get cut off. This is ok because we still get all the data we can access:
Your function: 01 23 45 67 89 AB CD EF 00 00
Mine: 01 23 45 67 89 AB CD EF
Now we read bytes at 0x8 for 5 bytes...
Your function: 00 00 00 00 00
Mine: null
Still acceptable behavior. Now this is where it gets ugly.
Let's read 10 bytes from the same place:
Your function: 00 00 00 00 00 00 00 00 00 00
Mine: null
Where we would really like to convey the actual contents of XX XX XX XX XX 01 23 45 67 89 somehow...
To summarize, if the starting address is protected, the ENTIRE read fails, even if later parts of the specified address range are unprotected!
A visual demonstration... the pictured control does one ReadProcessMemory operation on the entire pictured block of memory... here is a result with an entirely non-protected block:
http://x.mzzt.net/0039.jpg
Now if we scroll up one line, we have the top line as a protected block. The whole read operation is blank:
http://x.mzzt.net/0040.jpg
Now my problem is, how do I determine where a protected area ends? If I have a condition like 40.jpg, I can't tell unless I read every single protected byte one at a time until I find the first unprotected one... and that is SLOW.
I know there must be a Windows API function to get the addresses of these protected areas, because the program I use for memory scanning can show me those ranges in a list.
So my question is... what is it? I've been looking through the API docs and I can't see anything relevant.
I figure it's my lack of expertise in this area that's responsible... the term "memory pages" keeps popping in my head but I don't remember enough about OS-level memory management to know if this is what I'm running into. Not that I saw any API functions relating to pages either.
I'm also curious if it's possible to do this a lazy way... like, can I count on a certain boundary for these areas (ie I'd only need to check once every 0xXXXX bytes instead of checking every protected byte to find the end of the protected area).
PS: I think you should consider splitting your article into two articles, one on basics of memory and another on your actual program. This way those of us who were expecting just an article on the program don't have to go past a bunch of stuff we already know... you can have it in a separate article for those of us who don't know. Also you should expand more on the actual program and how it operates... right now most of your article about that is just theory and not how you actually implemented it.
BTW I assume when you are referring to *-bit OSs you mean the maximum number of bits used to access memory, and thus the limit on how much memory the OS supports. Nowadays that's what the *-bit means in modern OSs, but when you are talking about the *-bit of microprocessors there are a few different metrics that can be used... it's all very confusing but I will just say there has never been an 8-bit OS as far as memory usage. 8 bits is only enough to fit 256 bytes, you can't do ANYTHING in that. And I know for a fact DOS was 16-bit, with the exception of extenders like DOS4GW and Windows 386 Enhanced mode which enabled some 32-bit functionality in supported programs.
|
|
|
|
|
|
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|