亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? liubo2004666_ezusbsys.c

?? EZ-USB 通用驅動程序源碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
   {
      ntStatus = Ezusb_CreateDeviceObject(DriverObject, &deviceObject, instance);
      instance++;
   } while (!NT_SUCCESS(ntStatus) && (instance < MAX_EZUSB_DEVICES));

   if (NT_SUCCESS(ntStatus))
   {
      pdx = deviceObject->DeviceExtension;

      //
      // Non plug and play drivers usually create the device object in
      // driver entry, and the I/O manager autimatically clears this flag.
      // Since we are creating the device object ourselves in response to 
      // a PnP START_DEVICE IRP, we need to clear this flag ourselves.
      //
      deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

      //
      // This driver uses direct I/O for read/write requests
      //
      deviceObject->Flags |= DO_DIRECT_IO;

      deviceObject->Flags |= DO_POWER_PAGABLE;

      //
      //
      // store away the Physical device Object
      //
      pdx->PhysicalDeviceObject=PhysicalDeviceObject;

      //
      // Attach to the StackDeviceObject.  This is the device object that what we 
      // use to send Irps and Urbs down the USB software stack
      //
      pdx->StackDeviceObject =
         IoAttachDeviceToDeviceStack(deviceObject, PhysicalDeviceObject);

      ASSERT (pdx->StackDeviceObject != NULL);

      pdx->LastFailedUrbStatus = 0;

	   pdx->usage = 1;				// locked until RemoveDevice
	   KeInitializeEvent(&pdx->evRemove,
                        NotificationEvent,
                        FALSE);              // set when use count drops to zero
   }

   Ezusb_KdPrint(("exit Ezusb_PnPAddDevice (%x)\n", ntStatus));

   return ntStatus;
}


NTSTATUS
Ezusb_CreateDeviceObject(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT *DeviceObject,
    LONG Instance
    )
/*++

Routine Description:
    Creates a Functional DeviceObject

Arguments:
    DriverObject - pointer to the driver object for device
    DeviceObject - pointer to DeviceObject pointer to return
                   created device object.
    Instance - instnace of the device create.

Return Value:
    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise
--*/
{
   NTSTATUS ntStatus;
   WCHAR deviceLinkBuffer[]  = L"\\DosDevices\\Ezusb-0";
   UNICODE_STRING deviceLinkUnicodeString;
   WCHAR deviceNameBuffer[]  = L"\\Device\\Ezusb-0";
   UNICODE_STRING deviceNameUnicodeString;
   PDEVICE_EXTENSION pdx;
   STRING deviceName;

   Ezusb_KdPrint(("enter Ezusb_CreateDeviceObject instance = %d\n", Instance));

   //
   // fix up device names based on Instance
   //
   deviceLinkBuffer[18] = (USHORT) ('0' + Instance);
   deviceNameBuffer[14] = (USHORT) ('0' + Instance);

   Ezusb_KdPrint(("Create Device name (%ws)\n", deviceNameBuffer));

   RtlInitUnicodeString (&deviceNameUnicodeString,
                         deviceNameBuffer);

   //
   //Print out the unicode string
   //NOTE:  We must first convert the string to Unicode due to a bug in the Debugger that does not allow
   //       Unicode Strings to be printed to the debug device.
   //
   deviceName.Buffer = NULL;

   ntStatus = RtlUnicodeStringToAnsiString (&deviceName,
                                          &deviceNameUnicodeString, 
                                          TRUE);


   if (NT_SUCCESS(ntStatus))
   {
      Ezusb_KdPrint(("Create Device Name (%s)\n", deviceName.Buffer));
      RtlFreeAnsiString (&deviceName);
   }
   else
   {
      Ezusb_KdPrint(("Unicode to Ansi str failed w/ ntStatus: 0x%x\n",ntStatus));
   }

   ntStatus = IoCreateDevice (DriverObject,
                              sizeof (DEVICE_EXTENSION),
                              &deviceNameUnicodeString,
                              FILE_DEVICE_UNKNOWN,
                              0,
                              FALSE,
                              DeviceObject);


   if (NT_SUCCESS(ntStatus))
   {

      // Initialize our device extension
      pdx = (PDEVICE_EXTENSION) ((*DeviceObject)->DeviceExtension);

      RtlCopyMemory(pdx->DeviceLinkNameBuffer,
                   deviceLinkBuffer,
                   sizeof(deviceLinkBuffer));

      pdx->OpenHandles = 0;
      pdx->ConfigurationHandle = NULL;
      pdx->DeviceDescriptor = NULL;
      pdx->NeedCleanup = FALSE;
      pdx->DataRingBuffer = NULL;
      pdx->DescriptorRingBuffer = NULL;
      pdx->Started = FALSE;

      // Initialize our interface
      pdx->Interface = NULL;

      RtlInitUnicodeString (&deviceLinkUnicodeString,
                           deviceLinkBuffer);

      Ezusb_KdPrint(("Create DosDevice name (%ws)\n", deviceLinkBuffer));

      ntStatus = IoCreateSymbolicLink (&deviceLinkUnicodeString,
                                      &deviceNameUnicodeString);

   }

   Ezusb_KdPrint(("exit Ezusb_CreateDeviceObject (%x)\n", ntStatus));

   return ntStatus;
}

NTSTATUS
Ezusb_CallUSBD(
    IN PDEVICE_OBJECT fdo,
    IN PURB Urb
    )
/*++

Routine Description:
   Passes a Usb Request Block (URB) to the USB class driver (USBD)

   Note that we create our own IRP here and use it to send the request to
   the USB software subsystem.  This means that this routine is essentially
   independent of the IRP that caused this driver to be called in the first
   place.  The IRP for this transfer is created, used, and then destroyed
   in this routine.

   However, note that this routine uses the Usb Request Block (urb) passed
   in by the caller as the request block for the USB software stack.

   Implementation of this routine may be changed depending on the specific
   requirements of your driver.  For example, while this routine issues a
   synchronous request to the USB stack, you may wish to implement this as an
   asynchronous request in which you set an IoCompletionRoutine to be called
   when the request is complete.

Arguments:
   fdo - pointer to the device object for this instance of an Ezusb Device
   Urb          - pointer to Urb request block

Return Value:
   STATUS_SUCCESS if successful,
   STATUS_UNSUCCESSFUL otherwise

--*/
{
   NTSTATUS ntStatus, status = STATUS_SUCCESS;
   PDEVICE_EXTENSION pdx;
   PIRP irp;
   KEVENT event;
   IO_STATUS_BLOCK ioStatus;
   PIO_STACK_LOCATION nextStack;

   Ezusb_KdPrint (("enter Ezusb_CallUSBD\n"));

   pdx = fdo->DeviceExtension;

   // issue a synchronous request (see notes above)
   KeInitializeEvent(&event, NotificationEvent, FALSE);

   irp = IoBuildDeviceIoControlRequest(
             IOCTL_INTERNAL_USB_SUBMIT_URB,
             pdx->StackDeviceObject,
             NULL,
             0,
             NULL,
             0,
             TRUE, /* INTERNAL */
             &event,
             &ioStatus);

   // Prepare for calling the USB driver stack
   nextStack = IoGetNextIrpStackLocation(irp);
   ASSERT(nextStack != NULL);

   // Set up the URB ptr to pass to the USB driver stack
   nextStack->Parameters.Others.Argument1 = Urb;

   Ezusb_KdPrint (("Calling USB Driver Stack\n"));

   //
   // Call the USB class driver to perform the operation.  If the returned status
   // is PENDING, wait for the request to complete.
   //
   ntStatus = IoCallDriver(pdx->StackDeviceObject,
                         irp);

   Ezusb_KdPrint (("return from IoCallDriver USBD %x\n", ntStatus));

   if (ntStatus == STATUS_PENDING)
   {
      Ezusb_KdPrint (("Wait for single object\n"));

      status = KeWaitForSingleObject(
                    &event,
                    Suspended,
                    KernelMode,
                    FALSE,
                    NULL);

      Ezusb_KdPrint (("Wait for single object, returned %x\n", status));
   }
   else
   {
      ioStatus.Status = ntStatus;
   }

   Ezusb_KdPrint (("URB status = %x status = %x irp status %x\n",
     Urb->UrbHeader.Status, status, ioStatus.Status));

   //
   // USBD maps the error code for us.  USBD uses error codes in its URB
   // structure that are more insightful into USB behavior. In order to
   // match the NT Status codes, USBD maps its error codes into more general NT
   // error categories so higher level drivers can decipher the error codes
   // based on standard NT error code definitions.
   //
   ntStatus = ioStatus.Status;

   //
   // If the URB status was not USBD_STATUS_SUCCESS, we save a copy of the
   // URB status in the device extension.  After a failure, another IOCTL,
   // IOCTL_EZUSB_GET_LAST_ERROR can be used to retrieve the URB status
   // for the most recently failed URB.  Of course, this status gets
   // overwritten by subsequent failures, but it's better than nothing.
   //
   if (!(USBD_SUCCESS(Urb->UrbHeader.Status)))
      pdx->LastFailedUrbStatus = Urb->UrbHeader.Status;

   //
   // if ioStatus.Status indicates an error (ie. the IRP failed) then return that.
   // If ioStatus.Status indicates success, it is still possible that what we were
   // trying to do failed.  For example, if the IRP is cancelled, the status returned
   // by the I/O manager for the IRP will not indicate an error.  In that case, we
   // should check the URB status.  If it indicates anything other than
   // USBD_SUCCESS, then we should return STATUS_UNSUCCESSFUL.
   //
   if (NT_SUCCESS(ntStatus))
   {
      if (!(USBD_SUCCESS(Urb->UrbHeader.Status)))
         ntStatus = STATUS_UNSUCCESSFUL;
   }

   Ezusb_KdPrint(("exit Ezusb_CallUSBD (%x)\n", ntStatus));

   return ntStatus;
}

NTSTATUS
Ezusb_ConfigureDevice(
    IN  PDEVICE_OBJECT fdo
    )
/*++
Routine Description:
   Configures the USB device via USB-specific device requests and interaction
   with the USB software subsystem.

Arguments:
   fdo - pointer to the device object for this instance of the Ezusb Device

Return Value:
   NT status code
--*/
{
   PDEVICE_EXTENSION pdx;
   NTSTATUS ntStatus;
   PURB urb = NULL;
   ULONG siz;
   PUSB_CONFIGURATION_DESCRIPTOR configurationDescriptor = NULL;

   Ezusb_KdPrint (("enter Ezusb_ConfigureDevice\n"));

   pdx = fdo->DeviceExtension;

   //
   // Get memory for the USB Request Block (urb).
   //
   urb = ExAllocatePool(NonPagedPool,
                      sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));

   if (urb != NULL)
   {
      //
      // Set size of the data buffer.  Note we add padding to cover hardware faults
      // that may cause the device to go past the end of the data buffer
      //
        siz = sizeof(USB_CONFIGURATION_DESCRIPTOR) + 16;

        // Get the nonpaged pool memory for the data buffer
        configurationDescriptor = ExAllocatePool(NonPagedPool, siz);

        if (configurationDescriptor != NULL) {

            UsbBuildGetDescriptorRequest(urb,
                                         (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                                         USB_CONFIGURATION_DESCRIPTOR_TYPE,
                                         0,
                                         0,
                                         configurationDescriptor,
                                         NULL,
                                         sizeof (USB_CONFIGURATION_DESCRIPTOR),/* Get only the configuration descriptor */
                                         NULL);

            ntStatus = Ezusb_CallUSBD(fdo, urb);

            if (NT_SUCCESS(ntStatus)) {
                Ezusb_KdPrint (("Configuration Descriptor is at %x, bytes txferred: %d\n\
                                  Configuration Descriptor Actual Length: %d\n",
                                  configurationDescriptor,
                                  urb->UrbControlDescriptorRequest.TransferBufferLength,
                                  configurationDescriptor->wTotalLength));
            }//if

        } else {
            ntStatus = STATUS_NO_MEMORY;
            goto Exit_EzusbConfigureDevice;
        }//if-else

        // Determine how much data is in the entire configuration descriptor
        // and add extra room to protect against accidental overrun
        siz = configurationDescriptor->wTotalLength + 16;

        //  Free up the data buffer memory just used
        ExFreePool(configurationDescriptor);
        configurationDescriptor = NULL;

        // Get nonpaged pool memory for the data buffer
        configurationDescriptor = ExAllocatePool(NonPagedPool, siz);

        // Now get the entire Configuration Descriptor
        if (configurationDescriptor != NULL) {
            UsbBuildGetDescriptorRequest(urb,
                                         (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                                         USB_CONFIGURATION_DESCRIPTOR_TYPE,
                                         0,
                                         0,
                                         configurationDescriptor,
                                         NULL,
                                         siz,  // Get all the descriptor data
                                         NULL);

            ntStatus = Ezusb_CallUSBD(fdo, urb);

            if (NT_SUCCESS(ntStatus)) {
                Ezusb_KdPrint (("Entire Configuration Descriptor is at %x, bytes txferred: %d\n",
                                  configurationDescriptor,
                                  urb->UrbControlDescriptorRequest.TransferBufferLength));
            } else {
                //Error in getting configuration descriptor
                goto Exit_EzusbConfigureDevice;
            }//else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜久久久久久久久电影院| 波多野结衣中文字幕一区二区三区| 久久国产精品色| 欧美日韩国产高清一区二区三区| 亚洲婷婷综合色高清在线| 国产精品69毛片高清亚洲| 久久精品夜色噜噜亚洲a∨| 国产成人a级片| 亚洲男女一区二区三区| 欧美一级日韩一级| 国产精一区二区三区| 精品亚洲欧美一区| 18成人在线视频| 日韩欧美另类在线| 99麻豆久久久国产精品免费| 亚洲国产日韩a在线播放性色| 一区二区中文字幕在线| 亚洲欧美一区二区三区国产精品 | 精品一区二区三区免费观看| 日韩电影免费在线看| 国产欧美综合在线观看第十页| av中文字幕在线不卡| 波多野结衣91| 欧美色国产精品| 成人黄色电影在线| 色婷婷综合久久久中文一区二区| 激情五月婷婷综合网| 日韩黄色免费电影| 一区二区三区欧美日韩| 欧美精品一区二区三区很污很色的| eeuss影院一区二区三区| 99精品偷自拍| 99久久精品国产精品久久| 欧美午夜寂寞影院| 91欧美激情一区二区三区成人| 国产精一区二区三区| 色综合天天综合色综合av | 国产成人欧美日韩在线电影| 91黄视频在线| 色综合夜色一区| 日韩欧美一级精品久久| 18欧美亚洲精品| 麻豆精品视频在线观看视频| 丝袜脚交一区二区| 成人教育av在线| 欧美精品久久99久久在免费线| 欧美性生活影院| 欧美激情一区二区三区在线| 精品成人私密视频| 亚洲第一精品在线| 香蕉久久夜色精品国产使用方法| 韩国av一区二区三区| 欧美亚洲国产一区二区三区va| 久久久久高清精品| 中文在线一区二区| 九一九一国产精品| 欧美一级欧美一级在线播放| 亚洲视频一二区| 成人黄色电影在线| 久久精品视频一区二区| 久久激情五月婷婷| 欧美一区二区在线播放| 亚洲高清在线精品| 91丝袜国产在线播放| 日本一区二区动态图| 久久99精品国产.久久久久| 欧美高清hd18日本| 亚洲影视资源网| 精品在线播放免费| 欧美一区二区三区在线观看视频| 夜夜精品浪潮av一区二区三区| 99久久久久久| 中文字幕一区二区三区不卡| 国产不卡在线一区| 欧美在线综合视频| 亚洲精品一区二区三区99| 美女尤物国产一区| 欧美一区二区大片| 久色婷婷小香蕉久久| 91麻豆精品国产自产在线观看一区| 精品国产第一区二区三区观看体验| 日产欧产美韩系列久久99| 日韩一区二区精品葵司在线| 国产精品情趣视频| 午夜精品成人在线| 国产成人在线电影| 中文字幕久久午夜不卡| av在线一区二区三区| 中文字幕一区二区三区视频| 日本高清视频一区二区| 亚洲一区av在线| 日韩三级电影网址| 韩国一区二区在线观看| 日本一区二区三区在线不卡| 成人av电影观看| 亚洲成人综合在线| 久久综合九色综合欧美就去吻| 亚洲国产成人精品视频| 91麻豆精品91久久久久久清纯 | 国产一区三区三区| 欧美日韩精品一区二区三区蜜桃| 首页亚洲欧美制服丝腿| 精品粉嫩aⅴ一区二区三区四区| 国产精品夜夜嗨| 亚洲国产精品人人做人人爽| 91精品免费在线观看| 国产成人免费网站| 亚洲综合久久久| 久久嫩草精品久久久精品| 97精品久久久午夜一区二区三区| 亚洲电影中文字幕在线观看| 日韩精品自拍偷拍| 92国产精品观看| 韩日av一区二区| 亚洲一二三四区不卡| 久久亚洲精品小早川怜子| 色偷偷久久人人79超碰人人澡| 麻豆久久久久久久| 一二三区精品福利视频| 欧美国产1区2区| 日韩一级黄色片| 欧美午夜不卡在线观看免费| 国产精品一区二区免费不卡| 一区二区三区日韩| 久久久91精品国产一区二区三区| 欧美三级电影在线看| 成人中文字幕在线| 国产亚洲精品bt天堂精选| 欧美午夜在线一二页| 国产盗摄视频一区二区三区| 日本伊人色综合网| 亚洲综合区在线| 欧美日韩一二三区| 在线免费亚洲电影| 99在线精品一区二区三区| 裸体一区二区三区| 香蕉影视欧美成人| 亚洲青青青在线视频| 欧美激情综合网| 久久久久久久久久久久久女国产乱| 欧美精品色综合| 欧美精品色一区二区三区| 在线日韩一区二区| 色偷偷久久人人79超碰人人澡 | 婷婷国产在线综合| 亚洲精品美腿丝袜| 3d成人h动漫网站入口| 一本久久精品一区二区| 丁香另类激情小说| 粉嫩久久99精品久久久久久夜| 国产真实乱偷精品视频免| 麻豆成人在线观看| 九色|91porny| 国产在线精品一区二区夜色| 日韩高清一区二区| 日本亚洲最大的色成网站www| 肉丝袜脚交视频一区二区| 日韩精品电影在线| 日韩国产精品大片| 久久电影国产免费久久电影| 免费人成精品欧美精品| 亚洲丝袜自拍清纯另类| 国产精品成人一区二区三区夜夜夜| 欧美午夜寂寞影院| 欧美日韩aaaaa| 6080午夜不卡| 精品成人一区二区| 亚洲国产成人私人影院tom| 中文字幕亚洲区| 亚洲伊人色欲综合网| 三级成人在线视频| 国产精品一区二区三区99| 丁香啪啪综合成人亚洲小说 | 天堂va蜜桃一区二区三区漫画版| 午夜欧美2019年伦理 | 中文av一区二区| 亚洲乱码国产乱码精品精98午夜| 亚洲一区在线看| 精品一区二区三区久久| 成人午夜av电影| 欧美亚洲综合网| 精品美女在线播放| 欧美精品亚洲二区| 久久综合久久综合久久| 中文字幕在线不卡| 日韩高清在线不卡| www.亚洲在线| 6080国产精品一区二区| 国产日韩综合av| 亚洲精品成人精品456| 日日摸夜夜添夜夜添国产精品| 国产成人免费视频网站 | 国产一区二区三区在线观看免费| 国产成a人亚洲精品| 在线视频欧美精品| 国产亚洲一区二区在线观看| 亚洲夂夂婷婷色拍ww47| 国产一区二区在线视频| 欧美手机在线视频| 国产精品久久夜|