STRING - NtDoc

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

//
// Strings
//

typedef struct _STRING
{
    USHORT Length;
    USHORT MaximumLength;
    _Field_size_bytes_part_opt_(MaximumLength, Length) PCHAR Buffer;
} STRING, *PSTRING, ANSI_STRING, *PANSI_STRING, OEM_STRING, *POEM_STRING;

#endif
#endif

View code on GitHub
// ntdef.h

typedef struct _STRING {
  USHORT Length;
  USHORT MaximumLength;
  PCHAR  Buffer;
} STRING;
View the official Win32 API reference
// winternl.h

typedef struct _STRING {
  USHORT Length;
  USHORT MaximumLength;
  PCHAR  Buffer;
} STRING;
View the official Win32 API reference

NtDoc

This structure is documented in Windows Driver Kit and in Windows SDK.

Win32 API reference (ns-ntdef-string)

STRING structure

Description

The ANSI_STRING structure defines a counted string used for ANSI strings.

Members

Length

The length in bytes of the string stored in the buffer pointed to by Buffer.

MaximumLength

The length in bytes of the buffer pointed to by Buffer.

Buffer

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

Buffer.size_is

Buffer.size_is.MaximumLength

Buffer.length_is

Buffer.length_is.Length

Remarks

The ANSI_STRING structure is used to pass ANSI strings. Use the RtlInitAnsiString routine to initialize an ANSI_STRING.

If the string is null-terminated, Length does not include the terminating NULL.

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

See also

OEM_STRING

RtlAnsiStringToUnicodeSize

RtlAnsiStringToUnicodeString

RtlFreeAnsiString

RtlInitAnsiString

RtlUnicodeStringToAnsiSize

RtlUnicodeStringToAnsiString

UNICODE_STRING


Win32 API reference (ns-winternl-string)

STRING structure

Description

Used with the RtlUnicodeStringToOemString function.

Members

Length

The length of the buffer.

MaximumLength

The maximum length of the buffer.

Buffer

The address of the buffer.

Remarks

The data type used in the DestinationString parameter of the RtlUnicodeStringToOemString function, POEM_STRING, is defined as:

typedef PSTRING POEM_STRING;