Search code examples
c#code-injectionexplorervirtual-drive

C# "Inject" drive to Windows explorer


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


Solution

  • 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);