• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IoAllocateIrp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IoAllocateIrp函数的典型用法代码示例。如果您正苦于以下问题:C++ IoAllocateIrp函数的具体用法?C++ IoAllocateIrp怎么用?C++ IoAllocateIrp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IoAllocateIrp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:35,代码来源:xferpkt.c


示例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;
}
开发者ID:340211173,项目名称:Remote_Malware_Analyzer,代码行数:29,代码来源:sockets.c


示例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;
}
开发者ID:miguelinux,项目名称:vbox,代码行数:35,代码来源:VBoxUsbTool.cpp


示例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;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:59,代码来源:fdo.c


示例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()
开发者ID:xfxf123444,项目名称:japan,代码行数:57,代码来源:Iomon.C


示例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;
}
开发者ID:the-alien,项目名称:evhdparser,代码行数:44,代码来源:parser.c


示例7: UNREFERENCED_PARAMETER

_Must_inspect_result_
FORCEINLINE
MdIrp
FxIrp::AllocateIrp(
    _In_ CCHAR StackSize,
    _In_opt_ FxDevice* Device
    )
{
    UNREFERENCED_PARAMETER(Device);
    
    return IoAllocateIrp(StackSize, FALSE);
}
开发者ID:AntejaVM,项目名称:WDF,代码行数:12,代码来源:fxirpkm.hpp


示例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;
}
开发者ID:OpenXT,项目名称:xc-windows,代码行数:52,代码来源:pdo.c


示例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;
}
开发者ID:capturePointer,项目名称:DiskCryptor-1,代码行数:13,代码来源:misc_mem.c


示例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;
}
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:14,代码来源:xtdi.c


示例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;
}
开发者ID:lcxl,项目名称:lcxl-shadow,代码行数:49,代码来源:winkernel.c


示例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;
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:48,代码来源:iop.c


示例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;
}
开发者ID:AmesianX,项目名称:A-Protect,代码行数:47,代码来源:FileSystem.c


示例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;
}
开发者ID:daynix,项目名称:UsbDk,代码行数:17,代码来源:Irp.cpp


示例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);
    }
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:17,代码来源:util.c


示例16: IrpSetInformationFile

NTSTATUS
IrpSetInformationFile(
					  IN PFILE_OBJECT FileObject,
					  OUT PIO_STATUS_BLOCK IoStatusBlock,
					  IN PVOID FileInformation,
					  IN ULONG Length,
					  IN FILE_INFORMATION_CLASS FileInformationClass,
					  IN BOOLEAN ReplaceIfExists)
{
	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);

	Irp->AssociatedIrp.SystemBuffer = FileInformation;
	Irp->UserEvent = &kEvent;
	Irp->UserIosb = IoStatusBlock;
	Irp->RequestorMode = KernelMode;
	Irp->Tail.Overlay.Thread = PsGetCurrentThread();
	Irp->Tail.Overlay.OriginalFileObject = FileObject;

	IrpSp = IoGetNextIrpStackLocation(Irp);
	IrpSp->MajorFunction = IRP_MJ_SET_INFORMATION;
	IrpSp->DeviceObject = FileObject->Vpb->DeviceObject;
	IrpSp->FileObject = FileObject;
	IrpSp->Parameters.SetFile.ReplaceIfExists = ReplaceIfExists;
	IrpSp->Parameters.SetFile.FileObject = FileObject;
	IrpSp->Parameters.SetFile.AdvanceOnly = FALSE;
	IrpSp->Parameters.SetFile.Length = Length;
	IrpSp->Parameters.SetFile.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;
}
开发者ID:AmesianX,项目名称:A-Protect,代码行数:46,代码来源:FileSystem.c


示例17: say_hello

NTSTATUS say_hello(PDEVICE_OBJECT deviceObject) {
	NTSTATUS status = STATUS_SUCCESS;

	DbgPrint("Say Hello to 0x%08X\n", deviceObject);

	PIRP myIrp = IoAllocateIrp(deviceObject->StackSize, FALSE);
	if (!myIrp) {
		DbgPrint("Cannot allocate Irp\n");
		status = STATUS_INSUFFICIENT_RESOURCES;
		goto cleanup;
	}

	PIO_STACK_LOCATION pMyIoStackLocation = IoGetNextIrpStackLocation(myIrp);
	if (!pMyIoStackLocation) {
		DbgPrint("No stack location\n");
		status = STATUS_UNSUCCESSFUL;
		goto cleanup;
	}

	pMyIoStackLocation->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
	pMyIoStackLocation->Parameters.DeviceIoControl.IoControlCode = MY_INTERNAL_IOCTL_HELLO;

	char buffer[BUFFER_SIZE] = "Hello you!";

	pMyIoStackLocation->Parameters.DeviceIoControl.InputBufferLength  = BUFFER_SIZE;
	pMyIoStackLocation->Parameters.DeviceIoControl.OutputBufferLength = BUFFER_SIZE;

	myIrp->AssociatedIrp.SystemBuffer = buffer;
	myIrp->MdlAddress = NULL;

	IoSetCompletionRoutine(myIrp, my_completion_routine, NULL, TRUE, TRUE, TRUE);

	status = IoCallDriver(deviceObject, myIrp);
	if (status != STATUS_SUCCESS) {
		DbgPrint("Error while calling the other driver\n");
		goto cleanup;
	}
	DbgPrint("The other one says: %s\n", myIrp->AssociatedIrp.SystemBuffer);

cleanup:
	if (myIrp) {
		IoFreeIrp(myIrp);
	}
	return status;
}
开发者ID:ChibiTomo,项目名称:sandbox,代码行数:45,代码来源:second_driver.c


示例18: EVhdPrepareMetaOperation

NTSTATUS EVhdPrepareMetaOperation(ParserInstance *parser, MetaOperationBuffer *pBuffer, MetaOperationCompletionRoutine pfnCompletionCb, void *pInterface, MetaOperation **ppOperation)
{
	MetaOperation *pOperation = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(MetaOperation), EvhdPoolTag);
	if (!pOperation)
		return STATUS_INSUFFICIENT_RESOURCES;
	pOperation->pfnCompletionRoutine = pfnCompletionCb;
	pOperation->pParser = parser;
	pOperation->pInterface = pInterface;
	pOperation->pIrp = IoAllocateIrp(IoGetRelatedDeviceObject(parser->pVhdmpFileObject)->StackSize, FALSE);
	pOperation->pBuffer = pBuffer;
	if (!pOperation->pIrp)
	{
		EVhdCleanupMetaOperation(pOperation);
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	*ppOperation = pOperation;
	return STATUS_SUCCESS;
}
开发者ID:the-alien,项目名称:evhdparser,代码行数:18,代码来源:parser.c


示例19: LspDataInitialize

NTSTATUS
LspDataInitialize(
	__in PDEVICE_OBJECT DeviceObject,
	__in PDEVICE_OBJECT ConnectionDeviceObject, 
	__inout PLSP_TRANSFER_DATA LspTransferData)
{
	RtlZeroMemory(LspTransferData, sizeof(LSP_TRANSFER_DATA));

	LspTransferData->Irp = IoAllocateIrp(
		ConnectionDeviceObject->StackSize + 1,
		FALSE);
	if (NULL == LspTransferData->Irp)
	{
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	LspTransferData->Overlapped.CompletionRoutine = LspTransferCompletion;
	LspTransferData->Overlapped.UserContext = DeviceObject;
	return STATUS_SUCCESS;
}
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:19,代码来源:lsptransfer.c


示例20: InitWskData

NTSTATUS
InitWskData(
	__out PIRP*		pIrp,
	__out PKEVENT	CompletionEvent
)
{
	ASSERT(pIrp);
	ASSERT(CompletionEvent);

	*pIrp = IoAllocateIrp(1, FALSE);
	if (!*pIrp)
	{
		return STATUS_INSUFFICIENT_RESOURCES;
	}

	KeInitializeEvent(CompletionEvent, SynchronizationEvent, FALSE);
	IoSetCompletionRoutine(*pIrp, CompletionRoutine, CompletionEvent, TRUE, TRUE, TRUE);

	return STATUS_SUCCESS;
}
开发者ID:airhigh,项目名称:wdrbd,代码行数:20,代码来源:wsk2.c



注:本文中的IoAllocateIrp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IoAllocateMdl函数代码示例发布时间:2022-05-30
下一篇:
C++ IoAcquireRemoveLock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap