Jump to content
Tuts 4 You

What are the exact use of CreateFileMapping & MapViewOfFile


swell

Recommended Posts

Posted

I'm reading the code of dnlib and I was wondering the exact purpose of CreateFileMapping & MapViewOfFile primitives?

What are the advantages of using these?

Thanks guys!

Peter Ferrie
Posted (edited)

It allows the file to be accessed directly (including writing) as an array of bytes in memory.It replaces this sequence:

VirtualAlloc() -> region

SetFilePointer()

ReadFile()

update region

SetFilePointer()

WriteFile()

SetFilePointer()

ReadFile()

update region

SetFilePointer()

WriteFile()

...

SetFilePointer()

ReadFile()

update region

SetFilePointer()

WriteFile()

with this one:

CreateFileMapping()

MapViewOfFile() -> region

update region

update region

...

update region

Edited by Peter Ferrie
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...