# GetDomainNameFromIPV4AddressAsString

```
BOOL GetDomainNameFromIPV4AddressAsStringW(_In_ PWCHAR IpAddress, _Inout_ PWCHAR DomainName)
{
    WSADATA WindowsSocketData = { 0 };
    BOOL bFlag = FALSE;
    SOCKADDR_IN AddressInformation = { 0 };

    if (WSAStartup(MAKEWORD(2, 2), &WindowsSocketData) != ERROR_SUCCESS)
        return FALSE;

    AddressInformation.sin_family = AF_INET;
    AddressInformation.sin_addr.S_un.S_addr = ConvertIPv4StringToUnsignedLongW(IpAddress);

    if (GetNameInfoW((CONST SOCKADDR*) & AddressInformation, sizeof(SOCKADDR), DomainName, 32, NULL, 0, NI_NUMERICSERV) != ERROR_SUCCESS)
        goto EXIT_ROUTINE;

    bFlag = TRUE;

EXIT_ROUTINE:

    WSACleanup();

    return bFlag;
}

BOOL GetDomainNameFromIPV4AddressAsStringA(_In_ PCHAR IpAddress, _Inout_ PCHAR DomainName)
{
    WSADATA WindowsSocketData = { 0 };
    BOOL bFlag = FALSE;
    SOCKADDR_IN AddressInformation = { 0 };

    if (WSAStartup(MAKEWORD(2, 2), &WindowsSocketData) != ERROR_SUCCESS)
        return FALSE;

    AddressInformation.sin_family = AF_INET;
    AddressInformation.sin_addr.S_un.S_addr = ConvertIPv4StringToUnsignedLongA(IpAddress);

    if (GetNameInfoA((CONST SOCKADDR*) & AddressInformation, sizeof(SOCKADDR), DomainName, 32, NULL, 0, NI_NUMERICSERV) != ERROR_SUCCESS)
        goto EXIT_ROUTINE;

    bFlag = TRUE;

EXIT_ROUTINE:

    WSACleanup();

    return bFlag;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malwaresourcecode.com/home/networking/getdomainnamefromipv4addressasstring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
