Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

patch auto saved in memory map?

Featured Replies

Posted

hello tuts4you


 


i suppose after mapping a file in memory, and after making a change/patch in this mapped memory, i need to save the bytes wich are changed using FlushViewOfFile , right?


 


so the weird thing is, it saves the patch already without using the FlushViewOfFile api yet!


 


so actually i don't have to use FlushViewOfFile because the bytes are automatic saved after unmapping it seems.


 


can someone tell me why?



hOpenFile = CreateFile(szFilePath, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL) hOpenFileMapping = CreateFileMapping(hOpenFile, NULL, PAGE_READWRITE, 0, dwSizeOfFile, NULL) pFile = MapViewOfFile(hOpenFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, dwSizeOfFile) /** make a some patches in mapped file, then unmap it **/
UnmapViewOfFile(pFile);
CloseHandle(hOpenFileMapping);
CloseHandle(hOpenFile);

Edited by PieterJones

i suppose after mapping a file in memory, and after making a change/patch in this mapped memory, i need to save the bytes wich are changed using FlushViewOfFile , right?

Nope, you don't. Closing file handle commits all changes automagically.

FlushViewOfFile is useful in specific situations when, for example, you have the same file mapped in several processes and you want to write the changes without actually closing the handle. Something like this, for example - http://stackoverflow.com/questions/4306157/createfilemapping-synchronous-between-programs

  • Author

Thanks for the clear answer kao. +1


Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.