本文整理汇总了C++中ExAcquireResourceSharedLite函数的典型用法代码示例。如果您正苦于以下问题:C++ ExAcquireResourceSharedLite函数的具体用法?C++ ExAcquireResourceSharedLite怎么用?C++ ExAcquireResourceSharedLite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExAcquireResourceSharedLite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pnp_cancel_remove_device
static NTSTATUS pnp_cancel_remove_device(PDEVICE_OBJECT DeviceObject) {
device_extension* Vcb = DeviceObject->DeviceExtension;
NTSTATUS Status;
ExAcquireResourceSharedLite(&Vcb->tree_lock, TRUE);
ExAcquireResourceSharedLite(&Vcb->fileref_lock, TRUE);
if (Vcb->root_fileref && Vcb->root_fileref->fcb && (Vcb->root_fileref->open_count > 0 || has_open_children(Vcb->root_fileref))) {
Status = STATUS_ACCESS_DENIED;
goto end;
}
Status = send_disks_pnp_message(Vcb, IRP_MN_CANCEL_REMOVE_DEVICE);
if (!NT_SUCCESS(Status)) {
WARN("send_disks_pnp_message returned %08x\n", Status);
goto end;
}
end:
ExReleaseResourceLite(&Vcb->fileref_lock);
ExReleaseResourceLite(&Vcb->tree_lock);
return STATUS_SUCCESS;
}
示例2: FspFileNodeTryAcquireSharedF
BOOLEAN FspFileNodeTryAcquireSharedF(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 = ExAcquireResourceSharedLite(FileNode->Header.Resource, Wait);
if (!Result)
return FALSE;
}
if (Flags & FspFileNodeAcquirePgio)
{
Result = ExAcquireResourceSharedLite(FileNode->Header.PagingIoResource, Wait);
if (!Result)
{
if (Flags & FspFileNodeAcquireMain)
ExReleaseResourceLite(FileNode->Header.Resource);
return FALSE;
}
}
if (Result)
FSP_FILE_NODE_SET_FLAGS();
return Result;
}
示例3: 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();
}
示例4: 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();
}
示例5: FspFileNodeAcquireSharedF
VOID FspFileNodeAcquireSharedF(FSP_FILE_NODE *FileNode, ULONG Flags)
{
PAGED_CODE();
FSP_FILE_NODE_GET_FLAGS();
FSP_FILE_NODE_ASSERT_FLAGS_CLR();
if (Flags & FspFileNodeAcquireMain)
ExAcquireResourceSharedLite(FileNode->Header.Resource, TRUE);
if (Flags & FspFileNodeAcquirePgio)
ExAcquireResourceSharedLite(FileNode->Header.PagingIoResource, TRUE);
FSP_FILE_NODE_SET_FLAGS();
}
示例6: 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");
}
示例7: vol_get_length
static NTSTATUS vol_get_length(volume_device_extension* vde, PIRP Irp) {
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
pdo_device_extension* pdode = vde->pdode;
GET_LENGTH_INFORMATION* gli;
LIST_ENTRY* le;
if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(GET_LENGTH_INFORMATION))
return STATUS_BUFFER_TOO_SMALL;
gli = (GET_LENGTH_INFORMATION*)Irp->AssociatedIrp.SystemBuffer;
gli->Length.QuadPart = 0;
ExAcquireResourceSharedLite(&pdode->child_lock, TRUE);
le = pdode->children.Flink;
while (le != &pdode->children) {
volume_child* vc = CONTAINING_RECORD(le, volume_child, list_entry);
gli->Length.QuadPart += vc->size;
le = le->Flink;
}
ExReleaseResourceLite(&pdode->child_lock);
Irp->IoStatus.Information = sizeof(GET_LENGTH_INFORMATION);
return STATUS_SUCCESS;
}
示例8: vol_is_writable
static NTSTATUS vol_is_writable(volume_device_extension* vde) {
pdo_device_extension* pdode = vde->pdode;
NTSTATUS Status;
LIST_ENTRY* le;
BOOL writable = FALSE;
ExAcquireResourceSharedLite(&pdode->child_lock, TRUE);
le = pdode->children.Flink;
while (le != &pdode->children) {
volume_child* vc = CONTAINING_RECORD(le, volume_child, list_entry);
Status = dev_ioctl(vc->devobj, IOCTL_DISK_IS_WRITABLE, NULL, 0, NULL, 0, TRUE, NULL);
if (NT_SUCCESS(Status)) {
writable = TRUE;
break;
} else if (Status != STATUS_MEDIA_WRITE_PROTECTED)
goto end;
le = le->Flink;
}
Status = writable ? STATUS_SUCCESS : STATUS_MEDIA_WRITE_PROTECTED;
end:
ExReleaseResourceLite(&pdode->child_lock);
return STATUS_SUCCESS;
}
示例9: CdAcquireForCache
BOOLEAN
CdAcquireForCache (
_Inout_ PFCB Fcb,
_In_ BOOLEAN Wait
)
/*++
Routine Description:
The address of this routine is specified when creating a CacheMap for
a file. It is subsequently called by the Lazy Writer for synchronization.
Arguments:
Fcb - The pointer supplied as context to the cache initialization
routine.
Wait - TRUE if the caller is willing to block.
Return Value:
None
--*/
{
PAGED_CODE();
NT_ASSERT(IoGetTopLevelIrp() == NULL);
IoSetTopLevelIrp((PIRP)FSRTL_CACHE_TOP_LEVEL_IRP);
return ExAcquireResourceSharedLite( Fcb->Resource, Wait );
}
示例10: pnp_remove_device
static NTSTATUS pnp_remove_device(PDEVICE_OBJECT DeviceObject) {
device_extension* Vcb = DeviceObject->DeviceExtension;
NTSTATUS Status;
ExAcquireResourceSharedLite(&Vcb->tree_lock, TRUE);
Status = send_disks_pnp_message(Vcb, IRP_MN_REMOVE_DEVICE);
if (!NT_SUCCESS(Status))
WARN("send_disks_pnp_message returned %08x\n", Status);
ExReleaseResourceLite(&Vcb->tree_lock);
if (DeviceObject->Vpb->Flags & VPB_MOUNTED) {
Status = FsRtlNotifyVolumeEvent(Vcb->root_file, FSRTL_VOLUME_DISMOUNT);
if (!NT_SUCCESS(Status)) {
WARN("FsRtlNotifyVolumeEvent returned %08x\n", Status);
}
if (Vcb->vde)
Vcb->vde->mounted_device = NULL;
ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
Vcb->removing = TRUE;
ExReleaseResourceLite(&Vcb->tree_lock);
if (Vcb->open_files == 0)
uninit(Vcb);
}
return STATUS_SUCCESS;
}
示例11: KeEnterCriticalRegion
dev_hook *dc_find_hook(wchar_t *dev_name)
{
PLIST_ENTRY entry;
dev_hook *hook;
dev_hook *found = NULL;
KeEnterCriticalRegion();
ExAcquireResourceSharedLite(&hooks_sync_resource, TRUE);
entry = hooks_list_head.Flink;
while (entry != &hooks_list_head)
{
hook = CONTAINING_RECORD(entry, dev_hook, hooks_list);
entry = entry->Flink;
if (_wcsicmp(hook->dev_name, dev_name) == 0) {
dc_reference_hook(hook);
found = hook; break;
}
}
ExReleaseResourceLite(&hooks_sync_resource);
KeLeaveCriticalRegion();
return found;
}
示例12: vol_check_verify
static NTSTATUS vol_check_verify(volume_device_extension* vde) {
pdo_device_extension* pdode = vde->pdode;
NTSTATUS Status;
LIST_ENTRY* le;
ExAcquireResourceSharedLite(&pdode->child_lock, TRUE);
le = pdode->children.Flink;
while (le != &pdode->children) {
volume_child* vc = CONTAINING_RECORD(le, volume_child, list_entry);
Status = dev_ioctl(vc->devobj, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, FALSE, NULL);
if (!NT_SUCCESS(Status))
goto end;
le = le->Flink;
}
Status = STATUS_SUCCESS;
end:
ExReleaseResourceLite(&pdode->child_lock);
return Status;
}
示例13: dc_probe_decrypt
static
int dc_probe_decrypt(dev_hook *hook, dc_header **header, xts_key **res_key, dc_pass *password)
{
xts_key *hdr_key;
dsk_pass *d_pass;
int resl, succs;
hdr_key = NULL; succs = 0; *header = NULL;
do
{
/* read raw volume header */
if ( (resl = io_read_header(hook, header, NULL, NULL)) != ST_OK ) {
break;
}
if ( (hdr_key = mm_secure_alloc(sizeof(xts_key))) == NULL ) {
resl = ST_NOMEM; break;
}
/* derive header key and decrypt header */
do
{
if (password != NULL)
{
/* probe mount with entered password */
if (succs = cp_decrypt_header(hdr_key, *header, password)) {
break;
}
}
KeEnterCriticalRegion();
ExAcquireResourceSharedLite(&p_resource, TRUE);
/* probe mount with cached passwords */
for (d_pass = f_pass; d_pass; d_pass = d_pass->next)
{
if (succs = cp_decrypt_header(hdr_key, *header, &d_pass->pass)) {
break;
}
}
ExReleaseResourceLite(&p_resource);
KeLeaveCriticalRegion();
} while (0);
if (succs != 0) {
*res_key = hdr_key; hdr_key = NULL; resl = ST_OK;
} else {
resl = ST_PASS_ERR;
}
} while (0);
if (resl != ST_OK && *header != NULL) {
mm_secure_free(*header); *header = NULL;
}
if (hdr_key != NULL) {
mm_secure_free(hdr_key);
}
return resl;
}
示例14: VfsAcqReadAhead
//
// acquire for read ahead
//
BOOLEAN DDKAPI VfsAcqReadAhead(PVOID context, BOOLEAN wait)
{
PLKLFCB fcb = (PLKLFCB) context;
ASSERT(fcb);
ASSERT((fcb->id.type == FCB) && (fcb->id.size == sizeof(PLKLFCB)));
return ExAcquireResourceSharedLite(&(fcb->fcb_resource), wait);
}
示例15: MrLockGlobal
BOOLEAN MrLockGlobal(BOOLEAN ex)
{
KeEnterCriticalRegion();
if (!ex)
return ExAcquireResourceSharedLite(&g_core.mc_lock, TRUE);
return ExAcquireResourceExclusiveLite(&g_core.mc_lock, TRUE);
}