View Single Post
Old 07-22-2010, 14:33
Enigma Enigma is offline
Join Date: Oct 2009
Posts: 30
Rept. Given: 0
Rept. Rcvd 23 Times in 8 Posts
Thanks Given: 0
Thanks Rcvd at 7 Times in 7 Posts
Enigma Reputation: 23
MapViewOfFile and VirtualQuery?

Hi Folks, yesterday had noticed incorrect work of these 2 functions in the x64 application.. Just have not ideas what is wrong there..Please advise...

1. VirtualQuery, if I call this function to know the status of the unallocated memory page then it always fails and GetLastError says that something like "Function access to the invalid memory". If I call VirtualQuery to know a status of some allocated memory, then it works well.

What would be the reason that I can't know status of unallocated memory? In usual 32 application this works well and jus return page status as MEM_FREE..?

2. More strange thing with MapViewOfFile function, simple code that I've used for a years in 32bits does not work in 64bits application:
PHP Code:
HANDLE hFilehfMappMap

if (
hFile == INVALID_HANDLE_VALUE) {return 0;} 

hfMap CreateFileMapping(hFileNULLPAGE_READONLY00NULL); 
if (
hfMap == NULL) {return 0;} 

pMap MapViewOfFile(hfMap,FILE_MAP_READ,0,0,0); 
CreateFile and CreateFileMapping are working well, but MapViewOfFile returns null. Debugging MapViewOfFile I noticed that NtMapViewOfSection returns with the status 0xC00000F1 - "Invalid third parameter".. it is more strange..

Can anybody suggest?
Reply With Quote