EldoS | Feel safer!

Software components for data protection, secure storage and transfer

CBFS callbacks are not called (WPF App)

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#31587
Posted: 12/05/2014 05:48:45
by Alex Netkachov (Basic support level)
Joined: 12/05/2014
Posts: 1

I'm trying to incorporate CBFS into the small WPF app as follows:

Code
    using System.Threading;
    using System.Windows;
    using CallbackFS;

    namespace WPFTest
    {
        /// <summary>
        /// Interaction logic for App.xaml
        /// </summary>
        public partial class App
        {
            private CallbackFileSystem _cbfs;

            protected override void OnStartup(StartupEventArgs e)
            {
                base.OnStartup(e);

                var thread = new Thread(() =>
                {
                    CallbackFileSystem.SetRegistrationKey("*****************************************" +
                        "***************************************************************************" +
                        "***************************************************************************" +
                        "*****************");

                    var installed = false;
                    var initialized = false;

                    try
                    {
                        CallbackFileSystem.Initialize("CBFSTest");
                        initialized = true;
                    }
                    catch
                    {
                        var isRebootRequired = 0u;

                        try
                        {
                            CallbackFileSystem.Install(@"c:\Projects\CBFSTests\CBFS\Drivers\cbfs.cab",
                                "CBFSTest", string.Empty, true,
                                CallbackFileSystem.CBFS_MODULE_NET_REDIRECTOR_DLL |
                                CallbackFileSystem.CBFS_MODULE_MOUNT_NOTIFIER_DLL,
                                ref isRebootRequired);

                            installed = true;

                            if (isRebootRequired != 0)
                            {
                                MessageBox.Show("Driver is installed, reboot is required.", "CBFS");
                            }
                        }
                        catch
                        {
                            // do nothing
                        }
                    }

                    if (!initialized && !installed)
                    {
                        MessageBox.Show("Driver is not installed. Cannot proceed.", "CBFS");
                        return;
                    }

                    if (installed && !initialized)
                    {
                        CallbackFileSystem.Initialize("CBFSTest");
                    }

                    _cbfs = new CallbackFileSystem();

                    _cbfs.OnMount += delegate
                    {
                        LogService.Instance.Add("OnMount");
                    };

                    _cbfs.CreateStorage();
                    _cbfs.MountMedia(10000);
                    _cbfs.AddMountingPoint("P:");
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }

            protected override void OnExit(ExitEventArgs e)
            {
                try
                {
                    _cbfs.UnmountMedia(true);
                    _cbfs.DeleteStorage(true);
                }
                catch
                {
                    // do nothing
                }

                base.OnExit(e);
            }
        }
    }


It installs driver well (as I see). The LogService is just a container for ObservableCollection<string>.

The problem is that the OnMount callback is never called (VS does not stop at the breakpoint, no message in the collection).
#31588
Posted: 12/05/2014 05:54:51
by Eugene Mayevski (EldoS Corp.)

1) You must implement *all* mandatory callbacks for CBFS to work. Mandatory callbacks are all callbacks except On*Security and OnMount/OnUnmount.

2) Please start with the sample (Mapper sample preferred) and see if it works. This check will ensure that the driver is installed and loaded by the OS correctly. Then use Mapper sample as a guide.


Sincerely yours
Eugene Mayevski

Reply

Statistics

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