ReactOS 0.4.16-dev-1946-g52006dd
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{
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
136 {
139 }
140 else
141 {
145 }
146
147 return pEntry;
148}
149
150
154 LPCWSTR pwszCmdGroupToken,
155 DWORD dwShortCmdHelpToken,
157{
159
160 DPRINT("AddCommandGroup(%S %lu)\n", pwszCmdGroupToken, dwShortCmdHelpToken);
161
162 /* Allocate the entry */
164 if (pEntry == NULL)
165 return NULL;
166
167 pEntry->pwszCmdGroupToken = HeapAlloc(GetProcessHeap(),
169 (wcslen(pwszCmdGroupToken) + 1) * sizeof(WCHAR));
170 if (pEntry->pwszCmdGroupToken == NULL)
171 {
173 return NULL;
174 }
175
176 wcscpy((LPWSTR)pEntry->pwszCmdGroupToken, pwszCmdGroupToken);
177 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
178 pEntry->dwFlags = dwFlags;
179
181 {
184 }
185 else
186 {
190 }
191
192 return pEntry;
193}
194
195
198 PCOMMAND_GROUP pGroup,
199 LPCWSTR pwszCmdToken,
200 PFN_HANDLE_CMD pfnCmdHandler,
201 DWORD dwShortCmdHelpToken,
202 DWORD dwCmdHlpToken,
204{
206
207 if (pfnCmdHandler == NULL)
208 return NULL;
209
210 /* Allocate the entry */
212 if (pEntry == NULL)
213 return NULL;
214
215 pEntry->pwszCmdToken = HeapAlloc(GetProcessHeap(),
217 (wcslen(pwszCmdToken) + 1) * sizeof(WCHAR));
218 if (pEntry->pwszCmdToken == NULL)
219 {
221 return NULL;
222 }
223
224 wcscpy((LPWSTR)pEntry->pwszCmdToken, pwszCmdToken);
225
226 pEntry->pfnCmdHandler = pfnCmdHandler;
227 pEntry->dwShortCmdHelpToken = dwShortCmdHelpToken;
228 pEntry->dwCmdHlpToken = dwCmdHlpToken;
229 pEntry->dwFlags = dwFlags;
230
231 if (pGroup->pCommandListHead == NULL && pGroup->pCommandListTail == NULL)
232 {
233 pGroup->pCommandListHead = pEntry;
234 pGroup->pCommandListTail = pEntry;
235 }
236 else
237 {
238 pEntry->pPrev = pGroup->pCommandListTail;
239 pGroup->pCommandListTail->pNext = pEntry;
240 pGroup->pCommandListTail = pEntry;
241 }
242
243 return pEntry;
244}
245
246
247VOID
249 _In_ PCONTEXT_ENTRY pContextEntry)
250{
251 PCONTEXT_STACK_ENTRY pStackEntry, pNextEntry;
252
253 if (pContextStackHead == NULL)
254 return;
255
256 pStackEntry = pContextStackHead;
257 while (1)
258 {
259 if (pStackEntry->pContext == pContextEntry)
260 {
261 if (pStackEntry == pContextStackHead && pStackEntry == pContextStackHead)
262 {
265 HeapFree(GetProcessHeap(), 0, pStackEntry);
266 return;
267 }
268 else if (pStackEntry == pContextStackHead)
269 {
270 pStackEntry->pNext->pPrev = NULL;
271 pContextStackHead = pStackEntry->pNext;
272 HeapFree(GetProcessHeap(), 0, pStackEntry);
273 pStackEntry = pContextStackHead;
274 }
275 else if (pStackEntry == pContextStackTail)
276 {
277 pStackEntry->pPrev->pNext = NULL;
278 pContextStackTail = pStackEntry->pPrev;
279 HeapFree(GetProcessHeap(), 0, pStackEntry);
280 return;
281 }
282 else
283 {
284 pNextEntry = pStackEntry->pNext;
285 pStackEntry->pPrev->pNext = pStackEntry->pNext;
286 pStackEntry->pNext->pPrev = pStackEntry->pPrev;
287 HeapFree(GetProcessHeap(), 0, pStackEntry);
288 pStackEntry = pNextEntry;
289 }
290 }
291 else
292 {
293 if (pStackEntry == pContextStackTail)
294 return;
295
296 pStackEntry = pStackEntry->pNext;
297 }
298 }
299}
300
301
302VOID
304 PWSTR pszName)
305{
306 /* Remove the context from the stack */
307 /* RemoveContextFromStack(); */
308
309 /* Delete all commands */
310 /* Delete the context */
311}
312
313
314static
315int
317 _In_ const void *p1,
318 _In_ const void *p2)
319{
320 return ((PCONTEXT_ENTRY)p1)->ulPriority - ((PCONTEXT_ENTRY)p2)->ulPriority;
321}
322
323
324static
325DWORD
328 _In_ LPCWSTR pwszMachine,
332{
333 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
334 DWORD dwCount, dwIndex;
335 DWORD dwError = ERROR_SUCCESS;
336
337 DPRINT("DumpContext()\n");
338
339 if (pContext->pfnDumpFn)
340 {
341 dwError = pContext->pfnDumpFn(pwszMachine,
344 pvData);
345 if (dwError != ERROR_SUCCESS)
346 {
347 DPRINT1("Dump function failed (Error %lu)\n", dwError);
348 return dwError;
349 }
350 }
351
353 return dwError;
354
355 /* Count the sub-contexts */
356 dwCount = 0;
357 pSubContext = pContext->pSubContextHead;
358 while (pSubContext)
359 {
360 dwCount++;
361 pSubContext = pSubContext->pNext;
362 }
363
364 /* Allocate the sort array */
365 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
366 if (pSortArray == NULL)
368
369 /* Fill the sort array */
370 dwIndex = 0;
371 pSubContext = pContext->pSubContextHead;
372 while (pSubContext)
373 {
374 pSortArray[dwIndex] = pSubContext;
375 dwIndex++;
376 pSubContext = pSubContext->pNext;
377 }
378
379 /* Sort the array */
380 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
381
382 /* Dump the sub-contexts */
383 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
384 {
385 dwError = DumpContext(pSortArray[dwIndex],
386 pwszMachine,
389 pvData);
390 if (dwError != ERROR_SUCCESS)
391 {
392 DPRINT1("Dump function failed (Error %lu)\n", dwError);
393 break;
394 }
395 }
396
397 /* Free the sort array */
398 HeapFree(GetProcessHeap(), 0, pSortArray);
399
400 return dwError;
401}
402
403static
404DWORD
407 _In_ DWORD dwAction)
408{
409 PCONTEXT_ENTRY pSubContext, *pSortArray = NULL;
410 DWORD dwCount, dwIndex;
411 DWORD dwError = ERROR_SUCCESS;
412
413 DPRINT1("CommitContext(%p %lu)\n", pContext, dwAction);
414
416 {
417 dwError = pContext->pfnCommitFn(dwAction);
418 if (dwError != ERROR_SUCCESS)
419 {
420 DPRINT1("Commit function failed (Error %lu)\n", dwError);
421 return dwError;
422 }
423 }
424
426 return dwError;
427
428 /* Count the sub-contexts */
429 dwCount = 0;
430 pSubContext = pContext->pSubContextHead;
431 while (pSubContext)
432 {
433 dwCount++;
434 pSubContext = pSubContext->pNext;
435 }
436
437 /* Allocate the sort array */
438 pSortArray = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(PCONTEXT_ENTRY));
439 if (pSortArray == NULL)
441
442 /* Fill the sort array */
443 dwIndex = 0;
444 pSubContext = pContext->pSubContextHead;
445 while (pSubContext)
446 {
447 pSortArray[dwIndex] = pSubContext;
448 dwIndex++;
449 pSubContext = pSubContext->pNext;
450 }
451
452 /* Sort the array */
453 qsort(pSortArray, dwCount, sizeof(PCONTEXT_ENTRY), ContextCompare);
454
455 /* Commit the sub-contexts */
456 for (dwIndex = 0; dwIndex < dwCount; dwIndex++)
457 {
458 dwError = CommitContext(pSortArray[dwIndex],
459 dwAction);
460 if (dwError != ERROR_SUCCESS)
461 {
462 DPRINT1("Commit function failed (Error %lu)\n", dwError);
463 break;
464 }
465 }
466
467 /* Free the sort array */
468 HeapFree(GetProcessHeap(), 0, pSortArray);
469
470 return dwError;
471}
472
473
474DWORD
475WINAPI
477 _In_ LPCWSTR pwszMachine,
484{
487
488 return ERROR_SUCCESS;
489}
490
491
492DWORD
493WINAPI
495 _In_ LPCWSTR pwszMachine,
502{
503 DPRINT("AbortCommand()\n");
505 return ERROR_SUCCESS;
506}
507
508
509DWORD
510WINAPI
512 _In_ LPCWSTR pwszMachine,
519{
520 DPRINT("CommitCommand()\n");
522 return ERROR_SUCCESS;
523}
524
525
526DWORD
527WINAPI
529 _In_ LPCWSTR pwszMachine,
536{
537 DPRINT("DumpCommand()\n");
538
540 pwszMachine,
543 pvData);
544}
545
546
547DWORD
548WINAPI
550 _In_ LPCWSTR pwszMachine,
557{
558 DPRINT("ExecCommand()\n");
559
560 if (dwArgCount - dwCurrentIndex != 1)
561 return ERROR_SHOW_USAGE;
562
564}
565
566
567DWORD
568WINAPI
570 _In_ LPCWSTR pwszMachine,
577{
578 if (bOnline == FALSE)
580
581 *pbDone = TRUE;
582 return ERROR_SUCCESS;
583}
584
585
586DWORD
587WINAPI
589 _In_ LPCWSTR pwszMachine,
596{
597 return ERROR_SUCCESS;
598}
599
600
601DWORD
602WINAPI
604 _In_ LPCWSTR pwszMachine,
611{
612 DPRINT("OfflineCommand()\n");
614 bOnline = FALSE;
615 return ERROR_SUCCESS;
616}
617
618
619DWORD
620WINAPI
622 _In_ LPCWSTR pwszMachine,
629{
630 DPRINT("OnlineCommand()\n");
632 bOnline = TRUE;
633 return ERROR_SUCCESS;
634}
635
636
637DWORD
638WINAPI
640 _In_ LPCWSTR pwszMachine,
647{
649
650 DPRINT("PopdCommand()\n");
651
652 if (pContextStackHead == NULL)
653 return ERROR_SUCCESS;
654
656
657 pCurrentContext = pEntry->pContext;
658
660 {
663 }
664 else
665 {
666 pContextStackHead = pEntry->pNext;
668 }
669
671
672 return ERROR_SUCCESS;
673}
674
675
676DWORD
677WINAPI
679 _In_ LPCWSTR pwszMachine,
686{
688
689 DPRINT("PushdCommand()\n");
690
692 if (pEntry == NULL)
694
695 pEntry->pContext = pCurrentContext;
696 if (pContextStackHead == NULL)
697 {
700 }
701 else
702 {
703 pEntry->pNext = pContextStackHead;
706 }
707
708 return ERROR_SUCCESS;
709}
710
711
712DWORD
713WINAPI
715 _In_ LPCWSTR pwszMachine,
722{
723 DWORD dwError = ERROR_SUCCESS;
724
725 DPRINT("SetMachineCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
726 pwszMachine, dwCurrentIndex, dwArgCount);
727
728 if ((dwArgCount - dwCurrentIndex) > 1)
729 return ERROR_SHOW_USAGE;
730
731 if (pszMachine != NULL)
732 {
735 }
736
737 if ((dwArgCount - dwCurrentIndex) == 1)
738 {
739 pszMachine = HeapAlloc(GetProcessHeap(), 0, (sizeof(argv[dwCurrentIndex]) + 1) * sizeof(WCHAR));
740 if (pszMachine == NULL)
743 }
744
745 return dwError;
746}
747
748
749DWORD
750WINAPI
752 _In_ LPCWSTR pwszMachine,
759{
760 DWORD dwError = ERROR_SUCCESS;
761
762 DPRINT("SetModeCommand(pwszMachine %S dwCurrentIndex %lu dwArgCount %lu)\n",
763 pwszMachine, dwCurrentIndex, dwArgCount);
764
765 if ((dwArgCount - dwCurrentIndex) != 1)
766 return ERROR_SHOW_USAGE;
767
768 if (!_wcsicmp(argv[dwCurrentIndex], L"offline"))
769 {
771 bOnline = FALSE;
772 }
773 else if (!_wcsicmp(argv[dwCurrentIndex], L"online"))
774 {
776 bOnline = TRUE;
777 }
778 else
779 {
780 dwError = ERROR_INVALID_SYNTAX;
781 }
782
783 return dwError;
784}
785
786
787DWORD
788WINAPI
790 _In_ LPCWSTR pwszMachine,
797{
798 DPRINT("ShowModeCommand()\n");
799 ConPuts(StdOut, bOnline ? L"online\n\n" : L"offline\n\n");
800 return ERROR_SUCCESS;
801}
802
803
804BOOL
806{
807 PCOMMAND_GROUP pGroup;
808
809 pRootContext = AddContext(NULL, L"netsh", NULL);
810 DPRINT("pRootContext: %p\n", pRootContext);
811 if (pRootContext == NULL)
812 return FALSE;
813
815
832
834 if (pGroup)
835 {
837 }
838
839 pGroup = AddCommandGroup(pRootContext, L"delete", IDS_HLP_GROUP_DELETE, 0);
840 if (pGroup)
841 {
843 }
844
846 if (pGroup)
847 {
850 }
851
853 if (pGroup)
854 {
858 }
859
861
862 return TRUE;
863}
864
865
866static
870 const GUID *pGuid)
871{
872 PCONTEXT_ENTRY pResultContext, pSubContext;
873
874 DPRINT("FindSubContextByGuid(%p)\n", pContext);
875 DPRINT("%lx <--> %lx\n", pContext->Guid.Data1, pGuid->Data1);
876
877 if (IsEqualGUID(&pContext->Guid, pGuid))
878 {
879 DPRINT("Found!\n");
880 return pContext;
881 }
882
883 pSubContext = pContext->pSubContextHead;
884 while (pSubContext)
885 {
886 pResultContext = FindSubContextByGuid(pSubContext, pGuid);
887 if (pResultContext)
888 return pResultContext;
889
890 pSubContext = pSubContext->pNext;
891 }
892
893 return NULL;
894}
895
896
899 const GUID *pGuid)
900{
901 if (pRootContext == NULL)
902 return NULL;
903 return FindSubContextByGuid(pRootContext, pGuid);
904}
905
906
907DWORD
908WINAPI
910 _In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
911{
912 PHELPER_ENTRY pHelper;
913 PCONTEXT_ENTRY pContext, pParentContext;
914 PCOMMAND_GROUP pGroup;
915 DWORD i, j;
916
917 DPRINT1("RegisterContext(%p)\n", pChildContext);
918 if (pChildContext == NULL)
919 {
920 DPRINT1("Invalid child context!\n");
922 }
923
924 if ((pChildContext->pwszContext == NULL) ||
925 (wcslen(pChildContext->pwszContext) == 0) ||
926 (wcschr(pChildContext->pwszContext, L' ') != 0) ||
927 (wcschr(pChildContext->pwszContext, L'=') != 0))
928 {
929 DPRINT1("Invalid context name!\n");
931 }
932
933 DPRINT("Name: %S\n", pChildContext->pwszContext);
934 DPRINT("Groups: %lu\n", pChildContext->ulNumGroups);
935 DPRINT("Top commands: %lu\n", pChildContext->ulNumTopCmds);
936
937 pHelper = FindHelper(&pChildContext->guidHelper, pHelperListHead);
938 DPRINT("Helper %p\n", pHelper);
939 pParentContext = pRootContext;
940 if (pHelper != NULL)
941 {
942 pParentContext = FindContextByGuid(&pHelper->ParentHelperGuid);
943 DPRINT("pParentContext %p\n", pParentContext);
944 if (pParentContext == NULL)
945 pParentContext = pRootContext;
946 }
947
948 pContext = AddContext(pParentContext, pChildContext->pwszContext, (GUID*)&pChildContext->guidHelper);
949 if (pContext != NULL)
950 {
951 pContext->pfnCommitFn = pChildContext->pfnCommitFn;
952 pContext->pfnDumpFn = pChildContext->pfnDumpFn;
953 pContext->pfnConnectFn = pChildContext->pfnConnectFn;
954 pContext->ulPriority = (pChildContext->dwFlags & CMD_FLAG_PRIORITY) ?
955 pChildContext->ulPriority : DEFAULT_CONTEXT_PRIORITY;
956
957 if ((pHelper != NULL) && (pHelper->pDllEntry != NULL))
958 {
959 pContext->hModule = pHelper->pDllEntry->hModule;
960 }
961
962 for (i = 0; i < pChildContext->ulNumTopCmds; i++)
963 {
965 pChildContext->pTopCmds[i].pwszCmdToken,
966 pChildContext->pTopCmds[i].pfnCmdHandler,
967 pChildContext->pTopCmds[i].dwShortCmdHelpToken,
968 pChildContext->pTopCmds[i].dwCmdHlpToken,
969 pChildContext->pTopCmds[i].dwFlags);
970 }
971
972 /* Add command groups */
973 for (i = 0; i < pChildContext->ulNumGroups; i++)
974 {
975 pGroup = AddCommandGroup(pContext,
976 pChildContext->pCmdGroups[i].pwszCmdGroupToken,
977 pChildContext->pCmdGroups[i].dwShortCmdHelpToken,
978 pChildContext->pCmdGroups[i].dwFlags);
979 if (pGroup != NULL)
980 {
981 for (j = 0; j < pChildContext->pCmdGroups[i].ulCmdGroupSize; j++)
982 {
983 AddGroupCommand(pGroup,
984 pChildContext->pCmdGroups[i].pCmdGroup[j].pwszCmdToken,
985 pChildContext->pCmdGroups[i].pCmdGroup[j].pfnCmdHandler,
986 pChildContext->pCmdGroups[i].pCmdGroup[j].dwShortCmdHelpToken,
987 pChildContext->pCmdGroups[i].pCmdGroup[j].dwCmdHlpToken,
988 pChildContext->pCmdGroups[i].pCmdGroup[j].dwFlags);
989 }
990 }
991 }
992 }
993
994 return ERROR_SUCCESS;
995}
996
997
998VOID
1000{
1001 /* Delete the context stack */
1002
1003}
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
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:898
static BOOL bOnline
Definition: context.c:34
PCONTEXT_STACK_ENTRY pContextStackHead
Definition: context.c:29
struct _CONTEXT_STACK_ENTRY * PCONTEXT_STACK_ENTRY
BOOL CreateRootContext(VOID)
Definition: context.c:805
PCOMMAND_GROUP AddCommandGroup(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdGroupToken, DWORD dwShortCmdHelpToken, DWORD dwFlags)
Definition: context.c:152
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:751
DWORD WINAPI RegisterContext(_In_ const NS_CONTEXT_ATTRIBUTES *pChildContext)
Definition: context.c:909
PCOMMAND_ENTRY AddContextCommand(PCONTEXT_ENTRY pContext, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:101
PCOMMAND_ENTRY AddGroupCommand(PCOMMAND_GROUP pGroup, LPCWSTR pwszCmdToken, PFN_HANDLE_CMD pfnCmdHandler, DWORD dwShortCmdHelpToken, DWORD dwCmdHlpToken, DWORD dwFlags)
Definition: context.c:197
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:549
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:511
VOID CleanupContext(VOID)
Definition: context.c:999
VOID RemoveContextFromStack(_In_ PCONTEXT_ENTRY pContextEntry)
Definition: context.c:248
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:789
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:494
static int ContextCompare(_In_ const void *p1, _In_ const void *p2)
Definition: context.c:316
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:588
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:621
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:476
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:714
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:868
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:528
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:639
VOID DeleteContext(PWSTR pszName)
Definition: context.c:303
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:405
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:603
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:678
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:569
static DWORD DumpContext(_In_ PCONTEXT_ENTRY pContext, _In_ LPCWSTR pwszMachine, _In_ LPWSTR *ppwcArguments, _In_ DWORD dwArgCount, _In_ LPCVOID pvData)
Definition: context.c:326
PCONTEXT_STACK_ENTRY pContextStackTail
Definition: context.c:30
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
wcscpy
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#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
#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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
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 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
_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
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define DPRINT
Definition: sndvol32.h:73
Definition: precomp.h:80
struct _COMMAND_ENTRY * pNext
Definition: precomp.h:82
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:101
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:100
struct _COMMAND_GROUP * pNext
Definition: precomp.h:94
DWORD dwShortCmdHelpToken
Definition: precomp.h:97
Definition: precomp.h:105
PNS_CONTEXT_CONNECT_FN pfnConnectFn
Definition: precomp.h:118
PWSTR pszContextName
Definition: precomp.h:112
PCOMMAND_ENTRY pCommandListTail
Definition: precomp.h:121
PCOMMAND_GROUP pGroupListTail
Definition: precomp.h:124
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:126
ULONG ulPriority
Definition: precomp.h:115
PNS_CONTEXT_COMMIT_FN pfnCommitFn
Definition: precomp.h:116
HMODULE hModule
Definition: precomp.h:114
struct _CONTEXT_ENTRY * pParentContext
Definition: precomp.h:109
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:107
GUID Guid
Definition: precomp.h:113
PNS_CONTEXT_DUMP_FN pfnDumpFn
Definition: precomp.h:117
PCOMMAND_GROUP pGroupListHead
Definition: precomp.h:123
PCOMMAND_ENTRY pCommandListHead
Definition: precomp.h:120
struct _CONTEXT_ENTRY * pSubContextTail
Definition: precomp.h:127
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:57
Definition: precomp.h:62
PDLL_LIST_ENTRY pDllEntry
Definition: precomp.h:69
GUID ParentHelperGuid
Definition: precomp.h:67
uint16_t * PWSTR
Definition: typedefs.h:56
#define WINAPI
Definition: msvc.h:6
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184