Newer
Older
AMI-Aptio-BIOS-Reversed / LenovoServerPkg / SystemInventory / SystemInventory / SystemInventory_sub_6028.c
@Ajax Dong Ajax Dong 2 days ago 7 KB Restructure the repo
__int64 __fastcall sub_6028(__int64 a1)
{
  __int64 v2; // rbx
  __int64 v3; // rdx
  __int64 v4; // rcx
  __int64 v5; // r8
  __int64 v6; // r9
  __int64 v7; // rbx
  __int64 v8; // rdx
  __int64 v9; // rcx
  __int64 v10; // r8
  __int64 v11; // r9
  __int64 v12; // rdx
  unsigned __int8 v13; // di
  __int64 v14; // r9
  __int64 v15; // rdx
  __int64 v16; // rcx
  __int64 v17; // r8
  __int64 v18; // r9
  __int64 v19; // rdx
  __int64 v20; // r9
  __int64 v21; // rdx
  __int64 v22; // rcx
  __int64 v23; // r8
  __int64 v24; // r9
  __int64 v25; // rdx
  __int64 v26; // rcx
  __int64 v27; // rbx
  __int64 v28; // r8
  __int64 v29; // r9
  __int64 v30; // rdx
  __int64 v31; // rcx
  __int64 v32; // r8
  __int64 v33; // r9
  __int64 v34; // rdx
  __int64 v35; // rcx
  __int64 v36; // r8
  __int64 v37; // r9
  __int64 v38; // rdx
  __int64 v39; // rcx
  __int64 v40; // r8
  __int64 v41; // r9
  __int64 v42; // rdx
  __int64 v43; // rcx
  __int64 v44; // rbx
  __int64 v45; // r8
  __int64 v46; // r9
  __int64 v47; // rdx
  __int64 v48; // rcx
  __int64 v49; // r8
  __int64 v50; // r9
  __int64 v51; // rdx
  __int64 v52; // rcx
  __int64 v53; // r8
  __int64 v54; // r9
  __int64 v55; // rdx
  __int64 v56; // rcx
  __int64 v57; // r8
  __int64 v58; // r9
  int v60; // [rsp+28h] [rbp-40h]
  unsigned __int8 v61; // [rsp+80h] [rbp+18h] BYREF

  v2 = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD *))(qword_96A8 + 64))(4, 3402, &p_n145); /*0x6064*/
  if ( (unsigned __int8)sub_7EC() && v2 < 0 ) /*0x6086*/
  {
    if ( (unsigned __int8)sub_7F8(v4, v3, v5, v6) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x6093*/
      sub_740(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v2); /*0x60a8*/
    sub_788("e:\\hs\\LenovoServerPkg\\SystemInventory\\SystemInventory.c", 1972, "!EFI_ERROR (Status)"); /*0x60b8*/
  }
  sub_63C(p_n145, 3402); /*0x60c7*/
  v7 = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(qword_96A8 + 320))(&unk_9460, 0, &qword_9690); /*0x60e9*/
  if ( (unsigned __int8)sub_7F8(v9, v8, v10, v11) && (unsigned __int8)sub_804(64) ) /*0x60fe*/
    sub_740(64, "[System Inventory] Locating IPMI Dxe Protocol Status - %r\n", v7); /*0x6114*/
  if ( v7 >= 0 )
  {
    v13 = sub_3F00(); /*0x6127*/
    if ( !v13 ) /*0x612c*/
      sub_5E88(2); /*0x6130*/
    byte_9699 = 1; /*0x613d*/
    LOBYTE(v14) = -85; /*0x614b*/
    LOBYTE(v12) = 50; /*0x615b*/
    qword_94B0 = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, __int64, _QWORD, _BYTE, unsigned __int8 *, char *))(qword_9690 + 16))( /*0x6175*/
                   qword_9690,
                   v12,
                   0,
                   v14,
                   0,
                   0,
                   &v61,
                   &byte_9699);
    v7 = qword_94B0; /*0x617c*/
    if ( qword_94B0 >= 0 ) /*0x6182*/
    {
      if ( (unsigned __int8)sub_7F8(v16, v15, v17, v18) && (unsigned __int8)sub_804(64) ) /*0x61bd*/
        sub_740(64, "Get the virtual USB Status = %x \n", v61); /*0x61d9*/
      if ( v61 != 1 ) /*0x61e6*/
        goto LABEL_42; /*0x61e6*/
    }
    else if ( (unsigned __int8)sub_7F8(v16, v15, v17, v18) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x6190*/
    {
      sub_740(0x80000000LL, "Get virtual USB status failed! Status = %r\n", qword_94B0); /*0x61aa*/
    }
    LOBYTE(v20) = -86; /*0x61fe*/
    LOBYTE(v60) = 1; /*0x6208*/
    LOBYTE(v19) = 50; /*0x621c*/
    qword_94B0 = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, __int64, void *, int, unsigned __int8 *, char *))(qword_9690 + 16))( /*0x6224*/
                   qword_9690,
                   v19,
                   0,
                   v20,
                   &unk_9698,
                   v60,
                   &v61,
                   &byte_9699);
    if ( (unsigned __int8)sub_7F8(v22, v21, v23, v24) && (unsigned __int8)sub_804(64) ) /*0x6237*/
      sub_740(64, "[System Inventory] Enabling BMC USB Interface by disabling Power saving in BMC - %r\n", qword_94B0); /*0x6251*/
    v27 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)(__int64, __int64, __int64, __int64)))(qword_96A8 + 80))( /*0x6282*/
            513,
            16,
            sub_3C80);
    if ( v27 < 0 )
    {
      if ( (unsigned __int8)sub_7F8(v26, v25, v28, v29) && (unsigned __int8)sub_804(0x80000000LL) )
        sub_740(0x80000000LL, "Create DisableBmcUsbInterface Event with exit_boot_service fail, Status: %r\n", v27);
      if ( (unsigned __int8)sub_7EC() ) /*0x62b1*/
      {
        if ( (unsigned __int8)sub_7F8(v31, v30, v32, v33) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x62c6*/
          sub_740(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v27); /*0x62dc*/
        sub_788("e:\\hs\\LenovoServerPkg\\SystemInventory\\SystemInventory.c", 2064, "!EFI_ERROR (Status)"); /*0x62ec*/
      }
    }
    v7 = sub_21C8(16, (__int64 (__fastcall *)(EFI_HANDLE, EFI_SYSTEM_TABLE *))sub_3C80, 0, (__int64)&qword_9718); /*0x630a*/
    if ( v7 < 0 )
    {
      if ( (unsigned __int8)sub_7F8(v35, v34, v36, v37) && (unsigned __int8)sub_804(0x80000000LL) )
        sub_740(0x80000000LL, "Create DisableBmcUsbInterface Event with legacy boot fail, Status: %r\n", v7);
      if ( (unsigned __int8)sub_7EC() ) /*0x6339*/
      {
        if ( (unsigned __int8)sub_7F8(v39, v38, v40, v41) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x634e*/
          sub_740(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0x6364*/
        sub_788("e:\\hs\\LenovoServerPkg\\SystemInventory\\SystemInventory.c", 2075, "!EFI_ERROR (Status)"); /*0x6374*/
      }
    }
LABEL_42:
    if ( !v13 )
    {
      v44 = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)(), _QWORD, void *))(qword_96A8 + 80))( /*0x63b2*/
              513,
              16,
              sub_3E1C,
              0,
              &unk_9710);
      if ( v44 < 0 )
      {
        if ( (unsigned __int8)sub_7F8(v43, v42, v45, v46) && (unsigned __int8)sub_804(0x80000000LL) )
          sub_740(0x80000000LL, "Create DisableBmcVirtualCD Event with exit_boot_service fail, Status: %r\n", v44);
        if ( (unsigned __int8)sub_7EC() ) /*0x63e1*/
        {
          if ( (unsigned __int8)sub_7F8(v48, v47, v49, v50) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x63f6*/
            sub_740(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v44); /*0x640c*/
          sub_788("e:\\hs\\LenovoServerPkg\\SystemInventory\\SystemInventory.c", 2091, "!EFI_ERROR (Status)"); /*0x641c*/
        }
      }
      v7 = sub_21C8(16, (__int64 (__fastcall *)(EFI_HANDLE, EFI_SYSTEM_TABLE *))sub_3E1C, 0, (__int64)&qword_9718); /*0x643a*/
      if ( v7 < 0 )
      {
        if ( (unsigned __int8)sub_7F8(v52, v51, v53, v54) && (unsigned __int8)sub_804(0x80000000LL) )
          sub_740(0x80000000LL, "Create DisableBmcVirtualCD Event with legacy boot fail, Status: %r\n", v7);
        if ( (unsigned __int8)sub_7EC() ) /*0x6469*/
        {
          if ( (unsigned __int8)sub_7F8(v56, v55, v57, v58) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x647e*/
            sub_740(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", v7); /*0x6494*/
          sub_788("e:\\hs\\LenovoServerPkg\\SystemInventory\\SystemInventory.c", 2102, "!EFI_ERROR (Status)"); /*0x64a4*/
        }
      }
    }
    (*(void (__fastcall **)(__int64))(qword_96A8 + 112))(a1); /*0x64b3*/
  }
  return v7; /*0x64ca*/
}