ReactOS 0.4.17-dev-470-gf9e3448
context.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS NetSh
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Network Shell context management functions
5 * COPYRIGHT: Copyright 2023 Eric Kohl <eric.kohl@reactos.org>
6 */
7
8/* INCLUDES *******************************************************************/
9
10#include "precomp.h"
11
12#define NDEBUG
13#include <debug.h>
14
15/* GLOBALS ********************************************************************/
16
18{
21
24
25
28
31
33
34static BOOL bOnline = TRUE;
35
36/* FUNCTIONS ******************************************************************/
37
40 PCONTEXT_ENTRY pParentContext,
41 PWSTR pszName,
42 GUID *pGuid)
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}
98
99
103 LPCWSTR pwszCmdToken,
104 PFN_HANDLE_CMD pfnCmdHandler,
105 DWORD dwShortCmdHelpToken,
106 DWORD dwCmdHlpToken,
108 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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
138 {
141 }
142 else
143 {
147 }
148
149 return pEntry;
150}
151
152
156 LPCWSTR pwszCmdGroupToken,
157 DWORD dwShortCmdHelpToken,
159 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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
185 {
188 }
189 else
190 {
194 }
195
196 return pEntry;
197}
198
199
202 PCOMMAND_GROUP pGroup,
203 LPCWSTR pwszCmdToken,
204 PFN_HANDLE_CMD pfnCmdHandler,
205 DWORD dwShortCmdHelpToken,
206 DWORD dwCmdHlpToken,
208 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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}
251
252
253VOID
255 _In_ PCONTEXT_ENTRY pContextEntry)
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}
306
307
308VOID
310 PWSTR pszName)
311{
312 /* Remove the context from the stack */
313 /* RemoveContextFromStack(); */
314
315 /* Delete all commands */
316 /* Delete the context */
317}
318
319
320static
321int
323 _In_ const void *p1,
324 _In_ const void *p2)
325{
326 return ((PCONTEXT_ENTRY)p1)->ulPriority - ((PCONTEXT_ENTRY)p2)->ulPriority;
327}
328
329
330static
331DWORD
334 _In_ LPCWSTR pwszMachine,
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
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}
408
409static
410DWORD
413 _In_ DWORD dwAction)
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
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
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}
478
479
480DWORD
481WINAPI
483 _In_ LPCWSTR pwszMachine,
490{
493
494 return ERROR_SUCCESS;
495}
496
497
498DWORD
499WINAPI
501 _In_ LPCWSTR pwszMachine,
508{
509 DPRINT("AbortCommand()\n");
511 return ERROR_SUCCESS;
512}
513
514
515DWORD
516WINAPI
518 _In_ LPCWSTR pwszMachine,
525{
526 DPRINT("CommitCommand()\n");
528 return ERROR_SUCCESS;
529}
530
531
532DWORD
533WINAPI
535 _In_ LPCWSTR pwszMachine,
542{
543 DPRINT("DumpCommand()\n");
544
546 pwszMachine,
549 pvData);
550}
551
552
553DWORD
554WINAPI
556 _In_ LPCWSTR pwszMachine,
563{
564 DPRINT("ExecCommand()\n");
565
566 if (dwArgCount - dwCurrentIndex != 1)
567 return ERROR_SHOW_USAGE;
568
570}
571
572
573DWORD
574WINAPI
576 _In_ LPCWSTR pwszMachine,
583{
584 if (bOnline == FALSE)
586
587 *pbDone = TRUE;
588 return ERROR_SUCCESS;
589}
590
591
592DWORD
593WINAPI
595 _In_ LPCWSTR pwszMachine,
602{
603 return ERROR_SUCCESS;
604}
605
606
607DWORD
608WINAPI
610 _In_ LPCWSTR pwszMachine,
617{
618 DPRINT("OfflineCommand()\n");
620 bOnline = FALSE;
621 return ERROR_SUCCESS;
622}
623
624
625DWORD
626WINAPI
628 _In_ LPCWSTR pwszMachine,
635{
636 DPRINT("OnlineCommand()\n");
638 bOnline = TRUE;
639 return ERROR_SUCCESS;
640}
641
642
643DWORD
644WINAPI
646 _In_ LPCWSTR pwszMachine,
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}
680
681
682DWORD
683WINAPI
685 _In_ LPCWSTR pwszMachine,
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}
716
717
718DWORD
719WINAPI
721 _In_ LPCWSTR pwszMachine,
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}
753
754
755DWORD
756WINAPI
758 _In_ LPCWSTR pwszMachine,
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}
791
792
793DWORD
794WINAPI
796 _In_ LPCWSTR pwszMachine,
803{
804 DPRINT("ShowModeCommand()\n");
805 ConPuts(StdOut, bOnline ? L"online\n\n" : L"offline\n\n");
806 return ERROR_SUCCESS;
807}
808
809
810BOOL
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}
870
871
872static
876 const GUID *pGuid)
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}
901
902
905 const GUID *pGuid)
906{
907 if (pRootContext == NULL)
908 return NULL;
909 return FindSubContextByGuid(pRootContext, pGuid);
910}
911
912
913DWORD
914WINAPI
916 _In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
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 {
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
1005 {
1006 dwError = pContext->pfnConnectFn(pszMachine);
1007 DPRINT("pfnConnectFn(%S) returned %lu\n", pszMachine, dwError);
1008 }
1009 }
1010
1011 return dwError;
1012}
1013
1014
1015VOID
1017{
1018 /* Delete the context stack */
1019
1020}
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
PCONTEXT_ENTRY FindContextByGuid(const GUID *pGuid)
Definition: context.c:904
static BOOL bOnline
Definition: context.c:34
PCONTEXT_STACK_ENTRY pContextStackHead
Definition: context.c:29
PCOMMAND_GROUP AddCommandGroup(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags, PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: context.c:154
struct _CONTEXT_STACK_ENTRY * PCONTEXT_STACK_ENTRY
BOOL CreateRootContext(VOID)
Definition: context.c:811
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 RegisterContext(_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
Definition: context.c:915
PCONTEXT_ENTRY pRootContext
Definition: context.c:26
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
VOID CleanupContext(VOID)
Definition: context.c:1016
VOID RemoveContextFromStack(_In_ PCONTEXT_ENTRY pContextEntry)
Definition: context.c:254
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
static int ContextCompare(_In_ const void *p1, _In_ const void *p2)
Definition: context.c:322
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: context.c:594
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
PWSTR pszMachine
Definition: context.c:32
static PCONTEXT_ENTRY FindSubContextByGuid(PCONTEXT_ENTRY pContext, const GUID *pGuid)
Definition: context.c:874
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
struct _CONTEXT_STACK_ENTRY CONTEXT_STACK_ENTRY
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
VOID DeleteContext(PWSTR pszName)
Definition: context.c:309
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:39
static DWORD CommitContext(_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
Definition: context.c:411
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
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:332
PCONTEXT_STACK_ENTRY pContextStackTail
Definition: context.c:30
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
struct _CONTEXT_ENTRY * PCONTEXT_ENTRY
#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 DPRINT1
Definition: precomp.h:8
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
#define StdOut
Definition: conutils_noros.h:6
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
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
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
PHELPER_ENTRY pHelperListHead
Definition: helper.c:20
if(dx< 0)
Definition: linetemp.h:194
#define CopyMemory
Definition: minwinbase.h:29
CONST void * LPCVOID
Definition: minwindef.h:164
#define argv
Definition: mplay32.c:18
DWORD RunScript(_In_ LPCWSTR filename)
Definition: netsh.c:22
HMODULE g_hModule
Definition: netsh.c:17
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
FN_HANDLE_CMD * PFN_HANDLE_CMD
Definition: netsh.h:145
@ CMD_FLAG_PRIORITY
Definition: netsh.h:48
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10
NS_OSVERSIONCHECK * PNS_OSVERSIONCHECK
Definition: netsh.h:132
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
#define DEFAULT_CONTEXT_PRIORITY
Definition: netsh.h:60
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115
#define ERROR_SHOW_USAGE
Definition: netsh.h:22
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD _In_ LPCVOID _Out_ BOOL * pbDone
Definition: netsh.h:143
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139
@ NETSH_COMMIT
Definition: netsh.h:53
@ NETSH_FLUSH
Definition: netsh.h:55
@ NETSH_SAVE
Definition: netsh.h:57
@ NETSH_UNCOMMIT
Definition: netsh.h:54
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
short WCHAR
Definition: pedump.c:58
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
wcscpy
#define DPRINT
Definition: sndvol32.h:73
Definition: precomp.h:74
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:76
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:97
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:96
struct _COMMAND_GROUP * pNext
Definition: precomp.h:89
DWORD dwShortCmdHelpToken
Definition: precomp.h:92
Definition: precomp.h:101
PNS_CONTEXT_CONNECT_FN pfnConnectFn
Definition: precomp.h:114
PWSTR pszContextName
Definition: precomp.h:108
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:118
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:121
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:123
ULONG ulPriority
Definition: precomp.h:111
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:112
HMODULE hModule
Definition: precomp.h:110
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:105
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:103
GUID Guid
Definition: precomp.h:109
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: precomp.h:113
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:120
PNS_OSVERSIONCHECK pfnOsVersionCheck
Definition: precomp.h:115
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:117
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:124
Definition: context.c:18
PCONTEXT_ENTRY pContext
Definition: context.c:22
struct _CONTEXT_STACK_ENTRY * pNext
Definition: context.c:20
struct _CONTEXT_STACK_ENTRY * pPrev
Definition: context.c:19
HMODULE hModule
Definition: precomp.h:53
Definition: precomp.h:58
PDLL_LIST_ENTRY pDllEntry
Definition: precomp.h:65
GUID ParentHelperGuid
Definition: precomp.h:63
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
#define WINAPI
Definition: msvc.h:6