CmpAddProcessorConfigurationEntry
INT64 __stdcall CmpAddProcessorConfigurationEntry(_KPRCB *Prcb, UINT64 KeyIndex, PVOID ParentHandle){
unsigned int v4;
unsigned __int8 CpuVendor;
INT8 *v7;
__int64 v8;
INT64 result;
bool v10;
__int64 v11;
int v12;
VOID *v13;
NTSTATUS v14;
const char *v15;
__int128 *v16;
unsigned int v17;
__int64 v18;
__int64 v19;
_LARGE_INTEGER *p_UpdateSignature;
VOID *Data;
VOID *Dataa;
UINT64 DataSize;
int FeatureBits;
_UNICODE_STRING DestinationString;
_UNICODE_STRING UnicodeString;
VOID *KeyHandle;
_STRING SourceString;
_CONFIGURATION_COMPONENT_DATA a1;
VOID *Handle;
__int128 v31[3];
int v32;
char Dst[128];
FeatureBits = 0;
Handle = 0i64;
v32 = 0;
v4 = KeyIndex;
KeyHandle = (VOID *)-1i64;
SourceString = 0i64;
memset(v31, 0, sizeof(v31));
UnicodeString = 0i64;
DestinationString = 0i64;
memset(&a1, 0i64, sizeof(a1));
a1.ComponentEntry.Group = Prcb->Group;
a1.ComponentEntry.GroupIndex = Prcb->GroupIndex;
a1.ComponentEntry.Identifier = Dst;
CpuVendor = Prcb->CpuVendor;
a1.ComponentEntry.Class = ProcessorClass;
a1.ComponentEntry.Type = CentralProcessor;
a1.ComponentEntry.Key = v4;
if( CpuVendor == 1 )
{
v7 = "AMD64 Family %u Model %u Stepping %u";
}
else if( CpuVendor == 2 )
{
v7 = (INT8 *)"Intel64 Family %u Model %u Stepping %u";
}
else
{
if( CpuVendor != 3 )
KeBugCheck(0x5Du);
v7 = "VIA64 Family %u Model %u Stepping %u";
}
sprintf_s(Dst, 0x80ui64, v7, (unsigned int)Prcb->CpuType, HIBYTE(Prcb->CpuStep), (unsigned __int8)Prcb->CpuStep);
v8 = -1i64;
do
++v8;
while( Dst[v8] );
a1.ComponentEntry.IdentifierLength = v8 + 1;
LODWORD(Data) = -1;
result = CmpInitializeRegistryNode(
&a1,
ParentHandle,
&KeyHandle,
InterfaceTypeUndefined,
(UINT64)Data,
(UINT16 *)CmpDeviceIndexTable);
if( (int)result >= 0 )
{
memset(&a1, 0i64, sizeof(a1));
v10 = Prcb->CpuType == 3;
a1.ComponentEntry.Group = Prcb->Group;
a1.ComponentEntry.GroupIndex = Prcb->GroupIndex;
a1.ComponentEntry.Identifier = Dst;
a1.ComponentEntry.Class = ProcessorClass;
a1.ComponentEntry.Type = FloatingPointProcessor;
a1.ComponentEntry.Key = v4;
if( v10 )
strcpy_s(Dst, 0x80ui64, (PSTR)"80387");
v11 = -1i64;
do
++v11;
while( Dst[v11] );
a1.ComponentEntry.IdentifierLength = v11 + 1;
LODWORD(Dataa) = -1;
v12 = CmpInitializeRegistryNode(
&a1,
ParentHandle,
&Handle,
InterfaceTypeUndefined,
(UINT64)Dataa,
(UINT16 *)CmpDeviceIndexTable);
v13 = KeyHandle;
v14 = v12;
if( v12 >= 0 )
{
ZwClose((_HANDLE)Handle);
v15 = (const char *)((unsigned __int64)Prcb->VendorString & -(__int64)(Prcb->CpuID != 0));
if( (unsigned int)EAX(__cpuid(0x80000000, 0)) < 0x80000004 )
goto LABEL_40;
v16 = v31;
v17 = -2147483646;
do
{
v18 = __cpuid(v17, 0);
*(_DWORD *)v16 = EAX(v18);
++v17;
*((_DWORD *)v16 + 1) = EBX(v18);
*((_DWORD *)v16 + 2) = ECX(v18);
*((_DWORD *)v16++ + 3) = EDX(v18);
}
while( v17 <= 0x80000004 );
LOBYTE(v32) = 0;
if( !v16 )
goto LABEL_40;
RtlInitUnicodeString(&DestinationString, L"ProcessorNameString");
LODWORD(v19) = 0;
if( LOBYTE(v31[0]) == 32 )
{
do
v19 = (unsigned int)(v19 + 1);
while( *((_BYTE *)v31 + v19) == 32 );
}
RtlInitAnsiString(&SourceString, (PCSZ)v31 + (unsigned int)v19);
v14 = RtlAnsiStringToUnicodeString(&UnicodeString, &SourceString, 1u);
if( v14 >= 0 )
{
LODWORD(DataSize) = UnicodeString.Length + 2;
v14 = ZwSetValueKey(v13, &DestinationString, 0i64, 1ui64, UnicodeString.Buffer, DataSize);
RtlFreeAnsiString(&UnicodeString);
if( v14 >= 0 )
{
LABEL_40:
if( !v15
|| (RtlInitUnicodeString(&DestinationString, L"VendorIdentifier"),
RtlInitAnsiString(&SourceString, v15),
v14 = RtlAnsiStringToUnicodeString(&UnicodeString, &SourceString, 1u),
v14 >= 0)
&& (LODWORD(DataSize) = UnicodeString.Length + 2,
v14 = ZwSetValueKey(v13, &DestinationString, 0i64, 1ui64, UnicodeString.Buffer, DataSize),
RtlFreeAnsiString(&UnicodeString),
v14 >= 0) )
{
if( !Prcb->FeatureBits
|| (FeatureBits = Prcb->FeatureBits,
RtlInitUnicodeString(&DestinationString, L"FeatureSet"),
LODWORD(DataSize) = 4,
v14 = ZwSetValueKey(v13, &DestinationString, 0i64, 4ui64, &FeatureBits, DataSize),
v14 >= 0) )
{
if( !Prcb->MHz
|| (RtlInitUnicodeString(&DestinationString, L"~MHz"),
LODWORD(DataSize) = 4,
v14 = ZwSetValueKey(v13, &DestinationString, 0i64, 4ui64, &Prcb->MHz, DataSize),
v14 >= 0) )
{
p_UpdateSignature = &Prcb->UpdateSignature;
if( p_UpdateSignature->QuadPart )
{
RtlInitUnicodeString(&DestinationString, L"Update Revision");
LODWORD(DataSize) = 8;
v14 = ZwSetValueKey(v13, &DestinationString, 0i64, 3ui64, p_UpdateSignature, DataSize);
}
}
}
}
}
}
}
if( v13 != (VOID *)-1i64 )
ZwClose((_HANDLE)v13);
return(unsigned int)v14;
}
return result;
}Referenced by:
CmInitializeProcessor
CmpInitializeMachineDependentConfiguration