![]() |
|
#1
|
|||
|
|||
|
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 |
|
|
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 |