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

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

?? control.cpp

?? WDM驅動程序的范例程序
?? CPP
字號:
// Control.cpp -- Pending IOCTL support for GENERIC.SYS

// Copyright (C) 1999 by Walter Oney

// All rights reserved



#include "stddcls.h"

#include "driver.h"



VOID OnCancelPendingIoctl(PDEVICE_OBJECT junk, PIRP Irp);



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



#pragma PAGEDCODE



VOID AbortPendingIoctls(PGENERIC_EXTENSION pdx, NTSTATUS status)

	{							// AbortPendingIoctls

	PAGED_CODE();

	if (!(pdx->Flags & GENERIC_PENDING_IOCTLS))

		return;					// can't be anything to do

	InterlockedExchange(&pdx->IoctlAbortStatus, status);

	GenericCleanupControlRequests(pdx, status, NULL);

	}							// AbortPendingIoctls



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



#pragma LOCKEDCODE



GENERICAPI NTSTATUS GENERIC_EXPORT GenericCacheControlRequest(PGENERIC_EXTENSION pdx, PIRP Irp, PIRP* pIrp)

	{							// GenericCacheControlRequest

	ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);



	// Acquire the lock that guards pending IOCTL operations for this client



	KIRQL oldirql;

	KeAcquireSpinLock(&pdx->IoctlListLock, &oldirql);



	NTSTATUS status;



	if (*pIrp)

		status = STATUS_UNSUCCESSFUL;	// something already cached here

	else if (pdx->IoctlAbortStatus)

		status = pdx->IoctlAbortStatus;	// rejecting new IRPs for some reason

	else

		{						// try to cache IRP



		// Remember the IRP pointer cell and device extension pointers in DriverContext fields

		// within the IRP. This is how our cancel routine knows which lock to claim and which

		// pointer cell to nullify. It's important to set these fields *before* installing the

		// cancel pointer.



		Irp->Tail.Overlay.DriverContext[0] = (PVOID) pIrp;

		Irp->Tail.Overlay.DriverContext[1] = (PVOID) pdx;

		*pIrp = Irp;



		// Install a cancel routine and check for this IRP having already been

		// cancelled



		IoSetCancelRoutine(Irp, OnCancelPendingIoctl);

		if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))

			status = STATUS_CANCELLED;	// already cancelled



		// Put this IRP on our list of pending IOCTLs. Note that our cancel routine, 

		// if running, will be waiting for the spin lock before completing the IRP



		else

			{					// cache it

			IoMarkIrpPending(Irp);

			status = STATUS_PENDING;

			InsertTailList(&pdx->PendingIoctlList, &Irp->Tail.Overlay.ListEntry);

			}					// cache it

		}						// try to cache IRP



	KeReleaseSpinLock(&pdx->IoctlListLock, oldirql);

	return status;

	}							// GenericCacheControlRequest



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



#pragma PAGEDCODE



GENERICAPI VOID GENERIC_EXPORT GenericCleanupAllRequests(PGENERIC_EXTENSION pdx, PFILE_OBJECT fop, NTSTATUS status)

	{							// GenericCleanupAllRequests

	PAGED_CODE();

	CleanupAllRequests(pdx->queues, pdx->nqueues, fop, status);

	GenericCleanupControlRequests(pdx, status, fop);

	}							// GenericCleanupAllRequests



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



#pragma LOCKEDCODE



GENERICAPI VOID GENERIC_EXPORT GenericCleanupControlRequests(PGENERIC_EXTENSION pdx, NTSTATUS status, PFILE_OBJECT fop)

	{							// GenericCleanupControlRequests

	if (!(pdx->Flags & GENERIC_PENDING_IOCTLS))

		return;					// didn't signup for pending ioctl service!



	LIST_ENTRY cancellist;

	InitializeListHead(&cancellist);



	// Create a list of IRPs that belong to the same file object



	KIRQL oldirql;

	KeAcquireSpinLock(&pdx->IoctlListLock, &oldirql);



	PLIST_ENTRY first = &pdx->PendingIoctlList;

	PLIST_ENTRY next;



	for (next = first->Flink; next != first; )

		{						// for each queued IRP

		PIRP Irp = CONTAINING_RECORD(next, IRP, Tail.Overlay.ListEntry);

		PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);



		// Follow the chain to the next IRP now (so that the next iteration of

		// the loop is properly setup whether we dequeue this IRP or not)



		PLIST_ENTRY current = next;

		next = next->Flink;



		// Skip this IRP if it's not for the same file object as the

		// current IRP_MJ_CLEANUP.



		if (fop && stack->FileObject != fop)

			continue;			// not for same file object



		// Set the CancelRoutine pointer to NULL and remove the IRP from the

		// queue.



		if (!IoSetCancelRoutine(Irp, NULL))

			continue;			// being cancelled right this instant



		PIRP* pIrp = (PIRP*) Irp->Tail.Overlay.DriverContext[0];

		*pIrp = NULL;

		RemoveEntryList(current);

		InsertTailList(&cancellist, current);

		}						// for each queued IRP



	// Release the spin lock. We're about to undertake a potentially time-consuming

	// operation that might conceivably result in a deadlock if we keep the lock.



	KeReleaseSpinLock(&pdx->IoctlListLock, oldirql);



	// Complete the selected requests.



	while (!IsListEmpty(&cancellist))

		{						// cancel selected requests

		next = RemoveHeadList(&cancellist);

		PIRP Irp = CONTAINING_RECORD(next, IRP, Tail.Overlay.ListEntry);

		Irp->IoStatus.Status = STATUS_CANCELLED;

		IoCompleteRequest(Irp, IO_NO_INCREMENT);

		}						// cancel selected requests

	}							// GenericCleanupControlRequests



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



#pragma LOCKEDCODE



GENERICAPI PIRP GENERIC_EXPORT GenericUncacheControlRequest(PGENERIC_EXTENSION pdx, PIRP* pIrp)

	{							// GenericUncacheControlRequest

	ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);



	if (!(pdx->Flags & GENERIC_PENDING_IOCTLS))

		return NULL;

	

	KIRQL oldirql;

	KeAcquireSpinLock(&pdx->IoctlListLock, &oldirql);



	// Uncache the request. Once we claim the spin lock, it's not necessary to

	// further synchronize access to the pointer cell.



	PIRP Irp = *pIrp;

	*pIrp = NULL;



	if (Irp)

		{						// an IRP was cached



		// Clear the cancel pointer for this IRP. Since both we and the

		// completion routine use a spin lock, it cannot happen that this

		// IRP pointer is suddenly invalid but the cache pointer cell

		// wasn't already NULL.



		if (IoSetCancelRoutine(Irp, NULL))

			{					// uncache the IRP

			RemoveEntryList(&Irp->Tail.Overlay.ListEntry);

			}					// uncache the IRP

		else

			Irp = NULL;			// currently being cancelled

		}						// an IRP was cached



	KeReleaseSpinLock(&pdx->IoctlListLock, oldirql);

	

	return Irp;

	}							// GenericUncacheControlRequest



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



#pragma LOCKEDCODE



VOID OnCancelPendingIoctl(PDEVICE_OBJECT junk, PIRP Irp)

	{							// OnCancelPendingIoctl

	KIRQL oldirql = Irp->CancelIrql;

	IoReleaseCancelSpinLock(DISPATCH_LEVEL);



	// Remove the IRP from the pending IOCTL list. Also nullify the pointer cell

	// that points to this IRP. The following weird possibility exists:

	//	1.	Someone calls IoCancelIrp for this IRP.

	//	2.	Someone calls UncacheControlRequest for this pointer cell, and it

	//		gets to the point of calling IoSetCancelRoutine, whereupon it sees that

	//		IoCancelIrp has already nulled the cancel pointer. It releases the spin

	//		lock and returns NULL to its caller.

	//	3.	Someone calls CacheControlRequest for this pointer cell. It acquires the

	//		spin lock and sees that the pointer cell is NULL (from step 2), so it caches

	//		a new IRP and releases the spin lock.

	//	4.	We acquire the spin lock.

	// At this point, we need to be careful how we nullify the pointer cell to avoid

	// wiping out what happened in step 3. The hypothetical other IRP cannot be at 

	// the same address as this one because we haven't completed this one yet.



	PIRP* pIrp = (PIRP*) Irp->Tail.Overlay.DriverContext[0];

	PGENERIC_EXTENSION pdx = (PGENERIC_EXTENSION) Irp->Tail.Overlay.DriverContext[1];



	KeAcquireSpinLockAtDpcLevel(&pdx->IoctlListLock);

	RemoveEntryList(&Irp->Tail.Overlay.ListEntry);

	if (*pIrp == Irp)

		*pIrp = NULL;			// no need for interlocked operation here

	KeReleaseSpinLock(&pdx->IoctlListLock, oldirql);



	// Complete the IRP



	Irp->IoStatus.Status = STATUS_CANCELLED;

	IoCompleteRequest(Irp, IO_NO_INCREMENT);

	}							// OnCancelPendingIoctl

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区三区免费观看| 亚洲欧美综合网| 亚洲欧美中日韩| 久久国产尿小便嘘嘘| 播五月开心婷婷综合| xf在线a精品一区二区视频网站| 国产精品久久久久aaaa樱花| 日韩av电影天堂| k8久久久一区二区三区| 日韩精品在线看片z| 亚洲精品乱码久久久久久久久| 美女脱光内衣内裤视频久久网站| av网站免费线看精品| 精品国产一区久久| 性做久久久久久免费观看| 97精品久久久午夜一区二区三区| 久久精品一区二区三区四区| 日韩av一区二区三区| 欧美日韩黄色一区二区| 亚洲欧美电影一区二区| 99久久久无码国产精品| 中文字幕不卡在线播放| 国产美女一区二区三区| 日韩三级中文字幕| 免费在线观看精品| 欧美精品电影在线播放| 亚洲小说春色综合另类电影| 色94色欧美sute亚洲线路一久 | 美国av一区二区| 欧美乱熟臀69xxxxxx| 亚洲一区二区三区四区在线观看| 99re这里只有精品首页| 亚洲天堂精品在线观看| 成人免费va视频| 中文字幕av一区二区三区高| 国产99一区视频免费| 国产精品免费视频网站| 国产成人啪午夜精品网站男同| 久久午夜老司机| 国产成人av资源| 国产日韩欧美不卡| 成人免费va视频| ...xxx性欧美| 日本韩国欧美一区| 亚洲成人激情自拍| 7777女厕盗摄久久久| 日韩成人dvd| 久久久久久电影| av电影天堂一区二区在线| 亚洲精品ww久久久久久p站| 在线观看视频一区| 青青草原综合久久大伊人精品 | 亚洲一区二区三区影院| 91精品国产欧美一区二区18| 蜜桃视频在线观看一区二区| 欧美va在线播放| 成人性生交大片免费看视频在线| 亚洲视频你懂的| 日韩一级欧美一级| 国产成人免费av在线| 亚洲综合久久av| 欧美mv日韩mv亚洲| 99精品视频免费在线观看| 日韩精品每日更新| 欧美高清一级片在线观看| 欧美主播一区二区三区美女| 久久www免费人成看片高清| 综合色中文字幕| 91精品国产黑色紧身裤美女| 国产精品123| 洋洋av久久久久久久一区| 日韩欧美亚洲国产精品字幕久久久| 国产99久久久精品| 日本vs亚洲vs韩国一区三区二区 | 欧美日韩精品专区| 国产一区二区三区| 一区二区高清视频在线观看| 欧美tk丨vk视频| 欧美吻胸吃奶大尺度电影| 国产麻豆午夜三级精品| 亚洲国产一区二区三区| 久久久久久久久岛国免费| 欧美日韩和欧美的一区二区| 国产精品亚洲一区二区三区在线| 午夜欧美视频在线观看| 成人欧美一区二区三区1314| 欧美mv和日韩mv的网站| 精品视频123区在线观看| 成人一区二区三区视频| 美国欧美日韩国产在线播放| 亚洲一区二区视频在线| 亚洲人成伊人成综合网小说| 久久久久久久久免费| 欧美一区二区三区视频免费| 欧美专区在线观看一区| 91免费在线视频观看| 懂色av噜噜一区二区三区av| 麻豆国产精品官网| 污片在线观看一区二区| 亚洲综合精品自拍| 亚洲黄色片在线观看| 国产精品久久久久久久裸模| 久久久久久久av麻豆果冻| 日韩一区二区三区三四区视频在线观看 | 亚洲一区二区三区视频在线 | 成人aa视频在线观看| 国产在线视频一区二区三区| 免费成人结看片| 麻豆视频观看网址久久| 香港成人在线视频| 亚洲国产日韩综合久久精品| 一区二区三区精品在线观看| 一区二区三区在线观看网站| 亚洲男人天堂av| 樱花影视一区二区| 一区二区三区 在线观看视频| 亚洲欧美激情一区二区| 一区二区高清在线| 艳妇臀荡乳欲伦亚洲一区| 亚洲五月六月丁香激情| 亚洲午夜精品网| 日韩电影在线免费| 久久国产人妖系列| 国产盗摄视频一区二区三区| 成人午夜免费av| 97成人超碰视| 欧美三级视频在线| 欧美一级二级在线观看| 欧美xxxxx裸体时装秀| 国产人成亚洲第一网站在线播放| 国产婷婷色一区二区三区四区| 国产精品视频麻豆| 亚洲一区国产视频| 老汉av免费一区二区三区| 国产激情视频一区二区在线观看| 成人免费视频网站在线观看| 色综合色狠狠综合色| 欧美情侣在线播放| 久久久午夜精品| 亚洲欧美日韩国产一区二区三区 | 日本人妖一区二区| 国产精一区二区三区| 91在线视频观看| 7777精品久久久大香线蕉| ww久久中文字幕| 中文字幕在线一区| 亚洲一区二区三区视频在线播放| 久久国产尿小便嘘嘘尿| 91日韩一区二区三区| 在线观看91av| 中文字幕第一区| 日韩国产高清在线| 成人免费视频一区二区| 欧美精品xxxxbbbb| 国产精品久久夜| 全部av―极品视觉盛宴亚洲| 不卡的电影网站| 91精品国产欧美一区二区| 国产精品国产自产拍高清av| 丝袜亚洲另类丝袜在线| www.欧美色图| 日韩三级免费观看| 亚洲最色的网站| 成人午夜激情视频| 91麻豆精品久久久久蜜臀| 国产精品久久看| 奇米一区二区三区av| 一本到高清视频免费精品| 欧美精品一区二区三区蜜桃 | 精品亚洲国内自在自线福利| 色综合久久天天综合网| 久久久精品免费网站| 日韩精品一二区| 欧美最新大片在线看| 日本一区二区久久| 国产一区二区三区蝌蚪| 91精品欧美福利在线观看| 亚洲精品写真福利| 成人app在线| 欧美国产精品劲爆| 久久成人精品无人区| 欧美一区二区三区性视频| 亚洲综合999| 91丨porny丨户外露出| 欧美国产一区二区在线观看| 精油按摩中文字幕久久| 日韩一区二区三区观看| 三级精品在线观看| 精品视频在线视频| 亚洲国产wwwccc36天堂| 色美美综合视频| 亚洲天堂福利av| 99精品视频在线观看| 日韩美女视频一区二区| av成人老司机| 一区二区三区高清在线| 91搞黄在线观看| 亚洲第一成人在线| 欧美日韩久久一区| 青青草成人在线观看|