ReactOS 0.4.17-dev-573-g8315b8c
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
34
35/* FUNCTIONS ******************************************************************/
36
39 PCONTEXT_ENTRY pParentContext,
40 PWSTR pszName,
41 GUID *pGuid)
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}
97
98
102 LPCWSTR pwszCmdToken,
103 PFN_HANDLE_CMD pfnCmdHandler,
104 DWORD dwShortCmdHelpToken,
105 DWORD dwCmdHlpToken,
107 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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
137 {
140 }
141 else
142 {
146 }
147
148 return pEntry;
149}
150
151
155 LPCWSTR pwszCmdGroupToken,
156 DWORD dwShortCmdHelpToken,
158 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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
184 {
187 }
188 else
189 {
193 }
194
195 return pEntry;
196}
197
198
201 PCOMMAND_GROUP pGroup,
202 LPCWSTR pwszCmdToken,
203 PFN_HANDLE_CMD pfnCmdHandler,
204 DWORD dwShortCmdHelpToken,
205 DWORD dwCmdHlpToken,
207 PNS_OSVERSIONCHECK pfnOsVersionCheck)
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}
250
251
252VOID
254 _In_ PCONTEXT_ENTRY pContextEntry)
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}
305
306
307VOID
309 PWSTR pszName)
310{
311 /* Remove the context from the stack */
312 /* RemoveContextFromStack(); */
313
314 /* Delete all commands */
315 /* Delete the context */
316}
317
318
319static
320int
322 _In_ const void *p1,
323 _In_ const void *p2)
324{
325 return ((PCONTEXT_ENTRY)p1)->ulPriority - ((PCONTEXT_ENTRY)p2)->ulPriority;
326}
327
328
329static
330DWORD
333 _In_ LPCWSTR pwszMachine,
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
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}
407
408static
409DWORD
412 _In_ DWORD dwAction)
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
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
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}
477
478
479DWORD
480WINAPI
482 _In_ LPCWSTR pwszMachine,
489{
492
493 return ERROR_SUCCESS;
494}
495
496
497DWORD
498WINAPI
500 _In_ LPCWSTR pwszMachine,
507{
508 DPRINT("AbortCommand()\n");
510 return ERROR_SUCCESS;
511}
512
513
514DWORD
515WINAPI
517 _In_ LPCWSTR pwszMachine,
524{
525 DPRINT("CommitCommand()\n");
527 return ERROR_SUCCESS;
528}
529
530
531DWORD
532WINAPI
534 _In_ LPCWSTR pwszMachine,
541{
542 DPRINT("DumpCommand()\n");
543
545 pwszMachine,
548 pvData);
549}
550
551
552DWORD
553WINAPI
555 _In_ LPCWSTR pwszMachine,
562{
563 DPRINT("ExecCommand()\n");
564
565 if (dwArgCount - dwCurrentIndex != 1)
566 return ERROR_SHOW_USAGE;
567
569}
570
571
572DWORD
573WINAPI
575 _In_ LPCWSTR pwszMachine,
582{
583 if (g_bOnline == FALSE)
585
586 *pbDone = TRUE;
587 return ERROR_SUCCESS;
588}
589
590
591DWORD
592WINAPI
594 _In_ LPCWSTR pwszMachine,
601{
602 return ERROR_SUCCESS;
603}
604
605
606DWORD
607WINAPI
609 _In_ LPCWSTR pwszMachine,
616{
617 DPRINT("OfflineCommand()\n");
620 return ERROR_SUCCESS;
621}
622
623
624DWORD
625WINAPI
627 _In_ LPCWSTR pwszMachine,
634{
635 DPRINT("OnlineCommand()\n");
637 g_bOnline = TRUE;
638 return ERROR_SUCCESS;
639}
640
641
642DWORD
643WINAPI
645 _In_ LPCWSTR pwszMachine,
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}
679
680
681DWORD
682WINAPI
684 _In_ LPCWSTR pwszMachine,
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}
715
716
717DWORD
718WINAPI
720 _In_ LPCWSTR pwszMachine,
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}
752
753
754DWORD
755WINAPI
757 _In_ LPCWSTR pwszMachine,
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}
790
791
792DWORD
793WINAPI
795 _In_ LPCWSTR pwszMachine,
802{
803 DPRINT("ShowModeCommand()\n");
804 ConPuts(StdOut, g_bOnline ? L"online\n\n" : L"offline\n\n");
805 return ERROR_SUCCESS;
806}
807
808
809BOOL
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}
869
870
871static
875 const GUID *pGuid)
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}
900
901
904 const GUID *pGuid)
905{
906 if (pRootContext == NULL)
907 return NULL;
908 return FindSubContextByGuid(pRootContext, pGuid);
909}
910
911
912DWORD
913WINAPI
915 _In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
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 {
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 {
1007 DPRINT("pfnConnectFn(%S) returned %lu\n", g_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
BOOL g_bOnline
Definition: context.c:33
PCONTEXT_ENTRY FindContextByGuid(const GUID *pGuid)
Definition: context.c:903
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:153
struct _CONTEXT_STACK_ENTRY * PCONTEXT_STACK_ENTRY
BOOL CreateRootContext(VOID)
Definition: context.c:810
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 RegisterContext(_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
Definition: context.c:914
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: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
VOID CleanupContext(VOID)
Definition: context.c:1016
VOID RemoveContextFromStack(_In_ PCONTEXT_ENTRY pContextEntry)
Definition: context.c:253
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
static int ContextCompare(_In_ const void *p1, _In_ const void *p2)
Definition: context.c:321
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:593
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
static PCONTEXT_ENTRY FindSubContextByGuid(PCONTEXT_ENTRY pContext, const GUID *pGuid)
Definition: context.c:873
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
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:644
PWSTR g_pszMachine
Definition: context.c:32
VOID DeleteContext(PWSTR pszName)
Definition: context.c:308
PCONTEXT_ENTRY AddContext(PCONTEXT_ENTRY pParentContext, PWSTR pszName, GUID *pGuid)
Definition: context.c:38
static DWORD CommitContext(_In_ PCONTEXT_ENTRY pContext, _In_ DWORD dwAction)
Definition: context.c:410
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
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:331
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:200
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_ONLINE
Definition: netsh.h:45
@ CMD_FLAG_PRIORITY
Definition: netsh.h:48
@ CMD_FLAG_LOCAL
Definition: netsh.h:44
#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:115
PWSTR pszContextName
Definition: precomp.h:108
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:119
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:122
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:124
ULONG ulPriority
Definition: precomp.h:111
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:113
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:114
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:121
PNS_OSVERSIONCHECK pfnOsVersionCheck
Definition: precomp.h:116
DWORD dwFlags
Definition: precomp.h:112
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:118
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:125
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