阅读:1358回复:1
求各位帮帮忙,执行类似(*targetObj)=NULL赋值语句的时候总是蓝屏
以下是出问题的函数,请各位不吝赐教,谢谢
//找到一个串口设备,并返回指针 NTSTATUS ccpGetDevicePointer (IN ULONG comId,OUT PDEVICE_OBJECT *targetObj) { NTSTATUS status; UNICODE_STRING name_str; static WCHAR name[32]={0}; PFILE_OBJECT fileObj=NULL; PDEVICE_OBJECT to=NULL; (*targetObj)=NULL; //////////<------------------------------------------就是对targetObj进行这样赋值的时候总是蓝屏 memset(name,0,sizeof(WCHAR)*32); RtlStringCchPrintfW(name,32,L"\\Device\\Serial%d",comId); RtlInitUnicodeString(&name_str,name); status = IoGetDeviceObjectPointer(&name_str,FILE_ALL_ACCESS,&fileObj,&to); if (status == STATUS_SUCCESS) ObDereferenceObject(fileObj); (*targetObj)=to; ////////////<------------------------------------------此句也会蓝屏,可就是看不出这样用的问题呢 return status; } //将过滤设备绑定到串口上 VOID ccpAttachToCom(ULONG i,PDRIVER_OBJECT driver,OUT PDEVICE_OBJECT *fltObj,OUT PDEVICE_OBJECT *finObj) { NTSTATUS status,createStatus,getStatus; PDEVICE_OBJECT *targetObj; PDEVICE_OBJECT topDevice; (*fltObj)=NULL; (*finObj)=NULL; targetObj=NULL; getStatus=ccpGetDevicePointer(i,targetObj); ////////<----------------------这句话调用了出问题的函数 if (getStatus != STATUS_SUCCESS) return ; #if DBG _asm int 3 #endif createStatus=ccpCreateDevice (driver,(*targetObj),fltObj); topDevice=IoAttachDeviceToDeviceStack(*fltObj,*targetObj); if (topDevice == NULL) { IoDeleteDevice(*fltObj); (*fltObj)=NULL; return ; } *finObj=topDevice; } |
|
沙发#
发布于:2012-03-16 16:30
是不是应该这样? 只懂c,不懂驱动开发的
getStatus=ccpGetDevicePointer(i, &targetObj); NTSTATUS ccpGetDevicePointer (IN ULONG comId,OUT PDEVICE_OBJECT **targetObj) |
|