mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[RTL]
- 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
This commit is contained in:
parent
7697e22142
commit
bcaee07f89
1 changed files with 23 additions and 14 deletions
|
@ -551,6 +551,20 @@ RtlpGetRegistryHandle(IN ULONG RelativeTo,
|
|||
return Status;
|
||||
}
|
||||
|
||||
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 **********************************************************/
|
||||
|
||||
/*
|
||||
|
@ -572,7 +586,7 @@ RtlCheckRegistryKey(IN ULONG RelativeTo,
|
|||
&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;
|
||||
}
|
||||
|
@ -596,8 +610,8 @@ RtlCreateRegistryKey(IN ULONG RelativeTo,
|
|||
&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);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -626,8 +640,8 @@ RtlDeleteRegistryValue(IN ULONG RelativeTo,
|
|||
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);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -664,13 +678,8 @@ RtlWriteRegistryValue(IN ULONG RelativeTo,
|
|||
ValueData,
|
||||
ValueLength);
|
||||
|
||||
/* 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);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1017,7 +1026,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
if (!KeyValueInfo)
|
||||
{
|
||||
/* Close the handle if we have one and fail */
|
||||
if (!(RelativeTo & RTL_REGISTRY_HANDLE)) ZwClose(KeyHandle);
|
||||
RtlpCloseRegistryHandle(RelativeTo, KeyHandle);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1318,7 +1327,7 @@ ProcessValues:
|
|||
}
|
||||
|
||||
/* 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 */
|
||||
|
|
Loading…
Reference in a new issue