Newer
Older
AMI-Aptio-BIOS-Reversed / SystemInventory / SystemInventory_sub_4C00.c
@Ajax Dong Ajax Dong 2 days ago 7 KB Init
__int64 __fastcall sub_4C00(__int64 a1, __int64 a2, __int64 a3, double a4)
{
  __int64 result; // rax
  unsigned __int8 v5; // r14
  __int64 i; // rbx
  unsigned __int8 n0x18; // r12
  void *v8; // rdx
  __int64 v9; // rcx
  __int64 v10; // r8
  __int64 v11; // r9
  __int64 v12; // rsi
  __int16 v13; // cx
  unsigned __int8 v14; // di
  __int64 v15; // rcx
  __int64 v16; // rcx
  const char *_1.2V; // r8
  __int64 v18; // rdx
  __int64 v19; // rdx
  __int64 v20; // rdx
  unsigned __int8 n4; // di
  __int64 i_1; // r15
  unsigned __int64 v23; // rax
  char v24; // cl
  __int64 v25; // rdx
  __int64 v26; // rcx
  __int64 v27; // r8
  __int64 v28; // r9
  __int64 v29; // rdx
  __int64 v30; // rcx
  __int64 v31; // r8
  __int64 v32; // r9
  __int64 v33; // rdx
  __int64 v34; // rcx
  __int64 v35; // r8
  __int64 v36; // r9
  __int64 v37; // rdx
  __int64 v38; // rcx
  __int64 v39; // r8
  __int64 v40; // r9
  __int64 v41; // rdx
  __int64 v42; // rcx
  __int64 v43; // r8
  __int64 v44; // r9
  __int64 v45; // rdx
  __int64 v46; // rcx
  __int64 v47; // r8
  __int64 v48; // r9
  __int64 v49; // rdx
  __int64 v50; // rcx
  __int64 v51; // r8
  __int64 v52; // r9
  __int64 v53; // rdx
  __int64 v54; // rcx
  __int64 v55; // r8
  __int64 v56; // r9
  __int64 v57; // rdx
  __int64 v58; // rcx
  __int64 v59; // r8
  __int64 v60; // r9
  char v61; // [rsp+60h] [rbp+40h] BYREF
  __int64 v62; // [rsp+68h] [rbp+48h] BYREF
  __int64 v63; // [rsp+70h] [rbp+50h] BYREF

  v63 = 0; /*0x4c12*/
  v62 = 0; /*0x4c17*/
  *(_BYTE *)(qword_9680 + 257) = 24; /*0x4c23*/
  if ( qword_9678 /*0x4c54*/
    || (result = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(qword_96D8 + 320))(&unk_93F0, 0, &qword_9678),
        result >= 0) )
  {
    v5 = 0; /*0x4c5a*/
    for ( i = 0; ; i += 84 ) /*0x4c63*/
    {
      n0x18 = v5 + 1; /*0x4c6c*/
      LOBYTE(a2) = v5 + 1; /*0x4c74*/
      LOBYTE(a1) = 17; /*0x4c7b*/
      *(_BYTE *)(i + qword_9680 + 258) = v5 + 1; /*0x4c7d*/
      if ( (*(__int64 (__fastcall **)(__int64, __int64, __int64 *, char *))(qword_9678 + 64))(a1, a2, &v63, &v61) >= 0 ) /*0x4c92*/
        break; /*0x4c92*/
LABEL_33:
      if ( (unsigned __int8)sub_7F8(v9, v8, v10, v11) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4eb6*/
        sub_740( /*0x4edd*/
          0x80000000LL,
          "gSystemInventoryProtocol->DimmInfo[%d].DimmSlotIndex = %x \n",
          v5,
          *(unsigned __int8 *)(i + qword_9680 + 258));
      if ( (unsigned __int8)sub_7F8(v26, v25, v27, v28) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4eee*/
        sub_740( /*0x4f15*/
          0x80000000LL,
          "gSystemInventoryProtocol->DimmInfo[%d].NodeNumber = %x \n",
          v5,
          *(unsigned __int8 *)(i + qword_9680 + 259));
      if ( (unsigned __int8)sub_7F8(v30, v29, v31, v32) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4f26*/
        sub_740( /*0x4f4d*/
          0x80000000LL,
          "gSystemInventoryProtocol->DimmInfo[%d].ChannelNumber = %x \n",
          v5,
          *(unsigned __int8 *)(i + qword_9680 + 260));
      if ( (unsigned __int8)sub_7F8(v34, v33, v35, v36) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4f5e*/
        sub_740(0x80000000LL, "gSystemInventoryProtocol->DimmInfo[%d].DimmType = %a \n", v5, a4); /*0x4f86*/
      if ( (unsigned __int8)sub_7F8(v38, v37, v39, v40) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4f97*/
        sub_740(0x80000000LL, "gSystemInventoryProtocol->DimmInfo[%d].DdrVoltage = %a \n", v5, a4); /*0x4fbf*/
      if ( (unsigned __int8)sub_7F8(v42, v41, v43, v44) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4fd0*/
        sub_740( /*0x4ff7*/
          0x80000000LL,
          "gSystemInventoryProtocol->DimmInfo[%d].DimmFreq = %d \n",
          v5,
          *(unsigned __int16 *)(i + qword_9680 + 281));
      if ( (unsigned __int8)sub_7F8(v46, v45, v47, v48) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x5008*/
        sub_740( /*0x502f*/
          0x80000000LL,
          "gSystemInventoryProtocol->DimmInfo[%d].DimmSize = %d \n",
          v5,
          *(unsigned __int16 *)(i + qword_9680 + 283));
      if ( (unsigned __int8)sub_7F8(v50, v49, v51, v52) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x5040*/
        sub_740(0x80000000LL, "gSystemInventoryProtocol->DimmInfo[%d].ManufacturerIdName = %a \n", v5, a4); /*0x5068*/
      if ( (unsigned __int8)sub_7F8(v54, v53, v55, v56) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x5079*/
        sub_740(0x80000000LL, "gSystemInventoryProtocol->DimmInfo[%d].SerialNumber = %a \n", v5, a4); /*0x50a1*/
      if ( (unsigned __int8)sub_7F8(v58, v57, v59, v60) ) /*0x50a6*/
      {
        if ( (unsigned __int8)sub_804(0x80000000LL) ) /*0x50b2*/
          sub_740(0x80000000LL, "gSystemInventoryProtocol->DimmInfo[%d].PartNumber = %a \n", v5, a4); /*0x50da*/
      }
      (*(void (__fastcall **)(__int64))(qword_96D8 + 72))(v63); /*0x50ea*/
      ++v5; /*0x50f1*/
      if ( n0x18 >= 0x18u ) /*0x50f8*/
        return 0; /*0x50fe*/
    }
    v12 = v63; /*0x4ca2*/
    *(_BYTE *)(i + qword_9680 + 260) = (v5 >> 1) + 65; /*0x4cab*/
    if ( *(_WORD *)(v12 + 12) == 0x7FFF ) /*0x4cbb*/
      v13 = *(_WORD *)(v12 + 28); /*0x4cbd*/
    else
      v13 = *(_WORD *)(v12 + 12); /*0x4cc3*/
    v14 = 0; /*0x4cce*/
    *(_WORD *)(i + qword_9680 + 283) = v13; /*0x4cd1*/
    v15 = *(unsigned __int16 *)(v12 + 21); /*0x4ce0*/
    *(_WORD *)(i + qword_9680 + 281) = v15; /*0x4ce4*/
    while ( 1 ) /*0x4cec*/
    {
      if ( (unsigned __int8)sub_7F8(v15, v8, v10, v11) && (unsigned __int8)sub_804(0x80000000LL) ) /*0x4cf8*/
        sub_740( /*0x4d24*/
          0x80000000LL,
          "gSmbiosDimmTypeNameMapping[j].Value = %x, Type17->MemoryType = %x\n",
          *((unsigned __int16 *)&unk_9540 + 5 * v14),
          *(unsigned __int8 *)(v12 + 18));
      v8 = &unk_9540; /*0x4d2d*/
      v15 = 5LL * v14; /*0x4d34*/
      if ( *((_WORD *)&unk_9540 + 5 * v14) == *(unsigned __int8 *)(v12 + 18) ) /*0x4d40*/
        break; /*0x4d40*/
      if ( ++v14 >= 0x1Eu ) /*0x4d49*/
        goto LABEL_16; /*0x4d49*/
    }
    sub_D38(i + qword_9680 + 261, 10, *(_QWORD *)((char *)&unk_9540 + 10 * v14 + 2)); /*0x4d77*/
LABEL_16:
    switch ( *(_WORD *)(v12 + 38) ) /*0x4d89*/
    {
      case 0x4B0: /*0x4d89*/
        _1.2V = "1.2V"; /*0x4dc8*/
        break;
      case 0x4E2: /*0x4d89*/
        _1.2V = "1.25V"; /*0x4dbf*/
        break;
      case 0x546: /*0x4d89*/
        _1.2V = "1.35V"; /*0x4db6*/
        break;
      default:
        v16 = qword_9680; /*0x4d9b*/
        if ( *(_WORD *)(v12 + 38) == 1500 ) /*0x4da2*/
          _1.2V = "1.5V"; /*0x4dad*/
        else
          _1.2V = "N/A"; /*0x4da4*/
        goto LABEL_26; /*0x4dab*/
    }
    v16 = qword_9680; /*0x4dcf*/
LABEL_26:
    sub_D38(i + v16 + 271, 10, _1.2V); /*0x4dd6*/
    LOBYTE(v18) = *(_BYTE *)(v12 + 23); /*0x4de5*/
    if ( !sub_27B8(v63, v18, &v62) ) /*0x4df0*/
      (*(void (__fastcall **)(__int64, __int64, __int64))(qword_96D8 + 352))(i + qword_9680 + 285, v62, 30); /*0x4e1a*/
    LOBYTE(v19) = *(_BYTE *)(v12 + 24); /*0x4e20*/
    if ( !sub_27B8(v63, v19, &v62) ) /*0x4e2b*/
    {
      n4 = 0; /*0x4e35*/
      i_1 = i; /*0x4e38*/
      do /*0x4e67*/
      {
        v23 = sub_AAC(v62); /*0x4e3f*/
        v24 = n4++; /*0x4e44*/
        *(_BYTE *)(i_1 + qword_9680 + 315) = v23 >> (8 * v24); /*0x4e58*/
        ++i_1; /*0x4e60*/
      }
      while ( n4 < 4u ); /*0x4e67*/
    }
    LOBYTE(v20) = *(_BYTE *)(v12 + 26); /*0x4e6f*/
    if ( !sub_27B8(v63, v20, &v62) ) /*0x4e7a*/
      (*(void (__fastcall **)(__int64, __int64, __int64))(qword_96D8 + 352))(i + qword_9680 + 319, v62, 21); /*0x4ea4*/
    goto LABEL_33; /*0x4ea4*/
  }
  return result; /*0x5100*/
}