MapViewOfFile throws an "access denied" error - but only on large files

Giganews Newsgroups
Subject: MapViewOfFile throws an "access denied" error - but only on large files
Posted by:  R.Wieser (addre…@not.available)
Date: Tue, 20 Nov 2018

Hello All,

I've got some basic code opening a file map (removed all error catching):

call CreateFileA,[@@sFile],GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
mov [ebx].FM_hFile,eax
call CreateFileMappingA,[ebx].FM_hFile,0,PAGE_READONLY,0,0,0
mov [ebx].FM_hMap,eax
call MapViewOfFile,[ebx].FM_hMap,FILE_MAP_READ,0,0,0

The problem is that this works for smallish files, but when I try to open a
3 GB file the MapViewOfFile returns with an error, and GetLastError shows me
its "access denied".  Which does not make any sense to me.

I've just tried to google the problem, but most of those are about coding
mistakes.  And as my code seems to work perfectly for smallish files  ....

The only thing I can think of is that my (old) machine doesn't have a whole
lot of memory and a 3 GBfile might simply not fit.  Than again, I though
that mapping a file doesn't actally try to load everything into memory. And
besides, I would than have expected an "out of memory", not an "access
denied" error.

Does anyone know whats going on here ?

Regards,
Rudy Wieser

Replies