当前位置: 首页>>代码示例>>C++>>正文


C++ KeEnterCriticalRegion函数代码示例

本文整理汇总了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();
}
开发者ID:mutoso-mirrors,项目名称:reactos,代码行数:30,代码来源:ExResource.c

示例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");
}
开发者ID:Driim,项目名称:dokany,代码行数:32,代码来源:timeout.c

示例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();
    }
}
开发者ID:EternalKeel,项目名称:CodeMachineCourse,代码行数:30,代码来源:locking.c

示例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();
	}
}
开发者ID:the-alien,项目名称:diskcryptor,代码行数:27,代码来源:mount.c

示例5: UserEnterExclusive

VOID FASTCALL UserEnterExclusive(VOID)
{
    ASSERT_NOGDILOCKS();
    KeEnterCriticalRegion();
    ExAcquireResourceExclusiveLite(&UserLock, TRUE);
    gptiCurrent = PsGetCurrentThreadWin32Thread();
}
开发者ID:RPG-7,项目名称:reactos,代码行数:7,代码来源:ntuser.c

示例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();
	}
}
开发者ID:the-alien,项目名称:diskcryptor,代码行数:28,代码来源:mount.c

示例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);
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:32,代码来源:volume.c

示例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;
}
开发者ID:nmlgc,项目名称:dokany,代码行数:30,代码来源:create.c

示例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();
}
开发者ID:mutoso-mirrors,项目名称:reactos,代码行数:25,代码来源:ExResource.c

示例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();
}
开发者ID:mutoso-mirrors,项目名称:reactos,代码行数:32,代码来源:ExResource.c

示例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();

}
开发者ID:kcrazy,项目名称:winekit,代码行数:31,代码来源:filter.c

示例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;
}
开发者ID:the-alien,项目名称:evhdparser,代码行数:30,代码来源:parser.c

示例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();
}
开发者ID:GYGit,项目名称:reactos,代码行数:27,代码来源:apc.c

示例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();
}
开发者ID:angry7panda,项目名称:dementia-forensics,代码行数:27,代码来源:SymbolEngine.cpp

示例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;
}
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:38,代码来源:busenum.c


注:本文中的KeEnterCriticalRegion函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。