ReactOS 0.4.16-dev-319-g6cf4263
helper.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for helper.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID StartHelpers (VOID)
 
static VOID RegisterHelperDll (_In_ PDLL_LIST_ENTRY pEntry)
 
static VOID FreeHelperDll (_In_ PDLL_LIST_ENTRY pEntry)
 
static DWORD LoadHelperDll (_In_ PWSTR pszDllName, _In_ BOOL bRegister)
 
VOID LoadHelpers (VOID)
 
VOID UnloadHelpers (VOID)
 
PHELPER_ENTRY FindHelper (_In_ const GUID *pguidHelper)
 
DWORD WINAPI RegisterHelper (_In_ const GUID *pguidParentHelper, _In_ const NS_HELPER_ATTRIBUTES *pHelperAttributes)
 
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)
 
static VOID PrintSubContext (_In_ PCONTEXT_ENTRY pParentContext, _In_ DWORD dwLevel)
 
DWORD WINAPI ShowHelperCommand (LPCWSTR pwszMachine, LPWSTR *ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, DWORD dwFlags, LPCVOID pvData, BOOL *pbDone)
 

Variables

PDLL_LIST_ENTRY pDllListHead = NULL
 
PDLL_LIST_ENTRY pDllListTail = NULL
 
PHELPER_ENTRY pHelperListHead = NULL
 
PHELPER_ENTRY pHelperListTail = NULL
 
PDLL_LIST_ENTRY pCurrentDll = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file helper.c.

Function Documentation

◆ AddHelperCommand()

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

Definition at line 425 of file helper.c.

433{
434 DWORD dwError = ERROR_SUCCESS;
435
436 DPRINT("AddHelperCommand()\n");
437
438 if (dwArgCount == 2)
439 {
440// ConResPrintf(StdErr, IDS_INVALID_SYNTAX);
441// ConResPrintf(StdErr, IDS_HLP_ADD_HELPER_EX);
442 return 1;
443 }
444
445 dwError = LoadHelperDll(ppwcArguments[2], TRUE);
446 if (dwError != ERROR_SUCCESS)
447 return dwError;
448
449 StartHelpers();
450
451 return ERROR_SUCCESS;
452}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID StartHelpers(VOID)
Definition: helper.c:29
static DWORD LoadHelperDll(_In_ PWSTR pszDllName, _In_ BOOL bRegister)
Definition: helper.c:109
#define DPRINT
Definition: sndvol32.h:73

Referenced by CreateRootContext().

◆ DeleteHelperCommand()

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

Definition at line 457 of file helper.c.

465{
467 HKEY hKey;
468 DWORD dwError;
469
470 DPRINT("DeleteHelper()\n");
471
472 if (dwArgCount == 2)
473 {
474// ConResPrintf(StdErr, IDS_INVALID_SYNTAX);
475// ConResPrintf(StdErr, IDS_HLP_DEL_HELPER_EX);
476 return 1;
477 }
478
480 while (pEntry != NULL)
481 {
482 if (wcscmp(pEntry->pszShortName, ppwcArguments[2]) == 0)
483 {
484 DPRINT1("remove %S\n", pEntry->pszShortName);
485
486 if (pEntry->pPrev != NULL)
487 pEntry->pPrev->pNext = pEntry->pNext;
488 if (pEntry->pNext != NULL)
489 pEntry->pNext->pPrev = pEntry->pPrev;
490 if (pDllListTail == pEntry)
491 pDllListTail = pEntry->pPrev;
492 if (pDllListHead == pEntry)
493 pDllListHead = pEntry->pNext;
494 pEntry->pPrev = NULL;
495 pEntry->pNext = NULL;
496
499 0,
500 KEY_WRITE,
501 &hKey);
502 if (dwError == ERROR_SUCCESS)
503 {
504 RegDeleteValue(hKey, pEntry->pszValueName);
506 }
507
509
510 return 1;
511 }
512
513 pEntry = pEntry->pNext;
514 }
515
516 return ERROR_SUCCESS;
517}
#define REG_NETSH_PATH
Definition: precomp.h:37
#define DPRINT1
Definition: precomp.h:8
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:88
PDLL_LIST_ENTRY pDllListTail
Definition: helper.c:18
#define KEY_WRITE
Definition: nt_native.h:1031
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: precomp.h:43
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegDeleteValue
Definition: winreg.h:508

Referenced by CreateRootContext().

◆ FindHelper()

PHELPER_ENTRY FindHelper ( _In_ const GUID pguidHelper)

Definition at line 338 of file helper.c.

340{
341 PHELPER_ENTRY pHelper;
342
343 pHelper = pHelperListHead;
344 while (pHelper != NULL)
345 {
346 if (IsEqualGUID(pguidHelper, &pHelper->Attributes.guidHelper))
347 return pHelper;
348
349 pHelper = pHelper->pNext;
350 }
351
352 return NULL;
353}
PHELPER_ENTRY pHelperListHead
Definition: helper.c:20
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: precomp.h:56
NS_HELPER_ATTRIBUTES Attributes
Definition: precomp.h:60
struct _HELPER_ENTRY * pNext
Definition: precomp.h:58

Referenced by PrintSubContext(), and RegisterHelper().

◆ FreeHelperDll()

static VOID FreeHelperDll ( _In_ PDLL_LIST_ENTRY  pEntry)
static

Definition at line 88 of file helper.c.

90{
91 if (pEntry->hModule)
92 FreeLibrary(pEntry->hModule);
93
94 if (pEntry->pszValueName)
95 HeapFree(GetProcessHeap(), 0, pEntry->pszValueName);
96
97 if (pEntry->pszShortName)
98 HeapFree(GetProcessHeap(), 0, pEntry->pszShortName);
99
100 if (pEntry->pszDllName)
101 HeapFree(GetProcessHeap(), 0, pEntry->pszDllName);
102
104}
#define GetProcessHeap()
Definition: compat.h:736
#define FreeLibrary(x)
Definition: compat.h:748
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by DeleteHelperCommand(), LoadHelperDll(), and UnloadHelpers().

◆ LoadHelperDll()

static DWORD LoadHelperDll ( _In_ PWSTR  pszDllName,
_In_ BOOL  bRegister 
)
static

Definition at line 109 of file helper.c.

112{
113 PNS_DLL_INIT_FN pInitHelperDll;
115 PWSTR pszStart, pszEnd;
116 BOOL bInserted = FALSE;
117 DWORD dwError;
118
120 if (pEntry == NULL)
121 {
122 return ERROR_OUTOFMEMORY;
123 }
124
125 pEntry->pszDllName = HeapAlloc(GetProcessHeap(),
127 (wcslen(pszDllName) + 1) * sizeof(WCHAR));
128 if (pEntry->pszDllName == NULL)
129 {
130 dwError = ERROR_OUTOFMEMORY;
131 goto done;
132 }
133
134 wcscpy(pEntry->pszDllName, pszDllName);
135
136 pszStart = wcsrchr(pszDllName, L'\\');
137 if (pszStart == NULL)
138 pszStart = pszDllName;
139
140 pEntry->pszShortName = HeapAlloc(GetProcessHeap(),
142 (wcslen(pszStart) + 1) * sizeof(WCHAR));
143 if (pEntry->pszShortName == NULL)
144 {
145 dwError = ERROR_OUTOFMEMORY;
146 goto done;
147 }
148
149 wcscpy(pEntry->pszShortName, pszStart);
150
151 pEntry->pszValueName = HeapAlloc(GetProcessHeap(),
153 (wcslen(pEntry->pszShortName) + 1) * sizeof(WCHAR));
154 if (pEntry->pszValueName == NULL)
155 {
156 dwError = ERROR_OUTOFMEMORY;
157 goto done;
158 }
159
160 wcscpy(pEntry->pszValueName, pEntry->pszShortName);
161
162 pszEnd = wcsrchr(pEntry->pszValueName, L'.');
163 if (pszEnd != NULL)
164 *pszEnd = UNICODE_NULL;
165
166 if (pDllListTail == NULL)
167 {
168 pEntry->pPrev = NULL;
169 pEntry->pNext = NULL;
172 }
173 else
174 {
175 pEntry->pPrev = NULL;
176 pEntry->pNext = pDllListHead;
179 }
180
181 bInserted = TRUE;
182
183 pEntry->hModule = LoadLibraryW(pEntry->pszDllName);
184 if (pEntry->hModule == NULL)
185 {
186 dwError = GetLastError();
187 DPRINT1("Could not load the helper dll %S (Error: %lu)\n", pEntry->pszDllName, dwError);
188 goto done;
189 }
190
191 pInitHelperDll = (PNS_DLL_INIT_FN)GetProcAddress(pEntry->hModule, "InitHelperDll");
192 if (pInitHelperDll == NULL)
193 {
194 dwError = GetLastError();
195 DPRINT1("Could not find 'InitHelperDll' (Error: %lu)\n", dwError);
196 goto done;
197 }
198
200 dwError = pInitHelperDll(5, NULL);
202
203 DPRINT1("InitHelperDll returned %lu\n", dwError);
204 if (dwError != ERROR_SUCCESS)
205 {
206 DPRINT1("Call to InitHelperDll failed (Error: %lu)\n", dwError);
207 goto done;
208 }
209
210// if (pEntry->Attributes.pfnStart)
211// pEntry->Attributes.pfnStart(NULL, 0);
212
213 if (bRegister)
215
216done:
217 if (dwError != ERROR_SUCCESS)
218 {
219 if (bInserted)
220 {
221 if (pEntry->pPrev != NULL)
222 pEntry->pPrev->pNext = pEntry->pNext;
223 if (pEntry->pNext != NULL)
224 pEntry->pNext->pPrev = pEntry->pPrev;
225 if (pDllListTail == pEntry)
226 pDllListTail = pEntry->pPrev;
227 if (pDllListHead == pEntry)
228 pDllListHead = pEntry->pNext;
229 pEntry->pPrev = NULL;
230 pEntry->pNext = NULL;
231 }
232
234 }
235
236 return dwError;
237}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define FALSE
Definition: types.h:117
#define wcsrchr
Definition: compat.h:16
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define LoadLibraryW(x)
Definition: compat.h:747
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
PDLL_LIST_ENTRY pCurrentDll
Definition: helper.c:23
static VOID RegisterHelperDll(_In_ PDLL_LIST_ENTRY pEntry)
Definition: helper.c:54
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
DWORD(WINAPI * PNS_DLL_INIT_FN)(_In_ DWORD dwNetshVersion, _Out_ PVOID pReserved)
Definition: netsh.h:17
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
char * pszDllName
Definition: spec2def.c:73
struct _DLL_LIST_ENTRY * pPrev
Definition: precomp.h:44
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by AddHelperCommand(), and LoadHelpers().

◆ LoadHelpers()

VOID LoadHelpers ( VOID  )

Definition at line 241 of file helper.c.

242{
243 PWSTR pszNameBuffer = NULL;
244 PWSTR pszValueBuffer = NULL;
245 HKEY hKey;
246 DWORD dwValueCount, dwMaxNameLength, dwMaxValueLength;
247 DWORD dwNameLength, dwValueLength, dwType;
248 DWORD dwIndex, dwError;
249
250 DPRINT1("LoadHelpers()\n");
251
254 0,
255 KEY_READ,
256 &hKey);
257 if (dwError != ERROR_SUCCESS)
258 return;
259
260 dwError = RegQueryInfoKeyW(hKey,
261 NULL,
262 NULL,
263 NULL,
264 NULL,
265 NULL,
266 NULL,
267 &dwValueCount,
268 &dwMaxNameLength,
269 &dwMaxValueLength,
270 NULL,
271 NULL);
272 if (dwError != ERROR_SUCCESS)
273 goto done;
274
275 pszNameBuffer = HeapAlloc(GetProcessHeap(), 0,
276 (dwMaxNameLength + 1) * sizeof(WCHAR));
277 if (pszNameBuffer == NULL)
278 goto done;
279
280 pszValueBuffer = HeapAlloc(GetProcessHeap(), 0,
281 dwMaxValueLength + sizeof(WCHAR));
282 if (pszValueBuffer == NULL)
283 goto done;
284
285 for (dwIndex = 0; dwIndex < dwValueCount; dwIndex++)
286 {
287 dwNameLength = dwMaxNameLength + 1;
288 dwValueLength = dwMaxValueLength + sizeof(WCHAR);
289 dwError = RegEnumValueW(hKey,
290 dwIndex,
291 pszNameBuffer,
292 &dwNameLength,
293 NULL,
294 &dwType,
295 (PBYTE)pszValueBuffer,
296 &dwValueLength);
297 if (dwError != ERROR_SUCCESS)
298 break;
299
300 DPRINT1("Dll: %S --> %S %lu\n", pszNameBuffer, pszValueBuffer, dwError);
301 LoadHelperDll(pszValueBuffer, FALSE);
302 }
303
304done:
305 if (pszValueBuffer)
306 HeapFree(GetProcessHeap(), 0, pszValueBuffer);
307
308 if (pszNameBuffer)
309 HeapFree(GetProcessHeap(), 0, pszNameBuffer);
310
312
313 StartHelpers();
314}
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:1023
BYTE * PBYTE
Definition: pedump.c:66

Referenced by wmain().

◆ PrintSubContext()

static VOID PrintSubContext ( _In_ PCONTEXT_ENTRY  pParentContext,
_In_ DWORD  dwLevel 
)
static

Definition at line 522 of file helper.c.

525{
526 PCONTEXT_ENTRY pContext;
527 PHELPER_ENTRY pHelper;
528 WCHAR szPrefix[22];
529 DWORD i;
530
531 if (pParentContext == NULL)
532 return;
533
534 pContext = pParentContext->pSubContextHead;
535 while (pContext != NULL)
536 {
537 pHelper = FindHelper(&pContext->Guid);
538 if (pHelper != NULL)
539 {
540 if (dwLevel > 10)
541 dwLevel = 10;
542
543 for (i = 0; i < dwLevel * 2; i++)
544 szPrefix[i] = L' ';
545 szPrefix[i] = UNICODE_NULL;
546
547 ConPrintf(StdOut, L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X} %-16s %s%s\n",
548 pHelper->Attributes.guidHelper.Data1,
549 pHelper->Attributes.guidHelper.Data2,
550 pHelper->Attributes.guidHelper.Data3,
551 pHelper->Attributes.guidHelper.Data4[0],
552 pHelper->Attributes.guidHelper.Data4[1],
553 pHelper->Attributes.guidHelper.Data4[2],
554 pHelper->Attributes.guidHelper.Data4[3],
555 pHelper->Attributes.guidHelper.Data4[4],
556 pHelper->Attributes.guidHelper.Data4[5],
557 pHelper->Attributes.guidHelper.Data4[6],
558 pHelper->Attributes.guidHelper.Data4[7],
559 pHelper->pDllEntry->pszShortName,
560 szPrefix,
561 pContext->pszContextName);
562 }
563
564 PrintSubContext(pContext, dwLevel + 1);
565
566 pContext = pContext->pNext;
567 }
568}
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
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
PHELPER_ENTRY FindHelper(_In_ const GUID *pguidHelper)
Definition: helper.c:338
static VOID PrintSubContext(_In_ PCONTEXT_ENTRY pParentContext, _In_ DWORD dwLevel)
Definition: helper.c:522
Definition: precomp.h:98
PWSTR pszContextName
Definition: precomp.h:104
struct _CONTEXT_ENTRY * pSubContextHead
Definition: precomp.h:114
struct _CONTEXT_ENTRY * pNext
Definition: precomp.h:100
GUID Guid
Definition: precomp.h:105
PWSTR pszShortName
Definition: precomp.h:48
PDLL_LIST_ENTRY pDllEntry
Definition: precomp.h:62

Referenced by PrintSubContext(), and ShowHelperCommand().

◆ RegisterHelper()

DWORD WINAPI RegisterHelper ( _In_ const GUID pguidParentHelper,
_In_ const NS_HELPER_ATTRIBUTES pHelperAttributes 
)

Definition at line 358 of file helper.c.

361{
362 PHELPER_ENTRY pHelper = NULL, pParentHelper;
363 DWORD dwError = ERROR_SUCCESS;
364
365 DPRINT("RegisterHelper(%p %p)\n", pguidParentHelper, pHelperAttributes);
366
367 if (FindHelper(&pHelperAttributes->guidHelper) != NULL)
368 {
369 DPRINT1("The Helper has already been registered!\n");
370 return 1;
371 }
372
374 if (pHelper == NULL)
375 {
376 dwError = ERROR_OUTOFMEMORY;
377 goto done;
378 }
379
380 CopyMemory(&pHelper->Attributes, pHelperAttributes, sizeof(NS_HELPER_ATTRIBUTES));
381 pHelper->pDllEntry = pCurrentDll;
382 DPRINT("pHelper->pDllEntry: %p\n", pHelper->pDllEntry);
383
384 if (pguidParentHelper == NULL)
385 {
386 if (pHelperListTail == NULL)
387 {
388 pHelperListHead = pHelper;
389 pHelperListTail = pHelper;
390 }
391 else
392 {
393 pHelper->pNext = pHelperListHead;
394 pHelperListHead->pPrev = pHelper;
395 pHelperListHead = pHelper;
396 }
397 }
398 else
399 {
400 pParentHelper = FindHelper(&pHelperAttributes->guidHelper);
401 if (pParentHelper == NULL)
403
404 if (pParentHelper->pSubHelperHead == NULL && pParentHelper->pSubHelperTail == NULL)
405 {
406 pParentHelper->pSubHelperHead = pHelper;
407 pParentHelper->pSubHelperTail = pHelper;
408 }
409 else
410 {
411 pHelper->pPrev = pParentHelper->pSubHelperTail;
412 pParentHelper->pSubHelperTail->pNext = pHelper;
413 pParentHelper->pSubHelperTail = pHelper;
414 }
415 }
416
417done:
418
419 return dwError;
420}
struct _HELPER_ENTRY * PHELPER_ENTRY
struct _HELPER_ENTRY HELPER_ENTRY
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PHELPER_ENTRY pHelperListTail
Definition: helper.c:21
struct _HELPER_ENTRY * pSubHelperTail
Definition: precomp.h:66
struct _HELPER_ENTRY * pPrev
Definition: precomp.h:57
#define CopyMemory
Definition: winbase.h:1735

◆ RegisterHelperDll()

static VOID RegisterHelperDll ( _In_ PDLL_LIST_ENTRY  pEntry)
static

Definition at line 54 of file helper.c.

56{
57 PWSTR pszValueName = NULL;
58 HKEY hKey;
59 DWORD dwError;
60
63 0,
64 NULL,
67 NULL,
68 &hKey,
69 NULL);
70 if (dwError == ERROR_SUCCESS)
71 {
73 pEntry->pszValueName,
74 0,
75 REG_SZ,
76 (PBYTE)pEntry->pszDllName,
77 (wcslen(pEntry->pszDllName) + 1) * sizeof(WCHAR));
78
80 }
81
82 HeapFree(GetProcessHeap(), 0, pszValueName);
83}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define REG_SZ
Definition: layer.c:22
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057

Referenced by LoadHelperDll().

◆ ShowHelperCommand()

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

Definition at line 573 of file helper.c.

581{
582 DPRINT("ShowHelperCommand()\n");
583
584 ConPrintf(StdOut, L"Helper GUID DLL Name Command\n");
585 ConPrintf(StdOut, L"-------------------------------------- ---------------- --------\n");
586
587 if (pRootContext == NULL)
588 return ERROR_SUCCESS;
589
591
592 return ERROR_SUCCESS;
593}
PCONTEXT_ENTRY pRootContext
Definition: context.c:17

Referenced by CreateRootContext().

◆ StartHelpers()

static VOID StartHelpers ( VOID  )
static

Definition at line 29 of file helper.c.

30{
31 PHELPER_ENTRY pHelper;
32 DWORD dwError;
33
34 pHelper = pHelperListHead;
35 while (pHelper != NULL)
36 {
37 if (pHelper->bStarted == FALSE)
38 {
39 if (pHelper->Attributes.pfnStart)
40 {
41 dwError = pHelper->Attributes.pfnStart(NULL, 0);
42 if (dwError == ERROR_SUCCESS)
43 pHelper->bStarted = TRUE;
44 }
45 }
46
47 pHelper = pHelper->pNext;
48 }
49}
BOOL bStarted
Definition: precomp.h:63
PNS_HELPER_START_FN pfnStart
Definition: netsh.h:106

Referenced by AddHelperCommand(), and LoadHelpers().

◆ UnloadHelpers()

VOID UnloadHelpers ( VOID  )

Definition at line 318 of file helper.c.

319{
321
322 while (pDllListHead != NULL)
323 {
325 pDllListHead = pEntry->pNext;
326
327// if (pEntry->Attributes.pfnStop)
328// pEntry->Attributes.pfnStop(0);
329
331 }
332
334}

Referenced by wmain().

Variable Documentation

◆ pCurrentDll

PDLL_LIST_ENTRY pCurrentDll = NULL

Definition at line 23 of file helper.c.

Referenced by LoadHelperDll(), and RegisterHelper().

◆ pDllListHead

PDLL_LIST_ENTRY pDllListHead = NULL

Definition at line 17 of file helper.c.

Referenced by DeleteHelperCommand(), LoadHelperDll(), and UnloadHelpers().

◆ pDllListTail

PDLL_LIST_ENTRY pDllListTail = NULL

Definition at line 18 of file helper.c.

Referenced by DeleteHelperCommand(), LoadHelperDll(), and UnloadHelpers().

◆ pHelperListHead

PHELPER_ENTRY pHelperListHead = NULL

Definition at line 20 of file helper.c.

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

◆ pHelperListTail

PHELPER_ENTRY pHelperListTail = NULL

Definition at line 21 of file helper.c.

Referenced by RegisterHelper().