reading from registry problem

Hi all,

I want to read in my driver a key value (like configuration info) and created in my RegistryPath->Buffer
(which is \REGISTRY\MACHINE\SYSTEM\ControlSet004\Services\myDriver) a new REG_DWORD key “Test”,
set its value to 5, but paramTable[0].DefaultData returns something wrong.

What I’m doing wrong? Could someone make it clear please?

RTL_QUERY_REGISTRY_TABLE paramTable[1];
ULONG zero = 0;
PWCHAR path;
NTSTATUS status;

if (path = (PWCHAR)ExAllocatePool(
PagedPool,
RegistryPath->Length+sizeof(WCHAR)
)) {

RtlZeroMemory(
&paramTable[0],
sizeof(paramTable)
);
RtlZeroMemory(
path,
RegistryPath->Length+sizeof(WCHAR)
);
RtlMoveMemory(
path,
RegistryPath->Buffer,
RegistryPath->Length
);

paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
paramTable[0].Name = L"Test";
paramTable[0].DefaultType = REG_DWORD;
paramTable[0].DefaultLength = sizeof(ULONG);

status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
path,
&paramTable[0],
NULL,
NULL
);

DbgPrint(“RtlQueryRegistryValues status: %08x\n”,status);

DbgPrint(“paramTable[0].DefaultData = %08x”, paramTable[0].DefaultData);
}

Thank you

You need to post the actual code (the whole function) and actual output;
this looks very suspect. I can’t say that I’ve really every used this
routine much, but I think the first problem I see is that your result
will not be in DefaultData, which is what you seem to be expecting. It
will be in the buffer you are supposed to provide in
paramTable[0].EntryContext since you passed RTL_QUERY_REGISTRY_DIRECT in
Flags. Presently, it appears to be 0.

Post.

mm


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Andrey
Kamchatnikov
Sent: Friday, June 22, 2007 12:12
To: Windows System Software Devs Interest List
Subject: [ntdev] reading from registry problem

Hi all,

I want to read in my driver a key value (like configuration info) and
created in my RegistryPath->Buffer

(which is \REGISTRY\MACHINE\SYSTEM\ControlSet004\Services\myDriver) a
new REG_DWORD key “Test”,

set its value to 5, but paramTable[0].DefaultData returns something
wrong.

What I’m doing wrong? Could someone make it clear please?

RTL_QUERY_REGISTRY_TABLE paramTable[1];
ULONG zero = 0;
PWCHAR path;
NTSTATUS status;

if (path = (PWCHAR)ExAllocatePool(
PagedPool,
RegistryPath->Length+sizeof(WCHAR)
)) {

RtlZeroMemory(
&paramTable[0],
sizeof(paramTable)
);
RtlZeroMemory(
path,
RegistryPath->Length+sizeof(WCHAR)
);
RtlMoveMemory(
path,
RegistryPath->Buffer,
RegistryPath->Length
);

paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
paramTable[0].Name = L"Test";
paramTable[0].DefaultType = REG_DWORD;
paramTable[0].DefaultLength = sizeof(ULONG);

status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE |
RTL_REGISTRY_OPTIONAL,
path,
&paramTable[0],
NULL,
NULL
);

DbgPrint(“RtlQueryRegistryValues status: %08x\n”,status);

DbgPrint(“paramTable[0].DefaultData = %08x”,
paramTable[0].DefaultData);
}

Thank you


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

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

  1. You only have one entry in the table and you need a terminating entry.

From the DDK: “The table must be terminated with a NULL table entry,
which is a table entry with a NULL QueryRoutine member and a NULL Name
member.”

  1. I don’t see you setting EntryContext in paramTable.

  2. I don’t see you setting the DefaultData pointer either.

Jerry.

“Andrey Kamchatnikov”
Sent by: xxxxx@lists.osr.com
06/22/2007 12:15 PM
Please respond to
“Windows System Software Devs Interest List”

To
“Windows System Software Devs Interest List”
cc

Subject
[ntdev] reading from registry problem

Hi all,

I want to read in my driver a key value (like configuration info) and
created in my RegistryPath->Buffer
(which is \REGISTRY\MACHINE\SYSTEM\ControlSet004\Services\myDriver) a new
REG_DWORD key “Test”,
set its value to 5, but paramTable[0].DefaultData returns something wrong.

What I’m doing wrong? Could someone make it clear please?

RTL_QUERY_REGISTRY_TABLE paramTable[1];
ULONG zero = 0;
PWCHAR path;
NTSTATUS status;

if (path = (PWCHAR)ExAllocatePool(
PagedPool,
RegistryPath->Length+sizeof(WCHAR)
)) {

RtlZeroMemory(
&paramTable[0],
sizeof(paramTable)
);
RtlZeroMemory(
path,
RegistryPath->Length+sizeof(WCHAR)
);
RtlMoveMemory(
path,
RegistryPath->Buffer,
RegistryPath->Length
);

paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
paramTable[0].Name = L"Test";
paramTable[0].DefaultType = REG_DWORD;
paramTable[0].DefaultLength = sizeof(ULONG);

status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
path,
&paramTable[0],
NULL,
NULL
);

DbgPrint(“RtlQueryRegistryValues status: %08x\n”,status);

DbgPrint(“paramTable[0].DefaultData = %08x”,
paramTable[0].DefaultData);
}

Thank you


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

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer