DWORD WINAPI SetDriverSign()
{
HKEY hReg;
DWORD dwLen;
DWORD dwSeed;
DWORD hProv;
DWORD hHash;
DWORD dwData;
BYTE bHash[16];
if(RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SYSTEM//WPA//PnP",0,KEY_READ,&hReg) == ERROR_SUCCESS)
{
dwLen = 4;
RegQueryValueExA(hReg,"seed",0,0,(LPBYTE)&dwSeed,&dwLen);
RegCloseKey(hReg);
CryptAcquireContext(&hProv,0,0,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT);
CryptCreateHash(hProv,0x8003,0,0,&hHash);
dwData = 0;
CryptHashData(hHash,(BYTE *)&dwData,4,0);
CryptHashData(hHash,(BYTE *)&dwSeed,4,0);
dwLen = 16;
CryptGetHashParam(hHash,HP_HASHVAL,&bHash[0],&dwLen,0);
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
// HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Setup PrivateHash BIN MD5
// HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Driver Signing Policy BIN 0
// HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Non-Driver Signing Policy BIN 0
// HKEY_CURRENT_USER/Software/Microsoft/Driver Signing Policy DWORD 0
lpParameter = 0;
RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Driver Signing",0,KEY_WRITE,&hReg);
RegSetValueExA(hReg,"Policy",0,REG_BINARY,(BYTE *)&dwData,1);
RegCloseKey(hReg);
RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Non-Driver Signing",0,KEY_WRITE,&hReg);
RegSetValueExA(hReg,"Policy",0,REG_BINARY,(BYTE *)&dwData,1);
RegCloseKey(hReg);
RegOpenKeyExA(HKEY_CURRENT_USER,"SOFTWARE//Microsoft//Driver Signing",0,KEY_WRITE,&hReg);
RegSetValueExA(hReg,"Policy",0,REG_BINARY,(BYTE *)&dwData,1);
RegCloseKey(hReg);
RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Windows//CurrentVersion//Setup",0,KEY_WRITE,&hReg);
RegSetValueExA(hReg,"PrivateHash",0,REG_BINARY,&bHash[0],16);
RegCloseKey(hReg);
}
return 0;
}
出处"http://www.osdiy.com",
驱动数字签名选项设置
最新推荐文章于 2022-12-29 22:41:47 发布