> For the complete documentation index, see [llms.txt](https://malwaresourcecode.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malwaresourcecode.com/home/networking/ipv4ipaddressunsignedlongtostring.md).

# IPv4IpAddressUnsignedLongToString

```
typedef PWSTR(NTAPI* RTLIPV4ADDRESSTOSTRINGW)(PIN_ADDR, PWSTR);

#pragma warning( push )
#pragma warning( disable : 6101)
BOOL ConvertIPv4IpAddressUnsignedLongToStringW(_In_ ULONG Address, _Out_ PWCHAR Buffer)
{
#pragma warning( pop ) 
	RTLIPV4ADDRESSTOSTRINGW RtlIpv4AddressToStringW = NULL;
	HMODULE hModule = NULL;
	WCHAR DisposeableObject[32] = { 0 };
	IN_ADDR InAddress = { 0 };

	if (Address == 0)
		return FALSE;

	InAddress.S_un.S_addr = Address;

	if (Buffer == NULL)
		return FALSE;

	hModule = GetModuleHandleW(L"ntdll.dll");
	if (hModule == NULL)
		return FALSE;

	RtlIpv4AddressToStringW = (RTLIPV4ADDRESSTOSTRINGW)GetProcAddress(hModule, "RtlIpv4AddressToStringW");
	if (!RtlIpv4AddressToStringW)
		return FALSE;

	RtlIpv4AddressToStringW(&InAddress, Buffer);

	RtlIpv4AddressToStringW = NULL;

	return TRUE;
}

#pragma warning( push )
#pragma warning( disable : 6101)
BOOL ConvertIPv4IpAddressUnsignedLongToStringA(_In_ ULONG Address, _Out_ PCHAR Buffer)
{
#pragma warning( pop ) 
	RTLIPV4ADDRESSTOSTRINGA RtlIpv4AddressToStringA = NULL;
	HMODULE hModule = NULL;
	CHAR DisposeableObject[32] = { 0 };
	IN_ADDR InAddress = { 0 };

	if (Address == 0)
		return FALSE;

	InAddress.S_un.S_addr = Address;

	if (Buffer == NULL)
		return FALSE;

	hModule = GetModuleHandleW(L"ntdll.dll");
	if (hModule == NULL)
		return FALSE;

	RtlIpv4AddressToStringA = (RTLIPV4ADDRESSTOSTRINGA)GetProcAddress(hModule, "RtlIpv4AddressToStringA");
	if (!RtlIpv4AddressToStringA)
		return FALSE;

	RtlIpv4AddressToStringA(&InAddress, Buffer);

	RtlIpv4AddressToStringA = NULL;

	return TRUE;
}
```
