How can I make a file read-only to a certain process?

First you need to set the CallAlOpenCloseCallbacks property to true. Next, you need to inspect the initiator of the request (using the GetOriginator*() methods) in the OnCreateFile and OnOpenFile callbacks. If the file is opened for writing (or created) and you don't want the initiator to write to the file, throw an ECBFSError exception with error code 5 (ACCESS_DENIED).

Note: do NOT cancel OnWriteFile requests to implement read-only functionality. Doing so can lead to unexpected side-effects for the system and for the calling process. OnWriteFile can be canceled only when the actual writing has failed unexpectedly.

Ready to get started?

Learn more about Callback Technologies or download a free trial.

Download Now