MiFreeRelocations

void __fastcall MiFreeRelocations(_DWORD *a1, _QWORD *a2){
  INT64 v2; 
  _QWORD *v5; 
  _QWORD *LeafPfnBuddy; 
  _QWORD *v7; 
  unsigned int v8; 
  bool v9; 
  _MMPFN *v10; 
  INT64 v11[2]; 
  __int64 v12; 
  if( a2 )
  {
    v12 = 0i64;
    v2 = (unsigned int)a1[22];
    *(_OWORD *)v11 = 0i64;
    if( v2 != 0xFFFFFFFFi64 )
    {
      v8 = a1[23];
      v11[0] = v2;
      LODWORD(v11[1]) = (unsigned __int16)v8;
      v9 = (a1[14] & 0x10000000) == 0;
      LODWORD(v12) = (v8 >> 20) & 3;
      if( v9 )
      {
        BYTE4(v11[1]) = 0;
      }
      else
      {
        BYTE4(v11[1]) = 1;
        BYTE5(v11[1]) = BYTE2(v8) & 1;
      }
      MiReturnImageBase((INT64)v11);
      a1[22] = -1;
    }
    MiFreeImageLoadConfig((INT64)(a2 + 9));
    v5 = (_QWORD *)a2[2];
    if( v5 )
    {
      do
      {
        v7 = (_QWORD *)*v5;
        ExFreePoolWithTag(v5, 0);
        v5 = v7;
      }
      while( v7 );
    }
    LeafPfnBuddy = (_QWORD *)a2[13];
    while( LeafPfnBuddy )
    {
      LeafPfnBuddy = (_QWORD *)MiGetLeafPfnBuddy(LeafPfnBuddy);
      MiDeleteDirectMapFixupPfn(v10, v10);
    }
    ExFreePoolWithTag(a2, 0);
  }
}

Referenced by:

MiDeleteControlArea
MiRelocateImage