Skip to content

Commit 38afa1a

Browse files
committed
[NETSH][REACTOS] Implement and export NsGetFriendlyNameFromIfName
Running the 'interface ip show address' command on XPs ifmon.dll now fails in netcfgx.dll.
1 parent ac4d735 commit 38afa1a

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

base/applications/network/netsh/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set_target_properties(netsh
2020

2121
set_module_type(netsh win32cui UNICODE)
2222
target_link_libraries(netsh conutils ${PSEH_LIB})
23-
add_importlibs(netsh advapi32 msvcrt user32 kernel32 ntdll)
23+
add_importlibs(netsh iphlpapi advapi32 msvcrt user32 kernel32 ntdll)
2424

2525
add_pch(netsh precomp.h SOURCE)
2626
add_cd_file(TARGET netsh DESTINATION reactos/system32 FOR all)

base/applications/network/netsh/netsh.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,43 @@ MatchToken(
237237
return (_wcsnicmp(pwszUserToken, pwszCmdToken, wcslen(pwszUserToken)) == 0) ? TRUE : FALSE;
238238
}
239239

240+
DWORD
241+
WINAPI
242+
NsGetFriendlyNameFromIfName(
243+
_In_ DWORD dwUnknown1,
244+
_In_ PWSTR pszIfName,
245+
_Inout_ PWSTR pszFriendlyName,
246+
_Inout_ PDWORD pdwFriendlyName)
247+
{
248+
UNICODE_STRING UnicodeIfName;
249+
GUID InterfaceGuid;
250+
NTSTATUS Status;
251+
DWORD ret;
252+
253+
DPRINT("NsGetFriendlyNameFromIfName(%lx %S %p %p)\n",
254+
dwUnknown1, pszIfName, pszFriendlyName, pdwFriendlyName);
255+
256+
RtlInitUnicodeString(&UnicodeIfName, pszIfName);
257+
Status = RtlGUIDFromString(&UnicodeIfName,
258+
&InterfaceGuid);
259+
if (!NT_SUCCESS(Status))
260+
{
261+
DPRINT1("RtlGUIDFromString failed 0x%08lx\n", Status);
262+
return RtlNtStatusToDosError(Status);
263+
}
264+
265+
ret = NhGetInterfaceNameFromDeviceGuid(&InterfaceGuid,
266+
pszFriendlyName,
267+
pdwFriendlyName,
268+
0, 0);
269+
if (ret != ERROR_SUCCESS)
270+
{
271+
DPRINT1("NhGetInterfaceNameFromDeviceGuid() failed %lu\n", ret);
272+
}
273+
274+
return ret;
275+
}
276+
240277
DWORD
241278
WINAPI
242279
PreprocessCommand(

base/applications/network/netsh/netsh.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@ stdcall MatchEnumTag(ptr wstr long ptr ptr)
1515
@ stub MatchTagsInCmdLine
1616
@ stdcall MatchToken(wstr wstr)
17-
@ stub NsGetFriendlyNameFromIfName
17+
@ stdcall NsGetFriendlyNameFromIfName(long wstr ptr ptr)
1818
@ stub NsGetIfNameFromFriendlyName
1919
@ stdcall PreprocessCommand(ptr ptr long long ptr long long long ptr)
2020
@ varargs PrintError(ptr long)

base/applications/network/netsh/precomp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@
1414
#include <stdlib.h>
1515
#include <stdarg.h>
1616

17+
#include <ndk/rtlfuncs.h>
18+
1719
#define WIN32_NO_STATUS
1820
#include <windef.h>
1921
#include <winbase.h>
2022
#include <winreg.h>
2123
#include <wincon.h>
2224
#include <winuser.h>
25+
#include <iphlpapi_undoc.h>
2326

2427
#include <errno.h>
2528

2629
#include <conutils.h>
2730
#include <netsh.h>
31+
#include <netsh_undoc.h>
2832

2933
#include "resource.h"
3034

sdk/include/reactos/netsh_undoc.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef __NETSH_UNDOC_H__
2+
#define __NETSH_UNDOC_H__
3+
4+
DWORD
5+
WINAPI
6+
NsGetFriendlyNameFromIfName(
7+
_In_ DWORD dwParam1,
8+
_In_ PWSTR pszIfName,
9+
_Inout_ PWSTR pszFriendlyName,
10+
_Inout_ PDWORD pdwFriendlyName);
11+
12+
#endif /* __NETSH_UNDOC_H__ */

0 commit comments

Comments
 (0)