From ac06652ab6d23761aa668dfea52ce609eaf96594 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 21 Jun 2026 00:59:22 +0200 Subject: [PATCH] [NETSH][REACTOS] Basic implementation of PreprocessCommand Preprocess is used by the 'reset' command in the 'interface ip' command. --- base/applications/network/netsh/netsh.c | 43 +++++++++++++++++++++++-- sdk/include/reactos/netsh_undoc.h | 2 +- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/base/applications/network/netsh/netsh.c b/base/applications/network/netsh/netsh.c index 029bb14531e..ad9cb5adad4 100644 --- a/base/applications/network/netsh/netsh.c +++ b/base/applications/network/netsh/netsh.c @@ -377,7 +377,7 @@ MatchTagsInCmdLine( _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, - _In_ TAG_TYPE *pttTags, + _Inout_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _Out_ DWORD *pdwTagType) { @@ -546,13 +546,50 @@ PreprocessCommand( _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, - _In_ TAG_TYPE *pttTags, + _Inout_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _In_ DWORD dwMinArgs, _In_ DWORD dwMaxArgs, _Out_ DWORD *pdwTagType) { - DPRINT1("PreprocessCommand()\n"); + DWORD i; + DWORD dwError = ERROR_SUCCESS; + + DPRINT("PreprocessCommand()\n"); + + if ((ppwcArguments == NULL) || (pttTags == NULL) || (pdwTagType == NULL)) + return ERROR_INVALID_PARAMETER; + + if (((dwArgCount - dwCurrentIndex) < dwMinArgs) || ((dwArgCount - dwCurrentIndex) > dwMaxArgs)) + return ERROR_INVALID_SYNTAX; + + for (i = 0; i < dwTagCount; i++) + { + pttTags[i].bPresent = FALSE; + } + + if ((dwArgCount - dwCurrentIndex) > 0) + { + dwError = MatchTagsInCmdLine(hModule, + ppwcArguments, + dwCurrentIndex, + dwArgCount, + pttTags, + dwTagCount, + pdwTagType); + if (dwError != ERROR_SUCCESS) + { + return dwError; + } + } + + /* Fail, if a required tag is missing */ + for (i = 0; i < dwTagCount; i++) + { + if ((pttTags[i].dwRequired & NS_REQ_PRESENT) && (pttTags[i].bPresent == FALSE)) + return ERROR_INVALID_SYNTAX; + } + return 0; } diff --git a/sdk/include/reactos/netsh_undoc.h b/sdk/include/reactos/netsh_undoc.h index 05b5105e822..76fd2a34e06 100644 --- a/sdk/include/reactos/netsh_undoc.h +++ b/sdk/include/reactos/netsh_undoc.h @@ -30,7 +30,7 @@ MatchTagsInCmdLine( _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, - _In_ TAG_TYPE *pttTags, + _Inout_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _Out_ DWORD *pdwTagType);