本文整理汇总了C++中ExAcquireResourceExclusiveLite函数的典型用法代码示例。如果您正苦于以下问题:C++ ExAcquireResourceExclusiveLite函数的具体用法?C++ ExAcquireResourceExclusiveLite怎么用?C++ ExAcquireResourceExclusiveLite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExAcquireResourceExclusiveLite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VfatFlush
NTSTATUS
VfatFlush(
PVFAT_IRP_CONTEXT IrpContext)
{
NTSTATUS Status;
PVFATFCB Fcb;
/* This request is not allowed on the main device object. */
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
IrpContext->Irp->IoStatus.Information = 0;
return STATUS_INVALID_DEVICE_REQUEST;
}
Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
ASSERT(Fcb);
if (BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
{
ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, TRUE);
Status = VfatFlushVolume(IrpContext->DeviceExt, Fcb);
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
}
else
{
ExAcquireResourceExclusiveLite(&Fcb->MainResource, TRUE);
Status = VfatFlushFile(IrpContext->DeviceExt, Fcb);
ExReleaseResourceLite (&Fcb->MainResource);
}
IrpContext->Irp->IoStatus.Information = 0;
return Status;
}
示例2: 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();
}
示例3: FspFileNodeTryAcquireExclusiveF
BOOLEAN FspFileNodeTryAcquireExclusiveF(FSP_FILE_NODE *FileNode, ULONG Flags, BOOLEAN Wait)
{
PAGED_CODE();
FSP_FILE_NODE_GET_FLAGS();
FSP_FILE_NODE_ASSERT_FLAGS_CLR();
BOOLEAN Result = TRUE;
if (Flags & FspFileNodeAcquireMain)
{
Result = ExAcquireResourceExclusiveLite(FileNode->Header.Resource, Wait);
if (!Result)
return FALSE;
}
if (Flags & FspFileNodeAcquirePgio)
{
Result = ExAcquireResourceExclusiveLite(FileNode->Header.PagingIoResource, Wait);
if (!Result)
{
if (Flags & FspFileNodeAcquireMain)
ExReleaseResourceLite(FileNode->Header.Resource);
return FALSE;
}
}
if (Result)
FSP_FILE_NODE_SET_FLAGS();
return Result;
}
示例4: DokanEventRelease
NTSTATUS
DokanEventRelease(__in PDEVICE_OBJECT DeviceObject) {
PDokanDCB dcb;
PDokanVCB vcb;
PDokanFCB fcb;
PDokanCCB ccb;
PLIST_ENTRY fcbEntry, fcbNext, fcbHead;
PLIST_ENTRY ccbEntry, ccbNext, ccbHead;
NTSTATUS status = STATUS_SUCCESS;
vcb = DeviceObject->DeviceExtension;
if (GetIdentifierType(vcb) != VCB) {
return STATUS_INVALID_PARAMETER;
}
dcb = vcb->Dcb;
// ExAcquireResourceExclusiveLite(&dcb->Resource, TRUE);
dcb->Mounted = 0;
// ExReleaseResourceLite(&dcb->Resource);
// search CCB list to complete not completed Directory Notification
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&vcb->Resource, TRUE);
fcbHead = &vcb->NextFCB;
for (fcbEntry = fcbHead->Flink; fcbEntry != fcbHead; fcbEntry = fcbNext) {
fcbNext = fcbEntry->Flink;
fcb = CONTAINING_RECORD(fcbEntry, DokanFCB, NextFCB);
ExAcquireResourceExclusiveLite(&fcb->Resource, TRUE);
ccbHead = &fcb->NextCCB;
for (ccbEntry = ccbHead->Flink; ccbEntry != ccbHead; ccbEntry = ccbNext) {
ccbNext = ccbEntry->Flink;
ccb = CONTAINING_RECORD(ccbEntry, DokanCCB, NextCCB);
DDbgPrint(" NotifyCleanup ccb:%p, context:%X, filename:%wZ\n", ccb,
(ULONG)ccb->UserContext, &fcb->FileName);
FsRtlNotifyCleanup(vcb->NotifySync, &vcb->DirNotifyList, ccb);
}
ExReleaseResourceLite(&fcb->Resource);
}
ExReleaseResourceLite(&vcb->Resource);
KeLeaveCriticalRegion();
ReleasePendingIrp(&dcb->PendingIrp);
ReleasePendingIrp(&dcb->PendingEvent);
DokanStopCheckThread(dcb);
DokanStopEventNotificationThread(dcb);
DokanDeleteDeviceObject(dcb);
return status;
}
示例5: DokanFreeFCB
NTSTATUS
DokanFreeFCB(
__in PDokanFCB Fcb
)
{
PDokanVCB vcb;
ASSERT(Fcb != NULL);
vcb = Fcb->Vcb;
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&vcb->Resource, TRUE);
ExAcquireResourceExclusiveLite(&Fcb->Resource, TRUE);
InterlockedDecrement(&Fcb->FileCount);
if (Fcb->FileCount == 0) {
RemoveEntryList(&Fcb->NextFCB);
DDbgPrint(" Free FCB:%p\n", Fcb);
ExFreePool(Fcb->FileName.Buffer);
#if _WIN32_WINNT >= 0x0501
FsRtlTeardownPerStreamContexts(&Fcb->AdvancedFCBHeader);
#else
if (DokanFsRtlTeardownPerStreamContexts) {
DokanFsRtlTeardownPerStreamContexts(&Fcb->AdvancedFCBHeader);
}
#endif
ExReleaseResourceLite(&Fcb->Resource);
ExDeleteResourceLite(&Fcb->Resource);
ExDeleteResourceLite(&Fcb->MainResource);
ExDeleteResourceLite(&Fcb->PagingIoResource);
InterlockedIncrement(&vcb->FcbFreed);
ExFreePool(Fcb);
} else {
ExReleaseResourceLite(&Fcb->Resource);
}
ExReleaseResourceLite(&vcb->Resource);
KeLeaveCriticalRegion();
return STATUS_SUCCESS;
}
示例6: FspFileNodeAcquireExclusiveF
VOID FspFileNodeAcquireExclusiveF(FSP_FILE_NODE *FileNode, ULONG Flags)
{
PAGED_CODE();
FSP_FILE_NODE_GET_FLAGS();
FSP_FILE_NODE_ASSERT_FLAGS_CLR();
if (Flags & FspFileNodeAcquireMain)
ExAcquireResourceExclusiveLite(FileNode->Header.Resource, TRUE);
if (Flags & FspFileNodeAcquirePgio)
ExAcquireResourceExclusiveLite(FileNode->Header.PagingIoResource, TRUE);
FSP_FILE_NODE_SET_FLAGS();
}
示例7: FlushFcb
VOID FlushFcb(__in PDokanFCB fcb, __in_opt PFILE_OBJECT fileObject) {
if (fcb == NULL) {
return;
}
if (fcb->SectionObjectPointers.ImageSectionObject != NULL) {
DDbgPrint(" MmFlushImageSection FileName: %wZ FileCount: %lu.\n",
&fcb->FileName, fcb->FileCount);
MmFlushImageSection(&fcb->SectionObjectPointers, MmFlushForWrite);
DDbgPrint(" MmFlushImageSection done FileName: %wZ FileCount: %lu.\n",
&fcb->FileName, fcb->FileCount);
}
if (fcb->SectionObjectPointers.DataSectionObject != NULL) {
DDbgPrint(" CcFlushCache FileName: %wZ FileCount: %lu.\n", &fcb->FileName,
fcb->FileCount);
ExAcquireResourceExclusiveLite(&fcb->PagingIoResource, TRUE);
CcFlushCache(&fcb->SectionObjectPointers, NULL, 0, NULL);
CcPurgeCacheSection(&fcb->SectionObjectPointers, NULL, 0, FALSE);
if (fileObject != NULL) {
CcUninitializeCacheMap(fileObject, NULL, NULL);
}
ExReleaseResourceLite(&fcb->PagingIoResource);
DDbgPrint(" CcFlushCache done FileName: %wZ FileCount: %lu.\n",
&fcb->FileName, fcb->FileCount);
}
}
示例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: RemoveMountEntry
VOID RemoveMountEntry(PDOKAN_GLOBAL dokanGlobal, PMOUNT_ENTRY MountEntry) {
ExAcquireResourceExclusiveLite(&dokanGlobal->Resource, TRUE);
RemoveEntryList(&MountEntry->ListEntry);
ExReleaseResourceLite(&dokanGlobal->Resource);
ExFreePool(MountEntry);
}
示例10: Ext2FlushFiles
NTSTATUS
Ext2FlushFiles(
IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb,
IN BOOLEAN bShutDown
)
{
IO_STATUS_BLOCK IoStatus;
PEXT2_FCB Fcb;
PLIST_ENTRY ListEntry;
if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY) ||
IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
return STATUS_SUCCESS;
}
IoStatus.Status = STATUS_SUCCESS;
DEBUG(DL_INF, ( "Flushing Files ...\n"));
// Flush all Fcbs in Vcb list queue.
for (ListEntry = Vcb->FcbList.Flink;
ListEntry != &Vcb->FcbList;
ListEntry = ListEntry->Flink ) {
Fcb = CONTAINING_RECORD(ListEntry, EXT2_FCB, Next);
ExAcquireResourceExclusiveLite(
&Fcb->MainResource, TRUE);
IoStatus.Status = Ext2FlushFile(IrpContext, Fcb, NULL);
ExReleaseResourceLite(&Fcb->MainResource);
}
return IoStatus.Status;
}
示例11: 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();
}
示例12: 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();
}
}
示例13: 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();
}
}
示例14: DokanFilterCallbackAcquireForCreateSection
NTSTATUS
DokanFilterCallbackAcquireForCreateSection(__in PFS_FILTER_CALLBACK_DATA
CallbackData,
__out PVOID *CompletionContext) {
PFSRTL_ADVANCED_FCB_HEADER header;
PDokanFCB fcb = NULL;
PDokanCCB ccb;
UNREFERENCED_PARAMETER(CompletionContext);
DDbgPrint("DokanFilterCallbackAcquireForCreateSection\n");
header = CallbackData->FileObject->FsContext;
ccb = CallbackData->FileObject->FsContext2;
if (ccb)
fcb = ccb->Fcb;
if (header && header->Resource) {
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(header->Resource, TRUE);
KeLeaveCriticalRegion();
}
if (CallbackData->Parameters.AcquireForSectionSynchronization.SyncType !=
SyncTypeCreateSection) {
return STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY;
} else if (fcb && fcb->ShareAccess.Writers == 0) {
return STATUS_FILE_LOCKED_WITH_ONLY_READERS;
} else {
return STATUS_FILE_LOCKED_WITH_WRITERS;
}
}
示例15: UserEnterExclusive
VOID FASTCALL UserEnterExclusive(VOID)
{
ASSERT_NOGDILOCKS();
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
gptiCurrent = PsGetCurrentThreadWin32Thread();
}