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

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

?? d12_driverdevice.cpp

?? USB d12 驅動
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//	Comments:
//

NTSTATUS D12_DriverDevice::Close(KIrp I)
{
	NTSTATUS status;

	t << "Entering D12_DriverDevice::Close, " << I << EOL;

// TODO: Add driver specific close handling code here

	// Generally a close IRP is targeted at our FDO, so we don't need
	// to pass it down to the PDO.  We have found for some devices, the
	// PDO is not expecting this Irp and returns an error code.
	// The default wizard code, therefore completes the Irp here using
	// PnpComplete().  The following commented code could be used instead
	// of PnpComplete() to pass the Irp to the PDO, which would complete it.
	//
//	I.ForceReuseOfCurrentStackLocationInCalldown();
//	status = m_Lower.PnpCall(this, I);

	status = I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);

	t << "D12_DriverDevice::Close Status " << (ULONG)status << EOL;

    return status;
}

////////////////////////////////////////////////////////////////////////
//  D12_DriverDevice::Cleanup
//
//	Routine Description:
//		Handler for IRP_MJ_CLEANUP	
//
//	Parameters:
//		I - Current IRP
//
//	Return Value:
//		NTSTATUS - Result code
//
//	Comments:
//

NTSTATUS D12_DriverDevice::CleanUp(KIrp I)
{
	t << "Entering CleanUp, " << I << EOL;

// TODO:	Insert your code to respond to the CLEANUP message.
	return I.PnpComplete(this, STATUS_SUCCESS);
}

////////////////////////////////////////////////////////////////////////
//  D12_DriverDevice::DeviceControl
//
//	Routine Description:
//		Handler for IRP_MJ_DEVICE_CONTROL
//
//	Parameters:
//		I - Current IRP
// 
//	Return Value:
//		None
//
//	Comments:
//		This routine is the first handler for Device Control requests.
//		The KPnpDevice class handles restricting IRP flow
//		if the device is stopping or being removed.
//

NTSTATUS D12_DriverDevice::DeviceControl(KIrp I) 
{
	NTSTATUS status;

	t << "Entering D12_DriverDevice::Device Control, " << I << EOL;
	switch (I.IoctlCode())
	{
		case D12_DRIVER_READ:
			status = D12_DRIVER_READ_Handler(I);
			break;

		case D12_DRIVER_WRITE:
			status = D12_DRIVER_WRITE_Handler(I);
			break;
		case D12_DRIVER_BULK_IN:
			status = D12_DRIVER_BULK_IN_Handler(I);
			break;

		case D12_DRIVER_BULK_OUT:
			status = D12_DRIVER_BULK_OUT_Handler(I);
			break;
		case D12_DRIVER_VENDOR_REQUEST:
			status = D12_DRIVER_VENDOR_REQUEST_Handler(I);
			break;

		default:
			// Unrecognized IOCTL request
			status = STATUS_INVALID_PARAMETER;
			break;
	}

	// If the IRP's IOCTL handler deferred processing using some driver
	// specific scheme, the status variable is set to STATUS_PENDING.
	// In this case we simply return that status, and the IRP will be
	// completed later.  Otherwise, complete the IRP using the status
	// returned by the IOCTL handler.
	if (status == STATUS_PENDING)
	{
		return status;
	}
	else
	{
		return I.PnpComplete(this, status);
	}
}

////////////////////////////////////////////////////////////////////////
//  D12_DriverDevice::D12_DRIVER_READ_Handler
//
//	Routine Description:
//		Handler for IO Control Code D12_DRIVER_READ
//
//	Parameters:
//		I - IRP containing IOCTL request
//
//	Return Value:
//		NTSTATUS - Status code indicating success or failure
//
//	Comments:
//		This routine implements the D12_DRIVER_READ function.
//		This routine runs at passive level.
//

NTSTATUS D12_DriverDevice::D12_DRIVER_READ_Handler(KIrp I)
{
	PURB pUrb;
	NTSTATUS status;

	t << "Entering D12_DriverDevice::D12_DRIVER_READ_Handler, " << I << EOL;
// TODO:	Verify that the input parameters are correct
//			If not, return STATUS_INVALID_PARAMETER

// TODO:	Handle the the D12_DRIVER_READ request, or 
//			defer the processing of the IRP (i.e. by queuing) and set
//			status to STATUS_PENDING.

// TODO:	Assuming that the request was handled here. Set I.Information
//			to indicate how much data to copy back to the user.
	// Always ok to read 0 elements.
	if (I.IoctlOutputBufferSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}

	// Declare a memory object

    ULONG dwTotalSize = I.IoctlInputBufferSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2In.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}
    ULONG dwBytesRead = 0;

	pUrb = m_Endpoint1In.BuildInterruptTransfer(
				(unsigned char *)I.IoctlBuffer(),		// transfer buffer
				I.IoctlInputBufferSize(),								// transfer buffer size
				TRUE,							// Short Ok
				NULL,							// link urb
				NULL							// new urb
				);

	if ( pUrb != NULL)
	{
	    // Submit the URB to our USB device, synchronously - say less is OK
//		pUrb->UrbBulkOrInterruptTransfer.TransferFlags =
//				(USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK);

        status = m_Endpoint1In.SubmitUrb(pUrb, NULL, NULL,300);

        if ( NT_SUCCESS(status) ) 
        {
	            dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;

				if (dwBytesRead > 0) 
					t << "Read got " << dwTotalSize	<< " bytes from USB\n";
	    }

		delete pUrb;
	}
	else
	{
		status=STATUS_INSUFFICIENT_RESOURCES;
	}

	
    I.Information() = dwBytesRead;
    return status;
}

////////////////////////////////////////////////////////////////////////
//  D12_DriverDevice::D12_DRIVER_WRITE_Handler
//
//	Routine Description:
//		Handler for IO Control Code D12_DRIVER_WRITE
//
//	Parameters:
//		I - IRP containing IOCTL request
//
//	Return Value:
//		NTSTATUS - Status code indicating success or failure
//
//	Comments:
//		This routine implements the D12_DRIVER_WRITE function.
//		This routine runs at passive level.
//

NTSTATUS D12_DriverDevice::D12_DRIVER_WRITE_Handler(KIrp I)
{
	PURB pUrb;
	NTSTATUS status;

	t << "Entering D12_DriverDevice::D12_DRIVER_WRITE_Handler, " << I << EOL;
// TODO:	Verify that the input parameters are correct
//			If not, return STATUS_INVALID_PARAMETER

// TODO:	Handle the the D12_DRIVER_WRITE request, or 
//			defer the processing of the IRP (i.e. by queuing) and set
//			status to STATUS_PENDING.

// TODO:	Assuming that the request was handled here. Set I.Information
//			to indicate how much data to copy back to the user.
	if (I.IoctlOutputBufferSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}

	// Declare a memory object

    ULONG dwTotalSize = I.IoctlOutputBufferSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2In.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}
    ULONG dwBytesRead = 0;

	pUrb = m_Endpoint1Out.BuildInterruptTransfer(
				(unsigned char *)I.IoctlBuffer(),		// transfer buffer
				I.IoctlOutputBufferSize(),								// transfer buffer size
				TRUE,							// Short Ok
				NULL,							// link urb
				NULL							// new urb
				);

	if ( pUrb != NULL)
	{
	    // Submit the URB to our USB device, synchronously - say less is OK

        status = m_Endpoint1Out.SubmitUrb(pUrb, NULL, NULL);

        if ( NT_SUCCESS(status) ) 
        {
	            dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;

				if (dwBytesRead > 0) 
					t << "Write got " << dwTotalSize	<< " bytes from USB\n";
	    }

		delete pUrb;
	}
	else
	{
		status=STATUS_INSUFFICIENT_RESOURCES;
	}

	
    I.Information() = dwBytesRead;
    return status;
}



VOID D12_DriverDevice::Cancel(KIrp I)
{
	t << "Cancel(KIrp I)\n";
	if ( (PIRP)I == CurrentIrp() )
	{
		CurrentIrp() = NULL;
		CancelSpinLock::Release(I.CancelIrql());
		I.Information() = 0;
		I.PnpComplete(this, STATUS_CANCELLED);
		IncrementOutstandingRequestCount();
		m_pItem.Queue(LinkTo(Workitem), this);
	}
	else
		CancelSpinLock::Release(I.CancelIrql());
}

VOID D12_DriverDevice::Workitem()
{
	m_Endpoint1In.Abort();
	m_Endpoint1Out.Abort();
	m_Endpoint2In.Abort();
	m_Endpoint2Out.Abort();
	DecrementOutstandingRequestCount();
}


NTSTATUS D12_DriverDevice::OnQueryCapabilities(KIrp I)
{
	I.CopyParametersDown();
	I.SetCompletionRoutine(LinkTo(OnQueryCapabilitiesComplete), this);
	return m_Lower.PnpCall(this, I);
}


NTSTATUS D12_DriverDevice::OnQueryCapabilitiesComplete(KIrp I)
{
	t << "Capabilities Completion routine\n";
	if (I->PendingReturned)
		I.MarkPending();
  	I.DeviceCapabilities()->SurpriseRemovalOK = TRUE;
	return STATUS_SUCCESS;
}

NTSTATUS D12_DriverDevice::D12_DRIVER_BULK_OUT_Handler(KIrp I)
{
	PURB pUrb;
	NTSTATUS status;

	t << "D12_DRIVER_BULK_OUT_Handler, " << I << EOL ;
	if (I.IoctlOutputBufferSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}

	// Declare a memory object

    ULONG dwTotalSize = I.IoctlOutputBufferSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2In.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}
    ULONG dwBytesRead = 0;


	pUrb = m_Endpoint2Out.BuildBulkTransfer(
				(unsigned char *)I.IoctlBuffer(),		// transfer buffer
				I.IoctlOutputBufferSize(),		// transfer buffer size
				FALSE,							// Device To Host
				NULL,							// link urb
				FALSE,							// Short Ok
				NULL							// new urb
				);

	if ( pUrb != NULL)
	{
	    // Submit the URB to our USB device, synchronously - say less is OK

        status = m_Endpoint2Out.SubmitUrb(pUrb, NULL, NULL);

        if ( NT_SUCCESS(status) ) 
        {
	            dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;

				if (dwBytesRead > 0) 
					t << "BULK_OUT got " << dwTotalSize	<< " bytes from USB\n";
	    }

		delete pUrb;
	}
	else
	{
		status=STATUS_INSUFFICIENT_RESOURCES;
	}

	
    I.Information() = dwBytesRead;
    return status;
}



NTSTATUS D12_DriverDevice::D12_DRIVER_VENDOR_REQUEST_Handler(KIrp I)
{
	PURB pUrb;
	NTSTATUS status;
//	UCHAR buffer1[]={0,0,0,0x20,0,0x80};

	t << "D12_DRIVER_VENDOR_REQUEST_Handler, " << I << EOL;
	pUrb = m_Lower.BuildVendorRequest(
				(unsigned char *)I.IoctlBuffer(),		// transfer buffer
				I.IoctlInputBufferSize(),				// transfer buffer size
//				buffer1,
//				6,
				0,										// ReservedBits
				0x0c,									// Request
				0,										// Value
				0,										// Direction
				0,										// bShortOk
				NULL,									// Link
				0x0471,									// wIndex
				URB_FUNCTION_VENDOR_DEVICE,				// Function
				NULL									//pUrb 
				);

	if ( pUrb == NULL )
	{
		status = STATUS_INSUFFICIENT_RESOURCES;
	}
	else
	{
		// submit the URB to USBD
		status = m_Lower.SubmitUrb(pUrb);
		delete pUrb;
	}

	return status;
}

NTSTATUS D12_DriverDevice::D12_DRIVER_BULK_IN_Handler(KIrp I)
{
	PURB pUrb;
	NTSTATUS status;
	t << "Entering DddDevice::BULK_IN, " << I << EOL;
// TODO:	Check the incoming request.  Replace "FALSE" in the following
//			line with a check that returns TRUE if the request is not valid.

	if (I.IoctlOutputBufferSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}

	// Declare a memory object

    ULONG dwTotalSize = I.IoctlInputBufferSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2In.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}
    ULONG dwBytesRead = 0;
	// Create an URB to do actual Bulk read from the pipe
	pUrb = m_Endpoint2In.BuildBulkTransfer(
				(unsigned char *)I.IoctlBuffer(),		// transfer buffer
				dwTotalSize,								// transfer buffer size
				TRUE,							// Host To Device
				NULL,							// link urb
				FALSE,							// Short Ok
				NULL						// new urb
				);

	if ( pUrb != NULL)
	{
	    // Submit the URB to our USB device, synchronously - say less is OK
//		pUrb->UrbBulkOrInterruptTransfer.TransferFlags =
//				(USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK);

        status = m_Endpoint1In.SubmitUrb(pUrb, NULL, NULL,300);

        if ( NT_SUCCESS(status) ) 
        {
	            dwBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;

				if (dwBytesRead > 0) 
					t << "BULK_IN got " << dwTotalSize	<< " bytes from USB\n";
	    }

		delete pUrb;
	}
	else
	{
		status=STATUS_INSUFFICIENT_RESOURCES;
	}

	
    I.Information() = dwBytesRead;
    return status;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产女同互慰高潮91漫画| 亚洲精品一二三四区| 国产精品婷婷午夜在线观看| 夜夜夜精品看看| 国产精品乡下勾搭老头1| 欧美色精品在线视频| 国产精品无遮挡| 国产在线精品一区二区夜色| 欧美日韩激情一区二区三区| 成人免费视频在线观看| 国产精品18久久久久| 日韩片之四级片| 水野朝阳av一区二区三区| 91蜜桃传媒精品久久久一区二区| 久久精品一区二区三区av| 久久国产精品免费| 欧美一区二区啪啪| 日韩精品福利网| 欧美久久婷婷综合色| 亚洲国产婷婷综合在线精品| 色偷偷久久一区二区三区| 国产精品乱码人人做人人爱| 国产成人av自拍| 中文字幕乱码久久午夜不卡| 国产另类ts人妖一区二区| 欧美精品一区二区三区视频| 蓝色福利精品导航| 欧美电影精品一区二区| 日韩高清国产一区在线| 欧美日韩国产另类不卡| 亚洲一区二区在线免费看| 91久久精品一区二区| 国产精品剧情在线亚洲| 国产精品一区免费在线观看| 欧美精品一区二区三区在线 | 欧美日韩国产一级片| 亚洲精品成人悠悠色影视| 成人激情文学综合网| 国产欧美久久久精品影院| 国产成人精品免费在线| 国产日韩欧美高清| 成人国产一区二区三区精品| 国产精品久久久久桃色tv| 国产成人免费视频网站| 国产偷国产偷亚洲高清人白洁| 国产精品资源网| 2021国产精品久久精品| 国产盗摄女厕一区二区三区| 日本一区二区三区在线观看| 福利一区二区在线观看| 亚洲欧美乱综合| 欧美妇女性影城| 久久精品久久精品| 国产精品福利影院| 欧美性一级生活| 麻豆专区一区二区三区四区五区| 久久综合资源网| 99久久久精品免费观看国产蜜| 伊人婷婷欧美激情| 日韩精品在线看片z| 盗摄精品av一区二区三区| 亚洲欧美一区二区三区孕妇| 69av一区二区三区| 国产99久久久国产精品免费看| 一区2区3区在线看| 日韩免费观看高清完整版在线观看| 国产乱码精品一区二区三区忘忧草 | 97国产一区二区| 日韩中文字幕一区二区三区| 26uuu国产在线精品一区二区| 91丝袜高跟美女视频| 蜜臀av性久久久久av蜜臀妖精| 国产精品久久久久毛片软件| 欧美伦理视频网站| 成人性色生活片| 日韩精品视频网站| 国产精品高潮呻吟久久| 日韩色在线观看| 91在线观看下载| 美脚の诱脚舐め脚责91| 亚洲视频一区在线观看| 久久影院午夜片一区| 欧美日产在线观看| 成人app下载| 五月天久久比比资源色| 日本一区二区不卡视频| 日韩免费看网站| 欧美亚洲禁片免费| 成人听书哪个软件好| 日精品一区二区| 伊人色综合久久天天人手人婷| 欧美一区二区在线免费播放| 日本乱人伦aⅴ精品| 丰满亚洲少妇av| 久久精品噜噜噜成人av农村| 亚洲精品中文在线观看| 国产亚洲一区二区三区四区 | 久久婷婷成人综合色| 欧美日韩精品一区二区三区蜜桃 | 国产一区二区三区四区五区入口| 亚洲h在线观看| 亚洲精品国产无天堂网2021| 国产女人aaa级久久久级 | 亚洲综合一区二区三区| 国产午夜精品理论片a级大结局| 日韩网站在线看片你懂的| 欧美精品一卡二卡| 欧美人体做爰大胆视频| 91免费观看国产| 91天堂素人约啪| 欧美日韩国产综合一区二区三区| 99在线精品免费| 成人av在线播放网址| 国产成人99久久亚洲综合精品| 国产一区三区三区| 国产乱码一区二区三区| 国产成a人无v码亚洲福利| 国产精品一区久久久久| 国产精品主播直播| 国产美女久久久久| 国产成人精品亚洲777人妖| 国产精品中文字幕一区二区三区| 国产精品一区二区在线观看不卡| 国产一区二区女| 国产jizzjizz一区二区| 成人国产精品免费观看视频| 波多野结衣欧美| 色婷婷亚洲综合| 欧美日韩性生活| 欧美一区二区在线观看| 26uuu精品一区二区在线观看| 亚洲精品videosex极品| 亚洲一级电影视频| 亚欧色一区w666天堂| 久久成人免费电影| 成人午夜视频网站| 欧美亚洲动漫精品| 欧美大片国产精品| 国产精品理伦片| 亚洲福中文字幕伊人影院| 久久精品国产精品青草| 福利一区在线观看| 欧洲av一区二区嗯嗯嗯啊| 91精品中文字幕一区二区三区| 精品99999| 亚洲一区二区成人在线观看| 青青草97国产精品免费观看无弹窗版| 黄一区二区三区| 色成年激情久久综合| 日韩三级高清在线| 最新国产成人在线观看| 午夜精品久久一牛影视| 国产麻豆成人精品| 欧洲精品一区二区三区在线观看| 欧美一区二区播放| 国产精品热久久久久夜色精品三区| 亚洲激情图片一区| 国产一区二区三区av电影| 在线观看日韩毛片| 国产嫩草影院久久久久| 亚洲国产精品一区二区久久恐怖片| 狠狠色综合日日| 成人白浆超碰人人人人| 在线观看国产一区二区| 久久理论电影网| 日日嗨av一区二区三区四区| www.av亚洲| 久久新电视剧免费观看| 亚洲成av人片在线| av激情亚洲男人天堂| 欧美一区中文字幕| 亚洲欧美另类在线| 丁香五精品蜜臀久久久久99网站| 在线不卡中文字幕| 亚洲精品ww久久久久久p站| 国产精品一区免费在线观看| 欧美精品久久一区二区三区| 综合精品久久久| 成人精品国产一区二区4080| 日韩欧美的一区二区| 午夜精彩视频在线观看不卡| 99国产精品久久久久久久久久久| 精品1区2区在线观看| 亚洲国产成人高清精品| 一本久久精品一区二区| 国产日韩欧美精品电影三级在线| 久久国产欧美日韩精品| 色婷婷av一区二区三区软件| 国产免费久久精品| 日本欧美在线观看| 欧美精品久久久久久久多人混战 | 欧美性猛片xxxx免费看久爱| 国产精品色婷婷久久58| 黄色成人免费在线| 日韩你懂的在线观看| 日产国产欧美视频一区精品| 欧美日韩久久久| 午夜精品久久久久久| 精品久久久久香蕉网| 日韩av电影天堂|