HvCheckBin

INT64 __fastcall HvCheckBin(INT64 a1, _DWORD *a2, INT64 a3, _DWORD *a4, RTL_BITMAP *BitMapHeader, INT64 a6, INT64 a7){
  INT64 v7; 
  unsigned int v8; 
  unsigned int v10; 
  unsigned int v11; 
  int v12; 
  int *v13; 
  __int64 v14; 
  __int64 v15; 
  __int64 v16; 
  char *v17; 
  char v19; 
  INT64 v20; 
  _DWORD *v21; 
  INT64 v22; 
  INT64 v23; 
  unsigned int v24; 
  _DWORD *v25; 
  v25 = a4;
  v7 = a7;
  v8 = 0;
  v24 = 0;
  v10 = 0;
  v11 = 0;
  v12 = 0;
  if( a7 )
    *(_QWORD *)(a7 + 328) = a2;
  v13 = a2 + 8;
  v14 = (unsigned int)a2[2];
  if( v13 >= (_DWORD *)((char *)a2 + v14) )
  {
LABEL_14:
    if( v11 + v10 + 32i64 == (unsigned int)v14 )
    {
      if( v13 == (_DWORD *)((char *)a2 + (unsigned int)v14) )
      {
        if( a4 )
          *a4 += v12;
        return v8;
      }
      LODWORD(v23) = 112;
    }
    else
    {
      LODWORD(v23) = 96;
    }
    v8 = -1073741492;
    SetFailureLocation(v7, 0i64, 17i64, 3221225804i64, v23);
    return v8;
  }
  while( 1 )
  {
    v15 = *v13;
    if( (int)v15 >= 0 )
      break;
    v16 = (unsigned int)-(int)v15;
    if( (unsigned int)v16 > (unsigned int)v14
      || (v17 = (char *)v13 + v16, (char *)v13 + v16 > (char *)a2 + (unsigned int)v14) )
    {
      v22 = a7;
      v8 = -1073741492;
      if( !a7 )
        return v8;
      LODWORD(v23) = 32;
      goto LABEL_39;
    }
    v11 -= v15;
    v12 = v12 - v15 - 4;
    if( v11 > (unsigned int)v14 )
    {
      v22 = a7;
      v8 = -1073741492;
      if( !a7 )
        return v8;
      LODWORD(v23) = 48;
      goto LABEL_39;
    }
    if( a6 && (unsigned int)v16 >= 0x54ui64 && *((_WORD *)v13 + 2) == 27502 )
    {
      v19 = *((_BYTE *)v13 + 16);
      if( (v19 & 2) != 0 )
      {
        HvMoveLayoutStats((_DWORD *)(a6 + 32));
        HvMoveLayoutStats((_DWORD *)(a6 + 16));
        *(_QWORD *)(a6 + 48) = 0i64;
      }
      else
      {
        v20 = (unsigned int)(8 * v13[6] + 40 - v15);
        if( (v19 & 1) != 0 )
        {
          HvAddToLayoutStats(a6 + 32, v20);
          HvMoveLayoutStats((_DWORD *)(a6 + 16));
          if( !*(_DWORD *)(a6 + 48) )
            *(_DWORD *)(a6 + 48) = a2[1];
          *(_DWORD *)(a6 + 52) = 0;
        }
        else
        {
          HvAddToLayoutStats(a6 + 16, v20);
          if( !*(_DWORD *)(a6 + 52) )
            *(_DWORD *)(a6 + 52) = a2[1];
        }
      }
    }
    if( BitMapHeader )
    {
      RtlSetBits(BitMapHeader, (unsigned int)((_DWORD)v13 + a2[1] - (_DWORD)a2) >> 3, 1ui64);
      v10 = v24;
    }
LABEL_12:
    v13 = (int *)v17;
    LODWORD(v14) = a2[2];
    if( v17 >= (char *)a2 + (unsigned int)v14 )
    {
      a4 = v25;
      v7 = a7;
      goto LABEL_14;
    }
  }
  if( (unsigned int)v15 <= (unsigned int)v14 && (char *)v13 + v15 <= (char *)a2 + (unsigned int)v14 && (_DWORD)v15 )
  {
    v10 += v15;
    v24 = v10;
    if( v10 <= (unsigned int)v14 )
    {
      if( a6 )
      {
        HvAddToLayoutStats(a6, (unsigned int)v15);
        HvMoveLayoutStats(v21);
      }
      v17 = (char *)v13 + *v13;
      goto LABEL_12;
    }
    v22 = a7;
    v8 = -1073741492;
    if( a7 )
    {
      LODWORD(v23) = 80;
LABEL_39:
      SetFailureLocation(v22, 0i64, 17i64, 3221225804i64, v23);
      *(_QWORD *)(a7 + 336) = v13;
      return v8;
    }
    return v8;
  }
  if( a7 )
  {
    LODWORD(v23) = 64;
    SetFailureLocation(a7, 0i64, 17i64, 3221225804i64, v23);
    *(_QWORD *)(a7 + 336) = v13;
  }
  return 60i64;
}

Referenced by:

HvCheckHive