CmpSetSystemBiosInformation
VOID __stdcall CmpSetSystemBiosInformation(
_LOADER_PARAMETER_BLOCK *LoaderBlock,
PVOID SectionHandle,
PVOID ParentHandle){
unsigned int v4;
UINT8 *v5;
INT8 v6;
WCHAR v7;
WCHAR v8;
INT8 v9;
UINT8 *v10;
_LOADER_PARAMETER_BLOCK *v11;
int i;
UINT64 v13;
CHAR *v14;
__int16 v15;
HANDLE v16;
unsigned int v17;
char *v18;
__int64 v19;
WCHAR v20;
PLARGE_INTEGER SectionOffset;
UINT64 AllocationType;
UINT64 Win32Protect;
PVOID BaseAddress;
struct _UNICODE_STRING UnicodeString;
struct _UNICODE_STRING ValueName;
struct _STRING DestinationString;
LARGE_INTEGER v28;
PVOID P;
UNICODE_STRING String2;
ULONG_PTR ViewSize;
_LOADER_PARAMETER_BLOCK *LoaderBlocka;
PVOID Data;
HANDLE KeyHandle;
char SourceString[128];
LODWORD(Win32Protect) = 4;
LoaderBlocka = LoaderBlock;
LODWORD(AllocationType) = 0;
KeyHandle = ParentHandle;
P = 0i64;
*(_DWORD *)(&String2.MaximumLength + 1) = 0;
BaseAddress = 0i64;
ViewSize = 0x10000i64;
v28.QuadPart = 983040i64;
DestinationString = 0i64;
v4 = 0;
UnicodeString = 0i64;
ValueName = 0i64;
if( ZwMapViewOfSection(
SectionHandle,
(PVOID)0xFFFFFFFFFFFFFFFFi64,
&BaseAddress,
0i64,
0x10000ui64,
&v28,
&ViewSize,
ViewUnmap,
AllocationType,
Win32Protect) >= 0 )
{
Data = ExAllocatePoolWithTag(PagedPool, 0x1000ui64, 0x20204D43ui64);
v5 = (UINT8 *)Data;
if( CmpGetBiosDate((PSTR)BaseAddress + 65525, 8ui64, SourceString, 1u) )
{
RtlInitAnsiString(&DestinationString, SourceString, v6);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
RtlInitUnicodeString(&ValueName, L"SystemBiosDate", v7);
if( CmpGetRegistryValue(ParentHandle, ValueName.Buffer, (_KEY_VALUE_PARTIAL_INFORMATION **)&P) >= 0 )
{
v18 = (char *)P;
if( P )
{
String2.MaximumLength = *((_WORD *)P + 4);
v19 = (unsigned __int16)(String2.MaximumLength - 2);
String2.Buffer = (wchar_t *)((char *)P + 12);
String2.Length = String2.MaximumLength - 2;
if( (unsigned int)RtlCompareUnicodeString(&UnicodeString, &String2, 1u) )
{
RtlInitUnicodeString(&ValueName, L"OldSystemBiosDate", v20);
LODWORD(SectionOffset) = (unsigned __int16)v19 + 2;
ZwSetValueKey(ParentHandle, &ValueName, 0i64, 1ui64, v18 + 12, (UINT64)SectionOffset);
}
ExFreePoolWithTag(v18, 0);
}
}
RtlFreeAnsiString(&UnicodeString);
}
}
if( CmpGetBiosDate((PSTR)BaseAddress, 0x10000ui64, SourceString, 1u) )
{
RtlInitUnicodeString(&ValueName, L"SystemBiosDate", v8);
RtlInitAnsiString(&DestinationString, SourceString, v9);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
LODWORD(SectionOffset) = UnicodeString.Length + 2;
ZwSetValueKey(ParentHandle, &ValueName, 0i64, 1ui64, UnicodeString.Buffer, (UINT64)SectionOffset);
RtlFreeAnsiString(&UnicodeString);
}
}
v10 = v5;
if( v5 )
{
v11 = LoaderBlocka;
for( i = 0; ; ++i )
{
if( i )
{
v13 = 0x10000i64;
v14 = 0i64;
if( i == 1 )
v14 = (CHAR *)BaseAddress;
if( i != 1 )
v13 = 0i64;
if( !CmpGetBiosVersion(v14, v13, SourceString) )
{
LABEL_17:
v5 = (UINT8 *)Data;
v16 = KeyHandle;
if( v4 )
{
*(_WORD *)v10 = 0;
RtlInitUnicodeString(&ValueName, L"SystemBiosVersion", v15);
LODWORD(SectionOffset) = v4 + 2;
ZwSetValueKey(v16, &ValueName, 0i64, 7ui64, v5, (UINT64)SectionOffset);
}
break;
}
}
else if( !CmpGetAcpiBiosVersion(v11, SourceString) )
{
continue;
}
RtlInitAnsiString(&DestinationString, SourceString, v15);
if( RtlAnsiStringToUnicodeString(&UnicodeString, &DestinationString, 1u) >= 0 )
{
v17 = UnicodeString.Length + 2;
memmove(v10, (UINT8 *)UnicodeString.Buffer, v17);
v4 += v17;
RtlFreeAnsiString(&UnicodeString);
if( (unsigned __int64)v4 + 260 > 0x1000 )
goto LABEL_17;
v10 += v17;
}
}
}
ZwUnmapViewOfSection((HANDLE)0xFFFFFFFFFFFFFFFFi64, BaseAddress);
if( v5 )
ExFreePoolWithTag(v5, 0);
}
}Referenced by:
CmpInitializeMachineDependentConfiguration