swell Posted October 5, 2015 Posted October 5, 2015 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!
Extreme Coders Posted October 5, 2015 Posted October 5, 2015 The main advantage is that you do not need a buffer, to operate on the file.You can directly access the file contents as if it was located directly in your own address space. Read up on MSDN, it is already explained there: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366556(v=vs.85).aspxAlso read this SO post. 3
Peter Ferrie Posted October 9, 2015 Posted October 9, 2015 (edited) It allows the file to be accessed directly (including writing) as an array of bytes in memory.It replaces this sequence:VirtualAlloc() -> regionSetFilePointer()ReadFile()update regionSetFilePointer()WriteFile()SetFilePointer()ReadFile()update regionSetFilePointer()WriteFile()...SetFilePointer()ReadFile()update regionSetFilePointer()WriteFile()with this one:CreateFileMapping()MapViewOfFile() -> regionupdate regionupdate region...update region Edited October 9, 2015 by Peter Ferrie 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now