ReactOS 0.4.17-dev-573-g8315b8c
precomp.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <wincon.h>
#include <winuser.h>
#include <iphlpapi.h>
#include <iphlpapi_undoc.h>
#include <ndk/rtlfuncs.h>
#include <conutils.h>
#include <netsh.h>
#include <netsh_undoc.h>
#include "resource.h"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DLL_LIST_ENTRY
 
struct  _HELPER_ENTRY
 
struct  _COMMAND_ENTRY
 
struct  _COMMAND_GROUP
 
struct  _CONTEXT_ENTRY
 

Macros

#define WIN32_NO_STATUS
 
#define MAX_STRING_SIZE   1024
 
#define MAX_ARGS_COUNT   256
 
#define REG_NETSH_PATH   L"Software\\Microsoft\\NetSh"
 

Typedefs

typedef struct _DLL_LIST_ENTRY DLL_LIST_ENTRY
 
typedef struct _DLL_LIST_ENTRYPDLL_LIST_ENTRY
 
typedef struct _HELPER_ENTRY HELPER_ENTRY
 
typedef struct _HELPER_ENTRYPHELPER_ENTRY
 
typedef struct _COMMAND_ENTRY COMMAND_ENTRY
 
typedef struct _COMMAND_ENTRYPCOMMAND_ENTRY
 
typedef struct _COMMAND_GROUP COMMAND_GROUP
 
typedef struct _COMMAND_GROUPPCOMMAND_GROUP
 
typedef struct _CONTEXT_ENTRY CONTEXT_ENTRY
 
typedef struct _CONTEXT_ENTRYPCONTEXT_ENTRY
 

Functions

VOID InitAliases (VOID)
 
VOID DestroyAliases (VOID)
 
DWORD WINAPI AliasCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI ShowAliasCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI UnaliasCommand (LPCWSTR pwszMachine, LPWSTR *argv, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
BOOL CreateRootContext (VOID)
 
VOID CleanupContext (VOID)
 
PCONTEXT_ENTRY FindContextByGuid (_In_ const GUID *pGuid)
 
VOID PrintCommandHelp (_In_ PCONTEXT_ENTRY pContext, _In_ PCOMMAND_GROUP pGroup, _In_ PCOMMAND_ENTRY pCommand)
 
VOID PrintGroupHelp (_In_ PCONTEXT_ENTRY pContext, _In_ LPWSTR pszGroupName, _In_ BOOL bRecurse)
 
VOID PrintContextHelp (_In_ PCONTEXT_ENTRY pContext)
 
DWORD CreateRootHelper (VOID)
 
VOID LoadHelpers (VOID)
 
VOID UnloadHelpers (VOID)
 
PHELPER_ENTRY FindHelper (_In_ const GUID *pguidHelper, _In_ PHELPER_ENTRY pHelper)
 
DWORD WINAPI AddHelperCommand (LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI DeleteHelperCommand (LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD WINAPI ShowHelperCommand (LPCWSTR pwszMachine, PWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 
DWORD InterpretLine (_In_ LPWSTR pszFileName)
 
VOID InterpretInteractive (VOID)
 
DWORD RunScript (_In_ LPCWSTR filename)
 
LPWSTR MergeStrings (_In_ LPWSTR pszStringArray[], _In_ UINT nCount)
 
BOOL CheckOsVersion (_In_ PNS_OSVERSIONCHECK pfnOsVersionCheck)
 
HRESULT GetWmiVersionInfo (VOID)
 

Variables

PCONTEXT_ENTRY pRootContext
 
PCONTEXT_ENTRY pCurrentContext
 
PHELPER_ENTRY pHelperListHead
 
HMODULE g_hModule
 
PWSTR g_pszMachine
 
BOOL g_bOnline
 
UINT VersionInfoArchitecture
 
UINT VersionInfoOsProductSuite
 
UINT VersionInfoOsType
 
WCHAR VersionInfoVersion [MAX_PATH]
 
WCHAR VersionInfoBuildNumber [MAX_PATH]
 
WCHAR VersionInfoServicePackMajorVersion [MAX_PATH]
 
WCHAR VersionInfoServicePackMinorVersion [MAX_PATH]
 

Macro Definition Documentation

◆ MAX_ARGS_COUNT

#define MAX_ARGS_COUNT   256

Definition at line 37 of file precomp.h.

◆ MAX_STRING_SIZE

#define MAX_STRING_SIZE   1024

Definition at line 36 of file precomp.h.

◆ REG_NETSH_PATH

#define REG_NETSH_PATH   L"Software\\Microsoft\\NetSh"

Definition at line 39 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 16 of file precomp.h.

Typedef Documentation

◆ COMMAND_ENTRY

◆ COMMAND_GROUP

◆ CONTEXT_ENTRY

◆ DLL_LIST_ENTRY

◆ HELPER_ENTRY

◆ PCOMMAND_ENTRY

◆ PCOMMAND_GROUP

◆ PCONTEXT_ENTRY

◆ PDLL_LIST_ENTRY

◆ PHELPER_ENTRY

Function Documentation

◆ AddHelperCommand()

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

Definition at line 461 of file helper.c.

469{
470 DWORD dwError = ERROR_SUCCESS;
471
472 DPRINT("AddHelperCommand()\n");
473
474 if (dwArgCount == 2)
475 {
476// ConResPrintf(StdErr, IDS_INVALID_SYNTAX);
477// ConResPrintf(StdErr, IDS_HLP_ADD_HELPER_EX);
478 return 1;
479 }
480
481 dwError = LoadHelperDll(ppwcArguments[2], TRUE);
482 if (dwError != ERROR_SUCCESS)
483 return dwError;
484
486
487 return ERROR_SUCCESS;
488}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID StartHelpers(PHELPER_ENTRY pHelper)
Definition: helper.c:29
PHELPER_ENTRY pHelperListHead
Definition: helper.c:20
static DWORD LoadHelperDll(_In_ PWSTR pszDllName, _In_ BOOL bRegister)
Definition: helper.c:116
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115
#define DPRINT
Definition: sndvol32.h:73

Referenced by CreateRootContext().

◆ AliasCommand()

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

Definition at line 123 of file alias.c.

131{
132 PALIAS_ENTRY pAliasEntry = NULL;
133 PWSTR pszAlias;
134
135 DPRINT("AliasCommand(dwCurrentIndex %lu dwArgCount %lu)\n",
137
138 /* Show aliases */
139 if (dwArgCount - dwCurrentIndex == 0)
140 {
141 ShowAliases();
142 return ERROR_SUCCESS;
143 }
144
145 if (dwArgCount - dwCurrentIndex == 1)
146 {
148 return ERROR_SUCCESS;
149 }
150
151
152 /* TODO: Check builtin commands */
153
154
155 pAliasEntry = GetAliasEntry(argv[dwCurrentIndex]);
156 if (pAliasEntry)
157 {
159 DPRINT("Alias: %S\n", pszAlias);
160 if (pszAlias == NULL)
162
163 if (pAliasEntry->pszAlias)
164 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAlias);
165
166 pAliasEntry->pszAlias = pszAlias;
167 }
168 else
169 {
170 pAliasEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ALIAS_ENTRY));
171 if (pAliasEntry == NULL)
173
174 pAliasEntry->pszAliasName = HeapAlloc(GetProcessHeap(), 0,
175 (wcslen(argv[dwCurrentIndex]) + 1) * sizeof(WCHAR));
176 if (pAliasEntry->pszAliasName == NULL)
177 {
178 HeapFree(GetProcessHeap(), 0, pAliasEntry);
180 }
181
182 wcscpy(pAliasEntry->pszAliasName, argv[dwCurrentIndex]);
183 DPRINT("AliasName: %S\n", pAliasEntry->pszAliasName);
184
186 DPRINT("Alias: %S\n", pAliasEntry->pszAlias);
187 if (pAliasEntry->pszAlias == NULL)
188 {
189 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAliasName);
190 HeapFree(GetProcessHeap(), 0, pAliasEntry);
192 }
193
194 if (AliasListHead == NULL)
195 {
196 AliasListHead = pAliasEntry;
197 AliasListTail = pAliasEntry;
198 }
199 else
200 {
201 pAliasEntry->pPrev = AliasListTail;
202 AliasListTail->pNext = pAliasEntry;
203 AliasListTail = pAliasEntry;
204 }
205 }
206
207 DPRINT("Done\n");
208
209 return ERROR_OKAY;
210}
static PALIAS_ENTRY GetAliasEntry(PWSTR pszAliasName)
Definition: alias.c:76
PALIAS_ENTRY AliasListHead
Definition: alias.c:26
PALIAS_ENTRY AliasListTail
Definition: alias.c:27
static VOID ShowAliases(VOID)
Definition: alias.c:34
static VOID ShowAlias(PWSTR pszAliasName)
Definition: alias.c:51
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define argv
Definition: mplay32.c:18
LPWSTR MergeStrings(_In_ LPWSTR pszStringArray[], _In_ UINT nCount)
Definition: netsh.c:53
#define ERROR_OKAY
Definition: netsh.h:24
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139
short WCHAR
Definition: pedump.c:58
wcscpy
Definition: alias.c:18
PWSTR pszAliasName
Definition: alias.c:22
struct _ALIAS_ENTRY * pNext
Definition: alias.c:20
struct _ALIAS_ENTRY * pPrev
Definition: alias.c:19
PWSTR pszAlias
Definition: alias.c:23
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by CreateRootContext().

◆ CheckOsVersion()

BOOL CheckOsVersion ( _In_ PNS_OSVERSIONCHECK  pfnOsVersionCheck)

Definition at line 35 of file wmi.c.

37{
38 DPRINT("CheckOsVersion(%p)\n", pfnOsVersionCheck);
39
40 if (pfnOsVersionCheck == NULL)
41 return TRUE;
42
43 return pfnOsVersionCheck(VersionInfoOsType,
50 0);
51}
WCHAR VersionInfoBuildNumber[MAX_PATH]
Definition: wmi.c:28
UINT VersionInfoArchitecture
Definition: wmi.c:24
WCHAR VersionInfoVersion[MAX_PATH]
Definition: wmi.c:27
WCHAR VersionInfoServicePackMinorVersion[MAX_PATH]
Definition: wmi.c:30
UINT VersionInfoOsProductSuite
Definition: wmi.c:25
UINT VersionInfoOsType
Definition: wmi.c:26
WCHAR VersionInfoServicePackMajorVersion[MAX_PATH]
Definition: wmi.c:29

Referenced by InterpretCommand(), PrintCommandHelp(), PrintContext(), PrintShortGroupCommands(), and PrintSubcontexts().

◆ CleanupContext()

VOID CleanupContext ( VOID  )

Definition at line 1016 of file context.c.

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

Referenced by wmain().

◆ CreateRootContext()

BOOL CreateRootContext ( VOID  )

Definition at line 810 of file context.c.

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

Referenced by wmain().

◆ CreateRootHelper()

DWORD CreateRootHelper ( VOID  )

Definition at line 245 of file helper.c.

246{
247 PHELPER_ENTRY pHelper;
248
250 if (pHelper == NULL)
251 return ERROR_OUTOFMEMORY;
252
253 /* FIXME: More to initialize here? */
254
255 pHelperListHead = pHelper;
256 pHelperListTail = pHelper;
257
258 return ERROR_SUCCESS;
259}
struct _HELPER_ENTRY * PHELPER_ENTRY
struct _HELPER_ENTRY HELPER_ENTRY
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
PHELPER_ENTRY pHelperListTail
Definition: helper.c:21
Definition: precomp.h:58

Referenced by wmain().

◆ DeleteHelperCommand()

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

Definition at line 493 of file helper.c.

501{
503 HKEY hKey;
504 DWORD dwError;
505
506 DPRINT("DeleteHelper()\n");
507
508 if (dwArgCount == 2)
509 {
510// ConResPrintf(StdErr, IDS_INVALID_SYNTAX);
511// ConResPrintf(StdErr, IDS_HLP_DEL_HELPER_EX);
512 return 1;
513 }
514
516 while (pEntry != NULL)
517 {
518 if (wcscmp(pEntry->pszShortName, ppwcArguments[2]) == 0)
519 {
520 DPRINT1("remove %S\n", pEntry->pszShortName);
521
522 if (pEntry->pPrev != NULL)
523 pEntry->pPrev->pNext = pEntry->pNext;
524 if (pEntry->pNext != NULL)
525 pEntry->pNext->pPrev = pEntry->pPrev;
526 if (pDllListTail == pEntry)
527 pDllListTail = pEntry->pPrev;
528 if (pDllListHead == pEntry)
529 pDllListHead = pEntry->pNext;
530 pEntry->pPrev = NULL;
531 pEntry->pNext = NULL;
532
535 0,
536 KEY_WRITE,
537 &hKey);
538 if (dwError == ERROR_SUCCESS)
539 {
540 RegDeleteValue(hKey, pEntry->pszValueName);
542 }
543
545
546 return 1;
547 }
548
549 pEntry = pEntry->pNext;
550 }
551
552 return ERROR_SUCCESS;
553}
#define REG_NETSH_PATH
Definition: precomp.h:39
#define DPRINT1
Definition: precomp.h:8
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
FxAutoRegKey hKey
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
PDLL_LIST_ENTRY pDllListHead
Definition: helper.c:17
static VOID FreeHelperDll(_In_ PDLL_LIST_ENTRY pEntry)
Definition: helper.c:95
PDLL_LIST_ENTRY pDllListTail
Definition: helper.c:18
#define KEY_WRITE
Definition: nt_native.h:1034
Definition: precomp.h:45
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegDeleteValue
Definition: winreg.h:539

Referenced by CreateRootContext().

◆ DestroyAliases()

VOID DestroyAliases ( VOID  )

Definition at line 103 of file alias.c.

104{
105 PALIAS_ENTRY pAliasEntry;
106
107 while (AliasListHead != NULL)
108 {
109 pAliasEntry = AliasListHead;
111
112 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAliasName);
113 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAlias);
114 HeapFree(GetProcessHeap(), 0, pAliasEntry);
115 }
116
118}

Referenced by wmain().

◆ FindContextByGuid()

PCONTEXT_ENTRY FindContextByGuid ( _In_ const GUID pGuid)

◆ FindHelper()

PHELPER_ENTRY FindHelper ( _In_ const GUID pguidHelper,
_In_ PHELPER_ENTRY  pHelper 
)

Definition at line 360 of file helper.c.

363{
364 PHELPER_ENTRY pFoundHelper;
365
366// pHelper = pHelperListHead;
367 while (pHelper != NULL)
368 {
369 if (IsEqualGUID(pguidHelper, &pHelper->Attributes.guidHelper))
370 return pHelper;
371
372 pFoundHelper = FindHelper(pguidHelper, pHelper->pSubHelperHead);
373 if (pFoundHelper)
374 return pFoundHelper;
375
376 pHelper = pHelper->pNext;
377 }
378
379 return NULL;
380}
PHELPER_ENTRY FindHelper(_In_ const GUID *pguidHelper, _In_ PHELPER_ENTRY pHelper)
Definition: helper.c:360
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
struct _HELPER_ENTRY * pNext
Definition: precomp.h:60

Referenced by FindHelper(), RegisterContext(), and RegisterHelper().

◆ GetWmiVersionInfo()

HRESULT GetWmiVersionInfo ( VOID  )

Definition at line 246 of file wmi.c.

247{
248 BSTR Path = NULL;
249 IWbemLocator *Locator = NULL;
251 HRESULT hr;
252
254
257 hr = CoCreateInstance(&CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER,
258 &IID_IWbemLocator, (void **)&Locator);
259 if (hr != S_OK)
260 {
261 DPRINT1("Can't create instance of WbemLocator\n");
262 return hr;
263 }
264
265 Path = SysAllocString(L"ROOT\\CIMV2");
266 if (Path == NULL)
267 {
269 goto done;
270 }
271
272 hr = IWbemLocator_ConnectServer(Locator, Path, NULL, NULL, NULL, 0, NULL, NULL, &Services);
273 if (hr != S_OK)
274 {
275 DPRINT1("Failed to get IWbemServices interface %08x\n", hr);
276 goto done;
277 }
278
281 if (hr != S_OK)
282 {
283 DPRINT1("Failed to set proxy blanket %08x\n", hr);
284 goto done;
285 }
286
288 if (hr == S_OK)
290
291done:
292 if (Path)
294
295 if (Services)
296 IWbemServices_Release(Services);
297
298 if (Locator)
299 IWbemLocator_Release(Locator);
300
302
303 return hr;
304}
PRTL_UNICODE_STRING_BUFFER Path
static HRESULT QueryOperatingSystemInfo(_In_ IWbemServices *Services)
Definition: wmi.c:55
static HRESULT QueryProcessorInfo(_In_ IWbemServices *Services)
Definition: wmi.c:164
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
HRESULT WINAPI CoSetProxyBlanket(IUnknown *proxy, DWORD authn_service, DWORD authz_service, OLECHAR *servername, DWORD authn_level, DWORD imp_level, void *auth_info, DWORD capabilities)
Definition: combase.c:1055
HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR sd, LONG cAuthSvc, SOLE_AUTHENTICATION_SERVICE *asAuthSvc, void *reserved1, DWORD authn_level, DWORD imp_level, void *reserved2, DWORD capabilities, void *reserved3)
Definition: combase.c:1163
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
OLECHAR * BSTR
Definition: compat.h:2293
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
#define S_OK
Definition: intsafe.h:52
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:240
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
#define RPC_C_AUTHZ_NONE
Definition: rpcdce.h:167
#define RPC_C_AUTHN_LEVEL_DEFAULT
Definition: rpcdce.h:145
#define RPC_C_AUTHN_LEVEL_CALL
Definition: rpcdce.h:148
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
#define RPC_C_AUTHN_WINNT
Definition: rpcdce.h:158
static SERVICES Services[NUM_SERVICES]
Definition: tcpsvcs.c:26

Referenced by wmain().

◆ InitAliases()

VOID InitAliases ( VOID  )

Definition at line 95 of file alias.c.

96{
99}

Referenced by wmain().

◆ InterpretInteractive()

VOID InterpretInteractive ( VOID  )

Definition at line 453 of file interpreter.c.

454{
455 WCHAR input_line[MAX_STRING_SIZE];
456 LPWSTR args_vector[MAX_ARGS_COUNT];
457 DWORD dwArgCount = 0, i, len;
458 BOOL bWhiteSpace = TRUE;
459 BOOL bDone = FALSE;
460 BOOL bInQuotes = FALSE;
461 LPWSTR ptr, pStartQuote, pEndQuote;
462 DWORD dwError = ERROR_SUCCESS;
463
464 for (;;)
465 {
466 dwArgCount = 0;
467 memset(args_vector, 0, sizeof(args_vector));
468
469 /* Shown just before the input where the user places commands */
470 if (g_pszMachine)
471 ConPrintf(StdOut, L"[%s] ", g_pszMachine);
473 ConPuts(StdOut, L">");
474
475 /* Get input from the user. */
476 fgetws(input_line, MAX_STRING_SIZE, stdin);
477
478 ptr = input_line;
479 while (*ptr != 0)
480 {
481 if (*ptr == L'\"')
482 bInQuotes = (bInQuotes) ? FALSE : TRUE;
483
484 if ((iswspace(*ptr) && (bInQuotes == FALSE)) || *ptr == L'\n')
485 {
486 *ptr = UNICODE_NULL;
487 bWhiteSpace = TRUE;
488 }
489 else
490 {
491 if ((bWhiteSpace != FALSE) && (dwArgCount < MAX_ARGS_COUNT))
492 {
493 args_vector[dwArgCount] = ptr;
494 dwArgCount++;
495 }
496 bWhiteSpace = FALSE;
497 }
498 ptr++;
499 }
500
501 /* Remove quotation marks */
502 for (i = 0; i < dwArgCount; i++)
503 {
504 pStartQuote = wcschr(args_vector[i], L'\"');
505 if (pStartQuote)
506 {
507 pEndQuote = wcschr(pStartQuote + 1, L'\"');
508 if (pEndQuote)
509 {
510 len = pEndQuote - pStartQuote;
511 memmove(pStartQuote, pStartQuote + 1, (len - 1) * sizeof(WCHAR));
512 *(pEndQuote - 1) = UNICODE_NULL;
513 }
514 }
515 }
516
517 dwError = InterpretCommand(args_vector, dwArgCount, &bDone);
518 if ((dwError != ERROR_SUCCESS) && (dwError != ERROR_SUPPRESS_OUTPUT))
519 {
520 PWSTR pszCommandString = MergeStrings(args_vector, dwArgCount);
521 PrintError(NULL, dwError, pszCommandString);
522 HeapFree(GetProcessHeap(), 0, pszCommandString);
523 }
524 if (dwError != ERROR_SUPPRESS_OUTPUT)
525 ConPuts(StdOut, L"\n");
526
527 if (bDone)
528 break;
529 }
530}
PWSTR g_pszMachine
Definition: context.c:32
static DWORD InterpretCommand(_In_ LPWSTR *argv, _In_ DWORD dwArgCount, _Inout_ PBOOL bDone)
Definition: interpreter.c:134
VOID PrintPrompt(_In_ PCONTEXT_ENTRY pContext)
Definition: interpreter.c:439
#define MAX_STRING_SIZE
Definition: precomp.h:36
#define MAX_ARGS_COUNT
Definition: precomp.h:37
static VOID PrintError(DWORD dwError)
Definition: cacls.c:37
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: conutils_noros.h:8
void ConPrintf(FILE *fp, LPCWSTR psz,...)
#define StdOut
Definition: conutils_noros.h:6
#define wcschr
Definition: compat.h:17
wchar_t *CDECL fgetws(wchar_t *s, int size, FILE *file)
Definition: file.c:4043
#define stdin
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLsizei len
Definition: glext.h:6722
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
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static PVOID ptr
Definition: dispmode.c:27
#define ERROR_SUPPRESS_OUTPUT
Definition: netsh.h:26
#define UNICODE_NULL
#define iswspace(_c)
Definition: ctype.h:669
#define memset(x, y, z)
Definition: compat.h:39
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by wmain().

◆ InterpretLine()

DWORD InterpretLine ( _In_ LPWSTR  pszFileName)

Definition at line 381 of file interpreter.c.

383{
384 LPWSTR args_vector[MAX_ARGS_COUNT];
385 DWORD dwArgCount = 0, i, len;
386 BOOL bWhiteSpace = TRUE;
387 BOOL bDone = FALSE;
388 BOOL bInQuotes = FALSE;
389 LPWSTR ptr, pStartQuote, pEndQuote;
390
391 memset(args_vector, 0, sizeof(args_vector));
392
393 ptr = pszInputLine;
394 while (*ptr != 0)
395 {
396 if (*ptr == L'\"')
397 bInQuotes = (bInQuotes) ? FALSE : TRUE;
398
399 if ((iswspace(*ptr) && (bInQuotes == FALSE)) || *ptr == L'\n')
400 {
401 *ptr = 0;
402 bWhiteSpace = TRUE;
403 }
404 else
405 {
406 if ((bWhiteSpace != FALSE) && (dwArgCount < MAX_ARGS_COUNT))
407 {
408 args_vector[dwArgCount] = ptr;
409 dwArgCount++;
410 }
411
412 bWhiteSpace = FALSE;
413 }
414
415 ptr++;
416 }
417
418 /* Remove quotation marks */
419 for (i = 0; i < dwArgCount; i++)
420 {
421 pStartQuote = wcschr(args_vector[i], L'\"');
422 if (pStartQuote)
423 {
424 pEndQuote = wcschr(pStartQuote + 1, L'\"');
425 if (pEndQuote)
426 {
427 len = pEndQuote - pStartQuote;
428 memmove(pStartQuote, pStartQuote + 1, (len - 1) * sizeof(WCHAR));
429 *(pEndQuote - 1) = UNICODE_NULL;
430 }
431 }
432 }
433
434 return InterpretCommand(args_vector, dwArgCount, &bDone);
435}

Referenced by RunScript(), and wmain().

◆ LoadHelpers()

VOID LoadHelpers ( VOID  )

Definition at line 263 of file helper.c.

264{
265 PWSTR pszNameBuffer = NULL;
266 PWSTR pszValueBuffer = NULL;
267 HKEY hKey;
268 DWORD dwValueCount, dwMaxNameLength, dwMaxValueLength;
269 DWORD dwNameLength, dwValueLength, dwType;
270 DWORD dwIndex, dwError;
271
272 DPRINT("LoadHelpers()\n");
273
276 0,
277 KEY_READ,
278 &hKey);
279 if (dwError != ERROR_SUCCESS)
280 return;
281
282 dwError = RegQueryInfoKeyW(hKey,
283 NULL,
284 NULL,
285 NULL,
286 NULL,
287 NULL,
288 NULL,
289 &dwValueCount,
290 &dwMaxNameLength,
291 &dwMaxValueLength,
292 NULL,
293 NULL);
294 if (dwError != ERROR_SUCCESS)
295 goto done;
296
297 pszNameBuffer = HeapAlloc(GetProcessHeap(), 0,
298 (dwMaxNameLength + 1) * sizeof(WCHAR));
299 if (pszNameBuffer == NULL)
300 goto done;
301
302 pszValueBuffer = HeapAlloc(GetProcessHeap(), 0,
303 dwMaxValueLength + sizeof(WCHAR));
304 if (pszValueBuffer == NULL)
305 goto done;
306
307 for (dwIndex = 0; dwIndex < dwValueCount; dwIndex++)
308 {
309 dwNameLength = dwMaxNameLength + 1;
310 dwValueLength = dwMaxValueLength + sizeof(WCHAR);
311 dwError = RegEnumValueW(hKey,
312 dwIndex,
313 pszNameBuffer,
314 &dwNameLength,
315 NULL,
316 &dwType,
317 (PBYTE)pszValueBuffer,
318 &dwValueLength);
319 if (dwError != ERROR_SUCCESS)
320 break;
321
322 DPRINT("Dll: %S --> %S %lu\n", pszNameBuffer, pszValueBuffer, dwError);
323 LoadHelperDll(pszValueBuffer, FALSE);
324 }
325
326done:
327 if (pszValueBuffer)
328 HeapFree(GetProcessHeap(), 0, pszValueBuffer);
329
330 if (pszNameBuffer)
331 HeapFree(GetProcessHeap(), 0, pszNameBuffer);
332
334
336}
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
#define KEY_READ
Definition: nt_native.h:1026
BYTE * PBYTE
Definition: pedump.c:66

Referenced by wmain().

◆ MergeStrings()

LPWSTR MergeStrings ( _In_ LPWSTR  pszStringArray[],
_In_ UINT  nCount 
)

Definition at line 53 of file netsh.c.

56{
57 LPWSTR pszOutString = NULL;
58 size_t nLength;
59 UINT i;
60
61 if ((pszStringArray == NULL) || (nCount == 0))
62 return NULL;
63
64 nLength = 0;
65 for (i = 0; i < nCount; i++)
66 nLength += wcslen(pszStringArray[i]);
67
68 if (nLength > 0)
69 nLength += nCount; /* Space characters and terminating zero */
70
71 pszOutString = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR));
72 if (pszOutString == NULL)
73 return NULL;
74
75 for (i = 0; i < nCount; i++)
76 {
77 if (i != 0)
78 wcscat(pszOutString, L" ");
79 wcscat(pszOutString, pszStringArray[i]);
80 }
81
82 return pszOutString;
83}
unsigned int UINT
Definition: sysinfo.c:13
wcscat
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682

Referenced by AliasCommand(), InterpretInteractive(), and wmain().

◆ PrintCommandHelp()

VOID PrintCommandHelp ( _In_ PCONTEXT_ENTRY  pContext,
_In_ PCOMMAND_GROUP  pGroup,
_In_ PCOMMAND_ENTRY  pCommand 
)

Definition at line 337 of file help.c.

341{
342 LPWSTR pszCommandBuffer;
343 DWORD_PTR Args[2];
344 DWORD dwLength = 1;
345
346 DPRINT("PrintCommandHelp(%p %p %p)\n", pContext, pGroup, pCommand);
347
348 if (!CheckOsVersion(pCommand->pfnOsVersionCheck))
349 return;
350
351 if (((pCommand->dwFlags & CMD_FLAG_LOCAL) && (g_pszMachine != NULL)) ||
352 ((pCommand->dwFlags & CMD_FLAG_ONLINE) && (g_bOnline == FALSE)) ||
353 (pCommand->dwFlags & CMD_FLAG_HIDDEN))
354 return;
355
356 dwLength += wcslen(pCommand->pwszCmdToken);
357 if (pGroup)
358 dwLength += (wcslen(pGroup->pwszCmdGroupToken) + 1);
359
360 pszCommandBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
361 if (pszCommandBuffer == NULL)
362 return;
363
364 _swprintf(pszCommandBuffer, L"%s%s%s",
365 (pGroup) ? pGroup->pwszCmdGroupToken : L"",
366 (pGroup) ? L" " : L"",
367 pCommand->pwszCmdToken);
368
369 Args[0] = (DWORD_PTR)pszCommandBuffer;
370 Args[1] = (DWORD_PTR)NULL;
371
373 pContext->hModule,
375 pCommand->dwCmdHlpToken,
377 (va_list *)&Args);
378 ConPuts(StdOut, L"\n");
379
380 HeapFree(GetProcessHeap(), 0, pszCommandBuffer);
381}
char ** Args
Definition: acdebug.h:353
BOOL g_bOnline
Definition: context.c:33
BOOL CheckOsVersion(_In_ PNS_OSVERSIONCHECK pfnOsVersionCheck)
Definition: wmi.c:35
static DWORD DWORD * dwLength
Definition: fusion.c:86
char * va_list
Definition: vadefs.h:50
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
@ CMD_FLAG_HIDDEN
Definition: netsh.h:46
INT ConResMsgPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1216
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:401

Referenced by InterpretCommand().

◆ PrintContextHelp()

VOID PrintContextHelp ( _In_ PCONTEXT_ENTRY  pContext)

Definition at line 412 of file help.c.

414{
416 PrintContext(pContext);
417 PrintSubcontexts(pContext);
419}
static VOID PrintSubcontexts(_In_ PCONTEXT_ENTRY pContext)
Definition: help.c:281
static VOID PrintContext(_In_ PCONTEXT_ENTRY pContext)
Definition: help.c:121
#define IDS_HELP_FOOTER
Definition: resource.h:20
#define IDS_HELP_HEADER
Definition: resource.h:19
void ConResPrintf(FILE *fp, UINT nID,...)

Referenced by InterpretCommand().

◆ PrintGroupHelp()

VOID PrintGroupHelp ( _In_ PCONTEXT_ENTRY  pContext,
_In_ LPWSTR  pszGroupName,
_In_ BOOL  bRecurse 
)

Definition at line 385 of file help.c.

389{
390 PCOMMAND_GROUP pGroup;
391
392 if (bRecurse)
393 {
394 if (pContext != pRootContext)
395 PrintGroupHelp(pContext->pParentContext, pszGroupName, bRecurse);
396 }
397
398 pGroup = pContext->pGroupListHead;
399 while (pGroup != NULL)
400 {
401 if (_wcsicmp(pszGroupName, pGroup->pwszCmdGroupToken) == 0)
402 {
404 PrintShortGroupCommands(pContext, pGroup);
405 }
406 pGroup = pGroup->pNext;
407 }
408}
static VOID PrintShortGroupCommands(_In_ PCONTEXT_ENTRY pContext, _In_ PCOMMAND_GROUP pGroup)
Definition: help.c:82
static VOID PrintCurrentContextHeader(_In_ PCONTEXT_ENTRY pContext)
Definition: help.c:64
VOID PrintGroupHelp(_In_ PCONTEXT_ENTRY pContext, _In_ LPWSTR pszGroupName, _In_ BOOL bRecurse)
Definition: help.c:385
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
struct _COMMAND_GROUP * pNext
Definition: precomp.h:89
PWSTR pwszCmdGroupToken
Definition: precomp.h:91

Referenced by InterpretCommand(), and PrintGroupHelp().

◆ RunScript()

DWORD RunScript ( _In_ LPCWSTR  filename)

Definition at line 22 of file netsh.c.

24{
25 WCHAR tmp_string[MAX_STRING_SIZE];
26 FILE *script;
27 DWORD dwError = ERROR_SUCCESS;
28
29 /* Open the file for processing */
30 script = _wfopen(filename, L"r");
31 if (script == NULL)
32 {
35 }
36
37 /* Read and process the script */
38 while (fgetws(tmp_string, MAX_STRING_SIZE, script) != NULL)
39 {
40 dwError = InterpretLine(tmp_string);
41 if (dwError != ERROR_SUCCESS)
42 break;
43 }
44
45 /* Close the file */
47
48 return dwError;
49}
DWORD InterpretLine(_In_ LPWSTR pszInputLine)
Definition: interpreter.c:381
#define IDS_OPEN_FAILED
Definition: resource.h:14
#define StdErr
Definition: conutils_noros.h:7
int CDECL fclose(FILE *file)
Definition: file.c:3757
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
Definition: file.c:4335
const char * filename
Definition: ioapi.h:137
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
script
Definition: msipriv.h:383

Referenced by ExecCommand(), and wmain().

◆ ShowAliasCommand()

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

Definition at line 215 of file alias.c.

223{
224 DPRINT("ShowAliasCommand()\n");
225
226 ShowAliases();
227
228 return ERROR_SUCCESS;
229}

Referenced by CreateRootContext().

◆ ShowHelperCommand()

DWORD WINAPI ShowHelperCommand ( LPCWSTR  pwszMachine,
PWSTR ppwcArguments,
DWORD  dwCurrentIndex,
DWORD  dwArgCount,
DWORD  dwFlags,
LPCVOID  pvData,
BOOL pbDone 
)

Definition at line 614 of file helper.c.

622{
623 DPRINT("ShowHelperCommand()\n");
624
625 ConPrintf(StdOut, L"Helper GUID DLL Name Command\n");
626 ConPrintf(StdOut, L"-------------------------------------- ---------------- --------\n");
627
628 if (pRootContext == NULL)
629 return ERROR_SUCCESS;
630
632
633 return ERROR_SUCCESS;
634}
static VOID PrintHelpers(_In_ PHELPER_ENTRY pHelperListHead, _In_ DWORD dwLevel)
Definition: helper.c:558

Referenced by CreateRootContext().

◆ UnaliasCommand()

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

Definition at line 234 of file alias.c.

242{
243 PALIAS_ENTRY pAliasEntry = NULL;
244
245 DPRINT("UnaliasCommand()\n");
246
247 if (dwArgCount - dwCurrentIndex != 1)
249
250 DPRINT("Alias %S\n", argv[dwCurrentIndex]);
251
252 pAliasEntry = AliasListHead;
253 while (pAliasEntry)
254 {
255 if (wcscmp(pAliasEntry->pszAliasName, argv[dwCurrentIndex]) == 0)
256 {
257 DPRINT("Alias found %S\n", argv[dwCurrentIndex]);
258
259 if (pAliasEntry->pNext != NULL)
260 pAliasEntry->pNext->pPrev = pAliasEntry->pPrev;
261 else
262 AliasListTail = pAliasEntry->pPrev;
263
264 if (pAliasEntry->pPrev != NULL)
265 pAliasEntry->pPrev->pNext = pAliasEntry->pNext;
266 else
267 AliasListHead = pAliasEntry->pNext;
268
269 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAliasName);
270 HeapFree(GetProcessHeap(), 0, pAliasEntry->pszAlias);
271 HeapFree(GetProcessHeap(), 0, pAliasEntry);
272
273 return ERROR_SUCCESS;
274 }
275
276 pAliasEntry = pAliasEntry->pNext;
277 }
278
280
281 return ERROR_SUCCESS;
282}
#define IDS_ALIAS_NOT_FOUND
Definition: resource.h:17
#define ERROR_INVALID_SYNTAX
Definition: netsh.h:10

Referenced by CreateRootContext().

◆ UnloadHelpers()

VOID UnloadHelpers ( VOID  )

Definition at line 340 of file helper.c.

341{
343
344 while (pDllListHead != NULL)
345 {
347 pDllListHead = pEntry->pNext;
348
349// if (pEntry->Attributes.pfnStop)
350// pEntry->Attributes.pfnStop(0);
351
353 }
354
356}

Referenced by wmain().

Variable Documentation

◆ g_bOnline

◆ g_hModule

HMODULE g_hModule
extern

Definition at line 17 of file netsh.c.

◆ g_pszMachine

◆ pCurrentContext

◆ pHelperListHead

◆ pRootContext

◆ VersionInfoArchitecture

UINT VersionInfoArchitecture
extern

Definition at line 24 of file wmi.c.

Referenced by CheckOsVersion(), and QueryProcessorInfo().

◆ VersionInfoBuildNumber

WCHAR VersionInfoBuildNumber[MAX_PATH]
extern

Definition at line 28 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().

◆ VersionInfoOsProductSuite

UINT VersionInfoOsProductSuite
extern

Definition at line 25 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().

◆ VersionInfoOsType

UINT VersionInfoOsType
extern

Definition at line 26 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().

◆ VersionInfoServicePackMajorVersion

WCHAR VersionInfoServicePackMajorVersion[MAX_PATH]
extern

Definition at line 29 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().

◆ VersionInfoServicePackMinorVersion

WCHAR VersionInfoServicePackMinorVersion[MAX_PATH]
extern

Definition at line 30 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().

◆ VersionInfoVersion

WCHAR VersionInfoVersion[MAX_PATH]
extern

Definition at line 27 of file wmi.c.

Referenced by CheckOsVersion(), and QueryOperatingSystemInfo().