EldoS | Feel safer!

Software components for data protection, secure storage and transfer

throw new ECBFltError(5) not Working

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.
#31998
Posted: 01/25/2015 01:39:26
by saharan lv (Basic support level)
Joined: 01/25/2015
Posts: 4

Code below

Code
mFilter.OnCreateFileC = CbFltCreateFileC;
            mFilter.OnPostCreateFileC = CbFltPostCreateFileC;
            mFilter.OnRenameOrMoveFileC = CbFltRenameOrMoveFileC;
            mFilter.OnPostRenameOrMoveFileC = CbFltPostRenameOrMoveFileC;
            mFilter.OnWriteFileC = CbFltWriteFileC;
            mFilter.OnPostWriteFileC = CbFltPostWriteFileC;
            mFilter.OnSetFileSecurityC = CbFltSetFileSecurityC;
            mFilter.OnSetFileAttributesC = CbFltSetFileAttributesC;
            mFilter.OnSetAllocationSizeC = CbFltSetAllocationSizeC;

            mFilter.AddFilterCallbackRule("e:\\temp\\*.txt",
               CbFltCallbackFlags.WriteCallback |
               CbFltCallbackFlags.CreateCallback |
               CbFltCallbackFlags.RenameCallback |
               CbFltCallbackFlags.SetBasicInfoCallback |
               CbFltCallbackFlags.SetSizesCallback |
               CbFltCallbackFlags.PostWriteCallback |
               CbFltCallbackFlags.SetSecurityCallback |
               CbFltCallbackFlags.DeleteCallback);

            mFilter.AttachFilter(0);

    private static void CbFltCreateFileC(CallbackFilter Sender, string FileName, ref uint DesiredAccess, ref uint FileAttributes, ref ushort ShareMode, ref uint CreateOptions, ref ushort CreateDisposition, ref bool VirtualFile, ref bool ProcessRequest)
        {
            ProcessRequest = false;
            
            throw new ECBFltError(ERROR_ACCESS_DENIED);

        }

    private static void CbFltWriteFileC(CallbackFilter Sender, string FileName, ref long Position, byte[] Buffer, ref int BytesToWrite, bool Cached, ref IntPtr UserContext, ref bool ProcessRequest)
        {
            ProcessRequest = false;
            throw new ECBFltError(ERROR_ACCESS_DENIED);

        }


I use these code to prevent file Create and Write .
But when I execute another c# code :
Code
try
            {
               using (var fs = File.CreateText(string.Format("e:\\temp\\{0}.aaa.txt", DateTime.Now.Ticks)))
               {
                  fs.WriteLine("hello,");
                  fs.Close();
               }
            }
            catch (Exception exc)
            {

            }

A file still be created and some contents writed;
#31999
Posted: 01/25/2015 01:52:28
by Eugene Mayevski (EldoS Corp.)

By default CallbackFilter doesn't filter requests that originate from the same application that installs the filter. You just don't get the callback.

On a side note if you have a license, please link the license ticket to your user account before we continue. The ticket itself and the procedure of its use are specified in the registration e-mail that was sent to you upon license purchase. If you don't have the license ticket, please contact the person from which you have obtained the license key (the one in your source code) for a license ticket.

NOTE: please don't post license keys and license tickets to the forum. If you need to clarify something about your license, please use HelpDesk ( http://www.eldos.com/helpdesk/ ).


Sincerely yours
Eugene Mayevski
#32000
Posted: 01/25/2015 04:29:34
by saharan lv (Basic support level)
Joined: 01/25/2015
Posts: 4

Thanks Eugene
But I test the code in another application.And CallbackFilter fire the right events. but this can not prevent the new process to create and write .
#32001
Posted: 01/25/2015 07:30:38
by Vladimir Cherniga (EldoS Corp.)

You should add a handler for OnOpenFileC event and process it identically to OnCreateFileC.
#32002
Posted: 01/25/2015 18:50:01
by saharan lv (Basic support level)
Joined: 01/25/2015
Posts: 4

Thanks Vladimir ,
But I think this could not work.

When I use notepad to create a txt file,nodepad will be prevented .
But When I write a C# code ,a file created.

Perhaps you can paste a sample code to help me .
#32005
Posted: 01/26/2015 03:14:06
by Vladimir Cherniga (EldoS Corp.)

Quote
saharan lv wrote:
But When I write a C# code ,a file created.

Your own process in not filtered with default settings, because it may deadlock in recursive call to callback. Use this code from another process.
#32029
Posted: 01/28/2015 05:11:17
by saharan lv (Basic support level)
Joined: 01/25/2015
Posts: 4

Hi Vladimir , This is another exe not use callbackFilter.

@ Vladimir Cherniga can you test the code or give me a sample code.
This really not working.
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.

Reply

Statistics

Topic viewed 3403 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!