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

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

?? readwrite.cpp

?? 智能卡的讀寫程序
?? CPP
字號:
// Read/Write request processors for Smart_Card driver
// Copyright (C) 1999, 2000 by Walter Oney
// All rights reserved

#include "stddcls.h"
#include "driver.h"

#ifdef DBG
	#define MSGUSBSTRING(d,s,i) { \
		UNICODE_STRING sd; \
		if (i && NT_SUCCESS(GetStringDescriptor(d,i,&sd))) { \
			DbgPrint(s, sd.Buffer); \
			RtlFreeUnicodeString(&sd); \
		}}
#else
	#define MSGUSBSTRING(d,i,s)
#endif

VOID OnCancelReadWrite(PDEVICE_OBJECT fdo, PIRP Irp);

///////////////////////////////////////////////////////////////////////////////

#pragma PAGEDCODE
/*
NTSTATUS DispatchCleanup(PDEVICE_OBJECT fdo, PIRP Irp)
	{							// DispatchCleanup
	PAGED_CODE();
	KdPrint((DRIVERNAME " - IRP_MJ_CLEANUP\n"));
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
	PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
	// TODO If you use multiple queues, code this instead:
	//	CleanupAllRequests(pdx->queues, arraysize(pdx->queues), stack->FileObject, STATUS_CANCELLED);
	CleanupRequests(&pdx->dqReadWrite, stack->FileObject, STATUS_CANCELLED);
	return CompleteRequest(Irp, STATUS_SUCCESS, 0);
	}							// DispatchCleanup
*/
///////////////////////////////////////////////////////////////////////////////

#pragma PAGEDCODE

NTSTATUS DispatchCreate(PDEVICE_OBJECT fdo, PIRP Irp)
	{							// DispatchCreate
	PAGED_CODE();
	KdPrint((DRIVERNAME " - IRP_MJ_CREATE\n"));
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

	PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);

	NTSTATUS status = STATUS_SUCCESS;

	if (NT_SUCCESS(status))
		{						// okay to open
		if (InterlockedIncrement(&pdx->handles) == 1)
			{					// first open handle
			}					// okay to open
		}					// first open handle
	return CompleteRequest(Irp, status, 0);
	}							// DispatchCreate

///////////////////////////////////////////////////////////////////////////////

#pragma PAGEDCODE

NTSTATUS DispatchClose(PDEVICE_OBJECT fdo, PIRP Irp)
	{							// DispatchClose
	PAGED_CODE();
	KdPrint((DRIVERNAME " - IRP_MJ_CLOSE\n"));
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
	PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
	if (InterlockedDecrement(&pdx->handles) == 0)
		{						// no more open handles
		}						// no more open handles

	return CompleteRequest(Irp, STATUS_SUCCESS, 0);
	}							// DispatchClose

///////////////////////////////////////////////////////////////////////////////
// TODO If you use separate queues for reads and writes, you need to arrange to
// call StartPacket and CancelRequests with the right queue argument. The easiest
// way to do that is to have separate dispatch and cancel functions for IRP_MJ_READ and
// IRP_MJ_WRITE.

#pragma PAGEDCODE

NTSTATUS DispatchReadWrite(PDEVICE_OBJECT fdo, PIRP Irp)
	{							// DispatchReadWrite
	PAGED_CODE();
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
	return STATUS_SUCCESS;
	// TODO Write this routine
	}							// DispatchReadWrite

///////////////////////////////////////////////////////////////////////////////

#pragma PAGEDCODE

NTSTATUS GetStringDescriptor(PDEVICE_OBJECT fdo, UCHAR istring, PUNICODE_STRING s)
	{							// GetStringDescriptor
	NTSTATUS status;
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
	URB urb;

	UCHAR data[256];			// maximum-length buffer

	// If this is the first time here, read string descriptor zero and arbitrarily select
	// the first language identifer as the one to use in subsequent get-descriptor calls.

	if (!pdx->langid)
		{						// determine default language id
		UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE,
			0, 0, data, NULL, sizeof(data), NULL);
		status = SendAwaitUrb(fdo, &urb);
		if (!NT_SUCCESS(status))
			return status;
		pdx->langid = *(LANGID*)(data + 2);
		}						// determine default language id

	// Fetch the designated string descriptor.

	UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_STRING_DESCRIPTOR_TYPE,
		istring, pdx->langid, data, NULL, sizeof(data), NULL);
	status = SendAwaitUrb(fdo, &urb);
	if (!NT_SUCCESS(status))
		return status;

	ULONG nchars = (data[0] - sizeof(WCHAR)) / sizeof(WCHAR);
	if (nchars > 127)
		nchars = 127;
	PWSTR p = (PWSTR) ExAllocatePool(PagedPool, (nchars + 1) * sizeof(WCHAR));
	if (!p)
		return STATUS_INSUFFICIENT_RESOURCES;

	memcpy(p, data + 2, nchars * sizeof(WCHAR));
	p[nchars] = 0;

	s->Length = (USHORT) (sizeof(WCHAR) * nchars);
	s->MaximumLength = (USHORT) ((sizeof(WCHAR) * nchars) + sizeof(WCHAR));
	s->Buffer = p;

	return STATUS_SUCCESS;
	}							// GetStringDescriptor

///////////////////////////////////////////////////////////////////////////////

NTSTATUS SendAwaitUrb(PDEVICE_OBJECT fdo, PURB urb)
	{							// SendAwaitUrb
	PAGED_CODE();
	ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

	KEVENT event;
	KeInitializeEvent(&event, NotificationEvent, FALSE);

	IO_STATUS_BLOCK iostatus;
	PIRP Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
		pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event, &iostatus);

	if (!Irp)
		{
		KdPrint((DRIVERNAME " - Unable to allocate IRP for sending URB\n"));
		return STATUS_INSUFFICIENT_RESOURCES;
		}

	PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
	stack->Parameters.Others.Argument1 = (PVOID) urb;
	NTSTATUS status = IoCallDriver(pdx->LowerDeviceObject, Irp);
	if (status == STATUS_PENDING)
		{
		KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
		status = iostatus.Status;
		}
	return status;
	}							// SendAwaitUrb

///////////////////////////////////////////////////////////////////////////////

NTSTATUS StartDevice(PDEVICE_OBJECT fdo)
	{							// StartDevice
	PAGED_CODE();
	NTSTATUS status;
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

	URB urb;					// URB for use in this subroutine

	// Read our device descriptor. The only thing this skeleton does with it is print
	// debugging messages with the string descriptors.

	UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_DEVICE_DESCRIPTOR_TYPE,
		0, 0, &pdx->dd, NULL, sizeof(pdx->dd), NULL);
	status = SendAwaitUrb(fdo, &urb);
	if (!NT_SUCCESS(status))
		{
		KdPrint((DRIVERNAME " - Error %X trying to read device descriptor\n", status));
		return status;
		}

	MSGUSBSTRING(fdo, DRIVERNAME " - Configuring device from %ws\n", pdx->dd.iManufacturer);
	MSGUSBSTRING(fdo, DRIVERNAME " - Product is %ws\n", pdx->dd.iProduct);
	MSGUSBSTRING(fdo, DRIVERNAME " - Serial number is %ws\n", pdx->dd.iSerialNumber);

	// Read the descriptor of the first configuration. This requires two steps. The first step
	// reads the fixed-size configuration descriptor alone. The second step reads the
	// configuration descriptor plus all imbedded interface and endpoint descriptors.

	USB_CONFIGURATION_DESCRIPTOR tcd;
	UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_CONFIGURATION_DESCRIPTOR_TYPE,
		0, 0, &tcd, NULL, sizeof(tcd), NULL);
	status = SendAwaitUrb(fdo, &urb);
	if (!NT_SUCCESS(status))
		{
		KdPrint((DRIVERNAME " - Error %X trying to read configuration descriptor 1\n", status));
		return status;
		}

	ULONG size = tcd.wTotalLength;
	PUSB_CONFIGURATION_DESCRIPTOR pcd = (PUSB_CONFIGURATION_DESCRIPTOR) ExAllocatePool(NonPagedPool, size);
	if (!pcd)
		{
		KdPrint((DRIVERNAME " - Unable to allocate %X bytes for configuration descriptor\n", size));
		return STATUS_INSUFFICIENT_RESOURCES;
		}

	__try
		{
		UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_CONFIGURATION_DESCRIPTOR_TYPE,
			0, 0, pcd, NULL, size, NULL);
		status = SendAwaitUrb(fdo, &urb);
		if (!NT_SUCCESS(status))
			{
			KdPrint((DRIVERNAME " - Error %X trying to read configuration descriptor 1\n", status));
			return status;
			}
                                   
		MSGUSBSTRING(fdo, DRIVERNAME " - Selecting configuration named %ws\n", pcd->iConfiguration);

		// Locate the descriptor for the one and only interface we expect to find

		PUSB_INTERFACE_DESCRIPTOR pid = USBD_ParseConfigurationDescriptorEx(pcd, pcd,
			-1, -1, -1, -1, -1);
		ASSERT(pid);
                                   
		MSGUSBSTRING(fdo, DRIVERNAME " - Selecting interface named %ws\n", pid->iInterface);

		// Create a URB to use in selecting a configuration.

		USBD_INTERFACE_LIST_ENTRY interfaces[2] = {
			{pid, NULL},
			{NULL, NULL},		// fence to terminate the array
			};

		PURB selurb = USBD_CreateConfigurationRequestEx(pcd, interfaces);
		if (!selurb)
			{
			KdPrint((DRIVERNAME " - Unable to create configuration request\n"));
			return STATUS_INSUFFICIENT_RESOURCES;
			}

		__try
			{

			// Verify that the interface describes exactly the endpoints we expect

			if (pid->bNumEndpoints != 3)
				{
				KdPrint((DRIVERNAME " - %d is the wrong number of endpoints\n", pid->bNumEndpoints));
				return STATUS_DEVICE_CONFIGURATION_ERROR;
				}

			PUSB_ENDPOINT_DESCRIPTOR ped = (PUSB_ENDPOINT_DESCRIPTOR) pid;
			ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd, tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);
			if (!ped || ped->bEndpointAddress != 0x86 || ped->bmAttributes != USB_ENDPOINT_TYPE_INTERRUPT || ped->wMaxPacketSize != 8)
				{
				KdPrint((DRIVERNAME " - Endpoint has wrong attributes\n"));
				return STATUS_DEVICE_CONFIGURATION_ERROR;
				}
			++ped;
			ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd, tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);
			if (!ped || ped->bEndpointAddress != 0x87 || ped->bmAttributes != USB_ENDPOINT_TYPE_BULK || ped->wMaxPacketSize != 64)
				{
				KdPrint((DRIVERNAME " - Endpoint has wrong attributes\n"));
				return STATUS_DEVICE_CONFIGURATION_ERROR;
				}
			++ped;
			ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd, tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);
			if (!ped || ped->bEndpointAddress != 0x8 || ped->bmAttributes != USB_ENDPOINT_TYPE_BULK || ped->wMaxPacketSize != 64)
				{
				KdPrint((DRIVERNAME " - Endpoint has wrong attributes\n"));
				return STATUS_DEVICE_CONFIGURATION_ERROR;
				}
			++ped;

			PUSBD_INTERFACE_INFORMATION pii = interfaces[0].Interface;

			// Initialize the maximum transfer size for each of the endpoints
			// TODO remove these statements if you're happy with the default
			// value provided by USBD.

			pii->Pipes[0].MaximumTransferSize = 512;
			pii->Pipes[1].MaximumTransferSize = 1024;
			pii->Pipes[2].MaximumTransferSize = 1024;

			// Submit the set-configuration request

			status = SendAwaitUrb(fdo, selurb);
			if (!NT_SUCCESS(status))
				{
				KdPrint((DRIVERNAME " - Error %X trying to select configuration\n", status));
				return status;
				}

			// Save the configuration and pipe handles

			pdx->hconfig = selurb->UrbSelectConfiguration.ConfigurationHandle;
			pdx->INT_IN_ENDPOINT6 = pii->Pipes[0].PipeHandle;
			pdx->BULK_IN_ENDPOINT7 = pii->Pipes[1].PipeHandle;
			pdx->BULK_OUT_ENDPOINT8 = pii->Pipes[2].PipeHandle;

			// TODO If you have an interrupt endpoint, now would be the time to
			// create an IRP and URB with which to poll it continuously

			// Transfer ownership of the configuration descriptor to the device extension
			
			pdx->pcd = pcd;
			pcd = NULL;
			}
		__finally
			{
			ExFreePool(selurb);
			}

		}
	__finally
		{
		if (pcd)
			ExFreePool(pcd);
		}

	return STATUS_SUCCESS;
	}							// StartDevice

///////////////////////////////////////////////////////////////////////////////

#pragma PAGEDCODE

VOID StopDevice(IN PDEVICE_OBJECT fdo, BOOLEAN oktouch /* = FALSE */)
	{							// StopDevice
	PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

	// If it's okay to touch our hardware (i.e., we're processing an IRP_MN_STOP_DEVICE),
	// deconfigure the device.
	
	if (oktouch)
		{						// deconfigure device
		URB urb;
		UsbBuildSelectConfigurationRequest(&urb, sizeof(_URB_SELECT_CONFIGURATION), NULL);
		NTSTATUS status = SendAwaitUrb(fdo, &urb);
		if (!NT_SUCCESS(status))
			KdPrint((DRIVERNAME " - Error %X trying to deconfigure device\n", status));
		}						// deconfigure device

	if (pdx->pcd)
		ExFreePool(pdx->pcd);
	pdx->pcd = NULL;
	}							// StopDevice

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产一区二区| 亚洲综合自拍偷拍| 日本高清不卡一区| 九九精品一区二区| 美国一区二区三区在线播放| 亚洲a一区二区| 亚洲激情六月丁香| 亚洲欧洲日韩一区二区三区| 久久久噜噜噜久久人人看 | 亚洲人成小说网站色在线| 久久精子c满五个校花| 日韩女优制服丝袜电影| 欧美日韩免费电影| 69堂成人精品免费视频| 91精品国产色综合久久不卡蜜臀 | 91黄色激情网站| 久久久不卡影院| 久久精品国产亚洲a| 欧美日韩一级二级| 在线综合亚洲欧美在线视频| 亚洲日本欧美天堂| 亚洲国产综合91精品麻豆| 依依成人综合视频| 白白色 亚洲乱淫| 99精品黄色片免费大全| 色乱码一区二区三区88| 国产精品卡一卡二| 五月天一区二区| 国产一区二区三区在线观看免费| 国产在线播放一区二区三区| 日韩午夜在线观看视频| 国产欧美日韩精品一区| 国产精品视频yy9299一区| 亚洲国产视频在线| 欧洲精品中文字幕| 精品久久久久久久久久久院品网| 日本一区二区高清| 一区二区三区**美女毛片| 99久久综合国产精品| 国产精品女同互慰在线看| 懂色av一区二区在线播放| 欧美图区在线视频| 国产日韩欧美精品在线| 国产传媒一区在线| 欧美一区二区福利视频| 蜜桃免费网站一区二区三区| 日韩精品一区二区三区四区| 国产中文字幕精品| 9191久久久久久久久久久| 天天影视色香欲综合网老头| 91精品国产免费| 国产一区二区三区四| 国产精品免费av| 在线日韩国产精品| 奇米精品一区二区三区四区| 在线一区二区三区做爰视频网站| 亚洲尤物在线视频观看| 不卡一区二区三区四区| 欧美大尺度电影在线| 久久 天天综合| 国产精品国产精品国产专区不蜜| 一本到一区二区三区| 国产精品色婷婷| 欧美亚洲国产一区二区三区 | 日韩小视频在线观看专区| 久久99久国产精品黄毛片色诱| 久久久久久久久免费| 97国产精品videossex| 偷拍一区二区三区| 国产欧美一区二区精品久导航 | bt欧美亚洲午夜电影天堂| 一区二区激情小说| 337p日本欧洲亚洲大胆精品| 视频一区二区欧美| 欧洲中文字幕精品| 经典三级一区二区| 日韩欧美成人激情| 91黄色免费版| 国产jizzjizz一区二区| 午夜精品123| 最新热久久免费视频| 日韩欧美的一区| 在线免费视频一区二区| 国产精品1区2区| 国产欧美一区二区三区网站| 欧美日本国产视频| 丁香五精品蜜臀久久久久99网站| 日韩精品一二三四| 专区另类欧美日韩| 久久久久久久av麻豆果冻| 91精品欧美综合在线观看最新| 99久久精品免费| 国产一区二区三区观看| 日产精品久久久久久久性色| 欧美一级夜夜爽| 在线观看日韩高清av| 成人一区二区视频| 亚洲资源中文字幕| 中文字幕中文乱码欧美一区二区| 亚洲精品一区二区三区四区高清| 狠狠色丁香九九婷婷综合五月| 夜夜爽夜夜爽精品视频| 中文字幕亚洲精品在线观看| 久久久久久久久97黄色工厂| 欧美电影免费观看高清完整版在| 欧美色图天堂网| 91国产精品成人| 在线亚洲高清视频| 91丝袜国产在线播放| 三级在线观看一区二区| 亚洲一区在线免费观看| 亚洲精品水蜜桃| 一区二区三区久久久| 一区二区三区中文在线| 亚洲激情综合网| 亚洲一级片在线观看| 亚洲另类在线制服丝袜| 一区二区三区不卡视频| 亚洲精品成人天堂一二三| 夜夜嗨av一区二区三区网页| 一区二区三区四区在线| 伊人夜夜躁av伊人久久| 亚洲成a人片综合在线| 亚洲成人自拍偷拍| 日本不卡高清视频| 美日韩一区二区| 国产一区二区三区日韩| 国产精品888| 99久久精品一区二区| 欧洲一区二区三区免费视频| 欧美午夜电影一区| 91精品黄色片免费大全| 欧美一区二区三区四区五区| 精品国产免费久久| 欧美激情艳妇裸体舞| 亚洲欧美日韩一区二区| 亚洲成人激情自拍| 青草av.久久免费一区| 国产麻豆午夜三级精品| 成人国产精品免费观看视频| 色婷婷精品大视频在线蜜桃视频| 欧美精品久久天天躁| 日本韩国精品在线| 日韩一区二区在线看片| 亚洲国产精品黑人久久久| 一区二区在线观看免费| 日韩激情一二三区| 国产成人自拍在线| 欧洲人成人精品| 国产亚洲成av人在线观看导航| 亚洲日本va午夜在线影院| 日韩在线观看一区二区| 国产成人在线免费| 欧美色综合久久| 国产欧美日韩不卡免费| 亚洲一区精品在线| 国产91在线观看| 欧美日韩精品综合在线| 国产日韩欧美综合一区| 亚洲1区2区3区4区| 成人综合在线观看| 欧美一区二区播放| 自拍偷自拍亚洲精品播放| 老汉av免费一区二区三区| 91在线观看高清| 欧美精品一区二区三区很污很色的 | 亚洲成人一区在线| 成人av电影在线播放| 欧美一区二区三区思思人| 中文乱码免费一区二区| 裸体健美xxxx欧美裸体表演| 日本精品视频一区二区| 国产色综合久久| 蜜桃av噜噜一区| 欧美日韩视频一区二区| 国产精品久久久久久久久快鸭 | 欧美三级在线看| 中文字幕亚洲一区二区va在线| 美国三级日本三级久久99| 欧美中文一区二区三区| 国产精品乱码一区二区三区软件 | 免费成人在线观看视频| 欧美在线视频全部完| 国产欧美精品国产国产专区| 精品亚洲成a人| 日韩免费一区二区| 性感美女极品91精品| 91国偷自产一区二区使用方法| 日韩毛片一二三区| 成人开心网精品视频| 久久蜜桃一区二区| 狠狠色丁香久久婷婷综合丁香| 日韩欧美电影在线| 久久精品噜噜噜成人88aⅴ | 韩国三级中文字幕hd久久精品| 91麻豆精品国产综合久久久久久| 一区二区高清在线| 欧美在线一二三四区| 亚洲午夜国产一区99re久久| 欧美性三三影院|