Newer
Older
AMI-Aptio-BIOS-Reversed / KbcEmulDxe / KbcEmulDxe_43C.c
@Ajax Dong Ajax Dong 2 days ago 2 KB Init
// Original function: sub_43C
// Address: 0x43C
// Signature: __int64 __fastcall sub_43C(__int64 n33_1, EFI_SYSTEM_TABLE *SystemTable)

__int64 __fastcall sub_43C(__int64 n33_1, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_RUNTIME_SERVICES *RuntimeServices; // rax
  __int64 v3; // rbx
  __int64 v4; // rax
  __int64 n162; // rdx
  __int64 v6; // rax
  _BYTE v8[56]; // [rsp+30h] [rbp-38h] BYREF
  __int64 n33; // [rsp+70h] [rbp+8h] BYREF

  n33 = n33_1; /*0x43c*/
  if ( SystemTable_0 ) /*0x44e*/
  {
    RuntimeServices = (EFI_RUNTIME_SERVICES *)RuntimeServices_0; /*0x46f*/
  }
  else
  {
    SystemTable_0 = (__int64)SystemTable; /*0x450*/
    BootServices_0 = (__int64)SystemTable->BootServices; /*0x45b*/
    RuntimeServices = SystemTable->RuntimeServices; /*0x462*/
    RuntimeServices_0 = (__int64)RuntimeServices; /*0x466*/
  }
  n33 = 33; /*0x47b*/
  if ( ((__int64 (__fastcall *)(const __int16 *, void *, _QWORD, __int64 *, _BYTE *))RuntimeServices->GetVariable)( /*0x4b0*/
         L"UsbSupport",
         &unk_11B0,
         0,
         &n33,
         v8) < 0
    || !v8[7] )
  {
    return 0; /*0x5c6*/
  }
  v3 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_1190, 0, &qword_1258); /*0x4d3*/
  if ( v3 >= 0 ) /*0x4d9*/
  {
    byte_11F9 = 0; /*0x4f0*/
    v4 = (*(__int64 (__fastcall **)(void *, void *, _QWORD, __int64 (__fastcall **)()))(BootServices_0 + 128))( /*0x505*/
           &unk_1200,
           &unk_1170,
           0,
           off_11C0);
    v3 = v4; /*0x50b*/
    if ( v4 >= 0 ) /*0x511*/
    {
      if ( byte_11F9 ) /*0x54b*/
      {
        word_11E0 = -29952; /*0x552*/
        n43 = 43; /*0x55e*/
        return v3; /*0x565*/
      }
      v6 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)()))(BootServices_0 + 368))( /*0x59a*/
             512,
             8,
             sub_5D4);
      v3 = v6; /*0x5a0*/
      if ( v6 >= 0 ) /*0x5a6*/
        return v3; /*0x5a6*/
      sub_844(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v6); /*0x5b7*/
      n162 = 162; /*0x5bc*/
    }
    else
    {
      sub_844(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v4); /*0x522*/
      n162 = 143; /*0x527*/
    }
    sub_88C("e:\\hs\\AmiModulePkg\\KbcEmulation\\KbcEmulDxe.c", n162, "!EFI_ERROR (Status)"); /*0x53a*/
  }
  return v3; /*0x5cb*/
}