#include "AmiTpm20PlatformPei.h"
//
// AmiTpm20PlatformPei - UEFI Module (Regenerated from IDA)
// Total functions: 100
//
// Function: RdRand16 @ 0xffe21c74 (0x15 bytes)
// Index: 1/100
int __cdecl RdRand16(_WORD *a1)
{
__asm { rdrand eax } /*0xffe21c74*/
if ( !_CF ) /*0xffe21c77*/
return 0; /*0xffe21c79*/
*a1 = _EAX; /*0xffe21c80*/
return 1; /*0xffe21c7b*/
}
// Function: BaseCopyMem @ 0xffe21cc4 (0x3f bytes)
// Index: 2/100
char *__cdecl BaseCopyMem(char *dst, char *src, unsigned int count)
{
unsigned int count_1; // edx
char *dst_1; // edi
char *src_1; // esi
count_1 = count; /*0xffe21cce*/
if ( src < dst && &src[count - 1] >= dst ) /*0xffe21cdc*/
{
src_1 = &src[count - 1]; /*0xffe21cf0*/
dst_1 = &dst[count - 1]; /*0xffe21cf2*/
}
else
{
count_1 = count & 3; /*0xffe21ce0*/
qmemcpy(dst, src, 4 * (count >> 2)); /*0xffe21ce9*/
src_1 = &src[4 * (count >> 2)]; /*0xffe21ce9*/
dst_1 = &dst[4 * (count >> 2)]; /*0xffe21ce9*/
}
qmemcpy(dst_1, src_1, count_1); /*0xffe21cf9*/
return dst; /*0xffe21d00*/
}
// Function: BaseSetMem8 @ 0xffe21d04 (0x15 bytes)
// Index: 3/100
void *__cdecl BaseSetMem8(void *buf, unsigned int count, char value)
{
memset(buf, value, count); /*0xffe21d11*/
return buf; /*0xffe21d17*/
}
// Function: BaseDivU64x32Remainder @ 0xffe21d44 (0x1f bytes)
// Index: 4/100
int __cdecl BaseDivU64x32Remainder(int a1, int a2, int a3, int a4)
{
do /*0xffe21d5d*/
{
*(_DWORD *)(a1 + 8 * a2 - 8) = a3; /*0xffe21d55*/
*(_DWORD *)(a1 + 8 * a2-- - 4) = a4; /*0xffe21d59*/
}
while ( a2 ); /*0xffe21d5d*/
return a1; /*0xffe21d61*/
}
// Function: BaseSetMem32 @ 0xffe21d64 (0x15 bytes)
// Index: 5/100
void *__cdecl BaseSetMem32(void *buf, unsigned int count, int value)
{
memset32(buf, value, count); /*0xffe21d71*/
return buf; /*0xffe21d77*/
}
// Function: _ModuleEntryPoint @ 0xffe21e04 (0x30 bytes)
// Index: 6/100
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
void *v2; // ecx
void *PcdFlags; // ecx
void *v4; // ecx
_BYTE *PcdFlagsPtr; // eax
if ( *(char *)(LibPcdGet32(v2) + 1024068) >= 0 ) /*0xffe21e15*/
{
LibPcdSet32(PcdFlags); /*0xffe21e17*/
PcdFlagsPtr = (_BYTE *)(LibPcdGet32(v4) + 1024068); /*0xffe21e21*/
LOBYTE(PcdFlags) = *PcdFlagsPtr | 0x80; /*0xffe21e25*/
*PcdFlagsPtr = (_BYTE)PcdFlags; /*0xffe21e28*/
}
return AmiTpm20PlatformPeiEntry((int)PcdFlags, (int *)SystemTable); /*0xffe21e2e*/
}
// Function: AmiTpm20GetPpiPointer @ 0xffe21e34 (0xc9 bytes)
// Index: 7/100
int __fastcall AmiTpm20GetPpiPointer(int PeiServices, int PpiDescriptor, int Instance)
{
int Status; // eax
_DWORD *PpiData; // ecx
int Index; // edi
int result; // eax
int PpiNotifyDesc; // [esp+10h] [ebp-8h] BYREF
int PpiInstance; // [esp+14h] [ebp-4h] BYREF
PpiNotifyDesc = 0; /*0xffe21e36*/
if ( !PeiServices || !*(_DWORD *)PeiServices || !PpiDescriptor ) /*0xffe21e56*/
return -2147483646; /*0xffe21ef1*/
Status = (*(int (__cdecl **)(int, int, int *))(*(_DWORD *)PeiServices + 76))(PeiServices, 22, &PpiNotifyDesc); /*0xffe21e64*/
PpiData = (_DWORD *)PpiNotifyDesc; /*0xffe21e67*/
if ( !PpiNotifyDesc || Status < 0 ) /*0xffe21e74*/
return -2147483639; /*0xffe21eea*/
Index = 0; /*0xffe21e7a*/
while ( 1 ) /*0xffe21e7c*/
{
PpiInstance = Instance; /*0xffe21e7c*/
*PpiData = 22; /*0xffe21e80*/
*(_DWORD *)(PpiNotifyDesc + 4) = 14; /*0xffe21e8f*/
*(_WORD *)(PpiNotifyDesc + 8) = 1; /*0xffe21e9a*/
*(_DWORD *)(PpiNotifyDesc + 10) = Index; /*0xffe21ea2*/
*(_DWORD *)(PpiNotifyDesc + 14) = 4; /*0xffe21ea9*/
(*(void (__cdecl **)(int, int *, int))(*(_DWORD *)PeiServices + 80))(PpiNotifyDesc + 18, &PpiInstance, 4); /*0xffe21ebf*/
result = (*(int (__cdecl **)(int, _DWORD, _DWORD, int *, _DWORD, int, _DWORD, int))(PpiDescriptor + 8))( /*0xffe21ed4*/
PpiDescriptor,
0,
0,
&PpiInstance,
0,
4,
0,
PpiNotifyDesc);
if ( result < 0 ) /*0xffe21edc*/
break; /*0xffe21edc*/
if ( (unsigned int)++Index >= 8 ) /*0xffe21ee2*/
break; /*0xffe21ee2*/
PpiData = (_DWORD *)PpiNotifyDesc; /*0xffe21ee4*/
}
return result; /*0xffe21ef6*/
}
// Function: AmiTpm20GetTrEEProtocol @ 0xffe21efd (0x30 bytes)
// Index: 8/100
int __fastcall AmiTpm20GetTrEEProtocol(int TrEEProtocolInstance, int CmdBuffer)
{
ReadUnaligned32((_DWORD *)CmdBuffer, 150995008); /*0xffe21f08*/
WriteUnaligned16((_WORD *)(CmdBuffer + 4), 0); /*0xffe21f12*/
*(_BYTE *)(CmdBuffer + 6) = 0; /*0xffe21f19*/
WriteUnaligned16((_WORD *)(CmdBuffer + 7), 0); /*0xffe21f20*/
return 9; /*0xffe21f2a*/
}
// Function: AmiTpm20SubmitCommand @ 0xffe21f2d (0x137 bytes)
// Index: 9/100
int __fastcall AmiTpm20SubmitCommand(int TrEEProtocolInstance, unsigned int CommandCode)
{
unsigned int TpmTag; // eax
_BYTE *CmdBufPtr; // edi
unsigned int CmdBufSize; // edi
int Status; // eax
int Result; // esi
int ResponseSizeSwapped; // eax
int ResponseCodeSwapped; // eax
__int16 TpmSessionTag; // [esp+10h] [ebp-13Ch] BYREF
unsigned __int32 CmdSizeSwapped; // [esp+12h] [ebp-13Ah]
int CmdOrdinal; // [esp+16h] [ebp-136h]
int RcVal; // [esp+1Ah] [ebp-132h]
unsigned __int32 CmdTagSwapped; // [esp+1Eh] [ebp-12Eh]
int CmdBuffer[35]; // [esp+22h] [ebp-12Ah] BYREF
_BYTE RespBuffer[2]; // [esp+B0h] [ebp-9Ch] BYREF
unsigned int RespHeaderRaw; // [esp+B2h] [ebp-9Ah]
unsigned int RespCodeRaw; // [esp+B6h] [ebp-96h]
CmdOrdinal = 553713664; /*0xffe21f45*/
TpmSessionTag = 640; /*0xffe21f52*/
RcVal = 201326656; /*0xffe21f59*/
TpmTag = AmiTpm20GetTrEEProtocol(TrEEProtocolInstance, (int)CmdBuffer); /*0xffe21f61*/
CmdBufPtr = (char *)CmdBuffer + TpmTag; /*0xffe21f6a*/
CmdTagSwapped = _byteswap_ulong(TpmTag); /*0xffe21f72*/
ReadUnaligned32((int *)((char *)CmdBuffer + TpmTag), _byteswap_ulong(CommandCode)); /*0xffe21f78*/
CmdBufPtr += 4; /*0xffe21f7d*/
*CmdBufPtr = 0; /*0xffe21f89*/
CmdBufSize = CmdBufPtr - (_BYTE *)&TpmSessionTag + 1; /*0xffe21f8e*/
CmdSizeSwapped = _byteswap_ulong(CmdBufSize); /*0xffe21f93*/
Status = (*(int (__cdecl **)(int, unsigned int, __int16 *, int, _BYTE *))(TrEEProtocolInstance + 12))( /*0xffe21fa7*/
TrEEProtocolInstance,
CmdBufSize,
&TpmSessionTag,
147,
RespBuffer);
Result = Status; /*0xffe21faa*/
if ( Status >= 0 )
{
ResponseSizeSwapped = (RespHeaderRaw & 0xFF00 | (RespHeaderRaw << 16)) << 8; /*0xffe21ff5*/
if ( (ResponseSizeSwapped | ((HIWORD(RespHeaderRaw) | RespHeaderRaw & 0xFF0000) >> 8)) <= 0x93 )
{
ResponseCodeSwapped = (RespCodeRaw & 0xFF00 | (RespCodeRaw << 16)) << 8; /*0xffe22036*/
if ( ResponseCodeSwapped | ((HIWORD(RespCodeRaw) | RespCodeRaw & 0xFF0000) >> 8) )
{
DebugPrint(
0x80000000,
"HierarchyControl: Response Code error! 0x%08x\r\n",
ResponseCodeSwapped | ((HIWORD(RespCodeRaw) | RespCodeRaw & 0xFF0000) >> 8));
return -2147483641; /*0xffe22050*/
}
else
{
return 0; /*0xffe22057*/
}
}
else
{
DebugPrint(
0x80000000,
"HierarchyControl: Response size too large! %d\r\n",
ResponseSizeSwapped | ((HIWORD(RespHeaderRaw) | RespHeaderRaw & 0xFF0000) >> 8));
return -2147483643; /*0xffe22011*/
}
}
else
{
DebugPrint(0x80000000, "Tpm2GetRandom TrEEProtocolInstance->SubmitCommand = %r \n", Status); /*0xffe21fbe*/
return Result; /*0xffe21fc6*/
}
}
// Function: AmiTpm20CreateTpmHob @ 0xffe22064 (0x56 bytes)
// Index: 10/100
int __fastcall AmiTpm20CreateTpmHob(int PeiServices, _DWORD *TpmHobData, int DataSize, _DWORD *HobBuffer)
{
int Status; // eax
int Result; // esi
_DWORD *HobDataCursor; // edi
Status = (*(int (__cdecl **)(int, int, int, _DWORD *))(*(_DWORD *)PeiServices + 52))( /*0xffe2207b*/
PeiServices,
4,
DataSize + 24,
HobBuffer);
Result = Status; /*0xffe2207e*/
if ( Status >= 0 ) /*0xffe22085*/
{
DebugPrint(64, "Hob created \n"); /*0xffe220a2*/
HobDataCursor = (_DWORD *)(*HobBuffer + 8); /*0xffe220ab*/
*HobDataCursor++ = *TpmHobData; /*0xffe220b2*/
*HobDataCursor++ = TpmHobData[1]; /*0xffe220b3*/
*HobDataCursor = TpmHobData[2]; /*0xffe220b4*/
HobDataCursor[1] = TpmHobData[3]; /*0xffe220b5*/
return 0; /*0xffe220ae*/
}
else
{
DebugPrint(64, "Failed to create TCG/TPM Hob Status = %r \n", Status); /*0xffe2208f*/
return Result; /*0xffe22097*/
}
}
// Function: MeasureLogDxeFwVol @ 0xffe220ba (0x355 bytes)
// Index: 11/100
int __fastcall MeasureLogDxeFwVol(
int this,
int *a2,
int a3,
int (__cdecl **a4)(int, int, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD *, _DWORD *))
{
int v5; // ebp
int v6; // eax
int *p_src; // edi
char n2; // cl
int v9; // ebx
int v10; // eax
int v11; // esi
int v12; // esi
char n2_1; // [esp+17h] [ebp-3EDh]
int v15; // [esp+18h] [ebp-3ECh]
_DWORD v17[4]; // [esp+20h] [ebp-3E4h] BYREF
_DWORD buf_1[24]; // [esp+30h] [ebp-3D4h] BYREF
_BYTE buf[112]; // [esp+90h] [ebp-374h] BYREF
_DWORD v20[3]; // [esp+100h] [ebp-304h] BYREF
__int16 n4; // [esp+10Ch] [ebp-2F8h]
char dst[328]; // [esp+10Eh] [ebp-2F6h] BYREF
int n16; // [esp+256h] [ebp-1AEh]
int v24[52]; // [esp+260h] [ebp-1A4h] BYREF
int v25[53]; // [esp+330h] [ebp-D4h] BYREF
v5 = 0; /*0xffe220d6*/
DebugPrint(64, "[%d] Enter MeasureLogDxeFwVol\n", 555); /*0xffe220d8*/
v6 = *a2; /*0xffe220dd*/
p_src = a2 + 3; /*0xffe220df*/
n2 = *((_BYTE *)a2 + 4); /*0xffe220e2*/
v20[0] = 0; /*0xffe220e7*/
v17[3] = 0; /*0xffe220ef*/
v9 = a2[2]; /*0xffe220f6*/
v15 = v6; /*0xffe220f9*/
v17[0] = a2[3]; /*0xffe220ff*/
v17[1] = a2[4]; /*0xffe22106*/
v10 = a2[5]; /*0xffe2210a*/
n2_1 = n2; /*0xffe2210d*/
v20[1] = 1; /*0xffe22111*/
n16 = 16; /*0xffe22118*/
v17[2] = v10; /*0xffe22123*/
if ( n2 == 1 ) /*0xffe22129*/
{
InitHashContext(buf_1); /*0xffe2212f*/
}
else if ( n2 == 2 ) /*0xffe22139*/
{
if ( (v9 & 1) != 0 ) /*0xffe2213d*/
InitHashContext(buf_1); /*0xffe22143*/
if ( (v9 & 2) != 0 ) /*0xffe2214b*/
InitHashContextSm3(buf); /*0xffe22154*/
if ( (v9 & 4) != 0 ) /*0xffe2215c*/
Tpm12HashAll(v24); /*0xffe22165*/
if ( (v9 & 8) != 0 ) /*0xffe2216d*/
Tpm20MettleHashAll(v25); /*0xffe22176*/
if ( (v9 & 0x10) != 0 ) /*0xffe2217e*/
InitHashContextSm3(buf); /*0xffe22187*/
}
v11 = v15; /*0xffe2218c*/
DebugPrint(64, "FwVolHobCount = %x \n", v15); /*0xffe22198*/
if ( v15 ) /*0xffe221a2*/
{
do /*0xffe2225f*/
{
DebugPrint(64, "TpmFwVolHob[i].Size = %x \n", p_src[2]); /*0xffe221b2*/
DebugPrint(64, "TpmFwVolHob[i].baseAddress = %lx \n", *p_src); /*0xffe221c6*/
if ( n2_1 == 1 ) /*0xffe221d4*/
{
HashUpdateSha256((int)buf_1, (char *)*p_src, p_src[2]); /*0xffe221df*/
}
else if ( n2_1 == 2 ) /*0xffe221e8*/
{
if ( (v9 & 2) != 0 ) /*0xffe221ec*/
HashUpdateSm3((int)buf, (unsigned __int8 *)*p_src, p_src[2]); /*0xffe221fa*/
if ( (v9 & 1) != 0 ) /*0xffe22203*/
HashUpdateSha256((int)buf_1, (char *)*p_src, p_src[2]); /*0xffe2220e*/
if ( (v9 & 4) != 0 ) /*0xffe22217*/
Tpm20MettleHashUpdate((int)v24, (char *)*p_src, p_src[2]); /*0xffe22225*/
if ( (v9 & 8) != 0 ) /*0xffe2222e*/
Tpm20MettleHashUpdate((int)v25, (char *)*p_src, p_src[2]); /*0xffe2223c*/
if ( (v9 & 0x10) != 0 ) /*0xffe22245*/
HashUpdateSm3((int)buf, (unsigned __int8 *)*p_src, p_src[2]); /*0xffe22253*/
}
p_src += 6; /*0xffe22259*/
--v11; /*0xffe2225c*/
}
while ( v11 ); /*0xffe2225f*/
}
if ( n2_1 == 1 ) /*0xffe2226b*/
{
HashUpdateSha1((int)src_1, buf_1); /*0xffe22278*/
CopyMem(dst, src_1, 0x14u); /*0xffe22288*/
n4 = 4; /*0xffe22291*/
}
else if ( n2_1 == 2 ) /*0xffe222a0*/
{
if ( (v9 & 1) != 0 ) /*0xffe222a9*/
{
HashUpdateSha1((int)src_2, buf_1); /*0xffe222b6*/
CopyMem(dst, src_2, 0x14u); /*0xffe222c6*/
n4 = 4; /*0xffe222d1*/
v5 = 1; /*0xffe222d9*/
}
if ( (v9 & 2) != 0 ) /*0xffe222dd*/
{
HashUpdateSha512(buf, src_3); /*0xffe222ed*/
CopyMem(&dst[66 * v5], src_3, 0x20u); /*0xffe22302*/
*(_WORD *)&dst[66 * v5++ - 2] = 11; /*0xffe2230b*/
}
if ( (v9 & 4) != 0 ) /*0xffe22317*/
{
Tpm12HashExport((int)v24, ::dst); /*0xffe22327*/
CopyMem(&dst[66 * v5], ::dst, 0x30u); /*0xffe2233c*/
*(_WORD *)&dst[66 * v5++ - 2] = 12; /*0xffe22345*/
}
if ( (v9 & 8) != 0 ) /*0xffe22351*/
{
Tpm20MettleHashComplete((int)v25, src_4); /*0xffe22361*/
CopyMem(&dst[66 * v5], src_4, 0x40u); /*0xffe22376*/
*(_WORD *)&dst[66 * v5++ - 2] = 13; /*0xffe2237f*/
}
if ( (v9 & 0x10) != 0 ) /*0xffe2238b*/
{
HashUpdateSha512(buf, src_5); /*0xffe2239b*/
CopyMem(&dst[66 * v5], src_5, 0x20u); /*0xffe223b0*/
*(_WORD *)&dst[66 * v5++ - 2] = 18; /*0xffe223b9*/
}
v20[2] = v5; /*0xffe223c2*/
}
v12 = (*a4)(this, a3, 0, 0, 0, 0, v20, v17); /*0xffe223f0*/
DebugPrint(64, "MeasureLogDxeFwVol - %r\n", v12); /*0xffe223fa*/
return v12; /*0xffe22404*/
}
// Function: Tpm2GetCapability @ 0xffe2240f (0xd2 bytes)
// Index: 12/100
int __cdecl Tpm2GetCapability(int n267, int a2, _BYTE *a3, char *dst)
{
int v4; // ecx
int result; // eax
int v6; // edx
int v7; // eax
_WORD v8[3]; // [esp+0h] [ebp-424h] BYREF
int v9; // [esp+6h] [ebp-41Eh]
char v10; // [esp+Ah] [ebp-41Ah]
char src[1025]; // [esp+Bh] [ebp-419h] BYREF
__int16 n384; // [esp+40Ch] [ebp-18h] BYREF
int v13; // [esp+40Eh] [ebp-16h]
int n2046885888; // [esp+412h] [ebp-12h]
int v15; // [esp+416h] [ebp-Eh]
int v16; // [esp+41Ah] [ebp-Ah]
int v17; // [esp+41Eh] [ebp-6h]
if ( !v4 ) /*0xffe2241c*/
return -2147483646; /*0xffe2241e*/
n2046885888 = 2046885888; /*0xffe22430*/
n384 = 384; /*0xffe22438*/
v15 = SwapBytes16(6); /*0xffe22444*/
v16 = SwapBytes16(n267); /*0xffe2244e*/
v17 = SwapBytes16(1); /*0xffe2245a*/
v13 = SwapBytes16(22); /*0xffe22462*/
result = (*(int (__cdecl **)(int, int, __int16 *, int, _WORD *))(v6 + 12))(v6, 22, &n384, 1035, v8); /*0xffe22478*/
if ( result >= 0 )
{
if ( v8[0] == 384 )
{
v7 = SwapBytes16(v9); /*0xffe22498*/
if ( v7 )
{
DebugPrint(0x80000000, "Tpm2GetCapability: Response Code error! 0x%08x\r\n", v7);
return -2147483641; /*0xffe224b4*/
}
else
{
*a3 = v10; /*0xffe224cf*/
CopyMem(dst, src, 0x400u); /*0xffe224d4*/
return 0; /*0xffe224da*/
}
}
else
{
return -2147483623; /*0xffe2248b*/
}
}
return result; /*0xffe224dd*/
}
// Function: Tpm2GetFwVersion @ 0xffe224e1 (0xaf bytes)
// Index: 13/100
int __fastcall Tpm2GetFwVersion(int a1, int *p_n458812, int *p_n1229346816)
{
int result; // eax
int v5; // eax
int v6; // ecx
int v7; // eax
char dst[12]; // [esp+10h] [ebp-40Ch] BYREF
int v9; // [esp+1Ch] [ebp-400h]
_BYTE v10[5]; // [esp+417h] [ebp-5h] BYREF
if ( !p_n458812 || !p_n1229346816 ) /*0xffe224fe*/
return -2147483646; /*0xffe22584*/
*p_n458812 = 0; /*0xffe22504*/
*p_n1229346816 = 0; /*0xffe2250d*/
result = Tpm2GetCapability(267, a1, v10, dst); /*0xffe2251b*/
if ( result >= 0 ) /*0xffe22525*/
{
v5 = SwapBytes16(v9); /*0xffe2252d*/
*p_n458812 = v5; /*0xffe2253a*/
DebugPrint(64, "\n TpmFwVersion1 = %x \n", v5); /*0xffe2253c*/
result = Tpm2GetCapability(268, v6, v10, dst); /*0xffe22557*/
if ( result >= 0 ) /*0xffe22561*/
{
v7 = SwapBytes16(v9); /*0xffe22569*/
*p_n1229346816 = v7; /*0xffe22576*/
DebugPrint(64, "\n TpmFwVersion2 = %x \n", v7); /*0xffe22578*/
return 0; /*0xffe22580*/
}
}
return result; /*0xffe22589*/
}
// Function: Tpm2SelfTest @ 0xffe22590 (0x196 bytes)
// Index: 14/100
int __fastcall Tpm2SelfTest(int a1, int *a2, int *a3, int *a4)
{
int Capability; // ebx
int p_n1229346816_1; // esi
int p_n1229346816_2; // eax
int p_n458812_1; // edx
int v11; // esi
int v12; // [esp-4h] [ebp-440h]
char v13; // [esp+17h] [ebp-425h] BYREF
int p_n1229346816; // [esp+18h] [ebp-424h] BYREF
__int16 n384; // [esp+1Ch] [ebp-420h] BYREF
int n184549376; // [esp+1Eh] [ebp-41Eh]
int n1124139008; // [esp+22h] [ebp-41Ah]
char v18; // [esp+26h] [ebp-416h]
int p_n458812; // [esp+28h] [ebp-414h] BYREF
_WORD buf[3]; // [esp+2Ch] [ebp-410h] BYREF
unsigned int v21; // [esp+32h] [ebp-40Ah]
char dst[12]; // [esp+38h] [ebp-404h] BYREF
int v23; // [esp+44h] [ebp-3F8h]
n184549376 = 184549376; /*0xffe2259d*/
n384 = 384; /*0xffe225a6*/
n1124139008 = 1124139008; /*0xffe225b2*/
if ( Tpm2GetFwVersion(a1, &p_n458812, &p_n1229346816) == -2147483623 ) /*0xffe225cc*/
return -2147483641; /*0xffe225ce*/
Capability = Tpm2GetCapability(261, v12, &v13, dst); /*0xffe225ed*/
if ( Capability >= 0 ) /*0xffe225f4*/
{
p_n1229346816_1 = SwapBytes16(v23); /*0xffe22605*/
DebugPrint(64, "\n ManufactureId = %x \n", p_n1229346816_1); /*0xffe2260f*/
Capability = 0; /*0xffe22617*/
}
else
{
p_n1229346816_1 = p_n1229346816; /*0xffe225f6*/
}
p_n1229346816_2 = p_n1229346816; /*0xffe22620*/
p_n458812_1 = p_n458812; /*0xffe22624*/
*a2 = p_n458812; /*0xffe22628*/
*a3 = p_n1229346816_2; /*0xffe2262b*/
*a4 = p_n1229346816_1; /*0xffe22634*/
if ( Capability >= 0 && p_n1229346816_1 == 1229346816 ) /*0xffe22640*/
{
if ( p_n458812_1 == 458812 || (v18 = 0, p_n458812_1 == 327740) ) /*0xffe22655*/
v18 = 1; /*0xffe22657*/
}
SetMem(buf, 0xAu); /*0xffe22663*/
DebugPrint(64, "\nsending TPM20 SelfTest To Tpm \n"); /*0xffe22671*/
v11 = (*(int (__cdecl **)(int, int, __int16 *, int, _WORD *))(a1 + 12))(a1, 11, &n384, 10, buf); /*0xffe22688*/
if ( v11 >= 0 ) /*0xffe2268f*/
{
if ( buf[0] == 384 ) /*0xffe226a2*/
{
if ( v21 ) /*0xffe226b0*/
v11 = -2147483642; /*0xffe226b2*/
}
else
{
v11 = -2147483641; /*0xffe226a4*/
}
DebugPrint(64, "SelfTestReponse.Tag = %x \n", (buf[0] << 8) | HIBYTE(buf[0])); /*0xffe226cb*/
DebugPrint( /*0xffe22702*/
64,
"SelfTestReponse.ResponseCode = %x \n",
((v21 & 0xFF00 | (v21 << 16)) << 8) | ((HIWORD(v21) | v21 & 0xFF0000) >> 8));
DebugPrint(64, "SelfTestReponse.Status = %r \n", v11); /*0xffe22711*/
}
return v11; /*0xffe2271b*/
}
// Function: Tpm2HierarchyChangeAuth @ 0xffe22726 (0x14d bytes)
// Index: 15/100
int __cdecl Tpm2HierarchyChangeAuth(int a1, char *p_n20)
{
int TrEEProtocolInstance; // ecx
int TrEEProtocolInstance_1; // ebx
unsigned int TrEEProtocol; // eax
char *v5; // esi
char *dst; // esi
unsigned int v7; // ecx
int result; // eax
int v9; // eax
int v10; // eax
__int16 n640; // [esp+10h] [ebp-174h] BYREF
unsigned __int32 v12; // [esp+12h] [ebp-172h]
int n687931392; // [esp+16h] [ebp-16Eh]
int n201326656; // [esp+1Ah] [ebp-16Ah]
unsigned __int32 v15; // [esp+1Eh] [ebp-166h]
int CmdBuffer[51]; // [esp+22h] [ebp-162h] BYREF
_BYTE v17[2]; // [esp+F0h] [ebp-94h] BYREF
unsigned int v18; // [esp+F2h] [ebp-92h]
unsigned int v19; // [esp+F6h] [ebp-8Eh]
v12 = -587202560; /*0xffe22734*/
n640 = 640; /*0xffe22741*/
TrEEProtocolInstance_1 = TrEEProtocolInstance; /*0xffe22746*/
n687931392 = 687931392; /*0xffe22748*/
n201326656 = 201326656; /*0xffe22750*/
TrEEProtocol = AmiTpm20GetTrEEProtocol(TrEEProtocolInstance, (int)CmdBuffer); /*0xffe22758*/
v5 = (char *)CmdBuffer + TrEEProtocol; /*0xffe22768*/
v15 = _byteswap_ulong(TrEEProtocol); /*0xffe2276e*/
WriteUnaligned16((int *)((char *)CmdBuffer + TrEEProtocol), __ROL2__(*(_WORD *)p_n20, 8)); /*0xffe22779*/
dst = v5 + 2; /*0xffe22781*/
if ( *(_WORD *)p_n20 ) /*0xffe2277e*/
CopyMem(dst, p_n20 + 2, *(unsigned __int16 *)p_n20); /*0xffe2278e*/
v7 = (unsigned int)&dst[*(unsigned __int16 *)p_n20 - (_DWORD)&n640]; /*0xffe227a2*/
v12 = _byteswap_ulong(v7); /*0xffe227a8*/
result = (*(int (__cdecl **)(int, unsigned int, __int16 *, int, _BYTE *))(TrEEProtocolInstance_1 + 12))( /*0xffe227bc*/
TrEEProtocolInstance_1,
v7,
&n640,
147,
v17);
if ( result >= 0 )
{
DebugPrint(0x80000000, "HierarchyChangeAuth: Response code %x\r\n", v19);
v9 = (v18 & 0xFF00 | (v18 << 16)) << 8; /*0xffe2280c*/
if ( (v9 | ((HIWORD(v18) | v18 & 0xFF0000) >> 8)) <= 0x93 )
{
v10 = (v19 & 0xFF00 | (v19 << 16)) << 8; /*0xffe22849*/
if ( v10 | ((HIWORD(v19) | v19 & 0xFF0000) >> 8) )
{
DebugPrint(
0x80000000,
"HierarchyChangeAuth: Response Code error! 0x%08x\r\n",
v10 | ((HIWORD(v19) | v19 & 0xFF0000) >> 8));
return -2147483641; /*0xffe2285f*/
}
else
{
return 0; /*0xffe22866*/
}
}
else
{
DebugPrint(
0x80000000,
"HierarchyChangeAuth: Response size too large! %d\r\n",
v9 | ((HIWORD(v18) | v18 & 0xFF0000) >> 8));
return -2147483643; /*0xffe22824*/
}
}
return result; /*0xffe22868*/
}
// Function: Tpm2GetRandom @ 0xffe22873 (0x182 bytes)
// Index: 16/100
int __usercall Tpm2GetRandom@<eax>(int a1@<edx>, unsigned int n0x40, char *dst)
{
int v5; // ebx
unsigned int v6; // esi
char *dst_1; // edi
int Msr64; // eax
int v9; // eax
int v10; // edi
int v11; // eax
_BYTE buf_1[6]; // [esp+8h] [ebp-70h] BYREF
unsigned int v13; // [esp+Eh] [ebp-6Ah]
char src[64]; // [esp+14h] [ebp-64h] BYREF
char v15[18]; // [esp+54h] [ebp-24h] BYREF
int n1229870147; // [esp+66h] [ebp-12h]
__int16 buf; // [esp+6Ch] [ebp-Ch] BYREF
int n201326592; // [esp+6Eh] [ebp-Ah]
int n2063663104; // [esp+72h] [ebp-6h]
__int16 v20; // [esp+76h] [ebp-2h]
if ( n0x40 > 0x40 ) /*0xffe22883*/
{
DebugPrint(0x80000000, "Tpm2GetRandom Error. Request too large\n"); /*0xffe2288f*/
return -2147483643; /*0xffe2289b*/
}
v15[0] = 22; /*0xffe228a4*/
v5 = (*(int (__cdecl **)(int, char *))a1)(a1, v15); /*0xffe228ac*/
if ( v5 < 0 ) /*0xffe228b2*/
{
DebugPrint(0x80000000, "TCG get Capability failed. Aborting. ..\n"); /*0xffe228be*/
return v5; /*0xffe228c7*/
}
DebugPrint(64, "ManufacturerID = %x\n", n1229870147); /*0xffe228d6*/
if ( n1229870147 == 1229870147 ) /*0xffe228e5*/
{
DebugPrint(0x80000000, "Matched. ..\n"); /*0xffe228f1*/
v6 = n0x40 >> 1; /*0xffe228f6*/
if ( n0x40 >> 1 ) /*0xffe228f6*/
{
dst_1 = dst; /*0xffe228fc*/
do /*0xffe22929*/
{
if ( !dst_1 ) /*0xffe22901*/
{
Msr64 = BaseReadMsr64(); /*0xffe22903*/
if ( Msr64 ) /*0xffe2290a*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe22918*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\X86RdRand.c",
35,
"Rand != ((void *) 0)");
}
RdRand16(dst_1++); /*0xffe2291f*/
--v6; /*0xffe22926*/
}
while ( v6 ); /*0xffe22929*/
}
return 0; /*0xffe2292b*/
}
else
{
SetMem(&buf, 0xCu); /*0xffe22938*/
SetMem(buf_1, 0x4Cu); /*0xffe22943*/
n2063663104 = 2063663104; /*0xffe2294d*/
buf = 384; /*0xffe22954*/
v20 = __ROL2__(n0x40, 8); /*0xffe2295f*/
n201326592 = 201326592; /*0xffe2296c*/
v9 = (*(int (__cdecl **)(int, int, __int16 *, int, _BYTE *))(a1 + 12))(a1, 12, &buf, 76, buf_1); /*0xffe22977*/
v10 = v9; /*0xffe2297a*/
if ( v9 >= 0 ) /*0xffe22981*/
{
v11 = (v13 & 0xFF00 | (v13 << 16)) << 8; /*0xffe229ba*/
if ( v11 | ((HIWORD(v13) | v13 & 0xFF0000) >> 8) ) /*0xffe229bd*/
{
DebugPrint( /*0xffe229cc*/
0x80000000,
"Tpm2GetRandom TrEEPeiPpi->SubmitCommand Response Code error! = %x \n",
v11 | ((HIWORD(v13) | v13 & 0xFF0000) >> 8));
return -2147483641; /*0xffe229d9*/
}
if ( n0x40 ) /*0xffe229dd*/
CopyMem(dst, src, n0x40); /*0xffe229e6*/
}
else
{
DebugPrint(0x80000000, "Tpm2GetRandom TrEEPeiPpi->SubmitCommand = %r \n", v9); /*0xffe2298e*/
}
return v10; /*0xffe229ec*/
}
}
// Function: Tpm2SetPhRandomization @ 0xffe229f5 (0xcb bytes)
// Index: 17/100
int __fastcall Tpm2SetPhRandomization(int a1, int a2)
{
int n20; // eax
int result; // eax
int v6; // ecx
int n20_1; // [esp-4h] [ebp-80h]
__int16 n20_2; // [esp+8h] [ebp-74h] BYREF
_WORD dst[33]; // [esp+Ah] [ebp-72h] BYREF
_BYTE v10[5]; // [esp+4Ch] [ebp-30h] BYREF
char n2; // [esp+51h] [ebp-2Bh]
_DWORD v12[4]; // [esp+68h] [ebp-14h] BYREF
int v13; // [esp+78h] [ebp-4h] BYREF
v12[0] = -1486139870; /*0xffe22a06*/
v12[1] = 1075688714; /*0xffe22a0f*/
v12[2] = 609301899; /*0xffe22a16*/
v12[3] = 71416496; /*0xffe22a1d*/
DebugPrint(64, "Setting PhRandomization\n"); /*0xffe22a24*/
n20 = n20; /*0xffe22a29*/
if ( n20 != -1 ) /*0xffe22a33*/
goto LABEL_11; /*0xffe22a33*/
result = (*(int (__cdecl **)(int, _DWORD *, _DWORD, _DWORD, int *))(*(_DWORD *)a1 + 32))(a1, v12, 0, 0, &v13); /*0xffe22a44*/
if ( result >= 0 ) /*0xffe22a4c*/
{
result = v13; /*0xffe22a4e*/
if ( v13 ) /*0xffe22a53*/
{
if ( (*(int (__cdecl **)(int, _BYTE *))(v13 + 4))(a1, v10) < 0 || n2 == 1 ) /*0xffe22a68*/
{
n20_1 = 20; /*0xffe22a6a*/
}
else
{
if ( n2 != 2 ) /*0xffe22a76*/
{
n20 = n20; /*0xffe22a7c*/
goto LABEL_11; /*0xffe22a7c*/
}
n20_1 = 32; /*0xffe22a78*/
}
n20 = n20_1; /*0xffe22a6c*/
n20 = n20_1; /*0xffe22a6d*/
LABEL_11:
DebugPrint(0x80000000, "HashPolicysize = %x \n", n20); /*0xffe22a81*/
n20_2 = n20; /*0xffe22a99*/
Tpm2GetRandom(a2, (unsigned __int16)n20, (char *)dst); /*0xffe22aa4*/
return Tpm2HierarchyChangeAuth(v6, (char *)&n20_2); /*0xffe22ab3*/
}
}
return result; /*0xffe22aba*/
}
// Function: AmiTpm20PlatformPeiCheckError @ 0xffe22ac0 (0x192 bytes)
// Index: 18/100
int AmiTpm20PlatformPeiCheckError()
{
int BestGuid; // eax
int BestGuid_1; // esi
int Msr64; // eax
int v3; // eax
unsigned __int32 v4; // eax
int n16; // [esp+10h] [ebp-2Ch] BYREF
int p_this; // [esp+14h] [ebp-28h] BYREF
unsigned __int64 v8; // [esp+18h] [ebp-24h] BYREF
__int16 n255; // [esp+20h] [ebp-1Ch]
_DWORD v10[5]; // [esp+28h] [ebp-14h] BYREF
n255 = 255; /*0xffe22ac9*/
v8 = 0; /*0xffe22ad4*/
p_this = 0; /*0xffe22ae3*/
v10[0] = 20351105; /*0xffe22ae7*/
v10[1] = 1260242093; /*0xffe22aef*/
v10[2] = 2060792246; /*0xffe22af7*/
v10[3] = 1809565838; /*0xffe22aff*/
n16 = 16; /*0xffe22b07*/
BestGuid = InternalGetBestGuid(0, (int)&p_this); /*0xffe22b0f*/
BestGuid_1 = BestGuid; /*0xffe22b14*/
if ( BestGuid < 0 ) /*0xffe22b1f*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", BestGuid); /*0xffe22b28*/
Msr64 = BaseReadMsr64(); /*0xffe22b30*/
if ( Msr64 ) /*0xffe22b37*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe22b48*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTpm20PlatformPei.c",
1267,
"!EFI_ERROR (Status)");
}
DebugPrint(0x80000000, "VarSize = %x \n", n16); /*0xffe22b59*/
if ( p_this ) /*0xffe22b67*/
BestGuid_1 = (*(int (__cdecl **)(int, const __int16 *, _DWORD *, _DWORD, int *, unsigned __int64 *))p_this)( /*0xffe22b84*/
p_this,
L"AcpiResetVar",
v10,
0,
&n16,
&v8);
DebugPrint(0x80000000, "VarSize = %x \n", n16); /*0xffe22b8c*/
if ( BestGuid_1 < 0 ) /*0xffe22b96*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", BestGuid_1); /*0xffe22b9f*/
v3 = BaseReadMsr64(); /*0xffe22ba7*/
if ( v3 ) /*0xffe22bae*/
(*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe22bbf*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTpm20PlatformPei.c",
1283,
"!EFI_ERROR (Status)");
}
DebugPrint(
0x80000000,
"Getting AcpiResetVar: Status=%r Addess=%lx AccessSize=%x Type=%x \n",
BestGuid_1,
v8,
HIBYTE(n255),
(unsigned __int8)n255);
if ( HIBYTE(n255) == 2 && (unsigned __int8)n255 < 2u && v8 < 0xFFFFFFFF ) /*0xffe22c07*/
{
if ( (_BYTE)n255 == 1 ) /*0xffe22c0c*/
{
v4 = IoRead32(v8); /*0xffe22c10*/
IoWrite32(v8, v4 & 0xFFFFE3FF); /*0xffe22c20*/
}
else
{
*(_DWORD *)v8 &= 0xFFFFE3FF; /*0xffe22c27*/
}
}
else
{
DebugPrint(0x80000000, "Performing reset without clearing SLP_TYPx bits in PM1 Control Register! \n"); /*0xffe22c35*/
DebugPrint( /*0xffe22c40*/
0x80000000,
"After system will resets, it may still be on S3 resume path and can asserts or hang somewhere in memory initializa"
"tion or elsewhere! \n");
}
return BestGuid_1; /*0xffe22c48*/
}
// Function: AmiTpm20HandleTpmResume @ 0xffe22c52 (0xed bytes)
// Index: 19/100
int __fastcall AmiTpm20HandleTpmResume(int *SystemTable, int a2)
{
bool v4; // sf
int v5; // eax
int v6; // esi
int v7; // eax
int p_this[2]; // [esp+14h] [ebp-8h] BYREF
DebugPrint(64, "Handling TPM resume failure \n"); /*0xffe22c64*/
if ( AmiTpm20GetPpiPointer((int)SystemTable, a2, 1) < 0 ) /*0xffe22c79*/
{
if ( AmiTpm20PlatformPeiCheckError() >= 0 ) /*0xffe22c8f*/
{
v4 = InternalGetBestGuid(0, (int)p_this) < 0; /*0xffe22caf*/
v5 = *SystemTable; /*0xffe22cb1*/
if ( !v4 ) /*0xffe22cb4*/
{
(*(void (__cdecl **)(_DWORD, int, _DWORD, _DWORD))(v5 + 128))(0, -2147483622, 0, 0); /*0xffe22cbe*/
goto LABEL_9; /*0xffe22cbe*/
}
}
else
{
v4 = InternalGetBestGuid(0, (int)p_this) < 0; /*0xffe22c97*/
v5 = *SystemTable; /*0xffe22c99*/
if ( !v4 ) /*0xffe22c9c*/
{
(*(void (__cdecl **)(int, int, _DWORD, _DWORD))(v5 + 128))(2, -2147483622, 0, 0); /*0xffe22ca7*/
LABEL_9:
p_this[1] = 0; /*0xffe22cce*/
while ( 1 ) /*0xffe22cd2*/
; /*0xffe22cd2*/
}
}
(*(void (__cdecl **)(int *))(v5 + 92))(SystemTable); /*0xffe22cca*/
goto LABEL_9; /*0xffe22cca*/
}
v6 = -2147483646; /*0xffe22cd8*/
if ( !a2 ) /*0xffe22ce2*/
{
v7 = -2147483646; /*0xffe22ce4*/
LABEL_14:
DebugPrint(0x80000000, "Tcg2 Boot in recovery Disable EH Status =%r \n", v7); /*0xffe22cf8*/
goto LABEL_15; /*0xffe22cff*/
}
v7 = AmiTpm20SubmitCommand(a2, 0x4000000Bu); /*0xffe22cef*/
if ( v7 < 0 ) /*0xffe22cf6*/
goto LABEL_14; /*0xffe22cf6*/
LABEL_15:
if ( !a2 || (v6 = AmiTpm20SubmitCommand(a2, 0x40000001u), v6 < 0) ) /*0xffe22d1b*/
DebugPrint(0x80000000, "Tcg2 Boot in recovery Disable SH Status =%r \n", v6); /*0xffe22d24*/
Tpm2SetPhRandomization((int)SystemTable, a2); /*0xffe22d30*/
return v6; /*0xffe22d35*/
}
// Function: Tpm2Startup @ 0xffe22d3f (0x396 bytes)
// Index: 20/100
int __fastcall Tpm2Startup(int *SystemTable, int a2, int n17)
{
int result; // eax
int v6; // esi
__int16 n256; // ax
unsigned int n256_2; // ecx
int v9; // eax
int v10; // eax
int Msr64; // eax
int v12; // edi
char IsFirstBoot; // al
bool v14; // zf
char v15; // [esp+17h] [ebp-61h]
int v16; // [esp+18h] [ebp-60h] BYREF
int v17; // [esp+1Ch] [ebp-5Ch] BYREF
int v18; // [esp+20h] [ebp-58h] BYREF
int v19; // [esp+24h] [ebp-54h] BYREF
int v20; // [esp+28h] [ebp-50h] BYREF
_BYTE v21[4]; // [esp+2Ch] [ebp-4Ch] BYREF
_BYTE v22[4]; // [esp+30h] [ebp-48h] BYREF
unsigned __int16 buf; // [esp+34h] [ebp-44h] BYREF
int v24; // [esp+36h] [ebp-42h]
unsigned int v25; // [esp+3Ah] [ebp-3Eh]
__int16 n384; // [esp+40h] [ebp-38h] BYREF
int n201326592; // [esp+42h] [ebp-36h]
int n1140916224; // [esp+46h] [ebp-32h]
__int16 n256_1; // [esp+4Ah] [ebp-2Eh]
_DWORD v30[4]; // [esp+4Ch] [ebp-2Ch] BYREF
_BYTE v31[28]; // [esp+5Ch] [ebp-1Ch] BYREF
v30[0] = -1486139870; /*0xffe22d48*/
v30[1] = 1075688714; /*0xffe22d52*/
v15 = 0; /*0xffe22d61*/
v30[2] = 609301899; /*0xffe22d65*/
v30[3] = 71416496; /*0xffe22d6d*/
v16 = 0; /*0xffe22d75*/
v17 = 0; /*0xffe22d79*/
v18 = 0; /*0xffe22d7d*/
if ( n17 == 17 /*0xffe22d9a*/
&& (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, _BYTE *))(*SystemTable + 32))(
SystemTable,
&unk_FFE2C544,
0,
0,
v21) >= 0 )
{
return AmiTpm20HandleTpmResume(SystemTable, a2); /*0xffe22da5*/
}
if ( (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, _BYTE *))(*SystemTable + 32))( /*0xffe22dc3*/
SystemTable,
&gEfiPeiTpmInitializedPpiGuid,
0,
0,
v22) >= 0 )
v15 = 1; /*0xffe22dc5*/
result = (*(int (__cdecl **)(int *, _DWORD *, _DWORD, _DWORD, int *))(*SystemTable + 32))( /*0xffe22ddb*/
SystemTable,
v30,
0,
0,
&v20);
if ( result >= 0 && v20 )
{
v6 = (*(int (__cdecl **)(int *, _BYTE *))(v20 + 4))(SystemTable, v31); /*0xffe22dfe*/
if ( v6 >= 0 )
{
if ( !a2 ) /*0xffe22e0c*/
return -2147483646; /*0xffe22e13*/
n201326592 = 201326592; /*0xffe22e1d*/
n384 = 384; /*0xffe22e25*/
n256 = 256; /*0xffe22e2a*/
n1140916224 = 1140916224; /*0xffe22e32*/
if ( n17 != 17 ) /*0xffe22e3a*/
n256 = 0; /*0xffe22e3c*/
n256_1 = n256; /*0xffe22e45*/
SetMem(&buf, 0xAu); /*0xffe22e4a*/
if ( v15 )
{
LABEL_19:
if ( n17 == 17 && v31[18] == 1 )
{
if ( v25 ) /*0xffe22f17*/
{
n256_1 = 0; /*0xffe22f1f*/
v6 = (*(int (__cdecl **)(int, int, __int16 *, int, unsigned __int16 *))(a2 + 12))(a2, 12, &n384, 10, &buf); /*0xffe22f36*/
if ( v6 >= 0 ) /*0xffe22f3d*/
{
if ( v25 ) /*0xffe22f49*/
{
DebugPrint( /*0xffe22f76*/
64,
"StartupReponse.ResponseCode = %x \n",
((v25 & 0xFF00 | (v25 << 16)) << 8) | ((HIWORD(v25) | v25 & 0xFF0000) >> 8));
DebugPrint(64, "StartupReponse.Status = %r \n", v6); /*0xffe22f85*/
BootGuardInitialize(-2147483646, 50563586); /*0xffe22f97*/
return -2147483641; /*0xffe22fa1*/
}
return AmiTpm20HandleTpmResume(SystemTable, a2); /*0xffe22faf*/
}
}
}
else
{
if ( v6 >= 0 )
{
v9 = Tpm2SelfTest(a2, &v16, &v17, &v18); /*0xffe22fca*/
v6 = v9 != -2147483642 ? v9 : 0;
if ( v6 >= 0 ) /*0xffe22fdf*/
BootGuardInitialize(1, 50563589); /*0xffe22fe9*/
}
v10 = AmiTpm20CreateTpmHob((int)SystemTable, gEfiTpmDeviceSecretGuid, 15, &v19); /*0xffe22ffc*/
if ( v10 < 0 ) /*0xffe23005*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v10); /*0xffe23012*/
Msr64 = BaseReadMsr64(); /*0xffe2301a*/
if ( Msr64 ) /*0xffe23021*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe23032*/
"e:\\hs\\AmiModulePkg\\TCG2\\Common\\AmiTcgPlatformPei\\AmiTpm20PlatformPei.c",
1593,
"!EFI_ERROR (Status2)");
}
v12 = v19 + 24; /*0xffe23048*/
if ( v6 < 0 ) /*0xffe2303e*/
{
*(_BYTE *)(v19 + 24) = 0; /*0xffe2307a*/
*(_BYTE *)(v12 + 1) = v31[22]; /*0xffe23081*/
}
else
{
*(_BYTE *)(v19 + 24) = 1; /*0xffe2304b*/
*(_BYTE *)(v12 + 1) = BootGuardGetTpmType() == 0; /*0xffe23059*/
*(_DWORD *)(v12 + 3) = v16; /*0xffe23060*/
*(_DWORD *)(v12 + 11) = v17; /*0xffe23067*/
*(_DWORD *)(v12 + 7) = v18; /*0xffe2306e*/
}
IsFirstBoot = AmiTpm20IsFirstBoot(SystemTable); /*0xffe23086*/
v14 = *(_BYTE *)v12 == 0; /*0xffe2308b*/
*(_BYTE *)(v12 + 2) = IsFirstBoot; /*0xffe2308e*/
if ( !v14 ) /*0xffe23091*/
{
DebugPrint(64, "StartupReponse.Tag = %x \n", buf); /*0xffe2309f*/
DebugPrint(64, "StartupReponse.Size = %x \n", v24); /*0xffe230b1*/
DebugPrint(64, "StartupReponse.ResponseCode = %x \n", v25); /*0xffe230c3*/
}
}
return v6; /*0xffe22fb1*/
}
DebugPrint(64, "sending TPM20 b4 TCGPassThroughToTpm \n"); /*0xffe22e63*/
v6 = (*(int (__cdecl **)(int, int, __int16 *, int, unsigned __int16 *))(a2 + 12))(a2, 12, &n384, 10, &buf); /*0xffe22e7a*/
if ( v6 >= 0 ) /*0xffe22e81*/
{
if ( !v25 /*0xffe22eb9*/
|| (n256_2 = ((v25 & 0xFF00 | (v25 << 16)) << 8) | ((HIWORD(v25) | v25 & 0xFF0000) >> 8), n256_2 == 256) )
{
BootGuardInitialize(1, 50563586); /*0xffe22ef7*/
}
else
{
DebugPrint(64, "StartupReponse.ResponseCode = %x \n", n256_2); /*0xffe22ec2*/
DebugPrint(64, "StartupReponse.Status = %r \n", v6); /*0xffe22ed1*/
BootGuardInitialize(-2147483646, 50563586); /*0xffe22ee3*/
v6 = -2147483641; /*0xffe22ee8*/
}
goto LABEL_19; /*0xffe22eed*/
}
}
return v6; /*0xffe230cb*/
}
return result; /*0xffe230cd*/
}
// Function: AmiTpm20IsFirstBoot @ 0xffe230d5 (0x8e bytes)
// Index: 21/100
char __thiscall AmiTpm20IsFirstBoot(int *this)
{
int v1; // eax
int v2; // eax
_BYTE MonotonicCounter[32]; // [esp+8h] [ebp-40h] BYREF
__int16 v5; // [esp+28h] [ebp-20h]
_DWORD v6[4]; // [esp+2Ch] [ebp-1Ch] BYREF
_BYTE v7[4]; // [esp+3Ch] [ebp-Ch] BYREF
int n4; // [esp+40h] [ebp-8h] BYREF
int (__cdecl **v9)(_DWORD, _BYTE *, _DWORD *, _DWORD, int *, _BYTE *); // [esp+44h] [ebp-4h] BYREF
n4 = 4; /*0xffe230e1*/
qmemcpy(MonotonicCounter, L"MonotonicCounter", sizeof(MonotonicCounter)); /*0xffe230f1*/
v1 = *this; /*0xffe230f3*/
v5 = aMonotoniccount[16]; /*0xffe230f9*/
v6[0] = unk_FFE2A72C; /*0xffe23103*/
v6[1] = unk_FFE2A730; /*0xffe23104*/
v6[2] = unk_FFE2A734; /*0xffe23105*/
v6[3] = unk_FFE2A738; /*0xffe23106*/
v2 = (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, int (__cdecl ***)(_DWORD, _BYTE *, _DWORD *, _DWORD, int *, _BYTE *)))(v1 + 32))( /*0xffe23111*/
this,
&this_,
0,
0,
&v9);
if ( v2 >= 0 && v9 ) /*0xffe23120*/
{
if ( (*v9)(v9, MonotonicCounter, v6, 0, &n4, v7) >= 0 ) /*0xffe2313b*/
{
DebugPrint(64, "TPM20::Not First boot Scenario\n"); /*0xffe23154*/
LOBYTE(v2) = -1; /*0xffe23159*/
}
else
{
DebugPrint(64, "TPM20::First boot Scenario determined \n"); /*0xffe23144*/
LOBYTE(v2) = 1; /*0xffe23149*/
}
}
return v2; /*0xffe2315d*/
}
// Function: MeasureTcgPcClientSpecId @ 0xffe23163 (0x22f bytes)
// Index: 22/100
int __thiscall MeasureTcgPcClientSpecId(void *this)
{
int v2; // edi
int v3; // eax
int v4; // eax
int result; // eax
char v6; // bl
char *buf_1; // esi
unsigned int count; // eax
void *buf; // [esp+10h] [ebp-4Ch] BYREF
int v10; // [esp+14h] [ebp-48h] BYREF
int v11; // [esp+18h] [ebp-44h] BYREF
_DWORD v12[3]; // [esp+1Ch] [ebp-40h] BYREF
__int16 v13; // [esp+28h] [ebp-34h]
char n65; // [esp+2Ah] [ebp-32h]
char n4; // [esp+2Bh] [ebp-31h]
char src[16]; // [esp+2Ch] [ebp-30h] BYREF
_BYTE v17[32]; // [esp+3Ch] [ebp-20h] BYREF
v12[0] = -1486139870; /*0xffe2316f*/
v12[1] = 1075688714; /*0xffe2317b*/
strcpy(src, "Spec ID Event03"); /*0xffe23186*/
v10 = 0; /*0xffe23192*/
v12[2] = 609301899; /*0xffe23197*/
v13 = -17744; /*0xffe2319f*/
n65 = 65; /*0xffe231a6*/
n4 = 4; /*0xffe231ac*/
v2 = 0; /*0xffe231b3*/
DebugPrint(64, "TCG Pei: MeasureTCGPcClientSpecID\n");
v3 = (*(int (__cdecl **)(void *, void *, _DWORD, _DWORD, int *))(*(_DWORD *)this + 32))( /*0xffe231ca*/
this,
&gEfiTcg2ProtocolGuid,
0,
0,
&v10);
if ( !v10 ) /*0xffe231d4*/
return -2147483634; /*0xffe231d4*/
if ( v3 < 0 ) /*0xffe231dc*/
return -2147483634; /*0xffe231dc*/
v4 = (*(int (__cdecl **)(void *, _DWORD *, _DWORD, _DWORD, int *))(*(_DWORD *)this + 32))(this, v12, 0, 0, &v11); /*0xffe231f2*/
if ( !v11 || v4 < 0 ) /*0xffe23206*/
return -2147483634; /*0xffe23385*/
result = (*(int (__cdecl **)(void *, _BYTE *))(v11 + 4))(this, v17); /*0xffe23212*/
if ( result >= 0 )
{
v6 = v17[23]; /*0xffe2321f*/
DebugPrint(64, "TCG Pei: TCG_PcClientSpecID\n");
result = (*(int (__cdecl **)(void *, int, void **))(*(_DWORD *)this + 76))(this, 67, &buf); /*0xffe23239*/
if ( result >= 0 ) /*0xffe23241*/
{
buf_1 = (char *)buf; /*0xffe23247*/
SetMem(buf, 0x43u); /*0xffe23250*/
*(_DWORD *)((char *)buf + 10) = 0; /*0xffe2325c*/
*(_DWORD *)((char *)buf + 14) = 3; /*0xffe23263*/
*((_DWORD *)buf + 1) = 14; /*0xffe2326e*/
*((_WORD *)buf + 4) = 1; /*0xffe23279*/
DebugPrint(64, "TrEEEventData->Size = %x \n", *(_DWORD *)buf); /*0xffe2328c*/
DebugPrint(64, "TPML_DIGEST_VALUES Size = %x \n", 334); /*0xffe2329c*/
count = AsciiStrnCpy_s(src); /*0xffe232a8*/
if ( count ) /*0xffe232af*/
CopyMem(buf_1 + 18, src, count); /*0xffe232b9*/
*(_DWORD *)(buf_1 + 38) = 33554944; /*0xffe232c1*/
*(_DWORD *)(buf_1 + 34) = 0; /*0xffe232c8*/
if ( v17[5] == 2 ) /*0xffe232d0*/
{
if ( (v6 & 1) != 0 ) /*0xffe232d5*/
{
*((_WORD *)buf_1 + 23) = 4; /*0xffe232dc*/
*((_WORD *)buf_1 + 24) = 20; /*0xffe232e3*/
v2 = 1; /*0xffe232e7*/
}
if ( (v6 & 2) != 0 ) /*0xffe232ee*/
{
*(_WORD *)&buf_1[4 * v2 + 46] = 11; /*0xffe232f3*/
*(_WORD *)&buf_1[4 * v2++ + 48] = 32; /*0xffe232f8*/
}
if ( (v6 & 4) != 0 ) /*0xffe23301*/
{
*(_WORD *)&buf_1[4 * v2 + 46] = 12; /*0xffe23306*/
*(_WORD *)&buf_1[4 * v2++ + 48] = 48; /*0xffe2330e*/
}
if ( (v6 & 8) != 0 ) /*0xffe23317*/
{
*(_WORD *)&buf_1[4 * v2 + 46] = 13; /*0xffe2331c*/
*(_WORD *)&buf_1[4 * v2++ + 48] = 64; /*0xffe23321*/
}
if ( (v6 & 0x10) != 0 ) /*0xffe2332a*/
{
*(_WORD *)&buf_1[4 * v2 + 46] = 18; /*0xffe2332f*/
*(_WORD *)&buf_1[4 * v2++ + 48] = 32; /*0xffe23334*/
}
*(_DWORD *)(buf_1 + 42) = v2; /*0xffe2333a*/
}
else
{
*((_WORD *)buf_1 + 23) = 4; /*0xffe23342*/
*((_WORD *)buf_1 + 24) = 20; /*0xffe23349*/
*(_DWORD *)(buf_1 + 42) = 1; /*0xffe2334d*/
}
*(_DWORD *)buf = 4 * *(_DWORD *)(buf_1 + 42) + 47; /*0xffe23362*/
buf_1[4 * *(_DWORD *)(buf_1 + 42) + 46] = 0; /*0xffe23367*/
return (*(int (__cdecl **)(int, _DWORD, _DWORD, char *, _DWORD, _DWORD, _DWORD, void *))(v10 + 8))( /*0xffe2337d*/
v10,
0,
0,
buf_1 + 67,
0,
0,
0,
buf);
}
}
return result; /*0xffe2338a*/
}
// Function: AmiTpm20GetTpmFwVolHobFromGuid @ 0xffe23392 (0x3e bytes)
// Index: 23/100
int __fastcall AmiTpm20GetTpmFwVolHobFromGuid(int p_IsAcmPostSuccess, _DWORD *a2, char *IsAcmPostSuccess)
{
unsigned int FitEntryCount; // eax
if ( !p_IsAcmPostSuccess ) /*0xffe2339a*/
return -2147483646; /*0xffe2339c*/
if ( IsAcmPostSuccess ) /*0xffe233a9*/
FitEntryCount = BootGuardGetFitEntryCount(IsAcmPostSuccess); /*0xffe233bd*/
else
FitEntryCount = BootGuardIsAcmPostSuccess(0); /*0xffe233ab*/
*(_DWORD *)p_IsAcmPostSuccess = FitEntryCount; /*0xffe233b0*/
if ( !FitEntryCount ) /*0xffe233b4*/
return -2147483634; /*0xffe233b6*/
*a2 = *(_DWORD *)(*(_DWORD *)p_IsAcmPostSuccess + 28); /*0xffe233c9*/
return 0; /*0xffe233cd*/
}
// Function: AmiTpm20InstallTpmFwVolHobs @ 0xffe233d0 (0x24b bytes)
// Index: 24/100
int __thiscall AmiTpm20InstallTpmFwVolHobs(_DWORD *this)
{
_DWORD *this_1; // edi
int v2; // eax
unsigned int v3; // ebx
void *v4; // ecx
unsigned int IsAcmPostSuccess; // eax
unsigned int IsAcmPostSuccess_1; // esi
_DWORD *v7; // ebp
int v8; // ecx
int v9; // eax
int result; // eax
int v11; // eax
int v12; // ebp
unsigned int *v13; // esi
unsigned int v14; // ebp
unsigned int v15; // edi
unsigned int v16; // eax
int v17; // [esp-8h] [ebp-14Ch]
unsigned int v18; // [esp+10h] [ebp-134h] BYREF
unsigned int IsAcmPostSuccess_2; // [esp+14h] [ebp-130h] BYREF
int (__cdecl **v20)(int, int, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD *, _DWORD *); // [esp+18h] [ebp-12Ch] BYREF
int v21; // [esp+1Ch] [ebp-128h] BYREF
int v22; // [esp+20h] [ebp-124h] BYREF
int v23; // [esp+24h] [ebp-120h] BYREF
_DWORD *this_2; // [esp+28h] [ebp-11Ch]
int v25; // [esp+2Ch] [ebp-118h]
int v26; // [esp+30h] [ebp-114h]
_BYTE v27[23]; // [esp+34h] [ebp-110h] BYREF
unsigned int v28; // [esp+4Bh] [ebp-F9h]
int v29; // [esp+5Ch] [ebp-E8h]
unsigned int v30; // [esp+60h] [ebp-E4h]
_QWORD v31[28]; // [esp+64h] [ebp-E0h] BYREF
this_1 = this; /*0xffe233da*/
this_2 = this; /*0xffe233e2*/
v2 = *this; /*0xffe233e8*/
v3 = 0; /*0xffe233ea*/
v21 = 0; /*0xffe233f3*/
v20 = 0; /*0xffe233f7*/
if ( (*(int (__cdecl **)(_DWORD *, void *, _DWORD, _DWORD, int *))(v2 + 32))(this, &gEfiTcg2ProtocolGuid, 0, 0, &v21) < 0 /*0xffe23420*/
|| (*(int (__cdecl **)(_DWORD *, void *, _DWORD, _DWORD, int (__cdecl ***)(int, int, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD *, _DWORD *)))(*this_1 + 32))(
this_1,
&gTcgPpTrEEGuid,
0,
0,
&v20) < 0 )
{
return -2147483634; /*0xffe23420*/
}
IsAcmPostSuccess = BootGuardIsAcmPostSuccess(v4); /*0xffe23426*/
IsAcmPostSuccess_1 = IsAcmPostSuccess; /*0xffe2342b*/
IsAcmPostSuccess_2 = IsAcmPostSuccess; /*0xffe2342d*/
if ( IsAcmPostSuccess ) /*0xffe23433*/
{
v7 = v31; /*0xffe23438*/
v18 = *(_DWORD *)(IsAcmPostSuccess + 28); /*0xffe2343c*/
do /*0xffe234a9*/
{
if ( (*(_DWORD *)(IsAcmPostSuccess_1 + 36) & 0x8200) == 0x8200 /*0xffe2345c*/
|| (*(_BYTE *)(IsAcmPostSuccess_1 + 36) & 0xA) != 0 && (*(_DWORD *)(IsAcmPostSuccess_1 + 36) & 0x400) == 0 )
{
v9 = *(_DWORD *)(IsAcmPostSuccess_1 + 28); /*0xffe23464*/
v8 = *(_DWORD *)(IsAcmPostSuccess_1 + 20); /*0xffe2345e*/
v17 = *(_DWORD *)(IsAcmPostSuccess_1 + 16); /*0xffe23468*/
*(v7 - 2) = v17; /*0xffe23470*/
*(v7 - 1) = v8; /*0xffe23473*/
*v7 = v9; /*0xffe23476*/
DebugPrint(64, "RomArea->Address = %x \n", v17); /*0xffe23479*/
DebugPrint(64, "RomArea->Size = %x \n", *(_DWORD *)(IsAcmPostSuccess_1 + 28)); /*0xffe23488*/
++v3; /*0xffe23490*/
v7 += 6; /*0xffe23491*/
}
AmiTpm20GetTpmFwVolHobFromGuid((int)&IsAcmPostSuccess_2, &v18, (char *)IsAcmPostSuccess_1); /*0xffe2349d*/
IsAcmPostSuccess_1 = IsAcmPostSuccess_2; /*0xffe234a2*/
}
while ( IsAcmPostSuccess_2 ); /*0xffe234a9*/
}
else
{
v29 = -15663104; /*0xffe234b1*/
v30 = 0; /*0xffe234b9*/
v3 = 1; /*0xffe234bd*/
LODWORD(v31[0]) = 11137024; /*0xffe234be*/
}
v26 = 24 * v3; /*0xffe234d6*/
result = AmiTpm20CreateTpmHob((int)this_1, gAmiTpmFwVolHobGuid, 24 * v3, &v23); /*0xffe234da*/
if ( result >= 0 ) /*0xffe234e3*/
{
v11 = (*(int (__cdecl **)(_DWORD *, void *, _DWORD, _DWORD, int *))(*this_1 + 32))( /*0xffe234f8*/
this_1,
&gAmiTpm20ProtocolGuid,
0,
0,
&v22);
if ( v22 && v11 >= 0 ) /*0xffe2350c*/
{
v12 = (*(int (__cdecl **)(_DWORD *, _BYTE *))(v22 + 4))(this_1, v27); /*0xffe2351b*/
v25 = v12; /*0xffe2351d*/
if ( v12 >= 0 ) /*0xffe23525*/
{
v18 = 0; /*0xffe23532*/
v13 = (unsigned int *)(v23 + 24); /*0xffe23537*/
if ( v3 ) /*0xffe2353c*/
{
v14 = v18; /*0xffe23542*/
v15 = v31[0]; /*0xffe23546*/
do /*0xffe235e1*/
{
if ( v14 ) /*0xffe2354c*/
{
*v13 = 0; /*0xffe23572*/
v13[1] = 0; /*0xffe23575*/
v13[2] = 0; /*0xffe2357c*/
v13[5] = v31[3 * v14]; /*0xffe23584*/
v13[3] = *(&v29 + 6 * v14); /*0xffe2358b*/
v13[4] = *(&v30 + 6 * v14); /*0xffe23592*/
}
else
{
v13[3] = v29; /*0xffe23552*/
v16 = v30; /*0xffe23555*/
v13[5] = v15; /*0xffe23559*/
v13[4] = v16; /*0xffe2355c*/
*v13 = v3; /*0xffe2355f*/
v13[1] = v27[5]; /*0xffe23566*/
v13[2] = v28; /*0xffe2356d*/
}
DebugPrint(64, "TpmFwVolHob->Size = %x \n", v13[5]); /*0xffe2359f*/
DebugPrint(64, "TpmFwVolHob->baseAddress = %x \n", v13[3]); /*0xffe235b4*/
DebugPrint(64, "TpmFwVolHob->Tcg2SpecVersion = %x \n", v13[1]); /*0xffe235c3*/
DebugPrint(64, "TpmFwVolHob address = %x \n", v13); /*0xffe235d3*/
v13 += 6; /*0xffe235db*/
++v14; /*0xffe235de*/
}
while ( v14 < v3 ); /*0xffe235e1*/
this_1 = this_2; /*0xffe235e7*/
v12 = v25; /*0xffe235eb*/
}
MeasureLogDxeFwVol((int)this_1, (int *)&v13[v26 / 0xFFFFFFFC], v21, v20); /*0xffe235ff*/
}
return v12; /*0xffe23529*/
}
return -2147483634; /*0xffe2360b*/
}
return result; /*0xffe23610*/
}
// Function: AmiTpm20PlatformPeiEntry @ 0xffe2361b (0x17b bytes)
// Index: 25/100
int __fastcall AmiTpm20PlatformPeiEntry(int PcdValue, int *SystemTable)
{
int v3; // eax
int result; // eax
int v5; // eax
int PpiPointer; // eax
int v7; // edi
int v8; // eax
int v9; // eax
int v10; // [esp+8h] [ebp-28h] BYREF
int n17; // [esp+Ch] [ebp-24h] BYREF
int v12; // [esp+10h] [ebp-20h] BYREF
_BYTE v13[28]; // [esp+14h] [ebp-1Ch] BYREF
v3 = *SystemTable; /*0xffe23630*/
v10 = 0; /*0xffe23639*/
result = (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, int *))(v3 + 32))( /*0xffe2363d*/
SystemTable,
&gEfiTcg2ProtocolGuid,
0,
0,
&v10);
if ( result >= 0 && v10 )
{
v5 = (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, int *))(*SystemTable + 32))( /*0xffe23664*/
SystemTable,
&gAmiTpm20ProtocolGuid,
0,
0,
&v12);
if ( !v12 || v5 < 0 ) /*0xffe23678*/
return -2147483634; /*0xffe2378b*/
result = (*(int (__cdecl **)(int *, _BYTE *))(v12 + 4))(SystemTable, v13); /*0xffe23684*/
if ( result >= 0 )
{
result = (*(int (__cdecl **)(int *, int *))(*SystemTable + 40))(SystemTable, &n17); /*0xffe23699*/
if ( result >= 0 )
{
if ( Tpm2Startup(SystemTable, v10, n17) < 0 || n17 == 17 ) /*0xffe236c6*/
return 0; /*0xffe236bc*/
if ( n17 != 32 ) /*0xffe236cd*/
goto LABEL_18; /*0xffe236cd*/
PpiPointer = AmiTpm20GetPpiPointer((int)SystemTable, v10, 0); /*0xffe236d6*/
DebugPrint(64, "Tcg2 Boot in recovery CapPcrs Status =%r \n", PpiPointer); /*0xffe236e4*/
v7 = -2147483646; /*0xffe236f0*/
if ( v10 )
{
v8 = AmiTpm20SubmitCommand(v10, 0x4000000Bu); /*0xffe23702*/
if ( v8 >= 0 )
{
LABEL_15:
if ( !v10 || (v7 = AmiTpm20SubmitCommand(v10, 0x40000001u), v7 < 0) ) /*0xffe23731*/
DebugPrint(64, "Tcg2 Boot in recovery Disable SH Status =%r \n", v7); /*0xffe2373b*/
LABEL_18:
if ( v13[5] == 2 )
{
v9 = MeasureTcgPcClientSpecId(SystemTable); /*0xffe2374c*/
if ( v9 < 0 )
DebugPrint(0x80000000, "Error: Failure %d %a Status = %r\n", 2394, "AmiTpm20PlatformPeiEntry", v9);
}
result = BootGuardTcg2MeasureCrtm(SystemTable); /*0xffe23777*/
if ( result >= 0 ) /*0xffe23780*/
return AmiTpm20InstallTpmFwVolHobs(SystemTable); /*0xffe23784*/
return result; /*0xffe23789*/
}
}
else
{
v8 = -2147483646; /*0xffe236f9*/
}
DebugPrint(64, "Tcg2 Boot in recovery Disable EH Status =%r \n", v8); /*0xffe23713*/
goto LABEL_15; /*0xffe23713*/
}
}
}
return result; /*0xffe23790*/
}
// Function: AsciiStrnCpy_s @ 0xffe23796 (0x5b bytes)
// Index: 26/100
unsigned int __thiscall AsciiStrnCpy_s(char *Spec_ID_Event03)
{
char *Spec_ID_Event03_1; // esi
int Msr64; // eax
unsigned int n0xF4240; // edi
int v4; // eax
Spec_ID_Event03_1 = Spec_ID_Event03; /*0xffe23798*/
if ( !Spec_ID_Event03 ) /*0xffe237a2*/
{
Msr64 = BaseReadMsr64(); /*0xffe237a4*/
if ( Msr64 ) /*0xffe237ab*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe237b8*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
1082,
"String != ((void *) 0)");
}
n0xF4240 = 0; /*0xffe237be*/
while ( *Spec_ID_Event03_1 ) /*0xffe237e9*/
{
if ( n0xF4240 >= 0xF4240 ) /*0xffe237c8*/
{
v4 = BaseReadMsr64(); /*0xffe237ca*/
if ( v4 ) /*0xffe237d1*/
(*(void (__cdecl **)(const char *, int, const char *))(v4 + 4))( /*0xffe237de*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\String.c",
1090,
"Length < _gPcd_FixedAtBuild_PcdMaximumAsciiStringLength");
}
++Spec_ID_Event03_1; /*0xffe237e4*/
++n0xF4240; /*0xffe237e5*/
}
return n0xF4240; /*0xffe237ed*/
}
// Function: SwapBytes16 @ 0xffe237f1 (0x19 bytes)
// Index: 27/100
int __fastcall SwapBytes16(int a1)
{
return ((unsigned __int16)__ROL2__(a1, 8) << 16) | (unsigned __int16)__ROL2__(HIWORD(a1), 8); /*0xffe23809*/
}
// Function: WriteUnaligned16 @ 0xffe2380a (0x2f bytes)
// Index: 28/100
__int16 __fastcall WriteUnaligned16(_WORD *a1, __int16 a2)
{
int Msr64; // eax
if ( !a1 ) /*0xffe23813*/
{
Msr64 = BaseReadMsr64(); /*0xffe23815*/
if ( Msr64 ) /*0xffe2381c*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2382a*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
65,
"Buffer != ((void *) 0)");
}
*a1 = a2; /*0xffe23830*/
return a2; /*0xffe23836*/
}
// Function: ReadUnaligned32 @ 0xffe23839 (0x2f bytes)
// Index: 29/100
int __fastcall ReadUnaligned32(_DWORD *CmdBuffer, int n150995008)
{
int Msr64; // eax
if ( !CmdBuffer ) /*0xffe23841*/
{
Msr64 = BaseReadMsr64(); /*0xffe23843*/
if ( Msr64 ) /*0xffe2384a*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2385b*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
168,
"Buffer != ((void *) 0)");
}
*CmdBuffer = n150995008; /*0xffe23861*/
return n150995008; /*0xffe23865*/
}
// Function: ReadUnaligned64 @ 0xffe23868 (0x2c bytes)
// Index: 30/100
__int64 __thiscall ReadUnaligned64(void *this)
{
int Msr64; // eax
if ( !this ) /*0xffe2386d*/
{
Msr64 = BaseReadMsr64(); /*0xffe2386f*/
if ( Msr64 ) /*0xffe23876*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe23887*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
192,
"Buffer != ((void *) 0)");
}
return *(_QWORD *)this; /*0xffe23892*/
}
// Function: WriteUnaligned32 @ 0xffe23894 (0x34 bytes)
// Index: 31/100
int __cdecl WriteUnaligned32(int Unaligned64, int a2)
{
_DWORD *v2; // ecx
_DWORD *v3; // esi
int Msr64; // eax
v3 = v2; /*0xffe23895*/
if ( !v2 ) /*0xffe23899*/
{
Msr64 = BaseReadMsr64(); /*0xffe2389b*/
if ( Msr64 ) /*0xffe238a2*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe238b3*/
"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c",
219,
"Buffer != ((void *) 0)");
}
*v3 = Unaligned64; /*0xffe238c1*/
v3[1] = a2; /*0xffe238c3*/
return Unaligned64; /*0xffe238c6*/
}
// Function: CopyMem @ 0xffe238c8 (0x6f bytes)
// Index: 32/100
char *__fastcall CopyMem(char *dst, char *src, unsigned int count)
{
int Msr64; // eax
int v6; // eax
if ( count - 1 > -1 - (int)dst ) /*0xffe238de*/
{
Msr64 = BaseReadMsr64(); /*0xffe238e0*/
if ( Msr64 ) /*0xffe238e7*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe238f5*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
56,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)DestinationBuffer)");
}
if ( count - 1 > -1 - (int)src ) /*0xffe238ff*/
{
v6 = BaseReadMsr64(); /*0xffe23901*/
if ( v6 ) /*0xffe23908*/
(*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffe23916*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CopyMemWrapper.c",
57,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)SourceBuffer)");
}
if ( dst == src ) /*0xffe2391e*/
return dst; /*0xffe23920*/
else
return BaseCopyMem(dst, src, count); /*0xffe2392a*/
}
// Function: SetMem @ 0xffe23937 (0x3e bytes)
// Index: 33/100
void *__fastcall SetMem(void *buf, unsigned int count)
{
int Msr64; // eax
if ( count - 1 > -1 - (int)buf ) /*0xffe23948*/
{
Msr64 = BaseReadMsr64(); /*0xffe2394a*/
if ( Msr64 ) /*0xffe23951*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2395f*/
"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\SetMemWrapper.c",
54,
"(Length - 1) <= (0xFFFFFFFF - (UINTN)Buffer)");
}
return BaseSetMem8(buf, count, 0); /*0xffe23971*/
}
// Function: BaseIsEqualMemGuid @ 0xffe23975 (0x31 bytes)
// Index: 34/100
void *__thiscall BaseIsEqualMemGuid(void *this)
{
__int64 Unaligned64; // rax
__int64 Unaligned64_1; // rax
Unaligned64 = ReadUnaligned64(&gBootGuardHobGuid); /*0xffe2397d*/
WriteUnaligned32(Unaligned64, SHIDWORD(Unaligned64)); /*0xffe23986*/
Unaligned64_1 = ReadUnaligned64(&unk_FFE2C53C); /*0xffe23990*/
WriteUnaligned32(Unaligned64_1, SHIDWORD(Unaligned64_1)); /*0xffe2399a*/
return this; /*0xffe239a4*/
}
// Function: BaseIsZeroGuid @ 0xffe239a6 (0x5f bytes)
// Index: 35/100
bool __fastcall BaseIsZeroGuid(int a1, int a2)
{
__int64 Unaligned64; // rax
int Unaligned64_1; // ebp
__int64 Unaligned64_3; // rax
int Unaligned64_2; // edi
__int64 v8; // kr00_8
__int64 v9; // rax
int v11; // [esp+10h] [ebp-Ch]
int v12; // [esp+14h] [ebp-8h]
Unaligned64 = ReadUnaligned64((void *)a1); /*0xffe239b1*/
v12 = HIDWORD(Unaligned64); /*0xffe239b8*/
Unaligned64_1 = Unaligned64; /*0xffe239bc*/
Unaligned64_3 = ReadUnaligned64((void *)a2); /*0xffe239be*/
v11 = HIDWORD(Unaligned64_3); /*0xffe239c6*/
Unaligned64_2 = Unaligned64_3; /*0xffe239ca*/
v8 = ReadUnaligned64((void *)(a1 + 8)); /*0xffe239d8*/
v9 = ReadUnaligned64((void *)(a2 + 8)); /*0xffe239da*/
return Unaligned64_1 == Unaligned64_2 && v12 == v11 && v8 == v9; /*0xffe239fd*/
}
// Function: InternalGetBestGuid @ 0xffe23a05 (0x1e bytes)
// Index: 36/100
int __cdecl InternalGetBestGuid(int a1, int p_this)
{
int v2; // ecx
int v3; // esi
int Pointer; // eax
v3 = v2; /*0xffe23a06*/
Pointer = PeiServicesGetPointer(); /*0xffe23a08*/
return (*(int (__cdecl **)(int, int, _DWORD, int, int))(*(_DWORD *)Pointer + 32))(Pointer, v3, 0, a1, p_this); /*0xffe23a21*/
}
// Function: IoRead32 @ 0xffe23a23 (0x2c bytes)
// Index: 37/100
unsigned __int32 __fastcall IoRead32(unsigned __int16 a1)
{
int Msr64; // eax
if ( (a1 & 3) != 0 ) /*0xffe23a29*/
{
Msr64 = BaseReadMsr64(); /*0xffe23a2b*/
if ( Msr64 ) /*0xffe23a32*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe23a43*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c",
193,
"(Port & 3) == 0");
}
return __indword(a1); /*0xffe23a4d*/
}
// Function: IoWrite32 @ 0xffe23a4f (0x32 bytes)
// Index: 38/100
unsigned int __fastcall IoWrite32(unsigned __int16 a1, unsigned int a2)
{
int Msr64; // eax
if ( (a1 & 3) != 0 ) /*0xffe23a58*/
{
Msr64 = BaseReadMsr64(); /*0xffe23a5a*/
if ( Msr64 ) /*0xffe23a61*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe23a72*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c",
223,
"(Port & 3) == 0");
}
__outdword(a1, a2); /*0xffe23a7d*/
return a2; /*0xffe23a7e*/
}
// Function: BaseReadMsr64 @ 0xffe23a81 (0x28 bytes)
// Index: 39/100
int BaseReadMsr64()
{
int v1; // [esp+0h] [ebp-8h] BYREF
int p_this; // [esp+4h] [ebp-4h] BYREF
if ( InternalGetBestGuid((int)&v1, (int)&p_this) >= 0 ) /*0xffe23a9c*/
return p_this; /*0xffe23aa2*/
else
return 0; /*0xffe23a9e*/
}
// Function: DebugPrint @ 0xffe23aa9 (0x2a bytes)
// Index: 40/100
int DebugPrint(int a1, const char *a2, ...)
{
int result; // eax
int (__cdecl **v3)(int, const char *, char *); // esi
va_list va; // [esp+10h] [ebp+Ch] BYREF
va_start(va, a2);
result = BaseReadMsr64(); /*0xffe23aaa*/
v3 = (int (__cdecl **)(int, const char *, char *))result; /*0xffe23aaf*/
if ( result ) /*0xffe23ab3*/
{
result = BootGuardFitGetEntryType(); /*0xffe23ab5*/
if ( (result & a1) != 0 ) /*0xffe23ac0*/
return (*v3)(a1, a2, (char *)va); /*0xffe23acc*/
}
return result; /*0xffe23ad1*/
}
// Function: AmiTpm20LocatePpi @ 0xffe23ad3 (0x1e bytes)
// Index: 41/100
int __fastcall AmiTpm20LocatePpi(
int e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
int n48,
int PeiServices____((void__)_0))
{
int result; // eax
result = BaseReadMsr64(); /*0xffe23ad9*/
if ( result ) /*0xffe23ae0*/
return (*(int (__cdecl **)(int, int, int))(result + 4))( /*0xffe23ae8*/
e:__hs__MdePkg__Library__PeiServicesTablePointerLibIdt__PeiServ,
n48,
PeiServices____((void__)_0));
return result; /*0xffe23aee*/
}
// Function: GetGuidHobDataSize @ 0xffe23af1 (0x46 bytes)
// Index: 42/100
void *__fastcall GetGuidHobDataSize(int a1, char **p_src, int a3, int src)
{
int v6; // edi
_DWORD buf[23]; // [esp+8h] [ebp-5Ch] BYREF
InitHashContext(buf); /*0xffe23b00*/
if ( a1 ) /*0xffe23b07*/
{
v6 = a3 - (_DWORD)p_src; /*0xffe23b0d*/
do /*0xffe23b23*/
{
HashUpdateSha256((int)buf, *p_src, *(unsigned int *)((char *)p_src + v6)); /*0xffe23b17*/
++p_src; /*0xffe23b1c*/
--a1; /*0xffe23b20*/
}
while ( a1 ); /*0xffe23b23*/
}
return HashUpdateSha1(src, buf); /*0xffe23b31*/
}
// Function: Tpm20MeasureDigest @ 0xffe23b37 (0x123a bytes)
// Index: 43/100
void *__fastcall Tpm20MeasureDigest(_DWORD *a1, char *src)
{
int v3; // edi
int v4; // edx
int v5; // eax
int v6; // edx
int v7; // ebp
int v8; // ebx
int v9; // esi
int v10; // eax
int v11; // ebp
int v12; // edi
int v13; // eax
int v14; // esi
int v15; // edx
int v16; // eax
int v17; // edi
int v18; // ebx
int v19; // eax
int v20; // edx
int v21; // ebp
int v22; // eax
int v23; // ebx
int v24; // esi
int v25; // eax
int v26; // ebp
int v27; // edi
int v28; // eax
int v29; // esi
int v30; // edx
int v31; // ebx
int v32; // eax
int v33; // edx
int v34; // ebp
int v35; // edi
int v36; // ecx
int v37; // ebx
int v38; // ebp
int v39; // edi
int v40; // ebp
int v41; // edx
int v42; // ebx
int v43; // esi
int v44; // ebp
int v45; // eax
int v46; // edx
int v47; // edi
int v48; // eax
int v49; // esi
int v50; // ebx
int v51; // eax
int v52; // edi
int v53; // ebp
int v54; // eax
int v55;... [26231 chars total]
// Function: InitHashContext @ 0xffe24d71 (0x2b bytes)
// Index: 44/100
void __thiscall InitHashContext(_DWORD *this)
{
*(this + 6) = 0; /*0xffe24d71*/
*(this + 5) = 0; /*0xffe24d75*/
*this = 1732584193; /*0xffe24d79*/
*(this + 1) = -271733879; /*0xffe24d7f*/
*(this + 2) = -1732584194; /*0xffe24d86*/
*(this + 3) = 271733878; /*0xffe24d8d*/
*(this + 4) = -1009589776; /*0xffe24d94*/
}
// Function: HashUpdateSha256 @ 0xffe24d9c (0x96 bytes)
// Index: 45/100
char *__fastcall HashUpdateSha256(int a1, char *src, unsigned int i)
{
int v4; // ebx
unsigned int v5; // ecx
char *result; // eax
int i_1; // esi
unsigned int j; // ebx
char *src_1; // [esp+10h] [ebp-4h]
src_1 = src; /*0xffe24da7*/
v4 = (*(_DWORD *)(a1 + 20) >> 3) & 0x3F; /*0xffe24db3*/
v5 = *(_DWORD *)(a1 + 20) + 8 * i; /*0xffe24db6*/
*(_DWORD *)(a1 + 20) = v5; /*0xffe24dbe*/
if ( v5 < 8 * i ) /*0xffe24dc3*/
++*(_DWORD *)(a1 + 24); /*0xffe24dc5*/
*(_DWORD *)(a1 + 24) += i >> 29; /*0xffe24dcd*/
result = (char *)(v4 + i); /*0xffe24dd0*/
if ( v4 + i <= 0x3F ) /*0xffe24dd6*/
{
i_1 = 0; /*0xffe24e18*/
}
else
{
i_1 = 64 - v4; /*0xffe24ddb*/
CopyMem((char *)(v4 + a1 + 28), src, 64 - v4); /*0xffe24de5*/
result = (char *)Tpm20MeasureDigest((_DWORD *)a1, (char *)(a1 + 28)); /*0xffe24df0*/
for ( j = i_1 + 63; ; j += 64 ) /*0xffe24df5*/
{
src = src_1; /*0xffe24e0c*/
if ( j >= i ) /*0xffe24e12*/
break; /*0xffe24e12*/
result = (char *)Tpm20MeasureDigest((_DWORD *)a1, &src_1[j - 63]); /*0xffe24e01*/
i_1 += 64; /*0xffe24e06*/
}
v4 = 0; /*0xffe24e14*/
}
if ( i != i_1 ) /*0xffe24e1a*/
return CopyMem((char *)(v4 + a1 + 28), &src[i_1], i - i_1); /*0xffe24e26*/
return result; /*0xffe24e2c*/
}
// Function: HashUpdateSha1 @ 0xffe24e32 (0xc1 bytes)
// Index: 46/100
void *__fastcall HashUpdateSha1(int src, _DWORD *buf)
{
unsigned int n0x14; // edi
unsigned int i; // edx
char srca[8]; // [esp+10h] [ebp-8h] BYREF
n0x14 = 0; /*0xffe24e38*/
for ( i = 0; i < 8; ++i )
srca[i] = *(_DWORD *)((char *)buf + (i < 4 ? 4 : 0) + 20) >> (8 * (3 - (i & 3)));
HashUpdateSha256((int)buf, ::src, 1u); /*0xffe24e6e*/
while ( (buf[5] & 0x1F8) != 0x1C0 ) /*0xffe24e93*/
HashUpdateSha256((int)buf, src_0, 1u); /*0xffe24e7f*/
HashUpdateSha256((int)buf, srca, 8u); /*0xffe24e9b*/
do /*0xffe24ebf*/
{
*(_BYTE *)(n0x14 + src) = buf[n0x14 >> 2] >> (8 * (3 - (n0x14 & 3))); /*0xffe24eb8*/
++n0x14; /*0xffe24ebb*/
}
while ( n0x14 < 0x14 ); /*0xffe24ebf*/
SetMem(buf + 7, 0x40u); /*0xffe24ec7*/
SetMem(buf, 0x14u); /*0xffe24ed1*/
SetMem(buf + 5, 8u); /*0xffe24edb*/
return SetMem(srca, 8u); /*0xffe24eec*/
}
// Function: HashUpdateSha384 @ 0xffe24ef3 (0x51 bytes)
// Index: 47/100
void *__fastcall HashUpdateSha384(int a1, unsigned __int8 **p_src, int p_n256, _BYTE *src)
{
int v6; // edi
_BYTE buf[112]; // [esp+10h] [ebp-70h] BYREF
InitHashContextSm3(buf); /*0xffe24f03*/
if ( a1 ) /*0xffe24f0a*/
{
v6 = p_n256 - (_DWORD)p_src; /*0xffe24f0f*/
do /*0xffe24f25*/
{
HashUpdateSm3((int)buf, *p_src, *(unsigned int *)((char *)p_src + v6)); /*0xffe24f19*/
++p_src; /*0xffe24f1e*/
--a1; /*0xffe24f22*/
}
while ( a1 ); /*0xffe24f25*/
}
HashUpdateSha512(buf, src); /*0xffe24f2d*/
return SetMem(buf, 0x70u); /*0xffe24f3d*/
}
// Function: Tpm20HashAll @ 0xffe24f44 (0x2814 bytes)
// Index: 48/100
int __fastcall Tpm20HashAll(_DWORD *buf, unsigned __int8 *src)
{
int v2; // ebx
int v3; // edi
int v4; // edx
int v5; // ebp
int v6; // edx
int v7; // edi
int v8; // edx
int v9; // ebx
int v10; // edx
int v11; // edx
int v12; // edx
int v13; // edx
int v14; // edx
int v15; // edx
int v16; // edx
int v17; // edx
int v18; // edx
int v19; // edx
int v20; // edx
int v21; // edx
int v22; // edx
int v23; // edx
int v24; // edx
int v25; // edx
int v26; // edx
int v27; // edx
int v28; // edx
int v29; // edx
int v30; // edx
int v31; // edx
int v32; // edx
int v33; // edx
int v34; // edx
int v35; // edx
int v36; // edx
int v37; // edx
int v38; // edx
int v39; // edx
int v40; // edx
int v41; // edx
int v42; // edx
int v43; // edx
int v44; // edx
int v45; // edx
int v46; // edx
int v47; // edx
int v48; // edx
int v49; // edx
int v50; // edi
int v51; // edx
int v52; // ebx
int v53; // edx
int v... [39368 chars total]
// Function: InitHashContextSm3 @ 0xffe27758 (0x43 bytes)
// Index: 49/100
int __thiscall InitHashContextSm3(_BYTE *buf)
{
*((_DWORD *)buf + 10) = 0; /*0xffe2775a*/
*(_DWORD *)buf = 0; /*0xffe2775d*/
*((_DWORD *)buf + 1) = 0; /*0xffe2775f*/
*((_DWORD *)buf + 2) = 1779033703; /*0xffe27762*/
*((_DWORD *)buf + 3) = -1150833019; /*0xffe27769*/
*((_DWORD *)buf + 4) = 1013904242; /*0xffe27770*/
*((_DWORD *)buf + 5) = -1521486534; /*0xffe27777*/
*((_DWORD *)buf + 6) = 1359893119; /*0xffe2777e*/
*((_DWORD *)buf + 7) = -1694144372; /*0xffe27785*/
*((_DWORD *)buf + 8) = 528734635; /*0xffe2778c*/
*((_DWORD *)buf + 9) = 1541459225; /*0xffe27793*/
return 0; /*0xffe2779a*/
}
// Function: HashUpdateSm3 @ 0xffe2779b (0xa0 bytes)
// Index: 50/100
int __fastcall HashUpdateSm3(int buf, unsigned __int8 *src, unsigned int n0x40)
{
unsigned int n0x40_1; // ebx
if ( *(_DWORD *)(buf + 40) > 0x40u ) /*0xffe277a5*/
return -1; /*0xffe277a7*/
while ( 1 ) /*0xffe2780d*/
{
do /*0xffe2780d*/
{
while ( 1 ) /*0xffe2782b*/
{
if ( !n0x40 ) /*0xffe2782d*/
return 0; /*0xffe2782f*/
if ( *(_DWORD *)(buf + 40) || n0x40 < 0x40 ) /*0xffe277c0*/
break; /*0xffe277c0*/
if ( Tpm20HashAll((_DWORD *)buf, src) < 0 ) /*0xffe277cd*/
return -1; /*0xffe277cd*/
*(_QWORD *)buf += 512LL; /*0xffe277cf*/
src += 64; /*0xffe277d9*/
n0x40 -= 64; /*0xffe277dc*/
}
n0x40_1 = 64 - *(_DWORD *)(buf + 40); /*0xffe277e4*/
if ( n0x40 < n0x40_1 ) /*0xffe277e9*/
n0x40_1 = n0x40; /*0xffe277eb*/
if ( n0x40_1 ) /*0xffe277ef*/
CopyMem((char *)(buf + *(_DWORD *)(buf + 40) + 44), (char *)src, n0x40_1); /*0xffe277fc*/
*(_DWORD *)(buf + 40) += n0x40_1; /*0xffe27802*/
src += n0x40_1; /*0xffe27805*/
n0x40 -= n0x40_1; /*0xffe27807*/
}
while ( *(_DWORD *)(buf + 40) != 64 ); /*0xffe2780d*/
if ( Tpm20HashAll((_DWORD *)buf, (unsigned __int8 *)(buf + 44)) < 0 ) /*0xffe2781b*/
break; /*0xffe2781b*/
*(_QWORD *)buf += 512LL; /*0xffe2781d*/
*(_DWORD *)(buf + 40) = 0; /*0xffe27827*/
}
return -1; /*0xffe27833*/
}
// Function: HashUpdateSha512 @ 0xffe2783b (0x18f bytes)
// Index: 51/100
int __fastcall HashUpdateSha512(_BYTE *buf, _BYTE *src)
{
unsigned int n0x40; // ecx
bool v6; // cf
unsigned int n0x40_1; // eax
n0x40 = *((_DWORD *)buf + 10); /*0xffe27841*/
if ( n0x40 >= 0x40 ) /*0xffe27847*/
return -1; /*0xffe27849*/
v6 = __CFADD__(8 * n0x40, *(_DWORD *)buf); /*0xffe27857*/
*(_DWORD *)buf += 8 * n0x40; /*0xffe27857*/
*((_DWORD *)buf + 1) += v6; /*0xffe2785c*/
buf[n0x40 + 44] = 0x80; /*0xffe2785f*/
n0x40_1 = ++*((_DWORD *)buf + 10); /*0xffe27867*/
if ( n0x40_1 > 0x38 ) /*0xffe2786d*/
{
while ( n0x40_1 < 0x40 ) /*0xffe2787e*/
{
buf[n0x40_1 + 44] = 0; /*0xffe27871*/
n0x40_1 = ++*((_DWORD *)buf + 10); /*0xffe27878*/
}
Tpm20HashAll(buf, buf + 44); /*0xffe27885*/
*((_DWORD *)buf + 10) = 0; /*0xffe2788a*/
}
while ( *((_DWORD *)buf + 10) < 0x38u ) /*0xffe2789d*/
buf[(*((_DWORD *)buf + 10))++ + 44] = 0; /*0xffe27892*/
buf[100] = buf[7]; /*0xffe278a4*/
buf[101] = buf[6]; /*0xffe278aa*/
buf[102] = LShiftU64(0x28u, *(_QWORD *)buf); /*0xffe278b7*/
buf[103] = LShiftU64(0x20u, *(_QWORD *)buf); /*0xffe278c6*/
buf[104] = HIBYTE(*(_DWORD *)buf); /*0xffe278d8*/
buf[105] = BYTE2(*(_DWORD *)buf); /*0xffe278e7*/
buf[106] = BYTE1(*(_QWORD *)buf); /*0xffe278f6*/
buf[107] = *buf; /*0xffe278fd*/
Tpm20HashAll(buf, buf + 44); /*0xffe27900*/
*src = buf[11]; /*0xffe27908*/
src[1] = buf[10]; /*0xffe2790d*/
src[2] = buf[9]; /*0xffe27913*/
src[3] = buf[8]; /*0xffe27919*/
src[4] = buf[15]; /*0xffe2791f*/
src[5] = buf[14]; /*0xffe27925*/
src[6] = buf[13]; /*0xffe2792b*/
src[7] = buf[12]; /*0xffe27931*/
src[8] = buf[19]; /*0xffe27937*/
src[9] = buf[18]; /*0xffe2793d*/
src[10] = buf[17]; /*0xffe27943*/
src[11] = buf[16]; /*0xffe27949*/
src[12] = buf[23]; /*0xffe2794f*/
src[13] = buf[22]; /*0xffe27955*/
src[14] = buf[21]; /*0xffe2795b*/
src[15] = buf[20]; /*0xffe27961*/
src[16] = buf[27]; /*0xffe27967*/
src[17] = buf[26]; /*0xffe2796d*/
src[18] = buf[25]; /*0xffe27973*/
src[19] = buf[24]; /*0xffe27979*/
src[20] = buf[31]; /*0xffe2797f*/
src[21] = buf[30]; /*0xffe27985*/
src[22] = buf[29]; /*0xffe2798b*/
src[23] = buf[28]; /*0xffe27991*/
src[24] = buf[35]; /*0xffe27997*/
src[25] = buf[34]; /*0xffe2799d*/
src[26] = buf[33]; /*0xffe279a3*/
src[27] = buf[32]; /*0xffe279a9*/
src[28] = buf[39]; /*0xffe279af*/
src[29] = buf[38]; /*0xffe279b5*/
src[30] = buf[37]; /*0xffe279bb*/
src[31] = buf[36]; /*0xffe279c1*/
return 0; /*0xffe279c7*/
}
// Function: Tpm12HashAll @ 0xffe279ca (0x83 bytes)
// Index: 52/100
int __thiscall Tpm12HashAll(_DWORD *this)
{
if ( !this ) /*0xffe279cc*/
return -1; /*0xffe279ce*/
*(this + 18) = 0; /*0xffe279d4*/
*this = 0; /*0xffe279d7*/
*(this + 1) = 0; /*0xffe279d9*/
*(this + 2) = -1056596264; /*0xffe279dc*/
*(this + 3) = -876896931; /*0xffe279e3*/
*(this + 4) = 914150663; /*0xffe279ea*/
*(this + 5) = 1654270250; /*0xffe279f1*/
*(this + 6) = 812702999; /*0xffe279f8*/
*(this + 7) = -1856437926; /*0xffe279ff*/
*(this + 8) = -150054599; /*0xffe27a06*/
*(this + 9) = 355462360; /*0xffe27a0d*/
*(this + 10) = -4191439; /*0xffe27a14*/
*(this + 11) = 1731405415; /*0xffe27a1b*/
*(this + 12) = 1750603025; /*0xffe27a22*/
*(this + 13) = -1900787065; /*0xffe27a29*/
*(this + 14) = 1694076839; /*0xffe27a30*/
*(this + 15) = -619958771; /*0xffe27a37*/
*(this + 16) = -1090891868; /*0xffe27a3e*/
*(this + 17) = 1203062813; /*0xffe27a45*/
return 0; /*0xffe279d1*/
}
// Function: Tpm12HashExport @ 0xffe27a4d (0x3b bytes)
// Index: 53/100
int __fastcall Tpm12HashExport(int a1, char *dst)
{
char src[64]; // [esp+8h] [ebp-40h] BYREF
if ( !a1 || !dst || *(_DWORD *)(a1 + 72) >= 0x80u ) /*0xffe27a6a*/
return -1; /*0xffe27a5a*/
Tpm20MettleHashComplete(a1, src); /*0xffe27a6f*/
CopyMem(dst, src, 0x30u); /*0xffe27a7b*/
return 0; /*0xffe27a83*/
}
// Function: Tpm20HashDigestExtend @ 0xffe27a88 (0xd7f bytes)
// Index: 54/100
int __fastcall Tpm20HashDigestExtend(int a1, int src)
{
char *dst_1; // esi
char *src_1; // edi
int n8; // ebx
unsigned __int8 *v6; // edi
__int64 v7; // rt0
__int64 v8; // rax
unsigned __int64 v9; // rt0
int v10; // ecx
_BYTE *v11; // edx
__int64 v12; // rcx
unsigned int v13; // edi
unsigned int v14; // ebp
unsigned __int64 v15; // rt0
int v16; // edi
bool v17; // zf
int n8_1; // ebp
unsigned int v19; // ecx
unsigned int v20; // edx
unsigned __int64 v21; // kr28_8
unsigned __int64 v22; // kr58_8
unsigned __int64 v23; // kr88_8
unsigned __int64 v24; // kr90_8
unsigned __int64 v25; // krB0_8
unsigned __int64 v26; // kr00_8
unsigned __int64 v27; // krD0_8
unsigned int v28; // eax
unsigned __int64 v29; // kr100_8
unsigned int v30; // eax
unsigned __int64 v31; // kr130_8
unsigned __int64 v32; // kr08_8
unsigned int v33; // eax
unsigned __int64 v34; // kr160_8
unsigned __int64 v35; // kr20_8
unsigned __int64 v36; // kr170_8... [14483 chars total]
// Function: Tpm20MettleHashAll @ 0xffe28807 (0x83 bytes)
// Index: 55/100
int __thiscall Tpm20MettleHashAll(_DWORD *this)
{
if ( !this ) /*0xffe28809*/
return -1; /*0xffe2880b*/
*(this + 18) = 0; /*0xffe28811*/
*this = 0; /*0xffe28814*/
*(this + 1) = 0; /*0xffe28816*/
*(this + 2) = -205731576; /*0xffe28819*/
*(this + 3) = 1779033703; /*0xffe28820*/
*(this + 4) = -2067093701; /*0xffe28827*/
*(this + 5) = -1150833019; /*0xffe2882e*/
*(this + 6) = -23791573; /*0xffe28835*/
*(this + 7) = 1013904242; /*0xffe2883c*/
*(this + 8) = 1595750129; /*0xffe28843*/
*(this + 9) = -1521486534; /*0xffe2884a*/
*(this + 10) = -1377402159; /*0xffe28851*/
*(this + 11) = 1359893119; /*0xffe28858*/
*(this + 12) = 725511199; /*0xffe2885f*/
*(this + 13) = -1694144372; /*0xffe28866*/
*(this + 14) = -79577749; /*0xffe2886d*/
*(this + 15) = 528734635; /*0xffe28874*/
*(this + 16) = 327033209; /*0xffe2887b*/
*(this + 17) = 1541459225; /*0xffe28882*/
return 0; /*0xffe2880e*/
}
// Function: Tpm20MettleHashUpdate @ 0xffe2888a (0xa0 bytes)
// Index: 56/100
int __fastcall Tpm20MettleHashUpdate(int a1, char *src, unsigned int n0x80)
{
char *src_1; // ebp
int result; // eax
unsigned int n0x80_1; // ebx
src_1 = src; /*0xffe2888f*/
if ( !a1 || !src || *(_DWORD *)(a1 + 72) > 0x80u ) /*0xffe288aa*/
return -1; /*0xffe28896*/
while ( n0x80 ) /*0xffe28921*/
{
if ( *(_DWORD *)(a1 + 72) || n0x80 < 0x80 ) /*0xffe288ba*/
{
n0x80_1 = 128 - *(_DWORD *)(a1 + 72); /*0xffe288d8*/
if ( n0x80 < n0x80_1 ) /*0xffe288dd*/
n0x80_1 = n0x80; /*0xffe288df*/
if ( n0x80_1 ) /*0xffe288e3*/
CopyMem((char *)(*(_DWORD *)(a1 + 72) + a1 + 76), src_1, n0x80_1); /*0xffe288ee*/
*(_DWORD *)(a1 + 72) += n0x80_1; /*0xffe288f4*/
src_1 += n0x80_1; /*0xffe288f7*/
n0x80 -= n0x80_1; /*0xffe288f9*/
if ( *(_DWORD *)(a1 + 72) == 128 ) /*0xffe28903*/
{
result = Tpm20HashDigestExtend(a1, a1 + 76); /*0xffe2890a*/
if ( result ) /*0xffe28911*/
return result; /*0xffe28911*/
*(_QWORD *)a1 += 1024LL; /*0xffe28913*/
*(_DWORD *)(a1 + 72) = 0; /*0xffe2891c*/
}
}
else
{
result = Tpm20HashDigestExtend(a1, (int)src_1); /*0xffe288c0*/
if ( result ) /*0xffe288c7*/
return result; /*0xffe288c7*/
*(_QWORD *)a1 += 1024LL; /*0xffe288c9*/
src_1 += 128; /*0xffe288d2*/
n0x80 -= 128; /*0xffe288d4*/
}
}
return 0; /*0xffe28925*/
}
// Function: Tpm20MettleHashComplete @ 0xffe2892a (0x10a bytes)
// Index: 57/100
int __fastcall Tpm20MettleHashComplete(int a1, char *src)
{
unsigned int n0x80; // ecx
unsigned int n0x80_1; // eax
char *v7; // ecx
char *v8; // esi
int n8; // edx
char v10; // al
if ( !a1 ) /*0xffe28935*/
return -1; /*0xffe28935*/
if ( !src ) /*0xffe28941*/
return -1; /*0xffe28941*/
n0x80 = *(_DWORD *)(a1 + 72); /*0xffe28943*/
if ( n0x80 >= 0x80 ) /*0xffe2894d*/
return -1; /*0xffe28937*/
*(_QWORD *)a1 += 8LL * n0x80; /*0xffe28956*/
*(_BYTE *)(n0x80 + a1 + 76) = 0x80; /*0xffe2895b*/
n0x80_1 = ++*(_DWORD *)(a1 + 72); /*0xffe28962*/
if ( n0x80_1 > 0x70 ) /*0xffe28968*/
{
while ( n0x80_1 < 0x80 ) /*0xffe28979*/
{
*(_BYTE *)(a1 + n0x80_1 + 76) = 0; /*0xffe2896c*/
n0x80_1 = ++*(_DWORD *)(a1 + 72); /*0xffe28974*/
}
Tpm20HashDigestExtend(a1, a1 + 76); /*0xffe28980*/
*(_DWORD *)(a1 + 72) = 0; /*0xffe28985*/
}
while ( *(_DWORD *)(a1 + 72) < 0x78u ) /*0xffe2899a*/
{
*(_BYTE *)(*(_DWORD *)(a1 + 72) + a1 + 76) = 0; /*0xffe2898e*/
++*(_DWORD *)(a1 + 72); /*0xffe28993*/
}
*(_BYTE *)(a1 + 196) = *(_BYTE *)(a1 + 7); /*0xffe289a2*/
*(_BYTE *)(a1 + 197) = *(_BYTE *)(a1 + 6); /*0xffe289ad*/
*(_BYTE *)(a1 + 198) = *(_BYTE *)(a1 + 5); /*0xffe289b6*/
*(_BYTE *)(a1 + 199) = *(_BYTE *)(a1 + 4); /*0xffe289bf*/
*(_BYTE *)(a1 + 200) = *(_BYTE *)(a1 + 3); /*0xffe289c8*/
*(_BYTE *)(a1 + 201) = *(_BYTE *)(a1 + 2); /*0xffe289d1*/
*(_BYTE *)(a1 + 202) = *(_BYTE *)(a1 + 1); /*0xffe289da*/
*(_BYTE *)(a1 + 203) = *(_BYTE *)a1; /*0xffe289e2*/
Tpm20HashDigestExtend(a1, a1 + 76); /*0xffe289e8*/
v7 = src + 2; /*0xffe289ed*/
v8 = (char *)(a1 + 14); /*0xffe289f0*/
n8 = 8; /*0xffe289f3*/
do /*0xffe28a2a*/
{
*(v7 - 2) = v8[1]; /*0xffe289f8*/
*(v7 - 1) = *v8; /*0xffe289fd*/
*v7 = *(v8 - 1); /*0xffe28a03*/
v7[1] = *(v8 - 2); /*0xffe28a08*/
v7[2] = *(v8 - 3); /*0xffe28a0e*/
v7[3] = *(v8 - 4); /*0xffe28a14*/
v7[4] = *(v8 - 5); /*0xffe28a1a*/
v10 = *(v8 - 6); /*0xffe28a1d*/
v8 += 8; /*0xffe28a20*/
v7[5] = v10; /*0xffe28a22*/
v7 += 8; /*0xffe28a25*/
--n8; /*0xffe28a27*/
}
while ( n8 ); /*0xffe28a2a*/
return 0; /*0xffe28a2e*/
}
// Function: BootGuardIsTpmPresent @ 0xffe28a34 (0x34 bytes)
// Index: 58/100
bool BootGuardIsTpmPresent()
{
return MEMORY[0xFED40030] != -1 && MEMORY[0xFED40030]; /*0xffe28a64*/
}
// Function: BootGuardGetTpmType @ 0xffe28a68 (0x55 bytes)
// Index: 59/100
char BootGuardGetTpmType()
{
char v1; // [esp+6h] [ebp-2h]
v1 = MEMORY[0xFED40030] & 0xF; /*0xffe28a84*/
if ( BootGuardIsTpmPresent() ) /*0xffe28a8b*/
return v1 & 0xF; /*0xffe28ab6*/
else
return BootGuardGetPcdPttSkip() != 0; /*0xffe28aa1*/
}
// Function: BootGuardFindFitEntry @ 0xffe28abd (0xfa bytes)
// Index: 60/100
_DWORD *BootGuardFindFitEntry()
{
int Pointer; // 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; /*0xffe28ac4*/
v13 = 0; /*0xffe28ac8*/
Pointer = PeiServicesGetPointer(); /*0xffe28acc*/
if ( (*(int (__cdecl **)(int, _DWORD, int *))(*(_DWORD *)Pointer + 56))(Pointer, 0, &v12) < 0 ) /*0xffe28ae2*/
return 0; /*0xffe28ae2*/
v1 = v12; /*0xffe28ae8*/
v2 = PeiServicesGetPointer(); /*0xffe28aec*/
if ( (*(int (__cdecl **)(void *, int, int *))(*(_DWORD *)v2 + 104))(&unk_FFE2C524, v1, &v13) < 0 ) /*0xffe28b06*/
return 0; /*0xffe28b06*/
v4 = (_DWORD *)(v13 + 44); /*0xffe28b10*/
if ( *(_DWORD *)(v13 + 44) != 1280134994 ) /*0xffe28b19*/
return 0; /*0xffe28baf*/
v5 = (_DWORD *)BuildGuidHob(v3, 48 * *(_DWORD *)(v13 + 56) + 16); /*0xffe28b29*/
if ( v5 ) /*0xffe28b32*/
{
*v5 = v4[1]; /*0xffe28b37*/
v5[1] = v4[2]; /*0xffe28b3c*/
src_1 = (unsigned int)(v4 + 4); /*0xffe28b3f*/
v5[2] = 48; /*0xffe28b42*/
v5[3] = 0; /*0xffe28b49*/
count = v4[2]; /*0xffe28b4f*/
src = (char *)(v4 + 4); /*0xffe28b56*/
v8 = (char *)(v5 + 4); /*0xffe28b5a*/
if ( v4 + 4 < (_DWORD *)((char *)v4 + count * v4[3] + 16) ) /*0xffe28b63*/
{
v9 = 16 - (_DWORD)v5; /*0xffe28b65*/
do /*0xffe28ba7*/
{
if ( count ) /*0xffe28b69*/
{
CopyMem(v8 + 8, src, count); /*0xffe28b73*/
src_1 = (unsigned int)src; /*0xffe28b79*/
}
*((_DWORD *)v8 + 1) = 0; /*0xffe28b7d*/
*(_DWORD *)v8 = &v8[v9 + 8]; /*0xffe28b86*/
v8 += 48; /*0xffe28b88*/
count = v4[2]; /*0xffe28b8b*/
src = (char *)(count + src_1); /*0xffe28b90*/
src_1 += count; /*0xffe28ba3*/
}
while ( src_1 < (unsigned int)v4 + count * v4[3] + 16 ); /*0xffe28ba7*/
}
}
return v4; /*0xffe28bb1*/
}
// Function: BootGuardIsAcmPostSuccess @ 0xffe28bb7 (0x23 bytes)
// Index: 61/100
unsigned int __thiscall BootGuardIsAcmPostSuccess(void *this)
{
_WORD *FirstGuidHob; // ecx
FirstGuidHob = GetFirstGuidHob(); /*0xffe28bbd*/
if ( !FirstGuidHob ) /*0xffe28bc1*/
{
BootGuardFindFitEntry(); /*0xffe28bc3*/
FirstGuidHob = GetFirstGuidHob(); /*0xffe28bcd*/
}
return FirstGuidHob != 0 ? (unsigned int)(FirstGuidHob + 24) : 0;
}
// Function: BootGuardGetFitEntryCount @ 0xffe28bda (0x41 bytes)
// Index: 62/100
unsigned int __thiscall BootGuardGetFitEntryCount(char *this)
{
char *v1; // esi
char *v2; // edi
unsigned int v3; // esi
if ( this /*0xffe28c0e*/
&& (v1 = this - 8, v2 = &v1[-*(_DWORD *)v1], BaseIsZeroGuid((int)(v2 + 8), (int)&gBootGuardHobGuid))
&& (v3 = (unsigned int)&v1[*((_DWORD *)v2 + 8)], (unsigned int)(v2 + 40) <= v3)
&& (unsigned int)&v2[*((unsigned __int16 *)v2 + 1)] > v3 )
{
return v3 + 8; /*0xffe28c10*/
}
else
{
return 0; /*0xffe28c15*/
}
}
// Function: BootGuardInitialize @ 0xffe28c1b (0x1b bytes)
// Index: 63/100
int __fastcall BootGuardInitialize(int n2, int n50563586)
{
if ( byte_FFE2C634 ) /*0xffe28c22*/
return BootGuardPcdGetFunc(n2, n50563586); /*0xffe28c27*/
else
return -2147483645; /*0xffe28c30*/
}
// Function: BootGuardCheckCapability @ 0xffe28c36 (0x52 bytes)
// Index: 64/100
char BootGuardCheckCapability()
{
unsigned __int64 v0; // rax
v0 = __readmsr(0x13Au); /*0xffe28c3c*/
if ( (v0 & 0x100000000LL) != 0 ) /*0xffe28c45*/
{
DebugPrint(64, "[BootGuardTCG2.c] Bit 32 BootGuardCapability = 1 in MSR 0x13A\n"); /*0xffe28c4e*/
DebugPrint(64, "[BootGuardTCG2.c] Processor supports Boot Guard.\n"); /*0xffe28c5a*/
return 1; /*0xffe28c62*/
}
else
{
DebugPrint(0x80000000, "[BootGuardTCG2.c] Bit 32 BootGuardCapability = 0 in MSR 0x13A\n"); /*0xffe28c71*/
DebugPrint(0x80000000, "[BootGuardTCG2.c] Processor does not support Boot Guard.\n"); /*0xffe28c7c*/
return 0; /*0xffe28c84*/
}
}
// Function: BootGuardPrintHexBuffer @ 0xffe28c88 (0x4a bytes)
// Index: 65/100
int __fastcall BootGuardPrintHexBuffer(unsigned int i, int a2)
{
unsigned int j; // ebx
for ( j = 0; j < i; ++j ) /*0xffe28c99*/
{
if ( (j & 0xF) == 0 ) /*0xffe28c9e*/
DebugPrint(64, "\n"); /*0xffe28ca3*/
DebugPrint(64, " %02x", *(unsigned __int8 *)(j + a2)); /*0xffe28cb6*/
}
return DebugPrint(64, "\n"); /*0xffe28ccd*/
}
// Function: BootGuardPrintStructId @ 0xffe28cd2 (0x45 bytes)
// Index: 66/100
int __thiscall BootGuardPrintStructId(unsigned __int8 *this)
{
unsigned int i; // esi
DebugPrint(64, "StructureID:"); /*0xffe28cdd*/
for ( i = 0; i < 8; ++i ) /*0xffe28ce4*/
DebugPrint(64, "%c", *(this + i)); /*0xffe28cf2*/
return DebugPrint(64, "\nStructVersion[%02x]\n", *(this + 8)); /*0xffe28d14*/
}
// Function: BootGuardCheckMsrBootState @ 0xffe28d17 (0x89 bytes)
// Index: 67/100
int BootGuardCheckMsrBootState()
{
unsigned __int64 v0; // rax
char v1; // bl
const char *[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n; // [esp-4h] [ebp-14h]
v0 = __readmsr(0x13Au); /*0xffe28d20*/
v1 = v0; /*0xffe28d22*/
if ( (v0 & 1) != 0 ) /*0xffe28d27*/
[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n = "[BootGuardTCG2.c] NEM enabled in MSR 0x13A\n"; /*0xffe28d29*/
else
[BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n = "[BootGuardTCG2.c] NEM disable in MSR 0x13A\n"; /*0xffe28d30*/
DebugPrint(64, [BootGuardTCG2.c]_NEM_enabled_in_MSR_0x13A_n); /*0xffe28d39*/
if ( (v1 & 0x20) != 0 ) /*0xffe28d43*/
DebugPrint(64, "[BootGuardTCG2.c] Measure Boot enabled in MSR 0x13A\n"); /*0xffe28d4a*/
else
DebugPrint(64, "[BootGuardTCG2.c] Measure Boot disable in MSR 0x13A\n"); /*0xffe28d52*/
if ( (v1 & 8) != 0 ) /*0xffe28d5c*/
DebugPrint(64, "[BootGuardTCG2.c] Tpm Success in MSR 0x13A\n"); /*0xffe28d63*/
else
DebugPrint(64, "[BootGuardTCG2.c] Tpm Fail in MSR 0x13A\n"); /*0xffe28d6b*/
if ( (v1 & 0x29) == 0x29 )
{
DebugPrint(64, "[BootGuardTCG2.c] : ACM_PostSuccess : EFI_SUCCESS\n");
return 0; /*0xffe28d85*/
}
else
{
DebugPrint(64, "[BootGuardTCG2.c] : ACM_PostSuccess : EFI_UNSUPPORTED\n");
return -2147483645; /*0xffe28d94*/
}
}
// Function: BootGuardReadFitPointer @ 0xffe28da0 (0x59 bytes)
// Index: 68/100
unsigned __int64 BootGuardReadFitPointer()
{
unsigned __int64 result; // rax
result = __readmsr(0x13Au) >> 4; /*0xffe28ded*/
LOBYTE(result) = (2 /*0xffe28df2*/
* (((MEMORY[0xFED3032C] & 0x20) != 0)
| (2
* (((MEMORY[0xFED3032C] & 0x40) != 0)
| (2 * (((MEMORY[0xFED3032C] & 0x80) != 0) | (2 * (MEMORY[0xFED3032D] & 1))))))))
| result & 1;
return result; /*0xffe28df4*/
}
// Function: BootGuardReadBpmMsr @ 0xffe28df9 (0x4b bytes)
// Index: 69/100
char BootGuardReadBpmMsr()
{
unsigned __int64 v0; // rax
char v2; // [esp+4h] [ebp-4h]
v2 = MEMORY[0xFED3032C]; /*0xffe28e05*/
v0 = __readmsr(0x13Au); /*0xffe28e0d*/
return ((v0 & 0x20) != 0) | (2 * (((v0 & 0x40) != 0) | (2 * ((v2 & 0x10) != 0)))); /*0xffe28e3f*/
}
// Function: BootGuardGetTcgHob @ 0xffe28e44 (0xab bytes)
// Index: 70/100
int __cdecl BootGuardGetTcgHob(int a1, int src, int Boot_Guard_Measured_S_CRTM, int n27)
{
int v4; // ecx
int v5; // ebp
_WORD *NextHob; // eax
_WORD *v8; // ebx
char *v9; // edi
_WORD *v10; // [esp+10h] [ebp-4h] BYREF
v5 = v4; /*0xffe28e47*/
if ( (*(int (__cdecl **)(int, _WORD **))(*(_DWORD *)v4 + 48))(v4, &v10) < 0 )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 285);
return -2147483634; /*0xffe28e79*/
}
NextHob = GetNextHob((int)&unk_FFE2C608, v10); /*0xffe28e84*/
if ( !NextHob )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 292);
return -2147483634; /*0xffe28e99*/
}
v8 = NextHob + 12; /*0xffe28e9e*/
v9 = (char *)NextHob + *((_DWORD *)NextHob + 7) + 24; /*0xffe28ea1*/
*((_DWORD *)v9 + 10) = 0; /*0xffe28ea9*/
*((_DWORD *)v9 + 11) = 7; /*0xffe28ead*/
v9 += 48; /*0xffe28eb4*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)v5 + 80))(v9, src, 20); /*0xffe28ebb*/
*((_DWORD *)v9 + 5) = n27; /*0xffe28ec5*/
v9 += 24; /*0xffe28ec8*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)v5 + 80))(v9, Boot_Guard_Measured_S_CRTM, n27); /*0xffe28ed4*/
++*((_DWORD *)v8 + 2); /*0xffe28ee1*/
*((_DWORD *)v8 + 1) = v9 - (char *)v8 + n27 - 40; /*0xffe28ee4*/
return 0; /*0xffe28ee9*/
}
// Function: CreateBootGuardTpm12Event @ 0xffe28eef (0xb5 bytes)
// Index: 71/100
int __cdecl CreateBootGuardTpm12Event(int a1, char *src)
{
int v2; // ecx
int v3; // esi
int v5; // [esp-4h] [ebp-60h]
int src_1[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; /*0xffe28f02*/
DebugPrint(64, "BootGuardTCG2.c[%d] : Enter CreateBootGuardTPM12Event(...)\n", 341);
(*(void (__cdecl **)(int *, int, _DWORD))(*(_DWORD *)v3 + 84))(src_1, 64, 0); /*0xffe28f16*/
if ( (*(int (__cdecl **)(int, _WORD **))(*(_DWORD *)v3 + 48))(v3, &v9) < 0 )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 349);
return -2147483634; /*0xffe28f48*/
}
if ( !GetNextHob((int)&unk_FFE2C608, v9) )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 356);
return -2147483634; /*0xffe28f65*/
}
p_src = src; /*0xffe28f6d*/
n804 = 804; /*0xffe28f75*/
GetGuidHobDataSize(1, &p_src, (int)&n804, (int)src_1); /*0xffe28f82*/
return BootGuardGetTcgHob(v5, (int)src_1, (int)"Boot Guard Measured S-CRTM", 27); /*0xffe28f9f*/
}
// Function: LogBootGuardTpm20Event @ 0xffe28fa4 (0x188 bytes)
// Index: 72/100
int __fastcall LogBootGuardTpm20Event(
int this,
int n7,
int n7a,
int src,
int srca,
int FIT_Type_0x02_Measured_S_CRTM,
int n30)
{
_WORD *NextHob; // eax
_WORD *v11; // ebx
_DWORD *v12; // edi
_DWORD *v13; // edi
_DWORD *v14; // esi
char *v15; // edi
char *v16; // edi
_DWORD *v17; // edi
char *v18; // edi
char *v19; // ecx
int v20; // eax
_WORD *v21; // [esp+14h] [ebp-4h] BYREF
DebugPrint(64, "BootGuardTCG2.c[%d] : Enter LogBootGuardTPM20Event(...)\n", 394);
if ( (*(int (__cdecl **)(int, _WORD **))(*(_DWORD *)this + 48))(this, &v21) < 0 )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 400);
return -2147483634; /*0xffe28ff0*/
}
NextHob = GetNextHob((int)&unk_FFE2C5D8, v21); /*0xffe28ffe*/
if ( !NextHob )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 408);
return -2147483634; /*0xffe29013*/
}
v11 = NextHob + 12; /*0xffe29015*/
DebugPrint(64, "BootGuardTCG2.c[%d] : TcgLog Addr 0x%x\n", 413, NextHob + 12);
if ( (*((_DWORD *)v11 + 8) & 3) != 0 )
{
if ( !*((_DWORD *)v11 + 3) )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : For Invalid parameter\n", 424);
return -2147483634; /*0xffe29067*/
}
v12 = (_DWORD *)*((_DWORD *)v11 + 4); /*0xffe2906c*/
*v12++ = n7; /*0xffe29076*/
*v12 = n7a; /*0xffe2907a*/
v13 = v12 + 1; /*0xffe2907c*/
if ( *((_DWORD *)v11 + 3) == 1 ) /*0xffe29082*/
{
(*(void (__cdecl **)(_DWORD *, int, int))(*(_DWORD *)this + 80))(v13, src, 20); /*0xffe2908e*/
v13 += 5; /*0xffe29094*/
}
else if ( *((_DWORD *)v11 + 3) == 2 ) /*0xffe2909d*/
{
*v13 = 0; /*0xffe2909f*/
v14 = v13++; /*0xffe290a2*/
if ( (v11[16] & 1) != 0 ) /*0xffe290aa*/
{
*(_WORD *)v13 = 4; /*0xffe290ac*/
v15 = (char *)v13 + 2; /*0xffe290af*/
++*v14; /*0xffe290b2*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)this + 80))(v15, src, 20); /*0xffe290be*/
v13 = v15 + 20; /*0xffe290c4*/
}
if ( (v11[16] & 2) != 0 ) /*0xffe290cb*/
{
*(_WORD *)v13 = 11; /*0xffe290d0*/
v16 = (char *)v13 + 2; /*0xffe290d3*/
++*v14; /*0xffe290d6*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)this + 80))(v16, srca, 32); /*0xffe290e2*/
v13 = v16 + 32; /*0xffe290e8*/
}
}
*v13 = n30; /*0xffe290ef*/
v17 = v13 + 1; /*0xffe290f1*/
(*(void (__cdecl **)(_DWORD *, int, int))(*(_DWORD *)this + 80))(v17, FIT_Type_0x02_Measured_S_CRTM, n30); /*0xffe290fd*/
v18 = (char *)v17 + n30; /*0xffe29103*/
*((_DWORD *)v11 + 6) = *((_DWORD *)v11 + 4); /*0xffe29107*/
v19 = &v18[-*((_DWORD *)v11 + 4)]; /*0xffe2910a*/
v20 = *((_DWORD *)v11 + 5); /*0xffe29110*/
*((_DWORD *)v11 + 5) = 0; /*0xffe29113*/
*((_DWORD *)v11 + 1) += v19; /*0xffe29117*/
++*((_DWORD *)v11 + 2); /*0xffe2911a*/
*((_DWORD *)v11 + 7) = v20; /*0xffe2911d*/
*((_DWORD *)v11 + 4) = v18; /*0xffe29122*/
return 0; /*0xffe29120*/
}
else
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Err ActPcrBanks, No SHA1/SHA256 banks\n", 417);
return -2147483646; /*0xffe2904d*/
}
}
// Function: CreateBootGuardTpm20Event @ 0xffe2912c (0x152 bytes)
// Index: 73/100
int __fastcall CreateBootGuardTpm20Event(
int a1,
int n7,
int n3,
unsigned __int8 *src,
int n100,
int Boot_Guard_Measured_S_CRTM,
int n17)
{
_WORD *NextHob; // eax
_WORD *v11; // esi
unsigned int n2; // eax
int p_n256; // [esp+10h] [ebp-40h] BYREF
char *p_src; // [esp+14h] [ebp-3Ch] BYREF
_WORD *v15; // [esp+18h] [ebp-38h] BYREF
int src_1[5]; // [esp+1Ch] [ebp-34h] BYREF
int src_2[8]; // [esp+30h] [ebp-20h] BYREF
DebugPrint(64, "BootGuardTCG2.c[%d] : Enter CreateBootGuardTPM20Event(...)\n", 503);
(*(void (__cdecl **)(int *, int, _DWORD))(*(_DWORD *)a1 + 84))(src_1, 20, 0); /*0xffe29156*/
(*(void (__cdecl **)(int *, int, _DWORD))(*(_DWORD *)a1 + 84))(src_2, 32, 0); /*0xffe29167*/
if ( (*(int (__cdecl **)(int, _WORD **))(*(_DWORD *)a1 + 48))(a1, &v15) < 0 )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs\n", 513);
return -2147483634; /*0xffe2919a*/
}
NextHob = GetNextHob((int)&unk_FFE2C5D8, v15); /*0xffe291a8*/
if ( !NextHob )
{
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 521);
return -2147483634; /*0xffe291bd*/
}
v11 = NextHob + 12; /*0xffe291bf*/
DebugPrint(64, "BootGuardTCG2.c[%d] : TcgLog Addr 0x%x\n", 526, NextHob + 12);
p_src = (char *)src; /*0xffe291df*/
n2 = *((_DWORD *)v11 + 3); /*0xffe291e3*/
p_n256 = n100; /*0xffe291e6*/
if ( n2 < 2 ) /*0xffe291ed*/
{
GetGuidHobDataSize(1, &p_src, (int)&p_n256, (int)src_1); /*0xffe2924d*/
}
else if ( n2 == 2 ) /*0xffe291f6*/
{
if ( (v11[16] & 1) != 0 && n100 ) /*0xffe29200*/
GetGuidHobDataSize(1, &p_src, (int)&p_n256, (int)src_1); /*0xffe29213*/
if ( (v11[16] & 2) != 0 ) /*0xffe2921e*/
{
if ( n100 ) /*0xffe29222*/
HashUpdateSha384(1, (unsigned __int8 **)&p_src, (int)&p_n256, src_2); /*0xffe29235*/
}
}
return LogBootGuardTpm20Event(a1, n7, n3, (int)src_1, (int)src_2, Boot_Guard_Measured_S_CRTM, n17); /*0xffe29276*/
}
// Function: BootGuardFindBpmStruct @ 0xffe2927e (0x97 bytes)
// Index: 74/100
int __fastcall BootGuardFindBpmStruct(int *SystemTable, int a2)
{
int v4; // eax
_DWORD v5[2]; // [esp+8h] [ebp-110h] BYREF
__int16 v6; // [esp+10h] [ebp-108h]
int v7; // [esp+12h] [ebp-106h]
int n8; // [esp+16h] [ebp-102h]
_BYTE v9[238]; // [esp+1Ah] [ebp-FEh] BYREF
_DWORD v10[4]; // [esp+108h] [ebp-10h] BYREF
v10[0] = 1416362782; /*0xffe2928a*/
v10[1] = 1079319820; /*0xffe29291*/
v10[2] = -196170332; /*0xffe29298*/
v10[3] = 985143231; /*0xffe2929f*/
if ( !a2 ) /*0xffe292a9*/
return -2147483634; /*0xffe292ab*/
v5[0] = 34; /*0xffe292b4*/
n8 = 8; /*0xffe292bf*/
v6 = 1; /*0xffe292c9*/
v4 = *SystemTable; /*0xffe292d2*/
v5[1] = 14; /*0xffe292e0*/
v7 = 0; /*0xffe292eb*/
(*(void (__cdecl **)(_BYTE *, _DWORD *, int))(v4 + 80))(v9, v10, 16); /*0xffe292f1*/
return (*(int (__cdecl **)(int, _DWORD, _DWORD, _BYTE *, _DWORD, int, _DWORD, _DWORD *))(a2 + 8))( /*0xffe2930f*/
a2,
0,
0,
v9,
0,
16,
0,
v5);
}
// Function: BootGuardCheckAmiTreePpi @ 0xffe29315 (0xcb bytes)
// Index: 75/100
int __thiscall BootGuardCheckAmiTreePpi(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 (__cdecl **v10)(_DWORD, int *, _DWORD *, int, _DWORD *, _BYTE *); // [esp+124h] [ebp-14h] BYREF
_DWORD v11[4]; // [esp+128h] [ebp-10h] BYREF
v11[0] = 1416362782; /*0xffe29325*/
v11[1] = 1079319820; /*0xffe29331*/
v2 = *this; /*0xffe29338*/
v11[2] = -196170332; /*0xffe29343*/
v11[3] = 985143231; /*0xffe2934b*/
v10 = 0; /*0xffe29352*/
v9[0] = 394082770; /*0xffe29355*/
v9[1] = 1086866360; /*0xffe2935c*/
v9[2] = 1362944410; /*0xffe29363*/
v9[3] = 513070744; /*0xffe2936a*/
v6[0] = 0; /*0xffe29371*/
v6[1] = 8; /*0xffe29377*/
v6[7] = 16; /*0xffe29381*/
(*(void (__cdecl **)(_BYTE *, _DWORD *, int))(v2 + 80))(v7, v11, 16); /*0xffe29387*/
v3 = (*(int (__cdecl **)(int *, _DWORD *, _DWORD, _DWORD, int (__cdecl ***)(_DWORD, int *, _DWORD *, int, _DWORD *, _BYTE *)))(*this + 32))( /*0xffe29397*/
this,
v9,
0,
0,
&v10);
v4 = v3; /*0xffe2939a*/
if ( v3 >= 0 ) /*0xffe293a1*/
return (*v10)(v10, this, v11, 16, v6, v8); /*0xffe293d4*/
DebugPrint(0x80000000, "[%d]: gTcgPpiguid NOT found %r \n", 645, v3);
return v4; /*0xffe293d9*/
}
// Function: BootGuardDetectTpmDevice @ 0xffe293e0 (0x12d bytes)
// Index: 76/100
int __thiscall BootGuardDetectTpmDevice(int *this)
{
int v2; // eax
_WORD *NextHob; // eax
int v5; // eax
_DWORD v7[4]; // [esp+Ch] [ebp-1Ch] BYREF
int v8; // [esp+1Ch] [ebp-Ch] BYREF
_WORD *v9; // [esp+20h] [ebp-8h] BYREF
int v10; // [esp+24h] [ebp-4h] BYREF
v7[0] = 394082770; /*0xffe293ea*/
v7[1] = 1086866360; /*0xffe293f3*/
v10 = 0; /*0xffe293fd*/
v2 = *this; /*0xffe29401*/
v8 = 0; /*0xffe2940b*/
v7[2] = 1362944410; /*0xffe2940e*/
v7[3] = 513070744; /*0xffe29415*/
if ( (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, int *))(v2 + 32))(this, &unk_FFE2C5F8, 0, 0, &v10) < 0 )
{
DebugPrint(64, "BootGuardTCG2.c[%d] : Can not locate Ami Tree Ppi, It may TPM 1.2 Device\n", 702);
goto LABEL_11; /*0xffe29430*/
}
if ( (*(int (__cdecl **)(int *, _WORD **))(*this + 48))(this, &v9) < 0 )
{
DebugPrint(64, "BootGuardTCG2.c[%d] : Can not locate PEI HOB Logs, It may TPM 1.2 Device\n", 710);
goto LABEL_11; /*0xffe2944c*/
}
NextHob = GetNextHob((int)&unk_FFE2C5E8, v9); /*0xffe29456*/
if ( *((_BYTE *)NextHob + 24) != 1 )
{
DebugPrint(64, "BootGuardTCG2.c[%d] : TrEEDeviceHob->Tpm20DeviceState = 0, It may TPM 1.2 Device\n", 725);
LABEL_11:
v5 = (*(int (__cdecl **)(int *, _DWORD *, _DWORD, _DWORD, int *))(*this + 32))(this, v7, 0, 0, &v8); /*0xffe294ac*/
if ( v5 >= 0 )
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TPM 1.2 found\n", 743);
return 1; /*0xffe29506*/
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: gTcgPpiguid NOT found %r\n", 738, v5);
DebugPrint(64, "BootGuardTCG2.c[%d]: No TPM\n", 739);
return 0; /*0xffe294ec*/
}
}
if ( *((_BYTE *)NextHob + 25) == 1 )
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TPM 2.0 found\n", 718);
return 2; /*0xffe2947b*/
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: PTT found\n", 721);
return 3; /*0xffe29497*/
}
}
// Function: BootGuardFindFitEntryInTable @ 0xffe2950d (0x62 bytes)
// Index: 77/100
int __fastcall BootGuardFindFitEntryInTable(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; /*0xffe29513*/
if ( MEMORY[0xFFFFFFC0] == -1 || !MEMORY[0xFFFFFFC0] )
{
v11 = MEMORY[0xFFFFFFC0]; /*0xffe29551*/
[BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n = "[BootGuardTCG2.c] : FindEntryInFit(%lx) is Invalid\n";
n64 = 0x80000000; /*0xffe29557*/
goto LABEL_10; /*0xffe29557*/
}
v5 = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe29524*/
v6 = 1; /*0xffe29529*/
if ( v5 <= 1 )
{
LABEL_7:
v11 = a1; /*0xffe2953e*/
[BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n = "[BootGuardTCG2.c] : Error, Did not find Tbl type = %x\n";
n64 = 64; /*0xffe29547*/
LABEL_10:
v2 = -2147483634; /*0xffe2955c*/
DebugPrint(n64, [BootGuardTCG2.c]_:_FindEntryInFit(%lx)_is_Invalid_n, v11); /*0xffe29561*/
return v2; /*0xffe29561*/
}
v7 = MEMORY[0xFFFFFFC0] + 16; /*0xffe2952e*/
while ( *(_BYTE *)(v7 + 14) != a1 ) /*0xffe29534*/
{
++v6; /*0xffe29536*/
v7 += 16; /*0xffe29537*/
if ( v6 >= v5 ) /*0xffe2953c*/
goto LABEL_7; /*0xffe2953c*/
}
*a2 = *(_DWORD *)v7; /*0xffe2954d*/
return v2; /*0xffe29569*/
}
// Function: LogTpm20LocalityStartup @ 0xffe2956f (0x6b bytes)
// Index: 78/100
int __fastcall LogTpm20LocalityStartup(int SystemTable, char n2)
{
int Boot_Guard_Measured_S_CRTM[4]; // [esp+Ch] [ebp-14h] BYREF
char n3; // [esp+1Ch] [ebp-4h]
DebugPrint(64, "BootGuardTCG2.c[%d] : Enter LogTpm20LocalityStartupEvent(...)\n", 842);
if ( n2 ) /*0xffe29591*/
{
(*(void (__cdecl **)(int *, int, _DWORD))(*(_DWORD *)SystemTable + 84))(Boot_Guard_Measured_S_CRTM, 16, 0); /*0xffe2959d*/
(*(void (__cdecl **)(int *, const char *, int))(*(_DWORD *)SystemTable + 80))( /*0xffe295b0*/
Boot_Guard_Measured_S_CRTM,
"StartupLocality",
16);
n3 = 3; /*0xffe295b6*/
CreateBootGuardTpm20Event(SystemTable, 0, 3, 0, 0, (int)Boot_Guard_Measured_S_CRTM, 17); /*0xffe295ca*/
}
return 0; /*0xffe295d2*/
}
// Function: BootGuardSkipLogAuthority @ 0xffe295da (0x76 bytes)
// Index: 79/100
int __fastcall BootGuardSkipLogAuthority(int SystemTable, char n2)
{
int FitEntryInTable; // eax
int v6; // [esp+Ch] [ebp-4h] BYREF
v6 = 0; /*0xffe295df*/
FitEntryInTable = BootGuardFindFitEntryInTable(0xCu, &v6); /*0xffe295ee*/
if ( FitEntryInTable >= 0 )
{
if ( (*(_DWORD *)(v6 + 28) & 2) != 0 )
{
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe2963d*/
LogTpm20LocalityStartup(SystemTable, n2); /*0xffe29643*/
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: Skip Log Authority Event\n", 893);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 884, FitEntryInTable);
}
return 0; /*0xffe29648*/
}
// Function: LogAuthorityPcrEvent @ 0xffe29650 (0x1b5 bytes)
// Index: 80/100
int __fastcall LogAuthorityPcrEvent(int SystemTable, char n2)
{
int FitEntryInTable; // eax
int FitEntryInTable_1; // edi
int FitEntryInTable_2; // eax
int FitEntryInTable_3; // eax
int p_n256_1; // esi
int v10; // [esp+10h] [ebp-74h] BYREF
unsigned __int8 *p_src; // [esp+14h] [ebp-70h] BYREF
int p_n256; // [esp+18h] [ebp-6Ch] BYREF
unsigned __int8 src_1[4]; // [esp+1Ch] [ebp-68h] BYREF
char v14[32]; // [esp+20h] [ebp-64h] BYREF
char src[32]; // [esp+40h] [ebp-44h] BYREF
char v16[36]; // [esp+60h] [ebp-24h] BYREF
p_n256 = 0; /*0xffe29666*/
v10 = 0; /*0xffe2966a*/
p_src = 0; /*0xffe2966e*/
DebugPrint(64, "[BootGuardTCG2.c] : Enter LogAuthorityPCREvent(...)\n");
FitEntryInTable = BootGuardFindFitEntryInTable(0xCu, &v10); /*0xffe2967f*/
FitEntryInTable_1 = FitEntryInTable; /*0xffe29684*/
if ( FitEntryInTable >= 0 )
{
if ( (*(_DWORD *)(v10 + 28) & 4) != 0 )
{
src_1[0] = BootGuardReadFitPointer(); /*0xffe296cf*/
DebugPrint(64, "BP->RSTR:[%x]\n", src_1[0]); /*0xffe296dd*/
src_1[1] = BootGuardReadBpmMsr(); /*0xffe296ea*/
DebugPrint(64, "BP->TYPE:[%x]\n", src_1[1]); /*0xffe296f8*/
FitEntryInTable_2 = BootGuardFindFitEntryInTable(2u, &p_src); /*0xffe29706*/
FitEntryInTable_1 = FitEntryInTable_2; /*0xffe2970b*/
if ( FitEntryInTable_2 >= 0 )
{
*(_WORD *)&src_1[2] = IoWrite8((unsigned __int16 *)p_src + 14); /*0xffe29728*/
DebugPrint(64, "BP->ACM_SVN = [%x]\n", *(unsigned __int16 *)&src_1[2]); /*0xffe29737*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)SystemTable + 80))(v14, -19725312, 32); /*0xffe2974e*/
FitEntryInTable_3 = BootGuardFindFitEntryInTable(0xBu, &p_n256); /*0xffe2975a*/
FitEntryInTable_1 = FitEntryInTable_3; /*0xffe2975f*/
if ( FitEntryInTable_3 >= 0 )
{
p_n256_1 = p_n256; /*0xffe29770*/
p_n256 = 256; /*0xffe2977a*/
p_src = (unsigned __int8 *)(p_n256_1 + 58); /*0xffe29786*/
HashUpdateSha384(1, &p_src, (int)&p_n256, src); /*0xffe29794*/
(*(void (__cdecl **)(char *, int, int))(*(_DWORD *)SystemTable + 80))(v16, p_n256_1 + 16, 32); /*0xffe297a7*/
DebugPrint(64, "BP Hash Structure, Size[%x]", 100); /*0xffe297b6*/
BootGuardPrintHexBuffer(0x64u, (int)src_1); /*0xffe297c5*/
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe297d7*/
return CreateBootGuardTpm20Event( /*0xffe297f9*/
SystemTable,
7,
-2147483647,
src_1,
100,
(int)L"Boot Guard Measured S-CRTM",
54);
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 989, FitEntryInTable_3);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 976, FitEntryInTable_2);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: Skip Log Authority Event\n", 959);
return 0; /*0xffe296c3*/
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 951, FitEntryInTable);
}
return FitEntryInTable_1; /*0xffe297fd*/
}
// Function: LogDetailPcrEvent @ 0xffe29805 (0x2d9 bytes)
// Index: 81/100
int __fastcall LogDetailPcrEvent(int SystemTable, char n2)
{
int FitEntryInTable; // eax
int v5; // esi
__int16 v6; // ax
int v7; // eax
unsigned __int8 *v8; // esi
int v9; // eax
int v10; // edi
int v11; // esi
int v12; // ecx
int src; // [esp+14h] [ebp-10h] BYREF
int v15; // [esp+18h] [ebp-Ch] BYREF
unsigned __int8 *v16; // [esp+1Ch] [ebp-8h] BYREF
int v17; // [esp+20h] [ebp-4h] BYREF
src = 0; /*0xffe2981d*/
v16 = 0; /*0xffe29821*/
v17 = 0; /*0xffe29825*/
v15 = 0; /*0xffe29829*/
DebugPrint(64, "[BootGuardTCG2.c] : Enter LogDetailPCREvent(...)\n");
if ( (*(int (__cdecl **)(int, int, int *))(*(_DWORD *)SystemTable + 76))(SystemTable, 804, &src) < 0 ) /*0xffe29847*/
return -2147483639; /*0xffe29849*/
DebugPrint(64, "MSR[0x%x]:[%08x]\n", 314, (unsigned int)__readmsr(0x13Au)); /*0xffe29867*/
DebugPrint(64, "ACM_STATUS:[%08x]\n", MEMORY[0xFED30328]); /*0xffe2987b*/
*(_BYTE *)src = BootGuardReadFitPointer(); /*0xffe2988c*/
DebugPrint(64, "BP->RSTR:[%x]\n", *(unsigned __int8 *)src); /*0xffe2989c*/
*(_BYTE *)(src + 1) = BootGuardReadBpmMsr(); /*0xffe298ad*/
DebugPrint(64, "BP->TYPE:[%x]\n", *(unsigned __int8 *)(src + 1)); /*0xffe298bf*/
FitEntryInTable = BootGuardFindFitEntryInTable(2u, &v15); /*0xffe298cd*/
if ( FitEntryInTable >= 0 )
{
v5 = v15; /*0xffe298ef*/
v6 = IoWrite8((unsigned __int16 *)(v15 + 28)); /*0xffe298f6*/
*(_WORD *)(src + 2) = v6; /*0xffe298ff*/
DebugPrint(64, "BP->ACM_SVN = [%x]\n", *(unsigned __int16 *)(src + 2)); /*0xffe29912*/
(*(void (__cdecl **)(int, int, int))(*(_DWORD *)SystemTable + 80))(src + 4, v5 + 388, 256); /*0xffe29931*/
BootGuardPrintHexBuffer(0x100u, src + 4); /*0xffe29940*/
v7 = BootGuardFindFitEntryInTable(0xBu, &v16); /*0xffe2994b*/
if ( v7 >= 0 )
{
v8 = v16; /*0xffe2995c*/
DebugPrint(64, "\nKmStructure: Addr[%lx]\n", v16);
BootGuardPrintStructId(v8); /*0xffe29971*/
(*(void (__cdecl **)(int, unsigned __int8 *, int))(*(_DWORD *)SystemTable + 80))(src + 260, v8 + 321, 256); /*0xffe2998a*/
BootGuardPrintHexBuffer(0x100u, src + 260); /*0xffe2999c*/
v9 = BootGuardFindFitEntryInTable(0xCu, &v17); /*0xffe299a7*/
if ( v9 >= 0 )
{
v10 = v17; /*0xffe299bb*/
DebugPrint(64, "\nBpmStructure: Addr[%lx]\n", v17);
BootGuardPrintStructId((unsigned __int8 *)v10); /*0xffe299d0*/
DebugPrint(64, "BpmStructure->Ibb_Element.EntryPoint[%x]\n", *(_DWORD *)(v10 + 108)); /*0xffe299de*/
DebugPrint(64, "BpmStructure->Ibb_Element.SegmentCount[%x]\n", *(unsigned __int8 *)(v10 + 148)); /*0xffe299f4*/
v11 = 12 * *(unsigned __int8 *)(v10 + 148); /*0xffe29a03*/
DebugPrint(64, "\nBpmStructure->Bpm_Signature_Element.KeySignaturee"); /*0xffe29a0c*/
(*(void (__cdecl **)(int, int, int))(*(_DWORD *)SystemTable + 80))(src + 516, v11 + v10 + 431, 256); /*0xffe29a2b*/
BootGuardPrintHexBuffer(0x100u, src + 516); /*0xffe29a40*/
DebugPrint(64, "\n\nBpmStructure->Digest_of_Hashed_IBB_Segment:"); /*0xffe29a4b*/
(*(void (__cdecl **)(int, int, int))(*(_DWORD *)SystemTable + 80))(src + 772, v10 + 116, 32); /*0xffe29a62*/
BootGuardPrintHexBuffer(0x20u, src + 772); /*0xffe29a75*/
DebugPrint(64, "BP Hash Structure, Size[%x]", 804); /*0xffe29a86*/
BootGuardPrintHexBuffer(0x324u, src); /*0xffe29a94*/
if ( n2 == 1 ) /*0xffe29a9f*/
{
CreateBootGuardTpm12Event(v12, (char *)src); /*0xffe29aab*/
}
else if ( n2 == 2 || n2 == 3 ) /*0xffe29ab8*/
{
CreateBootGuardTpm20Event( /*0xffe29acc*/
SystemTable,
0,
7,
(unsigned __int8 *)src,
804,
(int)"Boot Guard Measured S-CRTM",
27);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1099, v9);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1087, v7);
}
}
else
{
DebugPrint(64, "BootGuardTCG2.c[%d]: TRACE ERROR - %r\n", 1075, FitEntryInTable);
}
return 0; /*0xffe29ad6*/
}
// Function: LogTxtTpm12CrtmEvent @ 0xffe29ade (0x235 bytes)
// Index: 82/100
int __thiscall LogTxtTpm12CrtmEvent(void *this)
{
int TcgHob; // esi
int v2; // edi
unsigned int v3; // ebx
unsigned int v4; // eax
_BYTE *v5; // ebp
int v6; // ecx
int v7; // ebp
int v8; // ecx
unsigned int v9; // edx
int v10; // ecx
int i; // eax
int v13; // [esp-4h] [ebp-90h]
int v14; // [esp-4h] [ebp-90h]
int v16; // [esp+18h] [ebp-74h] BYREF
unsigned int v17; // [esp+1Ch] [ebp-70h]
int v18; // [esp+20h] [ebp-6Ch]
int src[5]; // [esp+24h] [ebp-68h] BYREF
int v20[10]; // [esp+38h] [ebp-54h] BYREF
char *p_src[11]; // [esp+60h] [ebp-2Ch] BYREF
TcgHob = 0; /*0xffe29af5*/
DebugPrint(64, "BootGuardTCG2.c[%d]: Enter LogTxtTpm12CRTMEvent\n", 1175);
v2 = MEMORY[0xFFFFFFC0]; /*0xffe29b02*/
v18 = MEMORY[0xFFFFFFC0]; /*0xffe29b04*/
if ( MEMORY[0xFFFFFFC0] == -1 )
{
TcgHob = -2147483642; /*0xffe29b1a*/
DebugPrint(64, "[%d] : FitEntryPointer(%lx) is empty\n", 1183, -1);
}
else if ( *MEMORY[0xFFFFFFC0] == 1414088287 && *(_DWORD *)(MEMORY[0xFFFFFFC0] + 4) == 538976351 )
{
v3 = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe29b45*/
if ( v3 > 1 )
{
v4 = v3 - 1; /*0xffe29b51*/
v5 = (_BYTE *)(MEMORY[0xFFFFFFC0] + 16); /*0xffe29b54*/
v17 = v3 - 1; /*0xffe29b57*/
do
{
if ( v5[14] == 2 )
{
v16 = *(_DWORD *)(*(_DWORD *)v5 + 20); /*0xffe29b74*/
(*(void (__cdecl **)(int *, int, _DWORD))(*(_DWORD *)this + 84))(src, 20, 0); /*0xffe29b7a*/
src[0] = v16; /*0xffe29b84*/
TcgHob = BootGuardGetTcgHob(v6, (int)src, (int)"FIT Type 0x02 Measured S-CRTM", 30); /*0xffe29b9c*/
if ( TcgHob < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1219);
v4 = v17; /*0xffe29bb9*/
}
v5 += 16; /*0xffe29bbd*/
v17 = --v4; /*0xffe29bc3*/
}
while ( v4 );
v2 = v18; /*0xffe29bc9*/
if ( TcgHob < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error TRACE CODE\n", 1227);
}
v7 = 0; /*0xffe29be5*/
if ( v3 > 1 )
{
v8 = v2 + 24; /*0xffe29bec*/
v9 = v3 - 1; /*0xffe29bef*/
do /*0xffe29c0f*/
{
if ( *(_BYTE *)(v8 + 6) == 7 ) /*0xffe29bf6*/
{
p_src[v7] = *(char **)(v8 - 8); /*0xffe29bfb*/
v20[v7++] = 16 * *(_DWORD *)v8; /*0xffe29c04*/
}
v8 += 16; /*0xffe29c09*/
--v9; /*0xffe29c0c*/
}
while ( v9 ); /*0xffe29c0f*/
if ( v7 )
{
GetGuidHobDataSize(v7, p_src, (int)v20, (int)src); /*0xffe29c25*/
TcgHob = BootGuardGetTcgHob(v13, (int)src, (int)"FIT Type 0x07 Measured S-CRTM", 30); /*0xffe29c44*/
if ( TcgHob < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1259);
}
}
v16 = 0; /*0xffe29c67*/
v10 = 1; /*0xffe29c6e*/
if ( v3 > 1 )
{
for ( i = v2 + 16; *(_BYTE *)(i + 14) != 45; i += 16 ) /*0xffe29c77*/
{
if ( ++v10 >= v3 ) /*0xffe29c86*/
return TcgHob; /*0xffe29c86*/
}
v16 = *(_DWORD *)i; /*0xffe29c90*/
v20[0] = 4; /*0xffe29c9a*/
p_src[0] = (char *)&v16; /*0xffe29ca2*/
GetGuidHobDataSize(1, p_src, (int)v20, (int)src); /*0xffe29cb1*/
TcgHob = BootGuardGetTcgHob(v14, (int)src, (int)"FIT Type 0x2D Measured S-CRTM", 30); /*0xffe29ccc*/
if ( TcgHob < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM12Event(...)\n", 1291);
}
}
else
{
TcgHob = -2147483642; /*0xffe29cee*/
DebugPrint(64, "[%d] : [Type 0] FitEntry->TblAddress(%lx) is error\n", 1191, *MEMORY[0xFFFFFFC0]);
}
return TcgHob; /*0xffe29d09*/
}
// Function: LogTxtTpm20CrtmEvent @ 0xffe29d13 (0x2ba bytes)
// Index: 83/100
int __thiscall LogTxtTpm20CrtmEvent(void *this)
{
int this_1; // ebp
int v2; // esi
int v3; // esi
unsigned int v4; // ebx
int v5; // edi
int v6; // esi
unsigned int v7; // ebp
int v8; // ebx
int v9; // eax
bool v10; // sf
int v11; // edi
int v12; // ecx
unsigned int v13; // edx
unsigned int v14; // ecx
int *v15; // eax
int v17; // [esp+14h] [ebp-A0h] BYREF
int this_2; // [esp+18h] [ebp-9Ch]
int v19; // [esp+1Ch] [ebp-98h]
int v20; // [esp+20h] [ebp-94h]
int v21; // [esp+24h] [ebp-90h]
unsigned int v22; // [esp+28h] [ebp-8Ch]
int src_1[5]; // [esp+2Ch] [ebp-88h] BYREF
int p_n256[10]; // [esp+40h] [ebp-74h] BYREF
unsigned __int8 *p_src[10]; // [esp+68h] [ebp-4Ch] BYREF
_BYTE src[36]; // [esp+90h] [ebp-24h] BYREF
v19 = 0; /*0xffe29d19*/
this_1 = (int)this; /*0xffe29d27*/
this_2 = (int)this; /*0xffe29d30*/
DebugPrint(64, "BootGuardTCG2.c[%d]: Enter LogTxtTpm20CRTMEvent\n", 1317);
v2 = MEMORY[0xFFFFFFC0]; /*0xffe29d3f*/
v21 = MEMORY[0xFFFFFFC0]; /*0xffe29d41*/
if ( MEMORY[0xFFFFFFC0] == -1 )
{
v3 = -2147483642; /*0xffe29d58*/
DebugPrint(64, "[%d] : FitEntryPointer(%lx) is empty\n", 1325, -1);
}
else if ( *MEMORY[0xFFFFFFC0] == 1414088287 && *(_DWORD *)(MEMORY[0xFFFFFFC0] + 4) == 538976351 )
{
v4 = *(_DWORD *)(MEMORY[0xFFFFFFC0] + 8); /*0xffe29d86*/
v20 = 0; /*0xffe29d89*/
v22 = v4; /*0xffe29d8e*/
if ( v4 > 1 )
{
v5 = MEMORY[0xFFFFFFC0] + 16; /*0xffe29d9b*/
v6 = v19; /*0xffe29d9e*/
v7 = v4 - 1; /*0xffe29da2*/
v8 = v20; /*0xffe29da5*/
do
{
if ( *(_BYTE *)(v5 + 14) == 2 )
{
v9 = *(_DWORD *)v5; /*0xffe29db3*/
p_n256[v8] = 4; /*0xffe29db9*/
v17 = *(_DWORD *)(v9 + 20); /*0xffe29dc4*/
p_src[v8++] = (unsigned __int8 *)&v17; /*0xffe29dcc*/
HashUpdateSha384(v8, p_src, (int)p_n256, src); /*0xffe29de0*/
GetGuidHobDataSize(v8, (char **)p_src, (int)p_n256, (int)src_1); /*0xffe29df5*/
v6 = LogBootGuardTpm20Event(this_2, 0, 7, (int)src_1, (int)src, (int)"FIT Type 0x02 Measured S-CRTM", 30); /*0xffe29e1b*/
if ( v6 < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1366);
}
v5 += 16; /*0xffe29e38*/
--v7; /*0xffe29e3b*/
}
while ( v7 );
v4 = v22; /*0xffe29e44*/
v10 = v6 < 0; /*0xffe29e48*/
v2 = v21; /*0xffe29e4a*/
if ( v10 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error TRACE CODE\n", 1374);
this_1 = this_2; /*0xffe29e64*/
}
v11 = 0; /*0xffe29e68*/
if ( v4 > 1 )
{
v12 = v2 + 24; /*0xffe29e73*/
v13 = v4 - 1; /*0xffe29e76*/
do /*0xffe29e96*/
{
if ( *(_BYTE *)(v12 + 6) == 7 ) /*0xffe29e7d*/
{
p_src[v11] = *(unsigned __int8 **)(v12 - 8); /*0xffe29e82*/
p_n256[v11++] = 16 * *(_DWORD *)v12; /*0xffe29e8b*/
}
v12 += 16; /*0xffe29e90*/
--v13; /*0xffe29e93*/
}
while ( v13 ); /*0xffe29e96*/
if ( v11 )
{
HashUpdateSha384(v11, p_src, (int)p_n256, src); /*0xffe29eaf*/
GetGuidHobDataSize(v11, (char **)p_src, (int)p_n256, (int)src_1); /*0xffe29ec4*/
if ( LogBootGuardTpm20Event(this_1, 0, 7, (int)src_1, (int)src, (int)"FIT Type 0x07 Measured S-CRTM", 30) < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1408);
}
}
v17 = 0; /*0xffe29f03*/
v14 = 1; /*0xffe29f0b*/
if ( v4 > 1 ) /*0xffe29f0f*/
{
v15 = (int *)(v2 + 16); /*0xffe29f11*/
while ( *((_BYTE *)v15 + 14) != 45 ) /*0xffe29f18*/
{
++v14; /*0xffe29f1a*/
v15 += 4; /*0xffe29f1b*/
if ( v14 >= v4 ) /*0xffe29f20*/
goto LABEL_28; /*0xffe29f20*/
}
v17 = *v15; /*0xffe29f26*/
}
LABEL_28:
p_n256[0] = 4; /*0xffe29f2a*/
p_src[0] = (unsigned __int8 *)&v17; /*0xffe29f36*/
HashUpdateSha384(1, p_src, (int)p_n256, src); /*0xffe29f4d*/
GetGuidHobDataSize(1, (char **)p_src, (int)p_n256, (int)src_1); /*0xffe29f62*/
v3 = LogBootGuardTpm20Event(this_1, 0, 7, (int)src_1, (int)src, (int)"FIT Type 0x2D Measured S-CRTM", 30); /*0xffe29f86*/
if ( v3 < 0 )
DebugPrint(64, "BootGuardTCG2.c[%d]: Error LogBootGuardTPM20Event(...)\n", 1445);
}
else
{
v3 = -2147483642; /*0xffe29fb3*/
DebugPrint(64, "[%d] : [Type 0] FitEntry->TblAddress(%lx) is error\n", 1333, *MEMORY[0xFFFFFFC0]);
}
return v3; /*0xffe29fc0*/
}
// Function: BootGuardTcg2MeasureCrtm @ 0xffe29fcd (0x223 bytes)
// Index: 84/100
int __cdecl BootGuardTcg2MeasureCrtm(int *SystemTable)
{
char n2; // bl
unsigned __int64 v2; // rax
int v3; // eax
int Msr64; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v10[3]; // [esp+Ch] [ebp-Ch] BYREF
v10[0] = 0; /*0xffe29fe7*/
DebugPrint(64, "BootGuardTCG2.c[%d]: Enter BootGuardTcg2MeasureCRTMVersion\n", 1465);
n2 = BootGuardDetectTpmDevice(SystemTable); /*0xffe29fff*/
if ( (*(int (__cdecl **)(int *, void *, _DWORD, _DWORD, int *))(*SystemTable + 32))( /*0xffe2a016*/
SystemTable,
&unk_FFE2C5F8,
0,
0,
v10) < 0 )
v10[0] = 0; /*0xffe2a018*/
if ( MEMORY[0xFED300A4] < 0 )
{
DebugPrint(64, "[BootGuardTCG2.c] Bit 63 success in 0xFED300A0\n"); /*0xffe2a057*/
LABEL_7:
if ( BootGuardCheckCapability() == 1 && BootGuardCheckMsrBootState() >= 0 ) /*0xffe2a072*/
{
DebugPrint(64, "[BootGuardTCG2.c] Start the LogDetailPCREvent\n"); /*0xffe2a07f*/
v3 = BootGuardSkipLogAuthority((int)SystemTable, n2); /*0xffe2a08a*/
if ( v3 < 0 ) /*0xffe2a096*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v3); /*0xffe2a09f*/
Msr64 = BaseReadMsr64(); /*0xffe2a0a7*/
if ( Msr64 ) /*0xffe2a0ae*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a0bf*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1495,
"!EFI_ERROR (Status)");
}
v5 = LogDetailPcrEvent((int)SystemTable, n2); /*0xffe2a0c9*/
if ( v5 < 0 ) /*0xffe2a0d0*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v5); /*0xffe2a0d9*/
v6 = BaseReadMsr64(); /*0xffe2a0e1*/
if ( v6 ) /*0xffe2a0e8*/
(*(void (__cdecl **)(const char *, int, const char *))(v6 + 4))( /*0xffe2a0f9*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1497,
"!EFI_ERROR (Status)");
}
v7 = LogAuthorityPcrEvent((int)SystemTable, n2); /*0xffe2a103*/
if ( v7 < 0 ) /*0xffe2a10a*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0xffe2a117*/
v8 = BaseReadMsr64(); /*0xffe2a11f*/
if ( v8 ) /*0xffe2a126*/
(*(void (__cdecl **)(const char *, int, const char *))(v8 + 4))( /*0xffe2a13b*/
"e:\\hs\\PurleyPlatPkg\\BootGuard\\BootGuardTCG2\\BootGuardTCG2.c",
1499,
"!EFI_ERROR (Status)");
}
goto LABEL_27; /*0xffe2a13e*/
}
if ( LogTpm20LocalityStartup((int)SystemTable, n2) < 0 )
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1507);
if ( n2 == 1 )
{
if ( LogTxtTpm12CrtmEvent(SystemTable) >= 0 )
{
LABEL_27:
DebugPrint(64, "BootGuardTCG2.c[%d]: End of BootGuardTcg2MeasureCRTMVersion\n", 1524);
goto LABEL_28; /*0xffe2a1bc*/
}
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1513);
}
if ( (n2 == 2 || n2 == 3) && LogTxtTpm20CrtmEvent(SystemTable) < 0 )
DebugPrint(0x80000000, "BootGuardTCG2.c[%d] : Can not Find TCG HOB Logs\n", 1520);
goto LABEL_27; /*0xffe2a1a8*/
}
DebugPrint(64, "[BootGuardTCG2.c] Bit 63 fail in 0xFED300A0\n"); /*0xffe2a035*/
v2 = __readmsr(0x13Au); /*0xffe2a041*/
if ( (v2 & 0x20) != 0 ) /*0xffe2a048*/
goto LABEL_7; /*0xffe2a048*/
LABEL_28:
if ( n2 != 1 && (n2 == 2 || n2 == 3) ) /*0xffe2a1da*/
BootGuardFindBpmStruct(SystemTable, v10[0]); /*0xffe2a1e2*/
else
BootGuardCheckAmiTreePpi(SystemTable); /*0xffe2a1cb*/
return 0; /*0xffe2a1e7*/
}
// Function: BootGuardFitGetEntryType @ 0xffe2a1f0 (0x4f bytes)
// Index: 85/100
int BootGuardFitGetEntryType()
{
unsigned __int8 v0; // al
char n3; // al
char n3_1; // cl
v0 = __inbyte(0x70u); /*0xffe2a1f6*/
__outbyte(0x70u, v0 & 0x80 | 0x4A); /*0xffe2a1fb*/
n3 = __inbyte(0x71u); /*0xffe2a202*/
n3_1 = n3; /*0xffe2a203*/
if ( (unsigned __int8)n3 <= 3u ) /*0xffe2a208*/
{
LABEL_4:
if ( !n3_1 ) /*0xffe2a223*/
return 0; /*0xffe2a223*/
goto LABEL_5; /*0xffe2a223*/
}
n3_1 = n3; /*0xffe2a20a*/
if ( !n3 ) /*0xffe2a212*/
{
n3_1 = MEMORY[0xFDAF0490] & 2 | 1; /*0xffe2a21e*/
goto LABEL_4; /*0xffe2a21e*/
}
LABEL_5:
if ( n3_1 != -1 )
return n3_1 != 1 ? -2147483578 : -2147483644;
return 0; /*0xffe2a23b*/
}
// Function: PeiServicesGetPointer @ 0xffe2a23f (0x32 bytes)
// Index: 86/100
int PeiServicesGetPointer()
{
int v0; // esi
_BYTE v2[2]; // [esp+4h] [ebp-8h] BYREF
int v3; // [esp+6h] [ebp-6h]
BaseReadIdtr(v2); /*0xffe2a248*/
v0 = *(_DWORD *)(v3 - 4); /*0xffe2a250*/
if ( !v0 ) /*0xffe2a255*/
AmiTpm20LocatePpi( /*0xffe2a264*/
(int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c",
48,
(int)"PeiServices != ((void *) 0)");
return v0; /*0xffe2a26c*/
}
// Function: BaseReadIdtr @ 0xffe2a271 (0x23 bytes)
// Index: 87/100
void *__thiscall BaseReadIdtr(void *this)
{
void *this_1; // eax
if ( !this ) /*0xffe2a277*/
AmiTpm20LocatePpi((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)"); /*0xffe2a286*/
this_1 = this; /*0xffe2a28c*/
__sidt(this); /*0xffe2a28f*/
return this_1; /*0xffe2a293*/
}
// Function: InternalGetHobList @ 0xffe2a2b1 (0x6e bytes)
// Index: 88/100
int InternalGetHobList()
{
int Pointer; // eax
int v1; // eax
int Msr64; // eax
int v3; // eax
int v5; // [esp+4h] [ebp-4h] BYREF
Pointer = PeiServicesGetPointer(); /*0xffe2a2b6*/
v1 = (*(int (__cdecl **)(int, int *))(*(_DWORD *)Pointer + 48))(Pointer, &v5); /*0xffe2a2c2*/
if ( v1 < 0 ) /*0xffe2a2ce*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0xffe2a2db*/
Msr64 = BaseReadMsr64(); /*0xffe2a2e3*/
if ( Msr64 ) /*0xffe2a2ea*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a2f4*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
50,
"!EFI_ERROR (Status)");
}
if ( !v5 ) /*0xffe2a2fe*/
{
v3 = BaseReadMsr64(); /*0xffe2a300*/
if ( v3 ) /*0xffe2a307*/
(*(void (__cdecl **)(const char *, int, const char *))(v3 + 4))( /*0xffe2a311*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
51,
"HobList != ((void *) 0)");
}
return v5; /*0xffe2a31a*/
}
// Function: GetFirstHob @ 0xffe2a31f (0x45 bytes)
// Index: 89/100
_WORD *__fastcall GetFirstHob(int a1, _WORD *a2)
{
_WORD *v2; // esi
int Msr64; // eax
v2 = a2; /*0xffe2a320*/
if ( !a2 ) /*0xffe2a324*/
{
Msr64 = BaseReadMsr64(); /*0xffe2a326*/
if ( Msr64 ) /*0xffe2a32d*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a33b*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
82,
"HobStart != ((void *) 0)");
}
while ( 1 ) /*0xffe2a354*/
{
if ( *v2 == 0xFFFF ) /*0xffe2a35a*/
return 0; /*0xffe2a35f*/
if ( *v2 == 4 ) /*0xffe2a34c*/
break; /*0xffe2a34c*/
v2 = (_WORD *)((char *)v2 + (unsigned __int16)v2[1]); /*0xffe2a352*/
}
return v2; /*0xffe2a35e*/
}
// Function: GetNextHob @ 0xffe2a364 (0x2c bytes)
// Index: 90/100
_WORD *__fastcall GetNextHob(int a1, _WORD *a2)
{
_WORD *FirstHob; // eax
_WORD *FirstHob_1; // esi
while ( 1 ) /*0xffe2a37f*/
{
FirstHob = GetFirstHob(a1, a2); /*0xffe2a37f*/
FirstHob_1 = FirstHob; /*0xffe2a384*/
if ( !FirstHob || BaseIsZeroGuid(a1, (int)(FirstHob + 4)) ) /*0xffe2a370*/
break; /*0xffe2a370*/
a2 = (_WORD *)((char *)FirstHob_1 + (unsigned __int16)FirstHob_1[1]); /*0xffe2a37d*/
}
return FirstHob_1; /*0xffe2a38a*/
}
// Function: GetFirstGuidHob @ 0xffe2a390 (0x14 bytes)
// Index: 91/100
_WORD *__cdecl GetFirstGuidHob()
{
_WORD *HobList; // eax
HobList = (_WORD *)InternalGetHobList(); /*0xffe2a391*/
return GetNextHob((int)&gBootGuardHobGuid, HobList); /*0xffe2a3a3*/
}
// Function: GetNextGuidHob @ 0xffe2a3a4 (0x50 bytes)
// Index: 92/100
int __fastcall GetNextGuidHob(int a1, int a2)
{
int Pointer; // eax
int Msr64; // eax
int v6; // [esp+4h] [ebp-4h] BYREF
Pointer = PeiServicesGetPointer(); /*0xffe2a3ab*/
if ( (*(int (__cdecl **)(int, int, int, int *))(*(_DWORD *)Pointer + 52))(Pointer, 4, a2, &v6) < 0 ) /*0xffe2a3c3*/
v6 = 0; /*0xffe2a3c5*/
if ( !v6 ) /*0xffe2a3cd*/
{
Msr64 = BaseReadMsr64(); /*0xffe2a3cf*/
if ( Msr64 ) /*0xffe2a3d6*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a3e7*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
250,
"Hob != ((void *) 0)");
}
return v6; /*0xffe2a3c0*/
}
// Function: BuildGuidHob @ 0xffe2a3f4 (0x46 bytes)
// Index: 93/100
int __fastcall BuildGuidHob(int a1, unsigned int n0xFFE0)
{
int Msr64; // eax
int result; // eax
int v5; // esi
if ( n0xFFE0 > 0xFFE0 ) /*0xffe2a3fd*/
{
Msr64 = BaseReadMsr64(); /*0xffe2a3ff*/
if ( Msr64 ) /*0xffe2a406*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a417*/
"e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c",
421,
"DataLength <= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE))");
}
result = GetNextGuidHob(a1, n0xFFE0 + 24); /*0xffe2a420*/
v5 = result; /*0xffe2a425*/
if ( result ) /*0xffe2a429*/
{
BaseIsEqualMemGuid((void *)(result + 8)); /*0xffe2a430*/
return v5 + 24; /*0xffe2a435*/
}
return result; /*0xffe2a42b*/
}
// Function: IoWrite8 @ 0xffe2a43a (0x2e bytes)
// Index: 94/100
int __fastcall IoWrite8(unsigned __int16 *a1)
{
int Msr64; // eax
if ( ((unsigned __int8)a1 & 1) != 0 ) /*0xffe2a440*/
{
Msr64 = BaseReadMsr64(); /*0xffe2a442*/
if ( Msr64 ) /*0xffe2a449*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a45a*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
151,
"(Address & 1) == 0");
}
return *a1; /*0xffe2a466*/
}
// Function: BootGuardGetPcdPttSkip @ 0xffe2a498 (0x3 bytes)
// Index: 95/100
// (too small: 0x3 bytes)
// Function: BootGuardPcdGetFunc @ 0xffe2a49b (0x44 bytes)
// Index: 96/100
int __fastcall BootGuardPcdGetFunc(int n2, int n50563586)
{
int Pointer; // eax
int v6; // eax
if ( (unsigned __int8)n2 != 2 && (unsigned __int8)n2 != 3 ) /*0xffe2a4ac*/
return -2147483645; /*0xffe2a4ae*/
Pointer = PeiServicesGetPointer(); /*0xffe2a4b5*/
v6 = (*(int (__cdecl **)(int, int, int, _DWORD, void *, _DWORD))(*(_DWORD *)Pointer + 88))( /*0xffe2a4c8*/
Pointer,
n2,
n50563586,
0,
&unk_FFE2C5A4,
0);
return v6 != -1610612734 ? v6 : 0;
}
// Function: LibPcdGet32 @ 0xffe2a4df (0xc bytes)
// Index: 97/100
// (too small: 0xc bytes)
// Function: LibPcdSet32 @ 0xffe2a4eb (0x11 bytes)
// Index: 98/100
int __thiscall LibPcdSet32(void *this)
{
int v1; // ebx
int Msr64; // eax
v1 = LibPcdGet32(this) + 1024064; /*0xffe2a469*/
if ( (v1 & 1) != 0 ) /*0xffe2a46e*/
{
Msr64 = BaseReadMsr64(); /*0xffe2a470*/
if ( Msr64 ) /*0xffe2a477*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a488*/
"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c",
183,
"(Address & 1) == 0");
}
*(_WORD *)v1 = 1280; /*0xffe2a493*/
return 1280; /*0xffe2a497*/
}
// Function: LibPcdGetPtr @ 0xffe2a4fc (0x4f bytes)
// Index: 99/100
int __thiscall LibPcdGetPtr(void *this)
{
int BestGuid; // eax
int Msr64; // eax
int p_this; // [esp+0h] [ebp-4h] BYREF
p_this = (int)this; /*0xffe2a4ff*/
BestGuid = InternalGetBestGuid(0, (int)&p_this); /*0xffe2a50b*/
if ( BestGuid < 0 ) /*0xffe2a514*/
{
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", BestGuid); /*0xffe2a521*/
Msr64 = BaseReadMsr64(); /*0xffe2a529*/
if ( Msr64 ) /*0xffe2a530*/
(*(void (__cdecl **)(const char *, int, const char *))(Msr64 + 4))( /*0xffe2a53e*/
"e:\\hs\\MdePkg\\Library\\PeiPcdLib\\PeiPcdLib.c",
49,
"!EFI_ERROR (Status)");
}
return p_this; /*0xffe2a549*/
}
// Function: LShiftU64 @ 0xffe2a6b8 (0x1f bytes)
// Index: 100/100
unsigned __int64 __usercall LShiftU64@<edx:eax>(unsigned __int8 n0x40@<cl>, unsigned __int64 a2@<edx:eax>)
{
if ( n0x40 >= 0x40u ) /*0xffe2a6bb*/
return 0; /*0xffe2a6d2*/
else
return a2 >> n0x40; /*0xffe2a6c5*/
}