views:

539

answers:

2

I need an application to run only from a specific USB flash drive. I made some test with the WMI Win32_Diskdrive class and the PNPdeviceID property. It is a very good idea to enroll the application into a license server (web services) with this data, but I'm searching for a second method to reenforce this one in order to make the process harder to break.

I was thinking to create a second little hidden partition in the drive and locate in it as a name the serial obteined by the PNPdeviceID or other information. Any other idea, method or suggestion is accepted.

Thanks in advance.

EDIT: I already know a unique ID from the USB flash drive and the application can check if the Interfacetype property is "USB". I´m enrolling the application with a hash of the PNPDeviceID in a web-services suported licence manager. I'm searching for an additional second validation method.

+2  A: 

You can check the volume serial number, which will catch casual copying to a newly formatted volume, but it won't detect full byte-exact volume copies.
http://stackoverflow.com/questions/319508/to-protect-software-by-accessing-harddisk-serial-no
http://stackoverflow.com/questions/1142579/any-faster-method-to-get-volumne-serial-number

David
I'm usign the WMI property PNPDeviceID from the Win32_drive class and it is different in any USB flash drive, it persist even if you format the drive.
backslash17
+2  A: 

You can check the type of drive from which the program is running :

string path = Process.GetCurrentProcess().MainModule.FileName;
FileInfo fileInfo = new FileInfo(path);
string driveRoot = fileInfo.Directory.Root.Name;
DriveInfo driveInfo = new DriveInfo(driveRoot);
if (driveInfo.DriveType != DriveType.Removable)
{
    MessageBox.Show("Must run from removable drive");
    Application.Exit();
}
Thomas Levesque
I already know if the drive is Removable using the WMI Win32_Drive class. The property InterfaceType returns "USB". And what about if the application is copied into another removable media?
backslash17