Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement mremap (requires modification of mmap), method in description #19

Open
awsdert opened this issue Jun 13, 2024 · 0 comments
Open

Comments

@awsdert
Copy link

awsdert commented Jun 13, 2024

Rough outline of methods:

mmap:

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 );

mremap:

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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant