RtlIpv4AddressToStringEx - NtDoc

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

NTSYSAPI
NTSTATUS
NTAPI
RtlIpv4AddressToStringExA(
    _In_ PCIN_ADDR Address,
    _In_ USHORT Port,
    _Out_writes_to_(*AddressStringLength, *AddressStringLength) PSTR AddressString,
    _Inout_ PULONG AddressStringLength
    );

#endif

View code on GitHub
#ifndef _NTRTL_H

NTSYSAPI
NTSTATUS
NTAPI
RtlIpv4AddressToStringExW(
    _In_ PCIN_ADDR Address,
    _In_ USHORT Port,
    _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWSTR AddressString,
    _Inout_ PULONG AddressStringLength
    );

#endif

View code on GitHub
#ifndef _NTRTL_H

#define RtlIpv4AddressToStringEx RtlIpv4AddressToStringExW

#endif

View code on GitHub
// ip2string.h

NTSYSAPI NTSTATUS RtlIpv4AddressToStringExA(
  [in]      const in_addr *Address,
  [in]      USHORT        Port,
  [out]     PSTR          AddressString,
  [in, out] PULONG        AddressStringLength
);
View the official Win32 API reference
// ip2string.h

NTSYSAPI NTSTATUS RtlIpv4AddressToStringExW(
  [in]      const in_addr *Address,
  [in]      USHORT        Port,
  [out]     PWSTR         AddressString,
  [in, out] PULONG        AddressStringLength
);
View the official Win32 API reference

NtDoc

This function is documented in Windows SDK here and here.

Win32 API reference (nf-ip2string-rtlipv4addresstostringexa)

RtlIpv4AddressToStringExA function

Description

The RtlIpv4AddressToStringEx function converts an IPv4 address and port number to a string in Internet standard format.

Parameters

Address [in]

The IPv4 address in network byte order.

Port [in]

The port number in network byte order format. This parameter is optional.

AddressString [out]

A pointer to the buffer to receive the NULL-terminated string representation of the IPv4 address and port. This buffer should be large enough to hold at least INET_ADDRSTRLEN characters. The INET_ADDRSTRLEN value is defined in the Ws2ipdef.h header file.

AddressStringLength [in, out]

On input, the number of characters that fit in the buffer pointed to by the AddressString parameter, including the NULL terminator.

On output, this parameter contains the number of characters actually written to the buffer pointed to by the AddressString parameter.

Return value

If the function succeeds, the return value is STATUS_SUCCESS.

If the function fails, the return value is one of the following error codes.

Return code Description
STATUS_INVALID_PARAMETER An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the AddressString or AddressStringLength parameter. This error is also returned if the length of the buffer pointed to by the AddressString parameter is not large enough to receive the string representation of the IPv4 address and port.
Other Use FormatMessage to obtain the message string for the returned error.

Remarks

The RtlIpv4AddressToStringEx function is used to convert an IPv4 address and port number to the string representation of the IPv4 address in Internet dotted-decimal format followed by a colon character and a string representation of the port.

RtlIpv4AddressToStringEx is a convenience function that does not require that the Windows Sockets DLL be loaded to access a function provided in Windows Sockets to perform IP address to string conversion.

If the length of the buffer pointed to by the AddressString parameter is not large enough to receive the string representation of the IPv4 address and port, RtlIpv4AddressToStringEx returns ERROR_INVALID_PARAMETER and sets the AddressStringLength parameter to the buffer length required.

When either UNICODE or _UNICODE is defined, RtlIpv4AddressToStringEx is defined to RtlIpv4AddressToStringExW, the Unicode version of this function. The AddressString parameter is defined to the PWSTR data type.

When both UNICODE and _UNICODE are not defined, RtlIpv4AddressToStringEx is defined to RtlIpv4AddressToStringExA, the ANSI version of this function. The AddressString parameter is defined to the PSTR data type.

The IN_ADDR structure is defined in the Inaddr.h header file.

See also

GetModuleHandle GetProcAddress InetNtop InetPton LoadLibrary RtlIpv4AddressToString RtlIpv4StringToAddress RtlIpv4StringToAddressEx RtlIpv6AddressToString RtlIpv6AddressToStringEx RtlIpv6StringToAddress RtlIpv6StringToAddressEx inet_addr inet_ntoa


Win32 API reference (nf-ip2string-rtlipv4addresstostringexw)

RtlIpv4AddressToStringExW function

Description

The RtlIpv4AddressToStringEx function converts an IPv4 address and port number to a string in Internet standard format.

Parameters

Address [in]

The IPv4 address in network byte order.

Port [in]

The port number in network byte order format. This parameter is optional.

AddressString [out]

A pointer to the buffer to receive the NULL-terminated string representation of the IPv4 address and port. This buffer should be large enough to hold at least INET_ADDRSTRLEN characters. The INET_ADDRSTRLEN value is defined in the Ws2ipdef.h header file.

AddressStringLength [in, out]

On input, the number of characters that fit in the buffer pointed to by the AddressString parameter, including the NULL terminator. On output, this parameter contains the number of characters actually written to the buffer pointed to by the AddressString parameter.

Return value

If the function succeeds, the return value is STATUS_SUCCESS.

If the function fails, the return value is one of the following error codes.

Return code Description
STATUS_INVALID_PARAMETER An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the AddressString or AddressStringLength parameter. This error is also returned if the length of the buffer pointed to by the AddressString parameter is not large enough to receive the string representation of the IPv4 address and port.
Other Use FormatMessage to obtain the message string for the returned error.

Remarks

The RtlIpv4AddressToStringEx function is used to convert an IPv4 address and port number to the string representation of the IPv4 address in Internet dotted-decimal format followed by a colon character and a string representation of the port.

RtlIpv4AddressToStringEx is a convenience function that does not require that the Windows Sockets DLL be loaded to access a function provided in Windows Sockets to perform IP address to string conversion.

If the length of the buffer pointed to by the AddressString parameter is not large enough to receive the string representation of the IPv4 address and port, RtlIpv4AddressToStringEx returns ERROR_INVALID_PARAMETER and sets the AddressStringLength parameter to the buffer length required.

When either UNICODE or _UNICODE is defined, RtlIpv4AddressToStringEx is defined to RtlIpv4AddressToStringExW, the Unicode version of this function. The AddressString parameter is defined to the PWSTR data type.

When both UNICODE and _UNICODE are not defined, RtlIpv4AddressToStringEx is defined to RtlIpv4AddressToStringExA, the ANSI version of this function. The AddressString parameter is defined to the PSTR data type.

The IN_ADDR structure is defined in the Inaddr.h header file.

See also

GetModuleHandle

GetProcAddress

InetNtop

InetPton

LoadLibrary

RtlIpv4AddressToString

RtlIpv4StringToAddress

RtlIpv4StringToAddressEx

RtlIpv6AddressToString

RtlIpv6AddressToStringEx

RtlIpv6StringToAddress

RtlIpv6StringToAddressEx

inet_addr

inet_ntoa