public uint SFNTGetDeviceInfo(SentinelKey.DeviceInfo deviceInfo) { uint status = 0; try { status = SentinelKeyNativeAPI.SFNTGetDeviceInfo(this.licHandle, deviceInfo.bInfoBuffer); } catch (System.DllNotFoundException) { throw new System.DllNotFoundException(strError); } catch { // Anything else } return(status); }
public uint GetLicense(uint devID, uint offset, uint length) { uint result = SFNTGetLicense(devID, SentinelKeysLicense.SOFTWARE_KEY, SentinelKeysLicense.LICENSEID, 0x20); if (result != 0) { return(result); } byte[] rawDataSys = new byte[length]; result = SFNTReadRawData(SentinelKeysLicense.SP_SYSTEM_RAWDATA, rawDataSys, offset, length); if (result != 0) { return(result); } string strSystemData = System.Text.Encoding.UTF8.GetString(rawDataSys); if (strSystemData == null) { return(1); } int dogStatus = 0; string strOrderNo = strSystemData.Substring(24, 10).Trim('\0'); string strSerialNo = strSystemData.Substring(14, 10).Trim('\0'); string strInfoInKey = ""; foreach (char c in strOrderNo) { int temp = (int)(c ^ 'T'); strInfoInKey += temp.ToString(); } foreach (char c in strSerialNo) { int temp = (int)(c ^ 'T'); strInfoInKey += temp.ToString(); } RegistryKey hklm = Registry.LocalMachine; RegistryKey software = hklm.OpenSubKey("SOFTWARE"); RegistryKey HaoYiSheng = software.OpenSubKey("HaoYiSheng"); if (HaoYiSheng != null) { RegistryKey hys = HaoYiSheng.OpenSubKey("HYS"); if (hys != null) { SentinelKey.DeviceInfo keyInfo = new SentinelKey.DeviceInfo(); uint resultNum = SFNTGetDeviceInfo(keyInfo); if (resultNum != 0) { dogStatus = 1; } else { strSerialNo = keyInfo.DevSN.ToString("X"); string strInfoInReg = Convert.ToString(hys.GetValue(strSerialNo)); if (strInfoInReg == null || strInfoInReg == "") { dogStatus = 1; } else { if (strInfoInReg == strInfoInKey) { dogStatus = 0; } else { dogStatus = 1; } } } } else { dogStatus = 1; } } else { dogStatus = 1; } if (dogStatus != 0) { return(NotActive); } return(0); }