RtlUshortByteSwap - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H
//
// Byte swap routines.
//
#ifndef PHNT_RTL_BYTESWAP

#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))

#endif
#endif

View code on GitHub
#ifndef _NTRTL_H
//
// Byte swap routines.
//
#ifndef PHNT_RTL_BYTESWAP
// ...
#else

NTSYSAPI
USHORT
FASTCALL
RtlUshortByteSwap(
    _In_ USHORT Source
    );

#endif
#endif

View code on GitHub
// wdm.h

NTSYSAPI USHORT RtlUshortByteSwap(
  [in] USHORT Source
);
View the official Windows Driver Kit DDI reference

NtDoc

This function is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (nf-wdm-rtlushortbyteswap)

RtlUshortByteSwap macro

Description

The RtlUshortByteSwap routine reverses the ordering of the two bytes in a 16-bit unsigned integer value.

Parameters

Source [in]

A USHORT value to convert to a byte-swapped version.

Return value

The byte-swapped version of the input parameter value.

Remarks

For example, if the Source parameter value is 0x1234, the routine returns 0x3412.

A typical use of this routine is to convert a USHORT value from little-endian byte format to big-endian byte format, and vice versa.

Use this routine instead of ntohs or htons.

To reverse the ordering of bytes in a ULONG value, use the RtlUlongByteSwap routine. To reverse ordering of bytes in a ULONGLONG value, use the RtlUlonglongByteSwap routine.

See also

RtlUlongByteSwap

RtlUlonglongByteSwap