HvpPerformLogFileRecovery

NTSTATUS __stdcall HvpPerformLogFileRecovery(PVOID BugCheckParameter2){
  unsigned int v1; 
  __int64 v2; 
  _CHILD_LIST *v3; 
  INT64 v5; 
  __int64 v6; 
  unsigned int v7; 
  unsigned int v8; 
  unsigned int v9; 
  unsigned int *v10; 
  __int64 v11; 
  unsigned int v12; 
  int v13; 
  NTSTATUS v14; 
  INT64 v15; 
  int v16; 
  _HBIN *v17; 
  unsigned int v18; 
  struct _PRIVILEGE_SET *v19; 
  __int64 v20; 
  __int64 v21; 
  int v22; 
  unsigned int v23; 
  unsigned int *v24; 
  int v25; 
  char v26; 
  _HBIN *v27; 
  UINT64 v28; 
  unsigned int v29; 
  char v30; 
  UINT64 v31; 
  INT64 v33; 
  unsigned int v34; 
  int v35; 
  int v36; 
  unsigned int v37; 
  _HBIN *NewBin; 
  int v39; 
  PPRIVILEGE_SET v40; 
  RTL_BITMAP Source; 
  PPRIVILEGE_SET Privileges[2]; 
  __int64 v43; 
  unsigned int v44; 
  unsigned int v45; 
  __int64 v46; 
  v46 = v2;
  v45 = v1;
  v43 = 0i64;
  v34 = 0;
  NewBin = 0i64;
  v5 = (INT64)v3;
  v6 = *((_QWORD *)BugCheckParameter2 + 8);
  v7 = 0;
  *(_QWORD *)&Source.SizeOfBitMap = 0i64;
  Source.Buffer = 0i64;
  v40 = 0i64;
  v37 = 0;
  *(_OWORD *)Privileges = 0i64;
  v8 = *(_DWORD *)(v6 + 40);
  v9 = v8;
  if( v1 )
  {
    v10 = (unsigned int *)(v2 + 16);
    v11 = v1;
    do
    {
      v12 = *v10;
      v10 += 6;
      if( v12 <= v9 )
        v12 = v9;
      v9 = v12;
      --v11;
    }
    while( v11 );
    if( v12 > v8 )
    {
      if( (*((_DWORD *)BugCheckParameter2 + 40) & 0x8001) == 0 )
      {
        v13 = CmpDoFileSetSizeEx((INT64)BugCheckParameter2, 0i64, v12 + 4096, 1);
        v14 = v13;
        if( v13 < 0 )
        {
          LODWORD(v33) = 0;
LABEL_10:
          v15 = (unsigned int)v13;
LABEL_11:
          SetFailureLocation(v5, 0i64, 27i64, v15, v33);
          goto LABEL_62;
        }
        if( (*((_DWORD *)BugCheckParameter2 + 40) & 0x20000) != 0 )
        {
          HvpViewMapExtendStorage((INT64)BugCheckParameter2 + 216, v12);
          if( v16 < 0 )
          {
            LODWORD(v33) = 16;
            SetFailureLocation(v5, 0i64, 27i64, (unsigned int)v16, v33);
          }
        }
      }
      v13 = HvpExpandMap((INT8 *)BugCheckParameter2, 0i64, v8);
      v14 = v13;
      if( v13 < 0 )
      {
        LODWORD(v33) = 32;
        goto LABEL_10;
      }
      *((_DWORD *)BugCheckParameter2 + 68) = v12;
      v13 = HvpAdjustHiveFreeDisplay((INT64)BugCheckParameter2, v12, 0i64);
      v14 = v13;
      if( v13 < 0 )
      {
        LODWORD(v33) = 48;
        goto LABEL_10;
      }
      v13 = HvpGrowDirtyVectors((INT64)BugCheckParameter2, v12);
      v14 = v13;
      if( v13 < 0 )
      {
        LODWORD(v33) = 64;
        goto LABEL_10;
      }
      if( (*((_DWORD *)BugCheckParameter2 + 40) & 0x20000) != 0 )
        v18 = *((_DWORD *)BugCheckParameter2 + 56) - 4096;
      else
        v18 = 0;
      if( v8 < v18 )
      {
        v13 = HvpMapHiveImageFromViewMap((INT64)BugCheckParameter2, v8, v18 - v8);
        v14 = v13;
        if( v13 < 0 )
        {
          LODWORD(v33) = 80;
          goto LABEL_10;
        }
        v8 = v18;
      }
      v9 = v12;
      while( v8 < v12 )
      {
        v13 = HvpAddDummyBinToHive((_HHIVE *)BugCheckParameter2, v17, v8, &NewBin);
        v14 = v13;
        if( v13 < 0 )
        {
          LODWORD(v33) = 96;
          goto LABEL_10;
        }
        v8 += 4096;
      }
    }
    v7 = 0;
  }
  CmpAllocateTransientPoolWithTag((_HHIVE *)1, ((v9 >> 12) + 3) & 0xFFFFFFFC, 0x38334D43ui64, v3);
  v40 = v19;
  if( !v19 )
  {
    v14 = -1073741670;
    LODWORD(v33) = 112;
    v15 = 3221225626i64;
    goto LABEL_11;
  }
  memset((INT64)v19, 0i64);
  v21 = v46;
  Source.Buffer = &v40->PrivilegeCount;
  Source.SizeOfBitMap = v9 >> 9;
  v22 = *(_DWORD *)(v46 + 8);
  v39 = v22;
  v36 = v22;
  v23 = 0;
  v44 = 0;
  if( v45 )
  {
    NewBin = 0i64;
    v24 = (unsigned int *)(v46 + 4);
    v35 = 0;
    while( 1 )
    {
      HIDWORD(v43) = *v24;
      Privileges[0] = (PPRIVILEGE_SET)BugCheckParameter2;
      v13 = HvApplyLogFile(
              *((_DWORD **)BugCheckParameter2 + 8),
              v21 + 24i64 * v23,
              v20,
              (unsigned int *)Privileges,
              v33,
              (ULONG_PTR)BugCheckParameter2,
              *((__int64(__fastcall **)(_QWORD, _QWORD, __int64))BugCheckParameter2 + 3),
              *((void(__fastcall **)(_DWORD *, _QWORD))BugCheckParameter2 + 4),
              &Source,
              &v36,
              &v34,
              &v37);
      v14 = v13;
      if( v13 < 0 )
        break;
      v7 = *v24;
      v20 = 255i64;
      v25 = v35;
      v26 = -1;
      *((_WORD *)BugCheckParameter2 + 100) |= (unsigned __int16)*v24 << v35;
      if( v34 < 0xFF )
        v26 = v34;
      v27 = NewBin;
      v24 += 6;
      v35 = v25 + 3;
      v21 = v46;
      *((_BYTE *)BugCheckParameter2 + (_QWORD)NewBin + 202) = v26;
      v23 = v44 + 1;
      NewBin = (_HBIN *)((char *)&v27->Signature + 1);
      v44 = v23;
      if( v23 >= v45 )
      {
        v22 = v36;
        goto LABEL_43;
      }
    }
    LODWORD(v33) = 128;
    goto LABEL_10;
  }
LABEL_43:
  HvpSetRangeProtection(
    (_HHIVE *)BugCheckParameter2,
    0i64,
    *(unsigned int *)(*((_QWORD *)BugCheckParameter2 + 8) + 40i64),
    2ui64);
  RtlMergeBitMaps((RTL_BITMAP *)BugCheckParameter2 + 7, &Source);
  *((_DWORD *)BugCheckParameter2 + 32) = RtlNumberOfSetBits((PRTL_BITMAP)BugCheckParameter2 + 7);
  v13 = HvCheckAndUpdateHiveBackupTimeStamp((UINT64)BugCheckParameter2);
  v14 = v13;
  if( v13 < 0 )
  {
    LODWORD(v33) = 144;
    goto LABEL_10;
  }
  *((_DWORD *)BugCheckParameter2 + 45) = v39;
  *((_DWORD *)BugCheckParameter2 + 42) = v22;
  *((_BYTE *)BugCheckParameter2 + 190) = 0;
  if( *(_BYTE *)(v46 + 24i64 * (v45 - 1) + 20) )
  {
    if( v7 == 1 )
    {
      if( (*((_DWORD *)BugCheckParameter2 + 40) & 0x8001) == 0 )
      {
        RtlMergeBitMaps((RTL_BITMAP *)BugCheckParameter2 + 7, (RTL_BITMAP *)((char *)BugCheckParameter2 + 88));
        *((_DWORD *)BugCheckParameter2 + 32) = RtlNumberOfSetBits((PRTL_BITMAP)BugCheckParameter2 + 7);
        RtlClearAllBits((RTL_BITMAP *)((char *)BugCheckParameter2 + 88));
        *((_DWORD *)BugCheckParameter2 + 26) = 0;
        *((_DWORD *)BugCheckParameter2 + 40) |= 0x100u;
        v13 = HvWriteHivePrimaryFile((_HHIVE *)BugCheckParameter2, 0i64, 0i64);
        v14 = v13;
        if( v13 < 0 )
        {
          LODWORD(v33) = 256;
          goto LABEL_10;
        }
        *((_DWORD *)BugCheckParameter2 + 45) = *((_DWORD *)BugCheckParameter2 + 42);
        v13 = HvValidateOrInvalidatePrimaryFileHeader((INT64)BugCheckParameter2, 1, 0, 0);
        v14 = v13;
        if( v13 < 0 )
        {
          LODWORD(v33) = 272;
          goto LABEL_10;
        }
        RtlClearAllBits((RTL_BITMAP *)BugCheckParameter2 + 7);
        *((_DWORD *)BugCheckParameter2 + 32) = 0;
        HvResetLogFileStatusAll((INT64)BugCheckParameter2);
        *((_DWORD *)BugCheckParameter2 + 41) = 1;
      }
    }
    else
    {
      *((_DWORD *)BugCheckParameter2 + 41) = 5 - (v7 != 4);
      *((_DWORD *)BugCheckParameter2 + 43) = v22;
      *((_DWORD *)BugCheckParameter2 + 44) = 0;
      *((_BYTE *)BugCheckParameter2 + (unsigned int)HvpLogTypeToLogArrayIndex(v7) + 188) = 1;
      v29 = HvpLogTypeToLogArrayIndex(*((unsigned int *)BugCheckParameter2 + 41));
      *((_BYTE *)BugCheckParameter2 + v29 + 188) = v30;
    }
  }
  else
  {
    *((_DWORD *)BugCheckParameter2 + 41) = v7;
    *((_DWORD *)BugCheckParameter2 + 43) = *(_DWORD *)(v46 + 24i64 * (v45 - 1) + 8);
    *((_DWORD *)BugCheckParameter2 + 44) = v37;
    if( v7 == 1 )
    {
      v28 = 1i64;
    }
    else
    {
      *((_BYTE *)BugCheckParameter2 + (unsigned int)HvpLogTypeToLogArrayIndex(4ui64) + 188) = 1;
      v28 = 5i64;
    }
    *((_BYTE *)BugCheckParameter2 + (unsigned int)HvpLogTypeToLogArrayIndex(v28) + 188) = 1;
  }
  v31 = *(unsigned int *)(*((_QWORD *)BugCheckParameter2 + 8) + 40i64);
  if( (unsigned int)v31 < v9 )
    HvFreeHivePartial((UINT64)BugCheckParameter2, v31, 0i64);
  v14 = 0;
LABEL_62:
  if( Privileges[1] )
    CmSiFreeMemory(Privileges[1]);
  if( v40 )
    CmSiFreeMemory(v40);
  return v14;
}

Referenced by:

No references.