Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Upcoming OSR Seminars:

Writing WDF Drivers I: Core Concepts, Nashua, NH 15-19 May, 2017
Writing WDF Drivers II: Advanced Implementation Tech., Nashua, NH 23-26 May, 2017
Kernel Debugging and Crash Analysis, Dulles, VA 26-30 June, 2017
Windows Internals & Software Driver Development, Nashua, NH 24-28 July, 2017


Go Back   OSR Online Lists > ntfsd
Welcome, Guest
You must login to post to this list
  Message 1 of 3  
20 Mar 17 13:46
Hunter Wang
xxxxxx@serpurity.com
Join Date: 20 Mar 2017
Posts To This List: 2
How to flush memory mapped files?

Dear all, it has been a long time since I asked the last question few months ago. Now I encounter a new problem: I build an encryption filter driver with Isolation Filter framework, my filter driver maintains the memory/cache for white-list programs, and the programs-not-in-white-list just use the memory/cache of system, this design just worked well for most scenes. But for notepad.exe, my filter driver went into a wrong way, after writing some text and save the file, I found that the content in the file doesn't changed(I'm quite sure I have changed the content of that txt). In order to guarantee that programs-not-in-white-list can get the right and up-to-date data, I think my filter driver should flush the memory mapped files into the disk, but I didn't find a way to do so, is there any functions could flush the memory mapped files into the disk?
  Message 2 of 3  
20 Mar 17 13:52
Don Burn
xxxxxx@windrvr.com
Join Date: 23 Feb 2011
Posts To This List: 164
How to flush memory mapped files?

Read the archives, there is no way to guarantee a flush. Welcome to the challenges of encryption drivers. Don Burn Windows Driver Consulting Website: http://www.windrvr.com -----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@serpurity.com Sent: Monday, March 20, 2017 1:48 PM To: Windows File Systems Devs Interest List <xxxxx@lists.osr.com> Subject: [ntfsd] How to flush memory mapped files? Dear all, it has been a long time since I asked the last question few months ago. Now I encounter a new problem: I build an encryption filter driver with Isolation Filter framework, my filter driver maintains the memory/cache for white-list programs, and the programs-not-in-white-list just use the memory/cache of system, this design just worked well for most scenes. But for notepad.exe, my filter driver went into a wrong way, after writing some text and save the file, I found that the content in the file doesn't changed(I'm quite sure I have changed the content of that txt). In order to guarantee that programs-not-in-white-list can get the right and up-to-date data, I think my filter driver should flush the memory mapped files into the disk, but I didn't find a way to do so, is there any functions could flush the memory mapped files into the disk? --- NTFSD is sponsored by OSR MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <http://www.osr.com/seminars> To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>
  Message 3 of 3  
20 Mar 17 15:08
Slava Imameev
xxxxxx@hotmail.com
Join Date: 13 Sep 2013
Posts To This List: 152
How to flush memory mapped files?

If your driver maintains( i.e. initializes ) file objects then CcFlushCache is your friend as it calls MmFlushSection even for non-cached files ( i.e. mapped but not cached ), if the file is mapped and cached then the cache is supported by the same pages as the mapped virtual address range. Do not forget about proper synchronization before calling CcFlushCache. If your driver doesn't maintain file objects and uses file objects initialized by FSD(file system driver) it is attached to then there is no common way to do this. You can play with IRP_MJ_FLUSH_BUFFERS or you can use CcFlushCache, in the latter with a risk of going into conflict with FSD and MM( Memory Manager ) as you will be unable to properly synchronize with FSD before calling CcFlushCache.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntfsd list to be able to post.

All times are GMT -5. The time now is 20:21.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license