ReactOS 0.4.17-dev-470-gf9e3448
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 pszMachine = NULL
 
static BOOL 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 500 of file context.c.

508{
509 DPRINT("AbortCommand()\n");
511 return ERROR_SUCCESS;
512}
PCONTEXT_ENTRY pRootContext
Definition: context.c:26
static DWORD CommitContext(_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
Definition: context.c:411
#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 154 of file context.c.

160{
162
163 DPRINT("AddCommandGroup(%S %lu)\n", pwszCmdGroupToken, dwShortCmdHelpToken);
164
165 /* Allocate the entry */
167 if (pEntry == NULL)
168 return NULL;
169
170 pEntry->pwszCmdGroupToken = HeapAlloc(GetProcessHeap(),
172 (wcslen(pwszCmdGroupToken) + 1) * sizeof(WCHAR));
173 if (pEntry->pwszCmdGroupToken == NULL)
174 {
176 return NULL;
177 }
178
179 wcscpy((LPWSTR)pEntry->pwszCmdGroupToken, pwszCmdGroupToken);
180 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
181 pEntry->dwFlags = dwFlags;
182 pEntry->pfnOsVersionCheck = pfnOsVersionCheck;
183
184 if (pContext->pGroupListHead == NULL && pContext->pGroupListTail == NULL)
185 {
186 pContext->pGroupListHead = pEntry;
187 pContext->pGroupListTail = pEntry;
188 }
189 else
190 {
191 pEntry->pPrev = pContext->pGroupListTail;
192 pContext->pGroupListTail->pNext = pEntry;
193 pContext->pGroupListTail = pEntry;
194 }
195
196 return pEntry;
197}
#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:121
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:120
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 39 of file context.c.

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

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 101 of file context.c.

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

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 201 of file context.c.

209{
211
212 if (pfnCmdHandler == NULL)
213 return NULL;
214
215 /* Allocate the entry */
217 if (pEntry == NULL)
218 return NULL;
219
220 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
222 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
223 if (pEntry->pwszCmdToken == NULL)
224 {
226 return NULL;
227 }
228
229 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
230
231 pEntry->pfnCmdHandler = pfnCmdHandler;
232 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
233 pEntry->dwCmdHlpToken = dwCmdHlpToken;
234 pEntry->dwFlags = dwFlags;
235 pEntry->pfnOsVersionCheck = pfnOsVersionCheck;
236
237 if (pGroup->pCommandListHead == NULL && pGroup->pCommandListTail == NULL)
238 {
239 pGroup->pCommandListHead = pEntry;
240 pGroup->pCommandListTail = pEntry;
241 }
242 else
243 {
244 pEntry->pPrev = pGroup->pCommandListTail;
245 pGroup->pCommandListTail->pNext = pEntry;
246 pGroup->pCommandListTail = pEntry;
247 }
248
249 return pEntry;
250}
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 517 of file context.c.

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

Referenced by CreateRootContext().

◆ CommitContext()

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

Definition at line 411 of file context.c.

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

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

Referenced by CommitContext(), and DumpContext().

◆ CreateRootContext()

BOOL CreateRootContext ( VOID  )

Definition at line 811 of file context.c.

812{
813 PCOMMAND_GROUP pGroup;
814
815 pRootContext = AddContext(NULL, L"netsh", NULL);
816 DPRINT("pRootContext: %p\n", pRootContext);
817 if (pRootContext == NULL)
818 return FALSE;
819
821
838
840 if (pGroup)
841 {
843 }
844
846 if (pGroup)
847 {
849 }
850
852 if (pGroup)
853 {
856 }
857
859 if (pGroup)
860 {
864 }
865
867
868 return TRUE;
869}
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:154
PCOMMAND_ENTRY AddContextCommand(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:101
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:757
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:555
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:517
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:795
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:500
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:627
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:482
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:720
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:534
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:645
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:39
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:609
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:684
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:575
PCOMMAND_ENTRY AddGroupCommand(PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:201
#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
HMODULE hModule
Definition: precomp.h:110

Referenced by wmain().

◆ DeleteContext()

VOID DeleteContext ( PWSTR  pszName)

Definition at line 309 of file context.c.

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

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 534 of file context.c.

542{
543 DPRINT("DumpCommand()\n");
544
546 pwszMachine,
549 pvData);
550}
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:332
_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 332 of file context.c.

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

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 555 of file context.c.

563{
564 DPRINT("ExecCommand()\n");
565
566 if (dwArgCount - dwCurrentIndex != 1)
567 return ERROR_SHOW_USAGE;
568
570}
#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 575 of file context.c.

583{
584 if (bOnline == FALSE)
586
587 *pbDone = TRUE;
588 return ERROR_SUCCESS;
589}
static BOOL bOnline
Definition: context.c:34
_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 904 of file context.c.

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

Referenced by PrintHelpers(), and RegisterContext().

◆ FindSubContextByGuid()

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

Definition at line 874 of file context.c.

877{
878 PCONTEXT_ENTRY pResultContext, pSubContext;
879
880 DPRINT("FindSubContextByGuid(%p)\n", pContext);
881 DPRINT("%lx <--> %lx\n", pContext->Guid.Data1, pGuid->Data1);
882
883 if (IsEqualGUID(&pContext->Guid, pGuid))
884 {
885 DPRINT("Found!\n");
886 return pContext;
887 }
888
889 pSubContext = pContext->pSubContextHead;
890 while (pSubContext)
891 {
892 pResultContext = FindSubContextByGuid(pSubContext, pGuid);
893 if (pResultContext)
894 return pResultContext;
895
896 pSubContext = pSubContext->pNext;
897 }
898
899 return NULL;
900}
#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 609 of file context.c.

617{
618 DPRINT("OfflineCommand()\n");
620 bOnline = FALSE;
621 return ERROR_SUCCESS;
622}
@ 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 627 of file context.c.

635{
636 DPRINT("OnlineCommand()\n");
638 bOnline = TRUE;
639 return ERROR_SUCCESS;
640}
@ 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 645 of file context.c.

653{
655
656 DPRINT("PopdCommand()\n");
657
658 if (pContextStackHead == NULL)
659 return ERROR_SUCCESS;
660
662
663 pCurrentContext = pEntry->pContext;
664
666 {
669 }
670 else
671 {
672 pContextStackHead = pEntry->pNext;
674 }
675
677
678 return ERROR_SUCCESS;
679}
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 684 of file context.c.

692{
694
695 DPRINT("PushdCommand()\n");
696
698 if (pEntry == NULL)
700
701 pEntry->pContext = pCurrentContext;
702 if (pContextStackHead == NULL)
703 {
706 }
707 else
708 {
709 pEntry->pNext = pContextStackHead;
712 }
713
714 return ERROR_SUCCESS;
715}

Referenced by CreateRootContext().

◆ RegisterContext()

DWORD WINAPI RegisterContext ( _In_ const NS_CONTEXT_ATTRIBUTES pChildContext)

Definition at line 915 of file context.c.

917{
918 PHELPER_ENTRY pHelper;
919 PCONTEXT_ENTRY pContext, pParentContext;
920 PCOMMAND_GROUP pGroup;
921 DWORD i, j;
922 DWORD dwError = ERROR_SUCCESS;
923
924 DPRINT("RegisterContext(%p)\n", pChildContext);
925 if (pChildContext == NULL)
926 {
927 DPRINT1("Invalid child context!\n");
929 }
930
931 if ((pChildContext->pwszContext == NULL) ||
932 (wcslen(pChildContext->pwszContext) == 0) ||
933 (wcschr(pChildContext->pwszContext, L' ') != 0) ||
934 (wcschr(pChildContext->pwszContext, L'=') != 0))
935 {
936 DPRINT1("Invalid context name!\n");
938 }
939
940 DPRINT("Name: %S\n", pChildContext->pwszContext);
941 DPRINT("Groups: %lu\n", pChildContext->ulNumGroups);
942 DPRINT("Top commands: %lu\n", pChildContext->ulNumTopCmds);
943
944 pHelper = FindHelper(&pChildContext->guidHelper, pHelperListHead);
945 DPRINT("Helper %p\n", pHelper);
946 pParentContext = pRootContext;
947 if (pHelper != NULL)
948 {
949 pParentContext = FindContextByGuid(&pHelper->ParentHelperGuid);
950 DPRINT("pParentContext %p\n", pParentContext);
951 if (pParentContext == NULL)
952 pParentContext = pRootContext;
953 }
954
955 pContext = AddContext(pParentContext, pChildContext->pwszContext, (GUID*)&pChildContext->guidHelper);
956 if (pContext != NULL)
957 {
958 pContext->pfnCommitFn = pChildContext->pfnCommitFn;
959 pContext->pfnDumpFn = pChildContext->pfnDumpFn;
960 pContext->pfnConnectFn = pChildContext->pfnConnectFn;
961 pContext->pfnOsVersionCheck = pChildContext->pfnOsVersionCheck;
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(pszMachine);
1007 DPRINT("pfnConnectFn(%S) returned %lu\n", pszMachine, dwError);
1008 }
1009 }
1010
1011 return dwError;
1012}
PCONTEXT_ENTRY FindContextByGuid(const GUID *pGuid)
Definition: context.c:904
PWSTR 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:114
ULONG ulPriority
Definition: precomp.h:111
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:112
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: precomp.h:113
PNS_OSVERSIONCHECK pfnOsVersionCheck
Definition: precomp.h:115
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 594 of file context.c.

602{
603 return ERROR_SUCCESS;
604}

◆ RemoveContextFromStack()

VOID RemoveContextFromStack ( _In_ PCONTEXT_ENTRY  pContextEntry)

Definition at line 254 of file context.c.

256{
257 PCONTEXT_STACK_ENTRY pStackEntry, pNextEntry;
258
259 if (pContextStackHead == NULL)
260 return;
261
262 pStackEntry = pContextStackHead;
263 while (1)
264 {
265 if (pStackEntry->pContext == pContextEntry)
266 {
267 if (pStackEntry == pContextStackHead && pStackEntry == pContextStackHead)
268 {
271 HeapFree(GetProcessHeap(), 0, pStackEntry);
272 return;
273 }
274 else if (pStackEntry == pContextStackHead)
275 {
276 pStackEntry->pNext->pPrev = NULL;
277 pContextStackHead = pStackEntry->pNext;
278 HeapFree(GetProcessHeap(), 0, pStackEntry);
279 pStackEntry = pContextStackHead;
280 }
281 else if (pStackEntry == pContextStackTail)
282 {
283 pStackEntry->pPrev->pNext = NULL;
284 pContextStackTail = pStackEntry->pPrev;
285 HeapFree(GetProcessHeap(), 0, pStackEntry);
286 return;
287 }
288 else
289 {
290 pNextEntry = pStackEntry->pNext;
291 pStackEntry->pPrev->pNext = pStackEntry->pNext;
292 pStackEntry->pNext->pPrev = pStackEntry->pPrev;
293 HeapFree(GetProcessHeap(), 0, pStackEntry);
294 pStackEntry = pNextEntry;
295 }
296 }
297 else
298 {
299 if (pStackEntry == pContextStackTail)
300 return;
301
302 pStackEntry = pStackEntry->pNext;
303 }
304 }
305}
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 720 of file context.c.

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

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 757 of file context.c.

765{
766 DWORD dwError = ERROR_SUCCESS;
767
768 DPRINT("SetModeCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
769 pwszMachine, dwCurrentIndex, dwArgCount);
770
771 if ((dwArgCount - dwCurrentIndex) != 1)
772 return ERROR_SHOW_USAGE;
773
774 if (!_wcsicmp(argv[dwCurrentIndex], L"offline"))
775 {
777 bOnline = FALSE;
778 }
779 else if (!_wcsicmp(argv[dwCurrentIndex], L"online"))
780 {
782 bOnline = TRUE;
783 }
784 else
785 {
786 dwError = ERROR_INVALID_SYNTAX;
787 }
788
789 return dwError;
790}
_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 795 of file context.c.

803{
804 DPRINT("ShowModeCommand()\n");
805 ConPuts(StdOut, bOnline ? L"online\n\n" : L"offline\n\n");
806 return ERROR_SUCCESS;
807}
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 482 of file context.c.

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

Referenced by CreateRootContext().

Variable Documentation

◆ bOnline

BOOL bOnline = TRUE
static

Definition at line 34 of file context.c.

Referenced by ExitCommand(), OfflineCommand(), OnlineCommand(), SetModeCommand(), and ShowModeCommand().

◆ 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

◆ pszMachine