[Compuware Corporation] [Compuware NuMega home page]                [NuMega Lab]
[teal]

 [DriverStudio]    [Image][Image]
   Home
 [Driver Products]        Driver Technical Tips
   DriverStudio          Undocumented: ObReferenceObjectByName
   DriverBundle
   Previews              The DDK offers some support for exploring the NT
   Compatibility         object directory, but not all the functions are
 [Downloads]             described in the DDK documentation. One such
                          function, a close cousin of the documented call
 Wizards                  ObReferenceObjectByHandle, is
   Utilities             ObReferenceObjectByName. This function can return a
   NT source             pointer to any object in the object directory if the
 examples                 name of that object is known. This means that it can
   VxD source            be used to locate directory objects (including the
 examples                 root), thereby enabling you to do further exploration
   WDM source            of the object directory while in kernel mode.
 examples
 [Resources]             With a little bit of research (and some help from
 Technical papers         alert readers), we know the prototype for
   Useful links          ObReferenceObjectByName looks like this:
   Technical tips
 [Support]               extern "C"
                          NTSYSAPI
 Support                  NTSTATUS NTAPI ObReferenceObjectByName(
   Knowledge base            IN PUNICODE_STRING ObjectPath,
   Problem                   IN ULONG Attributes,
 submission                   IN PACCESS_STATE PassedAccessState OPTIONAL,
   Product                   IN ACCESS_MASK DesiredAccess OPTIONAL,
 registration                 IN POBJECT_TYPE ObjectType,
   Release notes             IN KPROCESSOR_MODE AccessMode,
 [Shop NuMega]               IN OUT PVOID ParseContext OPTIONAL,
 Buy it!                      OUT PVOID *ObjectPtr
   Price list            );
   How to buy
   Sales offices            * The first parameter, ObjectPath, points to a
                               counted unicode string that holds the path of
                               the object, e.g. \Driver\Serial
 [Y2K Compliance]            * Attributes may be zero or OBJ_CASE_INSENSITIVE,
                               which indicates that the name lookup should be
                               performed ignoring the case of the ObjectName.
 [More information]          * Set parameter AccessMode to KernelMode.
                             * Parameter ObjectType optionally points to a
                               'type' object, which can be used to limit the
                               search for the object to a particular type.
                             * ParseContext is an optional pointer that is
                               passed uninterpreted to any parse procedure that
                               is called during the course of performing the
                               name lookup.
                             * Parameter ObjectPtr is the address of the
                               variable that receives a pointer to the object
                               if the object is found.

                          This service is only callable at PASSIVE_LEVEL.

                          If you use this routine to reference an object, be
                          sure to call ObDereferenceObject when you are
                          finished with it.

                          This service is available on Windows 98, as well as
                          all versions of Windows NT. As with all undocumented
                          functions, use this service at your own risk, and
                          check the operating system and version before calling
                          it.

                          Back to technical tip start page.

  DriverCentral  DriverStudio  Free downloads  Resources  Support and
                          Services  Shop NuMega
     Compuware NuMega  Tel: +1 603 578-8400  Updated: 9 August 1999 
                      Problems? Contact our webmaster.
