Newer
Older
AMI-Aptio-BIOS-Reversed / MdeModulePkg / Core / DxeIplPeim / DxeIplLzmaDecodeCore1.c
@Ajax Dong Ajax Dong 2 days ago 2 KB Full restructure
/* DxeIplLzmaDecodeCore1 @ 0xffc168f9 size=0x149 */
int __fastcall DxeIplLzmaDecodeCore1(_DWORD *this, unsigned __int16 count, unsigned __int16 n8, __int16 n0x1F)
{
  unsigned __int16 DecompressAlgo; // di
  unsigned __int16 v7; // ax
  int n0x1F_1; // esi
  int n7; // eax
  bool v11; // cf
  unsigned int n0x10000000; // ecx
  unsigned __int16 n3; // dx
  int v14; // eax
  __int16 i; // cx
  int v16; // eax
  int n0x1F_2; // eax
  char n7_1; // [esp+14h] [ebp-8h]

  DecompressAlgo = DxeIplGetDecompressAlgo((int)this, n8); /*0xffc16911*/
  if ( !DecompressAlgo ) /*0xffc16917*/
  {
    v7 = DxeIplGetDecompressAlgo((int)this, n8); /*0xffc1691f*/
    memset32(this + 3213, (v7 << 16) | v7, 0x80u); /*0xffc16939*/
    DxeIplSetMem64(this + 1157, count, 0); /*0xffc16948*/
    return 0; /*0xffc16952*/
  }
  n0x1F_1 = 0; /*0xffc16959*/
  while ( (unsigned __int16)n0x1F_1 < 0x1Fu ) /*0xffc1696f*/
  {
    n7 = *(this + 5) >> 29; /*0xffc16978*/
    n7_1 = n7; /*0xffc1697b*/
    v11 = (unsigned __int16)n7 < 7u; /*0xffc1697f*/
    if ( (_WORD)n7 == 7 ) /*0xffc16982*/
    {
      n0x10000000 = 0x10000000; /*0xffc16984*/
      if ( (*(this + 5) & 0x10000000) == 0 ) /*0xffc1698c*/
        goto LABEL_11; /*0xffc1698c*/
      do /*0xffc16994*/
      {
        n0x10000000 >>= 1; /*0xffc1698e*/
        LOWORD(n7) = n7 + 1; /*0xffc16990*/
      }
      while ( (n0x10000000 & *(this + 5)) != 0 ); /*0xffc16994*/
      n7_1 = n7; /*0xffc16996*/
      v11 = (unsigned __int16)n7 < 7u; /*0xffc1699a*/
    }
    if ( !v11 ) /*0xffc1699d*/
    {
LABEL_11:
      n3 = n7 - 3; /*0xffc169a4*/
      goto LABEL_12; /*0xffc169a7*/
    }
    n3 = 3; /*0xffc169a1*/
LABEL_12:
    DxeIplDecompressLzma((int)this, n3); /*0xffc169aa*/
    v14 = (unsigned __int16)n0x1F_1++; /*0xffc169b5*/
    *((_BYTE *)this + v14 + 4628) = n7_1; /*0xffc169b9*/
    if ( (_WORD)n0x1F_1 == n0x1F ) /*0xffc169c5*/
    {
      for ( i = DxeIplGetDecompressAlgo((int)this, 2u) - 1; i >= 0 && (unsigned __int16)n0x1F_1 < 0x1Fu; --i ) /*0xffc169d2*/
      {
        v16 = (unsigned __int16)n0x1F_1++; /*0xffc169dc*/
        *((_BYTE *)this + v16 + 4628) = 0; /*0xffc169e6*/
      }
    }
    if ( (unsigned __int16)n0x1F_1 >= DecompressAlgo ) /*0xffc169f9*/
      break; /*0xffc169f9*/
  }
  while ( (unsigned __int16)n0x1F_1 < count && (unsigned __int16)n0x1F_1 < 0x1Fu ) /*0xffc16a0b*/
  {
    n0x1F_2 = (unsigned __int16)n0x1F_1; /*0xffc16a0d*/
    LOWORD(n0x1F_1) = n0x1F_1 + 1; /*0xffc16a10*/
    *((_BYTE *)this + n0x1F_2 + 4628) = 0; /*0xffc16a11*/
  }
  return DxeIplHuffmanBuildTable((int)this, count, (int)(this + 1157), 8u, (int)(this + 3213)); /*0xffc16a3a*/
}