Posted October 5, 20159 yr 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!
October 5, 20159 yr 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.
October 9, 20159 yr 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, 20159 yr by Peter Ferrie
Create an account or sign in to comment