//
// AmiTcgPlatformPeiAfterMem.efi - Full Decompilation
// Source: IDA Pro MCP port 13379
// Functions: 80
//
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int PcdPtr; // eax
if ( *(char *)(PeiGetPcdPtr() + 1024068) >= 0 ) /*0xffe192f8*/
{
PeiWriteIoPort(); /*0xffe192fa*/
PcdPtr = PeiGetPcdPtr(); /*0xffe192ff*/
*(_BYTE *)(PcdPtr + 1024068) |= 0x80u; /*0xffe1930a*/
}
return (*(int ( **)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 24))( /*0xffe1931e*/
SystemTable,
&unk_FFE21718);
}
int TpmMeasureDigestIntoPCR(int TpmPpi, int *this, unsigned int a3, int a4)
{
int result; // eax
int v7; // esi
int v8; // eax
int v9; // esi
int v10; // [esp+Ch] [ebp-8h] BYREF
int v11; // [esp+10h] [ebp-4h] BYREF
result = (*(int ( **)(int *, int, int *))(*this + 76))(this, 34, &v10); /*0xffe19335*/
if ( result >= 0 ) /*0xffe1933d*/
{
result = (*(int ( **)(int *, int, int *))(*this + 76))(this, 34, &v11); /*0xffe1934c*/
if ( result >= 0 ) /*0xffe19354*/
{
(*(void ( **)(int, int, _DWORD))(*this + 84))(v10, 34, 0); /*0xffe19364*/
v7 = v10; /*0xffe19367*/
*(_WORD *)v10 = -16128; /*0xffe19372*/
v7 += 10; /*0xffe19375*/
*(_DWORD *)(v10 + 2) = 570425344; /*0xffe1937c*/
*(_DWORD *)(v10 + 6) = 335544320; /*0xffe19387*/
v8 = *this; /*0xffe193b9*/
a3 = (((a3 << 16) | a3 & 0xFF00) << 8) | ((HIWORD(a3) | a3 & 0xFF0000) >> 8); /*0xffe193bd*/
(*(void ( **)(int, unsigned int *, int))(v8 + 80))(v7, &a3, 4); /*0xffe193c1*/
(*(void ( **)(int, int, int))(*this + 80))(v7 + 4, a4, 20); /*0xffe193d0*/
v9 = (*(int ( **)(int, int *, int, int, int, int))(TpmPpi + 8))(TpmPpi, this, 34, v10, 34, v11); /*0xffe193e2*/
DebugPrintWrapper(64, "Status = %r\n", v9); /*0xffe193ec*/
return v9; /*0xffe193f4*/
}
}
return result; /*0xffe193f7*/
}
int MeasureLogDxeFwVol(int *this, int *a2, void ( **TcgPpi)(_DWORD, int), int TpmPpi)
{
int Status; // eax
int *FwVolHobData; // esi
int FwVolHobCount; // ebx
unsigned int *FwVolHobEntry_1; // ecx
unsigned int *FwVolHobEntry_2; // ecx
int MeasureStatus; // ebp
int FinalStatus; // esi
int ParamArg; // ecx
unsigned int *FwVolHobEntry; // [esp+10h] [ebp-7Ch] BYREF
_BYTE MeasuredDigest[4]; // [esp+14h] [ebp-78h] BYREF
char DigestedData[20]; // [esp+18h] [ebp-74h] BYREF
char HashContext[96]; // [esp+2Ch] [ebp-60h] BYREF
FwVolHobEntry = 0; /*0xffe19400*/
DebugPrintWrapper(64, "[%d] Enter MeasureLogDxeFwVol\n", 212); /*0xffe19418*/
Status = (*(int ( **)(int *, int, unsigned int **))(*this + 76))(this, 48, &FwVolHobEntry); /*0xffe19427*/
if ( Status >= 0 ) /*0xffe1942f*/
{
FwVolHobData = a2 + 3; /*0xffe19439*/
FwVolHobCount = *a2; /*0xffe1943c*/
*FwVolHobEntry = 0; /*0xffe1943f*/
FwVolHobEntry[1] = 1; /*0xffe19446*/
FwVolHobEntry[7] = 16; /*0xffe19451*/
FwVolHobEntry_1 = FwVolHobEntry; /*0xffe19458*/
FwVolHobEntry[8] = a2[3]; /*0xffe1945e*/
FwVolHobEntry_1[9] = a2[4]; /*0xffe19464*/
FwVolHobEntry_2 = FwVolHobEntry; /*0xffe19467*/
FwVolHobEntry[10] = a2[5]; /*0xffe1946e*/
FwVolHobEntry_2[11] = 0; /*0xffe19471*/
InitHashContext(HashContext); /*0xffe19479*/
DebugPrintWrapper(64, "FwVolHobCount = %x \n", FwVolHobCount); /*0xffe19486*/
for ( ; FwVolHobCount; --FwVolHobCount ) /*0xffe19490*/
{
DebugPrintWrapper(64, "TpmFwVolHob[i].Size = %x \n", FwVolHobData[2]); /*0xffe1949c*/
DebugPrintWrapper(64, "TpmFwVolHob[i].baseAddress = %lx \n", *FwVolHobData); /*0xffe194ad*/
AllocateAndMeasureFwVol(HashContext, (char *)*FwVolHobData, FwVolHobData[2]); /*0xffe194bb*/
FwVolHobData += 6; /*0xffe194c3*/
}
HashFirmwareVolume((int)DigestedData, (int)HashContext); /*0xffe194d3*/
(*(void ( **)(unsigned int *, char *, int))(*this + 80))(FwVolHobEntry + 2, DigestedData, 20); /*0xffe194e9*/
(*TcgPpi)(TcgPpi, (int)this); /*0xffe194f5*/
MeasureStatus = TpmMeasureDigestIntoPCR(TpmPpi, this, *FwVolHobEntry, (int)(FwVolHobEntry + 2)); /*0xffe19516*/
TcgPpi[1](TcgPpi, (int)this); /*0xffe19518*/
if ( MeasureStatus >= 0 ) /*0xffe19520*/
{
FinalStatus = (*(int ( **)(int, int *, unsigned int *, _BYTE *))(TpmPpi + 4))( /*0xffe19534*/
TpmPpi,
this,
FwVolHobEntry,
MeasuredDigest);
DebugPrintWrapper(64, "MeasureLogDxeFwVol - %r\n", FinalStatus); /*0xffe1953e*/
if ( byte_FFE2177C ) /*0xffe19552*/
PeiPcdSetSku(1, 50563599, ParamArg, (int)&unk_FFE216E8, 0); /*0xffe19561*/
DelayMicroseconds(1, 50563599); /*0xffe1956e*/
return FinalStatus; /*0xffe19573*/
}
else
{
return MeasureStatus; /*0xffe19522*/
}
}
return Status; /*0xffe19575*/
}
int PeiServicesGetBootMode(int p_FirmwareVolumeInfo, _DWORD *p_TpmStatus, char *FirmwareVolumeInfo)
{
unsigned int BootGuardPolicy; // eax
if ( !p_FirmwareVolumeInfo ) /*0xffe19585*/
return -2147483646; /*0xffe19587*/
if ( FirmwareVolumeInfo ) /*0xffe19594*/
BootGuardPolicy = GetBootGuardPolicy(FirmwareVolumeInfo); /*0xffe195a8*/
else
BootGuardPolicy = GetFirmwareVolumeInfo(); /*0xffe19596*/
*(_DWORD *)p_FirmwareVolumeInfo = BootGuardPolicy; /*0xffe1959b*/
if ( !BootGuardPolicy ) /*0xffe1959f*/
return -2147483634; /*0xffe195a1*/
*p_TpmStatus = *(_DWORD *)(*(_DWORD *)p_FirmwareVolumeInfo + 28); /*0xffe195b4*/
return 0; /*0xffe195b8*/
}
int __thiscall TcgPlatformAfterMemInit(int *this)
{
unsigned int FvIndex; // edi
int *PeiServices; // ebx
unsigned int FvIndex_1; // ebp
int TpmStatus_1; // eax
unsigned int FirmwareVolumeInfo; // eax
int FirmwareVolumeInfo_1; // esi
_DWORD *RomAreaPtr; // edi
int FvSize; // ecx
int FvAddress; // eax
int HobStatus; // eax
int HobStatus_1; // esi
_DWORD *GuidDataPtr; // edi
int HobPtr; // edx
unsigned int *FwVolHobEntry; // esi
unsigned int FirstRomAreaValue; // ebx
unsigned int HobValue; // eax
int v17; // [esp-8h] [ebp-148h]
unsigned int v18; // [esp-4h] [ebp-144h]
int HobHandle; // [esp+14h] [ebp-12Ch] BYREF
int TpmStatus; // [esp+18h] [ebp-128h] BYREF
int p_FirmwareVolumeInfo; // [esp+1Ch] [ebp-124h] BYREF
int TcgProtocol; // [esp+20h] [ebp-120h] BYREF
int TpmPpi; // [esp+24h] [ebp-11Ch] BYREF
int TcgPpi; // [esp+28h] [ebp-118h] BYREF
int *PeiServicesCopy; // [esp+2Ch] [ebp-114h]
int HobFvBase; // [esp+3Ch] [ebp-104h]
unsigned int HobFvSize; // [esp+40h] [ebp-100h]
_QWORD RomAreaDescs[28]; // [esp+44h] [ebp-FCh] BYREF
char EventLogBuffer[28]; // [esp+124h] [ebp-1Ch] BYREF
FvIndex = 0; /*0xffe195cb*/
PeiServices = this; /*0xffe195d1*/
TcgPpi = 0; /*0xffe195d3*/
PeiServicesCopy = this; /*0xffe195dc*/
TpmPpi = 0; /*0xffe195e0*/
FvIndex_1 = 0; /*0xffe195e4*/
TcgProtocol = 0; /*0xffe195e6*/
HobHandle = 0; /*0xffe195ea*/
if ( LocateTcgOrTpmPpi((int)this, (int)&TcgPpi, (int)&TpmPpi) >= 0 ) /*0xffe195f6*/
{
FirmwareVolumeInfo = GetFirmwareVolumeInfo(); /*0xffe19611*/
FirmwareVolumeInfo_1 = FirmwareVolumeInfo; /*0xffe19616*/
p_FirmwareVolumeInfo = FirmwareVolumeInfo; /*0xffe19618*/
if ( FirmwareVolumeInfo ) /*0xffe1961e*/
{
RomAreaPtr = RomAreaDescs; /*0xffe19623*/
TpmStatus = *(_DWORD *)(FirmwareVolumeInfo + 28); /*0xffe19627*/
do /*0xffe19693*/
{
if ( (*(_DWORD *)(FirmwareVolumeInfo_1 + 36) & 0x8200) == 0x8200 /*0xffe19647*/
|| (*(_BYTE *)(FirmwareVolumeInfo_1 + 36) & 0xA) != 0 && (*(_DWORD *)(FirmwareVolumeInfo_1 + 36) & 0x400) == 0 )
{
FvAddress = *(_DWORD *)(FirmwareVolumeInfo_1 + 28); /*0xffe1964f*/
FvSize = *(_DWORD *)(FirmwareVolumeInfo_1 + 20); /*0xffe19649*/
v17 = *(_DWORD *)(FirmwareVolumeInfo_1 + 16); /*0xffe19653*/
*(RomAreaPtr - 2) = v17; /*0xffe1965b*/
*(RomAreaPtr - 1) = FvSize; /*0xffe1965e*/
*RomAreaPtr = FvAddress; /*0xffe19661*/
DebugPrintWrapper(64, "RomArea->Address = %x \n", v17); /*0xffe19663*/
DebugPrintWrapper(64, "RomArea->Size = %x \n", *(_DWORD *)(FirmwareVolumeInfo_1 + 28)); /*0xffe19672*/
++FvIndex_1; /*0xffe1967a*/
RomAreaPtr += 6; /*0xffe1967b*/
}
PeiServicesGetBootMode((int)&p_FirmwareVolumeInfo, &TpmStatus, (char *)FirmwareVolumeInfo_1); /*0xffe19687*/
FirmwareVolumeInfo_1 = p_FirmwareVolumeInfo; /*0xffe1968c*/
}
while ( p_FirmwareVolumeInfo ); /*0xffe19693*/
FvIndex = 0; /*0xffe19695*/
}
else
{
HobFvBase = -15663104; /*0xffe1969b*/
HobFvSize = 0; /*0xffe196a3*/
FvIndex_1 = 1; /*0xffe196a7*/
LODWORD(RomAreaDescs[0]) = 11137024; /*0xffe196a8*/
}
HobStatus = (*(int ( **)(int *, int, unsigned int, int *))(*PeiServices + 52))( /*0xffe196c1*/
PeiServices,
4,
24 * (FvIndex_1 + 1),
&HobHandle);
HobStatus_1 = HobStatus; /*0xffe196c4*/
if ( HobStatus >= 0 ) /*0xffe196cb*/
{
DebugPrintWrapper(64, "Hob created \n"); /*0xffe196e6*/
GuidDataPtr = (_DWORD *)(HobHandle + 8); /*0xffe196f6*/
*(_DWORD *)(HobHandle + 8) = unk_FFE216D8; /*0xffe196f9*/
*++GuidDataPtr = unk_FFE216DC; /*0xffe196fa*/
*++GuidDataPtr = unk_FFE216E0; /*0xffe196fb*/
GuidDataPtr[1] = unk_FFE216E4; /*0xffe196fc*/
FvIndex = 0; /*0xffe196fd*/
HobStatus_1 = 0; /*0xffe196ff*/
}
else
{
DebugPrintWrapper(64, "Failed to create TCG/TPM Hob Status = %r \n", HobStatus); /*0xffe196d5*/
}
if ( HobStatus_1 >= 0 ) /*0xffe19703*/
{
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(*PeiServices + 32))( /*0xffe19723*/
PeiServices,
&unk_FFE21638,
0,
0,
&TcgProtocol) >= 0 )
{
TpmStatus_1 = (*(int ( **)(int *, char *))(TcgProtocol + 4))(PeiServices, EventLogBuffer); /*0xffe1973c*/
TpmStatus = TpmStatus_1; /*0xffe1973f*/
if ( TpmStatus_1 >= 0 ) /*0xffe19747*/
{
HobPtr = HobHandle; /*0xffe1974d*/
FwVolHobEntry = (unsigned int *)(HobHandle + 24); /*0xffe19751*/
if ( FvIndex_1 ) /*0xffe19756*/
{
FirstRomAreaValue = RomAreaDescs[0]; /*0xffe1975c*/
do /*0xffe197e1*/
{
if ( FvIndex ) /*0xffe19762*/
{
*FwVolHobEntry = 0; /*0xffe19779*/
FwVolHobEntry[5] = RomAreaDescs[3 *FvIndex]; /*0xffe19780*/
FwVolHobEntry[3] = *(&HobFvBase + 6 *FvIndex); /*0xffe19787*/
HobValue = *(&HobFvSize + 6 *FvIndex); /*0xffe1978a*/
}
else
{
FwVolHobEntry[3] = HobFvBase; /*0xffe19768*/
HobValue = HobFvSize; /*0xffe1976b*/
FwVolHobEntry[5] = FirstRomAreaValue; /*0xffe1976f*/
*FwVolHobEntry = FvIndex_1; /*0xffe19772*/
}
v18 = FwVolHobEntry[5]; /*0xffe1978e*/
FwVolHobEntry[1] = 0; /*0xffe19791*/
FwVolHobEntry[4] = HobValue; /*0xffe1979c*/
DebugPrintWrapper(64, "TpmFwVolHob->Size = %x \n", v18); /*0xffe1979f*/
DebugPrintWrapper(64, "TpmFwVolHob->baseAddress = %x \n", FwVolHobEntry[3]); /*0xffe197b4*/
DebugPrintWrapper(64, "TpmFwVolHob->Tcg2SpecVersion = %x \n", FwVolHobEntry[1]); /*0xffe197c3*/
DebugPrintWrapper(64, "TpmFwVolHob address = %x \n", FwVolHobEntry); /*0xffe197d3*/
FwVolHobEntry += 6; /*0xffe197db*/
++FvIndex; /*0xffe197de*/
}
while ( FvIndex < FvIndex_1 ); /*0xffe197e1*/
HobPtr = HobHandle; /*0xffe197e7*/
PeiServices = PeiServicesCopy; /*0xffe197eb*/
}
MeasureLogDxeFwVol(PeiServices, (int *)(HobPtr + 24), (void ( **)(_DWORD, int))TcgPpi, TpmPpi); /*0xffe197fc*/
return TpmStatus; /*0xffe19801*/
}
}
else
{
return -2147483634; /*0xffe19725*/
}
}
else
{
return HobStatus_1; /*0xffe19705*/
}
}
else
{
DebugPrintWrapper(0x80000000, "\n LocateTcgPpi is failed \n"); /*0xffe19602*/
return -2147483634; /*0xffe19607*/
}
return TpmStatus_1; /*0xffe19807*/
}
int PeiServicesInstallPpi(int a1)
{
int v1; // esi
v1 = a1; /*0xffe19813*/
if ( (*(int ( **)(int, void *, _DWORD, _DWORD, int *))(*(_DWORD *)a1 + 32))(a1, &unk_FFE216C8, 0, 0, &a1) < 0 ) /*0xffe1982e*/
return 0; /*0xffe19839*/
else
return (*(int ( **)(int))a1)(v1); /*0xffe19834*/
}
int PeiServicesRegisterPpiNotify(int ( **n17)(void *))
{
int ( **PeiServicesCopy)(void *); // ebx
int ( *PeiServiceFuncs)(void *); // eax
int Status; // eax
char TpmCapabilityBuffer[36]; // [esp+4h] [ebp-74h] BYREF
_DWORD TpmCapData[9]; // [esp+28h] [ebp-50h] BYREF
__int16 v6; // [esp+4Ch] [ebp-2Ch] BYREF
int TpmCmdData1; // [esp+4Eh] [ebp-2Ah]
int TpmCmdData2; // [esp+52h] [ebp-26h]
char TpmCmdBuffer[6]; // [esp+56h] [ebp-22h] BYREF
_BYTE TpmResponseData[6]; // [esp+5Ch] [ebp-1Ch] BYREF
int TpmResultCode; // [esp+62h] [ebp-16h]
char TpmPcrIndex[4]; // [esp+68h] [ebp-10h] BYREF
char TpmCmdParam[4]; // [esp+6Ch] [ebp-Ch] BYREF
int TcgPpiHandle; // [esp+70h] [ebp-8h] BYREF
int TpmPpiInterface; // [esp+74h] [ebp-4h] BYREF
PeiServicesCopy = n17; /*0xffe19845*/
*(_DWORD *)TpmPcrIndex = 0x2000; /*0xffe1984d*/
PeiServiceFuncs = *n17; /*0xffe19856*/
*(_DWORD *)TpmCmdParam = 2048; /*0xffe1985f*/
TpmPpiInterface = 0; /*0xffe19866*/
TcgPpiHandle = 0; /*0xffe19869*/
if ( (*((int ( **)(int ( **)(void *), void *, _DWORD, _DWORD, int ( ***)(void *)))PeiServiceFuncs /*0xffe19874*/
+ 8))(
n17,
&unk_FFE21618,
0,
0,
&n17) >= 0 )
return (*n17)(PeiServicesCopy); /*0xffe1987d*/
if ( IsTpmPresent() ) /*0xffe19882*/
return 0; /*0xffe19889*/
TpmCmdData1 = 201326592; /*0xffe19894*/
v6 = -16128; /*0xffe1989b*/
TpmCmdData2 = 167772224; /*0xffe1989f*/
if ( !IsTpmPresent() ) /*0xffe198a6*/
TpmSelfTest(PeiServicesCopy); /*0xffe198b1*/
if ( LocateTcgOrTpmPpi((int)PeiServicesCopy, (int)&TpmPpiInterface, (int)&TcgPpiHandle) < 0 ) /*0xffe198c7*/
return -2147483634; /*0xffe198ce*/
qmemcpy(TpmCapData, TpmTcgGetCapability(TpmCapabilityBuffer), sizeof(TpmCapData)); /*0xffe198e9*/
if ( BYTE2(TpmCapData[5]) == 1 ) /*0xffe198fa*/
{
Status = (*(int ( **)(int, int ( **)(void *)))TpmPpiInterface)(TpmPpiInterface, PeiServicesCopy); /*0xffe198fc*/
if ( Status >= 0 ) /*0xffe19902*/
{
CopyMem(TpmCmdBuffer, TpmCmdParam, 2u); /*0xffe19910*/
(*(void ( **)(int, int ( **)(void *), int, __int16 *, int, _BYTE *))(TcgPpiHandle + 8))( /*0xffe19926*/
TcgPpiHandle,
PeiServicesCopy,
12,
&v6,
10,
TpmResponseData);
Status = (*(int ( **)(int, int ( **)(void *)))(TpmPpiInterface + 4))( /*0xffe1992e*/
TpmPpiInterface,
PeiServicesCopy);
if ( Status >= 0 ) /*0xffe19936*/
return 0; /*0xffe199d2*/
}
}
else
{
Status = (*(int ( **)(int, int ( **)(void *)))TpmPpiInterface)(TpmPpiInterface, PeiServicesCopy); /*0xffe19941*/
if ( Status >= 0 ) /*0xffe19947*/
{
CopyMem(TpmCmdBuffer, TpmPcrIndex, 2u); /*0xffe19955*/
(*(void ( **)(int, int ( **)(void *), int, __int16 *, int, _BYTE *))(TcgPpiHandle + 8))( /*0xffe1996b*/
TcgPpiHandle,
PeiServicesCopy,
12,
&v6,
10,
TpmResponseData);
CopyMem(TpmCmdBuffer, TpmCmdParam, 2u); /*0xffe19976*/
(*(void ( **)(int, int ( **)(void *), int, __int16 *, int, _BYTE *))(TcgPpiHandle + 8))( /*0xffe1998c*/
TcgPpiHandle,
PeiServicesCopy,
12,
&v6,
10,
TpmResponseData);
Status = (*(int ( **)(int, int ( **)(void *)))(TpmPpiInterface + 4))( /*0xffe19994*/
TpmPpiInterface,
PeiServicesCopy);
if ( Status >= 0 ) /*0xffe1999c*/
{
if ( TpmResultCode ) /*0xffe199a2*/
{
DelayMicroseconds(-2147483646, 50563590); /*0xffe199ae*/
return -2147483641; /*0xffe199b8*/
}
if ( *(_WORD *)TpmCmdParam == 1024 ) /*0xffe199c3*/
DelayMicroseconds(1, 50563590); /*0xffe199cd*/
return 0; /*0xffe199cd*/
}
}
}
return Status; /*0xffe199d4*/
}
int TcgPlatformPeiEntry(int *n17)
{
int *n17_1; // ebx
int v2; // eax
int result; // eax
int v4; // eax
int v5; // eax
_DWORD *v6; // edi
int v7; // eax
_DWORD *v8; // edi
_DWORD *v9; // esi
int v10; // eax
int v11; // esi
int v12; // eax
int v13; // [esp+10h] [ebp-14h] BYREF
int v14; // [esp+14h] [ebp-10h] BYREF
int ( **v15)(int *); // [esp+18h] [ebp-Ch] BYREF
int v16; // [esp+1Ch] [ebp-8h] BYREF
int v17; // [esp+20h] [ebp-4h] BYREF
n17_1 = n17; /*0xffe199dd*/
v2 = *n17; /*0xffe199e8*/
v17 = 0; /*0xffe199f5*/
v16 = 0; /*0xffe199f9*/
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, int ( ***)(int *)))(v2 + 32))( /*0xffe19a05*/
n17,
&unk_FFE21688,
0,
0,
&v15) >= 0 )
return (*v15)(n17_1); /*0xffe19a0c*/
v4 = (*(int ( **)(int *, int **))(*n17_1 + 40))(n17_1, &n17); /*0xffe19a1c*/
if ( v4 < 0 ) /*0xffe19a23*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0xffe19a30*/
v5 = AssertReport(); /*0xffe19a38*/
if ( v5 ) /*0xffe19a3f*/
(*(void ( **)(const char *, int, const char *))(v5 + 4))( /*0xffe19a50*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTcgPlatformPeiAfterMem.c",
1452,
"!EFI_ERROR (Status)");
}
result = TpmStartup(n17_1, (int)n17); /*0xffe19a5c*/
if ( result >= 0 )
{
if ( n17 == (int *)17 || n17 == (int *)32 )
{
return 0; /*0xffe19ba0*/
}
else
{
result = (*(int ( **)(int *, int, int, int *))(*n17_1 + 52))(n17_1, 4, 28, &v13); /*0xffe19a8b*/
if ( result >= 0 )
{
v6 = (_DWORD *)(v13 + 8); /*0xffe19aa4*/
*(_DWORD *)(v13 + 8) = unk_FFE21608; /*0xffe19aa7*/
*++v6 = unk_FFE2160C; /*0xffe19aa8*/
*++v6 = unk_FFE21610; /*0xffe19aa9*/
v6[1] = unk_FFE21614; /*0xffe19aaa*/
v7 = *n17_1; /*0xffe19abb*/
v13 += 24; /*0xffe19ac4*/
(*(void ( **)(int, int **, int))(v7 + 80))(v13, &n17, 4); /*0xffe19ac8*/
result = (*(int ( **)(int *, int, int, int *))(*n17_1 + 52))(n17_1, 4, 320, &v14); /*0xffe19ada*/
if ( result >= 0 )
{
v8 = (_DWORD *)(v14 + 8); /*0xffe19af3*/
*(_DWORD *)(v14 + 8) = unk_FFE216B8; /*0xffe19af6*/
*++v8 = unk_FFE216BC; /*0xffe19af7*/
*++v8 = unk_FFE216C0; /*0xffe19af8*/
v8[1] = unk_FFE216C4; /*0xffe19af9*/
v9 = (_DWORD *)(v14 + 24); /*0xffe19b08*/
(*(void ( **)(int, int, _DWORD))(*n17_1 + 84))(v14 + 24, 40, 0); /*0xffe19b0f*/
*v9 = 256; /*0xffe19b16*/
if ( LocateTcgOrTpmPpi((int)n17_1, (int)&v17, (int)&v16) >= 0 )
{
if ( !IsTpmPresent() )
{
v10 = BootGuardTcg2MeasureCRTMVersion(n17_1); /*0xffe19b40*/
v11 = v10; /*0xffe19b45*/
if ( v10 < 0 )
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v10); /*0xffe19b58*/
v12 = AssertReport(); /*0xffe19b60*/
if ( v12 ) /*0xffe19b67*/
(*(void ( **)(const char *, int, const char *))(v12 + 4))( /*0xffe19b78*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTcgPlatformPeiAfterMem.c",
1504,
"!EFI_ERROR (Status)");
DebugPrintWrapper(0x80000000, "Error: Failure %d %a Status = %r\n", 1507, "MemoryPresentEntry", v11);
}
}
return TcgPlatformAfterMemInit(n17_1); /*0xffe19b99*/
}
else
{
return -2147483634; /*0xffe19b2f*/
}
}
}
}
}
return result; /*0xffe19ba2*/
}
char *CopyMem(char *dst, char *src, unsigned int count)
{
int v5; // eax
int v6; // eax
if ( count - 1 > -1 - (int)dst ) /*0xffe19bc0*/
{
v5 = AssertReport(); /*0xffe19bc2*/
if ( v5 ) /*0xffe19bc9*/
(*(void ( **)(const char *, int, const char *))(v5 + 4))( /*0xffe19bd7*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if ( count - 1 > -1 - (int)src ) /*0xffe19be1*/
{
v6 = AssertReport(); /*0xffe19be3*/
if ( v6 ) /*0xffe19bea*/
(*(void ( **)(const char *, int, const char *))(v6 + 4))( /*0xffe19bf8*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if ( dst == src ) /*0xffe19c00*/
return dst; /*0xffe19c02*/
else
return SetMem(dst, src, count); /*0xffe19c0c*/
}
int AssertReport()
{
int Next; // eax
_BYTE v2[4]; // [esp+0h] [ebp-8h] BYREF
int v3; // [esp+4h] [ebp-4h] BYREF
Next = HobGetNext(); /*0xffe19c1e*/
if ( (*(int ( **)(int, void *, _DWORD, _BYTE *, int *))(*(_DWORD *)Next + 32))(Next, &unk_FFE21648, 0, v2, &v3) >= 0 ) /*0xffe19c3d*/
return v3; /*0xffe19c43*/
else
return 0; /*0xffe19c3f*/
}
int DebugPrintWrapper(int a1, const char *a2, ...)
{
int result; // eax
int ( **v3)(int, const char *, char *); // esi
va_list va; // [esp+10h] [ebp+Ch] BYREF
va_start(va, a2);
result = AssertReport(); /*0xffe19c4b*/
v3 = (int ( **)(int, const char *, char *))result; /*0xffe19c50*/
if ( result ) /*0xffe19c54*/
{
result = HobGetBaseAddress(); /*0xffe19c56*/
if ( (result & a1) != 0 ) /*0xffe19c61*/
return (*v3)(a1, a2, (char *)va); /*0xffe19c6d*/
}
return result; /*0xffe19c72*/
}
int DebugVPrint(
int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
int n48,
const char *Idtr____((void__)_0))
{
int result; // eax
result = AssertReport(); /*0xffe19c7a*/
if ( result ) /*0xffe19c81*/
return (*(int ( **)(int, int, const char *))(result + 4))( /*0xffe19c89*/
e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
n48,
Idtr____((void__)_0));
return result; /*0xffe19c8f*/
}
int DebugAssertPrint(int a1, char **p_src, int a3, int DigestedData)
{
int v6; // edi
char HashContext[92]; // [esp+8h] [ebp-5Ch] BYREF
InitHashContext(HashContext); /*0xffe19ca1*/
if ( a1 ) /*0xffe19ca8*/
{
v6 = a3 - (_DWORD)p_src; /*0xffe19cae*/
do /*0xffe19cc4*/
{
AllocateAndMeasureFwVol(HashContext, *p_src, *(unsigned int *)((char *)p_src + v6)); /*0xffe19cb8*/
++p_src; /*0xffe19cbd*/
--a1; /*0xffe19cc1*/
}
while ( a1 ); /*0xffe19cc4*/
}
return HashFirmwareVolume(DigestedData, (int)HashContext); /*0xffe19cd2*/
}
char *AllocateAndMeasureFwVol(char *HashContext, char *src, unsigned int n8)
{
int v4; // ebx
unsigned int v5; // ecx
char *result; // eax
int n8_1; // esi
unsigned int i; // ebx
char *src_1; // [esp+10h] [ebp-4h]
src_1 = src; /*0xffe1af48*/
v4 = (*((_DWORD *)HashContext + 5) >> 3) & 0x3F; /*0xffe1af54*/
v5 = *((_DWORD *)HashContext + 5) + 8 *n8; /*0xffe1af57*/
*((_DWORD *)HashContext + 5) = v5; /*0xffe1af5f*/
if ( v5 < 8 *n8 ) /*0xffe1af64*/
++*((_DWORD *)HashContext + 6); /*0xffe1af66*/
*((_DWORD *)HashContext + 6) += n8 >> 29; /*0xffe1af6e*/
result = (char *)(v4 + n8); /*0xffe1af71*/
if ( v4 + n8 <= 0x3F ) /*0xffe1af77*/
{
n8_1 = 0; /*0xffe1afb9*/
}
else
{
n8_1 = 64 - v4; /*0xffe1af7c*/
CopyMem(&HashContext[v4 + 28], src, 64 - v4); /*0xffe1af86*/
result = (char *)TpmMeasureFwVolWithType(HashContext, HashContext + 28); /*0xffe1af91*/
for ( i = n8_1 + 63; ; i += 64 ) /*0xffe1af96*/
{
src = src_1; /*0xffe1afad*/
if ( i >= n8 ) /*0xffe1afb3*/
break; /*0xffe1afb3*/
result = (char *)TpmMeasureFwVolWithType(HashContext, &src_1[i - 63]); /*0xffe1afa2*/
n8_1 += 64; /*0xffe1afa7*/
}
v4 = 0; /*0xffe1afb5*/
}
if ( n8 != n8_1 ) /*0xffe1afbb*/
return CopyMem(&HashContext[v4 + 28], &src[n8_1], n8 - n8_1); /*0xffe1afc7*/
return result; /*0xffe1afcd*/
}
void *HashFirmwareVolume(int DigestedData, int HashContext)
{
unsigned int n0x14; // edi
unsigned int i; // edx
char src[8]; // [esp+10h] [ebp-8h] BYREF
n0x14 = 0; /*0xffe1afd9*/
for ( i = 0; i < 8; ++i )
src[i] = *(_DWORD *)((i < 4 ? 4 : 0) + HashContext + 20) >> (8 * (3 - (i & 3)));
AllocateAndMeasureFwVol((char *)HashContext, ::src, 1u); /*0xffe1b00f*/
while ( (*(_DWORD *)(HashContext + 20) & 0x1F8) != 0x1C0 ) /*0xffe1b034*/
AllocateAndMeasureFwVol((char *)HashContext, src_0, 1u); /*0xffe1b020*/
AllocateAndMeasureFwVol((char *)HashContext, src, 8u); /*0xffe1b03c*/
do /*0xffe1b060*/
{
*(_BYTE *)(n0x14 + DigestedData) = *(_DWORD *)(HashContext + 4 * (n0x14 >> 2)) >> (8 * (3 - (n0x14 & 3))); /*0xffe1b059*/
++n0x14; /*0xffe1b05c*/
}
while ( n0x14 < 0x14 ); /*0xffe1b060*/
GetEndOfHobList((void *)(HashContext + 28), 0x40u); /*0xffe1b068*/
GetEndOfHobList((void *)HashContext, 0x14u); /*0xffe1b072*/
GetEndOfHobList((void *)(HashContext + 20), 8u); /*0xffe1b07c*/
return GetEndOfHobList(src, 8u); /*0xffe1b08d*/
}
int DelayMicroseconds(int n2, int n50563599)
{
if ( byte_FFE2177C ) /*0xffe1b09b*/
return PeiPcdSetSku(n2, n50563599, n2, (int)&unk_FFE216E8, 0); /*0xffe1b0a5*/
else
return -2147483645; /*0xffe1b0ae*/
}
char IsTpmPresent()
{
unsigned int n6; // ecx
n6 = 0; /*0xffe1b0bb*/
while ( word_FFE21730[n6] != MEMORY[0xFED40F00] || word_FFE21732[n6] != MEMORY[0xFED40F02] ) /*0xffe1b0d6*/
{
n6 += 2; /*0xffe1b0d8*/
if ( n6 >= 6 ) /*0xffe1b0de*/
return 0; /*0xffe1b0e3*/
}
return 1; /*0xffe1b0e2*/
}
int LocateTcgOrTpmPpi(int n17, int p_TcgPpi, int p_TpmPpi)
{
int v4; // eax
int v5; // esi
int result; // eax
v4 = (*(int ( **)(int, void *, _DWORD, _DWORD, int))(*(_DWORD *)n17 + 32))(n17, &unk_FFE21678, 0, 0, p_TcgPpi); /*0xffe1b0fa*/
v5 = v4; /*0xffe1b0fd*/
if ( v4 >= 0 ) /*0xffe1b104*/
{
result = (*(int ( **)(int, void *, _DWORD, _DWORD, int))(*(_DWORD *)n17 + 32))( /*0xffe1b11c*/
n17,
&unk_FFE21628,
0,
0,
p_TpmPpi);
v5 = result; /*0xffe1b11f*/
if ( result >= 0 ) /*0xffe1b126*/
return result; /*0xffe1b126*/
DebugPrintWrapper(0x80000000, "gTcgPpiguid NOT found %r \n", result); /*0xffe1b133*/
}
else
{
DebugPrintWrapper(0x80000000, "gTpmDevicePpiguid NOT found %r \n", v4); /*0xffe1b10c*/
}
return v5; /*0xffe1b13d*/
}
int TpmStartupCommand(int *n17, int n32)
{
int PeiServiceFuncs; // eax
int Status; // eax
__int16 n3; // bx
int v7; // [esp-18h] [ebp-64h]
_BYTE TpmResponseBuf[28]; // [esp+Ch] [ebp-40h] BYREF
__int16 TpmCmdTag; // [esp+28h] [ebp-24h] BYREF
int TpmCmdOrdinal; // [esp+2Ah] [ebp-22h]
int TpmCmdParamData; // [esp+2Eh] [ebp-1Eh]
__int16 TpmStartupType; // [esp+32h] [ebp-1Ah]
unsigned __int16 TpmResponseTag; // [esp+34h] [ebp-18h] BYREF
unsigned int TpmResponseSize; // [esp+36h] [ebp-16h]
unsigned int TpmResponseCode; // [esp+3Ah] [ebp-12h]
int TpmEventResult; // [esp+40h] [ebp-Ch] BYREF
int TcgPpiHandle; // [esp+44h] [ebp-8h] BYREF
int TpmPpiHandle; // [esp+48h] [ebp-4h] BYREF
PeiServiceFuncs = *n17; /*0xffe1b155*/
TpmPpiHandle = 0; /*0xffe1b15e*/
TpmEventResult = 0; /*0xffe1b161*/
TcgPpiHandle = 0; /*0xffe1b164*/
Status = (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(PeiServiceFuncs + 32))( /*0xffe1b167*/
n17,
&unk_FFE21638,
0,
0,
&TcgPpiHandle);
if ( Status >= 0 )
{
if ( TcgPpiHandle )
{
Status = (*(int ( **)(int *, _BYTE *))(TcgPpiHandle + 4))(n17, TpmResponseBuf); /*0xffe1b185*/
if ( Status >= 0 )
{
if ( TpmResponseBuf[4] == 1 ) /*0xffe1b196*/
n32 = 32; /*0xffe1b19a*/
n3 = (n32 == 17) + 1; /*0xffe1b1a4*/
if ( n32 == 32 ) /*0xffe1b1aa*/
n3 = 3; /*0xffe1b1ae*/
if ( LocateTcgOrTpmPpi((int)n17, (int)&TpmPpiHandle, (int)&TpmEventResult) < 0 ) /*0xffe1b1c0*/
return -2147483634; /*0xffe1b1c7*/
Status = (*(int ( **)(int, int *))TpmPpiHandle)(TpmPpiHandle, n17); /*0xffe1b1d1*/
if ( Status >= 0 )
{
TpmCmdTag = -16128; /*0xffe1b1e6*/
TpmCmdOrdinal = 201326592; /*0xffe1b1f3*/
TpmCmdParamData = -1728053248; /*0xffe1b202*/
TpmStartupType = __ROL2__(n3, 8); /*0xffe1b209*/
(*(void ( **)(int, int *, int, __int16 *, int, unsigned __int16 *))(TpmEventResult + 8))( /*0xffe1b20d*/
TpmEventResult,
n17,
12,
&TpmCmdTag,
10,
&TpmResponseTag);
DebugPrintWrapper(
64,
"Tcg Startup Command Return Code: size: %x; retCode:%x; tag:%x; bytes %08x\n",
((TpmResponseSize & 0xFF00 | (TpmResponseSize << 16)) << 8)
| ((HIWORD(TpmResponseSize) | TpmResponseSize & 0xFF0000) >> 8),
((TpmResponseCode & 0xFF00 | (TpmResponseCode << 16)) << 8)
| ((HIWORD(TpmResponseCode) | TpmResponseCode & 0xFF0000) >> 8),
(TpmResponseTag << 8) | HIBYTE(TpmResponseTag),
v7);
if ( !TpmResponseSize )
{
DebugPrintWrapper(0x80000000, "Tcg Startup: returning device error\n");
return -2147483641; /*0xffe1b292*/
}
if ( TpmResponseCode ) /*0xffe1b298*/
{
DebugPrintWrapper(0x80000000, "Error sending TPM Startup CMD\n"); /*0xffe1b29f*/
return -2147483641; /*0xffe1b29f*/
}
return (*(int ( **)(int, int *))(TpmPpiHandle + 4))(TpmPpiHandle, n17); /*0xffe1b2a6*/
}
}
}
}
return Status; /*0xffe1b2ab*/
}
unsigned int TcmStartup(int n17, int n17_1)
{
__int16 n3; // si
int v4; // edi
int v5; // [esp-1Ch] [ebp-40h]
int v6; // [esp+8h] [ebp-1Ch] BYREF
unsigned __int16 v7; // [esp+Ch] [ebp-18h] BYREF
unsigned int v8; // [esp+Eh] [ebp-16h]
unsigned int v9; // [esp+12h] [ebp-12h]
__int16 v10; // [esp+18h] [ebp-Ch] BYREF
int n201326592; // [esp+1Ah] [ebp-Ah]
int v12; // [esp+1Eh] [ebp-6h]
__int16 v13; // [esp+22h] [ebp-2h]
v6 = 0; /*0xffe1b2be*/
n3 = (n17_1 == 17) + 1; /*0xffe1b2c6*/
if ( n17_1 == 32 ) /*0xffe1b2cc*/
n3 = 3; /*0xffe1b2d0*/
if ( (*(int ( **)(int, void *, _DWORD, _DWORD, int *))(*(_DWORD *)n17 + 32))(n17, &unk_FFE21698, 0, 0, &v6) < 0 ) /*0xffe1b2e8*/
return -2147483634; /*0xffe1b2ea*/
v10 = -16128; /*0xffe1b2ff*/
n201326592 = 201326592; /*0xffe1b311*/
v12 = -1719664640; /*0xffe1b323*/
v13 = __ROL2__(n3, 8); /*0xffe1b32b*/
v4 = (*(int ( **)(int, __int16 *, int, unsigned __int16 *, int))(v6 + 24))(-19660800, &v10, 12, &v7, 10); /*0xffe1b338*/
DebugPrintWrapper(
64,
"Tcg TCM Startup Command Return Code: size: %x; retCode:%x; tag:%x; bytes %08x\n",
((v8 & 0xFF00 | (v8 << 16)) << 8) | ((HIWORD(v8) | v8 & 0xFF0000) >> 8),
((v9 & 0xFF00 | (v9 << 16)) << 8) | ((HIWORD(v9) | v9 & 0xFF0000) >> 8),
(v7 << 8) | HIBYTE(v7),
v5);
if ( v8 ) /*0xffe1b3a5*/
return v4 | ((v9 & 0xFF00 | (v9 << 16)) << 8) | ((v9 & 0xFF0000 | HIWORD(v9)) >> 8); /*0xffe1b3ce*/
else
return -2147483641; /*0xffe1b3a7*/
}
signed int __thiscall TpmSelfTest(void *this)
{
signed int result; // eax
int v3; // eax
_BYTE v4[6]; // [esp+4h] [ebp-20h] BYREF
unsigned int v5; // [esp+Ah] [ebp-1Ah]
__int16 v6; // [esp+10h] [ebp-14h] BYREF
int n167772160; // [esp+12h] [ebp-12h]
int n1392508928; // [esp+16h] [ebp-Eh]
int v9; // [esp+1Ch] [ebp-8h] BYREF
int ( **v10)(_DWORD, void *); // [esp+20h] [ebp-4h] BYREF
v10 = 0; /*0xffe1b3de*/
v9 = 0; /*0xffe1b3e5*/
if ( LocateTcgOrTpmPpi((int)this, (int)&v10, (int)&v9) < 0 ) /*0xffe1b3f8*/
return -2147483634; /*0xffe1b3fa*/
result = (*v10)(v10, this); /*0xffe1b409*/
if ( result >= 0 )
{
n167772160 = 167772160; /*0xffe1b417*/
v6 = -16128; /*0xffe1b41e*/
n1392508928 = 1392508928; /*0xffe1b42b*/
v3 = (*(int ( **)(int, void *, int, __int16 *, int, _BYTE *))(v9 + 8))(v9, this, 10, &v6, 10, v4); /*0xffe1b43a*/
DebugPrintWrapper(
64,
"TCG Pei: Self Test : status=%x; RetCode=%x\n",
v3,
(((v5 << 16) | v5 & 0xFF00) << 8) | ((HIWORD(v5) | v5 & 0xFF0000) >> 8));
result = v10[1](v10, this); /*0xffe1b477*/
if ( result >= 0 )
return v5 != 0 ? 0x80000007 : 0;
}
return result; /*0xffe1b48e*/
}
unsigned int __thiscall TcmSelfTest(int *this)
{
int v1; // eax
int v3; // eax
_BYTE v4[6]; // [esp+4h] [ebp-1Ch] BYREF
unsigned int v5; // [esp+Ah] [ebp-16h]
__int16 v6; // [esp+10h] [ebp-10h] BYREF
int n167772160; // [esp+12h] [ebp-Eh]
int n1400897536; // [esp+16h] [ebp-Ah]
int v9; // [esp+1Ch] [ebp-4h] BYREF
v1 = *this; /*0xffe1b499*/
v9 = 0; /*0xffe1b4aa*/
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(v1 + 32))(this, &unk_FFE21698, 0, 0, &v9) < 0 ) /*0xffe1b4b5*/
return -2147483634; /*0xffe1b4b7*/
n167772160 = 167772160; /*0xffe1b4c3*/
v6 = -16128; /*0xffe1b4ca*/
n1400897536 = 1400897536; /*0xffe1b4d9*/
v3 = (*(int ( **)(int, __int16 *, int, _BYTE *, int))(v9 + 24))(-19660800, &v6, 10, v4, 10); /*0xffe1b4e9*/
DebugPrintWrapper(
64,
"TCG TCM Pei: Self Test : status=%x; RetCode=%x\n",
v3,
(((v5 << 16) | v5 & 0xFF00) << 8) | ((HIWORD(v5) | v5 & 0xFF0000) >> 8));
return v5 != 0 ? 0x80000007 : 0;
}
signed int TpmStartup(int *n17, int n17_1)
{
int v4; // eax
char v5; // bl
signed int result; // eax
unsigned int v7; // esi
_BYTE v8[28]; // [esp+Ch] [ebp-24h] BYREF
_BYTE v9[4]; // [esp+28h] [ebp-8h] BYREF
int v10; // [esp+2Ch] [ebp-4h] BYREF
v4 = *n17; /*0xffe1b549*/
v5 = 0; /*0xffe1b54b*/
v10 = 0; /*0xffe1b554*/
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, _BYTE *))(v4 + 32))(n17, &unk_FFE216F8, 0, 0, v9) >= 0 ) /*0xffe1b55f*/
{
v5 = 1; /*0xffe1b569*/
DelayMicroseconds(1, 50563587); /*0xffe1b56b*/
}
result = (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(*n17 + 32))(n17, &unk_FFE21638, 0, 0, &v10); /*0xffe1b580*/
if ( result >= 0 )
{
if ( v10 )
{
result = (*(int ( **)(int *, _BYTE *))(v10 + 4))(n17, v8); /*0xffe1b59e*/
if ( result >= 0 )
{
if ( v8[4] == 1 )
{
if ( v5 )
return TpmSelfTest(n17) != 0 ? 0x80000007 : 0;
else
return TpmStartupCommand(n17, 32); /*0xffe1b5ba*/
}
if ( IsTpmPresent() ) /*0xffe1b5d4*/
{
if ( TcmStartup((int)n17, n17_1) ) /*0xffe1b62c*/
return -2147483641; /*0xffe1b62c*/
v7 = TcmSelfTest(n17); /*0xffe1b63c*/
if ( v7 ) /*0xffe1b640*/
return -2147483641; /*0xffe1b640*/
}
else
{
if ( !v5 ) /*0xffe1b5df*/
{
if ( TpmStartupCommand(n17, n17_1) ) /*0xffe1b5e5*/
{
DelayMicroseconds(-2147483646, 50563585); /*0xffe1b5f8*/
return -2147483641; /*0xffe1b602*/
}
DelayMicroseconds(1, 50563585); /*0xffe1b607*/
}
v7 = TpmSelfTest(n17); /*0xffe1b613*/
if ( v7 ) /*0xffe1b617*/
return -2147483641; /*0xffe1b617*/
DelayMicroseconds(1, 50563588); /*0xffe1b621*/
}
return v7; /*0xffe1b642*/
}
}
}
return result; /*0xffe1b644*/
}
void *TpmTcgGetCapability(void *dst)
{
_DWORD *v1; // ecx
_DWORD *v2; // ebp
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v10; // [esp+10h] [ebp-120h] BYREF
int v11; // [esp+14h] [ebp-11Ch] BYREF
__int16 v12; // [esp+18h] [ebp-118h] BYREF
int n369098752; // [esp+1Ah] [ebp-116h]
int n1694498816; // [esp+1Eh] [ebp-112h]
int n0x4000000; // [esp+22h] [ebp-10Eh]
int n0x4000000_1; // [esp+26h] [ebp-10Ah]
int n134283264; // [esp+2Ah] [ebp-106h]
_DWORD dst_1[64]; // [esp+30h] [ebp-100h] BYREF
v2 = v1; /*0xffe1b655*/
n369098752 = 369098752; /*0xffe1b657*/
n1694498816 = 1694498816; /*0xffe1b661*/
v10 = 0; /*0xffe1b66d*/
v11 = 0; /*0xffe1b677*/
v12 = -16128; /*0xffe1b67b*/
n0x4000000 = 0x4000000; /*0xffe1b686*/
n0x4000000_1 = 0x4000000; /*0xffe1b68a*/
v3 = *v1; /*0xffe1b68e*/
n134283264 = 134283264; /*0xffe1b698*/
v4 = (*(int ( **)(_DWORD *, void *, _DWORD, _DWORD, int *))(v3 + 32))(v1, &unk_FFE21678, 0, 0, &v10); /*0xffe1b6a0*/
if ( v4 < 0 ) /*0xffe1b6b2*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0xffe1b6bf*/
v5 = AssertReport(); /*0xffe1b6c7*/
if ( v5 ) /*0xffe1b6ce*/
(*(void ( **)(const char *, int, const char *))(v5 + 4))( /*0xffe1b6d7*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTcgPlatformPeiLib.c",
1073,
"!EFI_ERROR (Status)");
}
if ( (*(int ( **)(int, _DWORD *))v10)(v10, v2) )
{
GetEndOfHobList((int)dst_1, 36); /*0xffe1b6f2*/
}
else
{
v6 = (*(int ( **)(_DWORD *, void *, _DWORD, _DWORD, int *))(*v2 + 32))(v2, &unk_FFE21628, 0, 0, &v11); /*0xffe1b70c*/
if ( v6 < 0 ) /*0xffe1b714*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0xffe1b721*/
v7 = AssertReport(); /*0xffe1b729*/
if ( v7 ) /*0xffe1b730*/
(*(void ( **)(const char *, int, const char *))(v7 + 4))( /*0xffe1b739*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTcgPlatformPeiLib.c",
1090,
"!EFI_ERROR (Status)");
}
v8 = (*(int ( **)(int, _DWORD *, int, __int16 *, int, _DWORD *))(v11 + 8))(v11, v2, 22, &v12, 256, dst_1); /*0xffe1b756*/
DebugPrintWrapper(
64,
"GetCapability: %r; size: %x; retCode:%x; tag:%x; bytes %08x\n",
v8,
((HIWORD(dst_1[0]) & 0xFF00 | (*(_DWORD *)((char *)dst_1 + 2) << 16)) << 8)
| ((HIWORD(*(_DWORD *)((char *)dst_1 + 2)) | *(_DWORD *)((char *)dst_1 + 2) & 0xFF0000u) >> 8),
((HIWORD(dst_1[1]) & 0xFF00 | (*(_DWORD *)((char *)&dst_1[1] + 2) << 16)) << 8)
| ((HIWORD(*(_DWORD *)((char *)&dst_1[1] + 2)) | *(_DWORD *)((char *)&dst_1[1] + 2) & 0xFF0000u) >> 8),
(HIWORD(dst_1[3]) << 8) | HIBYTE(HIWORD(dst_1[3])),
((dst_1[4] & 0xFF00 | (dst_1[4] << 16)) << 8) | ((HIWORD(dst_1[4]) | dst_1[4] & 0xFF0000u) >> 8));
(*(void ( **)(int, _DWORD *))(v10 + 4))(v10, v2); /*0xffe1b7f3*/
}
qmemcpy(dst, dst_1, 0x24u); /*0xffe1b809*/
return dst; /*0xffe1b80b*/
}
_DWORD *GetBootGuardHobData()
{
int Next; // eax
int v1; // esi
int v2; // eax
int v3; // ecx
_DWORD *v4; // esi
_DWORD *v5; // eax
unsigned int src_1; // ecx
unsigned int count; // ebx
char *v8; // edi
int v9; // ebp
char *src; // [esp+8h] [ebp-Ch]
int v12; // [esp+Ch] [ebp-8h] BYREF
int v13; // [esp+10h] [ebp-4h] BYREF
v12 = 0; /*0xffe1b81d*/
v13 = 0; /*0xffe1b821*/
Next = HobGetNext(); /*0xffe1b825*/
if ( (*(int ( **)(int, _DWORD, int *))(*(_DWORD *)Next + 56))(Next, 0, &v12) < 0 ) /*0xffe1b83b*/
return 0; /*0xffe1b83b*/
v1 = v12; /*0xffe1b841*/
v2 = HobGetNext(); /*0xffe1b845*/
if ( (*(int ( **)(void *, int, int *))(*(_DWORD *)v2 + 104))(&unk_FFE21658, v1, &v13) < 0 ) /*0xffe1b85f*/
return 0; /*0xffe1b85f*/
v4 = (_DWORD *)(v13 + 44); /*0xffe1b869*/
if ( *(_DWORD *)(v13 + 44) != 1280134994 ) /*0xffe1b872*/
return 0; /*0xffe1b908*/
v5 = (_DWORD *)BuildGuidHob(v3, 48 * *(_DWORD *)(v13 + 56) + 16); /*0xffe1b882*/
if ( v5 ) /*0xffe1b88b*/
{
*v5 = v4[1]; /*0xffe1b890*/
v5[1] = v4[2]; /*0xffe1b895*/
src_1 = (unsigned int)(v4 + 4); /*0xffe1b898*/
v5[2] = 48; /*0xffe1b89b*/
v5[3] = 0; /*0xffe1b8a2*/
count = v4[2]; /*0xffe1b8a8*/
src = (char *)(v4 + 4); /*0xffe1b8af*/
v8 = (char *)(v5 + 4); /*0xffe1b8b3*/
if ( v4 + 4 < (_DWORD *)((char *)v4 + count *v4[3] + 16) ) /*0xffe1b8bc*/
{
v9 = 16 - (_DWORD)v5; /*0xffe1b8be*/
do /*0xffe1b900*/
{
if ( count ) /*0xffe1b8c2*/
{
CopyMem(v8 + 8, src, count); /*0xffe1b8cc*/
src_1 = (unsigned int)src; /*0xffe1b8d2*/
}
*((_DWORD *)v8 + 1) = 0; /*0xffe1b8d6*/
*(_DWORD *)v8 = &v8[v9 + 8]; /*0xffe1b8df*/
v8 += 48; /*0xffe1b8e1*/
count = v4[2]; /*0xffe1b8e4*/
src = (char *)(count + src_1); /*0xffe1b8e9*/
src_1 += count; /*0xffe1b8fc*/
}
while ( src_1 < (unsigned int)v4 + count *v4[3] + 16 ); /*0xffe1b900*/
}
}
return v4; /*0xffe1b90a*/
}
unsigned int GetFirmwareVolumeInfo()
{
_WORD *SystemConfiguration; // ecx
SystemConfiguration = GetSystemConfiguration(); /*0xffe1b916*/
if ( !SystemConfiguration ) /*0xffe1b91a*/
{
GetBootGuardHobData(); /*0xffe1b91c*/
SystemConfiguration = GetSystemConfiguration(); /*0xffe1b926*/
}
return SystemConfiguration != 0 ? (unsigned int)(SystemConfiguration + 24) : 0;
}
unsigned int __thiscall GetBootGuardPolicy(char *this)
{
char *v1; // esi
char *v2; // edi
unsigned int v3; // esi
if ( this /*0xffe1b967*/
&& (v1 = this - 8, v2 = &v1[-*(_DWORD *)v1], HobIsSuitable((int)(v2 + 8), (int)&unk_FFE21668))
&& (v3 = (unsigned int)&v1[*((_DWORD *)v2 + 8)], (unsigned int)(v2 + 40) <= v3)
&& (unsigned int)&v2[*((unsigned __int16 *)v2 + 1)] > v3 )
{
return v3 + 8; /*0xffe1b969*/
}
else
{
return 0; /*0xffe1b96e*/
}
}
char CheckBootGuardCapabilityMsr()
{
unsigned __int64 v0; // rax
v0 = __readmsr(0x13Au); /*0xffe1b97a*/
if ( (v0 & 0x100000000LL) != 0 ) /*0xffe1b983*/
{
DebugPrintWrapper(64, "[BootGuardTCG2.c] Bit 32 BootGuardCapability = 1 in MSR 0x13A\n"); /*0xffe1b98c*/
DebugPrintWrapper(64, "[BootGuardTCG2.c] Processor supports Boot Guard.\n"); /*0xffe1b998*/
return 1; /*0xffe1b9a0*/
}
else
{
DebugPrintWrapper(0x80000000, "[BootGuardTCG2.c] Bit 32 BootGuardCapability = 0 in MSR 0x13A\n"); /*0xffe1b9af*/
DebugPrintWrapper(0x80000000, "[BootGuardTCG2.c] Processor does not support Boot Guard.\n"); /*0xffe1b9ba*/
return 0; /*0xffe1b9c2*/
}
}
int DebugPrintHexBytes(unsigned int i, int a2)
{
unsigned int j; // ebx
for ( j = 0; j < i; ++j ) /*0xffe1b9d7*/
{
if ( (j & 0xF) == 0 ) /*0xffe1b9dc*/
DebugPrintWrapper(64, "\n"); /*0xffe1b9e1*/
DebugPrintWrapper(64, " %02x", *(unsigned __int8 *)(j + a2)); /*0xffe1b9f4*/
}
return DebugPrintWrapper(64, "\n"); /*0xffe1ba0b*/
}
int __thiscall ParseBootGuardStructureId(unsigned __int8 *this)
{
unsigned int i; // esi
DebugPrintWrapper(64, "StructureID:"); /*0xffe1ba1b*/
for ( i = 0; i < 8; ++i ) /*0xffe1ba22*/
DebugPrintWrapper(64, "%c", *(this + i)); /*0xffe1ba30*/
return DebugPrintWrapper(64, "\nStructVersion[%02x]\n", *(this + 8)); /*0xffe1ba52*/
}
int CheckNemMeasureBootStatus()
{
unsigned __int64 v0; // rax
char v1; // bl
const char *[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n; // [esp-4h] [ebp-14h]
v0 = __readmsr(0x13Au); /*0xffe1ba5e*/
v1 = v0; /*0xffe1ba60*/
if ( (v0 & 1) != 0 ) /*0xffe1ba65*/
[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n = "[BootGuardTCG2.c] NEM enabled in MSR 0x13A\n"; /*0xffe1ba67*/
else
[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n = "[BootGuardTCG2.c] NEM disable in MSR 0x13A\n"; /*0xffe1ba6e*/
DebugPrintWrapper(64, [BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n); /*0xffe1ba77*/
if ( (v1 & 0x20) != 0 ) /*0xffe1ba81*/
DebugPrintWrapper(64, "[BootGuardTCG2.c] Measure Boot enabled in MSR 0x13A\n"); /*0xffe1ba88*/
else
DebugPrintWrapper(64, "[BootGuardTCG2.c] Measure Boot disable in MSR 0x13A\n"); /*0xffe1ba90*/
if ( (v1 & 8) != 0 ) /*0xffe1ba9a*/
DebugPrintWrapper(64, "[BootGuardTCG2.c] Tpm Success in MSR 0x13A\n"); /*0xffe1baa1*/
else
DebugPrintWrapper(64, "[BootGuardTCG2.c] Tpm Fail in MSR 0x13A\n"); /*0xffe1baa9*/
if ( (v1 & 0x29) == 0x29 )
{
DebugPrintWrapper(64, "[BootGuardTCG2.c] : ACM_PostSuccess : EFI_SUCCESS\n");
return 0; /*0xffe1bac3*/
}
else
{
DebugPrintWrapper(64, "[BootGuardTCG2.c] : ACM_PostSuccess : EFI_UNSUPPORTED\n");
return -2147483645; /*0xffe1bad2*/
}
}
int LogBootGuardEventInternal(
int TpmEventResult,
_BYTE *EventSizeArray,
const char *Boot_Guard_Measured_S_CRTM,
int n27)
{
int v4; // ecx
int v5; // ebp
_WORD *HobFromAddress; // eax
_WORD *v8; // ebx
char *v9; // edi
_WORD *v10; // [esp+10h] [ebp-4h] BYREF
v5 = v4; /*0xffe1bb85*/
if ( (*(int ( **)(int, _WORD **))(*(_DWORD *)v4 + 48))(v4, &v10) < 0 )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 285);
return -2147483634; /*0xffe1bbb7*/
}
HobFromAddress = GetHobFromAddress((int)&unk_FFE2176C, v10); /*0xffe1bbc2*/
if ( !HobFromAddress )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 292);
return -2147483634; /*0xffe1bbd7*/
}
v8 = HobFromAddress + 12; /*0xffe1bbdc*/
v9 = (char *)HobFromAddress + *((_DWORD *)HobFromAddress + 7) + 24; /*0xffe1bbdf*/
*((_DWORD *)v9 + 10) = 0; /*0xffe1bbe7*/
*((_DWORD *)v9 + 11) = 7; /*0xffe1bbeb*/
v9 += 48; /*0xffe1bbf2*/
(*(void ( **)(char *, _BYTE *, int))(*(_DWORD *)v5 + 80))(v9, EventSizeArray, 20); /*0xffe1bbf9*/
*((_DWORD *)v9 + 5) = n27; /*0xffe1bc03*/
v9 += 24; /*0xffe1bc06*/
(*(void ( **)(char *, const char *, int))(*(_DWORD *)v5 + 80))(v9, Boot_Guard_Measured_S_CRTM, n27); /*0xffe1bc12*/
++*((_DWORD *)v8 + 2); /*0xffe1bc1f*/
*((_DWORD *)v8 + 1) = v9 - (char *)v8 + n27 - 40; /*0xffe1bc22*/
return 0; /*0xffe1bc27*/
}
int CreateBootGuardTPM12Event(int CallbackParam, char *src)
{
int v2; // ecx
int v3; // esi
int TpmEventResult; // [esp-4h] [ebp-60h]
int DigestedData[17]; // [esp+8h] [ebp-54h] BYREF
char *p_src; // [esp+4Ch] [ebp-10h] BYREF
int n804; // [esp+50h] [ebp-Ch] BYREF
_WORD *v9; // [esp+54h] [ebp-8h] BYREF
v3 = v2; /*0xffe1bc40*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Enter CreateBootGuardTPM12Event(...)\n", 341);
(*(void ( **)(int *, int, _DWORD))(*(_DWORD *)v3 + 84))(DigestedData, 64, 0); /*0xffe1bc54*/
if ( (*(int ( **)(int, _WORD **))(*(_DWORD *)v3 + 48))(v3, &v9) < 0 )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 349);
return -2147483634; /*0xffe1bc86*/
}
if ( !GetHobFromAddress((int)&unk_FFE2176C, v9) )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 356);
return -2147483634; /*0xffe1bca3*/
}
p_src = src; /*0xffe1bcab*/
n804 = 804; /*0xffe1bcb3*/
DebugAssertPrint(1, &p_src, (int)&n804, (int)DigestedData); /*0xffe1bcc0*/
return LogBootGuardEventInternal(TpmEventResult, DigestedData, "Boot Guard Measured S-CRTM", 27); /*0xffe1bcdd*/
}
int LogBootGuardTpm20EventWrapper(
int n17,
int n7,
int n7a,
_BYTE *HashBuffer,
_BYTE *DigestBuffer,
const char *FIT_Type_0x02_Measured_S_CRTM,
int n30)
{
_WORD *HobFromAddress; // eax
_WORD *EventLogHeader; // ebx
_DWORD *LogEntryPtr; // edi
_DWORD *NextLogEntry; // edi
_DWORD *HashAlgCount; // esi
char *Sha1DigestBuf; // edi
char *Sha256DigestBuf; // edi
_DWORD *EventDescBuf; // edi
char *NextDescBuf; // edi
char *DescSize; // ecx
int PrevNextEventOffset; // eax
_WORD *HobListPtr; // [esp+14h] [ebp-4h] BYREF
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Enter LogBootGuardTPM20Event(...)\n", 394);
if ( (*(int ( **)(int, _WORD **))(*(_DWORD *)n17 + 48))(n17, &HobListPtr) < 0 )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 400);
return -2147483634; /*0xffe1bd2e*/
}
HobFromAddress = GetHobFromAddress((int)&unk_FFE2173C, HobListPtr); /*0xffe1bd3c*/
if ( !HobFromAddress )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 408);
return -2147483634; /*0xffe1bd51*/
}
EventLogHeader = HobFromAddress + 12; /*0xffe1bd53*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : TcgLog Addr 0x%x\n", 413, HobFromAddress + 12);
if ( (*((_DWORD *)EventLogHeader + 8) & 3) != 0 )
{
if ( !*((_DWORD *)EventLogHeader + 3) )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : For Invalid parameter\n", 424);
return -2147483634; /*0xffe1bda5*/
}
LogEntryPtr = (_DWORD *)*((_DWORD *)EventLogHeader + 4); /*0xffe1bdaa*/
*LogEntryPtr++ = n7; /*0xffe1bdb4*/
*LogEntryPtr = n7a; /*0xffe1bdb8*/
NextLogEntry = LogEntryPtr + 1; /*0xffe1bdba*/
if ( *((_DWORD *)EventLogHeader + 3) == 1 ) /*0xffe1bdc0*/
{
(*(void ( **)(_DWORD *, _BYTE *, int))(*(_DWORD *)n17 + 80))(NextLogEntry, HashBuffer, 20); /*0xffe1bdcc*/
NextLogEntry += 5; /*0xffe1bdd2*/
}
else if ( *((_DWORD *)EventLogHeader + 3) == 2 ) /*0xffe1bddb*/
{
*NextLogEntry = 0; /*0xffe1bddd*/
HashAlgCount = NextLogEntry++; /*0xffe1bde0*/
if ( (EventLogHeader[16] & 1) != 0 ) /*0xffe1bde8*/
{
*(_WORD *)NextLogEntry = 4; /*0xffe1bdea*/
Sha1DigestBuf = (char *)NextLogEntry + 2; /*0xffe1bded*/
++*HashAlgCount; /*0xffe1bdf0*/
(*(void ( **)(char *, _BYTE *, int))(*(_DWORD *)n17 + 80))(Sha1DigestBuf, HashBuffer, 20); /*0xffe1bdfc*/
NextLogEntry = Sha1DigestBuf + 20; /*0xffe1be02*/
}
if ( (EventLogHeader[16] & 2) != 0 ) /*0xffe1be09*/
{
*(_WORD *)NextLogEntry = 11; /*0xffe1be0e*/
Sha256DigestBuf = (char *)NextLogEntry + 2; /*0xffe1be11*/
++*HashAlgCount; /*0xffe1be14*/
(*(void ( **)(char *, _BYTE *, int))(*(_DWORD *)n17 + 80))(Sha256DigestBuf, DigestBuffer, 32); /*0xffe1be20*/
NextLogEntry = Sha256DigestBuf + 32; /*0xffe1be26*/
}
}
*NextLogEntry = n30; /*0xffe1be2d*/
EventDescBuf = NextLogEntry + 1; /*0xffe1be2f*/
(*(void ( **)(_DWORD *, const char *, int))(*(_DWORD *)n17 + 80))( /*0xffe1be3b*/
EventDescBuf,
FIT_Type_0x02_Measured_S_CRTM,
n30);
NextDescBuf = (char *)EventDescBuf + n30; /*0xffe1be41*/
*((_DWORD *)EventLogHeader + 6) = *((_DWORD *)EventLogHeader + 4); /*0xffe1be45*/
DescSize = &NextDescBuf[-*((_DWORD *)EventLogHeader + 4)]; /*0xffe1be48*/
PrevNextEventOffset = *((_DWORD *)EventLogHeader + 5); /*0xffe1be4e*/
*((_DWORD *)EventLogHeader + 5) = 0; /*0xffe1be51*/
*((_DWORD *)EventLogHeader + 1) += DescSize; /*0xffe1be55*/
++*((_DWORD *)EventLogHeader + 2); /*0xffe1be58*/
*((_DWORD *)EventLogHeader + 7) = PrevNextEventOffset; /*0xffe1be5b*/
*((_DWORD *)EventLogHeader + 4) = NextDescBuf; /*0xffe1be60*/
return 0; /*0xffe1be5e*/
}
else
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Err ActPcrBanks, No SHA1/SHA256 banks\n", 417);
return -2147483646; /*0xffe1bd8b*/
}
}
int CreateBootGuardTPM20Event(
int n17,
int n7,
int n7a,
char *src,
int n100,
const char *Boot_Guard_Measured_S_CRTM,
int n54)
{
_WORD *HobFromAddress; // eax
_WORD *v11; // esi
unsigned int n2; // eax
int n100_1; // [esp+10h] [ebp-40h] BYREF
char *p_src; // [esp+14h] [ebp-3Ch] BYREF
_WORD *v15; // [esp+18h] [ebp-38h] BYREF
_BYTE DigestedData[20]; // [esp+1Ch] [ebp-34h] BYREF
char DigestBuffer[32]; // [esp+30h] [ebp-20h] BYREF
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Enter CreateBootGuardTPM20Event(...)\n", 503);
(*(void ( **)(_BYTE *, int, _DWORD))(*(_DWORD *)n17 + 84))(DigestedData, 20, 0); /*0xffe1be94*/
(*(void ( **)(char *, int, _DWORD))(*(_DWORD *)n17 + 84))(DigestBuffer, 32, 0); /*0xffe1bea5*/
if ( (*(int ( **)(int, _WORD **))(*(_DWORD *)n17 + 48))(n17, &v15) < 0 )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 513);
return -2147483634; /*0xffe1bed8*/
}
HobFromAddress = GetHobFromAddress((int)&unk_FFE2173C, v15); /*0xffe1bee6*/
if ( !HobFromAddress )
{
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 521);
return -2147483634; /*0xffe1befb*/
}
v11 = HobFromAddress + 12; /*0xffe1befd*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : TcgLog Addr 0x%x\n", 526, HobFromAddress + 12);
p_src = src; /*0xffe1bf1d*/
n2 = *((_DWORD *)v11 + 3); /*0xffe1bf21*/
n100_1 = n100; /*0xffe1bf24*/
if ( n2 < 2 ) /*0xffe1bf2b*/
{
DebugAssertPrint(1, &p_src, (int)&n100_1, (int)DigestedData); /*0xffe1bf8b*/
}
else if ( n2 == 2 ) /*0xffe1bf34*/
{
if ( (v11[16] & 1) != 0 && n100 ) /*0xffe1bf3e*/
DebugAssertPrint(1, &p_src, (int)&n100_1, (int)DigestedData); /*0xffe1bf51*/
if ( (v11[16] & 2) != 0 ) /*0xffe1bf5c*/
{
if ( n100 ) /*0xffe1bf60*/
GetFirstGuidHob(1, (char *)&p_src, &n100_1, DigestBuffer); /*0xffe1bf73*/
}
}
return LogBootGuardTpm20EventWrapper(n17, n7, n7a, DigestedData, DigestBuffer, Boot_Guard_Measured_S_CRTM, n54); /*0xffe1bfb4*/
}
int __thiscall LocateTcgPpi(int *this)
{
int v2; // eax
int v3; // eax
int v4; // esi
_DWORD v6[8]; // [esp+10h] [ebp-128h] BYREF
_BYTE v7[224]; // [esp+30h] [ebp-108h] BYREF
_BYTE v8[4]; // [esp+110h] [ebp-28h] BYREF
_DWORD v9[4]; // [esp+114h] [ebp-24h] BYREF
int ( **v10)(_DWORD, int *, _DWORD *, int, _DWORD *, _BYTE *); // [esp+124h] [ebp-14h] BYREF
_DWORD v11[4]; // [esp+128h] [ebp-10h] BYREF
v11[0] = 1416362782; /*0xffe1c063*/
v11[1] = 1079319820; /*0xffe1c06f*/
v2 = *this; /*0xffe1c076*/
v11[2] = -196170332; /*0xffe1c081*/
v11[3] = 985143231; /*0xffe1c089*/
v10 = 0; /*0xffe1c090*/
v9[0] = 394082770; /*0xffe1c093*/
v9[1] = 1086866360; /*0xffe1c09a*/
v9[2] = 1362944410; /*0xffe1c0a1*/
v9[3] = 513070744; /*0xffe1c0a8*/
v6[0] = 0; /*0xffe1c0af*/
v6[1] = 8; /*0xffe1c0b5*/
v6[7] = 16; /*0xffe1c0bf*/
(*(void ( **)(_BYTE *, _DWORD *, int))(v2 + 80))(v7, v11, 16); /*0xffe1c0c5*/
v3 = (*(int ( **)(int *, _DWORD *, _DWORD, _DWORD, int ( ***)(_DWORD, int *, _DWORD *, int, _DWORD *, _BYTE *)))(*this + 32))( /*0xffe1c0d5*/
this,
v9,
0,
0,
&v10);
v4 = v3; /*0xffe1c0d8*/
if ( v3 >= 0 ) /*0xffe1c0df*/
return (*v10)(v10, this, v11, 16, v6, v8); /*0xffe1c112*/
DebugPrintWrapper(0x80000000, "[%d]: gTcgPpiguid NOT found %r \n", 645, v3);
return v4; /*0xffe1c117*/
}
int __thiscall DetectTpmDeviceType(int *this)
{
int PeiServicesPtr; // eax
_WORD *HobFromAddress; // eax
int Tpm12Status; // eax
_DWORD Tpm12GuidData[4]; // [esp+Ch] [ebp-1Ch] BYREF
int Tpm12PpiHandle; // [esp+1Ch] [ebp-Ch] BYREF
_WORD *HobListPtr; // [esp+20h] [ebp-8h] BYREF
int Tpm20PpiHandle; // [esp+24h] [ebp-4h] BYREF
Tpm12GuidData[0] = 394082770; /*0xffe1c128*/
Tpm12GuidData[1] = 1086866360; /*0xffe1c131*/
Tpm20PpiHandle = 0; /*0xffe1c13b*/
PeiServicesPtr = *this; /*0xffe1c13f*/
Tpm12PpiHandle = 0; /*0xffe1c149*/
Tpm12GuidData[2] = 1362944410; /*0xffe1c14c*/
Tpm12GuidData[3] = 513070744; /*0xffe1c153*/
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(PeiServicesPtr + 32))(
this,
&unk_FFE2175C,
0,
0,
&Tpm20PpiHandle) < 0 )
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Can not locate Ami Tree Ppi, It may TPM 1.2 Device\n", 702);
goto LABEL_11; /*0xffe1c16e*/
}
if ( (*(int ( **)(int *, _WORD **))(*this + 48))(this, &HobListPtr) < 0 )
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs, It may TPM 1.2 Device\n", 710);
goto LABEL_11; /*0xffe1c18a*/
}
HobFromAddress = GetHobFromAddress((int)&unk_FFE2174C, HobListPtr); /*0xffe1c194*/
if ( *((_BYTE *)HobFromAddress + 24) != 1 )
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : TrEEDeviceHob->Tpm20DeviceState = 0, It may TPM 1.2 Device\n", 725);
LABEL_11:
Tpm12Status = (*(int ( **)(int *, _DWORD *, _DWORD, _DWORD, int *))(*this + 32))( /*0xffe1c1ea*/
this,
Tpm12GuidData,
0,
0,
&Tpm12PpiHandle);
if ( Tpm12Status >= 0 )
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TPM 1.2 found\n", 743);
return 1; /*0xffe1c244*/
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: gTcgPpiguid NOT found %r\n", 738, Tpm12Status);
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: No TPM\n", 739);
return 0; /*0xffe1c22a*/
}
}
if ( *((_BYTE *)HobFromAddress + 25) == 1 )
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TPM 2.0 found\n", 718);
return 2; /*0xffe1c1b9*/
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: PTT found\n", 721);
return 3; /*0xffe1c1d5*/
}
}
int LogBootGuardTpm12Event(unsigned __int8 a1, _DWORD *a2)
{
int v2; // esi
unsigned int v5; // edx
unsigned int v6; // ecx
int v7; // eax
int n64; // [esp-Ch] [ebp-18h]
const char *[BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n; // [esp-8h] [ebp-14h]
int v11; // [esp-4h] [ebp-10h]
v2 = 0; /*0xffe1c251*/
if ( MEMORY[0xFFFFFFC0] == -1 || !MEMORY[0xFFFFFFC0] )
{
v11 = MEMORY[0xFFFFFFC0]; /*0xffe1c28f*/
[BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n = "[BootGuardTCG2.c] : FindEntryInFit(%lx) is Invalid\n";
n64 = 0x80000000; /*0xffe1c295*/
goto LABEL_10; /*0xffe1c295*/
}
v5 = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe1c262*/
v6 = 1; /*0xffe1c267*/
if ( v5 <= 1 )
{
LABEL_7:
v11 = a1; /*0xffe1c27c*/
[BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n = "[BootGuardTCG2.c] : Error, Did not find Tbl type = %x\n";
n64 = 64; /*0xffe1c285*/
LABEL_10:
v2 = -2147483634; /*0xffe1c29a*/
DebugPrintWrapper(n64, [BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n, v11); /*0xffe1c29f*/
return v2; /*0xffe1c29f*/
}
v7 = MEMORY[0xFFFFFFC0] + 16; /*0xffe1c26c*/
while ( *(_BYTE *)(v7 + 14) != a1 ) /*0xffe1c272*/
{
++v6; /*0xffe1c274*/
v7 += 16; /*0xffe1c275*/
if ( v6 >= v5 ) /*0xffe1c27a*/
goto LABEL_7; /*0xffe1c27a*/
}
*a2 = *(_DWORD *)v7; /*0xffe1c28b*/
return v2; /*0xffe1c2a7*/
}
int LogTpm20LocalityStartupEvent(int n17, char n2)
{
char Boot_Guard_Measured_S_CRTM[20]; // [esp+Ch] [ebp-14h] BYREF
DebugPrintWrapper(64, "BootGuardTCG2.c[%d] : Enter LogTpm20LocalityStartupEvent(...)\n", 842);
if ( n2 ) /*0xffe1c2cf*/
{
(*(void ( **)(char *, int, _DWORD))(*(_DWORD *)n17 + 84))(Boot_Guard_Measured_S_CRTM, 16, 0); /*0xffe1c2db*/
(*(void ( **)(char *, const char *, int))(*(_DWORD *)n17 + 80))( /*0xffe1c2ee*/
Boot_Guard_Measured_S_CRTM,
"StartupLocality",
16);
Boot_Guard_Measured_S_CRTM[16] = 3; /*0xffe1c2f4*/
CreateBootGuardTPM20Event(n17, 0, 3, 0, 0, Boot_Guard_Measured_S_CRTM, 17); /*0xffe1c308*/
}
return 0; /*0xffe1c310*/
}
int SkipLogAuthorityEvent(int n17, char n2)
{
int v4; // eax
int v6; // [esp+Ch] [ebp-4h] BYREF
v6 = 0; /*0xffe1c31d*/
v4 = LogBootGuardTpm12Event(0xCu, &v6); /*0xffe1c32c*/
if ( v4 >= 0 )
{
if ( (*(_DWORD *)(v6 + 28) & 2) != 0 )
{
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe1c37b*/
LogTpm20LocalityStartupEvent(n17, n2); /*0xffe1c381*/
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Skip Log Authority Event\n", 893);
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 884, v4);
}
return 0; /*0xffe1c386*/
}
int LogAuthorityPCREvent(int n17, char n2)
{
int Tpm12Status; // eax
int Tpm12Status_1; // edi
int Tpm12Status_2; // eax
int Tpm12Status_3; // eax
int EventHandleSize_1; // esi
int Tpm12EventHandle; // [esp+10h] [ebp-74h] BYREF
int AcmStructPtr; // [esp+14h] [ebp-70h] BYREF
int EventHandleSize; // [esp+18h] [ebp-6Ch] BYREF
char BootGuardState[4]; // [esp+1Ch] [ebp-68h] BYREF
char HashCtxBuf[32]; // [esp+20h] [ebp-64h] BYREF
char DigestBuf[32]; // [esp+40h] [ebp-44h] BYREF
char EventBuf[36]; // [esp+60h] [ebp-24h] BYREF
EventHandleSize = 0; /*0xffe1c3a4*/
Tpm12EventHandle = 0; /*0xffe1c3a8*/
AcmStructPtr = 0; /*0xffe1c3ac*/
DebugPrintWrapper(64, "[BootGuardTCG2.c] : Enter LogAuthorityPCREvent(...)\n");
Tpm12Status = LogBootGuardTpm12Event(0xCu, &Tpm12EventHandle); /*0xffe1c3bd*/
Tpm12Status_1 = Tpm12Status; /*0xffe1c3c2*/
if ( Tpm12Status >= 0 )
{
if ( (*(_DWORD *)(Tpm12EventHandle + 28) & 4) != 0 )
{
BootGuardState[0] = ReadMsr(); /*0xffe1c40d*/
DebugPrintWrapper(64, "BP->RSTR:[%x]\n", (unsigned __int8)BootGuardState[0]); /*0xffe1c41b*/
BootGuardState[1] = IsBootGuardCapable(); /*0xffe1c428*/
DebugPrintWrapper(64, "BP->TYPE:[%x]\n", (unsigned __int8)BootGuardState[1]); /*0xffe1c436*/
Tpm12Status_2 = LogBootGuardTpm12Event(2u, &AcmStructPtr); /*0xffe1c444*/
Tpm12Status_1 = Tpm12Status_2; /*0xffe1c449*/
if ( Tpm12Status_2 >= 0 )
{
*(_WORD *)&BootGuardState[2] = IoWrite16((unsigned __int16 *)(AcmStructPtr + 28)); /*0xffe1c466*/
DebugPrintWrapper(64, "BP->ACM_SVN = [%x]\n", *(unsigned __int16 *)&BootGuardState[2]); /*0xffe1c475*/
(*(void ( **)(char *, int, int))(*(_DWORD *)n17 + 80))(HashCtxBuf, -19725312, 32); /*0xffe1c48c*/
Tpm12Status_3 = LogBootGuardTpm12Event(0xBu, &EventHandleSize); /*0xffe1c498*/
Tpm12Status_1 = Tpm12Status_3; /*0xffe1c49d*/
if ( Tpm12Status_3 >= 0 )
{
EventHandleSize_1 = EventHandleSize; /*0xffe1c4ae*/
EventHandleSize = 256; /*0xffe1c4b8*/
AcmStructPtr = EventHandleSize_1 + 58; /*0xffe1c4c4*/
GetFirstGuidHob(1, (char *)&AcmStructPtr, &EventHandleSize, DigestBuf); /*0xffe1c4d2*/
(*(void ( **)(char *, int, int))(*(_DWORD *)n17 + 80))(EventBuf, EventHandleSize_1 + 16, 32); /*0xffe1c4e5*/
DebugPrintWrapper(64, "BP Hash Structure, Size[%x]", 100); /*0xffe1c4f4*/
DebugPrintHexBytes(0x64u, (int)BootGuardState); /*0xffe1c503*/
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe1c515*/
return CreateBootGuardTPM20Event( /*0xffe1c537*/
n17,
7,
-2147483647,
BootGuardState,
100,
L"Boot Guard Measured S-CRTM",
54);
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 989, Tpm12Status_3);
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 976, Tpm12Status_2);
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Skip Log Authority Event\n", 959);
return 0; /*0xffe1c401*/
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 951, Tpm12Status);
}
return Tpm12Status_1; /*0xffe1c53b*/
}
int LogDetailPCREvent(int n17, char n2)
{
int Tpm12Status; // eax
int Tpm12EventHandle_1; // esi
__int16 AcmSvnValue; // ax
int Tpm12StatusB; // eax
unsigned __int8 *KmStructPtr_1; // esi
int Tpm12StatusC; // eax
int BpmStructPtr_1; // edi
int SegCountOffset; // esi
int CallbackParam; // ecx
char *src; // [esp+14h] [ebp-10h] BYREF
int Tpm12EventHandle; // [esp+18h] [ebp-Ch] BYREF
unsigned __int8 *KmStructPtr; // [esp+1Ch] [ebp-8h] BYREF
int BpmStructPtr; // [esp+20h] [ebp-4h] BYREF
src = 0; /*0xffe1c55b*/
KmStructPtr = 0; /*0xffe1c55f*/
BpmStructPtr = 0; /*0xffe1c563*/
Tpm12EventHandle = 0; /*0xffe1c567*/
DebugPrintWrapper(64, "[BootGuardTCG2.c] : Enter LogDetailPCREvent(...)\n");
if ( (*(int ( **)(int, int, char **))(*(_DWORD *)n17 + 76))(n17, 804, &src) < 0 ) /*0xffe1c585*/
return -2147483639; /*0xffe1c587*/
DebugPrintWrapper(64, "MSR[0x%x]:[%08x]\n", 314, (unsigned int)__readmsr(0x13Au)); /*0xffe1c5a5*/
DebugPrintWrapper(64, "ACM_STATUS:[%08x]\n", MEMORY[0xFED30328]); /*0xffe1c5b9*/
*src = ReadMsr(); /*0xffe1c5ca*/
DebugPrintWrapper(64, "BP->RSTR:[%x]\n", (unsigned __int8)*src); /*0xffe1c5da*/
src[1] = IsBootGuardCapable(); /*0xffe1c5eb*/
DebugPrintWrapper(64, "BP->TYPE:[%x]\n", (unsigned __int8)src[1]); /*0xffe1c5fd*/
Tpm12Status = LogBootGuardTpm12Event(2u, &Tpm12EventHandle); /*0xffe1c60b*/
if ( Tpm12Status >= 0 )
{
Tpm12EventHandle_1 = Tpm12EventHandle; /*0xffe1c62d*/
AcmSvnValue = IoWrite16((unsigned __int16 *)(Tpm12EventHandle + 28)); /*0xffe1c634*/
*((_WORD *)src + 1) = AcmSvnValue; /*0xffe1c63d*/
DebugPrintWrapper(64, "BP->ACM_SVN = [%x]\n", *((unsigned __int16 *)src + 1)); /*0xffe1c650*/
(*(void ( **)(char *, int, int))(*(_DWORD *)n17 + 80))(src + 4, Tpm12EventHandle_1 + 388, 256); /*0xffe1c66f*/
DebugPrintHexBytes(0x100u, (int)(src + 4)); /*0xffe1c67e*/
Tpm12StatusB = LogBootGuardTpm12Event(0xBu, &KmStructPtr); /*0xffe1c689*/
if ( Tpm12StatusB >= 0 )
{
KmStructPtr_1 = KmStructPtr; /*0xffe1c69a*/
DebugPrintWrapper(64, "\nKmStructure: Addr[%lx]\n", KmStructPtr);
ParseBootGuardStructureId(KmStructPtr_1); /*0xffe1c6af*/
(*(void ( **)(char *, unsigned __int8 *, int))(*(_DWORD *)n17 + 80))(src + 260, KmStructPtr_1 + 321, 256); /*0xffe1c6c8*/
DebugPrintHexBytes(0x100u, (int)(src + 260)); /*0xffe1c6da*/
Tpm12StatusC = LogBootGuardTpm12Event(0xCu, &BpmStructPtr); /*0xffe1c6e5*/
if ( Tpm12StatusC >= 0 )
{
BpmStructPtr_1 = BpmStructPtr; /*0xffe1c6f9*/
DebugPrintWrapper(64, "\nBpmStructure: Addr[%lx]\n", BpmStructPtr);
ParseBootGuardStructureId((unsigned __int8 *)BpmStructPtr_1); /*0xffe1c70e*/
DebugPrintWrapper(64, "BpmStructure->Ibb_Element.EntryPoint[%x]\n", *(_DWORD *)(BpmStructPtr_1 + 108)); /*0xffe1c71c*/
DebugPrintWrapper( /*0xffe1c732*/
64,
"BpmStructure->Ibb_Element.SegmentCount[%x]\n",
*(unsigned __int8 *)(BpmStructPtr_1 + 148));
SegCountOffset = 12 * *(unsigned __int8 *)(BpmStructPtr_1 + 148); /*0xffe1c741*/
DebugPrintWrapper(64, "\nBpmStructure->Bpm_Signature_Element.KeySignaturee"); /*0xffe1c74a*/
(*(void ( **)(char *, int, int))(*(_DWORD *)n17 + 80))( /*0xffe1c769*/
src + 516,
SegCountOffset + BpmStructPtr_1 + 431,
256);
DebugPrintHexBytes(0x100u, (int)(src + 516)); /*0xffe1c77e*/
DebugPrintWrapper(64, "\n\nBpmStructure->Digest_of_Hashed_IBB_Segment:"); /*0xffe1c789*/
(*(void ( **)(char *, int, int))(*(_DWORD *)n17 + 80))(src + 772, BpmStructPtr_1 + 116, 32); /*0xffe1c7a0*/
DebugPrintHexBytes(0x20u, (int)(src + 772)); /*0xffe1c7b3*/
DebugPrintWrapper(64, "BP Hash Structure, Size[%x]", 804); /*0xffe1c7c4*/
DebugPrintHexBytes(0x324u, (int)src); /*0xffe1c7d2*/
if ( n2 == 1 ) /*0xffe1c7dd*/
{
CreateBootGuardTPM12Event(CallbackParam, src); /*0xffe1c7e9*/
}
else if ( n2 == 2 || n2 == 3 ) /*0xffe1c7f6*/
{
CreateBootGuardTPM20Event(n17, 0, 7, src, 804, "Boot Guard Measured S-CRTM", 27); /*0xffe1c80a*/
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1099, Tpm12StatusC);
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1087, Tpm12StatusB);
}
}
else
{
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1075, Tpm12Status);
}
return 0; /*0xffe1c814*/
}
int __thiscall LogTxtTpm12CRTMEvent(void *this)
{
int ReturnStatus; // esi
int HashDigest_1; // edi
unsigned int FitTotalEntries; // ebx
unsigned int FitTableCopy_1; // eax
_BYTE *EntryCursor; // ebp
int TpmEventResult; // ecx
int Type7Count; // ebp
int Type7SearchPtr; // ecx
unsigned int Type7Remaining; // edx
int Type2DSearchIdx; // ecx
int i; // eax
int TpmEventResult_1; // [esp-4h] [ebp-90h]
int TpmEventResult_2; // [esp-4h] [ebp-90h]
int FitCountRemaining; // [esp+18h] [ebp-74h] BYREF
unsigned int FitTableCopy; // [esp+1Ch] [ebp-70h]
int HashDigest; // [esp+20h] [ebp-6Ch]
int EventSizeArray[5]; // [esp+24h] [ebp-68h] BYREF
int EventSizes[10]; // [esp+38h] [ebp-54h] BYREF
char *EventDataArray[11]; // [esp+60h] [ebp-2Ch] BYREF
ReturnStatus = 0; /*0xffe1c833*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Enter LogTxtTpm12CRTMEvent\n", 1175);
HashDigest_1 = MEMORY[0xFFFFFFC0]; /*0xffe1c840*/
HashDigest = MEMORY[0xFFFFFFC0]; /*0xffe1c842*/
if ( MEMORY[0xFFFFFFC0] == -1 )
{
ReturnStatus = -2147483642; /*0xffe1c858*/
DebugPrintWrapper(64, "[%d] : FitEntryPointer(%lx) is empty\n", 1183, -1);
}
else if ( *MEMORY[0xFFFFFFC0] == 1414088287 && *(_DWORD *)(MEMORY[0xFFFFFFC0] + 4) == 538976351 )
{
FitTotalEntries = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe1c883*/
if ( FitTotalEntries > 1 )
{
FitTableCopy_1 = FitTotalEntries - 1; /*0xffe1c88f*/
EntryCursor = (_BYTE *)(MEMORY[0xFFFFFFC0] + 16); /*0xffe1c892*/
FitTableCopy = FitTotalEntries - 1; /*0xffe1c895*/
do
{
if ( EntryCursor[14] == 2 )
{
FitCountRemaining = *(_DWORD *)(*(_DWORD *)EntryCursor + 20); /*0xffe1c8b2*/
(*(void ( **)(int *, int, _DWORD))(*(_DWORD *)this + 84))(EventSizeArray, 20, 0); /*0xffe1c8b8*/
EventSizeArray[0] = FitCountRemaining; /*0xffe1c8c2*/
ReturnStatus = LogBootGuardEventInternal(TpmEventResult, EventSizeArray, "FIT Type 0x02 Measured S-CRTM", 30); /*0xffe1c8da*/
if ( ReturnStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1219);
FitTableCopy_1 = FitTableCopy; /*0xffe1c8f7*/
}
EntryCursor += 16; /*0xffe1c8fb*/
FitTableCopy = --FitTableCopy_1; /*0xffe1c901*/
}
while ( FitTableCopy_1 );
HashDigest_1 = HashDigest; /*0xffe1c907*/
if ( ReturnStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error TRACE CODE\n", 1227);
}
Type7Count = 0; /*0xffe1c923*/
if ( FitTotalEntries > 1 )
{
Type7SearchPtr = HashDigest_1 + 24; /*0xffe1c92a*/
Type7Remaining = FitTotalEntries - 1; /*0xffe1c92d*/
do /*0xffe1c94d*/
{
if ( *(_BYTE *)(Type7SearchPtr + 6) == 7 ) /*0xffe1c934*/
{
EventDataArray[Type7Count] = *(char **)(Type7SearchPtr - 8); /*0xffe1c939*/
EventSizes[Type7Count++] = 16 * *(_DWORD *)Type7SearchPtr; /*0xffe1c942*/
}
Type7SearchPtr += 16; /*0xffe1c947*/
--Type7Remaining; /*0xffe1c94a*/
}
while ( Type7Remaining ); /*0xffe1c94d*/
if ( Type7Count )
{
DebugAssertPrint(Type7Count, EventDataArray, (int)EventSizes, (int)EventSizeArray); /*0xffe1c963*/
ReturnStatus = LogBootGuardEventInternal(TpmEventResult_1, EventSizeArray, "FIT Type 0x07 Measured S-CRTM", 30); /*0xffe1c982*/
if ( ReturnStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1259);
}
}
FitCountRemaining = 0; /*0xffe1c9a5*/
Type2DSearchIdx = 1; /*0xffe1c9ac*/
if ( FitTotalEntries > 1 )
{
for ( i = HashDigest_1 + 16; *(_BYTE *)(i + 14) != 45; i += 16 ) /*0xffe1c9b5*/
{
if ( ++Type2DSearchIdx >= FitTotalEntries ) /*0xffe1c9c4*/
return ReturnStatus; /*0xffe1c9c4*/
}
FitCountRemaining = *(_DWORD *)i; /*0xffe1c9ce*/
EventSizes[0] = 4; /*0xffe1c9d8*/
EventDataArray[0] = (char *)&FitCountRemaining; /*0xffe1c9e0*/
DebugAssertPrint(1, EventDataArray, (int)EventSizes, (int)EventSizeArray); /*0xffe1c9ef*/
ReturnStatus = LogBootGuardEventInternal(TpmEventResult_2, EventSizeArray, "FIT Type 0x2D Measured S-CRTM", 30); /*0xffe1ca0a*/
if ( ReturnStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1291);
}
}
else
{
ReturnStatus = -2147483642; /*0xffe1ca2c*/
DebugPrintWrapper(64, "[%d] : [Type 0] FitEntry->TblAddress(%lx) is error\n", 1191, *MEMORY[0xFFFFFFC0]);
}
return ReturnStatus; /*0xffe1ca47*/
}
int __thiscall LogTxtTpm20CRTMEvent(void *this)
{
int ThisPtr; // ebp
int FitTableBase; // esi
int ReturnStatus; // esi
unsigned int FitTotalEntries; // ebx
int FitEntryCursor; // edi
int FinalEventStatus; // esi
unsigned int RemainingEntries; // ebp
int EntryArrayIndex; // ebx
int EntryAddress; // eax
bool IsError; // sf
int FitEntryIndex_1; // edi
int Type7SearchPtr; // ecx
unsigned int Type7Remaining; // edx
unsigned int FitTotalEntries_1; // ecx
int *Type2DSearchPtr; // eax
int FitEntryValue; // [esp+14h] [ebp-A0h] BYREF
int ThisCopy; // [esp+18h] [ebp-9Ch]
int EventResult; // [esp+1Ch] [ebp-98h]
int FitEntryIndex; // [esp+20h] [ebp-94h]
int FitTablePtr; // [esp+24h] [ebp-90h]
unsigned int FitEntryCount; // [esp+28h] [ebp-8Ch]
_BYTE HashBuffer[20]; // [esp+2Ch] [ebp-88h] BYREF
int EventSizes[10]; // [esp+40h] [ebp-74h] BYREF
char *EventDataPtrs[10]; // [esp+68h] [ebp-4Ch] BYREF
char DigestBuffer[36]; // [esp+90h] [ebp-24h] BYREF
EventResult = 0; /*0xffe1ca57*/
ThisPtr = (int)this; /*0xffe1ca65*/
ThisCopy = (int)this; /*0xffe1ca6e*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Enter LogTxtTpm20CRTMEvent\n", 1317);
FitTableBase = MEMORY[0xFFFFFFC0]; /*0xffe1ca7d*/
FitTablePtr = MEMORY[0xFFFFFFC0]; /*0xffe1ca7f*/
if ( MEMORY[0xFFFFFFC0] == -1 )
{
ReturnStatus = -2147483642; /*0xffe1ca96*/
DebugPrintWrapper(64, "[%d] : FitEntryPointer(%lx) is empty\n", 1325, -1);
}
else if ( *MEMORY[0xFFFFFFC0] == 1414088287 && *(_DWORD *)(MEMORY[0xFFFFFFC0] + 4) == 538976351 )
{
FitTotalEntries = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe1cac4*/
FitEntryIndex = 0; /*0xffe1cac7*/
FitEntryCount = FitTotalEntries; /*0xffe1cacc*/
if ( FitTotalEntries > 1 )
{
FitEntryCursor = MEMORY[0xFFFFFFC0] + 16; /*0xffe1cad9*/
FinalEventStatus = EventResult; /*0xffe1cadc*/
RemainingEntries = FitTotalEntries - 1; /*0xffe1cae0*/
EntryArrayIndex = FitEntryIndex; /*0xffe1cae3*/
do
{
if ( *(_BYTE *)(FitEntryCursor + 14) == 2 )
{
EntryAddress = *(_DWORD *)FitEntryCursor; /*0xffe1caf1*/
EventSizes[EntryArrayIndex] = 4; /*0xffe1caf7*/
FitEntryValue = *(_DWORD *)(EntryAddress + 20); /*0xffe1cb02*/
EventDataPtrs[EntryArrayIndex++] = (char *)&FitEntryValue; /*0xffe1cb0a*/
GetFirstGuidHob(EntryArrayIndex, (char *)EventDataPtrs, EventSizes, DigestBuffer); /*0xffe1cb1e*/
DebugAssertPrint(EntryArrayIndex, EventDataPtrs, (int)EventSizes, (int)HashBuffer); /*0xffe1cb33*/
FinalEventStatus = LogBootGuardTpm20EventWrapper( /*0xffe1cb59*/
ThisCopy,
0,
7,
HashBuffer,
DigestBuffer,
"FIT Type 0x02 Measured S-CRTM",
30);
if ( FinalEventStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1366);
}
FitEntryCursor += 16; /*0xffe1cb76*/
--RemainingEntries; /*0xffe1cb79*/
}
while ( RemainingEntries );
FitTotalEntries = FitEntryCount; /*0xffe1cb82*/
IsError = FinalEventStatus < 0; /*0xffe1cb86*/
FitTableBase = FitTablePtr; /*0xffe1cb88*/
if ( IsError )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error TRACE CODE\n", 1374);
ThisPtr = ThisCopy; /*0xffe1cba2*/
}
FitEntryIndex_1 = 0; /*0xffe1cba6*/
if ( FitTotalEntries > 1 )
{
Type7SearchPtr = FitTableBase + 24; /*0xffe1cbb1*/
Type7Remaining = FitTotalEntries - 1; /*0xffe1cbb4*/
do /*0xffe1cbd4*/
{
if ( *(_BYTE *)(Type7SearchPtr + 6) == 7 ) /*0xffe1cbbb*/
{
EventDataPtrs[FitEntryIndex_1] = *(char **)(Type7SearchPtr - 8); /*0xffe1cbc0*/
EventSizes[FitEntryIndex_1++] = 16 * *(_DWORD *)Type7SearchPtr; /*0xffe1cbc9*/
}
Type7SearchPtr += 16; /*0xffe1cbce*/
--Type7Remaining; /*0xffe1cbd1*/
}
while ( Type7Remaining ); /*0xffe1cbd4*/
if ( FitEntryIndex_1 )
{
GetFirstGuidHob(FitEntryIndex_1, (char *)EventDataPtrs, EventSizes, DigestBuffer); /*0xffe1cbed*/
DebugAssertPrint(FitEntryIndex_1, EventDataPtrs, (int)EventSizes, (int)HashBuffer); /*0xffe1cc02*/
if ( LogBootGuardTpm20EventWrapper(ThisPtr, 0, 7, HashBuffer, DigestBuffer, "FIT Type 0x07 Measured S-CRTM", 30) < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1408);
}
}
FitEntryValue = 0; /*0xffe1cc41*/
FitTotalEntries_1 = 1; /*0xffe1cc49*/
if ( FitTotalEntries > 1 ) /*0xffe1cc4d*/
{
Type2DSearchPtr = (int *)(FitTableBase + 16); /*0xffe1cc4f*/
while ( *((_BYTE *)Type2DSearchPtr + 14) != 45 ) /*0xffe1cc56*/
{
++FitTotalEntries_1; /*0xffe1cc58*/
Type2DSearchPtr += 4; /*0xffe1cc59*/
if ( FitTotalEntries_1 >= FitTotalEntries ) /*0xffe1cc5e*/
goto LABEL_28; /*0xffe1cc5e*/
}
FitEntryValue = *Type2DSearchPtr; /*0xffe1cc64*/
}
LABEL_28:
EventSizes[0] = 4; /*0xffe1cc68*/
EventDataPtrs[0] = (char *)&FitEntryValue; /*0xffe1cc74*/
GetFirstGuidHob(1, (char *)EventDataPtrs, EventSizes, DigestBuffer); /*0xffe1cc8b*/
DebugAssertPrint(1, EventDataPtrs, (int)EventSizes, (int)HashBuffer); /*0xffe1cca0*/
ReturnStatus = LogBootGuardTpm20EventWrapper( /*0xffe1ccc4*/
ThisPtr,
0,
7,
HashBuffer,
DigestBuffer,
"FIT Type 0x2D Measured S-CRTM",
30);
if ( ReturnStatus < 0 )
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1445);
}
else
{
ReturnStatus = -2147483642; /*0xffe1ccf1*/
DebugPrintWrapper(64, "[%d] : [Type 0] FitEntry->TblAddress(%lx) is error\n", 1333, *MEMORY[0xFFFFFFC0]);
}
return ReturnStatus; /*0xffe1ccfe*/
}
int BootGuardTcg2MeasureCRTMVersion(int *n17)
{
char n2; // bl
unsigned __int64 v2; // rax
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v10[3]; // [esp+Ch] [ebp-Ch] BYREF
v10[0] = 0; /*0xffe1cd25*/
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: Enter BootGuardTcg2MeasureCRTMVersion\n", 1465);
n2 = DetectTpmDeviceType(n17); /*0xffe1cd3d*/
if ( (*(int ( **)(int *, void *, _DWORD, _DWORD, int *))(*n17 + 32))(n17, &unk_FFE2175C, 0, 0, v10) < 0 ) /*0xffe1cd54*/
v10[0] = 0; /*0xffe1cd56*/
if ( MEMORY[0xFED300A4] < 0 )
{
DebugPrintWrapper(64, "[BootGuardTCG2.c] Bit 63 success in 0xFED300A0\n"); /*0xffe1cd95*/
LABEL_7:
if ( CheckBootGuardCapabilityMsr() == 1 && CheckNemMeasureBootStatus() >= 0 ) /*0xffe1cdb0*/
{
DebugPrintWrapper(64, "[BootGuardTCG2.c] Start the LogDetailPCREvent\n"); /*0xffe1cdbd*/
v3 = SkipLogAuthorityEvent((int)n17, n2); /*0xffe1cdc8*/
if ( v3 < 0 ) /*0xffe1cdd4*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0xffe1cddd*/
v4 = AssertReport(); /*0xffe1cde5*/
if ( v4 ) /*0xffe1cdec*/
(*(void ( **)(const char *, int, const char *))(v4 + 4))( /*0xffe1cdfd*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1495,
"!EFI_ERROR (Status)");
}
v5 = LogDetailPCREvent((int)n17, n2); /*0xffe1ce07*/
if ( v5 < 0 ) /*0xffe1ce0e*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0xffe1ce17*/
v6 = AssertReport(); /*0xffe1ce1f*/
if ( v6 ) /*0xffe1ce26*/
(*(void ( **)(const char *, int, const char *))(v6 + 4))( /*0xffe1ce37*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1497,
"!EFI_ERROR (Status)");
}
v7 = LogAuthorityPCREvent((int)n17, n2); /*0xffe1ce41*/
if ( v7 < 0 ) /*0xffe1ce48*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0xffe1ce55*/
v8 = AssertReport(); /*0xffe1ce5d*/
if ( v8 ) /*0xffe1ce64*/
(*(void ( **)(const char *, int, const char *))(v8 + 4))( /*0xffe1ce79*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1499,
"!EFI_ERROR (Status)");
}
goto LABEL_27; /*0xffe1ce7c*/
}
if ( LogTpm20LocalityStartupEvent((int)n17, n2) < 0 )
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1507);
if ( n2 == 1 )
{
if ( LogTxtTpm12CRTMEvent(n17) >= 0 )
{
LABEL_27:
DebugPrintWrapper(64, "BootGuardTCG2.c[%d]: End of BootGuardTcg2MeasureCRTMVersion\n", 1524);
goto LABEL_28; /*0xffe1cefa*/
}
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1513);
}
if ( (n2 == 2 || n2 == 3) && LogTxtTpm20CRTMEvent(n17) < 0 )
DebugPrintWrapper(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1520);
goto LABEL_27; /*0xffe1cee6*/
}
DebugPrintWrapper(64, "[BootGuardTCG2.c] Bit 63 fail in 0xFED300A0\n"); /*0xffe1cd73*/
v2 = __readmsr(0x13Au); /*0xffe1cd7f*/
if ( (v2 & 0x20) != 0 ) /*0xffe1cd86*/
goto LABEL_7; /*0xffe1cd86*/
LABEL_28:
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe1cf18*/
LogBootGuardTpm20Event(n17, v10[0]); /*0xffe1cf20*/
else
LocateTcgPpi(n17); /*0xffe1cf09*/
return 0; /*0xffe1cf25*/
}
int HobGetBaseAddress()
{
unsigned __int8 v0; // al
char n3; // al
char n3_1; // cl
v0 = __inbyte(0x70u); /*0xffe1cf34*/
__outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffe1cf39*/
n3 = __inbyte(0x71u); /*0xffe1cf40*/
n3_1 = n3; /*0xffe1cf41*/
if ( (unsigned __int8)n3 <= 3u ) /*0xffe1cf46*/
{
LABEL_4:
if ( !n3_1 ) /*0xffe1cf61*/
return 0; /*0xffe1cf61*/
goto LABEL_5; /*0xffe1cf61*/
}
n3_1 = n3; /*0xffe1cf48*/
if ( !n3 ) /*0xffe1cf50*/
{
n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffe1cf5c*/
goto LABEL_4; /*0xffe1cf5c*/
}
LABEL_5:
if ( n3_1 != -1 )
return n3_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffe1cf79*/
}
int HobGetNext()
{
int v0; // esi
_BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF
int v3; // [esp+6h] [ebp-6h]
HobGetEnd(v2); /*0xffe1cf86*/
v0 = *(_DWORD *)(v3 - 4); /*0xffe1cf8e*/
if ( !v0 ) /*0xffe1cf93*/
DebugVPrint( /*0xffe1cfa2*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
"PeiServices != ((void *) 0)");
return v0; /*0xffe1cfaa*/
}
__int64 __thiscall HobGetType(void *this)
{
int v2; // eax
if ( !this ) /*0xffe1cfb4*/
{
v2 = AssertReport(); /*0xffe1cfb6*/
if ( v2 ) /*0xffe1cfbd*/
(*(void ( **)(const char *, int, const char *))(v2 + 4))( /*0xffe1cfce*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffe1cfd9*/
}
int ReadUnaligned32(int Type, int a2)
{
_DWORD *v2; // ecx
_DWORD *v3; // esi
int v4; // eax
v3 = v2; /*0xffe1cfdc*/
if ( !v2 ) /*0xffe1cfe0*/
{
v4 = AssertReport(); /*0xffe1cfe2*/
if ( v4 ) /*0xffe1cfe9*/
(*(void ( **)(const char *, int, const char *))(v4 + 4))( /*0xffe1cffa*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
219,
"Buffer != ((void *) 0)");
}
*v3 = Type; /*0xffe1d008*/
v3[1] = a2; /*0xffe1d00a*/
return Type; /*0xffe1d00d*/
}
void *__thiscall HobGetEnd(void *this)
{
void *this_1; // eax
if ( !this ) /*0xffe1d015*/
DebugVPrint((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, "Idtr != ((void *) 0)"); /*0xffe1d024*/
this_1 = this; /*0xffe1d02a*/
__sidt(this); /*0xffe1d02d*/
return this_1; /*0xffe1d031*/
}
int PeiServicesLocateHob()
{
int Next; // eax
int v1; // eax
int v2; // eax
int v3; // eax
int v5; // [esp+4h] [ebp-4h] BYREF
Next = HobGetNext(); /*0xffe1d054*/
v1 = (*(int ( **)(int, int *))(*(_DWORD *)Next + 48))(Next, &v5); /*0xffe1d060*/
if ( v1 < 0 ) /*0xffe1d06c*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0xffe1d079*/
v2 = AssertReport(); /*0xffe1d081*/
if ( v2 ) /*0xffe1d088*/
(*(void ( **)(const char *, int, const char *))(v2 + 4))( /*0xffe1d092*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
50,
"!EFI_ERROR (Status)");
}
if ( !v5 ) /*0xffe1d09c*/
{
v3 = AssertReport(); /*0xffe1d09e*/
if ( v3 ) /*0xffe1d0a5*/
(*(void ( **)(const char *, int, const char *))(v3 + 4))( /*0xffe1d0af*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
51,
"HobList != ((void *) 0)");
}
return v5; /*0xffe1d0b8*/
}
_WORD *GetHobList(int a1, _WORD *a2)
{
_WORD *v2; // esi
int v3; // eax
v2 = a2; /*0xffe1d0be*/
if ( !a2 ) /*0xffe1d0c2*/
{
v3 = AssertReport(); /*0xffe1d0c4*/
if ( v3 ) /*0xffe1d0cb*/
(*(void ( **)(const char *, int, const char *))(v3 + 4))( /*0xffe1d0d9*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
82,
"HobStart != ((void *) 0)");
}
while ( 1 ) /*0xffe1d0f2*/
{
if ( *v2 == 0xFFFF ) /*0xffe1d0f8*/
return 0; /*0xffe1d0fd*/
if ( *v2 == 4 ) /*0xffe1d0ea*/
break; /*0xffe1d0ea*/
v2 = (_WORD *)((char *)v2 + (unsigned __int16)v2[1]); /*0xffe1d0f0*/
}
return v2; /*0xffe1d0fc*/
}
_WORD *GetHobFromAddress(int a1, _WORD *a2)
{
_WORD *HobList; // eax
_WORD *HobList_1; // esi
while ( 1 ) /*0xffe1d11d*/
{
HobList = GetHobList(a1, a2); /*0xffe1d11d*/
HobList_1 = HobList; /*0xffe1d122*/
if ( !HobList || HobIsSuitable(a1, (int)(HobList + 4)) ) /*0xffe1d10e*/
break; /*0xffe1d10e*/
a2 = (_WORD *)((char *)HobList_1 + (unsigned __int16)HobList_1[1]); /*0xffe1d11b*/
}
return HobList_1; /*0xffe1d128*/
}
_WORD *GetSystemConfiguration()
{
_WORD *Hob; // eax
Hob = (_WORD *)PeiServicesLocateHob(); /*0xffe1d12f*/
return GetHobFromAddress((int)&unk_FFE21668, Hob); /*0xffe1d141*/
}
int GetNextHob(int a1, int a2)
{
int Next; // eax
int v4; // eax
int v6; // [esp+4h] [ebp-4h] BYREF
Next = HobGetNext(); /*0xffe1d149*/
if ( (*(int ( **)(int, int, int, int *))(*(_DWORD *)Next + 52))(Next, 4, a2, &v6) < 0 ) /*0xffe1d161*/
v6 = 0; /*0xffe1d163*/
if ( !v6 ) /*0xffe1d16b*/
{
v4 = AssertReport(); /*0xffe1d16d*/
if ( v4 ) /*0xffe1d174*/
(*(void ( **)(const char *, int, const char *))(v4 + 4))( /*0xffe1d185*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
250,
"Hob != ((void *) 0)");
}
return v6; /*0xffe1d15e*/
}
int BuildGuidHob(int a1, unsigned int n0xFFE0)
{
int v3; // eax
int result; // eax
int v5; // esi
if ( n0xFFE0 > 0xFFE0 ) /*0xffe1d19b*/
{
v3 = AssertReport(); /*0xffe1d19d*/
if ( v3 ) /*0xffe1d1a4*/
(*(void ( **)(const char *, int, const char *))(v3 + 4))( /*0xffe1d1b5*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
421,
"DataLength <= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE))");
}
result = GetNextHob(a1, n0xFFE0 + 24); /*0xffe1d1be*/
v5 = result; /*0xffe1d1c3*/
if ( result ) /*0xffe1d1c7*/
{
GetHobLength(result + 8, (int)&unk_FFE21668); /*0xffe1d1d3*/
return v5 + 24; /*0xffe1d1d8*/
}
return result; /*0xffe1d1c9*/
}
void *GetEndOfHobList(void *buf, unsigned int count)
{
int v4; // eax
if ( count - 1 > -1 - (int)buf ) /*0xffe1d1ee*/
{
v4 = AssertReport(); /*0xffe1d1f0*/
if ( v4 ) /*0xffe1d1f7*/
(*(void ( **)(const char *, int, const char *))(v4 + 4))( /*0xffe1d205*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
54,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)Buffer)");
}
return ZeroMem(buf, count, 0); /*0xffe1d217*/
}
int GetHobLength(int a1, int a2)
{
__int64 Type; // rax
__int64 Type_1; // rax
Type = HobGetType((void *)a2); /*0xffe1d223*/
ReadUnaligned32(Type, SHIDWORD(Type)); /*0xffe1d22c*/
Type_1 = HobGetType((void *)(a2 + 8)); /*0xffe1d234*/
ReadUnaligned32(Type_1, SHIDWORD(Type_1)); /*0xffe1d23e*/
return a1; /*0xffe1d248*/
}
bool HobIsSuitable(int a1, int a2)
{
__int64 Type; // rax
int Type_1; // ebp
__int64 Type_3; // rax
int Type_2; // edi
__int64 v8; // kr00_8
__int64 v9; // rax
int v11; // [esp+10h] [ebp-Ch]
int v12; // [esp+14h] [ebp-8h]
Type = HobGetType((void *)a1); /*0xffe1d256*/
v12 = HIDWORD(Type); /*0xffe1d25d*/
Type_1 = Type; /*0xffe1d261*/
Type_3 = HobGetType((void *)a2); /*0xffe1d263*/
v11 = HIDWORD(Type_3); /*0xffe1d26b*/
Type_2 = Type_3; /*0xffe1d26f*/
v8 = HobGetType((void *)(a1 + 8)); /*0xffe1d27d*/
v9 = HobGetType((void *)(a2 + 8)); /*0xffe1d27f*/
return Type_1 == Type_2 && v12 == v11 && v8 == v9; /*0xffe1d2a2*/
}
int IoWrite16(unsigned __int16 *a1)
{
int v2; // eax
if ( ((unsigned __int8)a1 & 1) != 0 ) /*0xffe1d2b0*/
{
v2 = AssertReport(); /*0xffe1d2b2*/
if ( v2 ) /*0xffe1d2b9*/
(*(void ( **)(const char *, int, const char *))(v2 + 4))( /*0xffe1d2ca*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
151,
"(Address & 1) == 0");
}
return *a1; /*0xffe1d2d6*/
}
void *GetFirstGuidHob(int FitEntryIndex, unsigned __int8 **p_src, int *p_n256, char *DigestBuffer)
{
int v6; // edi
_DWORD buf[28]; // [esp+10h] [ebp-70h] BYREF
PeiPcdLocateProtocol(buf); /*0xffe1d318*/
if ( FitEntryIndex ) /*0xffe1d31f*/
{
v6 = (char *)p_n256 - (char *)p_src; /*0xffe1d324*/
do /*0xffe1d33a*/
{
PeiPcdGetSize((int)buf, *p_src, *(unsigned int *)((char *)p_src + v6)); /*0xffe1d32e*/
++p_src; /*0xffe1d333*/
--FitEntryIndex; /*0xffe1d337*/
}
while ( FitEntryIndex ); /*0xffe1d33a*/
}
PeiPcdGetPtr(buf, DigestBuffer, FitEntryIndex); /*0xffe1d342*/
return GetEndOfHobList(buf, 0x70u); /*0xffe1d352*/
}
int PeiPcdGetSize(int buf, unsigned __int8 *src, unsigned int n0x40)
{
unsigned int n0x40_1; // ebx
if ( *(_DWORD *)(buf + 40) > 0x40u ) /*0xffe1fbba*/
return -1; /*0xffe1fbbc*/
while ( 1 ) /*0xffe1fc22*/
{
do /*0xffe1fc22*/
{
while ( 1 ) /*0xffe1fc40*/
{
if ( !n0x40 ) /*0xffe1fc42*/
return 0; /*0xffe1fc44*/
if ( *(_DWORD *)(buf + 40) || n0x40 < 0x40 ) /*0xffe1fbd5*/
break; /*0xffe1fbd5*/
if ( GetNextGuidHob((_DWORD *)buf, src) < 0 ) /*0xffe1fbe2*/
return -1; /*0xffe1fbe2*/
*(_QWORD *)buf += 512LL; /*0xffe1fbe4*/
src += 64; /*0xffe1fbee*/
n0x40 -= 64; /*0xffe1fbf1*/
}
n0x40_1 = 64 - *(_DWORD *)(buf + 40); /*0xffe1fbf9*/
if ( n0x40 < n0x40_1 ) /*0xffe1fbfe*/
n0x40_1 = n0x40; /*0xffe1fc00*/
if ( n0x40_1 ) /*0xffe1fc04*/
CopyMem((char *)(buf + *(_DWORD *)(buf + 40) + 44), (char *)src, n0x40_1); /*0xffe1fc11*/
*(_DWORD *)(buf + 40) += n0x40_1; /*0xffe1fc17*/
src += n0x40_1; /*0xffe1fc1a*/
n0x40 -= n0x40_1; /*0xffe1fc1c*/
}
while ( *(_DWORD *)(buf + 40) != 64 ); /*0xffe1fc22*/
if ( GetNextGuidHob((_DWORD *)buf, (unsigned __int8 *)(buf + 44)) < 0 ) /*0xffe1fc30*/
break; /*0xffe1fc30*/
*(_QWORD *)buf += 512LL; /*0xffe1fc32*/
*(_DWORD *)(buf + 40) = 0; /*0xffe1fc3c*/
}
return -1; /*0xffe1fc48*/
}
// local variable allocation has failed, the output may be wrong!
int __usercall PeiPcdGetPtr@<eax>(_DWORD *buf@<ecx>, _BYTE *DigestBuffer@<edx>, int FitEntryIndex@<ebx>)
{
unsigned int n0x40; // ecx
bool v7; // cf
unsigned int n0x40_1; // eax
__int64 v9; // rax
__int64 v10; // rax
_BYTE v11[12]; // [esp-4h] [ebp-Ch] OVERLAPPED
n0x40 = buf[10]; /*0xffe1fc56*/
if ( n0x40 >= 0x40 ) /*0xffe1fc5c*/
return -1; /*0xffe1fc5e*/
*(_DWORD *)v11 = FitEntryIndex; /*0xffe1fc66*/
v7 = __CFADD__(8 *n0x40, *buf); /*0xffe1fc6c*/
*buf += 8 *n0x40; /*0xffe1fc6c*/
buf[1] += v7; /*0xffe1fc71*/
*((_BYTE *)buf + n0x40 + 44) = 0x80; /*0xffe1fc74*/
n0x40_1 = ++buf[10]; /*0xffe1fc7c*/
if ( n0x40_1 > 0x38 ) /*0xffe1fc82*/
{
while ( n0x40_1 < 0x40 ) /*0xffe1fc93*/
{
*((_BYTE *)buf + n0x40_1 + 44) = 0; /*0xffe1fc86*/
n0x40_1 = ++buf[10]; /*0xffe1fc8d*/
}
GetNextGuidHob(buf, (unsigned __int8 *)buf + 44); /*0xffe1fc9a*/
buf[10] = 0; /*0xffe1fc9f*/
}
while ( buf[10] < 0x38u ) /*0xffe1fcb2*/
*((_BYTE *)buf + buf[10]++ + 44) = 0; /*0xffe1fca7*/
*((_BYTE *)buf + 100) = *((_BYTE *)buf + 7); /*0xffe1fcb9*/
*((_BYTE *)buf + 101) = *((_BYTE *)buf + 6); /*0xffe1fcbf*/
v9 = *(_QWORD *)v11 % *(_QWORD *)&v11[8]; /*0xffe1fcc7*/
*((_BYTE *)buf + 102) = v9; /*0xffe1fccc*/
v10 = *(_QWORD *)v11 % *(_QWORD *)&v11[8]; /*0xffe1fcd6*/
*((_BYTE *)buf + 103) = v10; /*0xffe1fcdb*/
*((_BYTE *)buf + 104) = HIBYTE(*buf); /*0xffe1fced*/
*((_BYTE *)buf + 105) = BYTE2(*buf); /*0xffe1fcfc*/
*((_BYTE *)buf + 106) = BYTE1(*(_QWORD *)buf); /*0xffe1fd0b*/
*((_BYTE *)buf + 107) = *(_BYTE *)buf; /*0xffe1fd12*/
GetNextGuidHob(buf, (unsigned __int8 *)buf + 44); /*0xffe1fd15*/
*DigestBuffer = *((_BYTE *)buf + 11); /*0xffe1fd1d*/
DigestBuffer[1] = *((_BYTE *)buf + 10); /*0xffe1fd22*/
DigestBuffer[2] = *((_BYTE *)buf + 9); /*0xffe1fd28*/
DigestBuffer[3] = *((_BYTE *)buf + 8); /*0xffe1fd2e*/
DigestBuffer[4] = *((_BYTE *)buf + 15); /*0xffe1fd34*/
DigestBuffer[5] = *((_BYTE *)buf + 14); /*0xffe1fd3a*/
DigestBuffer[6] = *((_BYTE *)buf + 13); /*0xffe1fd40*/
DigestBuffer[7] = *((_BYTE *)buf + 12); /*0xffe1fd46*/
DigestBuffer[8] = *((_BYTE *)buf + 19); /*0xffe1fd4c*/
DigestBuffer[9] = *((_BYTE *)buf + 18); /*0xffe1fd52*/
DigestBuffer[10] = *((_BYTE *)buf + 17); /*0xffe1fd58*/
DigestBuffer[11] = *((_BYTE *)buf + 16); /*0xffe1fd5e*/
DigestBuffer[12] = *((_BYTE *)buf + 23); /*0xffe1fd64*/
DigestBuffer[13] = *((_BYTE *)buf + 22); /*0xffe1fd6a*/
DigestBuffer[14] = *((_BYTE *)buf + 21); /*0xffe1fd70*/
DigestBuffer[15] = *((_BYTE *)buf + 20); /*0xffe1fd76*/
DigestBuffer[16] = *((_BYTE *)buf + 27); /*0xffe1fd7c*/
DigestBuffer[17] = *((_BYTE *)buf + 26); /*0xffe1fd82*/
DigestBuffer[18] = *((_BYTE *)buf + 25); /*0xffe1fd88*/
DigestBuffer[19] = *((_BYTE *)buf + 24); /*0xffe1fd8e*/
DigestBuffer[20] = *((_BYTE *)buf + 31); /*0xffe1fd94*/
DigestBuffer[21] = *((_BYTE *)buf + 30); /*0xffe1fd9a*/
DigestBuffer[22] = *((_BYTE *)buf + 29); /*0xffe1fda0*/
DigestBuffer[23] = *((_BYTE *)buf + 28); /*0xffe1fda6*/
DigestBuffer[24] = *((_BYTE *)buf + 35); /*0xffe1fdac*/
DigestBuffer[25] = *((_BYTE *)buf + 34); /*0xffe1fdb2*/
DigestBuffer[26] = *((_BYTE *)buf + 33); /*0xffe1fdb8*/
DigestBuffer[27] = *((_BYTE *)buf + 32); /*0xffe1fdbe*/
DigestBuffer[28] = *((_BYTE *)buf + 39); /*0xffe1fdc4*/
DigestBuffer[29] = *((_BYTE *)buf + 38); /*0xffe1fdca*/
DigestBuffer[30] = *((_BYTE *)buf + 37); /*0xffe1fdd0*/
DigestBuffer[31] = *((_BYTE *)buf + 36); /*0xffe1fdd6*/
return 0; /*0xffe1fddc*/
}
int PeiPcdSetSku(int n2, int n50563599, int n2a, int a4, int a5)
{
int Next; // eax
int v9; // eax
if ( (unsigned __int8)n2 != 2 && (unsigned __int8)n2 != 3 ) /*0xffe1fdf0*/
return -2147483645; /*0xffe1fdf2*/
Next = HobGetNext(); /*0xffe1fdf9*/
v9 = (*(int ( **)(int, int, int, _DWORD, int, int))(*(_DWORD *)Next + 88))(Next, n2, n50563599, 0, a4, a5); /*0xffe1fe0d*/
return v9 != -1610612734 ? v9 : 0;
}
int __thiscall PeiGetPcdPtr(void *this)
{
int ( **PcdProtocol)(int); // eax
PcdProtocol = (int ( **)(int))PeiPcdLibLocatePcdProtocol(this); /*0xffe1fe24*/
return PcdProtocol[4](5); /*0xffe1fe2f*/
}
int __thiscall PeiWriteIoPort(void *this)
{
int v1; // ebx
int v2; // eax
v1 = PeiGetPcdPtr(this) + 1024064; /*0xffe1d2d9*/
if ( (v1 & 1) != 0 ) /*0xffe1d2de*/
{
v2 = AssertReport(); /*0xffe1d2e0*/
if ( v2 ) /*0xffe1d2e7*/
(*(void ( **)(const char *, int, const char *))(v2 + 4))( /*0xffe1d2f8*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
183,
"(Address & 1) == 0");
}
*(_WORD *)v1 = 1280; /*0xffe1d303*/
return 1280; /*0xffe1d307*/
}
void *__thiscall PeiPcdLibLocatePcdProtocol(void *this)
{
int Next; // eax
int v2; // eax
int v3; // eax
void *this_1; // [esp+0h] [ebp-4h]
this_1 = this; /*0xffe1fe44*/
Next = HobGetNext(); /*0xffe1fe45*/
v2 = (*(int (__stdcall **)(int))(*(_DWORD *)Next + 32))(Next); /*0xffe1fe5a*/
if ( v2 < 0 ) /*0xffe1fe62*/
{
DebugPrintWrapper(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0xffe1fe6f*/
v3 = AssertReport(); /*0xffe1fe77*/
if ( v3 ) /*0xffe1fe7e*/
(*(void ( **)(const char *, int, const char *))(v3 + 4))( /*0xffe1fe8c*/
"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
49,
"!EFI_ERROR (Status)");
}
return this_1; /*0xffe1fe97*/
}