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

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

?? ezusbsys.c

?? EZ Usb system driver written in C.. a useful USB driver..
?? C
?? 第 1 頁 / 共 5 頁
字號:
   //
   instance = 0;
   do
   {
      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,
                    Executive,
                    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 {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品一区二区精华| 2020日本不卡一区二区视频| 日韩精品中文字幕在线不卡尤物 | 九一久久久久久| 成人成人成人在线视频| 91精品国产综合久久久久久久 | 波多野结衣中文字幕一区| 884aa四虎影成人精品一区| 国产精品国产三级国产普通话99| 日精品一区二区| 欧美在线综合视频| 亚洲欧美综合色| 国产精品一二三四五| 日韩一级二级三级精品视频| 一区二区三区欧美日韩| 91在线观看一区二区| 国产色一区二区| 国产精品综合一区二区三区| 精品国产91乱码一区二区三区| 日韩va亚洲va欧美va久久| 欧美日韩国产高清一区二区三区 | aa级大片欧美| 国产精品入口麻豆原神| 国产精品2024| 国产日韩欧美精品在线| 久久99这里只有精品| 欧美电影免费提供在线观看| 日韩高清不卡一区二区三区| 91麻豆精品国产91久久久久久久久 | 国产精品18久久久久久久久| 欧美大肚乱孕交hd孕妇| 极品少妇xxxx偷拍精品少妇| 欧美大片免费久久精品三p | 精品欧美一区二区久久 | 91免费在线播放| 亚洲视频在线一区观看| 波多野结衣欧美| 亚洲欧洲av色图| 91蝌蚪国产九色| 一区二区三区日韩在线观看| 在线免费精品视频| 精品一区二区国语对白| 久久久精品日韩欧美| 精品在线一区二区| 国产精品天美传媒| 91成人国产精品| 日本女优在线视频一区二区| www久久精品| av毛片久久久久**hd| 亚洲永久精品国产| 日韩欧美一卡二卡| 成人丝袜高跟foot| 亚洲已满18点击进入久久| 欧美色中文字幕| 久久成人免费网站| 国产精品久久久久久久第一福利| 91色乱码一区二区三区| 亚洲成人综合网站| 久久久久久亚洲综合影院红桃| 不卡的av电影在线观看| 视频精品一区二区| 久久久蜜桃精品| 在线免费观看日本一区| 国产又黄又大久久| 亚洲一区二区视频| 国产色综合一区| 欧美日韩大陆在线| 成人网页在线观看| 蜜桃视频在线观看一区| 亚洲天堂精品在线观看| 精品电影一区二区三区| 在线视频观看一区| 国产电影一区二区三区| 天堂一区二区在线免费观看| 国产精品私人自拍| 日韩久久久久久| 欧美色涩在线第一页| 国产福利电影一区二区三区| 视频一区视频二区中文| 一区在线中文字幕| 久久久亚洲精品一区二区三区| 欧美日韩欧美一区二区| www.欧美精品一二区| 麻豆久久久久久| 亚洲成人一区二区| 国产精品久久毛片av大全日韩| 日韩一级视频免费观看在线| 一本久久a久久精品亚洲| 国产不卡视频一区二区三区| 日本aⅴ免费视频一区二区三区 | 天天av天天翘天天综合网| 久久精品一二三| 日韩美女一区二区三区| 欧美亚洲日本国产| 91浏览器在线视频| av午夜一区麻豆| 国产成人免费av在线| 久久爱另类一区二区小说| 日本欧美一区二区| 亚洲chinese男男1069| 亚洲蜜臀av乱码久久精品| 91在线视频在线| 亚洲午夜久久久久久久久久久| 中文欧美字幕免费| 久久久久国产精品麻豆| 精品国产乱码久久久久久闺蜜| 欧美疯狂做受xxxx富婆| 精品视频在线视频| 欧美亚洲一区三区| 欧美日韩精品欧美日韩精品| 欧美亚洲一区二区三区四区| 欧美性xxxxxx少妇| 欧美日韩精品电影| 91精品国产综合久久国产大片| 欧美精品在线一区二区| 欧美色男人天堂| 3d成人动漫网站| 日韩欧美色电影| www成人在线观看| 国产欧美日韩激情| 中文字幕色av一区二区三区| 亚洲美女在线一区| 亚洲bt欧美bt精品| 久久99久久99| 国产福利电影一区二区三区| 成人免费看视频| 91福利在线看| 欧美一区二区三区免费在线看| 日韩免费看的电影| 日本一二三四高清不卡| 亚洲色图在线播放| 亚洲成人一二三| 精品午夜久久福利影院| 国产jizzjizz一区二区| 91在线一区二区| 777午夜精品视频在线播放| 欧美xxxx老人做受| 国产欧美精品一区二区三区四区 | 在线观看三级视频欧美| 欧美私模裸体表演在线观看| 欧美一区二区三区在线看| 精品日韩成人av| 中文字幕在线不卡一区 | 91麻豆精品91久久久久久清纯 | 亚洲天堂网中文字| 三级久久三级久久久| 国产一区二区在线观看视频| 99久免费精品视频在线观看| 日本乱码高清不卡字幕| 日韩欧美高清在线| 亚洲欧洲另类国产综合| 亚洲成人综合网站| 高清不卡一二三区| 欧美久久一二区| 国产精品国产三级国产aⅴ无密码| 亚洲一区二区三区视频在线 | 日日摸夜夜添夜夜添精品视频| 韩国成人在线视频| 欧美丝袜丝交足nylons| 久久久久99精品国产片| 欧美精品tushy高清| 欧美肥妇bbw| 国产日本欧洲亚洲| 奇米777欧美一区二区| 色综合天天综合网天天看片| 欧美xxxxxxxx| 亚洲国产欧美在线人成| 成人h版在线观看| 精品人在线二区三区| 无码av免费一区二区三区试看 | 麻豆国产精品视频| 欧美日韩高清一区二区| 中文字幕日韩一区二区| 国产乱一区二区| 这里只有精品视频在线观看| 亚洲情趣在线观看| 成+人+亚洲+综合天堂| 精品国产乱子伦一区| 丝袜诱惑制服诱惑色一区在线观看 | 欧美一区二区视频在线观看2020| 国产精品久久久久久久久图文区| 精品一二三四区| 欧美一二三区在线观看| 日韩精品一级中文字幕精品视频免费观看 | 亚洲色图另类专区| 丰满亚洲少妇av| 国产日本一区二区| 国产一区 二区| 久久久蜜臀国产一区二区| 国模套图日韩精品一区二区| 日韩三级视频中文字幕| 青青草国产精品亚洲专区无| 91精品国产入口| 日韩在线一区二区| 91精品国产一区二区人妖| 日韩国产欧美视频| 日韩精品一区二区三区老鸭窝| 久久激情五月激情| 久久久国产综合精品女国产盗摄| 经典三级在线一区|