ReactOS 0.4.17-dev-573-g8315b8c
context.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for context.c:

Go to the source code of this file.

Classes

struct  _CONTEXT_STACK_ENTRY
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _CONTEXT_STACK_ENTRY CONTEXT_STACK_ENTRY
 
typedef struct _CONTEXT_STACK_ENTRYPCONTEXT_STACK_ENTRY
 

Functions

PCONTEXT_ENTRY AddContext (PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
 
PCOMMAND_ENTRY AddContextCommand (PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
 
PCOMMAND_GROUP AddCommandGroup (PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
 
PCOMMAND_ENTRY AddGroupCommand (PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
 
VOID RemoveContextFromStack (_In_ PCONTEXT_ENTRY pContextEntry)
 
VOID DeleteContext (PWSTR pszName)
 
static int ContextCompare (_In_ const void *p1, _In_ const void *p2)
 
static DWORD DumpContext (_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
 
static DWORD CommitContext (_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
 
DWORD WINAPI UpCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI AbortCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI CommitCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI DumpCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ExecCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ExitCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI RemCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI OfflineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI OnlineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI PopdCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI PushdCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI SetMachineCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI SetModeCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
DWORD WINAPI ShowModeCommand (_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
 
BOOL CreateRootContext (VOID)
 
static PCONTEXT_ENTRY FindSubContextByGuid (PCONTEXT_ENTRY pContext, const GUID *pGuid)
 
PCONTEXT_ENTRY FindContextByGuid (const GUID *pGuid)
 
DWORD WINAPI RegisterContext (_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
 
VOID CleanupContext (VOID)
 

Variables

PCONTEXT_ENTRY pRootContext = NULL
 
PCONTEXT_ENTRY pCurrentContext = NULL
 
PCONTEXT_STACK_ENTRY pContextStackHead = NULL
 
PCONTEXT_STACK_ENTRY pContextStackTail = NULL
 
PWSTR g_pszMachine = NULL
 
BOOL g_bOnline = TRUE
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file context.c.

Typedef Documentation

◆ CONTEXT_STACK_ENTRY

◆ PCONTEXT_STACK_ENTRY

Function Documentation

◆ AbortCommand()

DWORD WINAPI AbortCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 499 of file context.c.

507{
508 DPRINT("AbortCommand()\n");
510 return ERROR_SUCCESS;
511}
PCONTEXT_ENTRY pRootContext
Definition: context.c:26
static DWORD CommitContext(_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
Definition: context.c:410
#define ERROR_SUCCESS
Definition: deptool.c:10
@ NETSH_FLUSH
Definition: netsh.h:55
#define DPRINT
Definition: sndvol32.h:73

Referenced by CreateRootContext().

◆ AddCommandGroup()

PCOMMAND_GROUP AddCommandGroup ( PCONTEXT_ENTRY  pContext,
LPCWSTR  pwszCmdGroupToken,
DWORD  dwShortCmdHelpToken,
DWORD  dwFlags,
PNS_OSVERSIONCHECK  pfnOsVersionCheck 
)

Definition at line 153 of file context.c.

159{
161
162 DPRINT("AddCommandGroup(%S %lu)\n", pwszCmdGroupToken, dwShortCmdHelpToken);
163
164 /* Allocate the entry */
166 if (pEntry == NULL)
167 return NULL;
168
169 pEntry->pwszCmdGroupToken = HeapAlloc(GetProcessHeap(),
171 (wcslen(pwszCmdGroupToken) + 1) * sizeof(WCHAR));
172 if (pEntry->pwszCmdGroupToken == NULL)
173 {
175 return NULL;
176 }
177
178 wcscpy((LPWSTR)pEntry->pwszCmdGroupToken, pwszCmdGroupToken);
179 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
180 pEntry->dwFlags = dwFlags;
181 pEntry->pfnOsVersionCheck = pfnOsVersionCheck;
182
183 if (pContext->pGroupListHead == NULL && pContext->pGroupListTail == NULL)
184 {
185 pContext->pGroupListHead = pEntry;
186 pContext->pGroupListTail = pEntry;
187 }
188 else
189 {
190 pEntry->pPrev = pContext->pGroupListTail;
191 pContext->pGroupListTail->pNext = pEntry;
192 pContext->pGroupListTail = pEntry;
193 }
194
195 return pEntry;
196}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
short WCHAR
Definition: pedump.c:58
wcscpy
struct _COMMAND_GROUP * pNext
Definition: precomp.h:89
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:122
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:121
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by CreateRootContext(), and RegisterContext().

◆ AddContext()

PCONTEXT_ENTRY AddContext ( PCONTEXT_ENTRY  pParentContext,
PWSTR  pszName,
GUID pGuid 
)

Definition at line 38 of file context.c.

42{
44
45 DPRINT("AddContext(%S)\n", pszName);
46 if (pParentContext)
47 {
48 DPRINT("ParentContext %S\n", pParentContext->pszContextName);
49 }
50
51 if (pParentContext != NULL && pszName == NULL)
52 return NULL;
53
54 /* Allocate the entry */
56 if (pEntry == NULL)
57 return NULL;
58
59 /* Allocate the name buffer */
60 if (pszName != NULL)
61 {
62 pEntry->pszContextName = HeapAlloc(GetProcessHeap(),
64 (wcslen(pszName) + 1) * sizeof(WCHAR));
65 if (pEntry->pszContextName == NULL)
66 {
68 return NULL;
69 }
70
71 /* Fill the entry */
72 wcscpy(pEntry->pszContextName, pszName);
73 }
74
75 pEntry->pParentContext = pParentContext;
76 if (pGuid != NULL)
77 CopyMemory(&pEntry->Guid, pGuid, sizeof(pEntry->Guid));
78
79 /* Insert it */
80 if (pParentContext != NULL)
81 {
82 if ((pParentContext->pSubContextHead == NULL) && (pParentContext->pSubContextTail == NULL))
83 {
84 pParentContext->pSubContextHead = pEntry;
85 pParentContext->pSubContextTail = pEntry;
86 }
87 else
88 {
89 pEntry->pPrev = pParentContext->pSubContextTail;
90 pParentContext->pSubContextTail->pNext = pEntry;
91 pParentContext->pSubContextTail = pEntry;
92 }
93 }
94
95 return pEntry;
96}
#define CopyMemory
Definition: minwinbase.h:29
Definition: precomp.h:101
PWSTR pszContextName
Definition: precomp.h:108
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:124
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:125

Referenced by CreateRootContext(), and RegisterContext().

◆ AddContextCommand()

PCOMMAND_ENTRY AddContextCommand ( PCONTEXT_ENTRY  pContext,
LPCWSTR  pwszCmdToken,
PFN_HANDLE_CMD  pfnCmdHandler,
DWORD  dwShortCmdHelpToken,
DWORD  dwCmdHlpToken,
DWORD  dwFlags,
PNS_OSVERSIONCHECK  pfnOsVersionCheck 
)

Definition at line 100 of file context.c.

108{
110
111 if (pfnCmdHandler == NULL)
112 return NULL;
113
114 /* Allocate the entry */
116 if (pEntry == NULL)
117 return NULL;
118
119 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
121 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
122 if (pEntry->pwszCmdToken == NULL)
123 {
125 return NULL;
126 }
127
128 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
129
130 pEntry->pfnCmdHandler = pfnCmdHandler;
131 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
132 pEntry->dwCmdHlpToken = dwCmdHlpToken;
133 pEntry->dwFlags = dwFlags;
134 pEntry->pfnOsVersionCheck = pfnOsVersionCheck;
135
136 if (pContext->pCommandListHead == NULL && pContext->pCommandListTail == NULL)
137 {
138 pContext->pCommandListHead = pEntry;
139 pContext->pCommandListTail = pEntry;
140 }
141 else
142 {
143 pEntry->pPrev = pContext->pCommandListTail;
144 pContext->pCommandListTail->pNext = pEntry;
145 pContext->pCommandListTail = pEntry;
146 }
147
148 return pEntry;
149}
Definition: precomp.h:74
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:76
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:119
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:118

Referenced by CreateRootContext(), and RegisterContext().

◆ AddGroupCommand()

PCOMMAND_ENTRY AddGroupCommand ( PCOMMAND_GROUP  pGroup,
LPCWSTR  pwszCmdToken,
PFN_HANDLE_CMD  pfnCmdHandler,
DWORD  dwShortCmdHelpToken,
DWORD  dwCmdHlpToken,
DWORD  dwFlags,
PNS_OSVERSIONCHECK  pfnOsVersionCheck 
)

Definition at line 200 of file context.c.

208{
210
211 if (pfnCmdHandler == NULL)
212 return NULL;
213
214 /* Allocate the entry */
216 if (pEntry == NULL)
217 return NULL;
218
219 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
221 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
222 if (pEntry->pwszCmdToken == NULL)
223 {
225 return NULL;
226 }
227
228 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
229
230 pEntry->pfnCmdHandler = pfnCmdHandler;
231 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
232 pEntry->dwCmdHlpToken = dwCmdHlpToken;
233 pEntry->dwFlags = dwFlags;
234 pEntry->pfnOsVersionCheck = pfnOsVersionCheck;
235
236 if (pGroup->pCommandListHead == NULL && pGroup->pCommandListTail == NULL)
237 {
238 pGroup->pCommandListHead = pEntry;
239 pGroup->pCommandListTail = pEntry;
240 }
241 else
242 {
243 pEntry->pPrev = pGroup->pCommandListTail;
244 pGroup->pCommandListTail->pNext = pEntry;
245 pGroup->pCommandListTail = pEntry;
246 }
247
248 return pEntry;
249}
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:97
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:96

Referenced by CreateRootContext(), and RegisterContext().

◆ CleanupContext()

VOID CleanupContext ( VOID  )

Definition at line 1016 of file context.c.

1017{
1018 /* Delete the context stack */
1019
1020}

Referenced by wmain().

◆ CommitCommand()

DWORD WINAPI CommitCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 516 of file context.c.

524{
525 DPRINT("CommitCommand()\n");
527 return ERROR_SUCCESS;
528}
@ NETSH_SAVE
Definition: netsh.h:57

Referenced by CreateRootContext().

◆ CommitContext()

static DWORD CommitContext ( _In_ PCONTEXT_ENTRY  pContext,
_In_ DWORD  dwAction 
)
static

Definition at line 410 of file context.c.

413{
414 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
415 DWORD dwCount, dwIndex;
416 DWORD dwError = ERROR_SUCCESS;
417
418 DPRINT1("CommitContext(%p %lu)\n", pContext, dwAction);
419
420 if (pContext->pfnCommitFn)
421 {
422 dwError = pContext->pfnCommitFn(dwAction);
423 if (dwError != ERROR_SUCCESS)
424 {
425 DPRINT1("Commit function failed (Error %lu)\n", dwError);
426 return dwError;
427 }
428 }
429
430 if (pContext->pSubContextHead == NULL)
431 return dwError;
432
433 /* Count the sub-contexts */
434 dwCount = 0;
435 pSubContext = pContext->pSubContextHead;
436 while (pSubContext)
437 {
438 dwCount++;
439 pSubContext = pSubContext->pNext;
440 }
441
442 /* Allocate the sort array */
443 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
444 if (pSortArray == NULL)
446
447 /* Fill the sort array */
448 dwIndex = 0;
449 pSubContext = pContext->pSubContextHead;
450 while (pSubContext)
451 {
452 pSortArray[dwIndex] = pSubContext;
453 dwIndex++;
454 pSubContext = pSubContext->pNext;
455 }
456
457 /* Sort the array */
458 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
459
460 /* Commit the sub-contexts */
461 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
462 {
463 dwError = CommitContext(pSortArray[dwIndex],
464 dwAction);
465 if (dwError != ERROR_SUCCESS)
466 {
467 DPRINT1("Commit function failed (Error %lu)\n", dwError);
468 break;
469 }
470 }
471
472 /* Free the sort array */
473 HeapFree(GetProcessHeap(), 0, pSortArray);
474
475 return dwError;
476}
static int ContextCompare(_In_ const void *p1, _In_ const void *p2)
Definition: context.c:321
#define DPRINT1
Definition: precomp.h:8
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:103

Referenced by AbortCommand(), CommitCommand(), CommitContext(), ExitCommand(), OfflineCommand(), OnlineCommand(), and SetModeCommand().

◆ ContextCompare()

static int ContextCompare ( _In_ const void p1,
_In_ const void p2 
)
static

Definition at line 321 of file context.c.

324{
325 return ((PCONTEXT_ENTRY)p1)->ulPriority - ((PCONTEXT_ENTRY)p2)->ulPriority;
326}
struct _CONTEXT_ENTRY * PCONTEXT_ENTRY

Referenced by CommitContext(), and DumpContext().

◆ CreateRootContext()

BOOL CreateRootContext ( VOID  )

Definition at line 810 of file context.c.

811{
812 PCOMMAND_GROUP pGroup;
813
814 pRootContext = AddContext(NULL, L"netsh", NULL);
815 DPRINT("pRootContext: %p\n", pRootContext);
816 if (pRootContext == NULL)
817 return FALSE;
818
820
837
839 if (pGroup)
840 {
842 }
843
845 if (pGroup)
846 {
848 }
849
851 if (pGroup)
852 {
855 }
856
858 if (pGroup)
859 {
863 }
864
866
867 return TRUE;
868}
DWORD WINAPI ShowAliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:215
DWORD WINAPI UnaliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:234
DWORD WINAPI AliasCommand(LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: alias.c:123
PCOMMAND_GROUP AddCommandGroup(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:153
PCOMMAND_ENTRY AddContextCommand(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:100
DWORD WINAPI SetModeCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:756
DWORD WINAPI ExecCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:554
DWORD WINAPI CommitCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:516
DWORD WINAPI ShowModeCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:794
DWORD WINAPI AbortCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:499
DWORD WINAPI OnlineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:626
DWORD WINAPI UpCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:481
DWORD WINAPI SetMachineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:719
PCONTEXT_ENTRY pCurrentContext
Definition: context.c:27
DWORD WINAPI DumpCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:533
DWORD WINAPI PopdCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:644
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:38
DWORD WINAPI OfflineCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:608
DWORD WINAPI PushdCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:683
DWORD WINAPI ExitCommand(_In_ LPCWSTR pwszMachine, _In_ LPWSTR *argv, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _In_ DWORD dwFlags, _In_ LPCVOID pvData, _Out_ BOOL *pbDone)
Definition: context.c:574
PCOMMAND_ENTRY AddGroupCommand(PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:200
#define IDS_HLP_POPD
Definition: resource.h:29
#define IDS_HLP_DEL_HELPER
Definition: resource.h:52
#define IDS_HLP_SHOW_MODE
Definition: resource.h:62
#define IDS_HLP_SHOW_ALIAS_EX
Definition: resource.h:59
#define IDS_HLP_GROUP_SET
Definition: resource.h:67
#define IDS_HLP_GROUP_ADD
Definition: resource.h:65
#define IDS_HLP_SHOW_ALIAS
Definition: resource.h:58
#define IDS_HLP_HELP
Definition: resource.h:25
#define IDS_HLP_DUMP
Definition: resource.h:35
#define IDS_HLP_PUSHD_EX
Definition: resource.h:32
#define IDS_HLP_EXEC_EX
Definition: resource.h:34
#define IDS_HLP_POPD_EX
Definition: resource.h:30
#define IDS_HLP_UNALIAS_EX
Definition: resource.h:48
#define IDS_HLP_DUMP_EX
Definition: resource.h:36
#define IDS_HLP_GROUP_SHOW
Definition: resource.h:68
#define IDS_HLP_EXIT
Definition: resource.h:23
#define IDS_HLP_COMMIT
Definition: resource.h:43
#define IDS_HLP_DEL_HELPER_EX
Definition: resource.h:53
#define IDS_HLP_SET_MACHINE
Definition: resource.h:54
#define IDS_HLP_OFFLINE_EX
Definition: resource.h:38
#define IDS_HLP_SET_MODE_EX
Definition: resource.h:57
#define IDS_HLP_COMMIT_EX
Definition: resource.h:44
#define IDS_HLP_ALIAS
Definition: resource.h:45
#define IDS_HLP_ONLINE
Definition: resource.h:39
#define IDS_HLP_GROUP_DELETE
Definition: resource.h:66
#define IDS_HLP_SHOW_MODE_EX
Definition: resource.h:63
#define IDS_HLP_HELP_EX
Definition: resource.h:26
#define IDS_HLP_EXEC
Definition: resource.h:33
#define IDS_HLP_UNALIAS
Definition: resource.h:47
#define IDS_HLP_PUSHD
Definition: resource.h:31
#define IDS_HLP_ONLINE_EX
Definition: resource.h:40
#define IDS_HLP_UP_EX
Definition: resource.h:28
#define IDS_HLP_SHOW_HELPER
Definition: resource.h:60
#define IDS_HLP_SET_MACHINE_EX
Definition: resource.h:55
#define IDS_HLP_ABORT_EX
Definition: resource.h:42
#define IDS_HLP_SET_MODE
Definition: resource.h:56
#define IDS_HLP_EXIT_EX
Definition: resource.h:24
#define IDS_HLP_OFFLINE
Definition: resource.h:37
#define IDS_HLP_ADD_HELPER_EX
Definition: resource.h:51
#define IDS_HLP_ALIAS_EX
Definition: resource.h:46
#define IDS_HLP_ABORT
Definition: resource.h:41
#define IDS_HLP_SHOW_HELPER_EX
Definition: resource.h:61
#define IDS_HLP_ADD_HELPER
Definition: resource.h:50
#define IDS_HLP_UP
Definition: resource.h:27
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define L(x)
Definition: resources.c:13
DWORD WINAPI ShowHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:614
DWORD WINAPI AddHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:461
DWORD WINAPI DeleteHelperCommand(LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
Definition: helper.c:493
HMODULE g_hModule
Definition: netsh.c:17
@ CMD_FLAG_ONLINE
Definition: netsh.h:45
@ CMD_FLAG_LOCAL
Definition: netsh.h:44
HMODULE hModule
Definition: precomp.h:110

Referenced by wmain().

◆ DeleteContext()

VOID DeleteContext ( PWSTR  pszName)

Definition at line 308 of file context.c.

310{
311 /* Remove the context from the stack */
312 /* RemoveContextFromStack(); */
313
314 /* Delete all commands */
315 /* Delete the context */
316}

Referenced by _Requires_lock_held_().

◆ DumpCommand()

DWORD WINAPI DumpCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR ppwcArguments,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 533 of file context.c.

541{
542 DPRINT("DumpCommand()\n");
543
545 pwszMachine,
548 pvData);
549}
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:331
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115

Referenced by CreateRootContext().

◆ DumpContext()

static DWORD DumpContext ( _In_ PCONTEXT_ENTRY  pContext,
_In_ LPCWSTR  pwszMachine,
_In_ LPWSTR ppwcArguments,
_In_ DWORD  dwArgCount,
_In_ LPCVOID  pvData 
)
static

Definition at line 331 of file context.c.

337{
338 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
339 DWORD dwCount, dwIndex;
340 DWORD dwError = ERROR_SUCCESS;
341
342 DPRINT("DumpContext()\n");
343
344 if (pContext->pfnDumpFn)
345 {
346 dwError = pContext->pfnDumpFn(pwszMachine,
349 pvData);
350 if (dwError != ERROR_SUCCESS)
351 {
352 DPRINT1("Dump function failed (Error %lu)\n", dwError);
353 return dwError;
354 }
355 }
356
357 if (pContext->pSubContextHead == NULL)
358 return dwError;
359
360 /* Count the sub-contexts */
361 dwCount = 0;
362 pSubContext = pContext->pSubContextHead;
363 while (pSubContext)
364 {
365 dwCount++;
366 pSubContext = pSubContext->pNext;
367 }
368
369 /* Allocate the sort array */
370 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
371 if (pSortArray == NULL)
373
374 /* Fill the sort array */
375 dwIndex = 0;
376 pSubContext = pContext->pSubContextHead;
377 while (pSubContext)
378 {
379 pSortArray[dwIndex] = pSubContext;
380 dwIndex++;
381 pSubContext = pSubContext->pNext;
382 }
383
384 /* Sort the array */
385 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
386
387 /* Dump the sub-contexts */
388 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
389 {
390 dwError = DumpContext(pSortArray[dwIndex],
391 pwszMachine,
394 pvData);
395 if (dwError != ERROR_SUCCESS)
396 {
397 DPRINT1("Dump function failed (Error %lu)\n", dwError);
398 break;
399 }
400 }
401
402 /* Free the sort array */
403 HeapFree(GetProcessHeap(), 0, pSortArray);
404
405 return dwError;
406}

Referenced by DumpCommand(), and DumpContext().

◆ ExecCommand()

DWORD WINAPI ExecCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 554 of file context.c.

562{
563 DPRINT("ExecCommand()\n");
564
565 if (dwArgCount - dwCurrentIndex != 1)
566 return ERROR_SHOW_USAGE;
567
569}
#define argv
Definition: mplay32.c:18
DWORD RunScript(_In_ LPCWSTR filename)
Definition: netsh.c:22
#define ERROR_SHOW_USAGE
Definition: netsh.h:22
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139

Referenced by CreateRootContext().

◆ ExitCommand()

DWORD WINAPI ExitCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 574 of file context.c.

582{
583 if (g_bOnline == FALSE)
585
586 *pbDone = TRUE;
587 return ERROR_SUCCESS;
588}
BOOL g_bOnline
Definition: context.c:33
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD _In_ LPCVOID _Out_ BOOL * pbDone
Definition: netsh.h:143

Referenced by CreateRootContext(), and main().

◆ FindContextByGuid()

PCONTEXT_ENTRY FindContextByGuid ( const GUID pGuid)

Definition at line 903 of file context.c.

905{
906 if (pRootContext == NULL)
907 return NULL;
908 return FindSubContextByGuid(pRootContext, pGuid);
909}
static PCONTEXT_ENTRY FindSubContextByGuid(PCONTEXT_ENTRY pContext, const GUID *pGuid)
Definition: context.c:873

Referenced by PrintHelpers(), and RegisterContext().

◆ FindSubContextByGuid()

static PCONTEXT_ENTRY FindSubContextByGuid ( PCONTEXT_ENTRY  pContext,
const GUID pGuid 
)
static

Definition at line 873 of file context.c.

876{
877 PCONTEXT_ENTRY pResultContext, pSubContext;
878
879 DPRINT("FindSubContextByGuid(%p)\n", pContext);
880 DPRINT("%lx <--> %lx\n", pContext->Guid.Data1, pGuid->Data1);
881
882 if (IsEqualGUID(&pContext->Guid, pGuid))
883 {
884 DPRINT("Found!\n");
885 return pContext;
886 }
887
888 pSubContext = pContext->pSubContextHead;
889 while (pSubContext)
890 {
891 pResultContext = FindSubContextByGuid(pSubContext, pGuid);
892 if (pResultContext)
893 return pResultContext;
894
895 pSubContext = pSubContext->pNext;
896 }
897
898 return NULL;
899}
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
GUID Guid
Definition: precomp.h:109

Referenced by FindContextByGuid(), and FindSubContextByGuid().

◆ OfflineCommand()

DWORD WINAPI OfflineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 608 of file context.c.

616{
617 DPRINT("OfflineCommand()\n");
620 return ERROR_SUCCESS;
621}
@ NETSH_UNCOMMIT
Definition: netsh.h:54

Referenced by CreateRootContext().

◆ OnlineCommand()

DWORD WINAPI OnlineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 626 of file context.c.

634{
635 DPRINT("OnlineCommand()\n");
637 g_bOnline = TRUE;
638 return ERROR_SUCCESS;
639}
@ NETSH_COMMIT
Definition: netsh.h:53

Referenced by CreateRootContext().

◆ PopdCommand()

DWORD WINAPI PopdCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 644 of file context.c.

652{
654
655 DPRINT("PopdCommand()\n");
656
657 if (pContextStackHead == NULL)
658 return ERROR_SUCCESS;
659
661
662 pCurrentContext = pEntry->pContext;
663
665 {
668 }
669 else
670 {
671 pContextStackHead = pEntry->pNext;
673 }
674
676
677 return ERROR_SUCCESS;
678}
PCONTEXT_STACK_ENTRY pContextStackHead
Definition: context.c:29
PCONTEXT_STACK_ENTRY pContextStackTail
Definition: context.c:30
Definition: context.c:18
struct _CONTEXT_STACK_ENTRY * pPrev
Definition: context.c:19

Referenced by CreateRootContext().

◆ PushdCommand()

DWORD WINAPI PushdCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 683 of file context.c.

691{
693
694 DPRINT("PushdCommand()\n");
695
697 if (pEntry == NULL)
699
700 pEntry->pContext = pCurrentContext;
701 if (pContextStackHead == NULL)
702 {
705 }
706 else
707 {
708 pEntry->pNext = pContextStackHead;
711 }
712
713 return ERROR_SUCCESS;
714}

Referenced by CreateRootContext().

◆ RegisterContext()

DWORD WINAPI RegisterContext ( _In_ const NS_CONTEXT_ATTRIBUTES pChildContext)

Definition at line 914 of file context.c.

916{
917 PHELPER_ENTRY pHelper;
918 PCONTEXT_ENTRY pContext, pParentContext;
919 PCOMMAND_GROUP pGroup;
920 DWORD i, j;
921 DWORD dwError = ERROR_SUCCESS;
922
923 DPRINT("RegisterContext(%p)\n", pChildContext);
924 if (pChildContext == NULL)
925 {
926 DPRINT1("Invalid child context!\n");
928 }
929
930 if ((pChildContext->pwszContext == NULL) ||
931 (wcslen(pChildContext->pwszContext) == 0) ||
932 (wcschr(pChildContext->pwszContext, L' ') != 0) ||
933 (wcschr(pChildContext->pwszContext, L'=') != 0))
934 {
935 DPRINT1("Invalid context name!\n");
937 }
938
939 DPRINT("Name: %S\n", pChildContext->pwszContext);
940 DPRINT("Groups: %lu\n", pChildContext->ulNumGroups);
941 DPRINT("Top commands: %lu\n", pChildContext->ulNumTopCmds);
942
943 pHelper = FindHelper(&pChildContext->guidHelper, pHelperListHead);
944 DPRINT("Helper %p\n", pHelper);
945 pParentContext = pRootContext;
946 if (pHelper != NULL)
947 {
948 pParentContext = FindContextByGuid(&pHelper->ParentHelperGuid);
949 DPRINT("pParentContext %p\n", pParentContext);
950 if (pParentContext == NULL)
951 pParentContext = pRootContext;
952 }
953
954 pContext = AddContext(pParentContext, pChildContext->pwszContext, (GUID*)&pChildContext->guidHelper);
955 if (pContext != NULL)
956 {
957 pContext->pfnCommitFn = pChildContext->pfnCommitFn;
958 pContext->pfnDumpFn = pChildContext->pfnDumpFn;
959 pContext->pfnConnectFn = pChildContext->pfnConnectFn;
960 pContext->pfnOsVersionCheck = pChildContext->pfnOsVersionCheck;
961 pContext->dwFlags = pChildContext->dwFlags;
962 pContext->ulPriority = (pChildContext->dwFlags & CMD_FLAG_PRIORITY) ?
963 pChildContext->ulPriority : DEFAULT_CONTEXT_PRIORITY;
964
965 if ((pHelper != NULL) && (pHelper->pDllEntry != NULL))
966 {
967 pContext->hModule = pHelper->pDllEntry->hModule;
968 }
969
970 for (i = 0; i < pChildContext->ulNumTopCmds; i++)
971 {
972 AddContextCommand(pContext,
973 pChildContext->pTopCmds[i].pwszCmdToken,
974 pChildContext->pTopCmds[i].pfnCmdHandler,
975 pChildContext->pTopCmds[i].dwShortCmdHelpToken,
976 pChildContext->pTopCmds[i].dwCmdHlpToken,
977 pChildContext->pTopCmds[i].dwFlags,
978 pChildContext->pTopCmds[i].pOsVersionCheck);
979 }
980
981 /* Add command groups */
982 for (i = 0; i < pChildContext->ulNumGroups; i++)
983 {
984 pGroup = AddCommandGroup(pContext,
985 pChildContext->pCmdGroups[i].pwszCmdGroupToken,
986 pChildContext->pCmdGroups[i].dwShortCmdHelpToken,
987 pChildContext->pCmdGroups[i].dwFlags,
988 pChildContext->pCmdGroups[i].pOsVersionCheck);
989 if (pGroup != NULL)
990 {
991 for (j = 0; j < pChildContext->pCmdGroups[i].ulCmdGroupSize; j++)
992 {
993 AddGroupCommand(pGroup,
994 pChildContext->pCmdGroups[i].pCmdGroup[j].pwszCmdToken,
995 pChildContext->pCmdGroups[i].pCmdGroup[j].pfnCmdHandler,
996 pChildContext->pCmdGroups[i].pCmdGroup[j].dwShortCmdHelpToken,
997 pChildContext->pCmdGroups[i].pCmdGroup[j].dwCmdHlpToken,
998 pChildContext->pCmdGroups[i].pCmdGroup[j].dwFlags,
999 pChildContext->pCmdGroups[i].pCmdGroup[j].pOsVersionCheck);
1000 }
1001 }
1002 }
1003
1004 if (pContext->pfnConnectFn)
1005 {
1006 dwError = pContext->pfnConnectFn(g_pszMachine);
1007 DPRINT("pfnConnectFn(%S) returned %lu\n", g_pszMachine, dwError);
1008 }
1009 }
1010
1011 return dwError;
1012}
PCONTEXT_ENTRY FindContextByGuid(const GUID *pGuid)
Definition: context.c:903
PWSTR g_pszMachine
Definition: context.c:32
#define wcschr
Definition: compat.h:17
#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
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 GLint GLint j
Definition: glfuncs.h:250
PHELPER_ENTRY FindHelper(_In_ const GUID *pguidHelper, _In_ PHELPER_ENTRY pHelper)
Definition: helper.c:360
PHELPER_ENTRY pHelperListHead
Definition: helper.c:20
if(dx< 0)
Definition: linetemp.h:194
@ CMD_FLAG_PRIORITY
Definition: netsh.h:48
#define DEFAULT_CONTEXT_PRIORITY
Definition: netsh.h:60
PNS_CONTEXT_CONNECT_FN pfnConnectFn
Definition: precomp.h:115
ULONG ulPriority
Definition: precomp.h:111
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:113
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: precomp.h:114
PNS_OSVERSIONCHECK pfnOsVersionCheck
Definition: precomp.h:116
DWORD dwFlags
Definition: precomp.h:112
HMODULE hModule
Definition: precomp.h:53
Definition: precomp.h:58
PDLL_LIST_ENTRY pDllEntry
Definition: precomp.h:65
GUID ParentHelperGuid
Definition: precomp.h:63

Referenced by InterfaceStart(), IpStart(), and WinsockStart().

◆ RemCommand()

DWORD WINAPI RemCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 593 of file context.c.

601{
602 return ERROR_SUCCESS;
603}

◆ RemoveContextFromStack()

VOID RemoveContextFromStack ( _In_ PCONTEXT_ENTRY  pContextEntry)

Definition at line 253 of file context.c.

255{
256 PCONTEXT_STACK_ENTRY pStackEntry, pNextEntry;
257
258 if (pContextStackHead == NULL)
259 return;
260
261 pStackEntry = pContextStackHead;
262 while (1)
263 {
264 if (pStackEntry->pContext == pContextEntry)
265 {
266 if (pStackEntry == pContextStackHead && pStackEntry == pContextStackHead)
267 {
270 HeapFree(GetProcessHeap(), 0, pStackEntry);
271 return;
272 }
273 else if (pStackEntry == pContextStackHead)
274 {
275 pStackEntry->pNext->pPrev = NULL;
276 pContextStackHead = pStackEntry->pNext;
277 HeapFree(GetProcessHeap(), 0, pStackEntry);
278 pStackEntry = pContextStackHead;
279 }
280 else if (pStackEntry == pContextStackTail)
281 {
282 pStackEntry->pPrev->pNext = NULL;
283 pContextStackTail = pStackEntry->pPrev;
284 HeapFree(GetProcessHeap(), 0, pStackEntry);
285 return;
286 }
287 else
288 {
289 pNextEntry = pStackEntry->pNext;
290 pStackEntry->pPrev->pNext = pStackEntry->pNext;
291 pStackEntry->pNext->pPrev = pStackEntry->pPrev;
292 HeapFree(GetProcessHeap(), 0, pStackEntry);
293 pStackEntry = pNextEntry;
294 }
295 }
296 else
297 {
298 if (pStackEntry == pContextStackTail)
299 return;
300
301 pStackEntry = pStackEntry->pNext;
302 }
303 }
304}
PCONTEXT_ENTRY pContext
Definition: context.c:22
struct _CONTEXT_STACK_ENTRY * pNext
Definition: context.c:20

◆ SetMachineCommand()

DWORD WINAPI SetMachineCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 719 of file context.c.

727{
728 DWORD dwError = ERROR_SUCCESS;
729
730 DPRINT("SetMachineCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
731 pwszMachine, dwCurrentIndex, dwArgCount);
732
733 if ((dwArgCount - dwCurrentIndex) > 1)
734 return ERROR_SHOW_USAGE;
735
736 if (g_pszMachine != NULL)
737 {
740 }
741
742 if ((dwArgCount - dwCurrentIndex) == 1)
743 {
744 g_pszMachine = HeapAlloc(GetProcessHeap(), 0, (sizeof(argv[dwCurrentIndex]) + 1) * sizeof(WCHAR));
745 if (g_pszMachine == NULL)
748 }
749
750 return dwError;
751}

Referenced by CreateRootContext().

◆ SetModeCommand()

DWORD WINAPI SetModeCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 756 of file context.c.

764{
765 DWORD dwError = ERROR_SUCCESS;
766
767 DPRINT("SetModeCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
768 pwszMachine, dwCurrentIndex, dwArgCount);
769
770 if ((dwArgCount - dwCurrentIndex) != 1)
771 return ERROR_SHOW_USAGE;
772
773 if (!_wcsicmp(argv[dwCurrentIndex], L"offline"))
774 {
777 }
778 else if (!_wcsicmp(argv[dwCurrentIndex], L"online"))
779 {
781 g_bOnline = TRUE;
782 }
783 else
784 {
785 dwError = ERROR_INVALID_SYNTAX;
786 }
787
788 return dwError;
789}
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10

Referenced by CreateRootContext().

◆ ShowModeCommand()

DWORD WINAPI ShowModeCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 794 of file context.c.

802{
803 DPRINT("ShowModeCommand()\n");
804 ConPuts(StdOut, g_bOnline ? L"online\n\n" : L"offline\n\n");
805 return ERROR_SUCCESS;
806}
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
#define StdOut
Definition: conutils_noros.h:6

Referenced by CreateRootContext().

◆ UpCommand()

DWORD WINAPI UpCommand ( _In_ LPCWSTR  pwszMachine,
_In_ LPWSTR argv,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_In_ DWORD  dwFlags,
_In_ LPCVOID  pvData,
_Out_ BOOL pbDone 
)

Definition at line 481 of file context.c.

489{
492
493 return ERROR_SUCCESS;
494}
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:105

Referenced by CreateRootContext().

Variable Documentation

◆ g_bOnline

◆ g_pszMachine

◆ pContextStackHead

PCONTEXT_STACK_ENTRY pContextStackHead = NULL

Definition at line 29 of file context.c.

Referenced by PopdCommand(), PushdCommand(), and RemoveContextFromStack().

◆ pContextStackTail

PCONTEXT_STACK_ENTRY pContextStackTail = NULL

Definition at line 30 of file context.c.

Referenced by PopdCommand(), PushdCommand(), and RemoveContextFromStack().

◆ pCurrentContext

◆ pRootContext