Reading a (var,value) pair under Parameters subkey ....

Hello,

In my .inf file I added a AddReg and successfully populated SYSTEM/CurrentControlSet/Services/blah/Parameters with a (var, value) pair. I read through IoGetDeviceProperty, but this doesn’t seem to be what I should use to get the (var, value) pair from my driver. How to do??

Regards, Vasili


Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Hello,
I think I have part of answer to my question. The info i need is in the 2nd parameter passed to DriverEntry (RegistryPath). How can I parse this UNICODE string to find (var, value) pair? I.e. I don’t know form/syntax of this string!
Regards, Vasili
Galchin Vasili wrote:
Hello,

In my .inf file I added a AddReg and successfully populated SYSTEM/CurrentControlSet/Services/blah/Parameters with a (var, value) pair. I read through IoGetDeviceProperty, but this doesn’t seem to be what I should use to get the (var, value) pair from my driver. How to do??

Regards, Vasili

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@yahoo.com To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Allocate a new UNICODE_STRING with a buffer large enough to contain the passed in reg path plus \Parameters, then use ZwOpenKey. Many DDK driver samples demonstrate this (look at pnpi8042’s I8xServiceParameters under input examples for instance).

D

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

-----Original Message-----
From: Galchin Vasili [mailto:xxxxx@yahoo.com]
Sent: Thursday, April 03, 2003 1:23 PM
To: NT Developers Interest List
Cc: xxxxx@yahoo.com
Subject: [ntdev] Re: Reading a (var,value) pair under Parameters subkey …

Hello,
??? I think I have part of answer to my question. The info i need is in the 2nd parameter passed to DriverEntry (RegistryPath). How can I parse this UNICODE string to find (var, value) pair? I.e. I don’t know form/syntax of this string!
Regards, Vasili
?Galchin Vasili wrote:
Hello,
??? In my .inf file I added a AddReg and successfully populated SYSTEM/CurrentControlSet/Services/blah/Parameters with a (var, value) pair. I read through IoGetDeviceProperty, but this doesn’t seem to be what I should use to get the (var, value) pair from my driver. How to do??
Regards, Vasili
?

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@yahoo.com To unsubscribe send a blank email to xxxxx@lists.osr.com

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com

\Registry\Machine\System\CurrentControlSet…

and why you need this except for registry work?

Max
----- Original Message -----
From: Galchin Vasili
To: NT Developers Interest List
Cc: xxxxx@yahoo.com
Sent: Friday, April 04, 2003 1:23 AM
Subject: [ntdev] Re: Reading a (var,value) pair under Parameters subkey …

Hello,

I think I have part of answer to my question. The info i need is in the 2nd parameter passed to DriverEntry (RegistryPath). How can I parse this UNICODE string to find (var, value) pair? I.e. I don’t know form/syntax of this string!

Regards, Vasili

Galchin Vasili wrote:

Hello,

In my .inf file I added a AddReg and successfully populated SYSTEM/CurrentControlSet/Services/blah/Parameters with a (var, value) pair. I read through IoGetDeviceProperty, but this doesn’t seem to be what I should use to get the (var, value) pair from my driver. How to do??

Regards, Vasili

----------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@yahoo.com To unsubscribe send a blank email to xxxxx@lists.osr.com

------------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@storagecraft.com To unsubscribe send a blank email to xxxxx@lists.osr.com

IoOpenDeviceRegistryKey opens the path hklm\system\currentcontrolset\enum<enumerator><deviceid><instanceid>\Device Parameters

If you want per device instance settings, store BaseAddress there. If you want the setting to be global to all instances, store it under services<blah>\parameters.

D

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

From: Galchin Vasili [mailto:xxxxx@yahoo.com]
Sent: Thursday, April 03, 2003 6:23 PM
To: NT Developers Interest List
Cc: Doron Holan
Hello,
??? I added the following to read a (var, value) pair where var=BaseAddress?from SYSTEM/CurrentControlSet/Services/blah/Parameters key:
?HANDLE KeyHandle;
UNICODE_STRING KeyName;
ULONG?? BaseAddress;
ULONG ActualLength;
NTSTATUS Status;

?IoOpenDeviceRegistryKey (KCSState->pDevObj,
??? PLUGPLAY_REGKEY_DRIVER,
??? STANDARD_RIGHTS_READ,
??? &KeyHandle);

RtlInitUnicodeString (&KeyName, L"BaseAddress");

Status = ZwQueryValueKey (KeyHandle,
??? &KeyName,
??? KeyValueFullInformation,
??? &BaseAddress,
??? sizeof (BaseAddress),
??? &ActualLength);
if (!NT_SUCCESS (Status))
{
DebugPrint (“Oops!!! Query failed!!! %d\n”, Status);
}

DebugPrint (“BaseAddress %x\n”, BaseAddress);

}
I saw very similar code in the serial driver from the DDK. (Note: for normal driver operation I am depending on PnP manager to pass resources in orthodox way via AddDevice. I need to read registry in some special debug situation … so please don’t ask why I want to read from the Registry. The fact is I do need to raed from Registry).
Problem: in the code above, the Query fails. I.e. it fails to find “BaseAddress”. Why?
Regards, Vasili
?Doron Holan wrote:
Allocate a new UNICODE_STRING with a buffer large enough to contain the passed in reg path plus \Parameters, then use ZwOpenKey. Many DDK driver samples demonstrate this (look at pnpi8042’s I8xServiceParameters under input examples for instance).

D

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

-----Original Message-----
From: Galchin Vasili [mailto:xxxxx@yahoo.com]
Sent: Thursday, April 03, 2003 1:23 PM
To: NT Developers Interest List
Cc: xxxxx@yahoo.com
Subject: [ntdev] Re: Reading a (var,value) pair under Parameters subkey …

Hello,
??? I think I have part of answer to my question. The info i need is in the 2nd parameter passed to DriverEntry (RegistryPath). How can I parse this UNICODE string to find (var, value) pair? I.e. I don’t know form/syntax of this string!
Regards, Vasili
?Galchin Vasili wrote:
Hello,
??? In my .inf file I added a AddReg and successfully populated SYSTEM/CurrentControlSet/Services/blah/Parameters with a (var, value) pair. I read through IoGetDeviceProperty, but this doesn’t seem to be what I should use to get the (var, value) pair from my driver. How to do??
Regards, Vasili
?

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@yahoo.com To unsubscribe send a blank email to xxxxx@lists.osr.com

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com


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

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

Hello,

I have populated under Parameters subkey a (SIBaseAddress, 0xca8) ordered pair. I saved the RegistryPath (DriverEntry) in a struct called state. Below is my code which doesn’t work because the value when I print out is not 0xca8. Help?!

Regards, Vasili

{
OBJECT_ATTRIBUTES oa;
UNICODE_STRING string;
HANDLE hService;
HANDLE hParameters;

InitializeObjectAttributes (&oa,
&(State->ServiceKey),
OBJ_CASE_INSENSITIVE,
NULL,
(PSECURITY_DESCRIPTOR)NULL);

if (NT_SUCCESS (ZwOpenKey (&hService,
KEY_ALL_ACCESS,
&oa)))
{
RtlInitUnicodeString (&string, L"Parameters");

InitializeObjectAttributes (&oa,
&string,
OBJ_CASE_INSENSITIVE,
hService,
(PSECURITY_DESCRIPTOR)NULL);

if (NT_SUCCESS (ZwOpenKey (&hParameters,
KEY_ALL_ACCESS,
&oa)))
{
UNICODE_STRING KeyName;
ULONG SIBaseAddress;
ULONG ActualLength;
NTSTATUS Status;

RtlInitUnicodeString (&KeyName, L"SIBaseAddress");

Status = ZwQueryValueKey (hParameters,
&KeyName,
KeyValueFullInformation,
&SIBaseAddress,
sizeof (SIBaseAddress),
&ActualLength);
if (!NT_SUCCESS (Status))
{
DebugPrint (“Oops!!! Query failed!!! %d\n”, Status);
}

DebugPrint (“SIBaseAddress %x\n”, SIBaseAddress);

} // end if

} // end if


Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

The 4th parameter to ZwQueryValueKey must match KeyValueInformationClass
value and not the raw ULONG point you are passing

KeyValueBasicInformation - PKEY_VALUE_BASIC_INFORMATION
KeyValueFullInformation - PKEY_VALUE_FULL_INFORMATION
KeyValuePartialInformation - PKEY_VALUE_PARTIAL_INFORMATION

Here is some more correct code to read a ULONG

PKEY_VALUE_PARTIAL_INFORMATION pPartial;
UNICODE_STRING name;
NTSTATUS status;
ULONG length, valueToRead;

PAGED_CODE();

RtlInitUnicodeString(&name, L"ValueName");

length = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG);
pPartial = (PKEY_VALUE_PARTIAL_INFORMATION)
ExAllocatePool(PagedPool, length);

if (pPartial == NULL) {
return STATUS_INSUFFICIENT_RESOURCES;
}

status = ZwQueryValueKey(Key,
&name,
KeyValuePartialInformation,
pPartial,
length,
&length);

if (NT_SUCCESS(status) && pPartial->Type == REG_DWORD) {
RtlCopyMemory(&valueToRead, &pPartial->Data[0],
pPartial->DataLength);
}

ExFreePool(pPartial);

return valueToRead;

d

-----Original Message-----
From: Galchin Vasili [mailto:xxxxx@yahoo.com]
Sent: Thursday, April 10, 2003 12:56 PM
To: NT Developers Interest List
Subject: [ntdev] Reading a (var,value) pair under Parameters subkey …

Hello,
I have populated under Parameters subkey a (SIBaseAddress, 0xca8)
ordered pair. I saved the RegistryPath (DriverEntry) in a struct called
state. Below is my code which doesn’t work because the value when I
print out is not 0xca8. Help?!
Regards, Vasili
{
OBJECT_ATTRIBUTES oa;
UNICODE_STRING string;
HANDLE hService;
HANDLE hParameters;

InitializeObjectAttributes (&oa,
&(State->ServiceKey),
OBJ_CASE_INSENSITIVE,
NULL,
(PSECURITY_DESCRIPTOR)NULL);
if (NT_SUCCESS (ZwOpenKey (&hService,
KEY_ALL_ACCESS,
&oa)))
{
RtlInitUnicodeString (&string, L"Parameters");
InitializeObjectAttributes (&oa,
&string,
OBJ_CASE_INSENSITIVE,
hService,
(PSECURITY_DESCRIPTOR)NULL);

if (NT_SUCCESS (ZwOpenKey (&hParameters,
KEY_ALL_ACCESS,
&oa)))
{
UNICODE_STRING KeyName;
ULONG SIBaseAddress;
ULONG ActualLength;
NTSTATUS Status;

RtlInitUnicodeString (&KeyName, L"SIBaseAddress");

Status = ZwQueryValueKey (hParameters,
&KeyName,
KeyValueFullInformation,
&SIBaseAddress,
sizeof (SIBaseAddress),
&ActualLength);
if (!NT_SUCCESS (Status))
{
DebugPrint (“Oops!!! Query failed!!! %d\n”, Status);
}
DebugPrint (“SIBaseAddress %x\n”, SIBaseAddress);

} // end if

} // end if

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more — You
are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com