首页
社区
课程
招聘
[求助]为什么一个驱动里面使用两种通信方式会蓝屏
发表于: 2011-12-13 18:58 3004

[求助]为什么一个驱动里面使用两种通信方式会蓝屏

2011-12-13 18:58
3004
一下为我的派遣函数

case add_code: 部分使用的是缓冲方式通信

case sub_code: 使用的是直接方式通信

注释掉其中的一个,就能正常运行不蓝屏

如果两个都存在,运行exe进行输入的时候果断就会蓝屏

为什么会这样?

这两种方式又不会同时运行

是swtich 分支的啊?
附件里面是驱动跟exe的源码
大家帮忙看下

#pragma PAGECODE
NTSTATUS MyDDKDispatchControl (PDEVICE_OBJECT pDEVObj, PIRP pIrp)
{
ULONG info,cbin,cbout,code;
int a,b,c;
int* InputBuffer;
int* OutputBuffer;
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(pIrp);

KdPrint(("MY Control Dispatch !!!\n"));
//得到输入缓冲区大小
//cbin = stack->Parameters.DeviceIoControl.InputBufferLength;
//得到输出缓冲区大小
//cbout = stack->Parameters.DeviceIoControl.OutputBufferLength;
//得到IOCTL码
code = stack->Parameters.DeviceIoControl.IoControlCode;
switch(code)
{
case add_code:
{
/*
         KdPrint(("add_code start\n"));
//获取缓冲区数据 a,b
InputBuffer = (int*)pIrp->AssociatedIrp.SystemBuffer;
__asm
{
mov eax,InputBuffer
mov ebx,[eax]
mov a,ebx
mov ebx,[eax+4]
mov b,ebx
}
KdPrint(("a=%d\nb=%d\n",a,b));
c=a+b;
//驱动层返回数据至用户层
//操作输出缓冲区
OutputBuffer = (int*)pIrp->AssociatedIrp.SystemBuffer;
__asm
{
mov eax,c
mov ebx,OutputBuffer
mov[ebx],eax
}
KdPrint(("a+b=%d\n",c));
//设置实际操作输出缓冲区长度
info = 4;
*/
break;
}
case sub_code:
{
KdPrint(("sub_code start\n"));
//获取输入缓冲区数据 a,b
InputBuffer = (int*)pIrp->AssociatedIrp.SystemBuffer;
__asm
{
mov eax,InputBuffer
mov ebx,[eax]
mov a,ebx
mov ebx,[eax+4]
mov b,ebx
}
KdPrint(("a=%d\nb=%d\n",a,b));
c=a-b;
//驱动层返回数据至用户层
//操作输出缓冲区
OutputBuffer = (int*)MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,
NormalPagePriority);
KdPrint(("MmGetSystemAddressForMdlSafe=%x",OutputBuffer));
__asm
{
mov eax,c
mov ebx,OutputBuffer
mov[ebx],eax
}
KdPrint(("a-b=%d\n",c));
//设置实际操作输出缓冲区长度
info = 4;
break;
}
default:
break;
}
pIrp->IoStatus.Information = info;//设置操作的字节数
pIrp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(pIrp,IO_NO_INCREMENT);
KdPrint(("Leave My _Dispatch Successful!!!\n"));
return STATUS_SUCCESS;

}

[课程]FART 脱壳王!加量不加价!FART作者讲授!

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