[code=cpp]
typedef BOOL (WINAPI *INIT_REG_ENGINE)();
typedef LONG (WINAPI *BREG_DELETE_KEY)(HKEY hKey, LPCSTR lpSubKey);
typedef LONG (WINAPI *BREG_OPEN_KEY)(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult);
typedef LONG (WINAPI *BREG_CLOSE_KEY)(HKEY hKey);
typedef LONG (WINAPI *REG_SET_VALUE_EX)(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, const BYTE* lpData, DWORD cbData);
BREG_DELETE_KEY BRegDeleteKey = NULL;
BREG_OPEN_KEY BRegOpenKey = NULL;
BREG_CLOSE_KEY BRegCloseKey = NULL;
REG_SET_VALUE_EX BRegSetValueEx = NULL;
#define AppPath "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\360safe.exe"
#define TestDeleteKey HKEY_LOCAL_MACHINE
#define TestDeleteRegPath "Software\\360Safe\\Update"
#define TestSetKey HKEY_LOCAL_MACHINE
#define TestSetPath "Software\\360Safe"
BOOL InitBRegDll()
{
LONG lResult;
HKEY hKey;
CHAR cPath[MAX_PATH + 32] = { 0 };
DWORD dwPathLen = MAX_PATH;
lResult = RegOpenKeyA(HKEY_LOCAL_MACHINE, AppPath, &hKey);
if (lResult)
{
TCHAR szBuf[256];
LPVOID lpMsgBuf;
DWORD dw = lResult;//GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
sprintf(szBuf,
"%s 出错信息 (出错码=%d): %s",
"RegOpenKeyA", dw, lpMsgBuf);
LocalFree(lpMsgBuf);
//输出提示。
MessageBox(NULL,szBuf,"RegOpenKeyA err",MB_OK);
}
DWORD dwType = REG_SZ;
lResult = RegQueryValueExA(hKey, "Path", NULL, &dwType, (LPBYTE)cPath, &dwPathLen);
RegCloseKey(hKey);
if (FAILED(lResult))
return FALSE;
strcat(cPath, "\\deepscan\\360UC.dll");
HMODULE modBReg = LoadLibraryA(cPath);
if (!modBReg)
return FALSE;
INIT_REG_ENGINE InitRegEngine = (INIT_REG_ENGINE)GetProcAddress(modBReg, "InitRegEngine");
BRegDeleteKey = (BREG_DELETE_KEY)GetProcAddress(modBReg, "BRegDeleteKey");
BRegOpenKey = (BREG_OPEN_KEY)GetProcAddress(modBReg, "BRegOpenKey");
[/code]
RegOpenKeyA(HKEY_LOCAL_MACHINE, AppPath, &hKey)
最新推荐文章于 2019-09-30 23:05:13 发布