UNICODE_STRING - NtDoc

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

typedef struct _UNICODE_STRING
{
    USHORT Length;
    USHORT MaximumLength;
    _Field_size_bytes_part_opt_(MaximumLength, Length) PWCH Buffer;
} UNICODE_STRING, *PUNICODE_STRING;

#endif
#endif

View code on GitHub
// ntdef.h

typedef struct _UNICODE_STRING {
  USHORT Length;
  USHORT MaximumLength;
  PWSTR  Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
View the official Win32 API reference

NtDoc

This structure is documented in Windows Driver Kit.

Win32 API reference (ns-ntdef-_unicode_string)

_UNICODE_STRING structure

Description

The UNICODE_STRING structure is used to define Unicode strings.

Members

Length

The length, in bytes, of the string stored in Buffer.

MaximumLength

The length, in bytes, of Buffer.

Buffer

Pointer to a buffer used to contain a string of wide characters.

Syntax

typedef struct _UNICODE_STRING {
  USHORT Length;
  USHORT MaximumLength;
  PWSTR  Buffer;
} UNICODE_STRING, *PUNICODE_STRING;

Remarks

The UNICODE_STRING structure is used to pass Unicode strings. Use RtlUnicodeStringInit or RtlUnicodeStringInitEx to initialize a UNICODE_STRING structure.

If the string is null-terminated, Length does not include the trailing null character.

The MaximumLength is used to indicate the length of Buffer so that if the string is passed to a conversion routine such as RtlAnsiStringToUnicodeString the returned string does not exceed the buffer size.

See also

ANSI_STRING

OEM_STRING

RtlAnsiStringToUnicodeSize

RtlAnsiStringToUnicodeString

RtlFreeUnicodeString

RtlInitUnicodeString

RtlUnicodeStringToAnsiSize

RtlUnicodeStringToAnsiString