首页
社区
课程
招聘
[旧帖] [求助]奇怪的问题,这键位映射驱动驱动在win7上卸载会蓝屏? 0.00雪花
发表于: 2010-3-3 22:06 1186

[旧帖] [求助]奇怪的问题,这键位映射驱动驱动在win7上卸载会蓝屏? 0.00雪花

2010-3-3 22:06
1186
下面这么一段卸载代码,是根据那个很有名ctrl2cap键盘驱动改来的
在xp上一点问题都没有,但在win7下会蓝屏
而且蓝屏的位置不在我写的代码里面,也就是说它在unload的最后输出了
KdPrint(("DriverEntry unLoad OK!\n"));
之后才蓝掉的- -这是怎么回事呢?
大家能给些建议吗>< 谢谢~

ps: 蓝屏代码 0x00000018

ps1:我只有宿主win7+虚拟机的xp...没办法对win7开windbg..

VOID 
detach(IN PDEVICE_OBJECT pDeviceObject) 
{ 
	//UNICODE_STRING filterSymbolicLink;
	PC2P_DEV_EXT devExt; 
	NTSTATUS status;
	BOOLEAN NoRequestsOutstanding = FALSE; 
	devExt = (PC2P_DEV_EXT)pDeviceObject->DeviceExtension; 
	__try 
	{ 
		__try 
		{ 
			IoDetachDevice(devExt->TargetDeviceObject);
			devExt->TargetDeviceObject = NULL; 
			

			//RtlInitUnicodeString(&filterSymbolicLink,);
			status = IoDeleteSymbolicLink(&devExt->FilterSymbolicLink);
			
			IoDeleteDevice(pDeviceObject); 
			devExt->pFilterDeviceObject = NULL; 
			
			KdPrint(("Detach Finished\n")); 
		} 
		__except (EXCEPTION_EXECUTE_HANDLER){} 
	} 
	__finally{} 
	return; 
}



VOID 
unload(IN PDRIVER_OBJECT DriverObject) 
{ 
    PDEVICE_OBJECT DeviceObject; 
    PDEVICE_OBJECT OldDeviceObject; 
    PC2P_DEV_EXT devExt; 

    LARGE_INTEGER	lDelay;
    PRKTHREAD CurrentThread;

	//__asm int 3;
	isEnabled=0;

    //delay some time 
    lDelay = RtlConvertLongToLargeInteger(100 * DELAY_ONE_MILLISECOND);
    CurrentThread = KeGetCurrentThread();
    // 把当前线程设置为低实时模式,以便让它的运行尽量少影响其他程序。
    KeSetPriorityThread(CurrentThread, LOW_REALTIME_PRIORITY);

    UNREFERENCED_PARAMETER(DriverObject); 
    KdPrint(("DriverEntry unLoading...\n")); 

    // 遍历所有设备并一律解除绑定
    DeviceObject = DriverObject->DeviceObject;
    while (DeviceObject)
    {
        // 解除绑定并删除所有的设备
        detach(DeviceObject);
        DeviceObject = DeviceObject->NextDevice;
    } 
    ASSERT(NULL == DriverObject->DeviceObject);

    while (gC2pKeyCount)
    {
	  KeDelayExecutionThread(KernelMode, FALSE, &lDelay);
    }		

	
	KdPrint(("DriverEntry unLoad OK!\n")); 
	//lDelay = RtlConvertLongToLargeInteger(50000 * DELAY_ONE_MILLISECOND);
	//KeDelayExecutionThread(KernelMode, FALSE, &lDelay);
    return; 
} 



[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//