reserved = virtualallocex( ..., NULL, pagesize+viewsize, MEM_RESERVE ... );
truebase = virtualallocex( ..., reserved, pagesize, MEM_COMMIT, ... );
HANDLE *handles = truebase;
handles[0] = file handle;
handles[1] = CreateFileMapping(...);
fileview = MapViewOfFileEx( handles[1], ..., viewsize, truebase + pagesize );
original = base - pagesize;
reserved = virtualallocex( ..., original, pagesize+viewsize, MEM_RESERVE ... );
if ( !reserved )
reserved = virtualallocex( ..., NULL, pagesize+viewsize, MEM_RESERVE ... );
truebase = virtualallocex( ..., reserved, pagesize, MEM_COMMIT, ... );
HANDLE *handles = truebase;
if ( reserved != original )
{
memcpy( original, reserved, sizeof(HANDLE) * 2 );
// decommit original or make available for malloc or something
}
fileview = MapViewOfFileEx( handles[1], ..., viewsize, truebase + pagesize );