RtlHotPatchSynchronizationRequired

INT64 __fastcall RtlHotPatchSynchronizationRequired(
        INT64 a1,
        _DWORD *a2,
        INT64 a3,
        INT64 a4,
        INT64 a5,
        INT64 a6,
        _RTL_BITMAP *BitMapHeader,
        INT64 a8,
        INT64 a9,
        INT64 a10){
  __int64 HotPatchSize; 
  unsigned int *v12; 
  signed int v13; 
  unsigned int *v14; 
  bool v15; 
  BYTE *v16; 
  INT64 v17; 
  char v18; 
  __int64 v19; 
  int v20; 
  ULONG i; 
  int v23; 
  ULONG ClearBitsAndSet; 
  *(_BYTE *)a10 = 0;
  if( a3 )
  {
    HotPatchSize = (unsigned int)RtlGetHotPatchSize(a2);
    do
    {
      v13 = *v12;
      v14 = v12;
      if( !*v12 )
        break;
      v15 = 0;
      ++v12;
      if( (v13 & 0xFC000) == 114688 )
        v15 = v13 >= 0;
      if( v15 )
      {
        if( (v13 & 0xFFF) != 0 )
        {
          do
          {
            v16 = 0i64;
            if( (_DWORD)HotPatchSize != 2 )
              v16 = (BYTE *)(v12 + 2);
            v17 = RtlpCheckFunctionPatchAppliedInOriginalImage((BYTE *)(a1 + *v12), v16);
            if( v17 == -1 )
              return 3221225595i64;
            if( v17 )
            {
              if( a6 )
                _bittestandset((signed __int32 *)BitMapHeader->Buffer, (v17 - a5) >> 3);
            }
            else if( (v18 & 7) == 7 )
            {
LABEL_14:
              *(_BYTE *)a10 = 1;
              return 0i64;
            }
            v12 = (unsigned int *)(v19 + 4 * HotPatchSize);
          }
          while( v20 != 1 );
        }
      }
      else
      {
        v12 = &v14[(v13 & 0xFFF) * (unsigned int)HotPatchSize + 1];
      }
    }
    while( v12 );
  }
  if( a6 )
  {
    for( i = 0; ; i = ClearBitsAndSet )
    {
      ClearBitsAndSet = RtlFindClearBitsAndSet(BitMapHeader, 1u, i);
      if( ClearBitsAndSet == -1 )
        break;
      v23 = *(_DWORD *)(a6 + 6i64 * ClearBitsAndSet);
      if( v23 && (((_BYTE)a1 + (_BYTE)v23) & 7) == 7 )
        goto LABEL_14;
    }
  }
  return 0i64;
}

Referenced by:

MiPrepareToHotPatchImage