EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How do I disconnect a mount network drive from Windows Explorer?

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
Posted: 03/12/2013 03:43:29
by Dmitry Novikov (Standard support level)
Joined: 03/11/2013
Posts: 6


I'm having similar problem:
I mount network drive and map it on Z: (Win7 32bit, C++, cbfs3.sys:
m_cbfs.AddMountingPoint(L"Z:;MyServer;MyShare", CBFS_SYMLINK_NETWORK|

Then I can't unmount Z: from Explorer (RCLICK drive->"Disconnect"). (That's the problem I need help with)

It says (message box appears): "The system cannot find the file specified"

Using process viewer I noticed that Explorer tries to open file "\\MyServer\pipe" (it may give you an idea):

"Explorer.EXE", "CreateFile","\\MyServer\pipe\","BAD NETWORK PATH","Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a"
"Explorer.EXE", "CreateFile","\\MyServer\MyShare\","SUCCESS","Desired Access: Generic Execute, Disposition: Open, Options: No Buffering, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
"Explorer.EXE","DeviceIoControl","\\MyServer\MyShare\","SUCCESS","Control: 0x242048 (Device:0x24 Function:2066 Method: 0)"
"Explorer.EXE","DeviceIoControl","\\MyServer\MyShare\","SUCCESS","Control: 0x242044 (Device:0x24 Function:2065 Method: 0)"

Other calls accessing drive Z: from Explorer.EXE and CBFS-callbacks coming during my try to unmount the drive from Explorer seem not suspicious...

I've tried to workaround it by passing empty 'Local Mounting Point' part of the 1st parameter to AddMountingPoint(). So then I was able manually from explorer to "Map network drive..." Z: on \\MyServer\MyShare and then "Disconnect" Z:.
But now I failed to map network drive programmatically via system call WNetAddConnection2. It returns no errors. If I try to call it again with the same parameters it returns 0x00000055:"The local device name is already in use." But drive does not appear in Explorer.

I need the way to unmap CBFS disks from Explorer. Thanks for any help in solving it!
Posted: 03/12/2013 04:37:16
by Volodymyr Zinin (Team)

Hello Dmitry,

Dmitry Novikov wrote:

There is already 4.0 version. Please try the problem with it (with the Mapper sample). Or at least do the same with the latest 3.2 build.
Posted: 05/23/2013 20:52:09
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

I get the same error message as Dimitry. I use Win7 64Bit, C#, CBFS4Net.
Posted: 05/24/2013 00:58:23
by Eugene Mayevski (Team)

Carsten, please be more descriptive and provide exact details on how the disk is created and mounted (what the settings of StorageType and StorageCharacteristics are, what is passed to the call to AddMountingPoint). Without this information we can't reproduce the issue.

Sincerely yours
Eugene Mayevski
Posted: 05/26/2013 18:47:35
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

Code is:

       public MyCBFS(string profileName)
            mCbFs                             = new CallbackFileSystem();
            mCbFs.OnMount                     = new CbFsMountEvent(CbFsMount);
            mCbFs.OnUnmount                   = new CbFsUnmountEvent(CbFsUnmount);
            mCbFs.OnWriteFile                 = new CbFsWriteFileEvent(CbFsWriteFile);
            mCbFs.OnIsDirectoryEmpty          = new CbFsIsDirectoryEmptyEvent(CbFsIsDirectoryEmpty);

            mCbFs.AddMountingPoint("K:;MyApp;" + profileName,
                CallbackFileSystem.CBFS_SYMLINK_NETWORK | CallbackFileSystem.CBFS_SYMLINK_NETWORK_ALLOW_MAP_AS_DRIVE, null);
Posted: 05/27/2013 04:39:15
by Volodymyr Zinin (Team)

The problem is that the "global" mounting point is used in your case. I.e. that one which is created without the CBFS_SYMLINK_LOCAL flag. In this case it's visible in all logon session. In order to protect deletion of a global mounting point by any currently logged on users we blocked possibility to delete it via the explorer menu.
In order to workaround the problem use the "local" mounting points. Actually the system network mounting points are always local.
As a variant in future CallbackFS versions we will add an additional flag for the AddMountingPoint API which will allow such behavior.
Posted: 05/27/2013 21:16:59
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

thanks, this did the trick!

How does my application get notified when this happens? It seems that neither the "OnUnmount" nor the "OnStorageEjected" event get triggered when the network drive is disconnected.
Posted: 05/27/2013 23:36:04
by Eugene Mayevski (Team)

Well, the functionality to create a share is a supplementary one, added for convenience. Our code just calls NetShareAdd function from WniAPI. The rest is up to you.

Sincerely yours
Eugene Mayevski
Posted: 05/28/2013 01:44:25
by Volodymyr Zinin (Team)

Carsten Friedrich wrote:
How does my application get notified when this happens? It seems that neither the "OnUnmount" nor the "OnStorageEjected" event get triggered when the network drive is disconnected.

"Disconnection" means that only the mounting point (i.e. drive letter) is removed. You can block the possibility of such mounting point deletion by not specifying the flag CBFS_SYMLINK_NETWORK_ALLOW_MAP_AS_DRIVE.
Posted: 05/28/2013 01:54:12
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

Thanks, for the reply. I don't necessarily want to prevent disconnecting. Actually, it can be quite helpful for me: If I find out about it I can use it to trigger some cleaning up. I'll have a look at the WIndows API if anything there can help me detect a disconnect from the user.
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.



Topic viewed 9293 times

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


Back to top

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

Got it!