[NTOS:CM] Protect user memory access with SEH in NtQueryOpenSubKeys.

This commit is contained in:
Thomas Faber 2019-12-29 10:00:59 +01:00
parent eb7be70007
commit 91cc1c3e4f
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -1473,6 +1473,7 @@ NtQueryOpenSubKeys(IN POBJECT_ATTRIBUTES TargetKey,
PCM_KEY_BODY KeyBody = NULL;
HANDLE KeyHandle;
NTSTATUS Status;
ULONG SubKeys;
DPRINT("NtQueryOpenSubKeys()\n");
@ -1543,8 +1544,8 @@ NtQueryOpenSubKeys(IN POBJECT_ATTRIBUTES TargetKey,
}
/* Call the internal API */
*HandleCount = CmpEnumerateOpenSubKeys(KeyBody->KeyControlBlock,
FALSE, FALSE);
SubKeys = CmpEnumerateOpenSubKeys(KeyBody->KeyControlBlock,
FALSE, FALSE);
/* Unlock the registry */
CmpUnlockRegistry();
@ -1552,6 +1553,17 @@ NtQueryOpenSubKeys(IN POBJECT_ATTRIBUTES TargetKey,
/* Dereference the key object */
ObDereferenceObject(KeyBody);
/* Write back the result */
_SEH2_TRY
{
*HandleCount = SubKeys;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
DPRINT("Done.\n");
return Status;