Skip to content

Commit

Permalink
[IPCONFIG] Improve adapter type and name output
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKohl committed Jun 25, 2023
1 parent cb98e91 commit 50d78f0
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 229 deletions.
81 changes: 23 additions & 58 deletions base/applications/network/ipconfig/ipconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ VOID DoFormatMessage(LONG ErrorCode)
}

VOID
PrintAdapterFriendlyName(LPSTR lpClass)
GetAdapterFriendlyName(
_In_ LPSTR lpClass,
_In_ DWORD cchFriendlyNameLength,
_Out_ PWSTR pszFriendlyName)
{
HKEY hKey = NULL;
LPSTR ConType = NULL;
LPSTR ConTypeTmp = NULL;
CHAR Path[256];
LPSTR PrePath = "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\";
LPSTR PostPath = "\\Connection";
Expand All @@ -247,47 +248,13 @@ PrintAdapterFriendlyName(LPSTR lpClass)
KEY_READ,
&hKey) == ERROR_SUCCESS)
{
if (RegQueryValueExA(hKey,
"Name",
NULL,
&dwType,
NULL,
&dwDataSize) == ERROR_SUCCESS)
{
ConTypeTmp = (LPSTR)HeapAlloc(ProcessHeap,
0,
dwDataSize);
if (ConTypeTmp == NULL)
return;

ConType = (LPSTR)HeapAlloc(ProcessHeap,
0,
dwDataSize);
if (ConType == NULL)
{
HeapFree(ProcessHeap, 0, ConTypeTmp);
return;
}

if (RegQueryValueExA(hKey,
"Name",
NULL,
&dwType,
(PBYTE)ConTypeTmp,
&dwDataSize) != ERROR_SUCCESS)
{
HeapFree(ProcessHeap, 0, ConType);
ConType = NULL;
}

if (ConType)
CharToOemA(ConTypeTmp, ConType);

printf("%s\n", ConType);

HeapFree(ProcessHeap, 0, ConTypeTmp);
HeapFree(ProcessHeap, 0, ConType);
}
dwDataSize = cchFriendlyNameLength * sizeof(WCHAR);
RegQueryValueExW(hKey,
L"Name",
NULL,
&dwType,
(PBYTE)pszFriendlyName,
&dwDataSize);
}

if (hKey != NULL)
Expand Down Expand Up @@ -477,50 +444,48 @@ VOID
PrintAdapterTypeAndName(
PIP_ADAPTER_INFO pAdapterInfo)
{
printf("\n");
WCHAR szFriendlyName[MAX_PATH];

GetAdapterFriendlyName(pAdapterInfo->AdapterName, MAX_PATH, szFriendlyName);

switch (pAdapterInfo->Type)
{
case MIB_IF_TYPE_OTHER:
ConResPrintf(StdOut, IDS_OTHER);
ConResPrintf(StdOut, IDS_OTHER, szFriendlyName);
break;

case MIB_IF_TYPE_ETHERNET:
ConResPrintf(StdOut, IDS_ETH);
ConResPrintf(StdOut, IDS_ETH, szFriendlyName);
break;

case MIB_IF_TYPE_TOKENRING:
ConResPrintf(StdOut, IDS_TOKEN);
ConResPrintf(StdOut, IDS_TOKEN, szFriendlyName);
break;

case MIB_IF_TYPE_FDDI:
ConResPrintf(StdOut, IDS_FDDI);
ConResPrintf(StdOut, IDS_FDDI, szFriendlyName);
break;

case MIB_IF_TYPE_PPP:
ConResPrintf(StdOut, IDS_PPP);
ConResPrintf(StdOut, IDS_PPP, szFriendlyName);
break;

case MIB_IF_TYPE_LOOPBACK:
ConResPrintf(StdOut, IDS_LOOP);
ConResPrintf(StdOut, IDS_LOOP, szFriendlyName);
break;

case MIB_IF_TYPE_SLIP:
ConResPrintf(StdOut, IDS_SLIP);
ConResPrintf(StdOut, IDS_SLIP, szFriendlyName);
break;

case IF_TYPE_IEEE80211:
ConResPrintf(StdOut, IDS_WIFI);
ConResPrintf(StdOut, IDS_WIFI, szFriendlyName);
break;

default:
ConResPrintf(StdOut, IDS_UNKNOWNADAPTER);
ConResPrintf(StdOut, IDS_UNKNOWNADAPTER, szFriendlyName);
break;
}

printf(": ");
PrintAdapterFriendlyName(pAdapterInfo->AdapterName);
printf("\n");
}

VOID ShowInfo(BOOL bAll)
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/bg-BG.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Друг вид карта"
IDS_ETH "Карта Ethernet"
IDS_TOKEN "Карта Token Ring"
IDS_FDDI "Карта FDDI"
IDS_PPP "Карта PPP"
IDS_LOOP "Карта Loopback"
IDS_SLIP "Карта SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nДруг вид карта: %ls\n"
IDS_ETH "\nКарта Ethernet: %ls\n"
IDS_TOKEN "\nКарта Token Ring: %ls\n"
IDS_FDDI "\nКарта FDDI: %ls\n"
IDS_PPP "\nКарта PPP: %ls\n"
IDS_LOOP "\nКарта Loopback: %ls\n"
IDS_SLIP "\nКарта SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/de-DE.rc
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unbekannter Adapter"
IDS_OTHER "Anderer Adapter"
IDS_ETH "Ethernet-Adapter"
IDS_TOKEN "Token-Ring-Adapter"
IDS_FDDI "FDDI-Adapter"
IDS_PPP "PPP-Adapter"
IDS_LOOP "Loopback-Adapter"
IDS_SLIP "SLIP-Adapter"
IDS_WIFI "Drahtlos-LAN-Adapter"
IDS_UNKNOWNADAPTER "\nUnbekannter Adapter: %ls\n"
IDS_OTHER "\nAnderer Adapter: %ls\n"
IDS_ETH "\nEthernet-Adapter: %ls\n"
IDS_TOKEN "\nToken-Ring-Adapter: %ls\n"
IDS_FDDI "\nFDDI-Adapter: %ls\n"
IDS_PPP "\nPPP-Adapter: %ls\n"
IDS_LOOP "\nLoopback-Adapter: %ls\n"
IDS_SLIP "\nSLIP-Adapter: %ls\n"
IDS_WIFI "\nDrahtlos-LAN-Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/el-GR.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Άλλος τύπος προσαρμογέα"
IDS_ETH "Προσαρμογέας Ethernet"
IDS_TOKEN "Προσαρμογέας Token Ring"
IDS_FDDI "Προσαρμογέας FDDI"
IDS_PPP "Προσαρμογέας PPP"
IDS_LOOP "Προσαρμογέας Loopback"
IDS_SLIP "Προσαρμογέας SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nΆλλος τύπος προσαρμογέα: %ls\n"
IDS_ETH "\nΠροσαρμογέας Ethernet: %ls\n"
IDS_TOKEN "\nΠροσαρμογέας Token Ring: %ls\n"
IDS_FDDI "\nΠροσαρμογέας FDDI: %ls\n"
IDS_PPP "\nΠροσαρμογέας PPP: %ls\n"
IDS_LOOP "\nΠροσαρμογέας Loopback: %ls\n"
IDS_SLIP "\nΠροσαρμογέας SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/en-US.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Other Type Of Adapter"
IDS_ETH "Ethernet Adapter"
IDS_TOKEN "Token Ring Adapter"
IDS_FDDI "FDDI Adapter"
IDS_PPP "PPP Adapter"
IDS_LOOP "Loopback Adapter"
IDS_SLIP "SLIP Adapter"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nOther Type Of Adapter: %ls\n"
IDS_ETH "\nEthernet Adapter: %ls\n"
IDS_TOKEN "\nToken Ring Adapter: %ls\n"
IDS_FDDI "\nFDDI Adapter: %ls\n"
IDS_PPP "\nPPP Adapter: %ls\n"
IDS_LOOP "\nLoopback Adapter: %ls\n"
IDS_SLIP "\nSLIP Adapter: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/es-ES.rc
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Otro tipo de adaptador"
IDS_ETH "Adaptador Ethernet"
IDS_TOKEN "Adaptador de red en anillo"
IDS_FDDI "Adaptador FDDI"
IDS_PPP "Adaptador PPP"
IDS_LOOP "Adaptador de bucle invertido"
IDS_SLIP "Adaptador SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nOtro tipo de adaptador: %ls\n"
IDS_ETH "\nAdaptador Ethernet: %ls\n"
IDS_TOKEN "\nAdaptador de red en anillo: %ls\n"
IDS_FDDI "\nAdaptador FDDI: %ls\n"
IDS_PPP "\nAdaptador PPP: %ls\n"
IDS_LOOP "\nAdaptador de bucle invertido: %ls\n"
IDS_SLIP "\nAdaptador SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/fr-FR.rc
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Autre Type d'adapteur"
IDS_ETH "Adapteur Ethernet"
IDS_TOKEN "Adapteur Token Ring"
IDS_FDDI "Adapteur FDDI"
IDS_PPP "Adapteur PPP"
IDS_LOOP "Adapteur Loopback"
IDS_SLIP "Adapteur SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nAutre Type d'adapteur: %ls\n"
IDS_ETH "\nAdapteur Ethernet: %ls\n"
IDS_TOKEN "\nAdapteur Token Ring: %ls\n"
IDS_FDDI "\nAdapteur FDDI: %ls\n"
IDS_PPP "\nAdapteur PPP: %ls\n"
IDS_LOOP "\nAdapteur Loopback: %ls\n"
IDS_SLIP "\nAdapteur SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/id-ID.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Adapter Tipe Lainnya"
IDS_ETH "Adapter Ethernet"
IDS_TOKEN "Adapter Token Ring"
IDS_FDDI "Adapter FDDI"
IDS_PPP "Adapter PPP"
IDS_LOOP "Adapter Loopback"
IDS_SLIP "Adapter SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nAdapter Tipe Lainnya: %ls\n"
IDS_ETH "\nAdapter Ethernet: %ls\n"
IDS_TOKEN "\nAdapter Token Ring: %ls\n"
IDS_FDDI "\nAdapter FDDI: %ls\n"
IDS_PPP "\nAdapter PPP: %ls\n"
IDS_LOOP "\nAdapter Loopback: %ls\n"
IDS_SLIP "\nAdapter SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/it-IT.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Altro tipo di adattatore"
IDS_ETH "Adattatore Ethernet"
IDS_TOKEN "Adattatore Token Ring"
IDS_FDDI "Adattatore FDDI"
IDS_PPP "Adattatore PPP"
IDS_LOOP "Adattatore Loopback"
IDS_SLIP "Adattatore SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nAltro tipo di adattatore: %ls\n"
IDS_ETH "\nAdattatore Ethernet: %ls\n"
IDS_TOKEN "\nAdattatore Token Ring: %ls\n"
IDS_FDDI "\nAdattatore FDDI: %ls\n"
IDS_PPP "\nAdattatore PPP: %ls\n"
IDS_LOOP "\nAdattatore Loopback: %ls\n"
IDS_SLIP "\nAdattatore SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/no-NO.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "Other Type Of Adapter"
IDS_ETH "Ethernet Adapter"
IDS_TOKEN "Token Ring Adapter"
IDS_FDDI "FDDI Adapter"
IDS_PPP "PPP Adapter"
IDS_LOOP "Loopback Adapter"
IDS_SLIP "SLIP Adapter"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\nOther Type Of Adapter: %ls\n"
IDS_ETH "\nEthernet Adapter: %ls\n"
IDS_TOKEN "\nToken Ring Adapter: %ls\n"
IDS_FDDI "\nFDDI Adapter: %ls\n"
IDS_PPP "\nPPP Adapter: %ls\n"
IDS_LOOP "\nLoopback Adapter: %ls\n"
IDS_SLIP "\nSLIP Adapter: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
18 changes: 9 additions & 9 deletions base/applications/network/ipconfig/lang/pl-PL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ END

STRINGTABLE
BEGIN
IDS_UNKNOWNADAPTER "Unknown Adapter"
IDS_OTHER "inny rodzaj karty"
IDS_ETH "karta Ethernet"
IDS_TOKEN "karta Token Ring"
IDS_FDDI "karta FDDI"
IDS_PPP "karta PPP"
IDS_LOOP "karta Loopback"
IDS_SLIP "karta SLIP"
IDS_WIFI "Wireless Network Adapter"
IDS_UNKNOWNADAPTER "\nUnknown Adapter: %ls\n"
IDS_OTHER "\ninny rodzaj karty: %ls\n"
IDS_ETH "\nkarta Ethernet: %ls\n"
IDS_TOKEN "\nkarta Token Ring: %ls\n"
IDS_FDDI "\nkarta FDDI: %ls\n"
IDS_PPP "\nkarta PPP: %ls\n"
IDS_LOOP "\nkarta Loopback: %ls\n"
IDS_SLIP "\nkarta SLIP: %ls\n"
IDS_WIFI "\nWireless Network Adapter: %ls\n"
END

STRINGTABLE
Expand Down
Loading

0 comments on commit 50d78f0

Please sign in to comment.