EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Callback File System as console appication

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
Posted: 07/01/2008 11:49:46
by Eugene Mayevski (Team)

Ok... but can the service itself "see" the drive after the drive was added? You can use GetDriveType() API function for this or you can use FindFirst/FindClose to check.

As for local vs global mounting point, this depends solely on your task and your design decision.

Sincerely yours
Eugene Mayevski
Posted: 07/01/2008 12:46:24
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Yes, the service sees the drive as a DRIVE_REMOVABLE, at least that is the return from GetDeviceType().

I tried the sample code I got from the forum to broadcast the WM_DEVICECHANGE message and I get some sort of unhandled exception in explorer.exe.
Posted: 07/01/2008 14:36:33
by Volodymyr Zinin (Team)

What version of Windows (including also whether it's 32 or 64-bit) and type of the CallbackFS api (.NET, Delphi, C++) are you using?
Also please specify your code chunk that calls AddMountingPointEx. And does AddMountingPointEx finish successfully?
Posted: 07/01/2008 14:55:24
by Volodymyr Zinin (Team)

Sid Schipper wrote:
I still would like to know whether I should add my mounting point as a global or a local mounting point?

It's simpler to use the global mounting points. With them you mustn't worry about logon sessions where mounting points should be created.
Posted: 07/02/2008 11:50:43
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I am using Windows XP Professional SP1 and the C++ Library interface to CBFS.

Below is my code snippet. Please let me know what I am doing wrong. Thank you.

BTW, how do you get your forum system to indent things nicely, tabs do not seem to work? Also in the code snippet below, the value for UseNetworkMountingPoint is FALSE.

typedef long (WINAPI *BroadcastSystemMessageW_Type)( DWORD, LPDWORD, UINT, WPARAM, LPARAM );

long nRetFromfp = 0;

char * sRegKey = DEFAULT_REG_KEY;
bool bNewRegKey = false;




if (UseNetworkMountingPoint)
g_CbFs.AddNetworkMountingPoint(_T("S:"), NULL, false, NULL);
g_CbFs.AddMountingPointEx(_T("S:"), FALSE, NULL);
HMODULE hUser32Dll = LoadLibrary(_T("USER32.DLL"));
WCHAR letter = 'S';
if (hUser32Dll)
BroadcastSystemMessageW_Type fp = (BroadcastSystemMessageW_Type)GetProcAddress(hUser32Dll, "BroadcastSystemMessageW");

if (fp)
DWORD dwRecipients;

dbv.dbcv_size = sizeof(dbv);
dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME;
dbv.dbcv_reserved = 0;
dbv.dbcv_unitmask = (1 << letter);
dbv.dbcv_flags = DBTF_NET;

dwRecipients = BSM_APPLICATIONS;
CString strDriveRootPath(_T("S:\\"));
UINT dType = GetDriveType(strDriveRootPath);

Posted: 07/07/2008 11:19:14
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I am still waiting for a reply to this thread, are you looking at the code I sent you?
Posted: 07/07/2008 12:22:27
by Volodymyr Zinin (Team)

Sorry for the delay. I'll answer you in a short time.
Posted: 07/07/2008 15:21:57
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I just tried an experiment that gave me some curious results that I'd like to tell you about. I ran my VDisk application as a service, but I put in a call to the Windows API function GetLogicalDriveStrings directly after I use your AddMountingPointEX to add the S: drive to the global namespace. I attached to the service process using the Visual C++ debugger and after the call to GetLogicalDriveStrings the S: drive was returned to me as a logical drive.

I then started up another debugging session with a program that I wrote that does only the call to GetLogicalDriveStrings. In that program, the S: drive also is returned to me as a logical drive. But, when I start up an explorer window from the same user where I am running the program that just does the GetLogicalDriveStrings, the drive does not show up?

I then do the Broadcast that you suggested, of the DeviceChanged message and the drive still does not show up in Windows explorer, but does appear in the return from GetLogicalDriveStrings. This seems very curious to me and I am at a loss to explain it. Maybe you can help me?
Posted: 07/07/2008 15:27:53
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

As a follow-up to my last post, another interesting thing is under the scenario I described above, if I open a cmd DOS command line console window I am able to navigate to my S: drive and use it as I would expect. So, it seems that the only problem I have is that Windows Explorer cannot see my S: drive for some unexplained reason.
Posted: 07/08/2008 11:30:56
by Volodymyr Zinin (Team)

I've created a nt-service from the Mapper sample and it works well. The sources of it is attached to this message. For writing the service I used the NTService sample described here: http://msdn.microsoft.com/en-us/library/ms810429.aspx
Before starting the service the driver and VSMntNtf.dll helper dll must be installed. The service is installed by specifying the key -i in its command line. After that it can be started/stopped from the "Services" applet in "Administrative tools".

Sid Schipper wrote:
Below is my code snippet. Please let me know what I am doing wrong. Thank you.
The BroadcastSystemMessage call won't work if the code is called from the system account (i.e. in context of a nt-service). You must call this function from an user session whose Explorer must be notified.

[ Download ]
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages



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