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

First you need to set CallAlOpenCloseCallbacks property to true. Next you need to inspect the initiator of the request (using GetOriginator*() methods) in 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 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