winapi - FileMapped write access -
i try write file while opened file mapped process , fails.
please @ fragments of code:
access = generic_read | generic_write; share = file_share_read | file_share_write; disposition = open_existing; handle filehandle = createfilea(filename.c_str(), access, share, 0, disposition, 0); //... unsigned long valprotect = 0; //... valprotect = page_readwrite; //... const handle mappinghandle = createfilemapping(filehandle, 0, valprotect, 0, 0, 0); //... this->m_access = file_map_all_access; //... this->m_startaddress = (uint8_t*)mapviewoffile(mappinghandle, this->m_access, 0, 0, 0); //... closehandle(filehandle);
at time file closed (it's handle) mapped address space. open file in notepad++, modify , try save, see message:
"please check if file opened in program."
so cannot rewrite process, seems it's permissions writing locked.
if unmapped file like:
unmapviewoffile(this->m_startaddress);
then cannot rewrite file again.
what did wrong?
notepad++ trying obtain exclusive access file when writing it, fail while mapping (or else using file) still open. many apps obtain exclusive access when writing files, avoid other processes reading data until finished being written. sharing file, notepad++ asking many rights. there nothing can in code.
Comments
Post a Comment