RtlCompareUnicodeString

NTSTATUS __stdcall RtlCompareUnicodeString(
        const _UNICODE_STRING *String1,
        const _UNICODE_STRING *String2,
        UINT8 CaseInSensitive){
  UINT16 *Buffer; 
  unsigned __int64 v4; 
  unsigned __int64 v5; 
  unsigned __int64 v6; 
  UINT16 *v7; 
  char *v8; 
  int v10; 
  unsigned __int64 v11; 
  int v12; 
  int v13; 
  char *v14; 

  Buffer = String1->Buffer;
  v4 = (unsigned __int64)String1->Length >> 1;
  v5 = (unsigned __int64)String2->Length >> 1;
  v6 = v4;
  if( v4 > v5 )
    v6 = (unsigned __int64)String2->Length >> 1;
  v7 = &Buffer[v6];
  if( Buffer >= v7 )
    return v4 - v5;
  if( CaseInSensitive )
  {
    v8 = (char *)((char *)String2->Buffer - (char *)Buffer);
    while( 1 )
    {
      if( *Buffer != *(UINT16 *)((char *)Buffer + (_QWORD)v8) )
      {
        v10 = NLS_UPCASE(*Buffer);
        if( (unsigned int)v11 >= 0x61 )
        {
          if( (unsigned int)v11 > 0x7A )
          {
            if( Nls844UnicodeUpcaseTable )
            {
              if( (unsigned __int16)v11 >= 0xC0u )
                LOWORD(v11) = *(_WORD *)(Nls844UnicodeUpcaseTable
                                       + 2
                                       * ((v11 & 0xF)
                                        + *(unsigned __int16 *)(Nls844UnicodeUpcaseTable
                                                              + 2i64
                                                              * (((unsigned __int8)v11 >> 4)
                                                               + (unsigned int)*(unsigned __int16 *)(Nls844UnicodeUpcaseTable + 2 * (v11 >> 8))))))
                            + v11;
            }
          }
          else
          {
            LOWORD(v11) = v11 - 32;
          }
        }
        if( (_WORD)v10 != (_WORD)v11 )
          break;
      }
      if( ++Buffer >= v7 )
        return v4 - v5;
    }
    v12 = (unsigned __int16)v11;
    v13 = v10;
  }
  else
  {
    v14 = (char *)((char *)String2->Buffer - (char *)Buffer);
    while( 1 )
    {
      v13 = *Buffer;
      v12 = *(unsigned __int16 *)((char *)Buffer + (_QWORD)v14);
      if( (_WORD)v13 != (_WORD)v12 )
        break;
      if( ++Buffer >= v7 )
        return v4 - v5;
    }
  }
  return v13 - v12;
}

Referenced by:

AuthzBasepCompareUnicodeStringOperands
CmpCheckLexicographicalOrder
CmpDoCompareKeyName
CmpFindNameInListCellWithStatus
CmpSetSystemBiosInformation
CmpSortedValueEnumStackValueCompareFunction
ExCovReadjustUnloadedModuleEntry
ExpCovIsModulePresent
ExpCovQueryHypervisorInformation
FsRtlCompareNodeAndKey
IopEliminateBogusConflict
IopExecuteHardwareProfileChange
IopInitializeBootDrivers
KiHwPolicyFindDriverImage
KsepCacheDeviceEqual
KsepCacheHwIdEqual
PiCompareDDBCacheEntries
PiDevCfgConfigureDevice
PiDevCfgFindDeviceMigrationNode
PiDevCfgResolveVariableExpression
PiSwBusRelationsCompareInstancePath
PnpCompareInstancePath
PopAvlComparePowerRequestKeys
PopFxFindAcpiDeviceByUniqueId
RtlpCapabilityCheckSystemCapability
RtlpProcessIFEOKeyFilter
SepAdtClassifyObjectIntoSubCategory
SepAdtStagingEvent
SepCaptureTokenSecurityAttributesInformation
SepRmGlobalSaclFind
SepVerifyDesktopAppPolicyOverrideCaller