5 IRegistryKeyVtbl
* lpVtbl
;
12 const GUID IID_IRegistryKey
;
15 Basic IUnknown methods
18 static IRegistryKeyVtbl vt_IRegistryKeyVtbl
;
23 IRegistryKey_fnAddRef(
24 IN IRegistryKey
* iface
)
26 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
28 DPRINT("IRegistryKey_AddRef: This %p\n", This
);
30 return _InterlockedIncrement(&This
->ref
);
35 IRegistryKey_fnRelease(
36 IN IRegistryKey
* iface
)
38 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
40 _InterlockedDecrement(&This
->ref
);
48 ExFreePoolWithTag(This
, TAG_PORTCLASS
);
51 /* Return new reference count */
57 IRegistryKey_fnQueryInterface(
58 IN IRegistryKey
* iface
,
62 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
64 if (IsEqualGUIDAligned(refiid
, &IID_IRegistryKey
))
66 *Output
= (PVOID
)&This
->lpVtbl
;
67 _InterlockedIncrement(&This
->ref
);
68 return STATUS_SUCCESS
;
71 DPRINT("IRegistryKey_QueryInterface: This %p unknown iid\n", This
, This
->ref
);
72 return STATUS_UNSUCCESSFUL
;
77 IRegistryKey_fnDeleteKey(
78 IN IRegistryKey
* iface
)
80 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
81 return ZwDeleteKey(This
->hKey
);
86 IRegistryKey_fnEnumerateKey(
87 IN IRegistryKey
* iface
,
89 IN KEY_INFORMATION_CLASS KeyInformationClass
,
90 OUT PVOID KeyInformation
,
92 OUT PULONG ResultLength
)
94 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
95 return ZwEnumerateKey(This
->hKey
, Index
, KeyInformationClass
, KeyInformation
, Length
, ResultLength
);
100 IRegistryKey_fnEnumerateKeyValue(
101 IN IRegistryKey
* iface
,
103 IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass
,
104 OUT PVOID KeyValueInformation
,
106 OUT PULONG ResultLength
)
108 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
109 return ZwEnumerateValueKey(This
->hKey
, Index
, KeyValueInformationClass
, KeyValueInformation
, Length
, ResultLength
);
114 IRegistryKey_fnNewSubKey(
115 IN IRegistryKey
* iface
,
116 OUT PREGISTRYKEY
*RegistrySubKey
,
117 IN PUNKNOWN OuterUnknown
,
118 IN ACCESS_MASK DesiredAccess
,
119 IN PUNICODE_STRING SubKeyName
,
120 IN ULONG CreateOptions
,
121 OUT PULONG Disposition OPTIONAL
)
123 OBJECT_ATTRIBUTES Attributes
;
126 IRegistryKeyImpl
* NewThis
, *This
= (IRegistryKeyImpl
*)iface
;
128 InitializeObjectAttributes(&Attributes
, SubKeyName
, 0, This
->hKey
, NULL
);
129 Status
= ZwCreateKey(&hKey
, KEY_READ
| KEY_WRITE
, &Attributes
, 0, NULL
, 0, Disposition
);
130 if (!NT_SUCCESS(Status
))
134 NewThis
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(IRegistryKeyImpl
), TAG_PORTCLASS
);
138 return STATUS_INSUFFICIENT_RESOURCES
;
141 NewThis
->hKey
= hKey
;
143 NewThis
->lpVtbl
= &vt_IRegistryKeyVtbl
;
144 *RegistrySubKey
= (PREGISTRYKEY
)&This
->lpVtbl
;
145 return STATUS_SUCCESS
;
150 IRegistryKey_fnQueryKey(
151 IN IRegistryKey
* iface
,
152 IN KEY_INFORMATION_CLASS KeyInformationClass
,
153 OUT PVOID KeyInformation
,
155 OUT PULONG ResultLength
)
157 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
158 return ZwQueryKey(This
->hKey
, KeyInformationClass
, KeyInformation
, Length
, ResultLength
);
163 IRegistryKey_fnQueryRegistryValues(
164 IN IRegistryKey
* iface
,
165 IN PRTL_QUERY_REGISTRY_TABLE QueryTable
,
166 IN PVOID Context OPTIONAL
)
168 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
169 DPRINT("IRegistryKey_QueryRegistryValues: This %p\n", This
);
170 return STATUS_UNSUCCESSFUL
;
175 IRegistryKey_fnQueryValueKey(
176 IN IRegistryKey
* iface
,
177 IN PUNICODE_STRING ValueName
,
178 IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass
,
179 OUT PVOID KeyValueInformation
,
181 OUT PULONG ResultLength
)
183 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
184 return ZwQueryValueKey(This
->hKey
, ValueName
, KeyValueInformationClass
, KeyValueInformation
, Length
, ResultLength
);
189 IRegistryKey_fnSetValueKey(
190 IN IRegistryKey
* iface
,
191 IN PUNICODE_STRING ValueName OPTIONAL
,
197 IRegistryKeyImpl
* This
= (IRegistryKeyImpl
*)iface
;
198 return ZwSetValueKey(This
->hKey
, ValueName
, 0, Type
, Data
, DataSize
);
201 static IRegistryKeyVtbl vt_IRegistryKey
=
203 /* IUnknown methods */
204 IRegistryKey_fnQueryInterface
,
205 IRegistryKey_fnAddRef
,
206 IRegistryKey_fnRelease
,
207 /* IRegistryKey methods */
208 IRegistryKey_fnQueryKey
,
209 IRegistryKey_fnEnumerateKey
,
210 IRegistryKey_fnQueryValueKey
,
211 IRegistryKey_fnEnumerateKeyValue
,
212 IRegistryKey_fnSetValueKey
,
213 IRegistryKey_fnQueryRegistryValues
,
214 IRegistryKey_fnNewSubKey
,
215 IRegistryKey_fnDeleteKey
223 OUT PREGISTRYKEY
* OutRegistryKey
,
224 IN PUNKNOWN OuterUnknown OPTIONAL
,
225 IN ULONG RegistryKeyType
,
226 IN ACCESS_MASK DesiredAccess
,
227 IN PVOID DeviceObject OPTIONAL
,
228 IN PVOID SubDevice OPTIONAL
,
229 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
230 IN ULONG CreateOptions OPTIONAL
,
231 OUT PULONG Disposition OPTIONAL
)
234 NTSTATUS Status
= STATUS_UNSUCCESSFUL
;
235 IRegistryKeyImpl
* This
;
238 return STATUS_INVALID_PARAMETER
;
240 if (RegistryKeyType
!= GeneralRegistryKey
&&
241 RegistryKeyType
!= DeviceRegistryKey
&&
242 RegistryKeyType
!= DriverRegistryKey
&&
243 RegistryKeyType
!= HwProfileRegistryKey
&&
244 RegistryKeyType
!= DeviceInterfaceRegistryKey
)
246 return STATUS_INVALID_PARAMETER
;
249 if (RegistryKeyType
== GeneralRegistryKey
)
251 if (!ObjectAttributes
)
252 return STATUS_INVALID_PARAMETER
;
254 Status
= ZwOpenKey(&hHandle
, DesiredAccess
, ObjectAttributes
);
257 if (!NT_SUCCESS(Status
))
262 This
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(IRegistryKeyImpl
), TAG_PORTCLASS
);
266 return STATUS_INSUFFICIENT_RESOURCES
;
269 This
->hKey
= hHandle
;
270 This
->lpVtbl
= &vt_IRegistryKey
;
273 *OutRegistryKey
= (PREGISTRYKEY
)&This
->lpVtbl
;
274 return STATUS_SUCCESS
;