How restrict an application to run only from a known USB flash drive?

戏子无情 提交于 2019-12-09 18:42:29

问题


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.


回答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?




回答2:


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();
}


来源:https://stackoverflow.com/questions/1303026/how-restrict-an-application-to-run-only-from-a-known-usb-flash-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!