[+] Fetch non-desktop class NT hostnames

This commit is contained in:
Reece Wilson 2023-09-20 18:33:27 +01:00
parent f59de8b4ae
commit 259572724c
2 changed files with 53 additions and 39 deletions

View File

@ -17,42 +17,10 @@ namespace Aurora
static bool gShouldResPathDoNothing {};
#if !defined(AURORA_PLATFORM_WIN32)
HMODULE UWPLibraryW(LPCWSTR lpLibFileName)
{
auto pos = std::basic_string_view<wchar_t>(lpLibFileName).find_last_of('/');
if (pos == std::basic_string_view<wchar_t>::npos)
{
#if defined(AURORA_HAS_LOAD_PGKD)
return (HMODULE)::LoadPackagedLibrary(lpLibFileName, 0);
#else
return (HMODULE)lpLibFileName;
#endif
}
else
{
auto pString = &lpLibFileName[pos];
#if defined(AURORA_HAS_LOAD_PGKD)
return (HMODULE)::LoadPackagedLibrary(pString, 0);
#else
return (HMODULE)pString;
#endif
}
}
HMODULE UWPLibraryW(LPCWSTR lpLibFileName);
FARPROC UWPProcAddress(HMODULE hModule,
LPCSTR lpProcName)
{
if (!hModule)
{
return nullptr;
}
#if defined(AURORA_HAS_GET_PROC_NONWIN32)
return GetProcAddress(hModule, lpProcName);
#endif
return nullptr;
}
LPCSTR lpProcName);
#endif
void InitNTAddresses()
@ -450,4 +418,43 @@ namespace Aurora
return INVALID_HANDLE_VALUE;
}
#if !defined(AURORA_PLATFORM_WIN32)
HMODULE UWPLibraryW(LPCWSTR lpLibFileName)
{
auto pos = std::basic_string_view<wchar_t>(lpLibFileName).find_last_of('/');
if (pos == std::basic_string_view<wchar_t>::npos)
{
#if defined(AURORA_HAS_LOAD_PGKD)
return (HMODULE)::LoadPackagedLibrary(lpLibFileName, 0);
#else
return (HMODULE)lpLibFileName;
#endif
}
else
{
auto pString = &lpLibFileName[pos];
#if defined(AURORA_HAS_LOAD_PGKD)
return (HMODULE)::LoadPackagedLibrary(pString, 0);
#else
return (HMODULE)pString;
#endif
}
}
FARPROC UWPProcAddress(HMODULE hModule,
LPCSTR lpProcName)
{
if (!hModule)
{
return nullptr;
}
#if defined(AURORA_HAS_GET_PROC_NONWIN32)
return GetProcAddress(hModule, lpProcName);
#endif
return nullptr;
}
#endif
}

View File

@ -19,8 +19,8 @@ namespace Aurora::IO::Net
AuString NetAdapter::GetHostname()
{
wchar_t buffer[256];
#if defined(AURORA_PLATFORM_WIN32)
wchar_t buffer[128];
DWORD dwLength { AuArraySize(buffer) };
if (!::GetComputerNameExW(ComputerNameDnsHostname, buffer, &dwLength))
@ -30,7 +30,14 @@ namespace Aurora::IO::Net
return AuLocale::ConvertFromWChar(buffer, dwLength);
#else
return "";
int iLength { AuArraySize(buffer) };
if (!(iLength = ::GetHostNameW(buffer, iLength)))
{
return {};
}
return AuLocale::ConvertFromWChar(buffer, iLength);
#endif
}
@ -230,7 +237,7 @@ namespace Aurora::IO::Net
static void FixupXPGatewaysIPv4()
{
IP_ADAPTER_INFO info[128];
IP_ADAPTER_INFO info[16];
DWORD size { sizeof(info) };
IP_ADAPTER_INFO *pAdapter {};
@ -272,8 +279,6 @@ namespace Aurora::IO::Net
}
}
#endif
static void PrecacheAdapters()
{
if (AuSwInfo::IsWindowsXPAny())
@ -293,6 +298,8 @@ namespace Aurora::IO::Net
}
}
#endif
AuList<AuSPtr<INetAdapter>> NetAdapter::GetIPv4s()
{
#if defined(AURORA_PLATFORM_WIN32)