各位大牛:
小弟最近用MFC写了个程序,里面用了驱动。驱动的加载时在OnInitDialog()完成的,使用的是如下的加载方式:(copy的别人的程序
)
bool MyZwLoadDriver(char * szDrvName, char * szDrvPath)
{
HMODULE hNtdll = NULL;
hNtdll = LoadLibrary( "ntdll.dll" );
RtlAnsiStringToUnicodeString = (RTLANSISTRINGTOUNICODESTRING)GetProcAddress( hNtdll, "RtlAnsiStringToUnicodeString");
RtlFreeUnicodeString = (RTLFREEUNICODESTRING)GetProcAddress( hNtdll, "RtlFreeUnicodeString");
ZwLoadDriver = (ZWLOADDRIVER)
GetProcAddress( hNtdll, "ZwLoadDriver");
ZwUnloadDriver = (ZWLOADDRIVER)
GetProcAddress( hNtdll, "ZwUnloadDriver");
//注册驱动程序
if(LoadDriver(szDrvName, szDrvPath) == false)
return false;
return true;
}
卸载时在一个退出的函数里面实现的,类似OnButtonClose()的函数,卸载函数如下(同样是copy的)
bool MyZwUnloadDriver(char * szDrvName, char * szDrvPath)
{
HMODULE hNtdll = NULL;
hNtdll = LoadLibrary( "ntdll.dll" );
RtlAnsiStringToUnicodeString = (RTLANSISTRINGTOUNICODESTRING)GetProcAddress( hNtdll, "RtlAnsiStringToUnicodeString");
RtlFreeUnicodeString = (RTLFREEUNICODESTRING)GetProcAddress( hNtdll, "RtlFreeUnicodeString");
ZwUnloadDriver = (ZWLOADDRIVER)GetProcAddress( hNtdll, "ZwUnloadDriver");
if(UnloadDriver(szDrvName, szDrvPath) == false)
return false;
return true;
}
但是应用程序一关闭,电脑就死机了,不知道为啥? 忘各位高手不吝赐教~~~~
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)