Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Monthly Seminars at OSR Headquarters

East Coast USA
Windows Internals and SW Drivers, Dulles (Sterling) VA, 13 November 2017

Kernel Debugging & Crash Analysis for Windows, Nashua (Amherst) NH, 4 December 2017

Writing WDF Drivers I: Core Concepts, Nashua (Amherst) NH, 8 January 2018

WDF Drivers II: Advanced Implementation Techniques, Nashua (Amherst) NH, 15 January 2018


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 6  
11 Jan 17 07:23
Harry
xxxxxx@gmail.com
Join Date: 11 Jan 2017
Posts To This List: 3
Alternative to ObReferenceObjectByName

Hi, I am currently developing a driver which reads from a given physical sector. I have a working code which retrieves physical drives in the system with use of ObReferenceObjectByName() undocumented function. I have tried for a week to find alternative for this without any success. I tried with ZwCreateFile() then ObReferenceObjectByHandle() functions for "\Driver\Disk" / "\Device\Harddisk0" / "\Device\Harddisk0\(DR0/DP0)" options and it ended up in either BSOD or OBJECT_TYPE_MISMATCH error. I then tried with IoCreateDevice() function which threw NAME_COLLISION error. Then I came across function IoGetDevicePointer() which again gave me OBJECT_TYPE_MISMATCH error. I want to avoid ObReferenceByName() function as it's undocumented. Is there any other alternative through which I can retrieve physical disk device objects in the system? Thanks!
  Message 2 of 6  
12 Jan 17 00:56
Harry
xxxxxx@gmail.com
Join Date: 11 Jan 2017
Posts To This List: 3
Alternative to ObReferenceObjectByName

One crucial information I forgot to mention is that this all is done from DriverEntry() routine. Does it affect?
  Message 3 of 6  
12 Jan 17 01:37
Jamey Kirby
xxxxxx@gmail.com
Join Date: 31 Dec 2014
Posts To This List: 245
Alternative to ObReferenceObjectByName

Let's see your Zw code On Thu, Jan 12, 2017 at 12:54 AM <xxxxx@gmail.com> wrote: > One crucial information I forgot to mention is that this all is done from > DriverEntry() routine. Does it affect? > > --- > NTDEV is sponsored by OSR > > Visit the list online at: < > http://www.osronline.com/showlists.cfm?list=ntdev> > > MONTHLY seminars on crash dump analysis, WDF, Windows internals and <...excess quoted lines suppressed...> --
  Message 4 of 6  
12 Jan 17 04:55
Slava Imameev
xxxxxx@hotmail.com
Join Date: 13 Sep 2013
Posts To This List: 207
Alternative to ObReferenceObjectByName

I guess you incorrectly provided the object type for ObReferenceObjectByName. Depending on the declaration this could be ObReferenceObjectByName( ..., *ObjectType, ... ) or ObReferenceObjectByName( ..., ObjectType, ... ). The former is common with WDK headers where they are declared as extern POBJECT_TYPE *CmKeyObjectType; extern POBJECT_TYPE *IoFileObjectType; extern POBJECT_TYPE *ExEventObjectType; extern POBJECT_TYPE *ExSemaphoreObjectType; extern POBJECT_TYPE *TmTransactionManagerObjectType; extern POBJECT_TYPE *TmResourceManagerObjectType; extern POBJECT_TYPE *TmEnlistmentObjectType; extern POBJECT_TYPE *TmTransactionObjectType; extern POBJECT_TYPE *PsProcessType; extern POBJECT_TYPE *PsThreadType; extern POBJECT_TYPE *SeTokenObjectType;
  Message 5 of 6  
12 Jan 17 12:08
ntdev member 168568
xxxxxx@gmail.com
Join Date:
Posts To This List: 180
Alternative to ObReferenceObjectByName

Look at the IoGetDeviceInterfaces documentation. The GUID_DEVINTERFACE_DISK GUID is used to list disk drives.
  Message 6 of 6  
16 Jan 17 09:04
Harry
xxxxxx@gmail.com
Join Date: 11 Jan 2017
Posts To This List: 3
Alternative to ObReferenceObjectByName

Thank you guys for all your help. Figured it out through a thread (http://www.osronline.com/showthread.cfm?link=100411) on this awesome forum. IoGetDeviceObjectPointer() is the routine I used as an alternate for ObReferenceObjectByName(). But as mentioned on the above thread, I used file object's device object instead of the device object function returned. Anyone trying to figure out/ implement the same please go through above thread.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 10:18.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license