Summary of Kernel-Mode Safe String Functions

The following table summarizes the safe string functions that are available to kernel-mode drivers, and it indicates the C/C++ language runtime library functions that they replace. If a function's name contains Cb, the function treats strings as byte-counted. If a function's name contains Cch, the function treats strings as character-counted.

Functions Purpose Replaces

RtlStringCbCat
RtlStringCbCatEx
RtlStringCchCat
RtlStringCchCatEx
RtlUnicodeStringCat
RtlUnicodeStringCatEx
RtlUnicodeStringCatString
RtlUnicodeStringCatStringEx
RtlUnicodeStringCbCatStringN
RtlUnicodeStringCbCatStringNEx
RtlUnicodeStringCchCatStringN
RtlUnicodeStringCchCatStringNEx

Concatenate two strings.

strcat
wcscat

RtlStringCbCatN
RtlStringCbCatNEx
RtlStringCchCatN
RtlStringCchCatNEx
RtlUnicodeStringCbCatN
RtlUnicodeStringCbCatNEx
RtlUnicodeStringCchCatN
RtlUnicodeStringCchCatNEx

Concatenate two byte-counted strings, while limiting the size of the appended string.

strncat
wcsncat

RtlStringCbCopy
RtlStringCbCopyEx
RtlStringCbCopyUnicodeString
RtlStringCbCopyUnicodeStringEx
RtlStringCchCopy
RtlStringCchCopyEx
RtlStringCchCopyUnicodeString
RtlStringCchCopyUnicodeStringEx
RtlUnicodeStringCopy
RtlUnicodeStringCopyEx
RtlUnicodeStringCopyString
RtlUnicodeStringCopyStringEx

Copy a string into a buffer.

strcpy
wcscpy

RtlStringCbCopyN
RtlStringCbCopyNEx
RtlStringCchCopyN
RtlStringCchCopyNEx
RtlUnicodeStringCbCopyN
RtlUnicodeStringCbCopyNEx
RtlUnicodeStringCchCopyN
RtlUnicodeStringCchCopyNEx
RtlUnicodeStringCbCopyStringN
RtlUnicodeStringCbCopyStringNEx
RtlUnicodeStringCchCopyStringN
RtlUnicodeStringCchCopyStringNEx

Copy a string into a buffer, while limiting the size of the copied string.

strncpy
wcsncpy

RtlStringCbLength
RtlStringCchLength
RtlUnalignedStringCbLength
RtlUnalignedStringCchLength

Determine the length of a supplied string.

strlen
wcslen

RtlStringCbPrintf
RtlStringCbPrintfEx
RtlStringCchPrintf
RtlStringCchPrintfEx
RtlUnicodeStringPrintf
RtlUnicodeStringPrintfEx

Create a formatted text string that is based on a format string and a set of additional function arguments.

sprintf
swprintf
_snprintf
_snwprintf

RtlStringCbVPrintf
RtlStringCbVPrintfEx
RtlStringCchVPrintf
RtlStringCchVPrintfEx
RtlUnicodeStringVPrintf
RtlUnicodeStringVPrintfEx

Create a formatted text string that is based on a format string and one additional function argument.

vsprintf
vswprintf
_vsnprintf
_vsnwprintf

RtlUnicodeStringInit
RtlUnicodeStringInitEx
RtlUnicodeStringValidate
RtlUnicodeStringValidateEx

Initialize or validate a UNICODE_STRING structure.

None