本文整理汇总了C++中IoGetRelatedDeviceObject函数的典型用法代码示例。如果您正苦于以下问题:C++ IoGetRelatedDeviceObject函数的具体用法?C++ IoGetRelatedDeviceObject怎么用?C++ IoGetRelatedDeviceObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoGetRelatedDeviceObject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TdiDisconnect
NTSTATUS
TdiDisconnect(
PFILE_OBJECT ConnectionObject
)
{
NTSTATUS ntStatus;
KEVENT Event;
PIRP Irp;
PDEVICE_OBJECT DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
IO_STATUS_BLOCK IoStatus;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
if (!(Irp = TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT, DeviceObject, ConnectionObject, &Event, &IoStatus)))
return STATUS_INSUFFICIENT_RESOURCES;
TdiBuildDisconnect(Irp, DeviceObject, ConnectionObject, 0, 0, 0, TDI_DISCONNECT_RELEASE, 0, 0);
ntStatus = IoCallDriver(DeviceObject, Irp);
if (ntStatus == STATUS_PENDING)
ntStatus = KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, 0);
return(ntStatus == STATUS_SUCCESS ? IoStatus.Status : ntStatus);
}
示例2: TdiSetEventHandler
NTSTATUS
TdiSetEventHandler(
PFILE_OBJECT AddressObject,
LONG EventType,
PVOID EventHandler,
PVOID EventContext
)
{
NTSTATUS ntStatus;
KEVENT Event;
PIRP Irp;
PDEVICE_OBJECT DeviceObject = IoGetRelatedDeviceObject(AddressObject);
IO_STATUS_BLOCK IoStatus;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
if (!(Irp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, DeviceObject, AddressObject, &Event, &IoStatus)))
return STATUS_INSUFFICIENT_RESOURCES;
TdiBuildSetEventHandler(Irp, DeviceObject, AddressObject, 0, 0, EventType, EventHandler, EventContext);
ntStatus = IoCallDriver(DeviceObject, Irp);
if (ntStatus == STATUS_PENDING)
ntStatus = KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, 0);
return(ntStatus == STATUS_SUCCESS ? IoStatus.Status : ntStatus);
}
示例3: TdiQueryAddress
NTSTATUS
TdiQueryAddress(
PFILE_OBJECT AddressObject,
PTDI_ADDRESS_INFO AddressInfo,
PULONG pInfoLength
)
{
NTSTATUS ntStatus;
PIRP Irp;
PMDL Mdl;
PDEVICE_OBJECT DeviceObject = IoGetRelatedDeviceObject(AddressObject);
IO_STATUS_BLOCK IoStatus;
if (!(Irp = TdiBuildInternalDeviceControlIrp(TDI_QUERY_INFORMATION, DeviceObject, FileObject, NULL, &IoStatus)))
return STATUS_INSUFFICIENT_RESOURCES;
if (!(Mdl = IoAllocateMdl(AddressInfo, *pInfoLength, FALSE, FALSE, Irp)))
{
IoFreeIrp(Irp);
return STATUS_INSUFFICIENT_RESOURCES;
}
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
TdiBuildQueryInformation(Irp, DeviceObject, AddressObject, NULL, NULL, TDI_QUERY_ADDRESS_INFO, Mdl);
ntStatus = IoCallDriver(DeviceObject, Irp);
return(ntStatus == STATUS_SUCCESS ? IoStatus.Status : ntStatus);
}
示例4: EVhdGetQosStatusDisk
NTSTATUS EVhdGetQosStatusDisk(ParserInstance *parser, PVOID pSystemBuffer, ULONG32 dwSize, QoSStatusCompletionRoutine pfnCompletionCb, PVOID pInterface)
{
PDEVICE_OBJECT pDeviceObject = NULL;
parser->pQoSStatusInterface = pInterface;
parser->pfnQoSStatusCallback = pfnCompletionCb;
memmove(parser->pQoSStatusBuffer, pSystemBuffer, dwSize);
IoReuseIrp(parser->pQoSStatusIrp, STATUS_PENDING);
parser->pQoSStatusIrp->Tail.Overlay.Thread = (PETHREAD)__readgsqword(0x188); // Pointer to calling thread control block
parser->pQoSStatusIrp->AssociatedIrp.SystemBuffer = parser->pQoSStatusBuffer; // IO buffer for buffered control code
PIO_STACK_LOCATION pStackFrame = IoGetNextIrpStackLocation(parser->pQoSStatusIrp);
pDeviceObject = IoGetRelatedDeviceObject(parser->pVhdmpFileObject);
pStackFrame->FileObject = parser->pVhdmpFileObject;
pStackFrame->DeviceObject = pDeviceObject;
pStackFrame->Parameters.DeviceIoControl.IoControlCode = IOCTL_STORAGE_VHD_GET_QOS_STATUS;
pStackFrame->Parameters.DeviceIoControl.InputBufferLength = dwSize;
pStackFrame->Parameters.DeviceIoControl.OutputBufferLength = 0x58;
pStackFrame->MajorFunction = IRP_MJ_DEVICE_CONTROL;
pStackFrame->MinorFunction = 0;
pStackFrame->Flags = 0;
pStackFrame->Control = SL_INVOKE_ON_CANCEL | SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR;
pStackFrame->Context = parser;
pStackFrame->CompletionRoutine = EvhdGetQosStatusCompletionRoutine;
IoCallDriver(pDeviceObject, parser->pQoSStatusIrp);
return STATUS_PENDING;
}
示例5: tdi_disconnect
NTSTATUS tdi_disconnect(PFILE_OBJECT connectionFileObject, ULONG flags)
{
PDEVICE_OBJECT devObj;
KEVENT event;
PIRP irp;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
devObj = IoGetRelatedDeviceObject(connectionFileObject);
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT, devObj, connectionFileObject, &event, &iosb);
if (irp == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
TdiBuildDisconnect(irp, devObj, connectionFileObject, NULL, NULL, NULL, flags, NULL, NULL);
status = IoCallDriver(devObj, irp);
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}
return status;
}
示例6: EVhdNotifyRecoveryStatus
NTSTATUS EVhdNotifyRecoveryStatus(ParserInstance *parser, RecoveryStatusCompletionRoutine pfnCompletionCb, void *pInterface)
{
PDEVICE_OBJECT pDeviceObject = NULL;
if (parser->bResiliencyEnabled)
{
if (!ExAcquireRundownProtection(&parser->RecoveryRundownProtection))
return STATUS_UNSUCCESSFUL;
parser->pfnRecoveryStatusCallback = pfnCompletionCb;
parser->pRecoveryStatusInterface = pInterface;
IoReuseIrp(parser->pRecoveryStatusIrp, STATUS_PENDING);
parser->pRecoveryStatusIrp->Tail.Overlay.Thread = (PETHREAD)__readgsqword(0x188); // Pointer to calling thread control block
PIO_STACK_LOCATION pStackFrame = IoGetNextIrpStackLocation(parser->pRecoveryStatusIrp);
pDeviceObject = IoGetRelatedDeviceObject(parser->pVhdmpFileObject);
pStackFrame->FileObject = parser->pVhdmpFileObject;
pStackFrame->DeviceObject = pDeviceObject;
pStackFrame->Parameters.DeviceIoControl.IoControlCode = IOCTL_STORAGE_VHD_NOTIFY_RECOVERY_STATUS;
pStackFrame->Parameters.DeviceIoControl.InputBufferLength = 0;
pStackFrame->Parameters.DeviceIoControl.OutputBufferLength = 0;
pStackFrame->MajorFunction = IRP_MJ_DEVICE_CONTROL;
pStackFrame->MinorFunction = 0;
pStackFrame->Flags = 0;
pStackFrame->Control = SL_INVOKE_ON_CANCEL | SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR;
pStackFrame->Context = parser;
pStackFrame->CompletionRoutine = EvhdRecoveryStatusCompletionRoutine;
IoCallDriver(pDeviceObject, parser->pRecoveryStatusIrp);
return STATUS_PENDING;
}
else
return STATUS_UNSUCCESSFUL;
}
示例7: tdi_recv_stream
NTSTATUS tdi_recv_stream(PFILE_OBJECT connectionFileObject, char *buf, int len, ULONG flags)
{
PDEVICE_OBJECT devObj;
KEVENT event;
PIRP irp;
PMDL mdl;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
devObj = IoGetRelatedDeviceObject(connectionFileObject);
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = TdiBuildInternalDeviceControlIrp(TDI_RECEIVE, devObj, connectionFileObject, &event, &iosb);
if (irp == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
if (len)
{
mdl = IoAllocateMdl((void*) buf, len, FALSE, FALSE, NULL);
if (mdl == NULL)
{
IoFreeIrp(irp);
return STATUS_INSUFFICIENT_RESOURCES;
}
__try
{
MmProbeAndLockPages(mdl, KernelMode, IoWriteAccess);
status = STATUS_SUCCESS;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
IoFreeMdl(mdl);
IoFreeIrp(irp);
status = STATUS_INVALID_USER_BUFFER;
}
if (!NT_SUCCESS(status))
{
return status;
}
}
TdiBuildReceive(irp, devObj, connectionFileObject, NULL, NULL, len ? mdl : 0, flags, len);
status = IoCallDriver(devObj, irp);
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}
return NT_SUCCESS(status) ? iosb.Information : status;
}
示例8: 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;
}
示例9: CcMdlWriteComplete
VOID
CcMdlWriteComplete (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain
)
{
PDEVICE_OBJECT DeviceObject;
PFAST_IO_DISPATCH FastIoDispatch;
DeviceObject = IoGetRelatedDeviceObject( FileObject );
FastIoDispatch = DeviceObject->DriverObject->FastIoDispatch;
if ((FastIoDispatch != NULL) &&
(FastIoDispatch->SizeOfFastIoDispatch > FIELD_OFFSET(FAST_IO_DISPATCH, MdlWriteComplete)) &&
(FastIoDispatch->MdlWriteComplete != NULL) &&
FastIoDispatch->MdlWriteComplete( FileObject, FileOffset, MdlChain, DeviceObject )) {
NOTHING;
} else {
CcMdlWriteComplete2( FileObject, FileOffset, MdlChain );
}
}
示例10: tdi_set_event_handler
NTSTATUS tdi_set_event_handler(PFILE_OBJECT addressFileObject, LONG eventType, PVOID eventHandler, PVOID eventContext)
{
PDEVICE_OBJECT devObj;
KEVENT event;
PIRP irp;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
devObj = IoGetRelatedDeviceObject(addressFileObject);
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, devObj, addressFileObject, &event, &iosb);
if (irp == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
TdiBuildSetEventHandler(irp, devObj, addressFileObject, NULL, NULL, eventType, eventHandler, eventContext);
status = IoCallDriver(devObj, irp);
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}
return status;
}
示例11: tdi_associate_address
NTSTATUS tdi_associate_address(PFILE_OBJECT connectionFileObject, HANDLE addressHandle)
{
PDEVICE_OBJECT devObj;
KEVENT event;
PIRP irp;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
devObj = IoGetRelatedDeviceObject(connectionFileObject);
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = TdiBuildInternalDeviceControlIrp(TDI_ASSOCIATE_ADDRESS, devObj, connectionFileObject, &event, &iosb);
if (irp == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
TdiBuildAssociateAddress(irp, devObj, connectionFileObject, NULL, NULL, addressHandle);
status = IoCallDriver(devObj, irp);
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = iosb.Status;
}
return status;
}
示例12: TdiSetEventHandler
NTSTATUS TdiSetEventHandler(
PFILE_OBJECT FileObject,
LONG EventType,
PVOID Handler,
PVOID Context)
/*
* FUNCTION: Sets or resets an event handler
* ARGUMENTS:
* FileObject = Pointer to file object
* EventType = Event code
* Handler = Event handler to be called when the event occurs
* Context = Context input to handler when the event occurs
* RETURNS:
* Status of operation
* NOTES:
* Specify NULL for Handler to stop calling event handler
*/
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
KEVENT Event;
PIRP Irp;
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
if (!FileObject) {
AFD_DbgPrint(MIN_TRACE, ("Bad file object.\n"));
return STATUS_INVALID_PARAMETER;
}
DeviceObject = IoGetRelatedDeviceObject(FileObject);
if (!DeviceObject) {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
return STATUS_INVALID_PARAMETER;
}
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, /* Sub function */
DeviceObject, /* Device object */
FileObject, /* File object */
&Event, /* Event */
&Iosb); /* Status */
if (!Irp)
return STATUS_INSUFFICIENT_RESOURCES;
TdiBuildSetEventHandler(Irp,
DeviceObject,
FileObject,
NULL,
NULL,
EventType,
Handler,
Context);
return TdiCall(Irp, DeviceObject, &Event, &Iosb);
}
示例13: TdiQueryDeviceControl
NTSTATUS TdiQueryDeviceControl(
PFILE_OBJECT FileObject,
ULONG IoControlCode,
PVOID InputBuffer,
ULONG InputBufferLength,
PVOID OutputBuffer,
ULONG OutputBufferLength,
PULONG Return)
/*
* FUNCTION: Queries a device for information
* ARGUMENTS:
* FileObject = Pointer to file object
* IoControlCode = I/O control code
* InputBuffer = Pointer to buffer with input data
* InputBufferLength = Length of InputBuffer
* OutputBuffer = Address of buffer to place output data
* OutputBufferLength = Length of OutputBuffer
* RETURNS:
* Status of operation
*/
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
KEVENT Event;
PIRP Irp;
if (!FileObject) {
AFD_DbgPrint(MIN_TRACE, ("Bad file object.\n"));
return STATUS_INVALID_PARAMETER;
}
DeviceObject = IoGetRelatedDeviceObject(FileObject);
if (!DeviceObject) {
AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
return STATUS_INVALID_PARAMETER;
}
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(IoControlCode,
DeviceObject,
InputBuffer,
InputBufferLength,
OutputBuffer,
OutputBufferLength,
FALSE,
&Event,
&Iosb);
if (!Irp)
return STATUS_INSUFFICIENT_RESOURCES;
Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
if (Return)
*Return = Iosb.Information;
return Status;
}
示例14: Pin_fnWrite
NTSTATUS
NTAPI
Pin_fnWrite(
PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PDISPATCH_CONTEXT Context;
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
NTSTATUS Status;
/* Get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
/* The dispatch context is stored in the FsContext member */
Context = (PDISPATCH_CONTEXT)IoStack->FileObject->FsContext;
/* Sanity check */
ASSERT(Context);
if (Context->hMixerPin)
{
// FIXME
// call kmixer to convert stream
UNIMPLEMENTED
}
/* acquire real pin file object */
Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("failed\n");
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = Status;
/* Complete the irp */
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
/* skip current irp location */
IoSkipCurrentIrpStackLocation(Irp);
/* get next stack location */
IoStack = IoGetNextIrpStackLocation(Irp);
/* store file object of next device object */
IoStack->FileObject = FileObject;
IoStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
//ASSERT(Irp->AssociatedIrp.SystemBuffer);
/* now call the driver */
Status = IoCallDriver(IoGetRelatedDeviceObject(FileObject), Irp);
/* dereference file object */
ObDereferenceObject(FileObject);
return Status;
}
示例15: EngFileIoControl
NTSTATUS
APIENTRY
EngFileIoControl(
IN PFILE_OBJECT pFileObject,
IN DWORD dwIoControlCode,
IN PVOID lpInBuffer,
IN SIZE_T nInBufferSize,
OUT PVOID lpOutBuffer,
IN SIZE_T nOutBufferSize,
OUT PULONG_PTR lpInformation)
{
PDEVICE_OBJECT pDeviceObject;
KEVENT Event;
PIRP pIrp;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
/* Get corresponding device object */
pDeviceObject = IoGetRelatedDeviceObject(pFileObject);
if (!pDeviceObject)
{
return STATUS_INVALID_PARAMETER;
}
/* Initialize an event */
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
/* Build IO control IRP */
pIrp = IoBuildDeviceIoControlRequest(dwIoControlCode,
pDeviceObject,
lpInBuffer,
(ULONG)nInBufferSize,
lpOutBuffer,
(ULONG)nOutBufferSize,
FALSE,
&Event,
&Iosb);
if (!pIrp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Call the driver */
Status = IoCallDriver(pDeviceObject, pIrp);
/* Wait if neccessary */
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0);
Status = Iosb.Status;
}
/* Return information to the caller about the operation. */
*lpInformation = Iosb.Information;
/* This function returns NTSTATUS */
return Status;
}