Would it be possible to create a program (.NET preferably) to create a virtual drive letter, but when it is read, written to, or browsed an independent program deals with what is returned?
Although you could do it by mapping a drive to a TCP server, webDAV or something like that, I'm wondering if it could be done with internal links.
This would be used for protected storage. The program does stream encryption and decryption of all the files in the drive (as they're read by all kinds of programs) if the program has had a password put into it.
What you're talking about is a storage device driver, which is how programs such as Daemon Tools and TrueCrypt accomplish such "virtual" drives.
You may not have to delve into the kernel to accomplish this, though. Microsoft supply a Windows User-Mode Driver Framework, which is designed to simplify the development of certain common Windows driver types. From what I can tell, you should be able to develop a virtual storage driver using the user-mode driver framework. As long as you're not directly interacting with hardware (like a kernel-mode device driver does), you should be fine. However, you won't be able to do this in C#. You'd probably have to use C, though you might get away with C++.
PowerShell already supports something like this with its Provider model. Certificate store, Active Directory, IIS configuration, SharePoint, ... are all made to look file system like, using the same commands to query and update.
This is at the heart of PowerShell. $foo is the value of variable foo, ${c:\foo.txt} is the content of file C:\foo.txt but used just like a variable. Equally dir HKLM:\Software lists the child keys of that registry key.
You can write you own providers.
There is an open source program, WinCDEmu that can mount an ISO image to a virtual drive. I suppose you'll be able to examine the sources to figure out how to provide a virtual drive that does what you want. The project is written in C++.
It is based on BazisLib, which is a framework for simplifying windows driver development.
Related
I have a use-case where I need to make a block of storage (think any cloud based storage provider or a Database) available as a Windows drive.
I am happy to do the coding but haven't got a clue where to start.
you have to work with Windows Drivers SDK, there are some samples online about this, something "similar" but not 100% saem as what you need is teh RAM drive implementation whcih creates a new drive which uses RAM memory as storage,
have a look here for some source code you can compile in Visual Studio and to see how you have to setup/prepare your machine for Windows drivers development.
https://github.com/Microsoft/Windows-driver-samples/tree/master/storage/ramdisk
See this question:
creating virtual hard Drive
You would need to create a folder location, probably somewhere in the user's folder tree and map the drive as in the answer in the above link. Then use that folder to sync files with your cloud storage. I doubt you'd want to have the files in memory as you may end up with a drive containing gigabytes of data.
Just wondering if there is any APIs that will let a .NET program write to a partition without entering kernel mode. I am developing an OS and just want to write a quick program on windows so I can add files to a partition shared with VMware. If I had the time I would write actual drivers for it, but I just want something to make something quick. I remember seeing a .NET program for modding Xbox games that could read and write directly to FatX Formatted USB flashdrives.
Try something like "\\?\Device\Harddisk0\Partition1" as path.
The question is similar to How do I read a disk directly with .Net?, except that the drive that requires direct access is a CD-ROM or DVD-ROM drive. These drives are not including as a physical drive and cannot be accessed using the DeviceStream class or CreateFile Win32 API method as cited in the topic above.
The Windows kernel automatically creates the internal device markers for various attached block devices. The first CD-ROM drive appears as \Device\CdRom0, though attempting to open this via CreateFile() will fail (apparently per http://support.microsoft.com/kb/235128).
Considering unmanaged applications can access these block devices natively (any CD-burning software, DD for Windows, Cygwin [via /dev/scdN]), is there a programmatic method available to access these block devices (preferably usable by .NET)?
You may want to look at this article
This is what I used when faced with an issue of making backups to CD's
I want to secure my external hard disk by writing sort of ShellExtension. But Shell extension is Workstation Specific.
Is there a way I can write an application that will show a authentication or an extension encrypt my drive data so user will get a failure message when double click on my drive.
You can't secure an external harddrive by the use of a shell extension, period.
If you want to keep your data safe, there's only one thing you can do: encrypt it. NTFS has built-in encryption, but I wouldn't recommend using that for an external drive, because of the way the encryption keys are handled.
There's a nice pre-cooked solution for you, though: TrueCrypt. It works, is available for multiple operating systems, has decent speed, and good security. Use it.
1) You should not write a shellextension in .net
This causes lots of trouble since then the .net runtime is injected into every application displaying a shell window (like the file open dialog) and if it already uses a different version of the runtime it will likely break.
2) I don't really understand what you are trying to do. But I encrypt my external harddisk with TrueCrypt. That's secure and easy to use.
This is only possible if you change the drive. Otherwise just using on a system without your software would bypass it.
Using NTFS with permissions for the drive's file system would be bypassed by anyone with applicable Window's privileges.
Using an encryption tool may be best: a single public file which contains a complete drive only accessible with the right software and authentication—there are a number around.
I have a requirement to implement a feature (in C#) to lock a folder on a USB drive. After locking, in any PC without my software, this folder is inaccessible (or better invisible). I have tried using ACL (Access Control List) but it does not work on USB.
My original requirement is that "Do not allow people to see the content of a folder on a USB drive without my software. When the user logs into my software, this folder is accessible and when the user logs out, my software has to do something to make sure this folder becomes inaccessible on other PCs". This leads me to think about locking the USB folder.
I already tried a work around to zip the folder (not compress) with a password but zipping takes time (about 2 minutes for 1 Gb). So if I have a large amount of data (100 GB) it takes too long to process (The software has to process this when doing logging out).
For the data to be inaccessible, you would need to create an encrypted container which your program would represent as a virtual folder on existing disk or a virtual disk (drive letter). The first is possible with Pismo File Mount, the second - with our product (Solid File System OS edition). Both approaches require installation of the kernel-mode driver to the system. This is not an application requirement but OS architecture requirement.
From technical point of view our approach is more robust because Pismo File Mount uses a filter driver, while SolFS uses a file system driver and filter drivers are more complicated and more prone to compatibility issues (we have filter-based product as well, so I have experience with both approaches).
(Note: TrueCrypt has nothing to do with C#. So that isn't applicable here.)
Have you had a look at TrueCrypt?
In general you shouldn't try to reinvent the wheel, especially with security requirements. This is a heavy topic and messing around with the file system on your own should be the last option to consider.
TrueCrypt uses two different modes of operation:
File-hosted (container)
Partition/device-hosted
Note: In addition to creating the above types of virtual volumes,
TrueCrypt can encrypt a physical
partition/drive where Windows is
installed (for more information, see
the chapter System Encryption).
A TrueCrypt file-hosted volume is a
normal file, which can reside on any
type of storage device. It contains
(hosts) a completely independent
encrypted virtual disk device.
A TrueCrypt partition is a hard disk
partition encrypted using TrueCrypt.
You can also encrypt entire hard
disks, USB hard disks, USB memory
sticks, and other types of storage
devices.
I have used this software before, which is open source, so you might get something out of it.
http://www.truecrypt.org/
However, I think it works at the partition level rather than the drive level (I think it formats the partition using its own file system).