Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-18-2006, 17:21
MarkusO
 
Posts: n/a
VirtualAlloc fails on specific memory address

I'm trying to manage a (theoretical) simple task: allocate memory at an address specified by me. However, I don't get it to work for some reason.

I simply use VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect);

If lpAddress is set to NULL, Windows will allocate the memory at an address it selects by itself. This works without any problems.

However, if I specify any memory location, the function will fail with ERROR_INVALID_ADDRESS from GetLastError. I traced a bit in the Windows kernel, but I found only one error check: If lpAddress is below 0x00010000, GetLastError will return ERROR_INVALID_PARAMETER.

The function even fails if I'm trying to force allocation of the memory region which Windows will give me if I set lpAddress to NULL.

Example:
Code:
VirtualAlloc(0x00830000, 0x4000, MEM_COMMIT, PAGE_READWRITE) -> function fails with ERROR_INVALID_ADDRESS
VirtualAlloc(NULL,       0x4000, MEM_COMMIT, PAGE_READWRITE) -> function allocates 0x4000 bytes at address 0x00830000
Did I miss something special or why doesn't the allocation of a specific memory region work?
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unpack OneWay.dll problem,Import REConstructor v1.6 Final fails. winndy General Discussion 3 01-07-2006 10:22
MapConv fails to apply IDA .MAP labels or comments 5Alive General Discussion 5 05-25-2005 19:55
Allocating memory at a specific location redbull General Discussion 5 04-18-2005 19:37


All times are GMT +8. The time now is 03:08.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )