shar123
驱动牛犊
驱动牛犊
  • 注册日期2009-05-12
  • 最后登录2009-10-09
  • 粉丝0
  • 关注0
  • 积分59分
  • 威望461点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1143回复:1

硬盘绑定问题

楼主#
更多 发布于:2009-05-21 14:08
我使用下面这段代码 将我创建的一个新的设备(MyDevice)绑定到XP的C盘上去  
BOOLEAN AttachToDiskDevice(IN PDEVICE_OBJECT MyDevice)
{
  NTSTATUS          status;
  PDEVICE_OBJECT    DiskDeviceObject;

  IO_STATUS_BLOCK   ioStatus;
  OBJECT_ATTRIBUTES objectAttributes;
  PFILE_OBJECT      fileObject = NULL;
 // HANDLE            ntFileHandle;
  UNICODE_STRING    DiskName;
    
  /*---------------------------------------------------------------------------------------------------new*/  
  RtlInitUnicodeString( &DiskName, L"\\Device\\HarddiskVolume1");
  status=IoGetDeviceObjectPointer(&DiskName,FILE_ALL_ACCESS,&fileObject, &DiskDeviceObject);
  if(!NT_SUCCESS(status))
  {
      KdPrint( ("shar:HarddiskVolume1:IoGetDeviceObjectPointer Error Code: 0x%xL\n", status) );
      return FALSE;  
  }
  else
  {
      if(DiskDeviceObject==NULL)
      {
        DbgPrint(("shar:HarddiskVolume1: 没有找到DiskDeviceObject\n"));
        return FALSE;
      }
      else
      {
          DbgPrint(("shar:HarddiskVolume1: 找到DiskDeviceObject成功\n"));
      }
  }
/*---------------------------------------------------------------------------------------------------new*/
  //将要绑定的设备存入到目标区中  
  PSFILTER_DEVICE_EXTENSION pExtension = (PSFILTER_DEVICE_EXTENSION)MyDevice->DeviceExtension;

//  MyDevice->Flags&=~DO_DEVICE_INITIALIZING;
  
  pExtension->AttachedToDeviceObject = IoAttachDeviceToDeviceStack(MyDevice,DiskDeviceObject);
  if(pExtension->AttachedToDeviceObject==NULL)
  {
    DbgPrint(("shar: failed to attach mydevice to target\n"));
//    ZwClose(ntFileHandle);
    ObDereferenceObject(fileObject);
    return FALSE;
  }
  else
  {
//    ZwClose(ntFileHandle);
    ObDereferenceObject(fileObject);
    DbgPrint(("shar: Attach mydevice to target successfully\n"));
    return TRUE;
  }
}

可是运行完成后系统却报错说
shar: 绑定硬件设备成功

*** Fatal System Error: 0x0000006b
                       (0xC0000010,0x00000002,0x00000000,0x00000000)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

安装驱动后系统死机
这个是怎么回事  哪位同志帮帮我啊  
shar123
驱动牛犊
驱动牛犊
  • 注册日期2009-05-12
  • 最后登录2009-10-09
  • 粉丝0
  • 关注0
  • 积分59分
  • 威望461点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2009-05-21 14:09
FastIO和Dsp函数我暂时没有设定
游客

返回顶部