EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Sample program "VDisk" and UNC paths

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#18420
Posted: 12/09/2011 20:02:48
by Dave Foster (Basic support level)
Joined: 12/09/2011
Posts: 7

Is it possible to use an UNC path instead of a drive letter when mounting the virtual filesystem in the sample program "VDisk". I am evaluating the software and thought I'd try to see how effective the forum is.

Thanks.
#18421
Posted: 12/09/2011 23:39:28
by Eugene Mayevski (EldoS Corp.)

As it's a sample which comes with full source code, you can modify it to do what you need. As you have not specified what API (.NET, VCL, C++) you are using, I can't tell you where exactly to change.


Sincerely yours
Eugene Mayevski
#18431
Posted: 12/11/2011 20:27:54
by Dave Foster (Basic support level)
Joined: 12/09/2011
Posts: 7

Hi Eugene.

Thanks for getting back so quickly. We are evaluating the C++ examples. I had hoped that the box for entering the drive letter could be used for a UNC path as well. Is it possible to modify the source code easily to try this?
#18434
Posted: 12/11/2011 22:50:56
by Eugene Mayevski (EldoS Corp.)

Quote
Dave Foster wrote:
I had hoped that the box for entering the drive letter could be used for a UNC path as well. Is it possible to modify the source code easily to try this?


It's always worth trying: from the sample code as I have checked it now it should work without modifications.


Sincerely yours
Eugene Mayevski
#18457
Posted: 12/12/2011 12:41:55
by Dave Foster (Basic support level)
Joined: 12/09/2011
Posts: 7

What would be the "exact" syntax and order of entry of the UNC path, with the sample application? I have tried "\\test\a" and it didn't work.
#18458
Posted: 12/12/2011 13:13:48
by Eugene Mayevski (EldoS Corp.)

"Name" (without quotes). Then the UNC path can be accessed in various applications as "\\.\Name"

Note that UNC Path here is just a notation - using UNC path doesn't magically share the disk across network. You indeed can create a disk and share it, but syntax will be more complex. See the help file topic regarding mounting points. This topic contains samples and detailed instructions.


Sincerely yours
Eugene Mayevski
#18460
Posted: 12/12/2011 16:29:01
by Dave Foster (Basic support level)
Joined: 12/09/2011
Posts: 7

OK, it does appear to work (no errors, now). However, while I expect that the UNC path "\\test" is not shared across my network, I believe that I'm supposed to be able to find the mounted path in a standard CFileDialog based user interface, when I "Look in" Network. Am I incorrect about this? Otherwise, how could I test that the UNC path is mounting correctly through a standard CFileDialog user interface to open or save a file? Thanks some more.
#18461
Posted: 12/13/2011 00:12:58
by Eugene Mayevski (EldoS Corp.)

It's not "\\test" but "\\.\test".

The whole point of UNC paths is that such path is not visible to user. You can type it by hand in the open dialog but you need to know it. Eg. for test, the file path would be "\\.\test\directory\filename.ext" .


Sincerely yours
Eugene Mayevski
#18469
Posted: 12/13/2011 12:54:25
by Dave Foster (Basic support level)
Joined: 12/09/2011
Posts: 7

It sounds really good. But, it doesn't work. I'm running Windows 7, and am using Visual Studio 2010. I have a breakpoint set in the project VDisk, at the routine OnCallbackAddPoint(), just after the CreateFile() call. If I "Create Storage", followed by "Mount", and then type the mount point name "X:", and then press "Add", the hFile returned is a valid file handle, and the file system with the directory "Sample" and the file "Sample\\testfile_1.txt" are created properly. Going in the order "Create Storage", followed by "Add" of the mount point "X:", followed by pressing "Mount", while seeming intuitive to me, does not create the directory, nor the file, but that is another matter).

However, when I "Create Storage", followed by "Mount", type the mount point name "test", and then "Add" it, the hFile in the routine OnCallbackAddPoint() is invalid, and so no wonder I cannot see the device, even with the path "\\.\test". Am I looking at the same evaluation kit as you?

Thanks
#18470
Posted: 12/13/2011 13:26:53
by Volodymyr Zinin (EldoS Corp.)

Try to use the "network" type of mounting point. It's necessary to modify the OnCallbackAddPoint function in the following way. So you will be able to access the storage by the use of the "\\server\share" UNC path.
Code
void OnCallbackAddPoint(void)
{
    TCHAR MountingPoint[_MAX_PATH];
    TCHAR head[] = _T("This is \r\nthe header for the file.\r\n ------------------------------\r\n");
    
    if(NULL == g_DiskContext) {
        
        g_DiskContext = new VirtualFile(_T("\\"));
    }
    
    GetWindowText(g_hEdit, MountingPoint, _MAX_PATH);
    
    try
    {
        //g_CbFs.AddMountingPoint(L"W:;server;share", CBFS_SYMLINK_NETWORK | CBFS_SYMLINK_NETWORK_ALLOW_MAP_AS_DRIVE, NULL);
        g_CbFs.AddMountingPoint(L";server;share", CBFS_SYMLINK_NETWORK | CBFS_SYMLINK_NETWORK_ALLOW_MAP_AS_DRIVE, NULL);
        
        //_tcscat(MountingPoint, _T("\\Sample\\"));
        wcscpy(MountingPoint, L"\\\\server\\share\\Sample");
        CreateDirectory(MountingPoint, NULL);
        
        //GetWindowText(g_hEdit, MountingPoint, _MAX_PATH);
        //_tcscat(MountingPoint, _T("\\Sample\\testfile_1.txt"));
        wcscpy(MountingPoint, L"\\\\server\\share\\Sample\\testfile_1.txt");

        HANDLE hFile = CreateFile(
            MountingPoint,
            GENERIC_READ | GENERIC_WRITE,
            FILE_SHARE_READ | FILE_SHARE_WRITE,
            NULL,
            OPEN_ALWAYS,
            FILE_ATTRIBUTE_ARCHIVE | FILE_FLAG_WRITE_THROUGH,
            0);
        
        DWORD Written = 0;
        
        if(hFile != INVALID_HANDLE_VALUE)
        {
            if(!WriteFile(hFile, head, _tcslen(head)* sizeof(TCHAR)+ sizeof(TCHAR), &Written, NULL))
            {
                ECBFSError e(GetLastError());
                MessageBox(g_hMainWnd, e.Message(), _T("Mounter"), MB_OK | MB_ICONERROR);
            }

            CloseHandle(hFile);
        }
        UpdateMountingPoints();

        EnableWindow(g_hDeletePoint, TRUE);
    }
    catch (ECBFSError err)
    {
        MessageBox(g_hMainWnd, err.Message(), _T("Mounter"), MB_OK | MB_ICONERROR);
    }
}
Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.

Reply

Statistics

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