Export (0) Print
Expand All
Expand Minimize

RtlInitAnsiString routine

The RtlInitAnsiString routine initializes a counted string of ANSI characters.

Syntax


VOID RtlInitAnsiString(
  _Out_     PANSI_STRING DestinationString,
  _In_opt_  PCSZ SourceString
);

Parameters

DestinationString [out]

A pointer to the ANSI_STRING structure to be initialized.

SourceString [in, optional]

A pointer to a null-terminated character string. This string is used to initialize the counted string pointed to by DestinationString.

Return value

None

Remarks

This routine initializes a counted character string.

The routine copies the SourceString pointer value to the Buffer member of the ANSI_STRING structure pointed to by DestinationString. The Length member of this structure is set to the length, in bytes, of the source string, excluding the terminating null. The MaximumLength member of the structure is set to the length, in bytes, of the source string, including the terminating null. If SourceString is NULL, Length and MaximumLength are both set to zero.

RtlInitAnsiString does not alter the source string pointed to by SourceString.

Note  If the source string is longer than MAXUSHORT - 1 bytes, RtlInitAnsiString sets the Length member of the ANSI_STRING structure pointed to by DestinationString to MAXUSHORT - 1, and sets the MaximumLength member of this structure to MAXUSHORT. In this case, the Length and MaximumLength values misrepresent the length of the null-terminated source string, and relying on the accuracy of these values is potentially dangerous.

Callers of RtlInitAnsiString can be running at IRQL <= DISPATCH_LEVEL if the DestinationString buffer is nonpageable. Usually, callers run at IRQL = PASSIVE_LEVEL because most other RtlXxxString routines cannot be called at IRQL > PASSIVE_LEVEL.

Requirements

Version

Available starting with Windows 2000.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

Ntoskrnl.lib

IRQL

Any level (See Remarks section)

See also

ANSI_STRING

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft