1 /* 2 * PROJECT: ReactOS NetSh 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Network Shell main header file 5 * COPYRIGHT: Copyright 2023 Eric Kohl <eric.kohl@reactos.org> 6 */ 7 8 #ifndef PRECOMP_H 9 #define PRECOMP_H 10 11 /* INCLUDES ******************************************************************/ 12 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <stdarg.h> 16 17 #define WIN32_NO_STATUS 18 #include <windef.h> 19 #include <winbase.h> 20 #include <winreg.h> 21 #include <wincon.h> 22 #include <winuser.h> 23 24 #include <errno.h> 25 26 #include <conutils.h> 27 #include <netsh.h> 28 29 #include "resource.h" 30 31 32 /* DEFINES *******************************************************************/ 33 34 #define MAX_STRING_SIZE 1024 35 #define MAX_ARGS_COUNT 256 36 37 #define REG_NETSH_PATH L"Software\\Microsoft\\NetSh" 38 39 40 /* TYPEDEFS ******************************************************************/ 41 42 typedef struct _DLL_LIST_ENTRY 43 { 44 struct _DLL_LIST_ENTRY *pPrev; 45 struct _DLL_LIST_ENTRY *pNext; 46 47 PWSTR pszDllName; 48 PWSTR pszShortName; 49 PWSTR pszValueName; 50 51 HMODULE hModule; 52 53 } DLL_LIST_ENTRY, *PDLL_LIST_ENTRY; 54 55 typedef struct _HELPER_ENTRY 56 { 57 struct _HELPER_ENTRY *pPrev; 58 struct _HELPER_ENTRY *pNext; 59 60 NS_HELPER_ATTRIBUTES Attributes; 61 62 PDLL_LIST_ENTRY pDllEntry; 63 BOOL bStarted; 64 65 struct _HELPER_ENTRY *pSubHelperHead; 66 struct _HELPER_ENTRY *pSubHelperTail; 67 68 } HELPER_ENTRY, *PHELPER_ENTRY; 69 70 71 72 typedef struct _COMMAND_ENTRY 73 { 74 struct _COMMAND_ENTRY *pPrev; 75 struct _COMMAND_ENTRY *pNext; 76 77 LPCWSTR pwszCmdToken; 78 PFN_HANDLE_CMD pfnCmdHandler; 79 DWORD dwShortCmdHelpToken; 80 DWORD dwCmdHlpToken; 81 DWORD dwFlags; 82 } COMMAND_ENTRY, *PCOMMAND_ENTRY; 83 84 typedef struct _COMMAND_GROUP 85 { 86 struct _COMMAND_GROUP *pPrev; 87 struct _COMMAND_GROUP *pNext; 88 89 LPCWSTR pwszCmdGroupToken; 90 DWORD dwShortCmdHelpToken; 91 DWORD dwFlags; 92 93 PCOMMAND_ENTRY pCommandListHead; 94 PCOMMAND_ENTRY pCommandListTail; 95 } COMMAND_GROUP, *PCOMMAND_GROUP; 96 97 typedef struct _CONTEXT_ENTRY 98 { 99 struct _CONTEXT_ENTRY *pPrev; 100 struct _CONTEXT_ENTRY *pNext; 101 102 struct _CONTEXT_ENTRY *pParentContext; 103 104 PWSTR pszContextName; 105 GUID Guid; 106 HMODULE hModule; 107 108 PCOMMAND_ENTRY pCommandListHead; 109 PCOMMAND_ENTRY pCommandListTail; 110 111 PCOMMAND_GROUP pGroupListHead; 112 PCOMMAND_GROUP pGroupListTail; 113 114 struct _CONTEXT_ENTRY *pSubContextHead; 115 struct _CONTEXT_ENTRY *pSubContextTail; 116 } CONTEXT_ENTRY, *PCONTEXT_ENTRY; 117 118 119 /* GLOBAL VARIABLES ***********************************************************/ 120 121 extern PCONTEXT_ENTRY pRootContext; 122 extern PCONTEXT_ENTRY pCurrentContext; 123 124 125 /* PROTOTYPES *****************************************************************/ 126 127 /* context.c */ 128 129 BOOL 130 CreateRootContext(VOID); 131 132 133 /* help.c */ 134 DWORD 135 WINAPI 136 HelpCommand( 137 LPCWSTR pwszMachine, 138 LPWSTR *ppwcArguments, 139 DWORD dwCurrentIndex, 140 DWORD dwArgCount, 141 DWORD dwFlags, 142 LPCVOID pvData, 143 BOOL *pbDone); 144 145 VOID 146 HelpGroup( 147 PCOMMAND_GROUP pGroup); 148 149 150 /* helper.c */ 151 VOID 152 LoadHelpers(VOID); 153 154 VOID 155 UnloadHelpers(VOID); 156 157 158 DWORD 159 WINAPI 160 AddHelperCommand( 161 LPCWSTR pwszMachine, 162 LPWSTR *ppwcArguments, 163 DWORD dwCurrentIndex, 164 DWORD dwArgCount, 165 DWORD dwFlags, 166 LPCVOID pvData, 167 BOOL *pbDone); 168 169 DWORD 170 WINAPI 171 DeleteHelperCommand( 172 LPCWSTR pwszMachine, 173 LPWSTR *ppwcArguments, 174 DWORD dwCurrentIndex, 175 DWORD dwArgCount, 176 DWORD dwFlags, 177 LPCVOID pvData, 178 BOOL *pbDone); 179 180 DWORD 181 WINAPI 182 ShowHelperCommand( 183 LPCWSTR pwszMachine, 184 PWSTR *ppwcArguments, 185 DWORD dwCurrentIndex, 186 DWORD dwArgCount, 187 DWORD dwFlags, 188 LPCVOID pvData, 189 BOOL *pbDone); 190 191 192 /* interpreter.c */ 193 BOOL 194 InterpretScript( 195 LPWSTR pszFileName); 196 197 BOOL 198 InterpretCommand( 199 LPWSTR *argv, 200 DWORD dwArgCount); 201 202 VOID 203 InterpretInteractive(VOID); 204 205 #endif /* PRECOMP_H */ 206