-4

is there a way to "inject" a drive into explorer? What I want to achieve: When opening the explorer there should be a drive that looks like a normal partition of a HDD or a network drive (only difference: without capacity information (if possible), and with a different icon). It doesn't require any IO logic behind, the only thing I need is to take action when it's clicked. When it's clicked a popup to insert a password should appear and if the password is correct I want to remove the fake drive, mount a network drive and open the root directory of the network drive (basically the user doesn't even notice it was a fake drive as it looks like he unlocked the network drive and it opens)

regards, Hidden

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Hidden
  • 19
  • 1
  • 4
  • why should somebody need something like this? - It sounds more like a really worst bug, than an application... – Smartis has left SO again Jun 24 '13 at 13:53
  • 1
    @Smartis Or some kind of virus to steal password user uses the most. – Leri Jun 24 '13 at 13:56
  • Don't worry, it's not a virus (who the hell would write a virus in C#?). It's some kind of security improvement I don't want to explain right now (I don't want anyone to copy my idea before I'm able to release my application). This feature also isn't a bug, it makes the usage of my application a little easier for unexperienced users. – Hidden Jun 24 '13 at 16:08

2 Answers2

3

For those who don't have any bad intentions and to answer the main Question:

Yes, there is a way to "Inject" a virtual Drive by using the Win32 API:

    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
    private static extern bool DefineDosDevice(
        int dwFlags,
        string lpDeviceName,
        string lpTargetPath);
  • Ok, that's basically what I was looking for, thanks. Is there a way to Name the virtual drive? It copies the name of the root drive for the path I defined and SetVolumeLabel and DeviceInfo.VolumeLabel both fail. – Hidden Jun 24 '13 at 16:04
1

The better option is to create a virtual drive, ready to present information but only after its root directory is opened and the password is entered. On Windows, this is doable using for example our CBFS Connect product, on Linux and macOS this is done using FUSE and "Fuse for macOS" respectively. That is if you can expose the filesystem data using code.

If you want to mount a network drive (via SMB / Windows networking) in place of the virtual drive that you have created, this is trickier - you can mount the network disk proactively but use the filesystem filter driver to block access to the network disk until access is made (e.g. by Explorer) and the password is entered. This is doable using our other product, CBFS Filter.

Particular implementations of both approaches are rather sophisticated to be illustrated using the simple code snippet.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121