EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Trying to expose virtual file

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#37628
Posted: 09/05/2016 05:12:51
by Michael Donkhin (Basic support level)
Joined: 09/04/2016
Posts: 1

Hi all,

I am trying to expose the .Net application manifest resource streams as virtual files using the CallbackFilter product. So far I can't do this, though I base my code on the samples provided with the installation. Attempt to open a FileStream on the virtual path fails with FileNotFoundException.

Code
CallbackFilter.SetRegistrationKey(licenseKey);

            _callbackFilter = new CallbackFilter
            {
                OnReadFileC = OnReadFile,
                OnEnumerateDirectoryC = OnEnumerateDirectory,
                OnOpenFileC = OnOpenFile,
                OnPostOpenFileC = OnPostOpenFile,
                OnCreateFileC = OnCreateFile,
                OnPostCreateFileC = OnPostCreateFile,
                OnCloseFileC = OnCloseFile,
                OnPostGetFileSizesC = OnPostGetFileSize,
                OnDeleteVirtualFile = OnDeleteVirtualFile,
                OnFilterDetach = OnDetachFilter,
            };
            
            string mask = @"C:\temp\files\virtual\*";

            _callbackFilter.AddFilterCallbackRule(
                mask,
                CbFltCallbackFlags.CreateCallback |
                CbFltCallbackFlags.OpenCallback |
                CbFltCallbackFlags.CloseCallback |
                CbFltCallbackFlags.ReadCallback |
                CbFltCallbackFlags.GetSizesCallback
                | CbFltCallbackFlags.EnumerateDirectoryCallback
                );

            _callbackFilter.AddFilterAccessRule(mask, CbFltAccessFlags.DeleteProtect | CbFltAccessFlags.ReadOnly);

            _callbackFilter.ProcessFailedRequests = false;
            _callbackFilter.ProcessCachedReadWriteCallbacks = false;
            _callbackFilter.AttachFilter(0);
            _callbackFilter.OwnProcessFiltered = true;


The code inside OnOpen/OnCreateFile checks the flags match the existing file access request and in case they are, sets the virtualfile parameter to 'true', processrequest to 'false'.
Currently the OnOpenFile callback is being called, parameters are set as I described, but immediately afterwards I get the above exception for the same path that had been just processed.

What am I missing here?

Thanks in advance!
#37641
Posted: 09/06/2016 06:05:29
by Vladimir Cherniga (EldoS Corp.)

Quote
Michael Donkhin wrote:
The code inside OnOpen/OnCreateFile checks the flags match the existing file access request and in case they are, sets the virtualfile parameter to 'true', processrequest to 'false'.

Virtual file cannot be opened if it wasn't created previously.
You must call CreateVirtualFile CBFilter api first. Then it may be opened safely.
Alternatively, you may try to modify open callback parameters on the fly, modifying CreateDisposition parameter, when file opened first time.

Reply

Statistics

Topic viewed 577 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!