RtlHotPatchSynchronizationRequired

NTSTATUS __stdcall RtlHotPatchSynchronizationRequired(
        INT64 a1,
        INT64 a2,
        INT64 a3,
        INT64 a4,
        INT64 a5,
        INT64 a6,
        PRTL_BITMAP BitMapHeader,
        INT64 a8,
        INT64 a9,
        INT64 a10){
  UINT8 *v10; 
  __int64 HotPatchSize; 
  int v13; 
  UINT8 *v14; 
  bool v15; 
  _BYTE *v16; 
  __int64 v17; 
  char v18; 
  __int64 v19; 
  int v20; 
  UINT64 i; 
  int v23; 
  unsigned int ClearBitsAndSet; 
  VOID *v25; 
  _TABLE_SEARCH_RESULT v26; 

  v10 = (UINT8 *)a3;
  *(_BYTE *)a10 = 0;
  if( a3 )
  {
    HotPatchSize = (unsigned int)RtlGetHotPatchSize((_DWORD *)a2);
    do
    {
      v13 = *(_DWORD *)v10;
      v14 = v10;
      if( !*(_DWORD *)v10 )
        break;
      v15 = 0;
      v10 += 4;
      if( (v13 & 0xFC000) == 114688 )
        v15 = v13 >= 0;
      if( v15 )
      {
        if( (v13 & 0xFFF) != 0 )
        {
          do
          {
            v16 = 0i64;
            if( (_DWORD)HotPatchSize != 2 )
              v16 = v10 + 8;
            LODWORD(v17) = RtlpCheckFunctionPatchAppliedInOriginalImage((_BYTE *)(a1 + *(unsigned int *)v10), v16);
            if( v17 == -1 )
              return -1073741701;
            if( v17 )
            {
              if( a6 )
                _bittestandset((signed __int32 *)BitMapHeader->Buffer, (v17 - a5) >> 3);
            }
            else if( (v18 & 7) == 7 )
            {
LABEL_14:
              *(_BYTE *)a10 = 1;
              return 0;
            }
            v10 = (UINT8 *)(v19 + 4 * HotPatchSize);
          }
          while( v20 != 1 );
        }
      }
      else
      {
        v10 = &v14[4 * (v13 & 0xFFF) * (unsigned int)HotPatchSize + 4];
      }
    }
    while( v10 );
  }
  if( a6 )
  {
    for( i = 0i64; ; i = ClearBitsAndSet )
    {
      ClearBitsAndSet = (unsigned int)RtlFindClearBitsAndSet(
                                        (_RTL_AVL_TABLE *)BitMapHeader,
                                        (VOID *)1,
                                        i,
                                        v10,
                                        v25,
                                        v26);
      if( ClearBitsAndSet == -1 )
        break;
      v23 = *(_DWORD *)(a6 + 6i64 * ClearBitsAndSet);
      if( v23 && (((_BYTE)a1 + (_BYTE)v23) & 7) == 7 )
        goto LABEL_14;
    }
  }
  return 0;
}

Referenced by:

MiPrepareToHotPatchImage