
Den 07-12-2011 16:13, Ion Gaztañaga skrev:
El 07/12/2011 14:44, Dean Michael Berris escribió:
Actually, I just checked the docs: it seems you want the 'copy_on_write' mode which combines PROT_WRITE|PROT_READ and MAP_PRIVATE. This allows you to make changes in place to the memory region without having the changes reflected to the original file.
Yes, copy_on_write should work. When a page is modified the OS creates a new page for you but other process sees your changes (well, I guess they can end in the page file).
Well, at least with 1.45 I cannot get it to work.
I also speculate if its actually any faster, since I need to change
every single byte in the memory region (I'm decrypting).
My understanding of these OS features are weak, but my mental model of
it is that
//Create a file mapping
file_mapping m_file( file.c_str(),
boost::interprocess::read_only );
//Map the whole file with read-write permissions in this
process
mapped_region region( m_file, boost::interprocess::read_only );
//Get the address of the mapped region
const char* addr = static_cast