ReactOS 0.4.17-dev-470-gf9e3448
netsh_undoc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID WINAPI FreeQuotedString (_In_ LPWSTR pszQuotedString)
 
VOID WINAPI FreeString (_In_ LPWSTR pszString)
 
LPWSTR WINAPI MakeQuotedString (_In_ LPWSTR pszString)
 
LPWSTR CDECL MakeString (_In_ HANDLE hModule, _In_ DWORD dwMsgId,...)
 
DWORD WINAPI MatchTagsInCmdLine (_In_ HANDLE hModule, _Inout_ LPWSTR *ppwcArguments, _In_ DWORD dwCurrentIndex, _In_ DWORD dwArgCount, _Inout_ TAG_TYPE *pttTags, _In_ DWORD dwTagCount, _Out_ DWORD *pdwTagType)
 
DWORD WINAPI NsGetFriendlyNameFromIfName (_In_ DWORD dwParam1, _In_ PWSTR pszIfName, _Inout_ PWSTR pszFriendlyName, _Inout_ PDWORD pdwFriendlyName)
 
DWORD WINAPI NsGetIfNameFromFriendlyName (_In_ DWORD dwUnknown1, _In_ PWSTR pszFriendlyName, _Inout_ PWSTR pszIfName, _Inout_ PDWORD pdwIfName)
 

Function Documentation

◆ FreeQuotedString()

VOID WINAPI FreeQuotedString ( _In_ LPWSTR  pszQuotedString)

Definition at line 272 of file netsh.c.

274{
275 DPRINT("FreeQuotedString(%S)\n", pszQuotedString);
276 HeapFree(GetProcessHeap(), 0, pszQuotedString);
277}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define DPRINT
Definition: sndvol32.h:73

◆ FreeString()

VOID WINAPI FreeString ( _In_ LPWSTR  pszString)

Definition at line 281 of file netsh.c.

283{
284 DPRINT("FreeString(%S)\n", pszString);
285 LocalFree(pszString);
286}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594

Referenced by CreateProcessInternalW(), IKsFilterFactory_fnInitialize(), and LoadLibraryExW().

◆ MakeQuotedString()

LPWSTR WINAPI MakeQuotedString ( _In_ LPWSTR  pszString)

Definition at line 290 of file netsh.c.

292{
293 LPWSTR pszQuotedString;
294
295 DPRINT("MakeQuotedString(%S)\n", pszString);
296
297 pszQuotedString = HeapAlloc(GetProcessHeap(), 0, (wcslen(pszString) + 3) * sizeof(WCHAR));
298 if (pszQuotedString == NULL)
299 return NULL;
300
301 _swprintf(pszQuotedString, L"\"%s\"", pszString);
302
303 return pszQuotedString;
304}
#define NULL
Definition: types.h:112
#define HeapAlloc
Definition: compat.h:733
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define L(x)
Definition: resources.c:13
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
short WCHAR
Definition: pedump.c:58
uint16_t * LPWSTR
Definition: typedefs.h:56

◆ MakeString()

LPWSTR CDECL MakeString ( _In_ HANDLE  hModule,
_In_ DWORD  dwMsgId,
  ... 
)

Definition at line 308 of file netsh.c.

312{
313 LPCWSTR pszStr;
314 LPWSTR pszInBuffer, pszOutBuffer = NULL;
316 va_list ap;
317
318 DPRINT("MakeString(%p %lu ...)\n", hModule, dwMsgId);
319
320 dwLength = LoadStringW(hModule, dwMsgId, (LPWSTR)&pszStr, 0);
321 if (dwLength == 0)
322 return NULL;
323
324 /* Allocate and copy the resource string, NUL-terminated */
325 pszInBuffer = HeapAlloc(GetProcessHeap(), 0, (dwLength + 1) * sizeof(WCHAR));
326 if (pszInBuffer == NULL)
327 return NULL;
328 CopyMemory(pszInBuffer, pszStr, dwLength * sizeof(WCHAR));
329 pszInBuffer[dwLength] = UNICODE_NULL;
330
331 va_start(ap, dwMsgId);
333 pszInBuffer,
334 0,
335 0,
336 (LPWSTR)&pszOutBuffer,
337 0,
338 &ap);
339 va_end(ap);
340
341 HeapFree(GetProcessHeap(), 0, pszInBuffer);
342
343 return pszOutBuffer;
344}
HMODULE hModule
Definition: animate.c:44
static DWORD DWORD * dwLength
Definition: fusion.c:86
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CopyMemory
Definition: minwinbase.h:29
#define UNICODE_NULL
#define LoadStringW
Definition: utils.h:64
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ MatchTagsInCmdLine()

DWORD WINAPI MatchTagsInCmdLine ( _In_ HANDLE  hModule,
_Inout_ LPWSTR ppwcArguments,
_In_ DWORD  dwCurrentIndex,
_In_ DWORD  dwArgCount,
_Inout_ TAG_TYPE pttTags,
_In_ DWORD  dwTagCount,
_Out_ DWORD pdwTagType 
)

Definition at line 377 of file netsh.c.

385{
386 PWSTR pszEqual;
387 DWORD i, j, dwTagLength;
388
389 DPRINT1("MatchTagsInCmdLine(%p %p %lu %lu %p %lu %p)\n",
391 pttTags, dwTagCount, pdwTagType);
392
393 /* Identify tagged arguments (tag=value) */
394 for (i = dwCurrentIndex; i < dwArgCount; i++)
395 {
396 DPRINT("Argument %lu: %S\n", i, ppwcArguments[i]);
397 pdwTagType[i - dwCurrentIndex] = (DWORD)-1;
398
399 /* Skip arguments that do not have a tag */
400 pszEqual = wcschr(ppwcArguments[i], L'=');
401 if (pszEqual == NULL)
402 continue;
403
404 dwTagLength = pszEqual - ppwcArguments[i];
405 DPRINT("Tag length %lu\n", dwTagLength);
406 DPRINT("Value length %lu\n", wcslen(pszEqual + 1));
407
408 pdwTagType[i - dwCurrentIndex] = (DWORD)-1;
409 for (j = 0; j < dwTagCount; j++)
410 {
411 DPRINT("Test tag %S -- %S\n", pttTags[j].pwszTag, ppwcArguments[i]);
412 if ((wcslen(pttTags[j].pwszTag) == dwTagLength) &&
413 (_wcsnicmp(ppwcArguments[i], pttTags[j].pwszTag, dwTagLength) == 0))
414 {
415 DPRINT("Found tag %S\n", pttTags[j].pwszTag);
416 pttTags[j].bPresent = TRUE;
417 pdwTagType[i - dwCurrentIndex] = j;
418
419 /* Remove the tag name from the argument */
420 wcscpy(ppwcArguments[i], pszEqual + 1);
421 break;
422 }
423 }
424 }
425
426 /* Identify un-tagged arguments (value) */
427 for (i = dwCurrentIndex; i < dwArgCount; i++)
428 {
429 if (pdwTagType[i - dwCurrentIndex] != (DWORD)-1)
430 continue;
431
432 for (j = 0; j < dwTagCount; j++)
433 {
434 DPRINT("Test tag %S\n", pttTags[j].pwszTag);
435 if (pttTags[j].bPresent == FALSE)
436 {
437 DPRINT("Found tag %S\n", pttTags[j].pwszTag);
438 pttTags[j].bPresent = TRUE;
439 pdwTagType[i - dwCurrentIndex] = j;
440 break;
441 }
442 }
443 }
444
445 return ERROR_SUCCESS;
446}
#define DPRINT1
Definition: precomp.h:8
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:200
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
_In_ LPWSTR * ppwcArguments
Definition: netsh.h:114
_In_ LPWSTR _In_ DWORD dwArgCount
Definition: netsh.h:115
_In_ LPWSTR _In_ DWORD dwCurrentIndex
Definition: netsh.h:139
#define DWORD
Definition: nt_native.h:44
wcscpy
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by IpAddAddress(), IpAddDns(), IpDeleteAddress(), IpDeleteArpCache(), IpDeleteDns(), IpSetAddress(), IpSetDns(), and PreprocessCommand().

◆ NsGetFriendlyNameFromIfName()

DWORD WINAPI NsGetFriendlyNameFromIfName ( _In_ DWORD  dwParam1,
_In_ PWSTR  pszIfName,
_Inout_ PWSTR  pszFriendlyName,
_Inout_ PDWORD  pdwFriendlyName 
)

Definition at line 464 of file netsh.c.

469{
470 UNICODE_STRING UnicodeIfName;
473 DWORD ret;
474
475 DPRINT("NsGetFriendlyNameFromIfName(%lx %S %p %p)\n",
476 dwUnknown1, pszIfName, pszFriendlyName, pdwFriendlyName);
477
478 RtlInitUnicodeString(&UnicodeIfName, pszIfName);
479 Status = RtlGUIDFromString(&UnicodeIfName,
481 if (!NT_SUCCESS(Status))
482 {
483 DPRINT1("RtlGUIDFromString failed 0x%08lx\n", Status);
485 }
486
488 pszFriendlyName,
489 pdwFriendlyName,
490 0, 0);
491 if (ret != ERROR_SUCCESS)
492 {
493 DPRINT1("NhGetInterfaceNameFromDeviceGuid() failed %lu\n", ret);
494 }
495
496 return ret;
497}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
return ret
Definition: mutex.c:146
Status
Definition: gdiplustypes.h:24
DWORD WINAPI NhGetInterfaceNameFromDeviceGuid(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static const GUID InterfaceGuid
Definition: wlanapi.c:25

◆ NsGetIfNameFromFriendlyName()

DWORD WINAPI NsGetIfNameFromFriendlyName ( _In_ DWORD  dwUnknown1,
_In_ PWSTR  pszFriendlyName,
_Inout_ PWSTR  pszIfName,
_Inout_ PDWORD  pdwIfName 
)

Definition at line 501 of file netsh.c.

506{
507 UNICODE_STRING UnicodeIfName;
510 DWORD ret;
511
512 DPRINT("NsGetIfNameFromFriendlyName(%lx %S %p %p)\n",
513 dwUnknown1, pszFriendlyName, pszIfName, pdwIfName);
514
515 ret = NhGetGuidFromInterfaceName(pszFriendlyName,
517 0, 0);
518 if (ret != ERROR_SUCCESS)
519 {
520 DPRINT1("NhGetGuidFromInterfaceName failed %lu\n", ret);
521 return ret;
522 }
523
524 RtlInitUnicodeString(&UnicodeIfName, NULL);
526 &UnicodeIfName);
527 if (!NT_SUCCESS(Status))
528 {
529 DPRINT1("RtlStringFromGUID failed 0x%08lx\n", Status);
531 }
532
533 if (*pdwIfName >= UnicodeIfName.MaximumLength)
534 {
535 CopyMemory(pszIfName, UnicodeIfName.Buffer, UnicodeIfName.MaximumLength);
536 *pdwIfName = UnicodeIfName.MaximumLength;
537 }
538
539 RtlFreeUnicodeString(&UnicodeIfName);
540
541 return ret;
542}
DWORD WINAPI NhGetGuidFromInterfaceName(_In_ PWCHAR pInterfaceName, _Out_ GUID *pInterfaceGUID, DWORD dwUnknown3, DWORD dwUnknown4)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)