RtlInitUnicodeString - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H
#ifndef PHNT_NO_INLINE_INIT_STRING

FORCEINLINE
VOID
NTAPI_INLINE
RtlInitUnicodeString(
    _Out_ PUNICODE_STRING DestinationString,
    _In_opt_z_ PCWSTR SourceString
    )
{
    if (SourceString)
        DestinationString->MaximumLength = (DestinationString->Length = (USHORT)(wcslen(SourceString) * sizeof(WCHAR))) + sizeof(UNICODE_NULL);
    else
        DestinationString->MaximumLength = DestinationString->Length = 0;

    DestinationString->Buffer = (PWCH)SourceString;
}

#endif
#endif

View code on GitHub
#ifndef _NTRTL_H
#ifndef PHNT_NO_INLINE_INIT_STRING
// ...
#else

NTSYSAPI
VOID
NTAPI
RtlInitUnicodeString(
    _Out_ PUNICODE_STRING DestinationString,
    _In_opt_z_ PCWSTR SourceString
    );

#endif
#endif

View code on GitHub
// wdm.h

NTSYSAPI VOID RtlInitUnicodeString(
  [out]          PUNICODE_STRING         DestinationString,
  [in, optional] __drv_aliasesMem PCWSTR SourceString
);

View the official Windows Driver Kit DDI reference
// winternl.h

VOID RtlInitUnicodeString(
  [in, out]      PUNICODE_STRING DestinationString,
  [in, optional] PCWSTR          SourceString
);

View the official Win32 API reference

NtDoc

This function is documented in Windows Driver Kit.

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

RtlInitUnicodeString function

Description

For more information, see the WdmlibRtlInitUnicodeStringEx function.

Parameters

DestinationString [out]

For more information, see the WdmlibRtlInitUnicodeStringEx function.

SourceString [in, optional]

For more information, see the WdmlibRtlInitUnicodeStringEx function.

Return value

For more information, see the WdmlibRtlInitUnicodeStringEx function.

Remarks

The RTL_CONSTANT_STRING macro creates a string or Unicode string structure to hold a counted string.

STRING RTL_CONSTANT_STRING(
  [in]  PCSZ SourceString
);

UNICODE_STRING RTL_CONSTANT_STRING(
  [in]  PCWSTR SourceString
);

RTL_CONSTANT_STRING returns either a string structure or Unicode string structure.

The RTL_CONSTANT_STRING macro replaces the RtlInitAnsiString, RtlInitString, and RtlInitUnicodeString routines when passing a constant string.

You can use RTL_CONSTANT_STRING to initialize global variables.

See also

RtlUnicodeStringInit

RtlUnicodeStringInitEx

UNICODE_STRING

WdmlibRtlInitUnicodeStringEx


Win32 API reference (nf-winternl-rtlinitunicodestring)

RtlInitUnicodeString function

Description

Initializes a counted Unicode string.

Parameters

DestinationString [in, out]

The buffer for a counted Unicode string to be initialized. The length is initialized to zero if the SourceString is not specified.

SourceString [in, optional]

Optional pointer to a null-terminated Unicode string with which to initialize the counted string.