#include "TcgDxe.h"
//
// TcgDxe - UEFI Module (Regenerated from IDA)
// Total functions: 21
//
// Function: CompareMemInternal @ 0x330 (0x1d bytes)
// Index: 1/21
unsigned __int64 __fastcall CompareMemInternal(_BYTE *a1, _BYTE *a2, __int64 n16)
{
bool v6; // zf
do /*0x33b*/
{
if ( !n16 ) /*0x33b*/
break; /*0x33b*/
v6 = *a1++ == *a2++; /*0x33b*/
--n16; /*0x33b*/
}
while ( v6 ); /*0x33b*/
return (unsigned __int8)*(a1 - 1) - (unsigned __int64)(unsigned __int8)*(a2 - 1); /*0x34a*/
}
// Function: _mm_pause_w @ 0x350 (0x3 bytes)
// Index: 2/21
// (too small: 0x3 bytes)
// Function: __rdtsc_w @ 0x360 (0xa bytes)
// Index: 3/21
// (too small: 0xa bytes)
// Function: _enable_w @ 0x370 (0x2 bytes)
// Index: 4/21
// (too small: 0x2 bytes)
// Function: _disable_w @ 0x380 (0x2 bytes)
// Index: 5/21
// (too small: 0x2 bytes)
// Function: __getcallerseflags_w @ 0x390 (0x3 bytes)
// Index: 6/21
// (too small: 0x3 bytes)
// Function: _ModuleEntryPoint @ 0x3c0 (0x13 bytes)
// Index: 7/21
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
__int16 *v2; // rcx
TcgDxeDriverEntryPoint((__int64)ImageHandle, SystemTable); /*0x3c4*/
return TcgDxeCallbackHandler(v2); /*0x3ce*/
}
// Function: TcgDxeDriverEntryPoint @ 0x3d4 (0x154 bytes)
// Index: 8/21
void __fastcall TcgDxeDriverEntryPoint(__int64 ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
__int64 v3; // rax
_WORD *v4; // rax
_BYTE *v5; // rax
__int16 callerseflags_w; // bx
bool v7; // bl
unsigned __int32 v8; // edi
::ImageHandle = ImageHandle; /*0x3e3*/
if ( !ImageHandle ) /*0x3f7*/
sub_774( /*0x406*/
(__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
51,
(__int64)"gImageHandle != ((void *) 0)");
::SystemTable = (__int64)SystemTable; /*0x40b*/
if ( !SystemTable ) /*0x415*/
sub_774( /*0x424*/
(__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
57,
(__int64)"gST != ((void *) 0)");
BootServices = (__int64)SystemTable->BootServices; /*0x42d*/
if ( !BootServices ) /*0x437*/
sub_774( /*0x446*/
(__int64)"e:\\hs\\MdePkg\\Library\\UefiBootServicesTableLib\\UefiBootServicesTableLib.c",
63,
(__int64)"gBS != ((void *) 0)");
RuntimeServices = (__int64)SystemTable->RuntimeServices; /*0x44f*/
if ( !RuntimeServices ) /*0x459*/
sub_774( /*0x46c*/
(__int64)"e:\\hs\\MdePkg\\Library\\UefiRuntimeServicesTableLib\\UefiRuntimeServicesTableLib.c",
47,
(__int64)"gRT != ((void *) 0)");
sub_7B4(ImageHandle); /*0x471*/
v3 = sub_9EC(); /*0x476*/
qword_1300 = (*(__int64 (__fastcall **)(__int64))(v3 + 32))(5); /*0x488*/
if ( *(char *)sub_88C(1024068) >= 0 ) /*0x49a*/
{
v4 = (_WORD *)sub_88C(1024064); /*0x49f*/
sub_988(v4); /*0x4a7*/
v5 = (_BYTE *)sub_88C(1024068); /*0x4ae*/
*v5 |= 0x80u; /*0x4b8*/
}
callerseflags_w = _getcallerseflags_w(); /*0x4bf*/
disable_w(); /*0x4c2*/
v7 = (callerseflags_w & 0x200) != 0; /*0x4d1*/
v8 = sub_9BC(0x508u) & 0xFFFFFF; /*0x4db*/
_rdtsc_w(); /*0x4e1*/
while ( ((v8 + 357 - sub_9BC(0x508u)) & 0x800000) == 0 ) /*0x501*/
mm_pause_w(); /*0x4e8*/
_rdtsc_w(); /*0x503*/
if ( v7 ) /*0x50a*/
enable_w(); /*0x50c*/
else
disable_w(); /*0x513*/
}
// Function: TcgDxeCallbackHandler @ 0x528 (0x142 bytes)
// Index: 9/21
__int64 __fastcall TcgDxeCallbackHandler(__int16 *a1)
{
__int64 v1; // rbx
__int64 v2; // rdi
__int64 v3; // rsi
_BYTE *v4; // rdi
__int64 v5; // rsi
__int64 v6; // rdi
__int16 *v8; // [rsp+40h] [rbp+8h] BYREF
__int64 v9; // [rsp+48h] [rbp+10h] BYREF
_BYTE *v10; // [rsp+50h] [rbp+18h] BYREF
v8 = a1; /*0x52d*/
v1 = 0; /*0x540*/
v9 = 0; /*0x542*/
v2 = *(_QWORD *)(SystemTable + 104); /*0x547*/
if ( v2 ) /*0x552*/
{
v3 = *(_QWORD *)(SystemTable + 112) + 24 * v2; /*0x558*/
while ( 1 ) /*0x55c*/
{
v3 -= 24; /*0x55c*/
--v2; /*0x570*/
if ( !sub_AE8(v3, (__int64)&qword_12C0, 16) ) /*0x573*/
{
v8 = *(__int16 **)(v3 + 16); /*0x58b*/
if ( (sub_8C8(&v8, &v10) & 0x8000000000000000uLL) == 0LL ) /*0x598*/
break; /*0x598*/
}
if ( !v2 ) /*0x5a1*/
goto LABEL_6; /*0x5a1*/
}
v4 = v10; /*0x660*/
}
else
{
LABEL_6:
v4 = 0; /*0x5a3*/
}
v5 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_1280, 0, &v9); /*0x5c1*/
if ( v4 && *v4 == 1 ) /*0x5cc*/
(*(void (**)(void))(v9 + 48))(); /*0x5d3*/
if ( v5 >= 0 ) /*0x5d9*/
{
if ( (*(__int64 (**)(void))(v9 + 24))() < 0 ) /*0x5eb*/
sub_6EC(0x80000000LL, (__int64)"\n Possible ERROR Processing Ppi Request from O.S.\n"); /*0x5f6*/
if ( (*(__int64 (**)(void))(v9 + 16))() < 0 ) /*0x606*/
sub_6EC(0x80000000LL, (__int64)"\n Possible ERROR Processing Tcg Setup\n"); /*0x612*/
if ( (*(__int64 (**)(void))(v9 + 8))() < 0 ) /*0x622*/
sub_6EC(0x80000000LL, (__int64)"\n Possible ERROR Measuring PCI Option Roms\n"); /*0x62e*/
v6 = (*(__int64 (**)(void))(v9 + 32))(); /*0x63b*/
if ( v6 < 0 ) /*0x641*/
sub_6EC(0x80000000LL, (__int64)"\n Possible ERROR process Tcg Ready to boot Callback\n"); /*0x64d*/
return v6; /*0x652*/
}
return v1; /*0x658*/
}
// Function: GetDebugProtocol @ 0x66c (0x7f bytes)
// Index: 10/21
__int64 GetDebugProtocol()
{
__int64 result; // rax
unsigned __int64 n0x10; // rbx
__int64 v2; // rax
__int64 v3; // rcx
result = qword_12F0; /*0x676*/
if ( !qword_12F0 ) /*0x682*/
{
n0x10 = (*(__int64 (__fastcall **)(__int64))(BootServices + 24))(31); /*0x69b*/
(*(void (__fastcall **)(unsigned __int64))(BootServices + 32))(n0x10); /*0x69e*/
if ( n0x10 <= 0x10 ) /*0x6a5*/
{
v2 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_1290, 0, &qword_12F0); /*0x6c2*/
v3 = qword_12F0; /*0x6c8*/
if ( v2 < 0 ) /*0x6d2*/
v3 = 0; /*0x6d2*/
qword_12F0 = v3; /*0x6d6*/
return v3; /*0x6dd*/
}
else
{
return 0; /*0x6a7*/
}
}
return result; /*0x6e5*/
}
// Function: DebugPrint @ 0x6ec (0x88 bytes)
// Index: 11/21
void DebugPrint(UINTN ErrorLevel, const CHAR8 *Format, ...)
{
__int64 v3; // rax
__int64 v4; // r8
void (__fastcall **v5)(UINTN, const CHAR8 *, __int64 *); // r9
unsigned __int8 v6; // al
char n3_1; // al
char n3; // cl
va_list va; // [rsp+40h] [rbp+18h] BYREF
va_start(va, Format);
v3 = sub_66C(); /*0x703*/
v4 = 0; /*0x708*/
v5 = (void (__fastcall **)(UINTN, const CHAR8 *, __int64 *))v3; /*0x70b*/
if ( v3 ) /*0x711*/
{
v6 = __inbyte(0x70u); /*0x717*/
__outbyte(0x70u, v6 & 0x80 | 0x4B); /*0x71c*/
n3_1 = __inbyte(0x71u); /*0x721*/
n3 = n3_1; /*0x722*/
if ( (unsigned __int8)n3_1 > 3u ) /*0x728*/
{
n3 = n3; /*0x72a*/
if ( !n3 ) /*0x732*/
n3 = MEMORY[0xFDAF0490] & 2 | 1; /*0x73e*/
}
if ( (unsigned __int8)(n3 - 1) <= 0xFDu ) /*0x746*/
{
v4 = 2147483718LL; /*0x74f*/
if ( n3 == 1 ) /*0x755*/
v4 = 2147483652LL; /*0x755*/
}
if ( (v4 & ErrorLevel) != 0 ) /*0x75c*/
(*v5)(ErrorLevel, Format, (__int64 *)va); /*0x76b*/
}
}
// Function: AssertReport @ 0x774 (0x3e bytes)
// Index: 12/21
__int64 __fastcall AssertReport(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
result = GetDebugProtocol(); /*0x78c*/
if ( result ) /*0x794*/
return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(result + 8))(a1, a2, a3); /*0x79f*/
return result; /*0x7ac*/
}
// Function: DxeGetHobList @ 0x7b4 (0xd6 bytes)
// Index: 13/21
__int64 __fastcall DxeGetHobList(__int64 ImageHandle)
{
__int64 result; // rax
__int64 SystemTable; // rdi
unsigned __int64 v3; // rbx
__int64 v4; // rsi
result = qword_12F8; /*0x7c3*/
if ( !qword_12F8 ) /*0x7cd*/
{
SystemTable = SystemTable; /*0x7d3*/
v3 = 0; /*0x7da*/
qword_12F8 = 0; /*0x7dc*/
if ( *(_QWORD *)(SystemTable + 104) ) /*0x7e3*/
{
v4 = 0; /*0x7e9*/
while ( !sub_A78(ImageHandle, v4 + *(_QWORD *)(SystemTable + 112)) ) /*0x7f9*/
{
++v3; /*0x7fb*/
v4 += 24; /*0x7fe*/
if ( v3 >= *(_QWORD *)(SystemTable + 104) ) /*0x806*/
goto LABEL_6; /*0x806*/
}
result = *(_QWORD *)(*(_QWORD *)(SystemTable + 112) + 24 * v3 + 16); /*0x87c*/
qword_12F8 = result; /*0x881*/
}
else
{
LABEL_6:
sub_6EC(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", 0x800000000000000EuLL); /*0x808*/
sub_774((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 54, (__int64)"!EFI_ERROR (Status)"); /*0x836*/
result = qword_12F8; /*0x83b*/
}
if ( !result ) /*0x845*/
{
sub_774((__int64)"e:\\hs\\MdePkg\\Library\\DxeHobLib\\HobLib.c", 55, (__int64)"mHobList != ((void *) 0)"); /*0x858*/
return qword_12F8; /*0x85d*/
}
}
return result; /*0x86e*/
}
// Function: PciExpressLibAddress @ 0x88c (0x3a bytes)
// Index: 14/21
__int64 __fastcall PciExpressLibAddress(__int64 n1024064)
{
if ( (n1024064 & 0xFFFFFFFFF0000000uLL) != 0 ) /*0x89c*/
AssertReport( /*0x8b1*/
(__int64)"e:\\hs\\MdePkg\\Library\\SmmPciExpressLib\\PciExpressLib.c",
118,
(__int64)"((Address) & ~0xfffffff) == 0");
return n1024064 + qword_1300; /*0x8c0*/
}
// Function: DevicePathFindProtocolNode @ 0x8c8 (0xbd bytes)
// Index: 15/21
__int64 __fastcall DevicePathFindProtocolNode(__int16 **a1, _QWORD *a2)
{
__int64 v3; // rdi
__int16 *v5; // r8
__int16 *v6; // rbx
__int16 i; // ax
v3 = 0x800000000000000EuLL; /*0x8ed*/
while ( 1 ) /*0x8f8*/
{
v5 = *a1; /*0x8f8*/
if ( **a1 == -1 ) /*0x8ff*/
break; /*0x8ff*/
v6 = *a1; /*0x901*/
if ( v5 ) /*0x907*/
{
for ( i = *v5; i != -1 && i != 4; i = *v6 ) /*0x909*/
v6 = (__int16 *)((char *)v6 + (unsigned __int16)v6[1]); /*0x919*/
if ( *v6 == -1 ) /*0x927*/
v6 = *a1; /*0x927*/
}
if ( *v6 == 4 && !sub_AE8(qword_12B0, (_BYTE *)v6 + 8, 16) ) /*0x942*/
{
v3 = 0; /*0x950*/
*a2 = v6 + 12; /*0x952*/
}
*a1 = (__int16 *)((char *)v6 + (unsigned __int16)v6[1]); /*0x95c*/
if ( v3 >= 0 ) /*0x962*/
return v3; /*0x967*/
}
return 0x800000000000000EuLL; /*0x97b*/
}
// Function: IoWrite16 @ 0x988 (0x34 bytes)
// Index: 16/21
UINT16 __cdecl IoWrite16(UINTN Port, UINT16 Value)
{
if ( (Port & 1) != 0 ) /*0x994*/
AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLib.c", 183, (__int64)"(Address & 1) == 0"); /*0x9a9*/
*(_WORD *)Port = 1280; /*0x9b3*/
return 1280; /*0x9b6*/
}
// Function: IoRead32 @ 0x9bc (0x30 bytes)
// Index: 17/21
UINT32 __cdecl IoRead32(UINTN Port)
{
unsigned __int16 Port_1; // bx
Port_1 = Port; /*0x9c2*/
if ( (Port & 3) != 0 ) /*0x9c8*/
AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseIoLibIntrinsic\\IoLibMsc.c", 193, (__int64)"(Port & 3) == 0"); /*0x9dd*/
return __indword(Port_1); /*0x9e6*/
}
// Function: GetPcdProtocol @ 0x9ec (0x8c bytes)
// Index: 18/21
__int64 GetPcdProtocol()
{
__int64 result; // rax
__int64 v1; // rax
result = qword_1308; /*0x9f0*/
if ( !qword_1308 ) /*0x9fa*/
{
v1 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices + 320))(&unk_12A0, 0, &qword_1308); /*0xa13*/
if ( v1 < 0 ) /*0xa1c*/
{
DebugPrint(0x80000000LL, (__int64)"\nASSERT_EFI_ERROR (Status = %r)\n", v1); /*0xa2d*/
AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 78, (__int64)"!EFI_ERROR (Status)"); /*0xa45*/
}
result = qword_1308; /*0xa4a*/
if ( !qword_1308 ) /*0xa54*/
{
AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\DxePcdLib\\DxePcdLib.c", 79, (__int64)"mPcd != ((void *) 0)"); /*0xa67*/
return qword_1308; /*0xa6c*/
}
}
return result; /*0xa73*/
}
// Function: GuidCompare @ 0xa78 (0x6e bytes)
// Index: 19/21
bool __fastcall GuidCompare(__int64 ImageHandle, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rbx
__int64 v5; // rbp
__int64 v6; // rax
v3 = ReadUnaligned64((__int64)&qword_12C0); /*0xa9e*/
v4 = ReadUnaligned64(a2); /*0xaad*/
v5 = ReadUnaligned64((__int64)&unk_12C8); /*0xab9*/
v6 = ReadUnaligned64(a2 + 8); /*0xabc*/
return v3 == v4 && v5 == v6; /*0xae0*/
}
// Function: CompareMemWithAssert @ 0xae8 (0xd6 bytes)
// Index: 20/21
unsigned __int64 __fastcall CompareMemWithAssert(_BYTE *a1, _BYTE *a2, __int64 n16)
{
if ( a1 == a2 ) /*0xb0d*/
return 0; /*0xb0f*/
if ( !a1 ) /*0xb19*/
sub_774( /*0xb2c*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
60,
(__int64)"DestinationBuffer != ((void *) 0)");
if ( !a2 ) /*0xb34*/
sub_774( /*0xb47*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
61,
(__int64)"SourceBuffer != ((void *) 0)");
if ( n16 - 1 > (unsigned __int64)(-1LL - (_QWORD)a1) ) /*0xb5d*/
sub_774( /*0xb70*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
62,
(__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)DestinationBuffer)");
if ( n16 - 1 > (unsigned __int64)(-1LL - (_QWORD)a2) ) /*0xb7b*/
sub_774( /*0xb90*/
(__int64)"e:\\hs\\MdePkg\\Library\\BaseMemoryLibRepStr\\CompareMemWrapper.c",
63,
(__int64)"(Length - 1) <= (0xFFFFFFFFFFFFFFFFULL - (UINTN)SourceBuffer)");
return sub_330(a1, a2, n16); /*0xbb7*/
}
// Function: ReadUnaligned64 @ 0xbc0 (0x2f bytes)
// Index: 21/21
UINT64 __cdecl ReadUnaligned64(const UINT64 *Buffer)
{
if ( !Buffer ) /*0xbcc*/
AssertReport((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, (__int64)"Buffer != ((void *) 0)"); /*0xbe1*/
return *Buffer; /*0xbe9*/
}