本文整理汇总了C++中IoAllocateIrp函数的典型用法代码示例。如果您正苦于以下问题:C++ IoAllocateIrp函数的具体用法?C++ IoAllocateIrp怎么用?C++ IoAllocateIrp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoAllocateIrp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewTransferPacket
PTRANSFER_PACKET NewTransferPacket(PDEVICE_OBJECT Fdo)
{
PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension;
PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
PTRANSFER_PACKET newPkt;
newPkt = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSFER_PACKET), 'pnPC');
if (newPkt){
RtlZeroMemory(newPkt, sizeof(TRANSFER_PACKET)); // just to be sure
/*
* Allocate resources for the packet.
*/
newPkt->Irp = IoAllocateIrp(Fdo->StackSize, FALSE);
if (newPkt->Irp){
KIRQL oldIrql;
newPkt->Fdo = Fdo;
/*
* Enqueue the packet in our static AllTransferPacketsList
* (just so we can find it during debugging if its stuck somewhere).
*/
KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
InsertTailList(&fdoData->AllTransferPacketsList, &newPkt->AllPktsListEntry);
KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
}
else {
ExFreePool(newPkt);
newPkt = NULL;
}
}
return newPkt;
}
示例2: 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;
}
示例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: WaitForUsbDeviceArrivalNotification
NTSTATUS
WaitForUsbDeviceArrivalNotification(PDEVICE_OBJECT DeviceObject)
{
PURB Urb;
PIRP Irp;
NTSTATUS Status;
PIO_STACK_LOCATION Stack = NULL;
PHUB_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
Urb = &DeviceExtension->Urb;
RtlZeroMemory(Urb, sizeof(URB));
/* Send URB to the miniports Status Change Endpoint SCE */
UsbBuildInterruptOrBulkTransferRequest(Urb,
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
DeviceExtension->PipeHandle,
&DeviceExtension->PortStatus,
NULL,
sizeof(ULONG) * 2,
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
NULL);
Urb->UrbHeader.UsbdDeviceHandle = DeviceExtension->RootHubUsbDevice;
Irp = IoAllocateIrp(DeviceExtension->RootHubPdo->StackSize, FALSE);
if (Irp == NULL)
{
DPRINT("Usbhub: IoBuildDeviceIoControlRequest() failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0;
Irp->Flags = 0;
Irp->UserBuffer = NULL;
Stack = IoGetCurrentIrpStackLocation(Irp);
Stack->DeviceObject = DeviceExtension->RootHubPdo;
Stack = IoGetNextIrpStackLocation(Irp);
Stack->DeviceObject = DeviceExtension->RootHubPdo;
Stack->Parameters.Others.Argument1 = Urb;
Stack->Parameters.Others.Argument2 = NULL;
Stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
Stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
//IoSetCompletionRoutineEx(DeviceExtension->RootHubPdo, Irp, (PIO_COMPLETION_ROUTINE)DeviceArrivalCompletion, DeviceObject, TRUE, TRUE, TRUE);
IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE)DeviceArrivalCompletion, DeviceObject, TRUE, TRUE, TRUE);
Status = IoCallDriver(DeviceExtension->RootHubPdo, Irp);
DPRINT1("SCE request status %x\n", Status);
return STATUS_PENDING;
}
示例5: AsyncReadWriteSec
NTSTATUS
AsyncReadWriteSec(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP ParentIrp,
IN ULONG ulStartSec,
IN ULONG ulSectors,
IN PVOID pBuffer,
IN UCHAR MajorFunction
)
{
PMDL MDL;
KEVENT event;
PIRP Irp;
ULONG ulBytes;
LARGE_INTEGER Start;
IO_STATUS_BLOCK ioStatus;
NTSTATUS status = STATUS_SUCCESS;
PIO_STACK_LOCATION NextIrpStack;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
ulBytes = ulSectors * SECTOR_SIZE;
Start.QuadPart = ((LONGLONG)ulStartSec)*SECTOR_SIZE;
Irp = IoAllocateIrp(LOBYTE(LOWORD(deviceExtension->TargetDeviceObject->StackSize+1)),FALSE);
//Irp = IoBuildSynchronousFsdRequest( MajorFunction,
// deviceExtension->TargetDeviceObject,
// pBuffer,ulBytes,
// &Start,&event,
// &ioStatus );
ASSERT(Irp);
if (!Irp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
MDL = IoAllocateMdl(pBuffer,ulBytes,FALSE,FALSE,Irp);
if (!MDL)
return STATUS_INSUFFICIENT_RESOURCES;
MmBuildMdlForNonPagedPool(MDL);
IoSetNextIrpStackLocation(Irp);
NextIrpStack = IoGetNextIrpStackLocation(Irp);
NextIrpStack->DeviceObject = deviceExtension->TargetDeviceObject;
NextIrpStack->MajorFunction = MajorFunction;
NextIrpStack->MinorFunction = 0;
NextIrpStack->Parameters.Read.Length = ulBytes;
NextIrpStack->Parameters.Read.Key = 0;
NextIrpStack->Parameters.Read.ByteOffset.QuadPart = Start.QuadPart;
RtlCopyMemory(&(NextIrpStack->Parameters.Write),&(NextIrpStack->Parameters.Read),sizeof(NextIrpStack->Parameters.Read));
IoSetCompletionRoutine(Irp,AsyncCompletion,ParentIrp,TRUE,TRUE,TRUE);
status = IoCallDriver(deviceExtension->TargetDeviceObject,Irp);
return status;
} // end SyncReadWriteSec()
示例6: EvhdInitialize
static NTSTATUS EvhdInitialize(HANDLE hFileHandle, PFILE_OBJECT pFileObject, ParserInstance *parser)
{
NTSTATUS status = STATUS_SUCCESS;
parser->pVhdmpFileObject = pFileObject;
parser->FileHandle = hFileHandle;
/* Initialize Direct IO */
parser->pDirectIoIrp = IoAllocateIrp(IoGetRelatedDeviceObject(parser->pVhdmpFileObject)->StackSize, FALSE);
if (!parser->pDirectIoIrp)
{
LOG_PARSER(LL_FATAL, "IoAllocateIrp failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Initialize QoS */
parser->pQoSStatusIrp = IoAllocateIrp(IoGetRelatedDeviceObject(parser->pVhdmpFileObject)->StackSize, FALSE);
if (!parser->pQoSStatusIrp)
{
LOG_PARSER(LL_FATAL, "IoAllocateIrp failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
parser->pQoSStatusBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, QoSBufferSize, EvhdQoSPoolTag);
if (!parser->pQoSStatusBuffer)
{
LOG_PARSER(LL_FATAL, "ExAllocatePoolWithTag failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Initialize CTL */
ExInitializeRundownProtection(&parser->RecoveryRundownProtection);
parser->pRecoveryStatusIrp = IoAllocateIrp(IoGetRelatedDeviceObject(parser->pVhdmpFileObject)->StackSize, FALSE);
if (!parser->pRecoveryStatusIrp)
{
LOG_PARSER(LL_FATAL, "IoAllocateIrp failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
parser->FileHandle = hFileHandle;
parser->pVhdmpFileObject = pFileObject;
return status;
}
示例7: UNREFERENCED_PARAMETER
_Must_inspect_result_
FORCEINLINE
MdIrp
FxIrp::AllocateIrp(
_In_ CCHAR StackSize,
_In_opt_ FxDevice* Device
)
{
UNREFERENCED_PARAMETER(Device);
return IoAllocateIrp(StackSize, FALSE);
}
示例8: XenM2BPdoDeviceUsageNotification
static NTSTATUS
XenM2BPdoDeviceUsageNotification(PXENM2B_PDO_EXTENSION pPdoExt,
PIRP pIrp)
{
PDEVICE_OBJECT pDeviceObject;
PIO_STACK_LOCATION pIrpStack;
PIRP pSubIrp;
PIO_STACK_LOCATION pSubIrpStack;
NTSTATUS Status;
pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
// Find the top of the FDO stack and hold a reference
pDeviceObject = IoGetAttachedDeviceReference(pPdoExt->pFdo);
// Get a new IRP for the FDO stack and reserve an extra stack location
// for our use here.
pSubIrp = IoAllocateIrp(pDeviceObject->StackSize + 1, FALSE);
if (pSubIrp == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
// Fill in the first stack location with our context information
// which we'll need to complete the original IRP.
pSubIrpStack = IoGetNextIrpStackLocation(pSubIrp);
pSubIrpStack->DeviceObject = pDeviceObject;
pSubIrpStack->Parameters.Others.Argument1 = (PVOID)pIrp;
// Advance the stack location, copy in the information from the
// original IRP and set up our completion routine.
IoSetNextIrpStackLocation(pSubIrp);
pSubIrpStack = IoGetNextIrpStackLocation(pSubIrp);
RtlCopyMemory(pSubIrpStack,
pIrpStack,
FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
pSubIrpStack->Control = 0;
IoSetCompletionRoutine(pSubIrp,
XenM2BPdoDeviceUsageCompletion,
NULL,
TRUE,
TRUE,
TRUE);
// Default completion status
pSubIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
IoMarkIrpPending(pIrp);
IoCallDriver(pDeviceObject, pSubIrp);
return STATUS_PENDING;
}
示例9: mm_allocate_irp_success
PIRP mm_allocate_irp_success(CCHAR StackSize)
{
PIRP irp;
int timeout;
for (timeout = DC_MEM_RETRY_TIMEOUT; timeout > 0; timeout -= DC_MEM_RETRY_TIME)
{
if (irp = IoAllocateIrp(StackSize, FALSE)) break;
if (KeGetCurrentIrql() >= DISPATCH_LEVEL) break;
dc_delay(DC_MEM_RETRY_TIME);
}
return irp;
}
示例10: xTdiBuildInternalIrp
static
FORCEINLINE
PIRP
xTdiBuildInternalIrp(
__in PDEVICE_OBJECT ConnectionDeviceObject,
__in PFILE_OBJECT ConnectionFileObject,
__in PKEVENT Event,
__in PIO_STATUS_BLOCK IoStatus)
{
PIRP irp = IoAllocateIrp(ConnectionDeviceObject->StackSize + 1, FALSE);
irp->UserEvent = Event;
irp->UserIosb = IoStatus;
return irp;
}
示例11: IrpQueryFile
NTSTATUS
IrpQueryFile(
IN PFILE_OBJECT FileObject,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
)
{
NTSTATUS status;
KEVENT event;
PIRP irp;
IO_STATUS_BLOCK ioStatus;
PIO_STACK_LOCATION irpSp;
PDEVICE_OBJECT deviceObject;
if (FileObject->Vpb == 0 || FileObject->Vpb->RealDevice == NULL)
return STATUS_UNSUCCESSFUL;
deviceObject = FileObject->Vpb->DeviceObject;
KeInitializeEvent(&event, SynchronizationEvent, FALSE);
irp = IoAllocateIrp(deviceObject->StackSize, FALSE);
if (irp == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
irp->Flags = IRP_BUFFERED_IO;
irp->AssociatedIrp.SystemBuffer = FileInformation;
irp->RequestorMode = KernelMode;
irp->Overlay.AsynchronousParameters.UserApcRoutine = (PIO_APC_ROUTINE)NULL;
irp->UserEvent = &event;
irp->UserIosb = &ioStatus;
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
irp->Tail.Overlay.OriginalFileObject = FileObject;
irpSp = IoGetNextIrpStackLocation(irp);
irpSp->MajorFunction = IRP_MJ_QUERY_INFORMATION;
irpSp->DeviceObject = deviceObject;
irpSp->FileObject = FileObject;
irpSp->Parameters.QueryFile.Length = Length;
irpSp->Parameters.QueryFile.FileInformationClass = FileInformationClass;
IoSetCompletionRoutine(irp, IoCompletionRoutine, NULL, TRUE, TRUE, TRUE);
status = IoCallDriver(deviceObject, irp);
if (status == STATUS_PENDING)
KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, NULL);
return ioStatus.Status;
}
示例12: FspIopPostWorkRequestFunnel
NTSTATUS FspIopPostWorkRequestFunnel(PDEVICE_OBJECT DeviceObject,
FSP_FSCTL_TRANSACT_REQ *Request, BOOLEAN BestEffort)
{
PAGED_CODE();
ASSERT(0 == Request->Hint);
NTSTATUS Result;
PIRP Irp;
if (BestEffort)
Irp = FspAllocateIrpMustSucceed(DeviceObject->StackSize);
else
{
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (0 == Irp)
{
Result = STATUS_INSUFFICIENT_RESOURCES;
goto exit;
}
}
PIO_STACK_LOCATION IrpSp = IoGetNextIrpStackLocation(Irp);
Irp->RequestorMode = KernelMode;
IrpSp->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;
IrpSp->MinorFunction = IRP_MN_USER_FS_REQUEST;
IrpSp->Parameters.FileSystemControl.FsControlCode = BestEffort ?
FSP_FSCTL_WORK_BEST_EFFORT : FSP_FSCTL_WORK;
IrpSp->Parameters.FileSystemControl.InputBufferLength = Request->Size;
IrpSp->Parameters.FileSystemControl.Type3InputBuffer = Request;
ASSERT(METHOD_NEITHER == (IrpSp->Parameters.DeviceIoControl.IoControlCode & 3));
IoSetCompletionRoutine(Irp, FspIopPostWorkRequestCompletion, 0, TRUE, TRUE, TRUE);
Result = IoCallDriver(DeviceObject, Irp);
if (STATUS_PENDING == Result)
return STATUS_SUCCESS;
/*
* If we did not receive STATUS_PENDING, we still own the Request and must delete it!
*/
exit:
FspIopDeleteRequest(Request);
return Result;
}
示例13: IrpQueryDirectoryFile
NTSTATUS
IrpQueryDirectoryFile(
IN PFILE_OBJECT FileObject,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass,
IN PUNICODE_STRING FileName OPTIONAL)
{
NTSTATUS ntStatus;
PIRP Irp;
KEVENT kEvent;
PIO_STACK_LOCATION IrpSp;
if (FileObject->Vpb == 0 || FileObject->Vpb->DeviceObject == NULL)
return STATUS_UNSUCCESSFUL;
Irp = IoAllocateIrp(FileObject->Vpb->DeviceObject->StackSize, FALSE);
if(Irp == NULL) return STATUS_INSUFFICIENT_RESOURCES;
KeInitializeEvent(&kEvent, SynchronizationEvent, FALSE);
RtlZeroMemory(FileInformation, Length);
Irp->UserEvent = &kEvent;
Irp->UserIosb = IoStatusBlock;
Irp->UserBuffer = FileInformation;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
Irp->Tail.Overlay.OriginalFileObject = FileObject;
Irp->Overlay.AsynchronousParameters.UserApcRoutine = (PIO_APC_ROUTINE)NULL;
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MajorFunction = IRP_MJ_DIRECTORY_CONTROL;
IrpSp->MinorFunction = IRP_MN_QUERY_DIRECTORY;
IrpSp->FileObject = FileObject;
IrpSp->Flags = SL_RESTART_SCAN;
IrpSp->Parameters.QueryDirectory.Length = Length;
IrpSp->Parameters.QueryDirectory.FileName = FileName;
IrpSp->Parameters.QueryDirectory.FileInformationClass = FileInformationClass;
IoSetCompletionRoutine(Irp, IoCompletionRoutine, 0, TRUE, TRUE, TRUE);
ntStatus = IoCallDriver(FileObject->Vpb->DeviceObject, Irp);
if (ntStatus == STATUS_PENDING)
KeWaitForSingleObject(&kEvent, Executive, KernelMode, TRUE, 0);
return IoStatusBlock->Status;
}
示例14: ASSERT
NTSTATUS CIrp::Create(PDEVICE_OBJECT TargetDevice)
{
ASSERT(m_TargetDevice == nullptr);
ASSERT(m_Irp == nullptr);
m_Irp = IoAllocateIrp(TargetDevice->StackSize, FALSE);
if (m_Irp == nullptr)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
m_Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
ObReferenceObject(TargetDevice);
m_TargetDevice = TargetDevice;
return STATUS_SUCCESS;
}
示例15: FspAllocateIrpMustSucceed
PVOID FspAllocateIrpMustSucceed(CCHAR StackSize)
{
// !PAGED_CODE();
PIRP Result;
LARGE_INTEGER Delay;
for (ULONG i = 0, n = sizeof(Delays) / sizeof(Delays[0]);; i++)
{
Result = DEBUGTEST(99) ? IoAllocateIrp(StackSize, FALSE) : 0;
if (0 != Result)
return Result;
Delay.QuadPart = n > i ? Delays[i] : Delays[n - 1];
KeDelayExecutionThread(KernelMode, FALSE, &Delay);
}
}