Problem with ZwOpenKey

Hi,

I have a problem to access to the registry:

RtlInitUnicodeString(&CfgPath,Buffer);

InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
,NULL);
Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);

Buffer contains \Registry\Machine\Software\Microsoft\Windows
NT\CurrentVersion\Ports

and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)

I tried also with only \Registry\Machine\Software in Buffer and I get the
same error

I don’t understand how I should write the path to the registry to access it.

Thanks for any help.

I think there is nothing wrong with your code. I met
the same problem before. You must have used this
function at system start up time. Just call ZwOpenKey
at a later time. I don’t know what is the exact reason
for this. Maybe at that time all the registry objects
have not been loaded in. That is what I did in my
driver.

Hope this help.

Michael

— Nicolas Mugnier wrote:
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status =
> ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains
> \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND
> (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in
> Buffer and I get the
> same error
>
> I don’t understand how I should write the path to
> the registry to access it.
>
> Thanks for any help.
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.ca
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a écrit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>

You are using ‘\’ instead of '' in your path string, right? In other
words, something like this:

RtlInitUnicodeString(&CfgPath,
L"\Registry\Machine\Software\Microsoft\Windows");


Bill McKenzie
Compuware Corporation
Watch your IRPs/IRBs/URBs/SRBs/NDIS pkts with our free WDMSniffer tool:
http://frontline.compuware.com/nashua/patches/utility.htm

“Nicolas Mugnier” wrote in message
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>

Ah, I didn’t see the other posts. That hive obviously isn’t available at
startup. You will have to delay your access as suggested.


Bill McKenzie
Compuware Corporation
Watch your IRPs/IRBs/URBs/SRBs/NDIS pkts with our free WDMSniffer tool:
http://frontline.compuware.com/nashua/patches/utility.htm

“Bill McKenzie” wrote in message
news:xxxxx@ntdev…
>
> You are using ‘\’ instead of '' in your path string, right? In other
> words, something like this:
>
> RtlInitUnicodeString(&CfgPath,
> L"\Registry\Machine\Software\Microsoft\Windows");
>
> –
> Bill McKenzie
> Compuware Corporation
> Watch your IRPs/IRBs/URBs/SRBs/NDIS pkts with our free WDMSniffer tool:
> http://frontline.compuware.com/nashua/patches/utility.htm
>
>
> “Nicolas Mugnier” wrote in message
> news:xxxxx@ntdev…
> >
> > Hi,
> >
> > I have a problem to access to the registry:
> >
> > RtlInitUnicodeString(&CfgPath,Buffer);
> >
> >
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> > ,NULL);
> > Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
> >
> > Buffer contains \Registry\Machine\Software\Microsoft\Windows
> > NT\CurrentVersion\Ports
> >
> > and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
> >
> > I tried also with only \Registry\Machine\Software in Buffer and I get
the
> > same error
> >
> > I don’t understand how I should write the path to the registry to access
> it.
> >
> > Thanks for any help.
> >
> >
> >
> >
>
>
>
>

This is purely a function of when your driver loads with relation to winlogon. As part of the winlogon start up, the software key under HKLM is loaded. In your case, I am sure your app is being loaded after winlogon which is why you can open this key at create time. There is no documented way to be notified when this key is loaded. If you want to store driver settings in the registry that are available at start device time, store them in the device’s devnode (per device settings) or in the driver’s service key (ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a ?crit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Doron,

This may explain a problem I am having. While working on an HID class driver
I have encountered the inability of ZwQueryValueKey to find the values
associated with the enumeration in
HKLM…Control\Class<guid><enumeration>. I have registered the interface
and opened it with IoOpenDeviceInterfaceRegistryKey pointing to the PnP
named returned from registration. That gives me a handle I pass to
ZwQueryValueKey, which promptly returns STATUS_OBJECT_NAME_NOT_FOUND. Note
that this is being done in the AddDevice routine.

Now when I look at the PnP name with WinDbg and use !handle on the handle
passed to ZwQueryValueKey, I find the name(s) agree with what I see in the
registry after the driver fails to load. Hypothetically speaking, could this
be because though the registry key can be constructed, the key/values
themselves will not exist until some time after AddDevice; e.g. Start
device?

I can live with moving the code to StartDevice, if that is required.

Donkey shines. (That’s Southern German for "thanks a bunch.)


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

This is purely a function of when your driver loads with relation to
winlogon. As part of the winlogon start up, the software key under HKLM is
loaded. In your case, I am sure your app is being loaded after winlogon
which is why you can open this key at create time. There is no documented
way to be notified when this key is loaded. If you want to store driver
settings in the registry that are available at start device time, store them
in the device’s devnode (per device settings) or in the driver’s service key
(ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a écrit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Does the IoOpenDeviceInterfaceRegistryKey return success? If so, you have a valid key and all of its contents should be there. If you are getting object not found, I don’t think your value is there (but you say it is there in start device … does an app place the value there or is it persistent?).

The contents of HKLM…\Control\Class<guid> are not under HKLM\Software and are loaded at boot time, so anything under these keys should be available once you have a PDO.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 3:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

Doron,

This may explain a problem I am having. While working on an HID class driver
I have encountered the inability of ZwQueryValueKey to find the values
associated with the enumeration in
HKLM…Control\Class<guid><enumeration>. I have registered the interface
and opened it with IoOpenDeviceInterfaceRegistryKey pointing to the PnP
named returned from registration. That gives me a handle I pass to
ZwQueryValueKey, which promptly returns STATUS_OBJECT_NAME_NOT_FOUND. Note
that this is being done in the AddDevice routine.

Now when I look at the PnP name with WinDbg and use !handle on the handle
passed to ZwQueryValueKey, I find the name(s) agree with what I see in the
registry after the driver fails to load. Hypothetically speaking, could this
be because though the registry key can be constructed, the key/values
themselves will not exist until some time after AddDevice; e.g. Start
device?

I can live with moving the code to StartDevice, if that is required.

Donkey shines. (That’s Southern German for "thanks a bunch.)


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

This is purely a function of when your driver loads with relation to
winlogon. As part of the winlogon start up, the software key under HKLM is
loaded. In your case, I am sure your app is being loaded after winlogon
which is why you can open this key at create time. There is no documented
way to be notified when this key is loaded. If you want to store driver
settings in the registry that are available at start device time, store them
in the device’s devnode (per device settings) or in the driver’s service key
(ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a ?crit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

My apologies to the Original Poster … I did not mean to abscond with your
thread.

Doron,

Ok, that too is making sense.

What I see for the PnPName returned from IoOpenDeviceInterfaceRegistryKey
is: …\DEVICECLASSES#<hid_class>#0000#, where as !handle is telling
me the directory object opened is:
…\CONTROLSET001\CONTROL\DEVICECLASSES{}##?#ROOT#<hid_device>#0000#
{}#\DEVICE PARAMETERS.

In the registry I see my values in 0000, and not in DEVICE PARAMETERS, in
fact DEVICE PARAMETERS does not exist as a sub-key for that key.

I’m thinking my INF file is not putting my values where I think it should
… I thought that

[PSSCR.Install.NT.HW.AddReg]
HKR, PhysicalDrive,%REG_SZ%,“\DosDevices\PhysicalDrive0”

would create the PhysicalDrive0 value for 0000. That it does … it’s the
DEVICE PARAMETERS in the directory object of the handle that is the problem.

-
Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

Does the IoOpenDeviceInterfaceRegistryKey return success? If so, you have a
valid key and all of its contents should be there. If you are getting
object not found, I don’t think your value is there (but you say it is there
in start device … does an app place the value there or is it persistent?).

The contents of HKLM…\Control\Class<guid> are not under HKLM\Software and
are loaded at boot time, so anything under these keys should be available
once you have a PDO.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 3:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

Doron,

This may explain a problem I am having. While working on an HID class driver
I have encountered the inability of ZwQueryValueKey to find the values
associated with the enumeration in
HKLM…Control\Class<guid><enumeration>. I have registered the interface
and opened it with IoOpenDeviceInterfaceRegistryKey pointing to the PnP
named returned from registration. That gives me a handle I pass to
ZwQueryValueKey, which promptly returns STATUS_OBJECT_NAME_NOT_FOUND. Note
that this is being done in the AddDevice routine.

Now when I look at the PnP name with WinDbg and use !handle on the handle
passed to ZwQueryValueKey, I find the name(s) agree with what I see in the
registry after the driver fails to load. Hypothetically speaking, could this
be because though the registry key can be constructed, the key/values
themselves will not exist until some time after AddDevice; e.g. Start
device?

I can live with moving the code to StartDevice, if that is required.

Donkey shines. (That’s Southern German for "thanks a bunch.)


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

This is purely a function of when your driver loads with relation to
winlogon. As part of the winlogon start up, the software key under HKLM is
loaded. In your case, I am sure your app is being loaded after winlogon
which is why you can open this key at create time. There is no documented
way to be notified when this key is loaded. If you want to store driver
settings in the registry that are available at start device time, store them
in the device’s devnode (per device settings) or in the driver’s service key
(ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a écrit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</hid_device></hid_class>

If you want the devnode (ie enum\xxx\xxx\device parameters), then you want to call IoOpenDeviceRegistryKey(Pdo, PLUGPLAY_REGKEY_DEVICE, …). You are opening up device interface keys, of which, an INF cannot know how to get to.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 7:00 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

My apologies to the Original Poster … I did not mean to abscond with your
thread.

Doron,

Ok, that too is making sense.

What I see for the PnPName returned from IoOpenDeviceInterfaceRegistryKey
is: …\DEVICECLASSES#<hid_class>#0000#, where as !handle is telling
me the directory object opened is:
…\CONTROLSET001\CONTROL\DEVICECLASSES{}##?#ROOT#<hid_device>#0000#
{}#\DEVICE PARAMETERS.

In the registry I see my values in 0000, and not in DEVICE PARAMETERS, in
fact DEVICE PARAMETERS does not exist as a sub-key for that key.

I’m thinking my INF file is not putting my values where I think it should
… I thought that

[PSSCR.Install.NT.HW.AddReg]
HKR, PhysicalDrive,%REG_SZ%,“\DosDevices\PhysicalDrive0”

would create the PhysicalDrive0 value for 0000. That it does … it’s the
DEVICE PARAMETERS in the directory object of the handle that is the problem.

-
Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

Does the IoOpenDeviceInterfaceRegistryKey return success? If so, you have a
valid key and all of its contents should be there. If you are getting
object not found, I don’t think your value is there (but you say it is there
in start device … does an app place the value there or is it persistent?).

The contents of HKLM…\Control\Class<guid> are not under HKLM\Software and
are loaded at boot time, so anything under these keys should be available
once you have a PDO.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 3:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

Doron,

This may explain a problem I am having. While working on an HID class driver
I have encountered the inability of ZwQueryValueKey to find the values
associated with the enumeration in
HKLM…Control\Class<guid><enumeration>. I have registered the interface
and opened it with IoOpenDeviceInterfaceRegistryKey pointing to the PnP
named returned from registration. That gives me a handle I pass to
ZwQueryValueKey, which promptly returns STATUS_OBJECT_NAME_NOT_FOUND. Note
that this is being done in the AddDevice routine.

Now when I look at the PnP name with WinDbg and use !handle on the handle
passed to ZwQueryValueKey, I find the name(s) agree with what I see in the
registry after the driver fails to load. Hypothetically speaking, could this
be because though the registry key can be constructed, the key/values
themselves will not exist until some time after AddDevice; e.g. Start
device?

I can live with moving the code to StartDevice, if that is required.

Donkey shines. (That’s Southern German for "thanks a bunch.)


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

This is purely a function of when your driver loads with relation to
winlogon. As part of the winlogon start up, the software key under HKLM is
loaded. In your case, I am sure your app is being loaded after winlogon
which is why you can open this key at create time. There is no documented
way to be notified when this key is loaded. If you want to store driver
settings in the registry that are available at start device time, store them
in the device’s devnode (per device settings) or in the driver’s service key
(ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a ?crit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</hid_device></hid_class>

Thanks Doron. I finally got it to work using PLUGPLAY_REGKEY_DRIVER in
IoOpenDeviceRegistryKey.


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

If you want the devnode (ie enum\xxx\xxx\device parameters), then you want
to call IoOpenDeviceRegistryKey(Pdo, PLUGPLAY_REGKEY_DEVICE, …). You are
opening up device interface keys, of which, an INF cannot know how to get
to.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 7:00 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

My apologies to the Original Poster … I did not mean to abscond with your
thread.

Doron,

Ok, that too is making sense.

What I see for the PnPName returned from IoOpenDeviceInterfaceRegistryKey
is: …\DEVICECLASSES#<hid_class>#0000#, where as !handle is telling
me the directory object opened is:
…\CONTROLSET001\CONTROL\DEVICECLASSES{}##?#ROOT#<hid_device>#0000#
{}#\DEVICE PARAMETERS.

In the registry I see my values in 0000, and not in DEVICE PARAMETERS, in
fact DEVICE PARAMETERS does not exist as a sub-key for that key.

I’m thinking my INF file is not putting my values where I think it should
… I thought that

[PSSCR.Install.NT.HW.AddReg]
HKR, PhysicalDrive,%REG_SZ%,“\DosDevices\PhysicalDrive0”

would create the PhysicalDrive0 value for 0000. That it does … it’s the
DEVICE PARAMETERS in the directory object of the handle that is the problem.

-
Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

Does the IoOpenDeviceInterfaceRegistryKey return success? If so, you have a
valid key and all of its contents should be there. If you are getting
object not found, I don’t think your value is there (but you say it is there
in start device … does an app place the value there or is it persistent?).

The contents of HKLM…\Control\Class<guid> are not under HKLM\Software and
are loaded at boot time, so anything under these keys should be available
once you have a PDO.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Wednesday, September 10, 2003 3:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

Doron,

This may explain a problem I am having. While working on an HID class driver
I have encountered the inability of ZwQueryValueKey to find the values
associated with the enumeration in
HKLM…Control\Class<guid><enumeration>. I have registered the interface
and opened it with IoOpenDeviceInterfaceRegistryKey pointing to the PnP
named returned from registration. That gives me a handle I pass to
ZwQueryValueKey, which promptly returns STATUS_OBJECT_NAME_NOT_FOUND. Note
that this is being done in the AddDevice routine.

Now when I look at the PnP name with WinDbg and use !handle on the handle
passed to ZwQueryValueKey, I find the name(s) agree with what I see in the
registry after the driver fails to load. Hypothetically speaking, could this
be because though the registry key can be constructed, the key/values
themselves will not exist until some time after AddDevice; e.g. Start
device?

I can live with moving the code to StartDevice, if that is required.

Donkey shines. (That’s Southern German for "thanks a bunch.)


Gary G. Little
Seagate Technologies, LLC

“Doron Holan” wrote in message
news:xxxxx@ntdev…

This is purely a function of when your driver loads with relation to
winlogon. As part of the winlogon start up, the software key under HKLM is
loaded. In your case, I am sure your app is being loaded after winlogon
which is why you can open this key at create time. There is no documented
way to be notified when this key is loaded. If you want to store driver
settings in the registry that are available at start device time, store them
in the device’s devnode (per device settings) or in the driver’s service key
(ie the regpath in DriverEntry) for driver wide settings.

D

This posting is provided “AS IS” with no warranties, and confers no rights

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nicolas Mugnier
Sent: Wednesday, September 10, 2003 7:35 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: Problem with ZwOpenKey

I discovered it happens only at driver load time, by example when the driver
receives
IRP_PJ_PNP - IRP_MN_START_DEVICE
Access to registry works when the driver receives IRP_MJ_CREATE and I cannot
explain it.

“Nicolas Mugnier” a écrit dans le message de
news:xxxxx@ntdev…
>
> Hi,
>
> I have a problem to access to the registry:
>
> RtlInitUnicodeString(&CfgPath,Buffer);
>
>
InitializeObjectAttributes(&KeyAttributes,&CfgPath,OBJ_CASE_INSENSITIVE,NULL
> ,NULL);
> Status = ZwOpenKey(&KeyHandle,KEY_READ,&KeyAttributes);
>
> Buffer contains \Registry\Machine\Software\Microsoft\Windows
> NT\CurrentVersion\Ports
>
> and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> I tried also with only \Registry\Machine\Software in Buffer and I get the
> same error
>
> I don’t understand how I should write the path to the registry to access
it.
>
> Thanks for any help.
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</hid_device></hid_class>

> Buffer contains \Registry\Machine\Software\Microsoft\Windows

NT\CurrentVersion\Ports

and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)

SOFTWARE registry is mounted rather late. Your driver’s init path is running
before this registry was mounted.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Not true, at least as to why the object was not being found. In this case
the registry was there and viable, but the function call I was using was
returning the “DEVICE PARAMETERS” sub-key when the install had taken the
values from the INF and placed then in the key that contained DEVICE
PARAMETERS. I was always trying to look one key down from where they were.
The solution was to use the function call but specify PLUGPLAY_??? _DRIVER.
That nicely presented a path to the enumerated HID device I had installed. I
was able to then acquire the parameters I needed, and provide a place that
an application can later access to modify.


Gary G. Little
Seagate Technologies, LLC

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> > Buffer contains \Registry\Machine\Software\Microsoft\Windows
> > NT\CurrentVersion\Ports
> >
> > and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
>
> SOFTWARE registry is mounted rather late. Your driver’s init path is
running
> before this registry was mounted.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>

Ooops … Max was replying to the OP … I forgot I had hijacked the thread.
So disregard my last post please.


Gary G. Little
Seagate Technologies, LLC

“Gary G. Little” wrote in message
news:xxxxx@ntdev…
>
> Not true, at least as to why the object was not being found. In this case
> the registry was there and viable, but the function call I was using was
> returning the “DEVICE PARAMETERS” sub-key when the install had taken the
> values from the INF and placed then in the key that contained DEVICE
> PARAMETERS. I was always trying to look one key down from where they were.
> The solution was to use the function call but specify PLUGPLAY_???
_DRIVER.
> That nicely presented a path to the enumerated HID device I had installed.
I
> was able to then acquire the parameters I needed, and provide a place that
> an application can later access to modify.
>
> –
> Gary G. Little
> Seagate Technologies, LLC
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
> >
> > > Buffer contains \Registry\Machine\Software\Microsoft\Windows
> > > NT\CurrentVersion\Ports
> > >
> > > and status is STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034)
> >
> > SOFTWARE registry is mounted rather late. Your driver’s init path is
> running
> > before this registry was mounted.
> >
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> >
> >
>
>
>
>