阅读:2880回复:5
IoGetDeviceObjectPointer获取设备指针
利用这个函数取得的设备指针,但是,可能会IoGetDeviceObjectPointer返回的并不是下层设备对象的指针。而是该设备堆栈中顶层的设备对象的指针。
请问,我怎么才能得到堆栈的低部指针呢... 再请教一下,我可不可以像HOOK API 一样HOOK这个函数呢...IoGetDeviceObjectPointer 谢谢,请指点一下 |
|
沙发#
发布于:2007-10-25 22:22
各位指点一下,我应该如何HOOK这个函数呀.说一下,大约的思路就行了..谢谢
|
|
板凳#
发布于:2007-10-26 00:20
我的目的是拦截他查询一个指定的设备..这个设备名,我是知道的..我的驱动刚好是他的上层过滤驱动
|
|
地板#
发布于:2007-10-26 08:38
IoGetBaseFileSystemDeviceObject
|
|
|
地下室#
发布于:2007-10-26 08:50
NTSTATUS
MyIoGetDeviceObjectPointer( IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject ) /*++ Routine Description: This routine returns a pointer to the device object specified by the object name. It also returns a pointer to the referenced file object that has been opened to the device that ensures that the device cannot go away. To close access to the device, the caller should dereference the file object pointer. Arguments: ObjectName - Name of the device object for which a pointer is to be returned. DesiredAccess - Access desired to the target device object. FileObject - Supplies the address of a variable to receive a pointer to the file object for the device. DeviceObject - Supplies the address of a variable to receive a pointer to the device object for the specified device. Return Value: The function value is a referenced pointer to the specified device object, if the device exists. Otherwise, NULL is returned. --*/ { PFILE_OBJECT fileObject; OBJECT_ATTRIBUTES objectAttributes; HANDLE fileHandle; IO_STATUS_BLOCK ioStatus; NTSTATUS status; PAGED_CODE(); // // Initialize the object attributes to open the device. // InitializeObjectAttributes( &objectAttributes, ObjectName, OBJ_KERNEL_HANDLE, (HANDLE) NULL, (PSECURITY_DESCRIPTOR) NULL ); status = ZwOpenFile( &fileHandle, DesiredAccess, &objectAttributes, &ioStatus, 0, FILE_NON_DIRECTORY_FILE ); if (NT_SUCCESS( status )) { // // The open operation was successful. Dereference the file handle // and obtain a pointer to the device object for the handle. // status = ObReferenceObjectByHandle( fileHandle, 0, IoFileObjectType, KernelMode, (PVOID *) &fileObject, NULL ); if (NT_SUCCESS( status )) { *FileObject = fileObject; // // Get a pointer to the device object for this file. // *DeviceObject = IoGetBaseFileSystemDeviceObject( fileObject ); } (VOID) ZwClose( fileHandle ); } return status; } BTW inline hook 即可. |
|
|
5楼#
发布于:2007-10-26 12:15
呵..谢谢....
|
|