4

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.

backslash17
  • 5,300
  • 4
  • 31
  • 46
  • Putting a question inside your question: Some anti-cheat like GunBound's know if its files were created by its installer/updater or copied by user. You don't change a single byte in the files, but somehow it senses the difference and say the installation was "compromissed". Howtf is it done? :O – Havenard Aug 19 '09 at 23:00

2 Answers2

1

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.
To protect software by accessing harddisk serial no
Any faster method to get Volume Serial number?

Community
  • 1
  • 1
David
  • 2,164
  • 13
  • 11
  • 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 Aug 19 '09 at 23:20
1

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
  • 286,951
  • 70
  • 623
  • 758
  • 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 Aug 19 '09 at 23:24