#1
|
|||
|
|||
Allocating memory at a specific location
Hi Guys,
Here is a question and I figure it might be possible to implement cause the windows LOADER seems to do this. (maybe i am just a fool ) I have a code generator which generates a code packet in memory. I want to take that code packet and a corresponding data packet and send it to clients, get them to perform the operations and send the results back (yes its a distributed processing application). However the problem is I want to carry the data seperate to the code packet so I need to be able to allocate a data block in memory at a specific location (hard coded into the code packet). As opposed to carrying the code and data together and using "virus like" techniques to find out where I am in memroy (eg a call <addr> and a pop ebp pair). I guess (from what I know about the PE header format) the windows loader uses this technique to put the required EXE code in the correct memory location. How is this done? Thanks for your help REDBull (MOO!) |
#2
|
|||
|
|||
You can allocate with VirtualAlloc. If memory localtion you need is available you can specify location from which allocation should start. Why do you need a specific location?
|
#3
|
|||
|
|||
Hi Nikola,
Thanks for the correct info !! I need to be able to allocate static memory because I dont want to make major changes to my code generation routines until I am sure that the rest of my ideas are going to work. |
#4
|
|||
|
|||
Code:
PUSH 40 PUSH 3000 PUSH 1000 PUSH 3B40000 CALL kernel32.VirtualAlloc stack: 03B40000 |Address = 03B40000 00001000 |Size = 1000 (4096.) 00003000 |AllocationType = MEM_COMMIT|MEM_RESERVE 00000040 \Protect = PAGE_EXECUTE_READWRITE |
#5
|
|||
|
|||
You may not be able to allocate all locations using VirtualAlloc as some of the location are pre-reserved by loader for various functions, e.g. thread stack. So if your location is conflicting with it, you may need to move it somewhere and its not simple .
Visu |
#6
|
|||
|
|||
Thanks guys,
I realize that the memory might be allocated but it will sure beat the hell out of me re-writing my enigne just yet! Thanks for the help! |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Allocating BSTR strings in IE9 | r00t | General Discussion | 4 | 01-31-2013 12:47 |
VirtualAlloc fails on specific memory address | MarkusO | General Discussion | 7 | 01-22-2006 18:11 |