CmpSetSystemBiosInformation
NTSTATUS __fastcall CmpSetSystemBiosInformation(_LOADER_PARAMETER_BLOCK *a1, VOID *a2, VOID *a3){
unsigned int v4;
NTSTATUS result;
_WORD *v6;
_WORD *v7;
_LOADER_PARAMETER_BLOCK *v8;
int i;
UINT64 v10;
char *v11;
VOID *v12;
size_t v13;
char *v14;
unsigned __int16 v15;
_LARGE_INTEGER *SectionOffset;
UINT64 AllocationType;
UINT64 Win32Protect;
VOID *BaseAddress;
_UNICODE_STRING UnicodeString;
_UNICODE_STRING ValueName;
_STRING DestinationString;
_LARGE_INTEGER v23;
PVOID P;
_UNICODE_STRING String2;
UINT64 ViewSize;
_LOADER_PARAMETER_BLOCK *LoaderBlock;
VOID *Data;
VOID *KeyHandle;
char SourceString[128];
LODWORD(Win32Protect) = 4;
LoaderBlock = a1;
LODWORD(AllocationType) = 0;
KeyHandle = a3;
P = 0i64;
*(_DWORD *)(&String2.MaximumLength + 1) = 0;
BaseAddress = 0i64;
ViewSize = 0x10000i64;
v23.QuadPart = 983040i64;
DestinationString = 0i64;
v4 = 0;
UnicodeString = 0i64;
ValueName = 0i64;
result = ZwMapViewOfSection(
a2,
(VOID *)0xFFFFFFFFFFFFFFFFi64,
&BaseAddress,
0i64,
0x10000ui64,
&v23,
&ViewSize,
ViewUnmap,
AllocationType,
Win32Protect);
if( result >= 0 )
{
Data = ExAllocatePoolWithTag(1ui64, 0x1000ui64, 538987843i64);
v6 = Data;
if( CmpGetBiosDate((PSTR)BaseAddress + 65525, 8ui64, SourceString, 1u) )
{
RtlInitAnsiString(&DestinationString, SourceString);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
RtlInitUnicodeString(&ValueName, L"SystemBiosDate");
if( CmpGetRegistryValue(a3, ValueName.Buffer, (_KEY_VALUE_PARTIAL_INFORMATION **)&P) >= 0 )
{
v14 = (char *)P;
if( P )
{
String2.MaximumLength = *((_WORD *)P + 4);
v15 = String2.MaximumLength - 2;
String2.Buffer = (wchar_t *)((char *)P + 12);
String2.Length = String2.MaximumLength - 2;
if( RtlCompareUnicodeString(&UnicodeString, &String2, 1u) )
{
RtlInitUnicodeString(&ValueName, L"OldSystemBiosDate");
LODWORD(SectionOffset) = v15 + 2;
ZwSetValueKey(a3, &ValueName, 0i64, 1ui64, v14 + 12, (UINT64)SectionOffset);
}
ExFreePoolWithTag(v14, 0);
}
}
RtlFreeAnsiString(&UnicodeString);
}
}
if( CmpGetBiosDate((PSTR)BaseAddress, 0x10000ui64, SourceString, 1u) )
{
RtlInitUnicodeString(&ValueName, L"SystemBiosDate");
RtlInitAnsiString(&DestinationString, SourceString);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
LODWORD(SectionOffset) = UnicodeString.Length + 2;
ZwSetValueKey(a3, &ValueName, 0i64, 1ui64, UnicodeString.Buffer, (UINT64)SectionOffset);
RtlFreeAnsiString(&UnicodeString);
}
}
v7 = v6;
if( v6 )
{
v8 = LoaderBlock;
for( i = 0; ; ++i )
{
if( i )
{
v10 = 0x10000i64;
v11 = 0i64;
if( i == 1 )
v11 = (char *)BaseAddress;
if( i != 1 )
v10 = 0i64;
if( !CmpGetBiosVersion(v11, v10, SourceString) )
{
LABEL_17:
v6 = Data;
v12 = KeyHandle;
if( v4 )
{
*v7 = 0;
RtlInitUnicodeString(&ValueName, L"SystemBiosVersion");
LODWORD(SectionOffset) = v4 + 2;
ZwSetValueKey(v12, &ValueName, 0i64, 7ui64, v6, (UINT64)SectionOffset);
}
break;
}
}
else if( !CmpGetAcpiBiosVersion((INT64)v8, SourceString) )
{
continue;
}
RtlInitAnsiString(&DestinationString, SourceString);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
v13 = UnicodeString.Length + 2;
memmove(v7, UnicodeString.Buffer, v13);
v4 += v13;
RtlFreeAnsiString(&UnicodeString);
if( (unsigned __int64)v4 + 260 > 0x1000 )
goto LABEL_17;
v7 = (_WORD *)((char *)v7 + v13);
}
}
}
result = ZwUnmapViewOfSection((VOID *)0xFFFFFFFFFFFFFFFFi64, BaseAddress);
if( v6 )
return(unsigned int)ExFreePoolWithTag(v6, 0);
}
return result;
}Referenced by:
CmpInitializeMachineDependentConfiguration