MapViewOfFile failes with errorCode 6 (Invalid Handle)

十年热恋 提交于 2019-12-01 14:52:29

Here:

HANDLE hFile = CreateFile(pFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

Replace GENERIC_READ with GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE

Also there is no FILE_MAP_ACCESS, but FILE_MAP_ALL_ACCESS.

I tried this code and it maps test file with success, not sure what you want to do with it further. Also for inspecting problems you can also use: Procmon.exe from sysinternals - it will report you what problems occured during file manipulations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!