| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Jul 30, 2008 10:25 am Post subject: [Help] Memory Saver [Visual Basic 6.0] |
|
|
Don't Flame.
This program I made is suppose to be able to create a exe from the process in the memory that is identical to it.
I have included the program here.
So It basically loops through the memory and stores it into a byte array then saving it later. But after I checked the binary of the file I discover that the file length is different between the 2 files and some bytes are corrupt.
This is made in visual basic. So see if you can get this to work.
Oh sorry forgot to include source...
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Jul 30, 2008 2:04 pm Post subject: |
|
|
It's because the PE loader has to fix the imports, fix relocation (if there is any) and align the sections. The .exe in the process is no where near the same as the image on disk.
In order to make a dump of the process you have to reverse all of those operations.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Jul 30, 2008 2:46 pm Post subject: |
|
|
| Hmm. Guess I excluded alot of those things.Cause I only compared the first like 10 bytes... o.o
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Jul 30, 2008 2:51 pm Post subject: |
|
|
| dnsi0 wrote: | | Hmm. Guess I excluded alot of those things.Cause I only compared the first like 10 bytes... o.o |
The first few bytes will always be the same since it is just the DOS/NT header.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Jul 30, 2008 3:00 pm Post subject: |
|
|
| Yea the THis cannot be run under dos thingy.
|
|
| Back to top |
|
 |
Ksbunker Advanced Cheater
Reputation: 0
Joined: 18 Oct 2006 Posts: 88
|
Posted: Wed Jul 30, 2008 5:30 pm Post subject: re: |
|
|
Easiest way would be to use MapFileAndCheckSumA (in imagehlp.dll)... what this does is compute a checksum using the array of bytes from the .TEXT (i.e. the code) section.
Once you have this dword, you can read the PE Header offset CheckSum, whose checksum is calculated using the same API that you just used (i.e. MapFileAndCheckSum). If there's a difference, modfied, if same, perfect.
To obtain the dword from PE header, its as simple as (assuming eax=imagebase);
| Code: | mov edx, eax ;00400000
mov ecx, [edx+3Ch] ;Offset to PE signature
add ecx, edx ;ecx=PE Header
add ecx, 58h ;ecx=CheckSum
mov eax, dword ptr [ecx] ;
mov PECheckSum, eax ;save contents to PECheckSum |
http://www.rohitab.com/discuss/index.php?showtopic=28822&hl=MapFileAndCheckSum
|
|
| Back to top |
|
 |
|