CmpQueryEditionVersion
NTSTATUS __fastcall CmpQueryEditionVersion(VOID *a1, INT64 a2, INT64 a3){
NTSTATUS result;
int v7;
void *v8;
void *v9;
__int64 v10;
WCHAR v11;
__int64 v12;
WCHAR v13;
__int64 v14;
WCHAR v15;
UNICODE_STRING *v16;
NTSTATUS v17;
ULONG ResultLength;
void *KeyHandle;
struct _STRING DestinationString;
struct _OBJECT_ATTRIBUTES ObjectAttributes;
int KeyValueInformation;
int v23;
unsigned int v24;
size_t Size;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
KeyHandle = 0i64;
ResultLength = 0;
*(_DWORD *)(&DestinationString.MaximumLength + 1) = 0;
memset((INT64)&KeyValueInformation, 0i64);
memset((INT64)a1, 0i64);
ObjectAttributes.RootDirectory = (void *)a2;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)&CmpEditionVersionString;
ObjectAttributes.SecurityDescriptor = (void *)a3;
ObjectAttributes.SecurityQualityOfService = 0i64;
result = ZwOpenKey(&KeyHandle, 1u, &ObjectAttributes);
if( result >= 0 )
{
v7 = ZwQueryValueKey(
KeyHandle,
(PUNICODE_STRING)&CmpEditionBuildNumberString,
KeyValueFullInformation,
&KeyValueInformation,
0x100u,
&ResultLength);
if( v7 >= 0 )
{
if( v23 != 4 )
{
LABEL_33:
v7 = -1073741788;
goto LABEL_41;
}
if( (_DWORD)Size != 4 )
goto LABEL_34;
if( v24 + 4i64 != ResultLength )
goto LABEL_35;
v8 = KeyHandle;
*(_DWORD *)a1 = *(int *)((char *)&KeyValueInformation + v24);
v7 = ZwQueryValueKey(
v8,
(PUNICODE_STRING)&CmpEditionBuildQfeString,
KeyValueFullInformation,
&KeyValueInformation,
0x100u,
&ResultLength);
if( v7 >= 0 )
{
if( v23 == 4 )
{
if( (_DWORD)Size != 4 )
goto LABEL_34;
if( v24 + 4i64 != ResultLength )
goto LABEL_35;
v9 = KeyHandle;
*((_DWORD *)a1 + 1) = *(int *)((char *)&KeyValueInformation + v24);
if( ZwQueryValueKey(
v9,
(PUNICODE_STRING)&CmpEditionBuildBranchString,
KeyValueFullInformation,
&KeyValueInformation,
0x100u,
&ResultLength) >= 0
&& v23 == 1 )
{
if( v24 + (_DWORD)Size != ResultLength )
goto LABEL_35;
if( (Size & 1) != 0 )
goto LABEL_34;
v10 = (unsigned int)Size;
if( (unsigned __int64)(unsigned int)Size + 2 > 0x80 )
goto LABEL_36;
memmove((UINT8 *)a1 + 56, (UINT8 *)&KeyValueInformation + v24, (unsigned int)Size);
*(_WORD *)((char *)a1 + v10 + 56) = 0;
RtlInitUnicodeString((PUNICODE_STRING)((char *)a1 + 8), (PCWSTR)a1 + 28, v11);
}
if( ZwQueryValueKey(
KeyHandle,
(PUNICODE_STRING)&CmpEditionBuildLabString,
KeyValueFullInformation,
&KeyValueInformation,
0x100u,
&ResultLength) < 0
|| v23 != 1 )
{
LABEL_22:
if( ZwQueryValueKey(
KeyHandle,
(PUNICODE_STRING)&CmpEditionBuildLabExString,
KeyValueFullInformation,
&KeyValueInformation,
0x100u,
&ResultLength) < 0
|| v23 != 1 )
{
LABEL_28:
*(_DWORD *)&DestinationString.Length = 0x800000;
DestinationString.Buffer = (char *)a1 + 440;
if( *((_QWORD *)a1 + 6) && (v16 = (UNICODE_STRING *)((char *)a1 + 40), *((_WORD *)a1 + 20))
|| *((_QWORD *)a1 + 4) && (v16 = (UNICODE_STRING *)((char *)a1 + 24), *((_WORD *)a1 + 12)) )
{
v17 = RtlUnicodeStringToAnsiString(&DestinationString, v16, 0);
}
else
{
v17 = -2147483614;
}
if( v17 < 0 )
*((_BYTE *)a1 + 440) = 0;
v7 = 0;
goto LABEL_41;
}
if( v24 + (_DWORD)Size == ResultLength )
{
if( (Size & 1) == 0 )
{
v14 = (unsigned int)Size;
if( (unsigned __int64)(unsigned int)Size + 2 <= 0x80 )
{
memmove((UINT8 *)a1 + 312, (UINT8 *)&KeyValueInformation + v24, (unsigned int)Size);
*(_WORD *)((char *)a1 + v14 + 312) = 0;
RtlInitUnicodeString((PUNICODE_STRING)((char *)a1 + 40), (PCWSTR)a1 + 156, v15);
goto LABEL_28;
}
goto LABEL_36;
}
goto LABEL_34;
}
LABEL_35:
v7 = -1073741764;
goto LABEL_41;
}
if( v24 + (_DWORD)Size != ResultLength )
goto LABEL_35;
if( (Size & 1) == 0 )
{
v12 = (unsigned int)Size;
if( (unsigned __int64)(unsigned int)Size + 2 <= 0x80 )
{
memmove((UINT8 *)a1 + 184, (UINT8 *)&KeyValueInformation + v24, (unsigned int)Size);
*(_WORD *)((char *)a1 + v12 + 184) = 0;
RtlInitUnicodeString((PUNICODE_STRING)((char *)a1 + 24), (PCWSTR)a1 + 92, v13);
goto LABEL_22;
}
LABEL_36:
v7 = -1073741789;
goto LABEL_41;
}
LABEL_34:
v7 = -1073741306;
goto LABEL_41;
}
goto LABEL_33;
}
}
LABEL_41:
ZwClose(KeyHandle);
return v7;
}
return result;
}Referenced by:
CmpSetVersionData