Newer
Older
AMI-Aptio-BIOS-Reversed / 117828F1-DA7D-4BC1-8B58-9A954FED5121 / RaidIsm.c
@Ajax Dong Ajax Dong 2 days ago 11 KB Init
#include "117828F1-DA7D-4BC1-8B58-9A954FED5121.h"

// RaidIsm.c - Extracted from 117828F1-DA7D-4BC1-8B58-9A954FED5121.c
// Total functions: 6

// Function: Assert_24 @ 0xa8fc (0x15e bytes)
// Index: 290/906

__int64 __fastcall Assert_24(unsigned __int8 n24)
{
  __int64 v2; // rcx
  _QWORD *v3; // rax
  __int64 v4; // rdi
  __int64 v6; // rsi
  int v7; // ecx
  __int64 v8; // rax
  __int64 v9; // rax
  __int64 v10; // rcx
  char n24_1; // al
  _BYTE *Source; // rsi
  __int64 v13; // rdx

  if ( !Source_16 ) /*0xa917*/
    return 1; /*0xa917*/
  v2 = *(_QWORD *)(Source_16 + 216); /*0xa91d*/
  if ( !v2 ) /*0xa927*/
    return 1; /*0xaa45*/
  v3 = RstLinkedListGetNth((_QWORD **)(v2 + 16), n24); /*0xa934*/
  v4 = (__int64)v3; /*0xa939*/
  if ( !v3 ) /*0xa93f*/
    return 15; /*0xa93f*/
  v6 = v3[6]; /*0xa94b*/
  if ( !v6 ) /*0xa952*/
    return 15; /*0xa941*/
  v7 = *(_DWORD *)(v6 + 136); /*0xa954*/
  if ( (v7 & 0x10) != 0 && (v7 & 0x40) == 0 ) /*0xa971*/
  {
    v8 = v3[5]; /*0xa977*/
    if ( v8 ) /*0xa97e*/
    {
      v9 = *(_QWORD *)(v8 + 232); /*0xa980*/
      if ( v9 ) /*0xa98a*/
      {
        v10 = *(_QWORD *)(*(_QWORD *)(v9 + 56) + 40LL); /*0xa990*/
        if ( v10 ) /*0xa997*/
        {
          if ( *(_WORD *)(v10 + 4) != 1 ) /*0xa99d*/
            goto LABEL_15; /*0xa99d*/
          n24_1 = 24; /*0xa99f*/
          if ( *(_BYTE *)(v10 + 6) <= 0x18u ) /*0xa9a5*/
            n24_1 = *(_BYTE *)(v10 + 6); /*0xa9a7*/
          if ( n24_1 != 2 ) /*0xa9ad*/
LABEL_15:
            Assert_28(*(_QWORD *)(Source_16 + 216), 0, v6); /*0xa9c2*/
        }
      }
    }
    if ( sub_128BC(v4) && Source_16 != -224 ) /*0xa9e1*/
    {
      Source = (_BYTE *)sub_12648(Source_16 + 224, v6); /*0xa9eb*/
      if ( RstDebugEnabled() ) /*0xa9ee*/
      {
        if ( !Source ) /*0xa9fa*/
          DebugAssert("IsmApi.cpp", 0x10Cu, "pJd"); /*0xaa0f*/
      }
      Assert_93(Source); /*0xaa17*/
    }
    RstDeviceClearFlags(*(_QWORD *)(v4 + 48), -1); /*0xaa23*/
    RstDeviceSetFlags(*(_QWORD *)(v4 + 48), 0x110u); /*0xaa31*/
    LOBYTE(v13) = 1; /*0xaa3a*/
    (***(void (__fastcall ****)(_QWORD, __int64))(v4 + 64))(*(_QWORD *)(v4 + 64), v13); /*0xaa3f*/
  }
  return 0; /*0xaa54*/
}


// Function: Assert_29 @ 0xcd30 (0x13a bytes)
// Index: 345/906

__int64 __fastcall Assert_29(unsigned __int8 n24, unsigned __int8 a2, _BYTE *i, unsigned __int8 n0x11)
{
  __int64 v8; // rcx
  _QWORD *v9; // rax
  _QWORD *v10; // rbx
  __int64 v11; // rdx
  __int64 v12; // rbx
  __int64 v13; // rdx
  __int64 v14; // rcx
  __int64 result; // rax
  unsigned __int8 v16[16]; // [rsp+20h] [rbp-C8h] BYREF
  __int64 ia[22]; // [rsp+30h] [rbp-B8h] BYREF

  if ( !Source_16 ) /*0xcd5c*/
    return 2; /*0xcd5c*/
  v8 = *(_QWORD *)(Source_16 + 216); /*0xcd62*/
  if ( !v8 ) /*0xcd6c*/
    return 2; /*0xcd6c*/
  v9 = RstLinkedListGetNth((_QWORD **)(v8 + 16), n24); /*0xcd79*/
  v10 = v9; /*0xcd7e*/
  if ( !v9 ) /*0xcd84*/
    return 2; /*0xcd84*/
  if ( !sub_128BC((__int64)v9) ) /*0xcd8d*/
    return 2; /*0xcd8d*/
  v11 = v10[6]; /*0xcd9a*/
  if ( (*(_BYTE *)(v11 + 139) & 1) != 0 || Source_16 == -224 ) /*0xcdb9*/
    return 2; /*0xce4c*/
  v12 = sub_12648(Source_16 + 224, v11); /*0xcdc4*/
  if ( (unsigned __int8)RstDebugEnabled(v14, v13) && !v12 ) /*0xcdd3*/
    DebugAssert("IsmApi.cpp", 0x1223u, "pJd"); /*0xcde8*/
  v16[0] = -1; /*0xcdf8*/
  result = sub_11E68(v12, a2, v16); /*0xcdfd*/
  if ( !(_DWORD)result && v16[0] != 0xFF ) /*0xce0b*/
  {
    if ( i && n0x11 ) /*0xce15*/
    {
      MemZero(i, 0, n0x11); /*0xce20*/
      if ( !(unsigned int)RstHelper_c8a8(v16[0], (__int64)ia) ) /*0xce2e*/
        sub_8304((__int64)i, (__int64)ia + 4, n0x11); /*0xce43*/
    }
    return 0; /*0xce48*/
  }
  return result; /*0xce65*/
}


// Function: Assert_23 @ 0xd390 (0x172 bytes)
// Index: 350/906

__int64 __fastcall Assert_23(int n5, __int64 a2)
{
  __int64 Source; // rcx
  unsigned __int8 v4; // r13
  unsigned int v5; // edi
  unsigned __int16 v6; // bp
  __int16 v7; // bx
  _QWORD *v8; // rax
  __int64 v9; // rsi
  __int64 v10; // rax
  __int64 i[7]; // [rsp+20h] [rbp-118h] BYREF
  signed __int32 v13[19]; // [rsp+5Ch] [rbp-DCh] BYREF
  char v14; // [rsp+A8h] [rbp-90h]
  int n5_1; // [rsp+B4h] [rbp-84h]

  Source = Source_16; /*0xd3b5*/
  v4 = a2; /*0xd3c3*/
  v5 = 0; /*0xd3c6*/
  v6 = **(_WORD **)(Source_16 + 216); /*0xd3c9*/
  v7 = 0; /*0xd3cc*/
  if ( v6 ) /*0xd3d4*/
  {
    while ( 1 ) /*0xd3de*/
    {
      if ( !n5 || (v8 = RstLinkedListGetNth((_QWORD **)(*(_QWORD *)(Source + 216) + 16LL), v7), RstHelper_02b4(v8[6], n5)) ) /*0xd3fd*/
      {
        if ( (unsigned int)RstHelper_ce6c(v7, (__int64)i) != 15 /*0xd44e*/
          && v13[1] != -1
          && (v14 & 4) == 0
          && !_bittest(v13, 9u)
          && n5_1 == 5 )
        {
          v9 = RstLinkedListGetNth((_QWORD **)(*(_QWORD *)(Source_16 + 216) + 16LL), v7)[6]; /*0xd46a*/
          if ( RstDebugEnabled() && !v9 ) /*0xd47b*/
            DebugAssert("IsmApi.cpp", 0x1186u, "pDisk"); /*0xd490*/
          v10 = sub_12648(Source_16 + 224, v9); /*0xd4a6*/
          if ( sub_11F60(v10) || v7 == v4 ) /*0xd4bf*/
            v5 |= 1 << v7; /*0xd4c8*/
        }
      }
      if ( (unsigned __int16)++v7 >= v6 ) /*0xd4d1*/
        break; /*0xd4d1*/
      Source = Source_16; /*0xd4d3*/
    }
  }
  return v5; /*0xd4f5*/
}


// Function: Assert_19 @ 0xd8d8 (0x1a5 bytes)
// Index: 356/906

__int64 __fastcall Assert_19(unsigned __int8 n24)
{
  __int64 v2; // rcx
  unsigned __int16 n24_1; // bx
  _QWORD *v4; // rax
  __int64 v5; // rdi
  int v6; // eax
  unsigned __int64 v8; // rbx
  unsigned int n0x96; // eax
  _BYTE *Source; // rbx
  __int64 v11; // rdx
  __int64 i[21]; // [rsp+30h] [rbp-F8h] BYREF
  unsigned int v13; // [rsp+DCh] [rbp-4Ch]

  if ( !Source_16 ) /*0xd8f1*/
    return 1; /*0xd8f1*/
  v2 = *(_QWORD *)(Source_16 + 216); /*0xd8f7*/
  if ( !v2 || Source_16 == -224 ) /*0xd90d*/
    return 1; /*0xd90d*/
  n24_1 = n24; /*0xd913*/
  v4 = RstLinkedListGetNth((_QWORD **)(v2 + 16), n24); /*0xd91d*/
  v5 = (__int64)v4; /*0xd922*/
  if ( !v4 ) /*0xd928*/
    return 18; /*0xd928*/
  if ( !v4[8] ) /*0xd92a*/
    return 18; /*0xd92a*/
  v6 = *(_DWORD *)(v4[6] + 136LL); /*0xd935*/
  if ( (v6 & 0x40) == 0 || (v6 & 0x1000000) != 0 || (unsigned int)RstHelper_ce6c(n24_1, (__int64)i) ) /*0xd954*/
    return 18; /*0xd95b*/
  v8 = 3 * (0x1000 / v13 + 384 * (0x100000 / v13)) + ((unsigned int)&loc_1FFFA + 6) / v13 + 161; /*0xd9a0*/
  n0x96 = RstFormatDiskSize(0, *(_QWORD *)(*(_QWORD *)(v5 + 48) + 88LL), v13, 0, 0); /*0xd9b1*/
  if ( *(_QWORD *)(*(_QWORD *)(v5 + 48) + 88LL) < v8 || n0x96 < 0x96 ) /*0xd9c9*/
    return 12; /*0xda76*/
  sub_12804(v5, 1); /*0xd9d4*/
  Source = Assert_51((_BYTE *)(Source_16 + 224), *(_QWORD *)(v5 + 48), 1); /*0xd9f3*/
  if ( !RstDebugEnabled() ) /*0xd9fd*/
    goto LABEL_15; /*0xd9fd*/
  if ( !Source ) /*0xda02*/
  {
    DebugAssert("IsmApi.cpp", 0x543u, "pJd"); /*0xda17*/
LABEL_15:
    if ( !Source ) /*0xda1f*/
      return 18; /*0xd962*/
  }
  if ( !Assert_48((__int64)Source) ) /*0xda28*/
  {
    Assert_130((_BYTE *)(Source_16 + 224), Source); /*0xda42*/
    sub_12804(v5, 0); /*0xda4c*/
    return 1; /*0xda51*/
  }
  LOBYTE(v11) = 1; /*0xda6b*/
  (***(void (__fastcall ****)(_QWORD, __int64))(v5 + 64))(*(_QWORD *)(v5 + 64), v11); /*0xda70*/
  return 0; /*0xda5e*/
}


// Function: Assert_56 @ 0xe37c (0xa0 bytes)
// Index: 376/906

__int64 __fastcall Assert_56(__int64 Source, _WORD *a2)
{
  bool i; // cc
  __int16 n0x18; // dx
  __int64 v6; // rbx
  __int64 v7; // rax

  for ( i = *a2 < *(_WORD *)(Source + 192); i; i = *a2 < *(_WORD *)(Source + 192) ) /*0xe398*/
  {
    n0x18 = (*a2)++; /*0xe39d*/
    v6 = sub_E334(Source, n0x18); /*0xe3ae*/
    if ( v6 ) /*0xe3b4*/
    {
      if ( RstDebugEnabled() && !*(_QWORD *)(v6 + 136) ) /*0xe3bf*/
        DebugAssert("RaidIsm.cpp", 0x16Du, "rDev->getCfgRaidDev()"); /*0xe3dc*/
      v7 = *(_QWORD *)(v6 + 136); /*0xe3e1*/
      if ( v7 ) /*0xe3eb*/
      {
        if ( *(_DWORD *)(v7 + 80) == 2 || *(_DWORD *)(v7 + 80) == 4 ) /*0xe3f7*/
          return v6; /*0xe408*/
      }
    }
  }
  return 0; /*0xe416*/
}


// Function: Assert_18 @ 0x156b4 (0x1ad bytes)
// Index: 601/906

__int64 __fastcall Assert_18(__int64 a1, __int64 Source)
{
  UINTN Length; // rsi
  CHAR16 *Sourcea_1; // r13
  unsigned int v6; // r15d
  unsigned int Source_1; // ebp
  unsigned int v8; // r12d
  _DWORD *v9; // rcx
  __int64 result; // rax
  bool v11; // zf
  _DWORD *v12; // rcx
  unsigned int v13; // eax
  CHAR16 *Sourcea; // [rsp+20h] [rbp-78h] BYREF
  char v15; // [rsp+28h] [rbp-70h]
  __int16 v16; // [rsp+2Ah] [rbp-6Eh]
  __int64 v17; // [rsp+30h] [rbp-68h] BYREF
  unsigned int v18; // [rsp+38h] [rbp-60h]
  int Sourcea_3; // [rsp+3Ch] [rbp-5Ch]
  bool v20; // [rsp+40h] [rbp-58h]
  CHAR16 Destination[2]; // [rsp+48h] [rbp-50h] BYREF
  int v22; // [rsp+4Ch] [rbp-4Ch]
  __int64 v23; // [rsp+50h] [rbp-48h]
  unsigned int Length_1; // [rsp+58h] [rbp-40h]
  int Sourcea_2; // [rsp+5Ch] [rbp-3Ch]
  char n40; // [rsp+60h] [rbp-38h]

  *(_WORD *)Source = 5; /*0x156db*/
  *(_WORD *)(Source + 2) = 8; /*0x156e3*/
  Length = (unsigned int)HiiLibReturnZero(a1); /*0x156f1*/
  if ( (*(_DWORD *)(Source + 20) & 1) != 0 ) /*0x156f8*/
  {
    v16 = 1; /*0x156fe*/
    Sourcea = 0; /*0x1570c*/
    v15 = 0; /*0x15711*/
    sub_17B58((__int64)&Sourcea, 0); /*0x15716*/
    if ( RstDebugEnabled() && !Sourcea ) /*0x1572a*/
      DebugAssert("HostIsmIntf.cpp", 0x4Cu, "sbuf.ptr()"); /*0x1573d*/
    Sourcea_1 = Sourcea; /*0x15745*/
    v6 = *(_DWORD *)(Source + 16) / (unsigned int)Length; /*0x1575c*/
    StrnCpy(Destination, (const CHAR16 *)Source, 0x20u); /*0x1575f*/
    Source_1 = *(_DWORD *)(Source + 20); /*0x15764*/
    Length_1 = Length; /*0x15767*/
    Sourcea_2 = (int)Sourcea_1; /*0x1576b*/
    v8 = 0; /*0x15770*/
    if ( v6 ) /*0x15776*/
    {
      while ( 1 ) /*0x15778*/
      {
        if ( *(_BYTE *)(Source + 24) == 42 ) /*0x1577c*/
          StrnCpy(Sourcea_1, (const CHAR16 *)Source_1, Length); /*0x15786*/
        v9 = *(_DWORD **)(a1 + 128); /*0x15794*/
        Sourcea_3 = Sourcea_2; /*0x1579b*/
        v20 = n40 != 40; /*0x157a3*/
        v18 = Length_1 / (unsigned int)Length; /*0x157b1*/
        v17 = v23; /*0x157ba*/
        if ( (unsigned int)Assert_63(v9, &v17) ) /*0x157bf*/
          break; /*0x157bf*/
        if ( *(_BYTE *)(Source + 24) == 40 ) /*0x157cc*/
          StrnCpy((CHAR16 *)Source_1, Sourcea_1, Length); /*0x157d6*/
        ++v23; /*0x157df*/
        ++v8; /*0x157e4*/
        *(_DWORD *)(Source + 4) += v22; /*0x157e7*/
        Source_1 += Length; /*0x157ea*/
        if ( v8 >= v6 ) /*0x157ef*/
          goto LABEL_12; /*0x157ef*/
      }
    }
    else
    {
LABEL_12:
      *(_WORD *)Source = 0; /*0x157f1*/
      *(_WORD *)(Source + 2) = 0; /*0x157f4*/
    }
    return sub_17400((__int64)Sourcea); /*0x157fd*/
  }
  else
  {
    v11 = *(_BYTE *)(Source + 24) == 40; /*0x15804*/
    v12 = *(_DWORD **)(a1 + 128); /*0x15808*/
    Sourcea_3 = *(_DWORD *)(Source + 20); /*0x1580f*/
    v13 = *(_DWORD *)(Source + 16); /*0x15813*/
    v20 = !v11; /*0x15816*/
    v18 = v13 / (unsigned int)Length; /*0x15824*/
    v17 = *(_QWORD *)(Source + 8); /*0x1582c*/
    result = Assert_63(v12, &v17); /*0x15831*/
    if ( !(_DWORD)result ) /*0x1583a*/
    {
      *(_WORD *)Source = 0; /*0x1583c*/
      *(_WORD *)(Source + 2) = 0; /*0x1583f*/
    }
  }
  return result; /*0x15854*/
}