If your code snippet is same as what I see, then there is a problem in this line
> RtlInitUnicodeString(RegistryPath,\Registry\Machine\SYSTEM\CurrentControlSet\Services\Tcpip)
The first parameter is address of UNICODE_STRING variable. Hence the name is not build properly.
Append L" before the strings starts and end with "
I guess, you would be getting 0xC0000034 - STATUS_OBJECT_NOT_FOUIND as error for the call to
ZwOpenKey( ).
Do check what is the content of the UNICODE_STRING after the call to RtlInitUnicodestring( ) before U
put some hypothesis.
If it still doesnot work after this, check using ZwCreateKey( ) where in U can use addition flags.
---------------------------------- Modified code --------------------------------
OBJECT_ATTRIBUTES oa;
HANDLE hkey;
UNICODE_STRING RegistryPath;
RtlInitUnicodeString(&RegistryPath,L"\Registry\Machine\SYSTEM\CurrentControlSet\Services\Tcpip")
InitializeObjectAttributes(&oa, &RegistryPath, (OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE), NULL, NULL);
status = ZwOpenKey(&hkey, KEY_READ, &oa);
Cheers,
----- Original Message -----
From: square
To: NT Developers Interest List
Sent: Saturday, June 15, 2002 4:03 PM
Subject: [ntdev] ZwOpenKey Failure
Hi:
My program use ZwOpenKey to open registry key,but return failure.
OBJECT_ATTRIBUTES oa;
HANDLE hkey;
UNICODE_STRING RegistryPath;
RtlInitUnicodeString(RegistryPath,\Registry\Machine\SYSTEM\CurrentControlSet\Services\Tcpip)
InitializeObjectAttributes(&oa, &RegistryPath, 0, NULL, NULL);
status = ZwOpenKey(&hkey, KEY_READ, &oa);
//return status is not STATUS_SUCCESS why???
b??箷????vڵ?j???wN???r??zǧu??jy???^j???ׯ??y&X???&