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

C++ IoGetDeviceObjectPointer函数代码示例

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

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



在下文中一共展示了IoGetDeviceObjectPointer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: setfilter

static void setfilter(PacketFilterExtensionPtr fn) {
	UNICODE_STRING name;
	PDEVICE_OBJECT device=NULL;
	PFILE_OBJECT file=NULL;
	NTSTATUS status;

	RtlInitUnicodeString(&name, DD_IPFLTRDRVR_DEVICE_NAME);
	status=IoGetDeviceObjectPointer(&name, STANDARD_RIGHTS_ALL, &file, &device);

	if(NT_SUCCESS(status)) {
		KEVENT event;
		IO_STATUS_BLOCK iostatus;
		PF_SET_EXTENSION_HOOK_INFO hookinfo;
		PIRP irp;

		hookinfo.ExtensionPointer=fn;
		KeInitializeEvent(&event, NotificationEvent, FALSE);

		irp=IoBuildDeviceIoControlRequest(
			IOCTL_PF_SET_EXTENSION_POINTER, device, &hookinfo,
			sizeof(PF_SET_EXTENSION_HOOK_INFO), NULL, 0, FALSE, &event, &iostatus);

		if(irp && IoCallDriver(device, irp)==STATUS_PENDING)
			KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);

		if(file) ObDereferenceObject(file);
	}
}
开发者ID:Tudi,项目名称:PG2-firewall,代码行数:28,代码来源:filter.c


示例2: RegisterForTargetDeviceNotification

/*
 * @implemented
 */
VOID
RegisterForTargetDeviceNotification(IN PDEVICE_EXTENSION DeviceExtension,
                                    IN PDEVICE_INFORMATION DeviceInformation)
{
    NTSTATUS Status;
    PFILE_OBJECT FileObject;
    PDEVICE_OBJECT DeviceObject;

    /* Get device object */
    Status = IoGetDeviceObjectPointer(&(DeviceInformation->DeviceName),
                                      FILE_READ_ATTRIBUTES,
                                      &FileObject,
                                      &DeviceObject);
    if (!NT_SUCCESS(Status))
    {
        return;
    }

    /* And simply register for notifications */
    Status = IoRegisterPlugPlayNotification(EventCategoryTargetDeviceChange,
                                            0, FileObject,
                                            DeviceExtension->DriverObject,
                                            MountMgrTargetDeviceNotification,
                                            DeviceInformation,
                                            &(DeviceInformation->TargetDeviceNotificationEntry));
    if (!NT_SUCCESS(Status))
    {
        DeviceInformation->TargetDeviceNotificationEntry = NULL;
    }

    ObDereferenceObject(FileObject);

    return;
}
开发者ID:Strongc,项目名称:reactos,代码行数:37,代码来源:notify.c


示例3: vol_close

NTSTATUS vol_close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
    volume_device_extension* vde = DeviceObject->DeviceExtension;
    pdo_device_extension* pdode = vde->pdode;

    TRACE("(%p, %p)\n", DeviceObject, Irp);

    Irp->IoStatus.Information = 0;

    ExAcquireResourceExclusiveLite(&pdo_list_lock, TRUE);

    ExAcquireResourceSharedLite(&pdode->child_lock, TRUE);

    if (InterlockedDecrement(&vde->open_count) == 0 && vde->removing) {
        NTSTATUS Status;
        UNICODE_STRING mmdevpath;
        PDEVICE_OBJECT mountmgr;
        PFILE_OBJECT mountmgrfo;
        PDEVICE_OBJECT pdo;

        RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
        Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &mountmgrfo, &mountmgr);
        if (!NT_SUCCESS(Status))
            ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
        else {
            remove_drive_letter(mountmgr, &vde->name);

            ObDereferenceObject(mountmgrfo);
        }

        if (vde->mounted_device) {
            device_extension* Vcb = vde->mounted_device->DeviceExtension;

            Vcb->vde = NULL;
        }

        if (vde->name.Buffer)
            ExFreePool(vde->name.Buffer);

        ExReleaseResourceLite(&pdode->child_lock);
        ExDeleteResourceLite(&pdode->child_lock);

        if (vde->pdo->AttachedDevice)
            IoDetachDevice(vde->pdo);

        pdo = vde->pdo;
        IoDeleteDevice(vde->device);

        if (!no_pnp)
            IoDeleteDevice(pdo);
    } else
        ExReleaseResourceLite(&pdode->child_lock);

    ExReleaseResourceLite(&pdo_list_lock);

    return STATUS_SUCCESS;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:56,代码来源:volume.c


示例4: DokanSendIoContlToMountManager

NTSTATUS
DokanSendIoContlToMountManager(__in ULONG IoControlCode, __in PVOID InputBuffer,
                               __in ULONG Length, __out PVOID OutputBuffer,
                               __in ULONG OutputLength) {
  NTSTATUS status;
  UNICODE_STRING mountManagerName;
  PFILE_OBJECT mountFileObject;
  PDEVICE_OBJECT mountDeviceObject;
  PIRP irp;
  KEVENT driverEvent;
  IO_STATUS_BLOCK iosb;

  DDbgPrint("=> DokanSendIoContlToMountManager\n");

  RtlInitUnicodeString(&mountManagerName, MOUNTMGR_DEVICE_NAME);

  status = IoGetDeviceObjectPointer(&mountManagerName, FILE_READ_ATTRIBUTES,
                                    &mountFileObject, &mountDeviceObject);

  if (!NT_SUCCESS(status)) {
    DDbgPrint("  IoGetDeviceObjectPointer failed: 0x%x\n", status);
    return status;
  }

  KeInitializeEvent(&driverEvent, NotificationEvent, FALSE);

  irp = IoBuildDeviceIoControlRequest(IoControlCode, mountDeviceObject,
                                      InputBuffer, Length, OutputBuffer,
                                      OutputLength, FALSE, &driverEvent, &iosb);

  if (irp == NULL) {
    DDbgPrint("  IoBuildDeviceIoControlRequest failed\n");
    return STATUS_INSUFFICIENT_RESOURCES;
  }

  status = IoCallDriver(mountDeviceObject, irp);

  if (status == STATUS_PENDING) {
    KeWaitForSingleObject(&driverEvent, Executive, KernelMode, FALSE, NULL);
  }
  status = iosb.Status;

  ObDereferenceObject(mountFileObject);
  // Don't dereference mountDeviceObject, mountFileObject is enough

  if (NT_SUCCESS(status)) {
    DDbgPrint("  IoCallDriver success\n");
  } else {
    DDbgPrint("  IoCallDriver failed: 0x%x\n", status);
  }

  DDbgPrint("<= DokanSendIoContlToMountManager\n");

  return status;
}
开发者ID:MelcherSt,项目名称:dokany,代码行数:55,代码来源:init.c


示例5: ImScsiGetAdapterDeviceObject

NTSTATUS
ImScsiGetAdapterDeviceObject()
{
    NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND;
    int i;
    UNICODE_STRING objname = { 0 };
    PFILE_OBJECT file_object = NULL;
    PDEVICE_OBJECT device_object = NULL;
    WCHAR objstr[] = L"\\Device\\Scsi\\PhDskMnt00";

    if (pMPDrvInfoGlobal->DeviceObject != NULL)
        return STATUS_SUCCESS;

    for (i = 0; i < 100; i++)
    {
        LARGE_INTEGER wait_time;

        if ((i & 7) == 7)
        {
            wait_time.QuadPart = -1;
            KeDelayExecutionThread(KernelMode, FALSE, &wait_time);
        }

        _snwprintf(objstr, sizeof(objstr)/sizeof(*objstr), L"\\Device\\Scsi\\PhDskMnt%i", i);

        RtlInitUnicodeString(&objname, objstr);

        KdPrint2(("PhDskMnt::ImScsiGetAdapterDeviceObject: Attempt to open %ws...\n", objstr));
    
        status = IoGetDeviceObjectPointer(&objname, GENERIC_ALL, &file_object, &device_object);

        if (!NT_SUCCESS(status))
        {
            KdPrint2(("PhDskMnt::ImScsiGetAdapterDeviceObject: Attempt to open %ws failed: status=0x%x\n", objstr, status));
            continue;
        }

        if (device_object->DriverObject != pMPDrvInfoGlobal->pDriverObj)
        {
            KdPrint2(("PhDskMnt::ImScsiGetAdapterDeviceObject: %ws was not our device.\n", objstr, status));
            continue;
        }

        pMPDrvInfoGlobal->DeviceObject = device_object;

        return STATUS_SUCCESS;
    }

    if (NT_SUCCESS(status))
        KdPrint(("PhDskMnt::ImScsiGetAdapterDeviceObject: Successfully opened %ws.\n", objstr));
    else
        DbgPrint(("PhDskMnt::ImScsiGetAdapterDeviceObject: Could not locate SCSI adapter device object by name.\n"));

    return status;
}
开发者ID:ludaohong,项目名称:Arsenal-Image-Mounter,代码行数:55,代码来源:phdskmnt.c


示例6: setfilter

static void setfilter(PacketFilterExtensionPtr fn)
{
	UNICODE_STRING name;
	PDEVICE_OBJECT device=NULL;
	PFILE_OBJECT file=NULL;
	NTSTATUS status;

	DbgPrint("pbfilter:  > Entering setfilter()\n");
	RtlInitUnicodeString(&name, DD_IPFLTRDRVR_DEVICE_NAME);
	status=IoGetDeviceObjectPointer(&name, STANDARD_RIGHTS_ALL, &file, &device);

	if(NT_SUCCESS(status))
	{
		KEVENT event;
		IO_STATUS_BLOCK iostatus;
		PF_SET_EXTENSION_HOOK_INFO hookinfo;
		PIRP irp;

		DbgPrint("pbfilter:    got devobj\n");
		hookinfo.ExtensionPointer=fn;
		KeInitializeEvent(&event, NotificationEvent, FALSE);

		irp=IoBuildDeviceIoControlRequest(
				IOCTL_PF_SET_EXTENSION_POINTER, device, &hookinfo,
				sizeof(PF_SET_EXTENSION_HOOK_INFO), NULL, 0, FALSE, &event, &iostatus);

		DbgPrint("pbfilter:    calling into driver\n");
		if(irp && IoCallDriver(device, irp)==STATUS_PENDING)
		{
			DbgPrint("pbfilter:    waiting for IRP to complete\n");
			KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
		}
		else
		{
			DbgPrint("pbfilter:    IRP not pending (or no IRP?)\n");
		}

		if(file)
		{
			DbgPrint("pbfilter:    Dereferencing file\n");
			ObDereferenceObject(file);
		}
		else
		{
			DbgPrint("pbfilter:    no file to dereference\n");
		}
	}
	else
	{
		DbgPrint("pbfilter:  * ERROR: unable to get IpFltDrv DevObj, status:[0x%lX]\n", status);
	}

	DbgPrint("pbfilter:  < Leaving setfilter()\n");
}
开发者ID:Cecildt,项目名称:peerblock,代码行数:54,代码来源:filter.c


示例7: DriverEntry

NTSTATUS DriverEntry(
	__in PDRIVER_OBJECT DriverObject,
	__in PUNICODE_STRING RegistryPath
	)
{
	UNICODE_STRING CfixkrName = RTL_CONSTANT_STRING( CFIXKR_DEVICE_NT_NAME );
	PFILE_OBJECT File;
	PDEVICE_OBJECT CfixkrObject;
	NTSTATUS Status;

	UNREFERENCED_PARAMETER( RegistryPath );

	KdPrint( ( "CFIXDRV: DriverEntry of test driver\n" ) );

	//
	// Install dispatch routines.
	//
	DriverObject->MajorFunction[ IRP_MJ_CREATE ]	= CfixkDrvNotImplemented;
	DriverObject->MajorFunction[ IRP_MJ_CLOSE ]		= CfixkDrvNotImplemented;
	DriverObject->DriverUnload						= CfixkDrvUnload;

	//
	// Lookup cfixkr and obtain interface.
	//
	Status = IoGetDeviceObjectPointer(
		&CfixkrName,
		FILE_WRITE_DATA,
		&File,
		&CfixkrObject );
	if ( ! NT_SUCCESS( Status ) )
	{
		KdPrint( ( "CFIX: Failed to obtain pointer to cfixkr device\n" ) );
		return Status;
	}

	Status = CfixkDrvQueryReporter( CfixkrObject );
	if ( NT_SUCCESS( Status ) )
	{
		//
		// Keep a reference to the device to lock the driver in
		// memory until we have released the interface.
		//
		ObReferenceObject( CfixkrObject );
		CfixkDrvCfixkrDevice = CfixkrObject;
	}

	//
	// We have obtained the interface, which is referenced. We can thus
	// release File while having locked the DO through the interface.
	//
	ObDereferenceObject( File );

	return Status; 
}
开发者ID:jpassing,项目名称:cfix,代码行数:54,代码来源:drvmain.c


示例8: SendOnlineNotification

/*
 * @implemented
 */
VOID
SendOnlineNotification(IN PUNICODE_STRING SymbolicName)
{
    PIRP Irp;
    KEVENT Event;
    NTSTATUS Status;
    PFILE_OBJECT FileObject;
    PIO_STACK_LOCATION Stack;
    PDEVICE_OBJECT DeviceObject;
    IO_STATUS_BLOCK IoStatusBlock;

    /* Get device object */
    Status = IoGetDeviceObjectPointer(SymbolicName,
                                      FILE_READ_ATTRIBUTES,
                                      &FileObject,
                                      &DeviceObject);
    if (!NT_SUCCESS(Status))
    {
        return;
    }

    /* And attached device object */
    DeviceObject = IoGetAttachedDeviceReference(FileObject->DeviceObject);

    /* And send VOLUME_ONLINE */
    KeInitializeEvent(&Event, NotificationEvent, FALSE);
    Irp = IoBuildDeviceIoControlRequest(IOCTL_VOLUME_ONLINE,
                                        DeviceObject,
                                        NULL, 0,
                                        NULL, 0,
                                        FALSE,
                                        &Event,
                                        &IoStatusBlock);
    if (!Irp)
    {
        goto Cleanup;
    }

    Stack = IoGetNextIrpStackLocation(Irp);
    Stack->FileObject = FileObject;

    Status = IoCallDriver(DeviceObject, Irp);
    if (Status == STATUS_PENDING)
    {
        KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
    }

Cleanup:
    ObDereferenceObject(DeviceObject);
    ObDereferenceObject(FileObject);

    return;
}
开发者ID:Strongc,项目名称:reactos,代码行数:56,代码来源:notify.c


示例9: VBoxGdcInit

/* Guest Device Communication API */
NTSTATUS VBoxGdcInit()
{
    UNICODE_STRING UniName;
    RtlInitUnicodeString(&UniName, VBOXGUEST_DEVICE_NAME_NT);
    NTSTATUS Status = IoGetDeviceObjectPointer(&UniName, FILE_ALL_ACCESS, &g_ctx.Gdc.pFo, &g_ctx.Gdc.pDo);
    if (!NT_SUCCESS(Status))
    {
        WARN(("IoGetDeviceObjectPointer failed Status(0x%x)", Status));
        memset(&g_ctx.Gdc, 0, sizeof (g_ctx.Gdc));
    }
    return Status;
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:13,代码来源:VBoxMFInternal.cpp


示例10: ssh_virtual_adapter_device_add_ref

/* ssh_virtual_adapter_device_add_ref()
 *
 * Increments the reference count of underlying virtual NIC's device object
 * thus ensuring that the virtual NIC can't be unloaded from memory.
 *
 * This function must be run on IRQL PASSIVE_LEVEL.
 *
 */
static Boolean
ssh_virtual_adapter_device_add_ref(SshVirtualAdapter va)
{
  Boolean status = TRUE;
#ifndef _WIN32_WCE
  PDEVICE_OBJECT device_object = NULL;
  UNICODE_STRING device_name;
#endif /* _WIN32_WCE */

  SSH_DEBUG(SSH_D_MIDSTART, ("ssh_virtual_adapter_device_add_ref()"));

  SSH_ASSERT(va != NULL);
  SSH_ASSERT(va->adapter != NULL);
  SSH_ASSERT(va->file_object == NULL);

#ifndef _WIN32_WCE
  SSH_ASSERT(SSH_GET_IRQL() == SSH_PASSIVE_LEVEL);

  NdisInitUnicodeString(&device_name, NULL);

  if (ssh_adapter_device_object_name_get(va->adapter, &device_name))
    {
      SSH_ASSERT(device_name.Buffer != NULL);
      SSH_ASSERT(device_name.Length > 0);

      if (!NT_SUCCESS(IoGetDeviceObjectPointer(
				       &device_name, FILE_ALL_ACCESS,
				       (PFILE_OBJECT *)&va->file_object,
				       &device_object)))
        {
          SSH_DEBUG(SSH_D_FAIL, ("IoGetDeviceObjectPointer() FAILED!"));

          status = FALSE;
        }

      ssh_free(device_name.Buffer);
    }
  else
    {
      SSH_DEBUG(SSH_D_FAIL, ("ssh_device_object_name_get() FAILED!"));
      status = FALSE;
    }

#else /* not _WIN32_WCE */

  /* Just initialize with a bogus value... */
  va->file_object = (void *)0x00BEEF00;

#endif /* not _WIN32_WCE */

  return (status);
}
开发者ID:patrick-ken,项目名称:kernel_808l,代码行数:60,代码来源:virtual_adapter_private.c


示例11: vbglDriverOpen

RT_C_DECLS_END
# endif

int vbglDriverOpen (VBGLDRIVER *pDriver)
{
# ifdef RT_OS_WINDOWS
    UNICODE_STRING uszDeviceName;
    RtlInitUnicodeString (&uszDeviceName, L"\\Device\\VBoxGuest");

    PDEVICE_OBJECT pDeviceObject = NULL;
    PFILE_OBJECT pFileObject = NULL;

    NTSTATUS rc = IoGetDeviceObjectPointer (&uszDeviceName, FILE_ALL_ACCESS,
                                            &pFileObject, &pDeviceObject);

    if (NT_SUCCESS (rc))
    {
        Log(("vbglDriverOpen VBoxGuest successful pDeviceObject=%x\n", pDeviceObject));
        pDriver->pDeviceObject = pDeviceObject;
        pDriver->pFileObject = pFileObject;
        return VINF_SUCCESS;
    }
    /** @todo return RTErrConvertFromNtStatus(rc)! */
    Log(("vbglDriverOpen VBoxGuest failed with ntstatus=%x\n", rc));
    return rc;

# elif defined (RT_OS_OS2)
    /*
     * Just check whether the connection was made or not.
     */
    if (    g_VBoxGuestIDC.u32Version == VMMDEV_VERSION
        &&  VALID_PTR(g_VBoxGuestIDC.u32Session)
        &&  VALID_PTR(g_VBoxGuestIDC.pfnServiceEP))
    {
        pDriver->u32Session = g_VBoxGuestIDC.u32Session;
        return VINF_SUCCESS;
    }
    pDriver->u32Session = UINT32_MAX;
    Log(("vbglDriverOpen: failed\n"));
    return VERR_FILE_NOT_FOUND;

# else
    uint32_t u32VMMDevVersion;
    pDriver->pvOpaque = VBoxGuestIDCOpen (&u32VMMDevVersion);
    if (    pDriver->pvOpaque
        &&  u32VMMDevVersion == VMMDEV_VERSION)
        return VINF_SUCCESS;

    Log(("vbglDriverOpen: failed\n"));
    return VERR_FILE_NOT_FOUND;
# endif
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:52,代码来源:SysHlp.cpp


示例12: get_device_object

/* get device object by its name */
NTSTATUS
get_device_object(wchar_t *name, PDEVICE_OBJECT *devobj)
{
	UNICODE_STRING str;
	NTSTATUS status;
	PFILE_OBJECT fileobj;

	RtlInitUnicodeString(&str, name);

	status = IoGetDeviceObjectPointer(&str, FILE_ALL_ACCESS, &fileobj, devobj);
	if (status == STATUS_SUCCESS)
		ObDereferenceObject(fileobj);

	return status;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:16,代码来源:tdi_fw.c


示例13: FspGetDeviceObjectPointer

NTSTATUS FspGetDeviceObjectPointer(PUNICODE_STRING ObjectName, ACCESS_MASK DesiredAccess,
    PULONG PFileNameIndex, PFILE_OBJECT *PFileObject, PDEVICE_OBJECT *PDeviceObject)
{
    PAGED_CODE();

    UNICODE_STRING PartialName;
    OBJECT_ATTRIBUTES ObjectAttributes;
    HANDLE Handle;
    NTSTATUS Result;

    PartialName.Length = 0;
    PartialName.MaximumLength = ObjectName->Length;
    PartialName.Buffer = ObjectName->Buffer;

    Result = STATUS_NO_SUCH_DEVICE;
    while (PartialName.MaximumLength > PartialName.Length)
    {
        while (PartialName.MaximumLength > PartialName.Length &&
            L'\\' == PartialName.Buffer[PartialName.Length / sizeof(WCHAR)])
            PartialName.Length += sizeof(WCHAR);
        while (PartialName.MaximumLength > PartialName.Length &&
            L'\\' != PartialName.Buffer[PartialName.Length / sizeof(WCHAR)])
            PartialName.Length += sizeof(WCHAR);

        Result = IoGetDeviceObjectPointer(&PartialName, DesiredAccess, PFileObject, PDeviceObject);
        if (NT_SUCCESS(Result))
        {
            *PFileNameIndex = PartialName.Length;
            break;
        }

        InitializeObjectAttributes(&ObjectAttributes, &PartialName, OBJ_KERNEL_HANDLE, 0, 0);
        Result = ZwOpenDirectoryObject(&Handle, 0, &ObjectAttributes);
        if (!NT_SUCCESS(Result))
        {
            Result = ZwOpenSymbolicLinkObject(&Handle, 0, &ObjectAttributes);
            if (!NT_SUCCESS(Result))
            {
                Result = STATUS_NO_SUCH_DEVICE;
                break;
            }
        }
        ZwClose(Handle);
    }

    return Result;
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:47,代码来源:util.c


示例14: CFTOpenCom

// 打开一个端口设备
PDEVICE_OBJECT CFTOpenCom(ULONG aId, NTSTATUS *aStatus)
{
	UNICODE_STRING nameString;
	static WCHAR name[32] = {0};
	PFILE_OBJECT fileObject = NULL;
	PDEVICE_OBJECT deviceObject = NULL;

	// 输入字符串
	RtlZeroMemory(name, sizeof(WCHAR)*32);
	RtlStringCchPrintfW(name, 32, L"\\Device\\Serial%d", aId);
	RtlInitUnicodeString(&nameString, name);

	// 打开设备对象
	*aStatus = IoGetDeviceObjectPointer(&nameString, FILE_ALL_ACCESS, &fileObject, &deviceObject);
	if (*aStatus == STATUS_SUCCESS)
		ObDereferenceObject(fileObject);

	return deviceObject;
}
开发者ID:killbug2004,项目名称:wy-windows-driver,代码行数:20,代码来源:wycomflt.cpp


示例15: OpenCom

PDEVICE_OBJECT OpenCom(ULONG id, NTSTATUS* status)
{
	UNICODE_STRING name_str;
	static WCHAR name[32] = { 0 };
	PFILE_OBJECT fileobj = NULL;
	PDEVICE_OBJECT devobj = NULL;

	memset(name, 0, sizeof(WCHAR)* 32);
	RtlStringCchPrintfW(
		name, 32,
		L"\\Device\\Serial%d", id);
	RtlInitUnicodeString(&name_str, name);
	*status = IoGetDeviceObjectPointer(
		&name_str, FILE_ALL_ACCESS,
		&fileobj, &devobj);
	if (*status == STATUS_SUCCESS)
		ObDereferenceObject(fileobj);

	return devobj;
}
开发者ID:61--,项目名称:learn_driver,代码行数:20,代码来源:main.c


示例16: testRoutine

void testRoutine(_In_     PDEVICE_OBJECT pDeviceObject, _In_opt_ PVOID          pContext){
	UNREFERENCED_PARAMETER(pDeviceObject);
	UNREFERENCED_PARAMETER(pContext);
	PFILE_OBJECT pFileObj;
	PDEVICE_OBJECT pDevObj;
	NTSTATUS status = STATUS_UNSUCCESSFUL;

	if (!pContext){
		DbgPrint("pcontext null");
		return;
	}
	PMY_WORK_CONTEXT pWorkContext = (PMY_WORK_CONTEXT)pContext;
	status = IoGetDeviceObjectPointer(pWorkContext->pSymlink, 0, &pFileObj, &pDevObj);
	if (status){
		DbgPrint("failed to access devobj!%lX", status);
		return;
	}
	DbgPrint("not failed to access devobj!%lX", status);
	ObfDereferenceObject(pFileObj);
	ObfDereferenceObject(pDevObj);
	//return;
}
开发者ID:Microwave89,项目名称:kbdfnflt2,代码行数:22,代码来源:main.c


示例17: supR0IdcNativeOpen

int VBOXCALL supR0IdcNativeOpen(PSUPDRVIDCHANDLE pHandle, PSUPDRVIDCREQCONNECT pReq)
{
    PDEVICE_OBJECT  pDeviceObject = NULL;
    PFILE_OBJECT    pFileObject = NULL;
    UNICODE_STRING  wszDeviceName;
    NTSTATUS        rcNt;
    int             rc;

    /*
     * Get the device object pointer.
     */
    RtlInitUnicodeString(&wszDeviceName, DEVICE_NAME_NT);
    rcNt = IoGetDeviceObjectPointer(&wszDeviceName, FILE_ALL_ACCESS, &pFileObject, &pDeviceObject);
    if (NT_SUCCESS(rcNt))
    {
        /*
         * Make the connection call.
         */
        rc = supR0IdcNtCallInternal(pDeviceObject, pFileObject, SUPDRV_IDC_REQ_CONNECT, &pReq->Hdr);
        if (RT_SUCCESS(rc))
        {
            pHandle->s.pDeviceObject = pDeviceObject;
            pHandle->s.pFileObject   = pFileObject;
            return rc;
        }

        /* only the file object. */
        ObDereferenceObject(pFileObject);
    }
    else
        rc = RTErrConvertFromNtStatus(rcNt);

    pHandle->s.pDeviceObject = NULL;
    pHandle->s.pFileObject = NULL;
    return rc;
}
开发者ID:sobomax,项目名称:virtualbox_64bit_edd,代码行数:36,代码来源:SUPR0IdcClient-win.c


示例18: KBFAttachDevicesEx

NTSTATUS KBFAttachDevicesEx(IN PDRIVER_OBJECT aDriverObject, IN PUNICODE_STRING aRegistryPath)
{
    UNREFERENCED_PARAMETER(aDriverObject);
    UNREFERENCED_PARAMETER(aRegistryPath);

    NTSTATUS status = STATUS_SUCCESS;

    // 遍历所有键盘设备
    UNICODE_STRING nameString;
    static WCHAR name[32] = {0};
    ULONG index = 0;

    PDEVICE_OBJECT deviceObject = NULL;
    PFILE_OBJECT fileObject = NULL;

    // 第一个设备
    RtlZeroMemory(name, sizeof(WCHAR)*32);
    RtlStringCchPrintfW(name, 32, L"\\Device\\KeyboardClass%d", index);
    RtlInitUnicodeString(&nameString, name);

    // 打开设备对象
    status = IoGetDeviceObjectPointer(&nameString, FILE_ALL_ACCESS, &fileObject, &deviceObject);
    if (NT_SUCCESS(status))
        ObDereferenceObject(fileObject);

    while (deviceObject != NULL)
    {
        PDEVICE_OBJECT pFilterDeviceObject = NULL;
        PDEVICE_OBJECT pLowerDeviceObject = NULL;

        // 创建一个过滤设备
        status = IoCreateDevice(aDriverObject, sizeof(DEVICE_EXTENSION), NULL,
                                deviceObject->DeviceType, deviceObject->Characteristics, FALSE, &pFilterDeviceObject);

        if (!NT_SUCCESS(status))
        {
            KdPrint(("wykbflt.sys : KBFAttachDevices Couldn't create the Filter Device Object %d\n", index));
            break;
        }

        pLowerDeviceObject = IoAttachDeviceToDeviceStack(pFilterDeviceObject, deviceObject);
        if (!pLowerDeviceObject)
        {
            KdPrint(("wykbflt.sys : Couldn't attach to Device Object\n"));
            IoDeleteDevice(pFilterDeviceObject);
            pFilterDeviceObject = NULL;
            break;
        }

        // 设备扩展
        PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION)pFilterDeviceObject->DeviceExtension;
        KBFInitDeviceExtension(deviceExtension, pFilterDeviceObject, deviceObject, pLowerDeviceObject);

        // 设置过滤操作
        pFilterDeviceObject->DeviceType = pLowerDeviceObject->DeviceType;	// 要过滤的设备类型跟物理设备类型一致
        pFilterDeviceObject->Characteristics = pLowerDeviceObject->Characteristics;
        pFilterDeviceObject->StackSize = pLowerDeviceObject->StackSize + 1;
        pFilterDeviceObject->Flags |= pLowerDeviceObject->Flags & (DO_BUFFERED_IO | DO_DIRECT_IO | DO_POWER_PAGABLE) ;

        ++index;

        RtlZeroMemory(name, sizeof(WCHAR)*32);
        RtlStringCchPrintfW(name, 32, L"\\Device\\KeyboardClass%d", index);
        RtlInitUnicodeString(&nameString, name);

        // 打开设备对象
        status = IoGetDeviceObjectPointer(&nameString, FILE_ALL_ACCESS, &fileObject, &deviceObject);
        if (NT_SUCCESS(status))
            ObDereferenceObject(fileObject);
        else
            break;
    }

    return STATUS_SUCCESS;
}
开发者ID:killbug2004,项目名称:wy-windows-driver,代码行数:75,代码来源:wykbflt.cpp


示例19: UDPFilter_Attach

NTSTATUS
UDPFilter_Attach(
	IN PDRIVER_OBJECT	DriverObject,
	IN PUNICODE_STRING	RegistryPath
)
{
	NTSTATUS				status	= 0;
	UNICODE_STRING			uniNtNameString;
	PTDIH_DeviceExtension	pTDIH_DeviceExtension;
	PDEVICE_OBJECT			pFilterDeviceObject = NULL;
	PDEVICE_OBJECT			pTargetDeviceObject = NULL;
	PFILE_OBJECT			pTargetFileObject	= NULL;
	PDEVICE_OBJECT			pLowerDeviceObject	= NULL;

	DBGPRINT("UDPFilter_Attach.\n");

	RtlInitUnicodeString( &uniNtNameString, DD_UDP_DEVICE_NAME );

	status = IoGetDeviceObjectPointer(
               IN	&uniNtNameString,
               IN	FILE_READ_ATTRIBUTES,
               OUT	&pTargetFileObject,   
               OUT	&pTargetDeviceObject
               );
	if( !NT_SUCCESS(status) )
	{
		DBGPRINT(("UDPFilter_Attach: Couldn't get the UDP Device Object\n"));
		pTargetFileObject	= NULL;
		pTargetDeviceObject = NULL;
		return( status );
	}

	RtlInitUnicodeString( &uniNtNameString, TDIH_UDP_DEVICE_NAME );

	status = IoCreateDevice(
               IN	DriverObject,
               IN	sizeof( TDIH_DeviceExtension ),
               IN	&uniNtNameString,
               IN	pTargetDeviceObject->DeviceType,
               IN	pTargetDeviceObject->Characteristics,
               IN	FALSE,                 
               OUT	&pFilterDeviceObject
               );
	if( !NT_SUCCESS(status) )
	{
		DBGPRINT(("UDPFilter_Attach: Couldn't create the UDP Filter Device Object\n"));
		ObDereferenceObject( pTargetFileObject );
		pTargetFileObject = NULL;
		pTargetDeviceObject = NULL;
		return( status );
	}

	pLowerDeviceObject 
		= IoAttachDeviceToDeviceStack(pFilterDeviceObject,pTargetDeviceObject);
	if( !pLowerDeviceObject )
	{
		DBGPRINT(("UDPFilter_Attach: Couldn't attach to UDP Device Object\n"));
		IoDeleteDevice( pFilterDeviceObject );
		pFilterDeviceObject = NULL;
		ObDereferenceObject( pTargetFileObject );
		pTargetFileObject	= NULL;
		pTargetDeviceObject = NULL;
		return( status );
	}

	pTDIH_DeviceExtension 
		= (PTDIH_DeviceExtension )( pFilterDeviceObject->DeviceExtension );
	UDPFilter_InitDeviceExtension(
		IN	pTDIH_DeviceExtension,
		IN	pFilterDeviceObject,
		IN	pTargetDeviceObject,
		IN	pTargetFileObject,
		IN	pLowerDeviceObject
		);

	pFilterDeviceObject->Flags |= pTargetDeviceObject->Flags 
		& (DO_BUFFERED_IO | DO_DIRECT_IO);
	return status;
}
开发者ID:jiangxilong,项目名称:TDI,代码行数:79,代码来源:Packet.c


示例20: IoctlToLanscsiBus

//
//	General ioctl to NDASBUS
//
NTSTATUS
IoctlToLanscsiBus(
	IN ULONG		IoControlCode,
    IN PVOID		InputBuffer  OPTIONAL,
    IN ULONG		InputBufferLength,
    OUT PVOID		OutputBuffer  OPTIONAL,
    IN ULONG		OutputBufferLength,
	OUT PULONG		BufferNeeded
)
{
	NTSTATUS			ntStatus;
	PWSTR				symbolicLinkList;
    UNICODE_STRING		objectName;
	PFILE_OBJECT		fileObject;
	PDEVICE_OBJECT		deviceObject;
	PIRP				irp;
    KEVENT				event;
    IO_STATUS_BLOCK		ioStatus;


	KDPrint(3,("IoControlCode = %x\n", IoControlCode));

	ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

	ntStatus = IoGetDeviceInterfaces(
		&GUID_NDAS_BUS_ENUMERATOR_INTERFACE_CLASS,
		NULL,
		0,
		&symbolicLinkList
		);
	
	if(!NT_SUCCESS(ntStatus)) {
		KDPrint(2,("IoGetDeviceInterfaces ntStatus = 0x%x\n", ntStatus));
		return ntStatus;
	}
	
	ASSERT(symbolicLinkList != NULL);

	KDPrint(2,("symbolicLinkList = %ws\n", symbolicLinkList));

    RtlInitUnicodeString(&objectName, symbolicLinkList);
	ntStatus = IoGetDeviceObjectPointer(
					&objectName,
					FILE_ALL_ACCESS,
					&fileObject,
					&deviceObject
					);

	if(!NT_SUCCESS(ntStatus)) {
		KDPrint(2,("ntStatus = 0x%x\n", ntStatus));
		ExFreePool(symbolicLinkList);
		return ntStatus;
	}
	
    KeInitializeEvent(&event, NotificationEvent, FALSE);

	irp = IoBuildDeviceIoControlRequest(
			IoControlCode,
			deviceObject,
			InputBuffer,
			InputBufferLength,
			OutputBuffer,
			OutputBufferLength,
			FALSE,
			&event,
			&ioStatus
			);
	
    if (irp == NULL) {
		KDPrint(2,("irp NULL\n"));
		ExFreePool(symbolicLinkList);
		ObDereferenceObject(fileObject); 
		return ntStatus;
	}
	KDPrint(3,("Before Done...ioStatus.Status = 0x%08x Information = %d\n", ioStatus.Status, ioStatus.Information));

	ntStatus = IoCallDriver(deviceObject, irp);
    if (ntStatus == STATUS_PENDING)
    {
		KDPrint(2,("IoCallDriver STATUS_PENDING\n"));
		KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
        ntStatus = ioStatus.Status;
    } else if(NT_SUCCESS(ntStatus)) {
		ntStatus = ioStatus.Status;
    }

	if(BufferNeeded)
		*BufferNeeded = (ULONG)ioStatus.Information;

	ExFreePool(symbolicLinkList);
	ObDereferenceObject(fileObject);
	
	KDPrint(2,("Done...ioStatus.Status = 0x%08x Information = %d\n", ioStatus.Status, ioStatus.Information));
	
	return ntStatus;
}
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:99,代码来源:ndsccomp.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IoGetNextIrpStackLocation函数代码示例发布时间:2022-05-30
下一篇:
C++ IoGetCurrentIrpStackLocation函数代码示例发布时间: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