From ddde8c5f93f1fd0344bff252244438763f423241 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 6 Jun 2026 23:29:28 +0200 Subject: [PATCH] [NETSH] Implement NsGetIfNameFromFriendlyName This is used the 'interface ip set address' command from the WinXP ifmon.dll. --- base/applications/network/netsh/netsh.c | 38 +++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/base/applications/network/netsh/netsh.c b/base/applications/network/netsh/netsh.c index 181132e97a1..7aa567ed431 100644 --- a/base/applications/network/netsh/netsh.c +++ b/base/applications/network/netsh/netsh.c @@ -502,9 +502,41 @@ NsGetIfNameFromFriendlyName( _Inout_ PWSTR pszIfName, _Inout_ PDWORD pdwIfName) { - DPRINT1("NsGetIfNameFromFriendlyName(%lx %S %p %p)\n", - dwUnknown1, pszFriendlyName, pszIfName, pdwIfName); - return 0; + UNICODE_STRING UnicodeIfName; + GUID InterfaceGuid; + NTSTATUS Status; + DWORD ret; + + DPRINT("NsGetIfNameFromFriendlyName(%lx %S %p %p)\n", + dwUnknown1, pszFriendlyName, pszIfName, pdwIfName); + + ret = NhGetGuidFromInterfaceName(pszFriendlyName, + &InterfaceGuid, + 0, 0); + if (ret != ERROR_SUCCESS) + { + DPRINT1("NhGetGuidFromInterfaceName failed %lu\n", ret); + return ret; + } + + RtlInitUnicodeString(&UnicodeIfName, NULL); + Status = RtlStringFromGUID(&InterfaceGuid, + &UnicodeIfName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlStringFromGUID failed 0x%08lx\n", Status); + ret = RtlNtStatusToDosError(Status); + } + + if (*pdwIfName >= UnicodeIfName.MaximumLength) + { + CopyMemory(pszIfName, UnicodeIfName.Buffer, UnicodeIfName.MaximumLength); + *pdwIfName = UnicodeIfName.MaximumLength; + } + + RtlFreeUnicodeString(&UnicodeIfName); + + return ret; } DWORD