ntstrsafe.h header

If you use the safe string functions instead of the string manipulation functions that are provided by C-language run-time libraries, you protect your code from buffer overrun errors that can make code untrustworthy. This header declares functions that copy, concatenate, and format strings in a manner that prevents buffer overrun errors.

To manipulate Unicode and ANSI strings, each function is available in two versions:

  • A W-suffixed version that supports two-byte Unicode characters.
  • An A-suffixed version that supports one-byte ANSI characters.

Unicode strings are specified within UNICODE_STRING structures in kernel-mode drivers.

For more information, see:

ntstrsafe.h contains the following programming interfaces:

Functions

 
RtlStringCbCatA

The RtlStringCbCatW and RtlStringCbCatA functions concatenate two byte-counted strings.
RtlStringCbCatExA

The RtlStringCbCatExW and RtlStringCbCatExA functions concatenate two byte-counted strings.
RtlStringCbCatExW

Learn how the RtlStringCbCatExW and RtlStringCbCatExA functions concatenate two byte-counted strings.
RtlStringCbCatNA

The RtlStringCbCatNW and RtlStringCbCatNA functions concatenate two byte-counted strings while limiting the size of the appended string.
RtlStringCbCatNExA

The RtlStringCbCatNExW and RtlStringCbCatNExA functions concatenate two byte-counted strings while limiting the size of the appended string.
RtlStringCbCatNExW

Learn how the RtlStringCbCatNExW and RtlStringCbCatNExA functions concatenate two byte-counted strings while limiting the size of the appended string.
RtlStringCbCatNW

Learn how the RtlStringCbCatNW and RtlStringCbCatNA functions concatenate two byte-counted strings while limiting the size of the appended string.
RtlStringCbCatW

Learn how the RtlStringCbCatW and RtlStringCbCatA functions concatenate two byte-counted strings.
RtlStringCbCopyA

The RtlStringCbCopyW and RtlStringCbCopyA functions copy a byte-counted string into a buffer.
RtlStringCbCopyExA

The RtlStringCbCopyExW and RtlStringCbCopyExA functions copy a byte-counted string into a buffer.
RtlStringCbCopyExW

Learn how the RtlStringCbCopyExW and RtlStringCbCopyExA functions copy a byte-counted string into a buffer.
RtlStringCbCopyNA

The RtlStringCbCopyNW and RtlStringCbCopyNA functions copy a byte-counted string to a buffer while limiting the size of the copied string.
RtlStringCbCopyNExA

The RtlStringCbCopyNExW and RtlStringCbCopyNExA functions copy a byte-counted string to a buffer while limiting the size of the copied string.
RtlStringCbCopyNExW

Learn how the RtlStringCbCopyNExW and RtlStringCbCopyNExA functions copy a byte-counted string to a buffer while limiting the size of the copied string.
RtlStringCbCopyNW

Learn how the RtlStringCbCopyNW and RtlStringCbCopyNA functions copy a byte-counted string to a buffer while limiting the size of the copied string.
RtlStringCbCopyUnicodeString

The RtlStringCbCopyUnicodeString function copies the contents of a UNICODE_STRING structure to a specified destination.
RtlStringCbCopyUnicodeStringEx

The RtlStringCbCopyUnicodeStringEx function copies the contents of a UNICODE_STRING structure to a specified destination.
RtlStringCbCopyW

Learn how the RtlStringCbCopyW and RtlStringCbCopyA functions copy a byte-counted string into a buffer.
RtlStringCbLengthA

The RtlStringCbLengthW and RtlStringCbLengthA functions determine the length, in bytes, of a supplied string.
RtlStringCbLengthW

Learn how the RtlStringCbLengthW and RtlStringCbLengthA functions determine the length, in bytes, of a supplied string.
RtlStringCbPrintfA

The RtlStringCbPrintfW and RtlStringCbPrintfA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbPrintfExA

The RtlStringCbPrintfExW and RtlStringCbPrintfExA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbPrintfExW

Learn how the RtlStringCbPrintfExW and RtlStringCbPrintfExA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbPrintfW

Learn how the RtlStringCbPrintfW and RtlStringCbPrintfA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbVPrintfA

The RtlStringCbVPrintfW and RtlStringCbVPrintfA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbVPrintfExA

The RtlStringCbVPrintfExW and RtlStringCbVPrintfExA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbVPrintfExW

Learn how the RtlStringCbVPrintfExW and RtlStringCbVPrintfExA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCbVPrintfW

Learn how the RtlStringCbVPrintfW and RtlStringCbVPrintfA functions create a byte-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchCatA

The RtlStringCchCatW and RtlStringCchCatA functions concatenate two character-counted strings.
RtlStringCchCatExA

The RtlStringCchCatExW and RtlStringCchCatExA functions concatenate two character-counted strings.
RtlStringCchCatExW

Learn how the RtlStringCchCatExW and RtlStringCchCatExA functions concatenate two character-counted strings.
RtlStringCchCatNA

The RtlStringCchCatNW and RtlStringCchCatNA functions concatenate two character-counted strings while limiting the size of the appended string.
RtlStringCchCatNExA

The RtlStringCchCatNExW and RtlStringCchCatNExA functions concatenate two character-counted strings while limiting the size of the appended string.
RtlStringCchCatNExW

Learn how the RtlStringCchCatNExW and RtlStringCchCatNExA functions concatenate two character-counted strings while limiting the size of the appended string.
RtlStringCchCatNW

Learn how the RtlStringCchCatNW and RtlStringCchCatNA functions concatenate two character-counted strings while limiting the size of the appended string.
RtlStringCchCatW

Learn how the RtlStringCchCatW and RtlStringCchCatA functions concatenate two character-counted strings.
RtlStringCchCopyA

The RtlStringCchCopyW and RtlStringCchCopyA functions copy a null-terminated source string into a destination buffer of specified length.
RtlStringCchCopyExA

The RtlStringCchCopyExW and RtlStringCchCopyExA functions copy a character-counted string into a buffer.
RtlStringCchCopyExW

Learn how the RtlStringCchCopyExW and RtlStringCchCopyExA functions copy a character-counted string into a buffer.
RtlStringCchCopyNA

The RtlStringCchCopyNW and RtlStringCchCopyNA functions copy a character-counted string to a buffer while limiting the size of the copied string.
RtlStringCchCopyNExA

The RtlStringCchCopyNExW and RtlStringCchCopyNExA functions copy a character-counted string to a buffer while limiting the size of the copied string.
RtlStringCchCopyNExW

Learn how the RtlStringCchCopyNExW and RtlStringCchCopyNExA functions copy a character-counted string to a buffer while limiting the size of the copied string.
RtlStringCchCopyNW

Learn how the RtlStringCchCopyNW and RtlStringCchCopyNA functions copy a character-counted string to a buffer while limiting the size of the copied string.
RtlStringCchCopyUnicodeString

The RtlStringCchCopyUnicodeString function copies the contents of a UNICODE_STRING structure to a specified destination.
RtlStringCchCopyUnicodeStringEx

The RtlStringCchCopyUnicodeStringEx function copies the contents of a UNICODE_STRING structure to a specified destination.
RtlStringCchCopyW

Learn how the RtlStringCchCopyW and RtlStringCchCopyA functions copy a null-terminated source string into a destination buffer of specified length.
RtlStringCchLengthA

The RtlStringCchLengthW and RtlStringCchLengthA functions determine the length, in characters, of a supplied string.
RtlStringCchLengthW

Learn how the RtlStringCchLengthW and RtlStringCchLengthA functions determine the length, in characters, of a supplied string.
RtlStringCchPrintfA

The RtlStringCchPrintfW and RtlStringCchPrintfA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchPrintfExA

The RtlStringCchPrintfExW and RtlStringCchPrintfExA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchPrintfExW

Learn how the RtlStringCchPrintfExW and RtlStringCchPrintfExA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchPrintfW

Learn how the RtlStringCchPrintfW and RtlStringCchPrintfA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchVPrintfA

The RtlStringCchVPrintfW and RtlStringCchVPrintfA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchVPrintfExA

The RtlStringCchVPrintfExW and RtlStringCchVPrintfExA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchVPrintfExW

Learn how the RtlStringCchVPrintfExW and RtlStringCchVPrintfExA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlStringCchVPrintfW

Learn how the RtlStringCchVPrintfW and RtlStringCchVPrintfA functions create a character-counted text string, with formatting that is based on supplied formatting information.
RtlUnalignedStringCbLengthW

The RtlUnalignedStringCbLengthW function is a version of the RtlStringCbLength function that accepts an unaligned pointer to a string of Unicode characters.
RtlUnalignedStringCchLengthW

The RtlUnalignedStringCchLengthW function is a version of the RtlStringCchLength function that accepts an unaligned pointer to a string of Unicode characters.
RtlUnicodeStringCat

The RtlUnicodeStringCat function concatenates two strings that are contained in UNICODE_STRING structures.
RtlUnicodeStringCatEx

The RtlUnicodeStringCatEx function concatenates two strings that are contained in UNICODE_STRING structures.
RtlUnicodeStringCatString

The RtlUnicodeStringCatString function concatenates two strings when the destination string is contained in a UNICODE_STRING structure.
RtlUnicodeStringCatStringEx

The RtlUnicodeStringCatStringEx function concatenates two strings when the destination string is contained in a UNICODE_STRING structure.
RtlUnicodeStringCbCatN

The RtlUnicodeStringCbCatN function concatenates two strings that are contained in UNICODE_STRING structures while limiting the size of the copied string.
RtlUnicodeStringCbCatNEx

The RtlUnicodeStringCbCatNEx function concatenates two strings that are contained in UNICODE_STRING structures while limiting the size of the copied string.
RtlUnicodeStringCbCatStringN

The RtlUnicodeStringCbCatStringN function concatenates two strings when the destination string is contained in a UNICODE_STRING structure, while limiting the size of the appended string.
RtlUnicodeStringCbCatStringNEx

The RtlUnicodeStringCbCatStringNEx function concatenates two strings when the destination string is contained in a UNICODE_STRING structure, while limiting the size of the appended string.
RtlUnicodeStringCbCopyN

The RtlUnicodeStringCbCopyN function copies a string from one UNICODE_STRING structure to another while limiting the size of the copied string.
RtlUnicodeStringCbCopyNEx

The RtlUnicodeStringCbCopyNEx function copies a string from one UNICODE_STRING structure to another while limiting the size of the copied string.
RtlUnicodeStringCbCopyStringN

The RtlUnicodeStringCbCopyStringN function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.
RtlUnicodeStringCbCopyStringNEx

The RtlUnicodeStringCbCopyStringNEx function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.
RtlUnicodeStringCchCatN

The RtlUnicodeStringCchCatN function concatenates two strings that are contained in UNICODE_STRING structures while limiting the size of the copied string.
RtlUnicodeStringCchCatNEx

The RtlUnicodeStringCchCatNEx function concatenates two strings that are contained in UNICODE_STRING structures while limiting the size of the copied string.
RtlUnicodeStringCchCatStringN

The RtlUnicodeStringCchCatStringN function concatenates two strings when the destination string is contained in a UNICODE_STRING structure, while limiting the size of the appended string.
RtlUnicodeStringCchCatStringNEx

The RtlUnicodeStringCchCatStringNEx function concatenates two strings when the destination string is contained in a UNICODE_STRING structure, while limiting the size of the appended string.
RtlUnicodeStringCchCopyN

The RtlUnicodeStringCchCopyN function copies a string from one UNICODE_STRING structure to another while limiting the size of the copied string.
RtlUnicodeStringCchCopyNEx

The RtlUnicodeStringCchCopyNEx function copies a string from one UNICODE_STRING structure to another while limiting the size of the copied string.
RtlUnicodeStringCchCopyStringN

The RtlUnicodeStringCchCopyStringN function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.
RtlUnicodeStringCchCopyStringNEx

The RtlUnicodeStringCchCopyStringNEx function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.
RtlUnicodeStringCopy

The RtlUnicodeStringCopy function copies a string from one UNICODE_STRING structure to another.
RtlUnicodeStringCopyEx

The RtlUnicodeStringCopyEx function copies a string from one UNICODE_STRING structure to another.
RtlUnicodeStringCopyString

The RtlUnicodeStringCopyString function copies a string into a UNICODE_STRING structure.
RtlUnicodeStringCopyStringEx

The RtlUnicodeStringCopyStringEx function copies a string into a UNICODE_STRING structure.
RtlUnicodeStringInit

The RtlUnicodeStringInit function initializes a UNICODE_STRING structure.
RtlUnicodeStringInitEx

The RtlUnicodeStringInitEx function initializes a UNICODE_STRING structure.
RtlUnicodeStringPrintf

The RtlUnicodeStringPrintf function creates a text string, with formatting that is based on supplied formatting information, and stores the string in a UNICODE_STRING structure.
RtlUnicodeStringPrintfEx

The RtlUnicodeStringPrintfEx function creates a text string, with formatting that is based on supplied formatting information, and stores the string in a UNICODE_STRING structure.
RtlUnicodeStringValidate

The RtlUnicodeStringValidate function validates the contents of a UNICODE_STRING structure.
RtlUnicodeStringValidateEx

The RtlUnicodeStringValidateEx function validates the contents of a UNICODE_STRING structure.
RtlUnicodeStringVPrintf

The RtlUnicodeStringVPrintf function creates a text string, with formatting that is based on supplied formatting information, and stores the string in a UNICODE_STRING structure.
RtlUnicodeStringVPrintfEx

The RtlUnicodeStringVPrintfEx function creates a text string, with formatting that is based on supplied formatting information, and stores the string in a UNICODE_STRING structure.