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

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

?? ezusbsys.c

?? cy7c68013usbdriver驅動程序,非常方便
?? 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一区二区三区免费野_久草精品视频
成人午夜av影视| www.亚洲免费av| 国产欧美1区2区3区| 色婷婷综合久久久久中文一区二区| 一区二区久久久久久| 亚洲免费观看高清完整版在线观看 | 日韩欧美在线影院| 成人三级在线视频| 日韩av一区二区三区四区| 欧美韩日一区二区三区| 欧美一区二区三区啪啪| 色哟哟日韩精品| 国产乱国产乱300精品| 亚洲一区二区3| 欧美激情一二三区| 精品av久久707| 欧美欧美欧美欧美| 色八戒一区二区三区| 国产一区二区三区免费在线观看| 亚洲一二三区在线观看| 中国色在线观看另类| 精品国产91久久久久久久妲己| 欧洲一区二区av| 成人性生交大合| 国产高清无密码一区二区三区| 免费日韩伦理电影| 视频一区视频二区在线观看| 亚洲乱码中文字幕| 国产女人水真多18毛片18精品视频| 日韩视频免费观看高清完整版| 欧美日韩在线播放三区四区| 91在线视频官网| 不卡的av网站| 成人性生交大合| 成人国产视频在线观看 | 日本伦理一区二区| av中文字幕在线不卡| 国产成a人亚洲| 丁香婷婷综合五月| 国产成人av电影在线| 成人在线视频首页| 国产成人在线影院| 风流少妇一区二区| 丰满白嫩尤物一区二区| 粉嫩嫩av羞羞动漫久久久| 国产 日韩 欧美大片| 成人综合婷婷国产精品久久| 国产电影精品久久禁18| 国产乱码精品一区二区三| 懂色av一区二区在线播放| 国产盗摄精品一区二区三区在线| 国产精品一区二区在线播放 | 欧美午夜电影在线播放| 色综合天天综合色综合av| 国产性天天综合网| 久久精品一区二区三区不卡| 久久精子c满五个校花| 国产欧美一区二区精品久导航| 久久综合精品国产一区二区三区| 337p日本欧洲亚洲大胆色噜噜| 久久日韩精品一区二区五区| 欧美激情在线一区二区| 亚洲视频一区二区免费在线观看 | 久久国产尿小便嘘嘘| 精品一区二区免费看| 国产精选一区二区三区 | 欧美电影免费观看高清完整版在| 精品国产网站在线观看| 国产欧美一区二区三区在线老狼| 国产精品视频九色porn| 亚洲一卡二卡三卡四卡无卡久久| 视频一区视频二区中文| 国产福利一区二区三区在线视频| 99精品视频一区| 欧美日韩黄色影视| 久久这里只精品最新地址| 日本一区二区免费在线观看视频| 中文字幕一区二区三区不卡在线| 一区二区高清在线| 毛片基地黄久久久久久天堂| 国产成人三级在线观看| 在线视频一区二区三区| 日韩午夜电影在线观看| 国产欧美日韩亚州综合| 一区二区三区在线播| 久久国产尿小便嘘嘘| 99亚偷拍自图区亚洲| 欧美一区二区三区日韩视频| 中文字幕av资源一区| 亚洲宅男天堂在线观看无病毒| 精品一区二区在线看| 99国产精品99久久久久久| 91精品国产乱| 粉嫩一区二区三区性色av| 欧美酷刑日本凌虐凌虐| 中文字幕一区二| 美女视频黄频大全不卡视频在线播放 | 亚洲国产精品尤物yw在线观看| 老司机精品视频线观看86| 91网页版在线| 久久综合九色欧美综合狠狠 | 成人av网在线| 日韩午夜中文字幕| 亚洲一区免费观看| 成人激情动漫在线观看| 日韩精品一区二区三区老鸭窝| 亚洲美女视频在线观看| 国产乱码精品一区二区三| 欧美丰满少妇xxxbbb| 亚洲视频狠狠干| 国产91丝袜在线播放0| 精品日韩在线一区| 天天操天天色综合| 在线视频欧美精品| 亚洲视频小说图片| 高清shemale亚洲人妖| 26uuu精品一区二区| 麻豆成人91精品二区三区| 欧美亚洲一区二区三区四区| 国产精品电影一区二区三区| 激情国产一区二区| 日韩午夜在线播放| 日韩精品乱码av一区二区| 欧美日韩专区在线| 一区二区三区91| 色成人在线视频| 亚洲精品你懂的| 91久久久免费一区二区| 自拍视频在线观看一区二区| 粉嫩在线一区二区三区视频| 日本一区免费视频| 国产精品99久久久久久似苏梦涵| 精品三级在线观看| 韩国一区二区三区| 久久蜜桃av一区精品变态类天堂 | 在线亚洲人成电影网站色www| 国产精品久久看| 波多野结衣亚洲一区| 国产精品蜜臀在线观看| 岛国一区二区在线观看| 国产精品色哟哟| 不卡的电影网站| 日韩美女久久久| 色8久久人人97超碰香蕉987| 亚洲综合久久av| 91精品国模一区二区三区| 日韩电影在线免费看| 日韩视频一区在线观看| 麻豆91在线观看| 久久免费美女视频| 国产**成人网毛片九色| 亚洲欧美另类图片小说| 在线看国产日韩| 美洲天堂一区二卡三卡四卡视频| 精品国产区一区| 99久久精品费精品国产一区二区| 依依成人精品视频| 欧美二区在线观看| 黑人巨大精品欧美一区| 国产免费成人在线视频| 91福利在线导航| 日韩电影在线一区| 国产拍揄自揄精品视频麻豆| av亚洲精华国产精华精| 亚洲午夜久久久久久久久久久| 欧美日韩电影在线| 久久精品国产在热久久| 亚洲国产经典视频| 色婷婷亚洲综合| 美国十次综合导航| 国产精品久久久久久久蜜臀| 欧美视频一区在线观看| 久久精品国产第一区二区三区| 中文字幕精品在线不卡| 欧美日韩国产大片| 日韩一区二区影院| 国产精品1区2区| 一区二区国产盗摄色噜噜| 精品国产乱码久久久久久夜甘婷婷| 成人免费毛片片v| 性感美女极品91精品| 26uuu色噜噜精品一区二区| 91在线视频观看| 激情欧美日韩一区二区| 亚洲乱码日产精品bd| 亚洲精品在线网站| 欧美在线高清视频| 国产91丝袜在线播放0| 日韩制服丝袜av| 中文字幕在线一区| 欧美大黄免费观看| 色狠狠色噜噜噜综合网| 国产一区91精品张津瑜| 亚洲18女电影在线观看| 国产精品视频免费| 欧美videofree性高清杂交| 91福利区一区二区三区| 国产一区二区三区免费| 午夜精品一区二区三区免费视频| 国产精品污网站|