mirror of https://github.com/JKornev/hidden
Memory leak fixes #2 (Verifier tests)
This commit is contained in:
parent
ca63ce3d31
commit
1db58b922c
|
@ -35,3 +35,4 @@
|
||||||
/HiddenTests/x64/Release
|
/HiddenTests/x64/Release
|
||||||
/Hidden/Debug
|
/Hidden/Debug
|
||||||
/Hidden/x64/Debug
|
/Hidden/x64/Debug
|
||||||
|
/HiddenCLI/x64/Debug
|
||||||
|
|
|
@ -259,7 +259,10 @@ NTSTATUS QueryAndAllocRegistryData(HANDLE hKey, LPCWSTR Value, ULONG Type, PUNIC
|
||||||
dataLength = info->DataLength;
|
dataLength = info->DataLength;
|
||||||
dataBuffer = ExAllocatePoolWithTag(NonPagedPool, dataLength, CONFIG_ALLOC_TAG);
|
dataBuffer = ExAllocatePoolWithTag(NonPagedPool, dataLength, CONFIG_ALLOC_TAG);
|
||||||
if (!dataBuffer)
|
if (!dataBuffer)
|
||||||
|
{
|
||||||
|
ExFreePoolWithTag(info, CONFIG_ALLOC_TAG);
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
RtlCopyMemory(dataBuffer, info->Data, dataLength);
|
RtlCopyMemory(dataBuffer, info->Data, dataLength);
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,7 @@ NTSTATUS RegPostEnumKey(PVOID context, PREG_POST_OPERATION_INFORMATION info)
|
||||||
HANDLE Key;
|
HANDLE Key;
|
||||||
ULONG resLen, i;
|
ULONG resLen, i;
|
||||||
BOOLEAN infinite = TRUE;
|
BOOLEAN infinite = TRUE;
|
||||||
|
PVOID tempBuffer;
|
||||||
|
|
||||||
status = ObOpenObjectByPointer(info->Object, OBJ_KERNEL_HANDLE, NULL, KEY_ALL_ACCESS, *CmKeyObjectType, KernelMode, &Key);
|
status = ObOpenObjectByPointer(info->Object, OBJ_KERNEL_HANDLE, NULL, KEY_ALL_ACCESS, *CmKeyObjectType, KernelMode, &Key);
|
||||||
if (!NT_SUCCESS(status))
|
if (!NT_SUCCESS(status))
|
||||||
|
@ -261,20 +262,39 @@ NTSTATUS RegPostEnumKey(PVOID context, PREG_POST_OPERATION_INFORMATION info)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; infinite; i++)
|
tempBuffer = (LPWSTR)ExAllocatePoolWithTag(PagedPool, preInfo->Length, FILTER_ALLOC_TAG);
|
||||||
|
if (tempBuffer)
|
||||||
{
|
{
|
||||||
status = ZwEnumerateKey(Key, preInfo->Index + incIndex, preInfo->KeyInformationClass, preInfo->KeyInformation, preInfo->Length, &resLen);
|
for (i = 0; infinite; i++)
|
||||||
if (!NT_SUCCESS(status))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!GetNameFromEnumKeyPreInfo(preInfo->KeyInformationClass, preInfo->KeyInformation, &keyName))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!CheckExcludeListRegKeyValueName(g_excludeRegKeyContext, (PUNICODE_STRING)regPath, &keyName, &incIndex))
|
|
||||||
{
|
{
|
||||||
*preInfo->ResultLength = resLen;
|
status = ZwEnumerateKey(Key, preInfo->Index + incIndex, preInfo->KeyInformationClass, tempBuffer, preInfo->Length, &resLen);
|
||||||
break;
|
if (!NT_SUCCESS(status))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!GetNameFromEnumKeyPreInfo(preInfo->KeyInformationClass, tempBuffer, &keyName))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!CheckExcludeListRegKeyValueName(g_excludeRegKeyContext, (PUNICODE_STRING)regPath, &keyName, &incIndex))
|
||||||
|
{
|
||||||
|
*preInfo->ResultLength = resLen;
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
RtlCopyMemory(preInfo->KeyInformation, tempBuffer, resLen);
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": Error, can't copy new key information\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExFreePoolWithTag(tempBuffer, FILTER_ALLOC_TAG);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->ReturnStatus = status;
|
info->ReturnStatus = status;
|
||||||
|
@ -351,6 +371,7 @@ NTSTATUS RegPostEnumValue(PVOID context, PREG_POST_OPERATION_INFORMATION info)
|
||||||
HANDLE Key;
|
HANDLE Key;
|
||||||
ULONG resLen, i;
|
ULONG resLen, i;
|
||||||
BOOLEAN infinite = TRUE;
|
BOOLEAN infinite = TRUE;
|
||||||
|
PVOID tempBuffer;
|
||||||
|
|
||||||
status = ObOpenObjectByPointer(info->Object, OBJ_KERNEL_HANDLE, NULL, KEY_ALL_ACCESS, *CmKeyObjectType, KernelMode, &Key);
|
status = ObOpenObjectByPointer(info->Object, OBJ_KERNEL_HANDLE, NULL, KEY_ALL_ACCESS, *CmKeyObjectType, KernelMode, &Key);
|
||||||
if (!NT_SUCCESS(status))
|
if (!NT_SUCCESS(status))
|
||||||
|
@ -359,20 +380,40 @@ NTSTATUS RegPostEnumValue(PVOID context, PREG_POST_OPERATION_INFORMATION info)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; infinite; i++)
|
tempBuffer = (LPWSTR)ExAllocatePoolWithTag(PagedPool, preInfo->Length, FILTER_ALLOC_TAG);
|
||||||
|
if (tempBuffer)
|
||||||
{
|
{
|
||||||
status = ZwEnumerateValueKey(Key, preInfo->Index + incIndex, preInfo->KeyInformationClass, preInfo->KeyInformation, preInfo->Length, &resLen);
|
|
||||||
if (!NT_SUCCESS(status))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!GetNameFromEnumValuePreInfo(preInfo->KeyInformationClass, preInfo->KeyInformation, &keyName))
|
for (i = 0; infinite; i++)
|
||||||
break;
|
|
||||||
|
|
||||||
if (!CheckExcludeListRegKeyValueName(g_excludeRegValueContext, (PUNICODE_STRING)regPath, &keyName, &incIndex))
|
|
||||||
{
|
{
|
||||||
*preInfo->ResultLength = resLen;
|
status = ZwEnumerateValueKey(Key, preInfo->Index + incIndex, preInfo->KeyInformationClass, tempBuffer, preInfo->Length, &resLen);
|
||||||
break;
|
if (!NT_SUCCESS(status))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!GetNameFromEnumValuePreInfo(preInfo->KeyInformationClass, tempBuffer, &keyName))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!CheckExcludeListRegKeyValueName(g_excludeRegValueContext, (PUNICODE_STRING)regPath, &keyName, &incIndex))
|
||||||
|
{
|
||||||
|
*preInfo->ResultLength = resLen;
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
RtlCopyMemory(preInfo->KeyInformation, tempBuffer, resLen);
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": Error, can't copy new key information\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExFreePoolWithTag(tempBuffer, FILTER_ALLOC_TAG);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->ReturnStatus = status;
|
info->ReturnStatus = status;
|
||||||
|
|
Loading…
Reference in New Issue