summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7697e22)
- Implement RtlpCloseRegistryHandle helper, which closes a registry key, if RTL_REGISTRY_HANDLE was not passed as RelativeTo
- Use RtlpCloseRegistryHandle whereever required, fixing some cases, where we unconditionally closed the handle
svn path=/trunk/; revision=64186
+FORCEINLINE
+VOID
+RtlpCloseRegistryHandle(
+ _In_ ULONG RelativeTo,
+ _In_ HANDLE KeyHandle)
+{
+ /* Did the caller pass a key handle? */
+ if (!(RelativeTo & RTL_REGISTRY_HANDLE))
+ {
+ /* We opened the key in RtlpGetRegistryHandle, so close it now */
+ ZwClose(KeyHandle);
+ }
+}
+
/* PUBLIC FUNCTIONS **********************************************************/
/*
/* PUBLIC FUNCTIONS **********************************************************/
/*
&KeyHandle);
if (!NT_SUCCESS(Status)) return Status;
&KeyHandle);
if (!NT_SUCCESS(Status)) return Status;
- /* All went well, close the handle and return success */
+ /* Close the handle even for RTL_REGISTRY_HANDLE */
ZwClose(KeyHandle);
return STATUS_SUCCESS;
}
ZwClose(KeyHandle);
return STATUS_SUCCESS;
}
&KeyHandle);
if (!NT_SUCCESS(Status)) return Status;
&KeyHandle);
if (!NT_SUCCESS(Status)) return Status;
- /* All went well, close the handle and return success */
- ZwClose(KeyHandle);
+ /* All went well, close the handle and return status */
+ RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
RtlInitUnicodeString(&Name, ValueName);
Status = ZwDeleteValueKey(KeyHandle, &Name);
RtlInitUnicodeString(&Name, ValueName);
Status = ZwDeleteValueKey(KeyHandle, &Name);
- /* All went well, close the handle and return status */
- ZwClose(KeyHandle);
+ /* Close the handle and return status */
+ RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
- /* Did the caller pass a key handle? */
- if (!(RelativeTo & RTL_REGISTRY_HANDLE))
- {
- /* We opened the key in RtlpGetRegistryHandle, so close it now */
- ZwClose(KeyHandle);
- }
-
+ /* Close the handle and return status */
+ RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
if (!KeyValueInfo)
{
/* Close the handle if we have one and fail */
if (!KeyValueInfo)
{
/* Close the handle if we have one and fail */
- if (!(RelativeTo & RTL_REGISTRY_HANDLE)) ZwClose(KeyHandle);
+ RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
}
/* Check if we need to close our handle */
}
/* Check if we need to close our handle */
- if ((KeyHandle) && !(RelativeTo & RTL_REGISTRY_HANDLE)) ZwClose(KeyHandle);
+ if (KeyHandle) RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
if ((CurrentKey) && (CurrentKey != KeyHandle)) ZwClose(CurrentKey);
/* Free our buffer and return status */
if ((CurrentKey) && (CurrentKey != KeyHandle)) ZwClose(CurrentKey);
/* Free our buffer and return status */