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

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

// Function: PplGetOffsetLo @ 0x1c6c8 (0xe bytes)
// Index: 778/906

unsigned __int64 __fastcall PplGetOffsetLo(__int64 a1)
{
  return *(unsigned int *)(a1 + 4) + ((unsigned __int64)*(unsigned int *)(a1 + 24) << 32); /*0x1c6d5*/
}


// Function: PplGetOffsetHi @ 0x1c6d8 (0xe bytes)
// Index: 779/906

unsigned __int64 __fastcall PplGetOffsetHi(__int64 a1)
{
  return *(unsigned int *)(a1 + 8) + ((unsigned __int64)*(unsigned int *)(a1 + 28) << 32); /*0x1c6e5*/
}


// Function: PplGetEntry @ 0x1c6e8 (0xd bytes)
// Index: 780/906

unsigned __int64 __fastcall PplGetEntry(unsigned int *a1)
{
  return *a1 + ((unsigned __int64)a1[5] << 32); /*0x1c6f4*/
}


// Function: PplInitEntry @ 0x1c6f8 (0xe9 bytes)
// Index: 781/906

char __fastcall PplInitEntry(__int64 a1, __int64 a2)
{
  char n24; // al
  __int16 n23_1; // r8
  __int64 n23_2; // rax
  int n23; // ecx

  *(_BYTE *)(a1 + 14) = *(_BYTE *)a2; /*0x1c711*/
  *(_BYTE *)(a1 + 15) = *(_BYTE *)(a2 + 4); /*0x1c71a*/
  if ( *(_BYTE *)(a2 + 6) > 0x18u ) /*0x1c721*/
    n24 = 24; /*0x1c729*/
  else
    n24 = *(_BYTE *)(a2 + 6); /*0x1c723*/
  *(_BYTE *)(a1 + 16) = n24; /*0x1c72b*/
  *(_WORD *)(a1 + 12) = *(_WORD *)(a2 + 16); /*0x1c732*/
  *(_DWORD *)a1 = *(_DWORD *)(a2 + 8); /*0x1c739*/
  *(_DWORD *)(a1 + 20) = HIDWORD(*(_QWORD *)(a2 + 8)); /*0x1c743*/
  *(_DWORD *)(a1 + 4) = sub_17820(a2); /*0x1c751*/
  n23_2 = sub_17820(a2); /*0x1c754*/
  n23_1 = 0; /*0x1c759*/
  *(_DWORD *)(a1 + 24) = HIDWORD(n23_2); /*0x1c760*/
  *(_DWORD *)(a1 + 8) = *(_DWORD *)(a2 + 32); /*0x1c766*/
  *(_DWORD *)(a1 + 28) = HIDWORD(*(_QWORD *)(a2 + 32)); /*0x1c771*/
  *(_BYTE *)(a1 + 17) = *(_BYTE *)(a2 + 40); /*0x1c777*/
  LOBYTE(n23_2) = *(_BYTE *)(a2 + 41); /*0x1c77a*/
  *(_BYTE *)(a1 + 19) = 1; /*0x1c77d*/
  *(_BYTE *)(a1 + 18) = n23_2; /*0x1c781*/
  *(_QWORD *)(a1 + 32) = 0; /*0x1c784*/
  *(_QWORD *)(a1 + 40) = 0; /*0x1c788*/
  if ( *(_BYTE *)(a1 + 16) ) /*0x1c78c*/
  {
    do /*0x1c7cf*/
    {
      n23 = 23; /*0x1c79a*/
      if ( n23_1 < 24 ) /*0x1c79f*/
        n23 = n23_1; /*0x1c79f*/
      n23_2 = (unsigned __int16)n23_1++; /*0x1c7bb*/
      *(_DWORD *)(a1 + 4 * n23_2 + 48) = (*(unsigned __int8 *)(n23 + a2 + 240) << 24) /*0x1c7c3*/
                                       | *(__int16 *)(*(_QWORD *)(a2 + 8LL * n23 + 48) + 16LL);
      LOWORD(n23_2) = *(unsigned __int8 *)(a1 + 16); /*0x1c7c7*/
    }
    while ( (unsigned __int16)n23_1 < (unsigned __int16)n23_2 ); /*0x1c7cf*/
  }
  return n23_2; /*0x1c7db*/
}


// Function: PplCopyEntry @ 0x1c7f0 (0x162 bytes)
// Index: 782/906

__int64 __fastcall PplCopyEntry(CHAR16 *Destination, __int64 a2)
{
  CHAR16 *Source; // rdi
  __int64 result; // rax
  __int64 v6; // rsi
  int v7; // eax
  __int64 v8; // rcx
  __int64 v9; // rax

  Source = (CHAR16 *)(a2 + 16); /*0x1c808*/
  result = sub_E48C(Source_16, (_BYTE *)(a2 + 16)); /*0x1c81c*/
  v6 = result; /*0x1c824*/
  if ( result ) /*0x1c82a*/
  {
    if ( !Source || StrnCpy16(Source, Destination, 16) ) /*0x1c843*/
      StrnCpy(Destination, Source, 0x10u); /*0x1c857*/
    *((_BYTE *)Destination + 32) = *(_BYTE *)(a2 + 36); /*0x1c866*/
    *((_QWORD *)Destination + 2) = *(_QWORD *)(a2 + 40); /*0x1c877*/
    v7 = *(_DWORD *)(a2 + 48); /*0x1c87a*/
    *((_DWORD *)Destination + 7) = 0; /*0x1c87d*/
    *((_DWORD *)Destination + 6) = v7; /*0x1c881*/
    Destination[18] = *(_WORD *)(a2 + 52); /*0x1c888*/
    *(_QWORD *)(Destination + 34) = 0; /*0x1c88c*/
    *((_DWORD *)Destination + 19) = 0; /*0x1c890*/
    *((_BYTE *)Destination + 38) = 0; /*0x1c894*/
    *((_BYTE *)Destination + 39) = 0; /*0x1c898*/
    *((_BYTE *)Destination + 35) = 0; /*0x1c89c*/
    LOWORD(v7) = *(_WORD *)(a2 + 64); /*0x1c8a0*/
    *((_BYTE *)Destination + 42) = 0; /*0x1c8a4*/
    *((_BYTE *)Destination + 43) = 0; /*0x1c8a8*/
    *((_DWORD *)Destination + 11) = 0; /*0x1c8ac*/
    Destination[24] = 0; /*0x1c8b0*/
    Destination[20] = v7; /*0x1c8b5*/
    *((_BYTE *)Destination + 34) = *(_BYTE *)(a2 + 66); /*0x1c8bc*/
    sub_1C070((__int64)(Destination + 40), *(_QWORD *)(a2 + 56), 0); /*0x1c8c3*/
    v8 = *(_QWORD *)(v6 + 160); /*0x1c8c8*/
    if ( *(_BYTE *)(v6 + 186) && !*(_BYTE *)(v6 + 190) && *(_BYTE *)(v6 + 187) ) /*0x1c8e1*/
    {
      *((_BYTE *)Destination + 90) = 0; /*0x1c8ea*/
      *(_BYTE *)(v8 + 82) = 0; /*0x1c8ee*/
    }
    else
    {
      *(_BYTE *)(v8 + 82) = *((_BYTE *)Destination + 90); /*0x1c8f7*/
      *((_BYTE *)Destination + 90) = *((_BYTE *)Destination + 90); /*0x1c8fd*/
    }
    v9 = sub_15A5C(v8); /*0x1c900*/
    sub_1C10C((_DWORD *)Destination + 20, v9); /*0x1c90c*/
    *((_BYTE *)Destination + 33) = 0; /*0x1c911*/
    *((_BYTE *)Destination + 50) = *(_BYTE *)(a2 + 80); /*0x1c921*/
    MemZero((_BYTE *)Destination + 51, 0, 16); /*0x1c924*/
    return sub_8304((__int64)Destination + 51, a2 + 84, 16); /*0x1c934*/
  }
  return result; /*0x1c948*/
}


// Function: PplInitLog @ 0x1c954 (0x20 bytes)
// Index: 783/906

__int64 __fastcall PplInitLog(__int64 a1)
{
  *(_QWORD *)a1 = off_24280; /*0x1c95b*/
  *(_QWORD *)(a1 + 16) = 0; /*0x1c960*/
  *(_QWORD *)(a1 + 8) = 0; /*0x1c964*/
  *(_QWORD *)(a1 + 24) = 0; /*0x1c968*/
  *(_WORD *)(a1 + 32) = 0; /*0x1c96c*/
  return a1; /*0x1c973*/
}


// Function: RstPplRecoveryLogSetOffset @ 0x1c974 (0x47 bytes)
// Index: 784/906

void __fastcall RstPplRecoveryLogSetOffset(__int64 a1, __int64 a2)
{
  if ( (unsigned __int8)RstDebugEnabled(a1, a2) && *(_WORD *)(a1 + 32) ) /*0x1c98d*/
    DebugAssert("PplRecoveryLog.cpp", 0x5Au, "m_nOffs == 0"); /*0x1c9a7*/
  *(_QWORD *)(a1 + 24) = a2; /*0x1c9ac*/
}


// Function: nullsub_1 @ 0x1c9bc (0x3 bytes)
// Index: 785/906

void nullsub_1()
{
  ; /*0x1c9bc*/
}


// Function: PplInitLogEx @ 0x1c9c0 (0x24 bytes)
// Index: 786/906

__int64 __fastcall PplInitLogEx(__int64 a1)
{
  *(_QWORD *)a1 = off_242B8; /*0x1c9c9*/
  *(_QWORD *)(a1 + 16) = 0; /*0x1c9cf*/
  *(_QWORD *)(a1 + 8) = 0; /*0x1c9d3*/
  *(_QWORD *)(a1 + 24) = 0; /*0x1c9d7*/
  *(_WORD *)(a1 + 32) = 0; /*0x1c9db*/
  *(_QWORD *)(a1 + 40) = 0; /*0x1c9df*/
  return a1; /*0x1c9e3*/
}


// Function: PplResetLog @ 0x1c9e4 (0x42 bytes)
// Index: 787/906

char __fastcall PplResetLog(__int64 a1, __int64 Length, __int64 a3, unsigned int a4, __int64 a5)
{
  if ( *(_QWORD *)(a1 + 40) ) /*0x1c9eb*/
  {
    RstPplRecoveryLogSetOffset(a1, a5); /*0x1ca1a*/
    return 0; /*0x1ca1f*/
  }
  else
  {
    *(_QWORD *)(a1 + 8) = a3; /*0x1c9f4*/
    *(_WORD *)(a1 + 32) = 0; /*0x1c9f8*/
    *(_QWORD *)(a1 + 40) = Length; /*0x1ca00*/
    *(_QWORD *)(a1 + 16) = a3 + a4; /*0x1ca04*/
    *(_QWORD *)(a1 + 24) = a5; /*0x1ca0d*/
    return 1; /*0x1ca11*/
  }
}


// Function: Assert_133 @ 0x1ca28 (0x53 bytes)
// Index: 788/906

void __fastcall sub_1CA28(__int64 *a1, int a2, int a3)
{
  int v6; // eax

  if ( a1[5] ) /*0x1ca37*/
  {
    v6 = (*(__int64 (__fastcall **)(__int64 *))(*a1 + 8))(a1); /*0x1ca4a*/
    Assert_89(Source_16, a1[5], 42, a2, v6, a3); /*0x1ca66*/
  }
}


// Function: RstHelper_ca7c @ 0x1ca7c (0x19 bytes)
// Index: 789/906

__int64 __fastcall sub_1CA7C(__int64 a1)
{
  __int64 v1; // rcx
  __int64 result; // rax

  v1 = *(_QWORD *)(a1 + 40); /*0x1ca80*/
  result = 0; /*0x1ca84*/
  if ( v1 ) /*0x1ca89*/
    return HiiLibReturnZero(v1); /*0x1ca8b*/
  return result; /*0x1ca90*/
}


// Function: PplBufferWrite @ 0x1ca98 (0xdb bytes)
// Index: 790/906

CHAR16 *__fastcall PplBufferWrite(__int64 a1, const CHAR16 *Source, unsigned __int16 Length)
{
  CHAR16 *result; // rax
  __int16 v7; // ax
  CHAR16 *Destination; // rcx
  unsigned __int16 Length_1; // si
  unsigned __int64 v10; // rdx
  unsigned __int64 v11; // rdx

  result = *(CHAR16 **)(a1 + 16); /*0x1cab0*/
  if ( *(_QWORD *)(a1 + 8) < (unsigned __int64)result ) /*0x1cac2*/
  {
    while ( 1 ) /*0x1cad1*/
    {
      v7 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 8LL))(a1); /*0x1cad1*/
      Destination = (CHAR16 *)(*(_QWORD *)(a1 + 24) + *(unsigned __int16 *)(a1 + 32)); /*0x1cadb*/
      Length_1 = v7 - *(_WORD *)(a1 + 32); /*0x1cae1*/
      if ( Length_1 >= Length ) /*0x1cae8*/
        break; /*0x1cae8*/
      StrnCpy(Destination, Source, Length_1); /*0x1caf1*/
      v10 = *(_QWORD *)(a1 + 8); /*0x1caf6*/
      if ( v10 < *(_QWORD *)(a1 + 16) ) /*0x1cafe*/
        (**(void (__fastcall ***)(__int64, unsigned __int64, _QWORD))a1)(a1, v10, *(_QWORD *)(a1 + 24)); /*0x1cb0a*/
      ++*(_QWORD *)(a1 + 8); /*0x1cb0c*/
      *(_WORD *)(a1 + 32) = 0; /*0x1cb10*/
      result = *(CHAR16 **)(a1 + 16); /*0x1cb15*/
      Length -= Length_1; /*0x1cb19*/
      Source = (const CHAR16 *)((char *)Source + Length_1); /*0x1cb1c*/
      if ( *(_QWORD *)(a1 + 8) >= (unsigned __int64)result ) /*0x1cb23*/
        return result; /*0x1cb23*/
    }
    result = StrnCpy(Destination, Source, Length); /*0x1cb2b*/
    if ( Length_1 == Length ) /*0x1cb33*/
    {
      v11 = *(_QWORD *)(a1 + 8); /*0x1cb35*/
      if ( v11 < *(_QWORD *)(a1 + 16) ) /*0x1cb3d*/
        result = (CHAR16 *)(**(__int64 (__fastcall ***)(__int64, unsigned __int64, _QWORD))a1)( /*0x1cb49*/
                             a1,
                             v11,
                             *(_QWORD *)(a1 + 24));
      ++*(_QWORD *)(a1 + 8); /*0x1cb4b*/
      *(_WORD *)(a1 + 32) = 0; /*0x1cb4f*/
    }
    else
    {
      *(_WORD *)(a1 + 32) += Length; /*0x1cb56*/
    }
  }
  return result; /*0x1cb69*/
}


// Function: PplStrCopy @ 0x1cb74 (0x2d bytes)
// Index: 791/906

CHAR16 *__fastcall PplStrCopy(__int64 a1)
{
  unsigned __int16 Length; // ax

  Length = StrLenA(Source_17); /*0x1cb84*/
  return PplBufferWrite(a1, Source_17, Length); /*0x1cb97*/
}


// Function: PplWriteFieldInfo @ 0x1cba4 (0xbc bytes)
// Index: 792/906

CHAR16 *__fastcall PplWriteFieldInfo(__int64 a1, CHAR16 *Destination)
{
  unsigned __int16 Length; // ax
  int Source; // [rsp+40h] [rbp+18h] BYREF

  Length = StrLenA(Source_4); /*0x1cbbb*/
  PplBufferWrite(a1, Source_4, Length); /*0x1cbce*/
  Source = RstGetFieldCount((__int64)Destination, 0); /*0x1cbeb*/
  PplBufferWrite(a1, (const CHAR16 *)&Source, 4u); /*0x1cbef*/
  Source = RstHelper_1d9c(Destination, 0); /*0x1cc0c*/
  PplBufferWrite(a1, (const CHAR16 *)&Source, 4u); /*0x1cc10*/
  Source = RstGetFieldSize(Destination, 0); /*0x1cc2d*/
  PplBufferWrite(a1, (const CHAR16 *)&Source, 4u); /*0x1cc31*/
  Source = RstGetFieldBlockSize(Destination); /*0x1cc4c*/
  return PplBufferWrite(a1, (const CHAR16 *)&Source, 4u); /*0x1cc5a*/
}