ReactOS 0.4.16-dev-1946-g52006dd
netsh.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for netsh.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD RunScript (_In_ LPCWSTR filename)
 
LPWSTR MergeStrings (_In_ LPWSTR pszStringArray[], _In_ INT nCount)
 
int wmain (_In_ int argc, _In_ const LPWSTR argv[])
 
VOID WINAPI FreeQuotedString (_In_ LPWSTR pszQuotedString)
 
VOID WINAPI FreeString (_In_ LPWSTR pszString)
 
LPWSTR WINAPI MakeQuotedString (_In_ LPWSTR pszString)
 
LPWSTR CDECL MakeString (_In_ HANDLE hModule, _In_ DWORD dwMsgId,...)
 
DWORD WINAPI MatchEnumTag (_In_ HANDLE hModule, _In_ LPCWSTR pwcArg, _In_ DWORD dwNumArg, _In_ const TOKEN_VALUE *pEnumTable, _Out_ PDWORD pdwValue)
 
BOOL WINAPI MatchToken (_In_ LPCWSTR pwszUserToken, _In_ LPCWSTR pwszCmdToken)
 
DWORD WINAPI NsGetFriendlyNameFromIfName (_In_ DWORD dwUnknown1, _In_ PWSTR pszIfName, _Inout_ PWSTR pszFriendlyName, _Inout_ PDWORD pdwFriendlyName)
 
DWORD WINAPI PreprocessCommand (_In_ HANDLE hModule, _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _In_ DWORD dwMinArgs, _In_ DWORD dwMaxArgs, _Out_ DWORD *pdwTagType)
 
DWORD CDECL PrintError (_In_opt_ HANDLE hModule, _In_ DWORD dwErrId,...)
 
DWORD CDECL PrintMessageFromModule (_In_ HANDLE hModule, _In_ DWORD dwMsgId,...)
 
DWORD CDECL PrintMessage (_In_ LPCWSTR pwszFormat,...)
 

Variables

HMODULE hModule = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file netsh.c.

Function Documentation

◆ FreeQuotedString()

VOID WINAPI FreeQuotedString ( _In_ LPWSTR  pszQuotedString)

Definition at line 269 of file netsh.c.

271{
272 DPRINT("FreeQuotedString(%S)\n", pszQuotedString);
273 HeapFree(GetProcessHeap(), 0, pszQuotedString);
274}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define DPRINT
Definition: sndvol32.h:73

◆ FreeString()

VOID WINAPI FreeString ( _In_ LPWSTR  pszString)

Definition at line 278 of file netsh.c.

280{
281 DPRINT("FreeString(%S)\n", pszString);
282 LocalFree(pszString);
283}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594

Referenced by CreateProcessInternalW(), IKsFilterFactory_fnInitialize(), and LoadLibraryExW().

◆ MakeQuotedString()

LPWSTR WINAPI MakeQuotedString ( _In_ LPWSTR  pszString)

Definition at line 287 of file netsh.c.

289{
290 LPWSTR pszQuotedString;
291
292 DPRINT("MakeQuotedString(%S)\n", pszString);
293
294 pszQuotedString = HeapAlloc(GetProcessHeap(), 0, (wcslen(pszString) + 3) * sizeof(WCHAR));
295 if (pszQuotedString == NULL)
296 return NULL;
297
298 swprintf(pszQuotedString, L"\"%s\"", pszString);
299
300 return pszQuotedString;
301}
#define NULL
Definition: types.h:112
#define HeapAlloc
Definition: compat.h:733
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ MakeString()

LPWSTR CDECL MakeString ( _In_ HANDLE  hModule,
_In_ DWORD  dwMsgId,
  ... 
)

Definition at line 305 of file netsh.c.

309{
310 LPWSTR pszInBuffer, pszOutBuffer = NULL;
312 va_list ap;
313
314 DPRINT("MakeString(%p %lu ...)\n", hModule, dwMsgId);
315
316 va_start(ap, dwMsgId);
317
318 pszInBuffer = HeapAlloc(GetProcessHeap(), 0, HUGE_BUFFER_SIZE * sizeof(WCHAR));
319 if (pszInBuffer == NULL)
320 return NULL;
321
322 dwLength = LoadStringW(hModule, dwMsgId, pszInBuffer, HUGE_BUFFER_SIZE);
323 if (dwLength > 0)
324 goto done;
325
327 pszInBuffer,
328 0,
329 0,
330 (LPWSTR)&pszOutBuffer,
331 0,
332 &ap);
333
334done:
335 if (pszInBuffer)
336 HeapFree(GetProcessHeap(), 0, pszInBuffer);
337
338 return pszOutBuffer;
339}
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define HUGE_BUFFER_SIZE
Definition: precomp.h:38
static DWORD DWORD * dwLength
Definition: fusion.c:86
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE hModule
Definition: netsh.c:17
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ MatchEnumTag()

DWORD WINAPI MatchEnumTag ( _In_ HANDLE  hModule,
_In_ LPCWSTR  pwcArg,
_In_ DWORD  dwNumArg,
_In_ const TOKEN_VALUE pEnumTable,
_Out_ PDWORD  pdwValue 
)

Definition at line 343 of file netsh.c.

349{
350 DWORD i;
351
352 DPRINT("MatchEnumTag(%p %p %lu %p %p)\n", hModule, pwcArg, dwNumArg, pEnumTable, pdwValue);
353
354 if ((pEnumTable == NULL) || (pdwValue == NULL))
356
357 for (i = 0; i < dwNumArg; i++)
358 {
359 if (MatchToken(pwcArg, pEnumTable[i].pwszToken))
360 {
361 *pdwValue = pEnumTable[i].dwValue;
362 return ERROR_SUCCESS;
363 }
364 }
365
366 return ERROR_NOT_FOUND;
367}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI MatchToken(_In_ LPCWSTR pwszUserToken, _In_ LPCWSTR pwszCmdToken)
Definition: netsh.c:371
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

◆ MatchToken()

BOOL WINAPI MatchToken ( _In_ LPCWSTR  pwszUserToken,
_In_ LPCWSTR  pwszCmdToken 
)

Definition at line 371 of file netsh.c.

374{
375 DPRINT("MatchToken(%S %S)\n", pwszUserToken, pwszCmdToken);
376
377 if ((pwszUserToken == NULL) || (pwszCmdToken == NULL))
378 return FALSE;
379
380 return (_wcsnicmp(pwszUserToken, pwszCmdToken, wcslen(pwszUserToken)) == 0) ? TRUE : FALSE;
381}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)

Referenced by GetContextCommand(), GetContextGroup(), GetContextSubContext(), GetGroupCommand(), IpShowAdapters(), and MatchEnumTag().

◆ MergeStrings()

LPWSTR MergeStrings ( _In_ LPWSTR  pszStringArray[],
_In_ INT  nCount 
)

Definition at line 53 of file netsh.c.

56{
57 LPWSTR pszOutString = NULL;
58 INT i, nLength;
59
60 if ((pszStringArray == NULL) || (nCount == 0))
61 return NULL;
62
63 nLength = 0;
64 for (i = 0; i < nCount; i++)
65 nLength += wcslen(pszStringArray[i]);
66
67 if (nLength > 0)
68 nLength += nCount; /* Space characters and terminating zero */
69
70 pszOutString = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR));
71 if (pszOutString == NULL)
72 return NULL;
73
74 for (i = 0; i < nCount; i++)
75 {
76 if (i != 0)
77 wcscat(pszOutString, L" ");
78 wcscat(pszOutString, pszStringArray[i]);
79 }
80
81 return pszOutString;
82}
wcscat
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
int32_t INT
Definition: typedefs.h:58
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682

Referenced by AliasCommand(), InterpretInteractive(), and wmain().

◆ NsGetFriendlyNameFromIfName()

DWORD WINAPI NsGetFriendlyNameFromIfName ( _In_ DWORD  dwUnknown1,
_In_ PWSTR  pszIfName,
_Inout_ PWSTR  pszFriendlyName,
_Inout_ PDWORD  pdwFriendlyName 
)

Definition at line 385 of file netsh.c.

390{
391 UNICODE_STRING UnicodeIfName;
394 DWORD ret;
395
396 DPRINT("NsGetFriendlyNameFromIfName(%lx %S %p %p)\n",
397 dwUnknown1, pszIfName, pszFriendlyName, pdwFriendlyName);
398
399 RtlInitUnicodeString(&UnicodeIfName, pszIfName);
400 Status = RtlGUIDFromString(&UnicodeIfName,
402 if (!NT_SUCCESS(Status))
403 {
404 DPRINT1("RtlGUIDFromString failed 0x%08lx\n", Status);
406 }
407
409 pszFriendlyName,
410 pdwFriendlyName,
411 0, 0);
412 if (ret != ERROR_SUCCESS)
413 {
414 DPRINT1("NhGetInterfaceNameFromDeviceGuid() failed %lu\n", ret);
415 }
416
417 return ret;
418}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
return ret
Definition: mutex.c:146
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
DWORD WINAPI NhGetInterfaceNameFromDeviceGuid(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static const GUID InterfaceGuid
Definition: wlanapi.c:25

◆ PreprocessCommand()

DWORD WINAPI PreprocessCommand ( _In_ HANDLE  hModule,
_Inout_ LPWSTR ppwcArguments,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ TAG_TYPE pttTags,
_In_ DWORD  dwTagCount,
_In_ DWORD  dwMinArgs,
_In_ DWORD  dwMaxArgs,
_Out_ DWORD pdwTagType 
)

Definition at line 422 of file netsh.c.

432{
433 DPRINT1("PreprocessCommand()\n");
434 return 0;
435}

◆ PrintError()

DWORD CDECL PrintError ( _In_opt_ HANDLE  hModule,
_In_ DWORD  dwErrId,
  ... 
)

Definition at line 439 of file netsh.c.

443{
444 PWSTR pszInBuffer = NULL, pszOutBuffer = NULL;
445 DWORD dwLength = 0;
446 va_list ap;
447
448 DPRINT("PrintError(%p %lu ...)\n", hModule, dwErrId);
449
450 va_start(ap, dwErrId);
451
452 pszOutBuffer = HeapAlloc(GetProcessHeap(), 0, HUGE_BUFFER_SIZE * sizeof(WCHAR));
453 if (pszOutBuffer == NULL)
454 goto done;
455
456 if (hModule)
457 {
458 pszInBuffer = HeapAlloc(GetProcessHeap(), 0, HUGE_BUFFER_SIZE * sizeof(WCHAR));
459 if (pszInBuffer == NULL)
460 goto done;
461
462 dwLength = LoadStringW(hModule, dwErrId, pszInBuffer, HUGE_BUFFER_SIZE);
463 if (dwLength == 0)
464 goto done;
465
467 pszInBuffer,
468 0,
469 0,
470 pszOutBuffer,
472 &ap);
473 }
474 else
475 {
476 if ((dwErrId > NETSH_ERROR_BASE) && (dwErrId < NETSH_ERROR_END))
477 {
478 pszInBuffer = HeapAlloc(GetProcessHeap(), 0, HUGE_BUFFER_SIZE * sizeof(WCHAR));
479 if (pszInBuffer == NULL)
480 goto done;
481
482 dwLength = LoadStringW(GetModuleHandle(NULL), dwErrId, pszInBuffer, HUGE_BUFFER_SIZE);
483 if (dwLength == 0)
484 goto done;
485
487 pszInBuffer,
488 0,
489 0L,
490 pszOutBuffer,
492 &ap);
493 }
494 else
495 {
497 NULL,
498 dwErrId,
500 pszOutBuffer,
502 &ap);
503 }
504 }
505
506 va_end(ap);
507
508 if (dwLength > 0)
509 ConPuts(StdOut, pszOutBuffer);
510
511done:
512 if (pszOutBuffer)
513 HeapFree(GetProcessHeap(), 0, pszOutBuffer);
514
515 if (pszInBuffer)
516 HeapFree(GetProcessHeap(), 0, pszInBuffer);
517
518 return dwLength;
519}
#define va_end(ap)
Definition: acmsvcex.h:90
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
#define NETSH_ERROR_BASE
Definition: netsh.h:8
#define NETSH_ERROR_END
Definition: netsh.h:30
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
uint16_t * PWSTR
Definition: typedefs.h:56
#define GetModuleHandle
Definition: winbase.h:3576
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400

Referenced by wmain().

◆ PrintMessage()

DWORD CDECL PrintMessage ( _In_ LPCWSTR  pwszFormat,
  ... 
)

Definition at line 542 of file netsh.c.

545{
546 INT Length;
547 va_list ap;
548
549 va_start(ap, pwszFormat);
550 Length = ConPrintfV(StdOut, pwszFormat, ap);
551 va_end(ap);
552
553 return Length;
554}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
INT ConPrintfV(IN PCON_STREAM Stream, IN PCWSTR szStr, IN va_list args)
Definition: outstream.c:466

◆ PrintMessageFromModule()

DWORD CDECL PrintMessageFromModule ( _In_ HANDLE  hModule,
_In_ DWORD  dwMsgId,
  ... 
)

Definition at line 523 of file netsh.c.

527{
528 INT Length;
529 va_list ap;
530
531 va_start(ap, dwMsgId);
534 ap);
535 va_end(ap);
536
537 return Length;
538}
INT ConResPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
Definition: outstream.c:653
#define SUBLANG_NEUTRAL
Definition: nls.h:167

Referenced by InterfaceDumpFn(), IpDumpFn(), and IpShowAdapters().

◆ RunScript()

DWORD RunScript ( _In_ LPCWSTR  filename)

Definition at line 22 of file netsh.c.

24{
25 WCHAR tmp_string[MAX_STRING_SIZE];
26 FILE *script;
27 DWORD dwError = ERROR_SUCCESS;
28
29 /* Open the file for processing */
30 script = _wfopen(filename, L"r");
31 if (script == NULL)
32 {
35 }
36
37 /* Read and process the script */
38 while (fgetws(tmp_string, MAX_STRING_SIZE, script) != NULL)
39 {
40 dwError = InterpretLine(tmp_string);
41 if (dwError != ERROR_SUCCESS)
42 break;
43 }
44
45 /* Close the file */
47
48 return dwError;
49}
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define StdErr
Definition: fc.c:15
DWORD InterpretLine(_In_ LPWSTR pszInputLine)
Definition: interpreter.c:333
#define MAX_STRING_SIZE
Definition: precomp.h:40
#define IDS_OPEN_FAILED
Definition: resource.h:14
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
const char * filename
Definition: ioapi.h:137
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
script
Definition: msipriv.h:383
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22

Referenced by ExecCommand(), and wmain().

◆ wmain()

int wmain ( _In_ int  argc,
_In_ const LPWSTR  argv[] 
)

Definition at line 90 of file netsh.c.

93{
94 LPCWSTR pszScriptFileName = NULL;
95 LPCWSTR pszAliasFileName = NULL;
96 LPCWSTR pszContext = NULL;
97 LPWSTR pszCommand = NULL;
98 int index;
99 DWORD dwError = ERROR_SUCCESS;
100
101 DPRINT("wmain(%S)\n", GetCommandLineW());
102
104
105 /* Initialize the Console Standard Streams */
107
108 /* FIXME: Init code goes here */
109 InitAliases();
112 LoadHelpers();
113
114 /* Process the command arguments */
115 for (index = 1; index < argc; index++)
116 {
117 if ((_wcsicmp(argv[index], L"-?") == 0) ||
118 (_wcsicmp(argv[index], L"/?") == 0) ||
119 (_wcsicmp(argv[index], L"?") == 0))
120 {
121 /* Help option */
123 dwError = ERROR_SUCCESS;
124 goto done;
125 }
126 else if ((_wcsicmp(argv[index], L"-a") == 0) ||
127 (_wcsicmp(argv[index], L"/a") == 0))
128 {
129 /* Aliasfile option */
130 if ((index + 1) < argc)
131 {
132 index++;
133 ConPuts(StdOut, L"\nThe -a option is not implemented yet\n");
134 pszAliasFileName = argv[index];
135 }
136 else
137 {
139 dwError = ERROR_INVALID_SYNTAX;
140 goto done;
141 }
142 }
143 else if ((_wcsicmp(argv[index], L"-c") == 0) ||
144 (_wcsicmp(argv[index], L"/c") == 0))
145 {
146 /* Context option */
147 if ((index + 1) < argc)
148 {
149 index++;
150 pszContext = argv[index];
151 }
152 else
153 {
155 dwError = ERROR_INVALID_SYNTAX;
156 goto done;
157 }
158 }
159 else if ((_wcsicmp(argv[index], L"-f") == 0) ||
160 (_wcsicmp(argv[index], L"/f") == 0))
161 {
162 /* File option */
163 if ((index + 1) < argc)
164 {
165 index++;
166 pszScriptFileName = argv[index];
167 }
168 else
169 {
171 dwError = ERROR_INVALID_SYNTAX;
172 goto done;
173 }
174 }
175 else if ((_wcsicmp(argv[index], L"-r") == 0) ||
176 (_wcsicmp(argv[index], L"/r") == 0))
177 {
178 /* Remote option */
179 if ((index + 1) < argc)
180 {
181 index++;
182 pszMachine = HeapAlloc(GetProcessHeap(), 0, (wcslen(argv[index]) + 1) * sizeof(WCHAR));
183 if (pszMachine == NULL)
184 {
185 dwError = ERROR_NOT_ENOUGH_MEMORY;
186 PrintError(hModule, dwError);
187 goto done;
188 }
189
191 }
192 else
193 {
195 dwError = ERROR_INVALID_SYNTAX;
196 goto done;
197 }
198 }
199 else
200 {
201 if (pszScriptFileName != NULL)
202 {
204 dwError = ERROR_INVALID_SYNTAX;
205 goto done;
206 }
207 else if (pszCommand == NULL)
208 {
209 pszCommand = MergeStrings((LPWSTR*)&argv[index], argc - index);
210 if (pszCommand == NULL)
211 {
212 dwError = ERROR_NOT_ENOUGH_MEMORY;
213 PrintError(hModule, dwError);
214 goto done;
215 }
216
217 break;
218 }
219 }
220 }
221
222 /* Run the alias file */
223 if (pszAliasFileName != NULL)
224 {
225 dwError = RunScript(pszAliasFileName);
226 if (dwError != ERROR_SUCCESS)
227 goto done;
228 }
229
230 /* Set a context */
231 if (pszContext)
232 {
233 dwError = InterpretLine((LPWSTR)pszContext);
234 if (dwError != ERROR_SUCCESS)
235 goto done;
236 }
237
238 /* Run a script, the command line instruction or the interactive interpeter */
239 if (pszScriptFileName != NULL)
240 {
241 dwError = RunScript(pszScriptFileName);
242 }
243 else if (pszCommand != NULL)
244 {
245 dwError = InterpretLine(pszCommand);
246 }
247 else
248 {
250 }
251
252done:
253 /* FIXME: Cleanup code goes here */
254 if (pszMachine != NULL)
256
257 if (pszCommand != NULL)
258 HeapFree(GetProcessHeap(), 0, pszCommand);
259
263
264 return (dwError == ERROR_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE;
265}
static int argc
Definition: ServiceArgs.c:12
#define ConInitStdStreams()
Definition: fc.c:13
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define index(s, c)
Definition: various.h:29
VOID DestroyAliases(VOID)
Definition: alias.c:103
VOID InitAliases(VOID)
Definition: alias.c:95
BOOL CreateRootContext(VOID)
Definition: context.c:805
VOID CleanupContext(VOID)
Definition: context.c:999
PWSTR pszMachine
Definition: context.c:32
VOID InterpretInteractive(VOID)
Definition: interpreter.c:385
#define IDS_APP_USAGE
Definition: resource.h:12
wcscpy
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LPWSTR WINAPI GetCommandLineW(void)
Definition: process.c:1338
GLuint index
Definition: glext.h:6031
DWORD CreateRootHelper(VOID)
Definition: helper.c:245
VOID LoadHelpers(VOID)
Definition: helper.c:263
VOID UnloadHelpers(VOID)
Definition: helper.c:340
#define EXIT_FAILURE
Definition: jerror.c:33
#define argv
Definition: mplay32.c:18
DWORD CDECL PrintError(_In_opt_ HANDLE hModule, _In_ DWORD dwErrId,...)
Definition: netsh.c:439
LPWSTR MergeStrings(_In_ LPWSTR pszStringArray[], _In_ INT nCount)
Definition: netsh.c:53
DWORD RunScript(_In_ LPCWSTR filename)
Definition: netsh.c:22
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Variable Documentation

◆ hModule

HMODULE hModule = NULL

Definition at line 17 of file netsh.c.

Referenced by __acrt_GetModuleFileNameA(), __wine_msi_call_dll_function(), _getdllprocaddr(), _Success_(), AddScreenSaver(), AddSfcNotification(), APIHook_GetProcAddress(), AVrfpGetProcAddress(), BasepGetModuleHandleExW(), BasepLoadLibraryAsDatafile(), BasepMapModuleHandle(), ClearUserApiHook(), co_IntCallLoadMenu(), Control_FillCache_RunDLLA(), Control_FillCache_RunDLLW(), CClassNode::ConvertResourceDescriptorToString(), CreateRootContext(), CryptInstallOIDFunctionAddress(), CURSORICON_CopyImage(), DllMain(), DRIVER_GetNumberOfModuleRefs(), DRIVER_TryOpenDriver32(), EndUserApiHook(), EngFindImageProcAddress(), EngUnloadImage(), EngUnmapFile(), EnumPickIconResourceProc(), EnumResNameProc(), find_resourceA(), find_resourceW(), FindModule(), FindResourceA(), FindResourceExA(), FindResourceExW(), FindResourceW(), FreeLibrary(), get_manifest_in_module(), GetDriverModuleHandle(), GetDriverVersion(), GetFileVersionInfoExW(), GetFileVersionInfoSizeExW(), GetFunctionPointer(), GetModuleBaseNameA(), GetModuleBaseNameW(), GetModuleFileNameA(), GetModuleFileNameExA(), GetModuleFileNameExW(), GetModuleFileNameW(), GetModuleHandleW(), GetModuleInformation(), GetMonitorUI(), GetNotificationHandler(), GetProcAddress(), GetSeconds(), GetServiceDllFunction(), GPNotificationThreadProc(), init_functions(), InstallSoftwareBusPnpEnumerator(), is_module_registered(), load_mui_string(), load_string(), LoadDialog(), LoadDialogResource(), LoadLibraryList(), LoadNotifyDll(), LoadResource(), LookupThreadProc(), MakeString(), MatchEnumTag(), MLFreeLibrary(), MSACM_GetNumberOfModuleRefs(), MSACM_RegisterLocalDriver(), NotifyLogon(), PrintError(), printm(), PrintMessageFromModule(), RegLoadMUIStringW(), CDeviceView::RunAddHardwareWizard(), search_res_tlb(), SeiGetModuleFromAddress(), SetupDiGetClassDevPropertySheetsW(), SRSetRestorePointA(), SRSetRestorePointW(), START_TEST(), StubGetProcAddress(), test_pack_ACTCTXA(), test_pack_ACTCTXW(), testLayout(), testLoadLibraryA(), testLoadLibraryA_Wrong(), UnloadAppInitDlls(), UserSignalProc(), WinMain(), wmain(), Ws2HelpDllMain(), and wWinMain().