Skip to content

Commit 0793006

Browse files
committed
[IFMON] Add first netsh helper dll
Run 'add helper ifmon.dll' in netsh to load the ifmon helper.
1 parent df01941 commit 0793006

File tree

12 files changed

+638
-0
lines changed

12 files changed

+638
-0
lines changed

dll/win32/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ add_subdirectory(iccvid)
5757
add_subdirectory(icmp)
5858
add_subdirectory(ieframe)
5959
add_subdirectory(iernonce)
60+
add_subdirectory(ifmon)
6061
add_subdirectory(imaadp32.acm)
6162
add_subdirectory(imagehlp)
6263
add_subdirectory(inetcomm)

dll/win32/ifmon/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
spec2def(ifmon.dll ifmon.spec)
3+
4+
list(APPEND SOURCE
5+
guid.c
6+
ifmon.c
7+
ifmon.rc
8+
interface.c
9+
ip.c
10+
${CMAKE_CURRENT_BINARY_DIR}/ifmon.def)
11+
12+
add_library(ifmon MODULE ${SOURCE})
13+
set_module_type(ifmon win32dll UNICODE)
14+
add_importlibs(ifmon netsh iphlpapi msvcrt kernel32 ntdll)
15+
add_cd_file(TARGET ifmon DESTINATION reactos/system32 FOR all)

dll/win32/ifmon/guid.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#define INITGUID
3+
#include <guiddef.h>
4+
5+
#include "guid.h"
6+

dll/win32/ifmon/guid.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
DEFINE_GUID(GUID_IFMON_INTERFACE, 0x0705eca1, 0x7aac, 0x11d2, 0x89, 0xdc, 0x00, 0x60, 0x08, 0xb0, 0xe5, 0xb9);
3+
//DEFINE_GUID(GUID_IFMON_INTERFACE, 0x0705ECB2, 0x7AAC, 0x11D2, 0x89, 0xDC, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xB9);
4+
DEFINE_GUID(GUID_IFMON_IP, 0x725588AC, 0x7A11, 0x4220, 0xA1, 0x21, 0xC9, 0x2C, 0x91, 0x5E, 0x8B, 0x73);
5+

dll/win32/ifmon/ifmon.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* PROJECT: ReactOS IF Monitor DLL
3+
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4+
* PURPOSE: NetSh Helper main functions
5+
* COPYRIGHT: Copyright 2025 Eric Kohl <[email protected]>
6+
*/
7+
8+
#include "precomp.h"
9+
10+
#define NDEBUG
11+
#include <debug.h>
12+
13+
#include "guid.h"
14+
#include "resource.h"
15+
16+
HINSTANCE hDllInstance;
17+
18+
DWORD
19+
WINAPI
20+
InitHelperDll(
21+
_In_ DWORD dwNetshVersion,
22+
_Out_ PVOID pReserved)
23+
{
24+
DWORD dwError;
25+
26+
dwError = RegisterInterfaceHelper();
27+
if (dwError == ERROR_SUCCESS)
28+
dwError = RegisterIpHelper();
29+
30+
return dwError;
31+
}
32+
33+
34+
BOOL WINAPI
35+
DllMain(
36+
_In_ HINSTANCE hinstDLL,
37+
_In_ DWORD dwReason,
38+
_In_ LPVOID lpvReserved)
39+
{
40+
switch (dwReason)
41+
{
42+
case DLL_PROCESS_ATTACH:
43+
hDllInstance = hinstDLL;
44+
DisableThreadLibraryCalls(hinstDLL);
45+
break;
46+
}
47+
48+
return TRUE;
49+
}

dll/win32/ifmon/ifmon.rc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <windef.h>
2+
#include <winuser.h>
3+
4+
#include "resource.h"
5+
6+
#define REACTOS_VERSION_DLL
7+
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS IF Monitor DLL"
8+
#define REACTOS_STR_INTERNAL_NAME "ifmon"
9+
#define REACTOS_STR_ORIGINAL_FILENAME "ifmon.dll"
10+
#include <reactos/version.rc>
11+
12+
#include <reactos/manifest_dll.rc>
13+
14+
/* UTF-8 */
15+
#pragma code_page(65001)
16+
17+
#ifdef LANGUAGE_EN_US
18+
#include "lang/en-US.rc"
19+
#endif

dll/win32/ifmon/ifmon.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@ stdcall InitHelperDll(long ptr)

dll/win32/ifmon/interface.c

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* PROJECT: ReactOS IF Monitor DLL
3+
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4+
* PURPOSE: NetSh Helper interface context functions
5+
* COPYRIGHT: Copyright 2025 Eric Kohl <[email protected]>
6+
*/
7+
8+
#include "precomp.h"
9+
10+
#include <guiddef.h>
11+
12+
#define NDEBUG
13+
#include <debug.h>
14+
15+
#include "guid.h"
16+
#include "resource.h"
17+
18+
static
19+
DWORD
20+
WINAPI
21+
InterfaceShowInterface(
22+
LPCWSTR pwszMachine,
23+
LPWSTR *argv,
24+
DWORD dwCurrentIndex,
25+
DWORD dwArgCount,
26+
DWORD dwFlags,
27+
LPCVOID pvData,
28+
BOOL *pbDone);
29+
30+
static
31+
CMD_ENTRY
32+
InterfaceShowCommands[] =
33+
{
34+
{L"interface", InterfaceShowInterface, IDS_HLP_INTERFACE_SHOW_INTERFACE, IDS_HLP_INTERFACE_SHOW_INTERFACE_EX, 0}
35+
};
36+
37+
static
38+
CMD_GROUP_ENTRY
39+
InterfaceGroups[] =
40+
{
41+
{L"show", IDS_HLP_INTERFACE_SHOW, sizeof(InterfaceShowCommands) / sizeof(CMD_ENTRY), 0, InterfaceShowCommands, NULL},
42+
};
43+
44+
45+
static
46+
DWORD
47+
WINAPI
48+
InterfaceShowInterface(
49+
LPCWSTR pwszMachine,
50+
LPWSTR *argv,
51+
DWORD dwCurrentIndex,
52+
DWORD dwArgCount,
53+
DWORD dwFlags,
54+
LPCVOID pvData,
55+
BOOL *pbDone)
56+
{
57+
PrintMessage(L"InterfaceShowInterface(): Not implemented yet!\n");
58+
59+
return ERROR_SUCCESS;
60+
}
61+
62+
63+
DWORD
64+
WINAPI
65+
InterfaceStart(
66+
_In_ const GUID *pguidParent,
67+
_In_ DWORD dwVersion)
68+
{
69+
NS_CONTEXT_ATTRIBUTES ContextAttributes;
70+
71+
DPRINT1("InterfaceStart()\n");
72+
73+
ZeroMemory(&ContextAttributes, sizeof(ContextAttributes));
74+
ContextAttributes.dwVersion = 1;
75+
ContextAttributes.pwszContext = L"interface";
76+
ContextAttributes.guidHelper = GUID_IFMON_INTERFACE;
77+
78+
ContextAttributes.ulNumTopCmds = 0;
79+
ContextAttributes.pTopCmds = NULL;
80+
81+
ContextAttributes.ulNumGroups = sizeof(InterfaceGroups) / sizeof(CMD_GROUP_ENTRY);
82+
ContextAttributes.pCmdGroups = InterfaceGroups;
83+
84+
RegisterContext(&ContextAttributes);
85+
86+
return ERROR_SUCCESS;
87+
}
88+
89+
90+
DWORD
91+
WINAPI
92+
RegisterInterfaceHelper(VOID)
93+
{
94+
NS_HELPER_ATTRIBUTES HelperAttributes;
95+
96+
DPRINT1("RegisterInterfaceHelper()\n");
97+
98+
ZeroMemory(&HelperAttributes, sizeof(HelperAttributes));
99+
HelperAttributes.dwVersion = 1;
100+
HelperAttributes.guidHelper = GUID_IFMON_INTERFACE;
101+
HelperAttributes.pfnStart = InterfaceStart;
102+
HelperAttributes.pfnStop = NULL;
103+
RegisterHelper(NULL, &HelperAttributes);
104+
105+
return ERROR_SUCCESS;
106+
}

0 commit comments

Comments
 (0)