本文整理汇总了C++中IoAcquireRemoveLock函数的典型用法代码示例。如果您正苦于以下问题:C++ IoAcquireRemoveLock函数的具体用法?C++ IoAcquireRemoveLock怎么用?C++ IoAcquireRemoveLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoAcquireRemoveLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PdoDispatchDefault
static DECLSPEC_NOINLINE NTSTATUS
PdoDispatchDefault(
IN PXENFILT_PDO Pdo,
IN PIRP Irp
)
{
NTSTATUS status;
status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
if (!NT_SUCCESS(status))
goto fail1;
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp,
__PdoDispatchDefault,
Pdo,
TRUE,
TRUE,
TRUE);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
return status;
fail1:
Error("fail1 (%08x)\n", status);
Irp->IoStatus.Status = status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
示例2: VolumeFilterDispatchIrp
NTSTATUS VolumeFilterDispatchIrp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
VolumeFilterExtension *Extension = (VolumeFilterExtension *) DeviceObject->DeviceExtension;
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
NTSTATUS status;
ASSERT (!Extension->bRootDevice && Extension->IsVolumeFilterDevice);
switch (irpSp->MajorFunction)
{
case IRP_MJ_DEVICE_CONTROL:
return DispatchControl (DeviceObject, Irp, Extension, irpSp);
case IRP_MJ_PNP:
return DispatchPnp (DeviceObject, Irp, Extension, irpSp);
case IRP_MJ_POWER:
return DispatchPower (DeviceObject, Irp, Extension, irpSp);
default:
status = IoAcquireRemoveLock (&Extension->Queue.RemoveLock, Irp);
if (!NT_SUCCESS (status))
return TCCompleteIrp (Irp, status, 0);
status = PassIrp (Extension->LowerDeviceObject, Irp);
IoReleaseRemoveLock (&Extension->Queue.RemoveLock, Irp);
return status;
}
}
示例3: PassIRP
//========================================================================================
// Function: PassIRP
// Purpose: Free all the allocated resources, etc.
// Return Value:
// NT status code
//========================================================================================
NTSTATUS PassIRP(
IN PDEVICE_OBJECT fido,
IN PIRP irp // Irp - pointer to an I/O Request Packet.
)
{
PDEVICE_EXTENSION dx;
NTSTATUS ntStatus;
dx = (PDEVICE_EXTENSION)fido->DeviceExtension;
// acquire remove lock
ntStatus = IoAcquireRemoveLock(&dx->rmLock, irp);
if (!NT_SUCCESS(ntStatus))
{
//complete irp if cannot acquire remove lock
irp->IoStatus.Status=ntStatus;
irp->IoStatus.Information=0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return ntStatus;
}
IoSkipCurrentIrpStackLocation(irp);
ntStatus = IoCallDriver(dx->lowerdo, irp);
IoReleaseRemoveLock(&dx->rmLock, irp);
return ntStatus;
}
示例4: DkDefault
NTSTATUS DkDefault(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
NTSTATUS ntStat = STATUS_SUCCESS;
PDEVICE_EXTENSION pDevExt = NULL;
PIO_STACK_LOCATION pStack = NULL;
PDEVICE_OBJECT pNextDevObj = NULL;
pDevExt = (PDEVICE_EXTENSION) pDevObj->DeviceExtension;
ntStat = IoAcquireRemoveLock(&pDevExt->removeLock, (PVOID) pIrp);
if (!NT_SUCCESS(ntStat))
{
DkDbgVal("Error acquire lock!", ntStat);
DkCompleteRequest(pIrp, ntStat, 0);
return ntStat;
}
pStack = IoGetCurrentIrpStackLocation(pIrp);
DkDbgVal("DkDefault", pStack->MajorFunction);
pNextDevObj = pDevExt->pNextDevObj;
IoSkipCurrentIrpStackLocation(pIrp);
ntStat = IoCallDriver(pNextDevObj, pIrp);
IoReleaseRemoveLock(&pDevExt->removeLock, (PVOID) pIrp);
return ntStat;
}
示例5: YtFilterShutdownFlush
NTSTATUS
YtFilterShutdownFlush(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
NTSTATUS status;
if (KeGetCurrentIrql() <= DISPATCH_LEVEL)
{
status = IoAcquireRemoveLock(&deviceExtension->RemoveLock, Irp);
if(!NT_SUCCESS(status))
{
Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
}
/* DebugPrint(("YtFilterShutdownFlush: DeviceObject %X Irp %X\n",
DeviceObject, Irp));*/
//Set current stack back one.
Irp->CurrentLocation++,
Irp->Tail.Overlay.CurrentStackLocation++;
status = IoCallDriver(deviceExtension->TargetDeviceObject, Irp);
if (KeGetCurrentIrql() <= DISPATCH_LEVEL)
IoReleaseRemoveLock(&deviceExtension->RemoveLock, NULL);
return status;
}
示例6: DispatchForSCSI
NTSTATUS DispatchForSCSI(IN PDEVICE_OBJECT fido, IN PIRP Irp)
{
// KdPrint((DRIVERNAME " - Enter DispatchForSCSI \n"));
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fido->DeviceExtension;
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp);
// Pass request down without additional processing
NTSTATUS status;
status = IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
if (!NT_SUCCESS(status))
return CompleteRequest(Irp, status, 0);
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine( Irp,
USBSCSICompletion,
NULL,
TRUE,
TRUE,
TRUE );
status = IoCallDriver(pdx->LowerDeviceObject, Irp);
IoReleaseRemoveLock(&pdx->RemoveLock, Irp);
return status;
}
示例7: PdoSurpriseRemoval
static DECLSPEC_NOINLINE NTSTATUS
PdoSurpriseRemoval(
IN PXENFILT_PDO Pdo,
IN PIRP Irp
)
{
NTSTATUS status;
status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
if (!NT_SUCCESS(status))
goto fail1;
__PdoSetDevicePnpState(Pdo, SurpriseRemovePending);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp,
__PdoSurpriseRemoval,
Pdo,
TRUE,
TRUE,
TRUE);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
return status;
fail1:
Irp->IoStatus.Status = status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
示例8: DiskDeviceControlWithLock
NTSTATUS
DiskDeviceControlWithLock(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) {
PDokanDCB dcb;
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
dcb = DeviceObject->DeviceExtension;
if (GetIdentifierType(dcb) != DCB) {
PrintIdType(dcb);
DDbgPrint(" Device is not dcb so go out here\n");
return STATUS_INVALID_PARAMETER;
}
status = IoAcquireRemoveLock(&dcb->RemoveLock, Irp);
if (!NT_SUCCESS(status)) {
DDbgPrint("IoAcquireRemoveLock failed with %#x", status);
return STATUS_INSUFFICIENT_RESOURCES;
}
if (IsDeletePending(DeviceObject)) {
DDbgPrint("Device is deleted, so go out here \n");
IoReleaseRemoveLock(&dcb->RemoveLock, Irp);
return STATUS_NO_SUCH_DEVICE;
}
status = DiskDeviceControl(DeviceObject, Irp);
IoReleaseRemoveLock(&dcb->RemoveLock, Irp);
return status;
}
示例9: V4vDispatchWmi
static NTSTATUS NTAPI
V4vDispatchWmi(PDEVICE_OBJECT fdo, PIRP irp)
{
NTSTATUS status;
PXENV4V_EXTENSION pde = V4vGetDeviceExtension(fdo);
TraceVerbose(("====> '%s'.\n", __FUNCTION__));
// We don't support WMI, so just pass it on down the stack
status = IoAcquireRemoveLock(&pde->removeLock, irp);
if (!NT_SUCCESS(status)) {
TraceError(("failed to acquire IO lock - error: 0x%x\n", status));
return V4vSimpleCompleteIrp(irp, status);
}
IoSkipCurrentIrpStackLocation(irp);
status = IoCallDriver(pde->ldo, irp);
IoReleaseRemoveLock(&pde->removeLock, irp);
TraceVerbose(("<==== '%s'.\n", __FUNCTION__));
return status;
}
示例10: YtDispatchFilterPower
NTSTATUS
YtDispatchFilterPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
NTSTATUS status;
if (KeGetCurrentIrql() <= DISPATCH_LEVEL)
{
status = IoAcquireRemoveLock(&deviceExtension->RemoveLock, Irp);
if(!NT_SUCCESS(status))
{
Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
}
PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);
status = PoCallDriver(deviceExtension->TargetDeviceObject, Irp);
if (KeGetCurrentIrql() <= DISPATCH_LEVEL)
IoReleaseRemoveLock(&deviceExtension->RemoveLock, NULL);
return status;
}
示例11: DispatchPower
//========================================================================================
// Function: DispatchPower
// Purpose: This routine is the dispatch routine for power irps.
// Does nothing except forwarding the IRP to the next device in the stack.
// Return Value:
// NT status code
//========================================================================================
NTSTATUS
DispatchPower(
IN PDEVICE_OBJECT fido, // fido - Pointer to the device object.
IN PIRP irp // Irp - Pointer to the request packet.
)
{
PDEVICE_EXTENSION dx;
NTSTATUS ntStatus;
dx = (PDEVICE_EXTENSION)fido->DeviceExtension;
PoStartNextPowerIrp(irp);
//acquire remove lock
ntStatus=IoAcquireRemoveLock(&dx->rmLock, irp);
if (!NT_SUCCESS(ntStatus))
{
//complete irp if cannot acquire remove lock
irp->IoStatus.Status=ntStatus;
irp->IoStatus.Information=0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return ntStatus;
}
IoSkipCurrentIrpStackLocation(irp);
ntStatus = PoCallDriver(dx->lowerdo, irp);
IoReleaseRemoveLock(&dx->rmLock, irp);
return ntStatus;
}
示例12: EncryptedIoQueueAddIrp
NTSTATUS EncryptedIoQueueAddIrp (EncryptedIoQueue *queue, PIRP irp)
{
NTSTATUS status;
InterlockedIncrement (&queue->OutstandingIoCount);
if (queue->StopPending)
{
Dump ("STATUS_DEVICE_NOT_READY out=%d\n", queue->OutstandingIoCount);
status = STATUS_DEVICE_NOT_READY;
goto err;
}
status = IoAcquireRemoveLock (&queue->RemoveLock, irp);
if (!NT_SUCCESS (status))
goto err;
#ifdef TC_TRACE_IO_QUEUE
{
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (irp);
Dump ("* %I64d [%I64d] %c len=%d out=%d\n", irpSp->MajorFunction == IRP_MJ_WRITE ? irpSp->Parameters.Write.ByteOffset : irpSp->Parameters.Read.ByteOffset, GetElapsedTime (&queue->LastPerformanceCounter), irpSp->MajorFunction == IRP_MJ_WRITE ? 'W' : 'R', irpSp->MajorFunction == IRP_MJ_WRITE ? irpSp->Parameters.Write.Length : irpSp->Parameters.Read.Length, queue->OutstandingIoCount);
}
#endif
IoMarkIrpPending (irp);
ExInterlockedInsertTailList (&queue->MainThreadQueue, &irp->Tail.Overlay.ListEntry, &queue->MainThreadQueueLock);
KeSetEvent (&queue->MainThreadQueueNotEmptyEvent, IO_DISK_INCREMENT, FALSE);
return STATUS_PENDING;
err:
DecrementOutstandingIoCount (queue);
return status;
}
示例13: DispatchControl
//========================================================================================
// Function: DispatchControl
// Purpose: This routine is the dispatch handler for the driver. It is responsible
// for processing the IRPs.
// Return Value:
// STATUS_SUCCESS if the IRP was processed successfully, otherwise an error
// indicating the reason for failure.
//========================================================================================
NTSTATUS
DispatchControl(
IN PDEVICE_OBJECT pDO, // pDO - Pointer to device object.
IN PIRP pIrp // pIrp - Pointer to the current IRP.
)
{
PDEVICE_EXTENSION dx;
PIO_STACK_LOCATION pIrpStack;
NTSTATUS Status;
PAGED_CODE();
pIrp->IoStatus.Information = 0;
dx = (PDEVICE_EXTENSION)pDO->DeviceExtension; // Get local info struct
KdPrint(("--> "__FUNCTION__"()\n"));
Status = IoAcquireRemoveLock (&dx->rmLock, NULL);
if (!NT_SUCCESS (Status))
{
pIrp->IoStatus.Information = 0;
pIrp->IoStatus.Status = Status;
IoCompleteRequest (pIrp, IO_NO_INCREMENT);
KdPrint(("<-- "__FUNCTION__"() IoAcquireRemoveLock() Status code: 0x%08x\n", Status));
return Status;
}
if (dx->DevicePnPState != Started)
{
//
// We fail all the IRPs that arrive before the device is started.
//
pIrp->IoStatus.Status = Status = STATUS_DEVICE_NOT_READY;
IoCompleteRequest(pIrp, IO_NO_INCREMENT );
IoReleaseRemoveLock(&dx->rmLock, NULL);
KdPrint(("<-- "__FUNCTION__"() - STATUS_DEVICE_NOT_READY\n"));
return Status;
}
pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
pIrp->IoStatus.Information = DispatchIOCTL(
pIrpStack->Parameters.DeviceIoControl.IoControlCode,
(PUCHAR)pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
(PUCHAR)pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
&Status
);
// We're done with I/O request. Record the status of the I/O action.
pIrp->IoStatus.Status = Status;
// Don't boost priority when returning since this took little time.
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
IoReleaseRemoveLock(&dx->rmLock, NULL);
KdPrint(("<-- "__FUNCTION__"() Completion Status code: 0x%08x\n", Status));
return Status;
}
示例14: SwdmDispatchWrite
NTSTATUS
SwdmDispatchWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PVOID Buf; //Buffer provided by user program
ULONG BufLen; //Buffer length for user provided buffer
LONGLONG Offset;//Buffer Offset
PVOID DataBuf; //Buffer provided by Driver
ULONG DataLen; //Buffer length for Driver Data Buffer
ULONG ByteTransferred;
PIO_STACK_LOCATION pStk;
PDEVICE_EXTENSION pCtx;
//NTSTATUS status;
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MJ_WRITE : Begin\r\n");
//Get I/o Stack Location & Device Extension
pStk = IoGetCurrentIrpStackLocation(Irp);
pCtx = DeviceObject->DeviceExtension;
//Get User Input Buffer & Length
BufLen = pStk->Parameters.Write.Length;
Offset = pStk->Parameters.Read.ByteOffset.QuadPart;
Buf = (PUCHAR)(Irp->AssociatedIrp.SystemBuffer) + Offset;
//Get Driver Data Buffer & Length
DataBuf = pCtx->DataBuffer;
DataLen = 1024;
IoAcquireRemoveLock(&pCtx->RemoveLock, Irp);
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Input Buffer Length : %d\r\n", BufLen);
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Driver Data Length : %d\r\n", DataLen);
if (BufLen <= DataLen) {
ByteTransferred = BufLen;
} else {
ByteTransferred = DataLen;
}
ByteTransferred = BufLen;
RtlZeroMemory(
pCtx->DataBuffer,
1024);
RtlCopyMemory(
DataBuf,
Buf,
ByteTransferred);
IoReleaseRemoveLock(&pCtx->RemoveLock, Irp);
CompleteRequest(Irp, STATUS_SUCCESS, ByteTransferred);
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "IRP_MJ_WRITE : End\r\n");
return STATUS_SUCCESS;
}
示例15: DispatchAny
NTSTATUS DispatchAny(IN PDEVICE_OBJECT fido, IN PIRP Irp)
{ // DispatchAny
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fido->DeviceExtension;
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp);
#if DBG
static char* irpname[] =
{
"IRP_MJ_CREATE",
"IRP_MJ_CREATE_NAMED_PIPE",
"IRP_MJ_CLOSE",
"IRP_MJ_READ",
"IRP_MJ_WRITE",
"IRP_MJ_QUERY_INFORMATION",
"IRP_MJ_SET_INFORMATION",
"IRP_MJ_QUERY_EA",
"IRP_MJ_SET_EA",
"IRP_MJ_FLUSH_BUFFERS",
"IRP_MJ_QUERY_VOLUME_INFORMATION",
"IRP_MJ_SET_VOLUME_INFORMATION",
"IRP_MJ_DIRECTORY_CONTROL",
"IRP_MJ_FILE_SYSTEM_CONTROL",
"IRP_MJ_DEVICE_CONTROL",
"IRP_MJ_INTERNAL_DEVICE_CONTROL",
"IRP_MJ_SHUTDOWN",
"IRP_MJ_LOCK_CONTROL",
"IRP_MJ_CLEANUP",
"IRP_MJ_CREATE_MAILSLOT",
"IRP_MJ_QUERY_SECURITY",
"IRP_MJ_SET_SECURITY",
"IRP_MJ_POWER",
"IRP_MJ_SYSTEM_CONTROL",
"IRP_MJ_DEVICE_CHANGE",
"IRP_MJ_QUERY_QUOTA",
"IRP_MJ_SET_QUOTA",
"IRP_MJ_PNP",
};
UCHAR type = stack->MajorFunction;
// if (type >= arraysize(irpname))
// KdPrint((DRIVERNAME " - Unknown IRP, major type %X\n", type));
// else
// KdPrint((DRIVERNAME " - %s\n", irpname[type]));
#endif
// Pass request down without additional processing
NTSTATUS status;
status = IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
if (!NT_SUCCESS(status))
return CompleteRequest(Irp, status, 0);
IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(pdx->LowerDeviceObject, Irp);
IoReleaseRemoveLock(&pdx->RemoveLock, Irp);
return status;
} // DispatchAny