本文整理汇总了C++中KeEnterCriticalRegion函数的典型用法代码示例。如果您正苦于以下问题:C++ KeEnterCriticalRegion函数的具体用法?C++ KeEnterCriticalRegion怎么用?C++ KeEnterCriticalRegion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KeEnterCriticalRegion函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestResourceExclusiveAccess
static
VOID
TestResourceExclusiveAccess(
IN PERESOURCE Res)
{
LONG Count = 0;
KeEnterCriticalRegion();
ok_bool_true(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned"); ++Count;
CheckResourceStatus(Res, TRUE, Count, 0LU, 0LU);
ok_bool_true(ExAcquireResourceExclusiveLite(Res, TRUE), "ExAcquireResourceExclusiveLite returned"); ++Count;
CheckResourceStatus(Res, TRUE, Count, 0LU, 0LU);
ok_bool_true(ExAcquireResourceSharedLite(Res, FALSE), "ExAcquireResourceSharedLite returned"); ++Count;
ok_bool_true(ExAcquireResourceSharedLite(Res, TRUE), "ExAcquireResourceSharedLite returned"); ++Count;
ok_bool_true(ExAcquireSharedStarveExclusive(Res, FALSE), "ExAcquireSharedStarveExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedStarveExclusive(Res, TRUE), "ExAcquireSharedStarveExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedWaitForExclusive(Res, FALSE), "ExAcquireSharedWaitForExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedWaitForExclusive(Res, TRUE), "ExAcquireSharedWaitForExclusive returned"); ++Count;
CheckResourceStatus(Res, TRUE, Count, 0LU, 0LU);
ExConvertExclusiveToSharedLite(Res);
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
while (Count--)
ExReleaseResourceLite(Res);
KeLeaveCriticalRegion();
}
示例2: DokanCheckKeepAlive
VOID DokanCheckKeepAlive(__in PDokanDCB Dcb) {
LARGE_INTEGER tickCount;
ULONG mounted;
// DDbgPrint("==> DokanCheckKeepAlive\n");
KeEnterCriticalRegion();
KeQueryTickCount(&tickCount);
ExAcquireResourceSharedLite(&Dcb->Resource, TRUE);
if (Dcb->TickCount.QuadPart < tickCount.QuadPart) {
mounted = Dcb->Mounted;
ExReleaseResourceLite(&Dcb->Resource);
DDbgPrint(" Timeout, umount\n");
if (!mounted) {
// not mounted
KeLeaveCriticalRegion();
return;
}
DokanUnmount(Dcb);
} else {
ExReleaseResourceLite(&Dcb->Resource);
}
KeLeaveCriticalRegion();
// DDbgPrint("<== DokanCheckKeepAlive\n");
}
示例3: ThreadNotifyCallback
VOID
ThreadNotifyCallback (
HANDLE ProcessId,
HANDLE ThreadId,
BOOLEAN Create )
{
DbgPrint ( "%s ProcessId=%x ThreadId=%x %s\n", __FUNCTION__,
ProcessId,
ThreadId,
Create ? "CREATED" : "DESTROYED" );
if ( Create ) {
// Step #2 : Acquire the lock that protects the g_Tidxxx globals
// (KeEnterCriticalRegion() and ExAcquireResourceExclusiveLite())
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&g_TidLock, TRUE);
g_TidArray[g_TidIndex] = ThreadId;
g_TidIndex++;
if ( g_TidIndex >= TID_ARRAY_SIZE ) {
g_TidIndex = 0;
}
// Step #3 : Release the lock that protects the g_Tidxxx globals
// (KeLeaveCriticalRegion() and ExReleaseResourceLite())
ExReleaseResourceLite(&g_TidLock);
KeLeaveCriticalRegion();
}
}
示例4: dc_clean_pass_cache
void dc_clean_pass_cache()
{
dsk_pass *d_pass;
dsk_pass *c_pass;
int loirql;
if (loirql = (KeGetCurrentIrql() == PASSIVE_LEVEL)) {
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&p_resource, TRUE);
}
for (d_pass = f_pass; d_pass;)
{
c_pass = d_pass;
d_pass = d_pass->next;
/* zero password data */
burn(c_pass, sizeof(dsk_pass));
/* free memory if possible */
if (loirql != 0) mm_secure_free(c_pass);
}
f_pass = NULL;
if (loirql != 0) {
ExReleaseResourceLite(&p_resource);
KeLeaveCriticalRegion();
}
}
示例5: UserEnterExclusive
VOID FASTCALL UserEnterExclusive(VOID)
{
ASSERT_NOGDILOCKS();
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
gptiCurrent = PsGetCurrentThreadWin32Thread();
}
示例6: dc_add_password
void dc_add_password(dc_pass *pass)
{
dsk_pass *d_pass;
if (pass->size != 0)
{
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&p_resource, TRUE);
for (d_pass = f_pass; d_pass; d_pass = d_pass->next)
{
if (IS_EQUAL_PASS(pass, &d_pass->pass)) {
break;
}
}
if ( (d_pass == NULL) && (d_pass = mm_secure_alloc(sizeof(dsk_pass))) )
{
memcpy(&d_pass->pass, pass, sizeof(dc_pass));
d_pass->next = f_pass;
f_pass = d_pass;
}
ExReleaseResourceLite(&p_resource);
KeLeaveCriticalRegion();
}
}
示例7: IoUnregisterFileSystem
/*
* @implemented
*/
VOID
NTAPI
IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
{
PAGED_CODE();
/* Acquire the FS lock */
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&IopDatabaseResource, TRUE);
/* Simply remove the entry - if queued */
if (DeviceObject->Queue.ListEntry.Flink)
{
RemoveEntryList(&DeviceObject->Queue.ListEntry);
}
/* And notify all registered file systems */
IopNotifyFileSystemChange(DeviceObject, FALSE);
/* Update operations counter */
IopFsRegistrationOps++;
/* Then release the lock */
ExReleaseResourceLite(&IopDatabaseResource);
KeLeaveCriticalRegion();
/* Decrease reference count to allow unload */
IopInterlockedDecrementUlong(LockQueueIoDatabaseLock, (PULONG)&DeviceObject->ReferenceCount);
}
示例8: DokanFreeCCB
NTSTATUS
DokanFreeCCB(
__in PDokanCCB ccb
)
{
PDokanFCB fcb;
ASSERT(ccb != NULL);
fcb = ccb->Fcb;
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&fcb->Resource, TRUE);
RemoveEntryList(&ccb->NextCCB);
ExReleaseResourceLite(&fcb->Resource);
KeLeaveCriticalRegion();
ExDeleteResourceLite(&ccb->Resource);
if (ccb->SearchPattern) {
ExFreePool(ccb->SearchPattern);
}
ExFreePool(ccb);
InterlockedIncrement(&fcb->Vcb->CcbFreed);
return STATUS_SUCCESS;
}
示例9: AcquireResourceThread
static
VOID
NTAPI
AcquireResourceThread(
PVOID Context)
{
NTSTATUS Status = STATUS_SUCCESS;
PTHREAD_DATA ThreadData = Context;
BOOLEAN Ret;
KeEnterCriticalRegion();
Ret = ThreadData->AcquireResource(ThreadData->Res, ThreadData->Wait);
if (ThreadData->RetExpected)
ok_bool_true(Ret, "AcquireResource returned");
else
ok_bool_false(Ret, "AcquireResource returned");
ok_bool_false(KeSetEvent(&ThreadData->OutEvent, 0, TRUE), "KeSetEvent returned");
Status = KeWaitForSingleObject(&ThreadData->InEvent, Executive, KernelMode, FALSE, NULL);
ok_eq_hex(Status, STATUS_SUCCESS);
if (Ret)
ExReleaseResource(ThreadData->Res);
KeLeaveCriticalRegion();
}
示例10: TestResourceSharedAccess
static
VOID
TestResourceSharedAccess(
IN PERESOURCE Res)
{
LONG Count = 0;
KeEnterCriticalRegion();
ok_bool_true(ExAcquireResourceSharedLite(Res, FALSE), "ExAcquireResourceSharedLite returned"); ++Count;
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
ok_bool_true(ExAcquireResourceSharedLite(Res, FALSE), "ExAcquireResourceSharedLite returned"); ++Count;
ok_bool_true(ExAcquireResourceSharedLite(Res, TRUE), "ExAcquireResourceSharedLite returned"); ++Count;
ok_bool_true(ExAcquireSharedStarveExclusive(Res, FALSE), "ExAcquireSharedStarveExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedStarveExclusive(Res, TRUE), "ExAcquireSharedStarveExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedWaitForExclusive(Res, FALSE), "ExAcquireSharedWaitForExclusive returned"); ++Count;
ok_bool_true(ExAcquireSharedWaitForExclusive(Res, TRUE), "ExAcquireSharedWaitForExclusive returned"); ++Count;
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
/* this one fails, TRUE would deadlock */
ok_bool_false(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned");
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
/* this asserts */
if (!KmtIsCheckedBuild)
ExConvertExclusiveToSharedLite(Res);
CheckResourceStatus(Res, FALSE, Count, 0LU, 0LU);
while (Count--)
ExReleaseResourceLite(Res);
KeLeaveCriticalRegion();
}
示例11: FilterDeleteControlObject
VOID
FilterDeleteControlObject(
)
{
UNICODE_STRING symbolicLinkName;
PCONTROL_DEVICE_EXTENSION deviceExtension;
PAGED_CODE();
KeEnterCriticalRegion();
KeWaitForSingleObject(&ControlLock, Executive, KernelMode, FALSE, NULL);
//
// If this is the last instance of the device then delete the controlobject
// and symbolic link to enable the pnp manager to unload the driver.
//
if (!(--InstanceCount) && ControlDeviceObject)
{
RtlInitUnicodeString(&symbolicLinkName, SYMBOLIC_NAME_STRING);
deviceExtension = ControlDeviceObject->DeviceExtension;
deviceExtension->Deleted = TRUE;
IoDeleteSymbolicLink(&symbolicLinkName);
IoDeleteDevice(ControlDeviceObject);
ControlDeviceObject = NULL;
}
KeSetEvent(&ControlLock, IO_NO_INCREMENT, FALSE);
KeLeaveCriticalRegion();
}
示例12: EvhdDirectIoControl
static NTSTATUS EvhdDirectIoControl(ParserInstance *parser, ULONG ControlCode, PVOID pSystemBuffer, ULONG InputBufferSize,
ULONG OutputBufferSize)
{
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT pDeviceObject = NULL;
KeEnterCriticalRegion();
FltAcquirePushLockExclusive(&parser->DirectIoPushLock);
IoReuseIrp(parser->pDirectIoIrp, STATUS_PENDING);
parser->pDirectIoIrp->Flags |= IRP_NOCACHE;
parser->pDirectIoIrp->Tail.Overlay.Thread = (PETHREAD)__readgsqword(0x188); // Pointer to calling thread control block
parser->pDirectIoIrp->AssociatedIrp.SystemBuffer = pSystemBuffer; // IO buffer for buffered control code
// fill stack frame parameters for synchronous IRP call
PIO_STACK_LOCATION pStackFrame = IoGetNextIrpStackLocation(parser->pDirectIoIrp);
pDeviceObject = IoGetRelatedDeviceObject(parser->pVhdmpFileObject);
pStackFrame->FileObject = parser->pVhdmpFileObject;
pStackFrame->DeviceObject = pDeviceObject;
pStackFrame->Parameters.DeviceIoControl.IoControlCode = ControlCode;
pStackFrame->Parameters.DeviceIoControl.InputBufferLength = InputBufferSize;
pStackFrame->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferSize;
pStackFrame->MajorFunction = IRP_MJ_DEVICE_CONTROL;
pStackFrame->MinorFunction = 0;
pStackFrame->Flags = 0;
pStackFrame->Control = 0;
IoSynchronousCallDriver(pDeviceObject, parser->pDirectIoIrp);
status = parser->pDirectIoIrp->IoStatus.Status;
FltReleasePushLock(&parser->DirectIoPushLock);
KeLeaveCriticalRegion();
return status;
}
示例13: _KeEnterCriticalRegion
/*++
* @name KeEnterCriticalRegion
* @implemented NT4
*
* The KeEnterCriticalRegion routine temporarily disables the delivery of
* normal kernel APCs; special kernel-mode APCs are still delivered.
*
* @param None.
*
* @return None.
*
* @remarks Highest-level drivers can call this routine while running in the
* context of the thread that requested the current I/O operation.
* Any caller of this routine should call KeLeaveCriticalRegion as
* quickly as possible.
*
* Callers of KeEnterCriticalRegion must be running at IRQL <=
* APC_LEVEL.
*
*--*/
VOID
NTAPI
_KeEnterCriticalRegion(VOID)
{
/* Use inlined function */
KeEnterCriticalRegion();
}
示例14: SymInit
VOID SymInit(void)
{
KeEnterCriticalRegion();
if(bIsSymEngineInitialized == TRUE)
{
KeLeaveCriticalRegion();
return;
}
// initialize all required data structures
ExInitializeNPagedLookasideList(&SymbolsLookasideList, // list to initialize
NULL, // allocate function - OS supplied
NULL, // free function - OS supplied
0, // flags - always zero
sizeof(SYMBOL_ENTRY), // size of each entry to be allocated
TAG_SYMBOL_LOOKASIDE, // SymL(ookaside) tag
0 // depth - always zero
);
InitializeListHead(&SymbolsListHead);
ASSERTMSG("Fast mutex must be initialized at or below DISPATCH_LEVEL", KeGetCurrentIrql() <= DISPATCH_LEVEL);
ExInitializeFastMutex(&SymbolsListMutex);
bIsSymEngineInitialized = TRUE;
KeLeaveCriticalRegion();
}
示例15: LookupPdoData
//
// Increment the reference count to a PDO.
//
PPDO_DEVICE_DATA
LookupPdoData(
PFDO_DEVICE_DATA FdoData,
ULONG SystemIoBusNumber
)
{
PPDO_DEVICE_DATA pdoData = NULL;
PLIST_ENTRY entry;
PAGED_CODE ();
KeEnterCriticalRegion();
ExAcquireFastMutex (&FdoData->Mutex);
for (entry = FdoData->ListOfPDOs.Flink;
entry != &FdoData->ListOfPDOs;
entry = entry->Flink) {
pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link);
if(pdoData->SlotNo == SystemIoBusNumber)
break;
pdoData = NULL;
}
if(pdoData) {
//
// increment the reference count to the PDO.
//
ObReferenceObject(pdoData->Self);
}
ExReleaseFastMutex (&FdoData->Mutex);
KeLeaveCriticalRegion();
return pdoData;
}