glming

Hi, all

I want to map the file into the address space of one program with execute attribute. First I use CreateFile() with GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE to open one file, then I use CreateFileMapping() with PAGE_EXECUTE_READWRITE to create FileMap object, last I use MapViewOfFileEx() with FILE_MAP_EXECUTE|FILE_MAP_READ|FILE_MAP_WRITE to map file into the program address space.

According to MSDN help, the mapped memory space has the executed access. When I try copying the instruction code into this space and execute it, the system still reports STATUS_ACCESS_VIOLATION (0xc0000005) exception. I doubt MapViewOfFileEx() API doesn't support FILE_MAP_EXECUTE setting. Because FILE_MAP_EXECUTE is undefined in WinNt.h or WinBase.h, I have to use SECTION_MAP_EXECUTE in my code, which doesn't take effecive.

If you meet with the similar issue or you know any more information about it, could you share with me

My system is windows server 2003 with service pack 1.

Thanks
Liming