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

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

?? liubo2004666_ezusbsys.c

?? EZ-USB 通用驅動程序源碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
        } else {
            // Failed getting data buffer (configurationDescriptor) memory
            ntStatus = STATUS_NO_MEMORY;
            goto Exit_EzusbConfigureDevice;
        }//if-else

    } else {
        // failed getting urb memory
        ntStatus = STATUS_NO_MEMORY;
        goto Exit_EzusbConfigureDevice;
    }//if-else

    /*
    // We have the configuration descriptor for the configuration
    // we want.
    //
    // Now we issue the SelectConfiguration command to get
    // the  pipes associated with this configuration.
    */
    if (configurationDescriptor) {
        // Get our pipes
        ntStatus = Ezusb_SelectInterfaces(fdo,
                                           configurationDescriptor,
                                           NULL // Device not yet configured
                                           );
    } //if

Exit_EzusbConfigureDevice:

    // Clean up and exit this routine
    if (urb != NULL) {
        ExFreePool(urb);                    // Free urb memory
    }//if

    if (configurationDescriptor != NULL) {
        ExFreePool(configurationDescriptor);// Free data buffer
    }//if

    Ezusb_KdPrint (("exit Ezusb_ConfigureDevice (%x)\n", ntStatus));
    return ntStatus;
}//Ezusb_ConfigureDevice


NTSTATUS
Ezusb_SelectInterfaces(
    IN PDEVICE_OBJECT fdo,
    IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
    IN PUSBD_INTERFACE_INFORMATION Interface
    )
/*++

Routine Description:
    Initializes an Ezusb Device with multiple interfaces

Arguments:
    fdo            - pointer to the device object for this instance of the Ezusb Device
    ConfigurationDescriptor - pointer to the USB configuration descriptor containing the interface and endpoint
                              descriptors.
    Interface               - pointer to a USBD Interface Information Object
                            - If this is NULL, then this driver must choose its interface based on driver-specific
                              criteria, and the driver must also CONFIGURE the device.
                            - If it is NOT NULL, then the driver has already been given an interface and
                              the device has already been configured by the parent of this device driver.

Return Value:
    NT status code
--*/
{
   PDEVICE_EXTENSION pdx;
   NTSTATUS ntStatus;
   PURB urb;
   ULONG j;
   UCHAR alternateSetting, MyInterfaceNumber;
   PUSBD_INTERFACE_INFORMATION interfaceObject;
   USBD_INTERFACE_LIST_ENTRY interfaceList[2];

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

   pdx = fdo->DeviceExtension;
   MyInterfaceNumber = SAMPLE_INTERFACE_NBR;

	// Search the configuration descriptor for the first interface/alternate setting

   interfaceList[0].InterfaceDescriptor =
   USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
                                       ConfigurationDescriptor,
                                       -1,         // Interface - don't care
                                       -1,         // Alternate Setting - don't care
                                       -1,         // Class - don't care
                                       -1,         // SubClass - don't care
                                       -1);        // Protocol - don't care

   ASSERT(interfaceList[0].InterfaceDescriptor != NULL);

   interfaceList[1].InterfaceDescriptor = NULL;
   interfaceList[1].Interface = NULL;

   urb = USBD_CreateConfigurationRequestEx(ConfigurationDescriptor,&interfaceList[0]);

   if (!urb)
   {
      Ezusb_KdPrint ((" USBD_CreateConfigurationRequestEx failed\n"));            
   }

   DumpBuffer(urb, urb->UrbHeader.Length);

   interfaceObject = (PUSBD_INTERFACE_INFORMATION) (&(urb->UrbSelectConfiguration.Interface));

   /*
   // We set up a default max transfer size for the endpoints.  Your driver will
   // need to change this to reflect the capabilities of your device's endpoints.
   */
   for (j=0; j<interfaceList[0].InterfaceDescriptor->bNumEndpoints; j++)
      interfaceObject->Pipes[j].MaximumTransferSize = (64 * 1024) - 1;


   ntStatus = Ezusb_CallUSBD(fdo, urb);

   DumpBuffer(urb, urb->UrbHeader.Length);

   if (NT_SUCCESS(ntStatus) && USBD_SUCCESS(urb->UrbHeader.Status))
   {

      // Save the configuration handle for this device
      pdx->ConfigurationHandle =
         urb->UrbSelectConfiguration.ConfigurationHandle;

      pdx->Interface = ExAllocatePool(NonPagedPool,
                                                interfaceObject->Length);

      // save a copy of the interfaceObject information returned
      RtlCopyMemory(pdx->Interface, interfaceObject, interfaceObject->Length);

      // Dump the interfaceObject to the debugger
      Ezusb_KdPrint (("---------\n"));
      Ezusb_KdPrint (("NumberOfPipes 0x%x\n", pdx->Interface->NumberOfPipes));
      Ezusb_KdPrint (("Length 0x%x\n", pdx->Interface->Length));
      Ezusb_KdPrint (("Alt Setting 0x%x\n", pdx->Interface->AlternateSetting));
      Ezusb_KdPrint (("Interface Number 0x%x\n", pdx->Interface->InterfaceNumber));

      // Dump the pipe info
      for (j=0; j<interfaceObject->NumberOfPipes; j++)
      {
         PUSBD_PIPE_INFORMATION pipeInformation;

         pipeInformation = &pdx->Interface->Pipes[j];

         Ezusb_KdPrint (("---------\n"));
         Ezusb_KdPrint (("PipeType 0x%x\n", pipeInformation->PipeType));
         Ezusb_KdPrint (("EndpointAddress 0x%x\n", pipeInformation->EndpointAddress));
         Ezusb_KdPrint (("MaxPacketSize 0x%x\n", pipeInformation->MaximumPacketSize));
         Ezusb_KdPrint (("Interval 0x%x\n", pipeInformation->Interval));
         Ezusb_KdPrint (("Handle 0x%x\n", pipeInformation->PipeHandle));
         Ezusb_KdPrint (("MaximumTransferSize 0x%x\n", pipeInformation->MaximumTransferSize));
      }

      Ezusb_KdPrint (("---------\n"));
   }


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

   return ntStatus;

}/* Ezusb_SelectInterfaces */


NTSTATUS
Ezusb_Read_Write(
   IN  PDEVICE_OBJECT fdo,
   IN  PIRP Irp
   )
/*++
Routine Description:
    
Arguments:

Return Value:
    NT status code
        STATUS_SUCCESS:                 Read was done successfully
        STATUS_INVALID_PARAMETER_3:     The Endpoint Index does not specify an IN pipe 
        STATUS_NO_MEMORY:               Insufficient data memory was supplied to perform the READ

    This routine fills the status code into the Irp
    
--*/
{
   PDEVICE_EXTENSION          pdx = fdo->DeviceExtension;
   NTSTATUS                   ntStatus;
   PIO_STACK_LOCATION         irpStack = IoGetCurrentIrpStackLocation (Irp);
   PBULK_TRANSFER_CONTROL     bulkControl =
                              (PBULK_TRANSFER_CONTROL)Irp->AssociatedIrp.SystemBuffer;
   ULONG                      bufferLength =
                              irpStack->Parameters.DeviceIoControl.OutputBufferLength;
   PURB                       urb = NULL;
   ULONG                      urbSize = 0;
   ULONG                      transferFlags = 0;
   PUSBD_INTERFACE_INFORMATION interfaceInfo = NULL;
   PUSBD_PIPE_INFORMATION     pipeInfo = NULL;
   USBD_PIPE_HANDLE           pipeHandle = NULL;


   Ezusb_KdPrint(("enter Ezusb_Read_Write()\n"));
   
   //
   // verify that the selected pipe is valid, and get a handle to it. If anything
   // is wrong, return an error
   //
   interfaceInfo = pdx->Interface;

   if (!interfaceInfo)
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() no interface info - Exiting\n"));
      return STATUS_UNSUCCESSFUL;
   }
   
   if (bulkControl->pipeNum > interfaceInfo->NumberOfPipes)
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() invalid pipe - Exiting\n"));
      return STATUS_INVALID_PARAMETER;
   }

   pipeInfo = &(interfaceInfo->Pipes[bulkControl->pipeNum]);

   if (!((pipeInfo->PipeType == UsbdPipeTypeBulk) ||
         (pipeInfo->PipeType == UsbdPipeTypeInterrupt)))
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() invalid pipe - Exiting\n"));
      return STATUS_INVALID_PARAMETER;
   }

   pipeHandle = pipeInfo->PipeHandle;

   if (!pipeHandle)
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() invalid pipe - Exiting\n"));
      return STATUS_UNSUCCESSFUL;
   }

   if (bufferLength > pipeInfo->MaximumTransferSize)
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() invalid transfer size - Exiting\n"));
      return STATUS_INVALID_PARAMETER;
   }

   //
   // allocate and fill in the Usb request (URB)
   //
   urbSize = sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER);

   urb = ExAllocatePool(NonPagedPool,urbSize);

   if (!urb)
   {
      Ezusb_KdPrint(("Ezusb_Read_Write() unable to alloc URB - Exiting\n"));
      return STATUS_NO_MEMORY;
   }
   

   transferFlags = USBD_SHORT_TRANSFER_OK;

   //
   // get direction info from the endpoint address
   //
   if (USB_ENDPOINT_DIRECTION_IN(pipeInfo->EndpointAddress))
      transferFlags |= USBD_TRANSFER_DIRECTION_IN;

   UsbBuildInterruptOrBulkTransferRequest(urb,        //ptr to urb
                        (USHORT) urbSize,             //size of urb
							   pipeHandle,                   //usbd pipe handle
							   NULL,                         //TransferBuffer
							   Irp->MdlAddress,              //mdl
							   bufferLength,                 //bufferlength
							   transferFlags,                //flags
							   NULL);                        //link

   //
   // Call the USB Stack.
   //
	ntStatus = Ezusb_CallUSBD(fdo, urb);

   //
   // If the transfer was successful, report the length of the transfer to the
   // caller by setting IoStatus.Information
   //
   if (NT_SUCCESS(ntStatus))
   {
      Irp->IoStatus.Information = urb->UrbBulkOrInterruptTransfer.TransferBufferLength;
      Ezusb_KdPrint(("Successfully transfered 0x%x bytes\n",Irp->IoStatus.Information));
   }

   //
   // free the URB
   //
   ExFreePool(urb);

   return ntStatus;
}


NTSTATUS
Ezusb_Create(
    IN PDEVICE_OBJECT fdo,
    IN PIRP Irp
    )
/*++
Routine Description:
     This is the Entry point for CreateFile calls from user mode apps (apps may open "\\.\Ezusb-x\yyzz"
     where yy is the interface number and zz is the endpoint address).

     Here is where you would add code to create symbolic links between endpoints
     (i.e., pipes in USB software terminology) and User Mode file names.  You are
     free to use any convention you wish to create these links, although the above
     convention offers a way to identify resources on a device by familiar file and
     directory structure nomenclature.

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

Return Value:
    NT status code
--*/
{
   NTSTATUS ntStatus;
   PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION )fdo->DeviceExtension;

   Ezusb_KdPrint(("Enter Ezusb_Create()\n"));

   if (!pdx->Started)
   {
      return STATUS_UNSUCCESSFUL;
   }

   // increment the open handle counter
   pdx->OpenHandles++;

   Irp->IoStatus.Status = STATUS_SUCCESS;
   Irp->IoStatus.Information = 0;

   // Create all the symbolic links here
   ntStatus = Irp->IoStatus.Status;

   IoCompleteRequest (Irp,
                    IO_NO_INCREMENT
                    );

   return ntStatus;

}//Ezusb_Create


NTSTATUS
Ezusb_Close(
    IN PDEVICE_OBJECT fdo,
    IN PIRP Irp
    )
/*++
Routine Description:
    Entry point for CloseHandle calls from user mode apps to close handles they have opened

Arguments:
    fdo - pointer to the device object for this instance of the Ezusb device
    Irp          - pointer to an irp

Return Value:
    NT status code

--*/
{
   NTSTATUS ntStatus;
   PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION )fdo->DeviceExtension;

   Ezusb_KdPrint(("Enter Ezusb_Close()\n"));

   // decrement the open handle counter
   pdx->OpenHandles--;

   Irp->IoStatus.Status = STATUS_SUCCESS;
   Irp->IoStatus.Information = 0;

   ntStatus = Irp->IoStatus.Status;

   IoCompleteRequest (Irp,
                    IO_NO_INCREMENT
                    );

   return ntStatus;

}//Ezusb_Close


NTSTATUS
Ezusb_ProcessIOCTL(
    IN PDEVICE_OBJECT fdo,
    IN PIRP Irp
    )
/*++

Routine Description:
   This where all the DeviceIoControl codes are handled.  You can add mor

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产尿小便嘘嘘尿| 欧美日韩国产bt| 日韩免费视频一区| 美女视频黄久久| 日本一区二区三区国色天香 | 99久久精品情趣| 国产精品无圣光一区二区| 不卡视频在线看| 婷婷夜色潮精品综合在线| 91精品国产91久久久久久最新毛片| 日韩国产欧美视频| 国产精品国产成人国产三级| 91精品国产综合久久小美女| 成人激情动漫在线观看| 99在线热播精品免费| 美女免费视频一区| 国产一区二区三区黄视频| 136国产福利精品导航| 欧美一级久久久久久久大片| 97精品国产露脸对白| 日本高清免费不卡视频| 精品在线观看视频| 五月婷婷综合激情| 紧缚奴在线一区二区三区| 国产福利精品一区| 久久99精品视频| 成人不卡免费av| 欧美视频精品在线| 91女人视频在线观看| 国产麻豆成人精品| 在线观看日韩一区| 欧美影院午夜播放| 精品国产伦一区二区三区免费| 欧美日韩国产一区二区三区地区| 欧美一区二区女人| 国产精品久久精品日日| 首页国产欧美久久| 人禽交欧美网站| 日本欧美肥老太交大片| 风间由美中文字幕在线看视频国产欧美| 日本成人在线一区| 成人av在线一区二区三区| 欧美一区二区视频免费观看| 国产精品三级av在线播放| 久久99久久久久| 色中色一区二区| 在线免费观看一区| 国产日韩一级二级三级| 免费成人深夜小野草| 色婷婷国产精品| 久久久亚洲精品石原莉奈| 精品动漫一区二区三区在线观看| 一区在线观看免费| 国产成人精品亚洲午夜麻豆| 日韩欧美在线123| 亚洲无人区一区| 青青青伊人色综合久久| 一本到三区不卡视频| 国产精品对白交换视频| 国产一区二区三区香蕉| 日韩一级二级三级| 六月丁香婷婷色狠狠久久| 欧美老肥妇做.爰bbww| 精品国产免费一区二区三区四区| 亚洲一区二区三区影院| 蜜臀久久99精品久久久久宅男| 91黄色激情网站| 亚洲精品午夜久久久| 美女网站一区二区| 67194成人在线观看| 亚洲成人av福利| 国产91丝袜在线播放九色| 日韩欧美三级在线| 国精产品一区一区三区mba桃花 | 黑人精品欧美一区二区蜜桃| 欧美日韩成人高清| 亚洲国产日韩a在线播放| 欧美做爰猛烈大尺度电影无法无天| 中文字幕精品一区二区精品绿巨人 | 精品久久久久99| 亚洲男帅同性gay1069| 日韩电影在线免费看| 91精品国产丝袜白色高跟鞋| 午夜精品久久久久影视| 欧美丰满少妇xxxxx高潮对白| 亚洲小说春色综合另类电影| 色菇凉天天综合网| 亚洲网友自拍偷拍| 日韩欧美国产综合| 成人福利视频在线| 亚洲国产精品久久久久婷婷884| 欧美日韩一区不卡| 中文字幕一区在线观看| 一本一本大道香蕉久在线精品| 一区二区三区在线视频播放| 国产一区欧美二区| 中文字幕第一区第二区| 色综合色综合色综合| 亚洲成a人片综合在线| 精品少妇一区二区| 99久久99久久综合| 日日摸夜夜添夜夜添国产精品| 日韩女优av电影| 99久久精品久久久久久清纯| 亚洲福中文字幕伊人影院| 精品日韩一区二区三区免费视频| 成人午夜激情视频| 国产亚洲一区字幕| 久久国产精品无码网站| 国产精品成人一区二区艾草 | 久久精品国产精品亚洲精品| 欧美激情一区二区三区蜜桃视频 | 久久品道一品道久久精品| 大陆成人av片| 午夜精品久久久久久久| 国产午夜精品一区二区三区嫩草 | 91麻豆蜜桃一区二区三区| 日本美女一区二区三区视频| 欧美激情综合五月色丁香小说| 欧美日本视频在线| 不卡在线观看av| 久久精品国产澳门| 一区二区三区在线视频免费观看| 精品视频在线免费看| 国内外成人在线| 日韩精品欧美成人高清一区二区| 国产欧美日产一区| 日韩三级.com| 欧美日韩免费高清一区色橹橹 | 欧美在线观看一区| 丁香另类激情小说| 日韩国产在线一| 亚洲一区在线观看网站| 国产精品高潮呻吟| 久久久久成人黄色影片| 精品国产髙清在线看国产毛片| 91黄色在线观看| 一本久久综合亚洲鲁鲁五月天| 国产suv精品一区二区6| 精品一区二区三区在线播放视频| 丝袜诱惑制服诱惑色一区在线观看 | av在线这里只有精品| 国产酒店精品激情| 久久久久久久久久久久电影| 欧美一区二区三区色| 欧美乱熟臀69xxxxxx| 日本一区免费视频| 国产日韩欧美a| 亚洲综合色成人| 91精品国产色综合久久| 欧美性做爰猛烈叫床潮| 色老综合老女人久久久| 97se亚洲国产综合在线| 97精品久久久午夜一区二区三区 | 国产视频不卡一区| 久久综合九色综合97婷婷女人| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲一二三区视频在线观看| 一区二区三区欧美亚洲| 亚洲综合色成人| 日本人妖一区二区| 精品无人码麻豆乱码1区2区| 精品一区二区在线播放| 国产成人午夜高潮毛片| 成人美女在线观看| 91麻豆蜜桃一区二区三区| 精品视频免费在线| 日韩欧美在线影院| 国产拍欧美日韩视频二区| 亚洲国产成人午夜在线一区 | 精品国产精品一区二区夜夜嗨| 国产亚洲欧美日韩日本| 一区在线播放视频| 午夜精品久久久久久久99水蜜桃| 丝瓜av网站精品一区二区| 黄色日韩网站视频| av午夜一区麻豆| 欧美精品在欧美一区二区少妇| 欧美成人bangbros| 国产精品毛片高清在线完整版| 一区二区三区在线观看动漫| 午夜电影久久久| 国产精品白丝jk白祙喷水网站| 色婷婷综合久色| 欧美成人猛片aaaaaaa| 国产精品黄色在线观看| 午夜国产不卡在线观看视频| 激情偷乱视频一区二区三区| 日本福利一区二区| 精品久久一区二区三区| 一区二区三区欧美久久| 久久99精品久久久久久久久久久久| 国产高清精品久久久久| 欧美精品在线观看播放| 中文字幕免费不卡| 日本成人在线网站| 91成人免费在线视频| 国产日本欧洲亚洲| 免费精品视频在线| 91久久人澡人人添人人爽欧美|