本文整理汇总了C++中IoFreeIrp函数的典型用法代码示例。如果您正苦于以下问题:C++ IoFreeIrp函数的具体用法?C++ IoFreeIrp怎么用?C++ IoFreeIrp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoFreeIrp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: DestroyTransferPacket
/*
* DestroyTransferPacket
*
*/
VOID DestroyTransferPacket(PTRANSFER_PACKET Pkt)
{
PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Pkt->Fdo->DeviceExtension;
PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
KIRQL oldIrql;
ASSERT(!Pkt->SlistEntry.Next);
// ASSERT(!Pkt->OriginalIrp);
KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
/*
* Delete the packet from our all-packets queue.
*/
ASSERT(!IsListEmpty(&Pkt->AllPktsListEntry));
ASSERT(!IsListEmpty(&fdoData->AllTransferPacketsList));
RemoveEntryList(&Pkt->AllPktsListEntry);
InitializeListHead(&Pkt->AllPktsListEntry);
KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
IoFreeMdl(Pkt->PartialMdl);
IoFreeIrp(Pkt->Irp);
FREE_POOL(Pkt->RetryHistory);
FREE_POOL(Pkt);
}
示例3: VBOXUSBTOOL_DECL
VBOXUSBTOOL_DECL(NTSTATUS) VBoxUsbToolGetDeviceSpeed(PDEVICE_OBJECT pDevObj, BOOLEAN *pbIsHigh)
{
Assert(pbIsHigh);
*pbIsHigh = FALSE;
PIRP pIrp = IoAllocateIrp(pDevObj->StackSize, FALSE);
Assert(pIrp);
if (!pIrp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
USB_BUS_INTERFACE_USBDI_V1 BusIf;
PIO_STACK_LOCATION pSl = IoGetNextIrpStackLocation(pIrp);
pSl->MajorFunction = IRP_MJ_PNP;
pSl->MinorFunction = IRP_MN_QUERY_INTERFACE;
pSl->Parameters.QueryInterface.InterfaceType = &USB_BUS_INTERFACE_USBDI_GUID;
pSl->Parameters.QueryInterface.Size = sizeof (BusIf);
pSl->Parameters.QueryInterface.Version = USB_BUSIF_USBDI_VERSION_1;
pSl->Parameters.QueryInterface.Interface = (PINTERFACE)&BusIf;
pSl->Parameters.QueryInterface.InterfaceSpecificData = NULL;
pIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
NTSTATUS Status = VBoxDrvToolIoPostSync(pDevObj, pIrp);
Assert(NT_SUCCESS(Status) || Status == STATUS_NOT_SUPPORTED);
if (NT_SUCCESS(Status))
{
*pbIsHigh = BusIf.IsDeviceHighSpeed(BusIf.BusContext);
BusIf.InterfaceDereference(BusIf.BusContext);
}
IoFreeIrp(pIrp);
return Status;
}
示例4: IoCompletionRoutine
NTSTATUS
IoCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Context);
PAGED_CODE();
KdPrint(("SYS(%d:%d):IoCompletionRoutine!\n", PsGetCurrentProcessId(), PsGetCurrentThreadId()));
*Irp->UserIosb = Irp->IoStatus;
if (Irp->UserEvent)
KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, 0);
if (Irp->MdlAddress)
{
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
}
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例5: IoCompletionRoutine
NTSTATUS
IoCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
//DbgPrint(("IoCompletionRoutine!\n"));
*Irp->UserIosb = Irp->IoStatus;
if (Irp->MdlAddress)
{
//MmUnmapLockedPages( Irp->MdlAddress,
// MmGetSystemAddressForMdlSafe( Irp->MdlAddress, NormalPagePriority ) );
MmUnlockPages( Irp->MdlAddress );
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
}
if (Irp->UserEvent)
KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, 0);
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
//return STATUS_SUCCESS;
}
示例6: DeviceArrivalCompletion
NTSTATUS
DeviceArrivalCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
{
PHUB_DEVICE_EXTENSION DeviceExtension;
LONG i;
PWORKITEMDATA WorkItemData;
DeviceExtension = (PHUB_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
for (i=0; i < DeviceExtension->UsbExtHubInfo.NumberOfPorts; i++)
DPRINT1("Port %x DeviceExtension->PortStatus %x\n",i+1, DeviceExtension->PortStatus[i]);
IoFreeIrp(Irp);
WorkItemData = ExAllocatePool(NonPagedPool, sizeof(WORKITEMDATA));
if (!WorkItemData)
{
DPRINT1("Failed to allocate memory\n");
return STATUS_NO_MEMORY;
}
RtlZeroMemory(WorkItemData, sizeof(WORKITEMDATA));
WorkItemData->Context = Context;
ExInitializeWorkItem(&WorkItemData->WorkItem, (PWORKER_THREAD_ROUTINE)WorkerThread, (PVOID)WorkItemData);
ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue);
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例7: ASSERT
void CIrp::DestroyIrp()
{
ASSERT(m_Irp != nullptr);
IoFreeIrp(m_Irp);
m_Irp = nullptr;
}
示例8: SelectiveSuspendCompletionRoutine
NTSTATUS SelectiveSuspendCompletionRoutine(PDEVICE_OBJECT pdo, PIRP Irp, UsbDev *pUsbDev)
{
NTSTATUS ntStatus = Irp->IoStatus.Status;
DBGU_TRACE("SelectiveSuspendCompletionRoutine: 0x%08X\n",ntStatus);
//test
/*if (InterlockedExchangePointer((PVOID *)&pUsbDev->m_SuspendIrp, NULL))
{
DBGU_TRACE("IoFreeIrp Suspend IRP at Completion Routine..\n");
IoFreeIrp(Irp);
}*/
InterlockedExchangePointer((PVOID *)&pUsbDev->m_SuspendIrp, NULL);
DBGU_TRACE("IoFreeIrp Suspend IRP at Completion Routine..\n");
IoFreeIrp(Irp);
// fix incorrect power state transition during S0 -> S3 (ymwu, 2005/7/16)
// this irp will be cancelled when system power state is changed to S3
// device power state should not be set to D0 in this situation
// if you make incorrect power state transition, the system sometimes hangs
{
DBGU_TRACE("Cancel Selective Suspend..\n");
pUsbDev->m_SuspendCancelled = 1;
}
KeSetEvent(&pUsbDev->m_SuspendIrpCancelEvent, IO_NO_INCREMENT, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例9: 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);
}
示例10: disconnectfromserver
NTSTATUS
disconnectfromserver(PWSK_SOCKET sock)
{
NTSTATUS status;
KEVENT event;
PIRP irp;
irp = IoAllocateIrp(1, FALSE);
if(!irp){
return STATUS_INSUFFICIENT_RESOURCES;
}
KeInitializeEvent(&event, NotificationEvent, FALSE);
IoSetCompletionRoutine(irp, disconnectcomplete, &event, TRUE, TRUE,
TRUE);
status = ((PWSK_PROVIDER_CONNECTION_DISPATCH)(sock->Dispatch))->
WskCloseSocket(sock, irp);
if(status == STATUS_PENDING){
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
status = irp->IoStatus.Status;
}
IoFreeIrp(irp);
return status;
}
示例11: SkillSetFileCompletion
NTSTATUS
SkillSetFileCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
BOOL bInit = FALSE;
ReLoadNtosCALL(&RKeSetEvent,L"KeSetEvent",SystemKernelModuleBase,ImageModuleBase);
if (RKeSetEvent)
{
bInit = TRUE;
}
if (!bInit)
return STATUS_UNSUCCESSFUL;
Irp->UserIosb->Status = Irp->IoStatus.Status;
Irp->UserIosb->Information = Irp->IoStatus.Information;
RKeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, FALSE);
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例12: CloseWskEventSocket
NTSTATUS
CloseWskEventSocket()
{
if (!netlink_server_socket)
{
return STATUS_SUCCESS;
}
KEVENT CompletionEvent = {0};
PIRP irp = NULL;
NTSTATUS status = InitWskData(&irp, &CompletionEvent);
if (!NT_SUCCESS(status))
{
return status;
}
status = ((PWSK_PROVIDER_BASIC_DISPATCH)netlink_server_socket->Dispatch)->WskCloseSocket(netlink_server_socket, irp);
if (STATUS_PENDING == status)
{
KeWaitForSingleObject(&CompletionEvent, Executive, KernelMode, FALSE, NULL);
status = irp->IoStatus.Status;
}
IoFreeIrp(irp);
WskDeregister(&gWskEventRegistration);
return status;
}
示例13: PopRequestPowerIrpCompletion
static
NTSTATUS
NTAPI
PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context)
{
PIO_STACK_LOCATION Stack;
PREQUEST_POWER_COMPLETE CompletionRoutine;
POWER_STATE PowerState;
Stack = IoGetCurrentIrpStackLocation(Irp);
CompletionRoutine = Context;
PowerState.DeviceState = (ULONG_PTR)Stack->Parameters.Others.Argument3;
CompletionRoutine(Stack->Parameters.Others.Argument1,
(UCHAR)(ULONG_PTR)Stack->Parameters.Others.Argument2,
PowerState,
Stack->Parameters.Others.Argument4,
&Irp->IoStatus);
IoSkipCurrentIrpStackLocation(Irp);
IoFreeIrp(Irp);
ObDereferenceObject(DeviceObject);
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例14: Ext2ReadWriteBlockSyncCompletionRoutine
NTSTATUS
Ext2ReadWriteBlockSyncCompletionRoutine (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context )
{
PEXT2_RW_CONTEXT pContext = (PEXT2_RW_CONTEXT)Context;
if (Irp != pContext->MasterIrp) {
if (!NT_SUCCESS(Irp->IoStatus.Status)) {
pContext->MasterIrp->IoStatus = Irp->IoStatus;
}
IoFreeMdl(Irp->MdlAddress);
IoFreeIrp(Irp );
}
if (InterlockedDecrement(&pContext->Blocks) == 0) {
pContext->MasterIrp->IoStatus.Information = 0;
if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status)) {
pContext->MasterIrp->IoStatus.Information =
pContext->Length;
}
KeSetEvent(&pContext->Event, 0, FALSE);
}
return STATUS_MORE_PROCESSING_REQUIRED;
}
示例15: PopRequestPowerIrpCompletion
static
NTSTATUS
NTAPI
PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context)
{
PIO_STACK_LOCATION Stack;
PREQUEST_POWER_ITEM RequestPowerItem;
Stack = IoGetNextIrpStackLocation(Irp);
RequestPowerItem = (PREQUEST_POWER_ITEM)Context;
RequestPowerItem->CompletionRoutine(DeviceObject,
Stack->MinorFunction,
RequestPowerItem->PowerState,
RequestPowerItem->Context,
&Irp->IoStatus);
IoFreeIrp(Irp);
ObDereferenceObject(RequestPowerItem->TopDeviceObject);
ExFreePool(Context);
return STATUS_MORE_PROCESSING_REQUIRED;
}