I’m having problem with mapping part of volume to memory. Volume is opened successfully, I can read from it, but CreateFileMapping() fails. GetLastError() returns 87, which has following meaning: “The parameter is incorrect.” I’ve created image of the volume and it is handled correctly. This is how I open file and create mapping:
/* open function */
fd->handle = CreateFile(name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
/* mapping function */
LARGE_INTEGER li;
li.QuadPart = offset;
handle = CreateFileMapping(fd->handle, NULL, PAGE_READONLY, li.u.HighPart, li.u.LowPart, NULL);
I’m working on Windows XP SP3 (but code should also work on newer versions), administrator account.
CreateFileMapping only supports mapping files. It’s returning the “The parameter is incorrect” because the handle isn’t for a file.