最近实现驱动预安装的脚本,即在安装软件时候,将驱动文件安装一起安装上,从而达到安装后,插入设备可以直接使用的目的,以下是具体脚本,共享给需要的人参考
注:
1.XP系统下,当插入设备,会提示发现新硬件,只要点击自动搜索,即可
2.Windows 7下直接插入设备即可
1.声明一个prototype
prototype BOOL Setupapi.SetupCopyOEMInfA(POINTER, POINTER, POINTER, POINTER, POINTER, POINTER, POINTER, POINTER);
2.使用SetupCopyOEMInfA实现驱动预安装
SourceUSB2InfFileName = WINDIR^"inf\\Motic Drivers\\USB2 Camera\\MoticUSB2Camera.inf";
UseDLL("Setupapi.dll");
SetupCopyOEMInfA(&SourceUSB2InfFileName, NULL, 1, NULL, NULL, 0, NULL, NULL);
UnUseDLL("Setupapi.dll");
3.遗留问题:会弹出微软认证界面。上网搜索到用VC++写的去除认证的代码,看谁能把它转化成installshield语言
WinXP/2k数字签名状态设置忽略的代码
本文转自 ☆★ 黑白前线 ★☆ - www.hackline.net 转载请注明出处,侵权必究!
原文链接:file:///E:/工作/Study/IS/驱动安装/WinXP-2k数字签名状态设置忽略的代码%20软件逆向%20黑白安全网.mht
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; }
本文转自 ☆★ 黑白前线 ★☆ - www.hackline.net 转载请注明出处,侵权必究!
原文链接:http://www.cnblogs.com/sabrinahuang/admin/file:///E:/工作/Study/IS/驱动安装/WinXP-2k数字签名状态设置忽略的代码%20软件逆向%20黑白安全网.mht
版权声明:转载请注明原始出处。