CmDeleteKeyRecursive
INT64 __stdcall CmDeleteKeyRecursive(PVOID hKeyRoot, WCHAR *Key, PVOID TemporaryBuffer, UINT64 LengthTemporaryBuffer){
INT64 result;
__int64 v7;
WCHAR *PoolWithTag;
WCHAR *v9;
__int64 v10;
int v11;
NTSTATUS v12;
UINT64 Length;
struct _UNICODE_STRING DestinationString;
struct _OBJECT_ATTRIBUTES ObjectAttributes;
void *KeyHandle;
UINT64 ResultLength;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
LODWORD(ResultLength) = 0;
KeyHandle = 0i64;
DestinationString = 0i64;
RtlInitUnicodeString(&DestinationString, Key, (WCHAR)TemporaryBuffer);
ObjectAttributes.RootDirectory = hKeyRoot;
ObjectAttributes.ObjectName = &DestinationString;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
LODWORD(result) = ZwOpenKey(&KeyHandle, 0xF003Fu, &ObjectAttributes);
if( (int)result >= 0 )
{
do
{
LODWORD(Length) = 254;
v11 = ZwEnumerateKey(KeyHandle, 0i64, KeyBasicInformation, TemporaryBuffer, Length, &ResultLength);
if( v11 < 0 )
break;
v7 = -1i64;
*((_WORD *)TemporaryBuffer + ((unsigned __int64)*((unsigned int *)TemporaryBuffer + 3) >> 1) + 8) = 0;
do
++v7;
while( *((_WORD *)TemporaryBuffer + v7 + 8) );
PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2 * v7 + 2, 0x20204D43ui64);
v9 = PoolWithTag;
if( !PoolWithTag )
{
v11 = -1073741670;
break;
}
v10 = -1i64;
do
++v10;
while( *((_WORD *)TemporaryBuffer + v10 + 8) );
wcscpy_s(PoolWithTag, v10 + 1, (PWCHAR)TemporaryBuffer + 8);
v11 = CmDeleteKeyRecursive(KeyHandle, v9, TemporaryBuffer, 0x100ui64);
ExFreePoolWithTag(v9, 0);
}
while( v11 >= 0 );
v12 = 0;
if( v11 != -2147483622 )
v12 = v11;
if( v12 >= 0 )
v12 = ZwDeleteKey(KeyHandle);
ZwClose(KeyHandle);
return(unsigned int)v12;
}
return result;
}Referenced by:
CmDeleteKeyRecursive
CmpCreateHardwareProfiles
CmpMoveBiosAliasTable