From 33b6cbc2a95e44a4e730c4d87e1f3b0da53984a2 Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 12 Jan 2021 10:40:10 +0000 Subject: [PATCH] DEV9: Use FriendlyName for Pcap adapters on windows --- pcsx2/DEV9/pcap_io.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pcsx2/DEV9/pcap_io.cpp b/pcsx2/DEV9/pcap_io.cpp index 8dac356952..90e3efa416 100644 --- a/pcsx2/DEV9/pcap_io.cpp +++ b/pcsx2/DEV9/pcap_io.cpp @@ -326,17 +326,25 @@ std::vector PCAPAdapter::GetAdapters() mbstowcs(wEth, d->name, sizeof(config.Eth) - 1); entry.guid = std::wstring(wEth); - //NPCAP 1.10 is using an version of pcap that dosn't - //allow us to set it to use UTF8 - //see https://github.com/nmap/npcap/issues/276 - //But use MultiByteToWideChar so we can later switch to UTF8 - int len_desc = strlen(d->description) + 1; - int len_buf = MultiByteToWideChar(CP_ACP, 0, d->description, len_desc, nullptr, 0); + IP_ADAPTER_ADDRESSES adapterInfo; - wchar_t* buf = new wchar_t[len_buf]; - MultiByteToWideChar(CP_ACP, 0, d->description, len_desc, buf, len_buf); - entry.name = std::wstring(buf); - delete[] buf; + if (GetAdapterFromPcapName(d->name, &adapterInfo)) + entry.name = std::wstring(adapterInfo.FriendlyName); + else + { + //have to use description + //NPCAP 1.10 is using an version of pcap that dosn't + //allow us to set it to use UTF8 + //see https://github.com/nmap/npcap/issues/276 + //But use MultiByteToWideChar so we can later switch to UTF8 + int len_desc = strlen(d->description) + 1; + int len_buf = MultiByteToWideChar(CP_ACP, 0, d->description, len_desc, nullptr, 0); + + wchar_t* buf = new wchar_t[len_buf]; + MultiByteToWideChar(CP_ACP, 0, d->description, len_desc, buf, len_buf); + entry.name = std::wstring(buf); + delete[] buf; + } #else entry.name = std::string(d->name); entry.guid = std::string(d->name);