문제

I worte the code below

 void * ptr1 = VirtualAlloc((void*)0x70000000, 32*1024*1024, MEM_RESERVE, PAGE_READWRITE);
 void * ptr2 = VirtualAlloc((void*)0x80000000, 4*1024*1024, MEM_RESERVE, PAGE_READWRITE);

But VirtualAlloc fails and the value of ptr1,ptr2 are always NULL. I want to use the adress 0x70000000,0x80000000. Does anyone know how I can use these adress ?

도움이 되었습니까?

해결책

This part of the memory is not accessible for usermode applications. From the following MSDN page:

User applications cannot call VirtualAlloc with shared heap address range (0x70000000 to 0x7fffffff) because this is read-only for user applications and read/write for kernel mode.

다른 팁

Are you sure some of the pages in the requested memory block are not already reserved (or committed)? VirtualAlloc cannot reserve a reserved page.

Why are 0x70000000 and 0x80000000 special? In the flat memory model, there is no reason why one address would be preferable to any other.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top