RtlFindNextForwardRunSet

UINT32 __stdcall RtlFindNextForwardRunSet(PRTL_BITMAP BitMapHeader, UINT32 FromIndex, PULONG StartingRunIndex){
  unsigned int SizeOfBitMap; 
  unsigned int v5; 
  unsigned int *Buffer; 
  unsigned int *v8; 
  unsigned int *v9; 
  UINT32 v10; 
  int v11; 
  unsigned int v12; 
  unsigned int i; 
  unsigned int *v15; 
  SizeOfBitMap = BitMapHeader->SizeOfBitMap;
  v5 = FromIndex;
  if( BitMapHeader->SizeOfBitMap <= FromIndex )
  {
    *StartingRunIndex = FromIndex;
    return 0;
  }
  Buffer = BitMapHeader->Buffer;
  v8 = &Buffer[(unsigned __int64)(SizeOfBitMap - 1) >> 5];
  v9 = &Buffer[(unsigned __int64)v5 >> 5];
  v10 = 0;
  if( v9 != v8 && (~*((_DWORD *)qword_140011CE0 + (v5 & 0x1F)) & *v9) == 0 )
  {
    v5 = v5 - (v5 & 0x1F) + 32;
    for( ++v9; v9 < v8 && !*v9; ++v9 )
      v5 += 32;
  }
  for( ; v5 < SizeOfBitMap; ++v5 )
  {
    if( _bittest((const signed __int32 *)BitMapHeader->Buffer, v5) )
      break;
  }
  if( v9 == v8 )
    goto LABEL_9;
  v11 = v5 & 0x1F;
  if( (*v9 | *((_DWORD *)qword_140011CE0 + (v5 & 0x1F))) != -1 )
    goto LABEL_9;
  v10 = 32 - v11;
  if( v11 != 33 )
  {
    v15 = v9 + 1;
    while( v15 < v8 && *v15 == -1 )
    {
      ++v15;
      v10 += 32;
      if( v10 == -1 )
        goto LABEL_13;
    }
LABEL_9:
    v12 = BitMapHeader->SizeOfBitMap;
    for( i = v10 + v5; i < v12; ++v10 )
    {
      if( !_bittest((const signed __int32 *)BitMapHeader->Buffer, i) )
        break;
      if( v10 == -1 )
        break;
      ++i;
    }
  }
LABEL_13:
  *StartingRunIndex = v5;
  return v10;
}

Referenced by:

CmFcpManagerDrainUsageNotifications
HvpResetPageProtection