MiFreeRelocations

VOID __stdcall MiFreeRelocations(_CONTROL_AREA *ControlArea, VOID *Context){
  __int64 NumberOfSystemCacheViews; 
  _QWORD *v5; 
  _QWORD *LeafPfnBuddy; 
  _QWORD *v7; 
  volatile unsigned int WritableUserReferences; 
  bool v9; 
  _MMPFN *v10; 
  __int128 v11; 
  __int64 v12; 

  if( Context )
  {
    v12 = 0i64;
    NumberOfSystemCacheViews = ControlArea->u2.NumberOfSystemCacheViews;
    v11 = 0i64;
    if( NumberOfSystemCacheViews != 0xFFFFFFFFi64 )
    {
      WritableUserReferences = ControlArea->u2.WritableUserReferences;
      *(_QWORD *)&v11 = NumberOfSystemCacheViews;
      DWORD2(v11) = (unsigned __int16)WritableUserReferences;
      v9 = (ControlArea->u.LongFlags & 0x10000000) == 0;
      LODWORD(v12) = (WritableUserReferences >> 20) & 3;
      if( v9 )
      {
        BYTE12(v11) = 0;
      }
      else
      {
        BYTE12(v11) = 1;
        BYTE13(v11) = BYTE2(WritableUserReferences) & 1;
      }
      MiReturnImageBase((__int64)&v11);
      ControlArea->u2.NumberOfSystemCacheViews = -1;
    }
    MiFreeImageLoadConfig((INT64)Context + 72);
    v5 = (_QWORD *)*((_QWORD *)Context + 2);
    if( v5 )
    {
      do
      {
        v7 = (_QWORD *)*v5;
        ExFreePoolWithTag(v5, 0);
        v5 = v7;
      }
      while( v7 );
    }
    LeafPfnBuddy = (_QWORD *)*((_QWORD *)Context + 13);
    while( LeafPfnBuddy )
    {
      LeafPfnBuddy = (_QWORD *)MiGetLeafPfnBuddy(LeafPfnBuddy);
      MiDeleteDirectMapFixupPfn(v10);
    }
    ExFreePoolWithTag(Context, 0);
  }
}

Referenced by:

MiDeleteControlArea
MiRelocateImage