Newer
Older
AMI-Aptio-BIOS-Reversed / MdeModulePkg / Core / DxeIplPeim / DxeIplLzmaDecodeCore2.c
@Ajax Dong Ajax Dong 2 days ago 2 KB Full restructure
/* DxeIplLzmaDecodeCore2 @ 0xffc16a42 size=0x188 */
int __thiscall DxeIplLzmaDecodeCore2(_DWORD *this)
{
  unsigned __int16 n0x1FE_2; // bp
  unsigned __int16 v3; // si
  int value; // eax
  int n0x1FE; // esi
  unsigned __int16 n0x13; // bx
  unsigned int n0x800000; // ecx
  int v8; // ebx
  unsigned __int16 v9; // ax
  int i; // ebx
  int n0x1FE_1; // eax
  int v12; // eax

  n0x1FE_2 = DxeIplGetDecompressAlgo((int)this, 9u); /*0xffc16a51*/
  if ( n0x1FE_2 )
  {
    n0x1FE = 0; /*0xffc16a9c*/
    do
    {
      if ( (unsigned __int16)n0x1FE >= 0x1FEu ) /*0xffc16ab2*/
        break; /*0xffc16ab2*/
      n0x13 = *((_WORD *)this + HIBYTE(*(this + 5)) + 6426); /*0xffc16abe*/
      if ( n0x13 >= 0x13u ) /*0xffc16ac9*/
      {
        n0x800000 = 0x800000; /*0xffc16acb*/
        do /*0xffc16aec*/
        {
          if ( (n0x800000 & *(this + 5)) != 0 ) /*0xffc16ad6*/
            n0x13 = *((_WORD *)this + n0x13 + 1040); /*0xffc16ad8*/
          else
            n0x13 = *((_WORD *)this + n0x13 + 21); /*0xffc16ae2*/
          n0x800000 >>= 1; /*0xffc16ae7*/
        }
        while ( n0x13 >= 0x13u ); /*0xffc16aec*/
      }
      DxeIplDecompressLzma((int)this, *((unsigned __int8 *)this + n0x13 + 4628)); /*0xffc16afb*/
      if ( n0x13 > 2u )
      {
        v12 = (unsigned __int16)n0x1FE++; /*0xffc16b6c*/
        *((_BYTE *)this + v12 + 4118) = n0x13 - 2; /*0xffc16b73*/
      }
      else
      {
        if ( n0x13 )
        {
          v9 = n0x13 == 1 ? DxeIplGetDecompressAlgo((int)this, 4u) + 3 : DxeIplGetDecompressAlgo((int)this, 9u) + 20;
          v8 = v9; /*0xffc16b3b*/
        }
        else
        {
          v8 = 1; /*0xffc16b0f*/
        }
        for ( i = v8 + 0xFFFF; (i & 0x8000u) == 0; *((_BYTE *)this + n0x1FE_1 + 4118) = 0 ) /*0xffc16b47*/
        {
          if ( (unsigned __int16)n0x1FE >= 0x1FEu ) /*0xffc16b51*/
            break; /*0xffc16b51*/
          n0x1FE_1 = (unsigned __int16)n0x1FE; /*0xffc16b53*/
          i += 0xFFFF; /*0xffc16b56*/
          ++n0x1FE; /*0xffc16b5c*/
        }
      }
    }
    while ( (unsigned __int16)n0x1FE < n0x1FE_2 );
    if ( (unsigned __int16)n0x1FE != 510 ) /*0xffc16b92*/
      DxeIplSetMem64((char *)this + (unsigned __int16)n0x1FE + 4118, 510 - (unsigned __int16)n0x1FE, 0); /*0xffc16ba0*/
    return DxeIplHuffmanBuildTable((int)this, 0x1FEu, (int)this + 4118, 0xCu, (int)(this + 1165)); /*0xffc16bbc*/
  }
  else
  {
    v3 = DxeIplGetDecompressAlgo((int)this, 9u); /*0xffc16a6b*/
    DxeIplSetMem64((char *)this + 4118, 0x1FEu, 0); /*0xffc16a74*/
    value = (v3 << 16) | v3; /*0xffc16a91*/
    memset32(this + 1165, value, 0x800u); /*0xffc16a93*/
  }
  return value; /*0xffc16bc4*/
}