ReactOS  0.4.15-dev-4614-ga5a6101
nsplookup.c
Go to the documentation of this file.
1 #include "precomp.h"
2 
3 #include <stdlib.h>
4 #include <ws2spi.h>
5 #include <nspapi.h>
6 #include <winuser.h>
7 #include <windns.h>
8 #include <guiddef.h>
9 #include <svcguid.h>
10 #include <iptypes.h>
11 #include <strsafe.h>
12 #include <winreg.h>
13 
14 #include "mswhelper.h"
15 
16 #define NDEBUG
17 #include <debug.h>
18 
19 #define NSP_CALLID_DNS 0x0001
20 #define NSP_CALLID_HOSTNAME 0x0002
21 #define NSP_CALLID_HOSTBYNAME 0x0003
22 #define NSP_CALLID_SERVICEBYNAME 0x0004
23 
24 #ifndef BUFSIZ
25 #define BUFSIZ 1024
26 #endif // BUFSIZ
27 #ifndef WS2_INTERNAL_MAX_ALIAS
28 #define WS2_INTERNAL_MAX_ALIAS 512
29 #endif // WS2_INTERNAL_MAX_ALIAS
30 
31 //#define IP_LOCALHOST 0x0100007F
32 
33 //#define NSP_REDIRECT
34 
35 typedef struct {
40  CHAR** servaliasesA; /* array */
43 
44 typedef struct {
45  GUID providerId; /* Provider-ID */
46  DWORD dwControlFlags; /* dwControlFlags (WSALookupServiceBegin) */
47  DWORD CallID; /* List for LookupServiceNext-Calls */
48  DWORD CallIDCounter; /* call-count of the current CallID. */
49  WCHAR* hostnameW; /* hostbyname */
50 #ifdef NSP_REDIRECT
51  HANDLE rdrLookup;
52  NSP_ROUTINE rdrproc;
53 #endif
55 
56 static const GUID guid_NULL = {0};
61 
62 /* GUIDs - maybe they should be loaded from registry? */
63 /* Namespace: 32 */
64 static const GUID guid_mswsock_TcpIp = {/*Data1:*/ 0x22059D40,
65  /*Data2:*/ 0x7E9E,
66  /*Data3:*/ 0x11CF,
67  /*Data4:*/ {0xAE, 0x5A, 0x00, 0xAA, 0x00, 0xA7, 0x11, 0x2B}};
68 
69 /* {6642243A-3BA8-4AA6-BAA5-2E0BD71FDD83} */
70 /* Namespace: 15 */
71 static const GUID guid_mswsock_NLA = {/*Data1:*/ 0x6642243A,
72  /*Data2:*/ 0x3BA8,
73  /*Data3:*/ 0x4AA6,
74  /*Data4:*/ {0xBA, 0xA5, 0x2E, 0x0B, 0xD7, 0x1F, 0xDD, 0x83}};
75 
76 #ifdef NSP_REDIRECT
77 
78 typedef INT
79 (CALLBACK *lpRdrNSPStartup)(
80  LPGUID lpProviderId,
81  LPNSP_ROUTINE lpRout);
82 
83 const rdrLib = "mswsock.dll-original";
84 lpRdrNSPStartup rdrNSPStartup;
85 HANDLE hLib;
86 NSP_ROUTINE rdrproc_tcpip;
87 NSP_ROUTINE rdrproc_nla;
88 
89 #endif /* NSP_REDIRECT */
90 
91 /* Forwards */
92 INT
93 WINAPI
95  LPGUID lpProviderId,
96  LPNSP_ROUTINE lpRout);
97 
98 INT
101  CHAR* hostnameA,
102  WCHAR* hostnameW,
103  DWORD CallID);
104 
105 INT
108  _In_ DWORD dwControlFlags,
109  _Inout_ LPWSAQUERYSETW lpRes,
110  _Inout_ LPDWORD lpResLen);
111 
112 INT
114  _Out_ WCHAR** hostname);
115 
116 INT
119  _In_ DWORD dwControlFlags,
120  _Out_ PWSHOSTINFOINTERN hostinfo);
121 
122 INT
125  _In_ DWORD dwControlFlags,
126  _Out_ PWSHOSTINFOINTERN hostinfo);
127 
128 /* Implementations - Internal */
129 
130 INT
131 WSAAPI
132 mwsNSPCleanUp(_In_ LPGUID lpProviderId)
133 {
134  //WSASetLastError(ERROR_CALL_NOT_IMPLEMENTED);
135  //return ERROR_CALL_NOT_IMPLEMENTED;
136  return ERROR_SUCCESS;
137 }
138 
139 INT
141 {
142  return ERROR_SUCCESS;
143 }
144 
145 INT
146 WSAAPI
148  _In_ LPWSAQUERYSETW lpqsRestrictions,
149  _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo,
150  _In_ DWORD dwControlFlags,
151  _Out_ LPHANDLE lphLookup)
152 {
153  PWSHANDLEINTERN pLook;
154  int wsaErr;
155 
156  if (IsEqualGUID(lpProviderId, &guid_mswsock_TcpIp))
157  {
158  //OK
159  }
160  else if (IsEqualGUID(lpProviderId, &guid_mswsock_NLA))
161  {
163  return SOCKET_ERROR;
164  }
165  else
166  {
168  }
169 
170  /* allocate internal structure */
171  pLook = HeapAlloc(GetProcessHeap(), 0, sizeof(WSHANDLEINTERN));
172  if (!pLook)
173  {
175  return SOCKET_ERROR;
176  }
177 
178  *lphLookup = (HANDLE)pLook;
179 
180  RtlZeroMemory(pLook, sizeof(*pLook));
181 
182  /* Anyway the ControlFlags "should" be needed
183  in NSPLookupServiceNext. (see doku) But
184  thats not the fact ATM. */
185  pLook->dwControlFlags = dwControlFlags;
186  pLook->providerId = *lpProviderId;
187 
188 #ifdef NSP_REDIRECT
189 
190  if (IsEqualGUID(lpProviderId, &guid_mswsock_TcpIp))
191  {
192  pLook->rdrproc = rdrproc_tcpip;
193  }
194  else if (IsEqualGUID(lpProviderId, &guid_mswsock_NLA))
195  {
196  pLook->rdrproc = rdrproc_nla;
197  }
198  else
199  {
201  }
202 
203  if (pLook->rdrproc.NSPLookupServiceBegin(lpProviderId,
204  lpqsRestrictions,
205  lpServiceClassInfo,
206  dwControlFlags,
207  &pLook->rdrLookup) == NO_ERROR)
208  {
209  wsaErr = NO_ERROR;
210  }
211  else
212  {
213  wsaErr = WSAGetLastError();
214  }
215 
216  /*
217  if (res)
218  res = WSAGetLastError();
219  */
220 
221 #else /* NSP_REDIRECT */
222 
224  if (IsEqualGUID(lpqsRestrictions->lpServiceClassId, &guid_NULL))
225  {
227  }
228  else if (IsEqualGUID(lpqsRestrictions->lpServiceClassId, &guid_HOSTNAME))
229  {
230  wsaErr = NSP_LookupServiceBeginW(pLook,
231  NULL,
232  NULL,
234  }
235  else if (IsEqualGUID(lpqsRestrictions->lpServiceClassId,
237  {
238  wsaErr = NSP_LookupServiceBeginW(pLook,
239  NULL,
240  lpqsRestrictions->lpszServiceInstanceName,
242  }
243  else if (IsEqualGUID(lpqsRestrictions->lpServiceClassId,
245  {
246  wsaErr = NSP_LookupServiceBeginW(pLook,
247  NULL,
248  lpqsRestrictions->lpszServiceInstanceName,
250  }
251  else if (IsEqualGUID(lpqsRestrictions->lpServiceClassId,
253  {
255  }
256 
257 #endif /* NSP_REDIRECT */
258 
259  if (wsaErr != NO_ERROR)
260  {
261  WSASetLastError(wsaErr);
262  return SOCKET_ERROR;
263  }
264  return NO_ERROR;
265 }
266 
267 INT
268 WSAAPI
270  _In_ DWORD dwControlFlags,
272  //_Out_writes_bytes_to_(*lpdwBufferLength, *lpdwBufferLength)
273  LPWSAQUERYSETW lpqsResults)
274 {
275  PWSHANDLEINTERN pLook = hLookup;
276  int wsaErr = 0;
277 
278 #ifdef NSP_REDIRECT
279 
280  INT res = pLook->rdrproc.NSPLookupServiceNext(pLook->rdrLookup,
281  dwControlFlags,
283  lpqsResults);
284  wsaErr = WSAGetLastError();
285  if (res != ERROR_SUCCESS)
286  {
287  wsaErr = WSAGetLastError();
288 
289  if (wsaErr == 0)
290  wsaErr = 0xFFFFFFFF;
291  }
292 
293 #else /* NSP_REDIRECT */
294 
295  if ((lpdwBufferLength == NULL) || (*lpdwBufferLength == 0))
296  {
297  wsaErr = WSA_NOT_ENOUGH_MEMORY;
298  goto End;
299  }
300 
301  RtlZeroMemory(lpqsResults, *lpdwBufferLength);
302  lpqsResults->dwSize = sizeof(*lpqsResults);
303 
304  wsaErr = NSP_LookupServiceNextW(pLook,
305  dwControlFlags,
306  lpqsResults,
308 
309 
310 #endif /* NSP_REDIRECT */
311 
312 End:
313  if (wsaErr != 0)
314  {
315  WSASetLastError(wsaErr);
316  return SOCKET_ERROR;
317  }
318  return NO_ERROR;
319 }
320 
321 INT
322 WSAAPI
324  _In_ DWORD dwControlCode,
325  _In_reads_bytes_(cbInBuffer) LPVOID lpvInBuffer,
326  _In_ DWORD cbInBuffer,
327  _Out_writes_bytes_to_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer,
328  _In_ DWORD cbOutBuffer,
329  _Out_ LPDWORD lpcbBytesReturned,
330  _In_opt_ LPWSACOMPLETION lpCompletion,
331  _In_ LPWSATHREADID lpThreadId)
332 {
335 }
336 
337 INT
338 WSAAPI
340 {
341  PWSHANDLEINTERN pLook;
342  HANDLE hHeap;
343  INT res;
344 
345  res = NO_ERROR;
346  pLook = (PWSHANDLEINTERN)hLookup;
347  hHeap = GetProcessHeap();
348 
349 #ifdef NSP_REDIRECT
350  res = pLook->rdrproc.NSPLookupServiceEnd(pLook->rdrLookup);
351 #endif
352 
353  if (pLook->hostnameW != NULL)
354  HeapFree(hHeap, 0, pLook->hostnameW);
355 
356  HeapFree(hHeap, 0, pLook);
357  return res;
358 }
359 
360 INT
361 WSAAPI
363  _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo,
364  _In_ LPWSAQUERYSETW lpqsRegInfo,
365  _In_ WSAESETSERVICEOP essOperation,
366  _In_ DWORD dwControlFlags)
367 {
370 }
371 
372 INT
373 WSAAPI
375  _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
376 {
379 }
380 
381 INT
382 WSAAPI
384  _In_ LPGUID lpServiceClassId)
385 {
388 }
389 
390 INT
391 WSAAPI
393  _In_ LPDWORD lpdwBufSize,
394  _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
395 {
398 }
399 
400 /*
401  hostnameA / hostnameW
402  * only used by HOSTBYNAME
403  * only one should be set
404 
405 */
406 INT
408  CHAR* hostnameA,
409  WCHAR* hostnameW,
410  DWORD CallID)
411 {
412  HANDLE hHeap;
413 
414  if (data->CallID != 0)
415  return WSAEFAULT;
416 
417  data->CallID = CallID;
418 
419  if ((CallID == NSP_CALLID_HOSTBYNAME) ||
420  (CallID == NSP_CALLID_SERVICEBYNAME))
421  {
422  hHeap = GetProcessHeap();
423 
424  if (data->hostnameW != NULL)
425  HeapFree(hHeap, 0, data->hostnameW);
426 
427  if (hostnameA != NULL)
428  {
429  data->hostnameW = StrA2WHeapAlloc(hHeap, hostnameA);
430  }
431  else
432  {
433  data->hostnameW = StrCpyHeapAllocW(hHeap, hostnameW);
434  }
435  }
436 
437  WSASetLastError(0);
438 
439  return ERROR_SUCCESS;
440 }
441 
442 INT
444 {
445  WCHAR* name;
446  HANDLE hHeap = GetProcessHeap();
447  DWORD bufCharLen = MAX_COMPUTERNAME_LENGTH + 1;
448  DWORD bufByteLen = bufCharLen * sizeof(WCHAR);
449 
450  name = HeapAlloc(hHeap, 0, bufByteLen);
451 
452  if (!GetComputerNameExW(ComputerNameDnsHostname,
453  name,
454  &bufCharLen))
455  {
456  HeapFree(hHeap, 0, name);
458  return SOCKET_ERROR;
459  }
460 
461  *hostname = name;
462  return ERROR_SUCCESS;
463 }
464 
465 INT
467  _In_ DWORD dwControlFlags,
468  _Out_ PWSHOSTINFOINTERN hostinfo)
469 {
470  HANDLE hHeap = GetProcessHeap();
471  DNS_STATUS dns_status = { 0 };
472  /* include/WinDNS.h -- look up DNS_RECORD on MSDN */
473  PDNS_RECORDW dp;
474  PDNS_RECORDW curr;
476  DWORD dwQueryFlags = DNS_QUERY_STANDARD;
477  PWCHAR Aliases[WS2_INTERNAL_MAX_ALIAS] = { 0 };
478  int AliasIndex = 0;
479 
480  /* needed to be cleaned up if != NULL */
481  dp = NULL;
482 
483  if (data->hostnameW == NULL)
484  {
486  goto cleanup;
487  }
488 
489  if ((data->dwControlFlags & LUP_DEEP) == 0)
490  {
491  dwQueryFlags |= DNS_QUERY_NO_RECURSION;
492  }
493 
494  /* DNS_TYPE_A: include/WinDNS.h */
495  /* DnsQuery -- lib/dnsapi/dnsapi/query.c */
496  dns_status = DnsQuery_W(data->hostnameW,
497  DNS_TYPE_A,
498  dwQueryFlags,
499  NULL /* extra dns servers */,
500  &dp,
501  NULL);
502  if (dns_status == ERROR_INVALID_NAME)
503  {
506  goto cleanup;
507  }
508 
509  if ((dns_status != 0) || (dp == NULL))
510  {
512  goto cleanup;
513  }
514 
515  //ASSERT(dp->wType == DNS_TYPE_A);
516  //ASSERT(dp->wDataLength == sizeof(DNS_A_DATA));
517  curr = dp;
518  while ((curr->pNext != NULL) || (curr->wType != DNS_TYPE_A))
519  {
520  if (curr->wType == DNS_TYPE_CNAME)
521  {
522  Aliases[AliasIndex++] = curr->Data.Cname.pNameHost;
523  }
524  curr = curr->pNext;
525  }
526 
527  if (curr->wType != DNS_TYPE_A)
528  {
530  goto cleanup;
531  }
532  hostinfo->hostnameW = StrCpyHeapAllocW(hHeap, curr->pName);
533  hostinfo->addr4 = curr->Data.A.IpAddress;
534  if (AliasIndex)
535  {
536  hostinfo->servaliasesA = StrAryCpyHeapAllocWToA(hHeap, (WCHAR**)&Aliases);
537  }
539 
540 cleanup:
541  if (dp != NULL)
543 
544  return result;
545 }
546 
547 #define SKIPWS(ptr, act) \
548 {while(*ptr && isspace(*ptr)) ptr++; if(!*ptr) act;}
549 
550 #define SKIPANDMARKSTR(ptr, act) \
551 {while(*ptr && !isspace(*ptr)) ptr++; \
552  if(!*ptr) {act;} else { *ptr = 0; ptr++; }}
553 
554 static
555 BOOL
558  OUT PCHAR *PortNumberStr,
559  OUT PCHAR *ProtocolStr,
560  IN PCHAR *Aliases,
561  IN DWORD MaxAlias)
562 {
563  UINT NAliases = 0;
564 
565  //WS_DbgPrint(MAX_TRACE, ("Parsing service ent [%s]\n", ServiceString));
566 
567  SKIPWS(ServiceString, return FALSE);
568  *ServiceName = ServiceString;
569  SKIPANDMARKSTR(ServiceString, return FALSE);
570  SKIPWS(ServiceString, return FALSE);
571  *PortNumberStr = ServiceString;
572  SKIPANDMARKSTR(ServiceString, ;);
573 
574  while (*ServiceString && NAliases < MaxAlias - 1)
575  {
576  SKIPWS(ServiceString, break);
577  if (*ServiceString)
578  {
579  SKIPWS(ServiceString, ;);
580  if (strlen(ServiceString))
581  {
582  //WS_DbgPrint(MAX_TRACE, ("Alias: %s\n", ServiceString));
583  *Aliases++ = ServiceString;
584  NAliases++;
585  }
586  SKIPANDMARKSTR(ServiceString, ;);
587  }
588  }
589  *Aliases = NULL;
590 
591  *ProtocolStr = strchr(*PortNumberStr, '/');
592 
593  if (!*ProtocolStr)
594  return FALSE;
595 
596  **ProtocolStr = 0;
597  (*ProtocolStr)++;
598 
599  //WS_DbgPrint(MAX_TRACE, ("Parsing done: %s %s %s %d\n",
600  // *ServiceName, *ProtocolStr, *PortNumberStr,
601  // NAliases));
602 
603  return TRUE;
604 }
605 
606 HANDLE
607 WSAAPI
609 {
610  PWSTR ExpandedPath;
612  INT ErrorCode;
613  HKEY DatabaseKey;
614  DWORD RegType;
615  DWORD RegSize = 0;
616  size_t StringLength;
617  HANDLE ret;
618 
619  ExpandedPath = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(WCHAR));
620  if (!ExpandedPath)
621  return INVALID_HANDLE_VALUE;
622 
623  /* Open the database path key */
625  L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters",
626  0,
627  KEY_READ,
628  &DatabaseKey);
629  if (ErrorCode == NO_ERROR)
630  {
631  /* Read the actual path */
632  ErrorCode = RegQueryValueEx(DatabaseKey,
633  L"DatabasePath",
634  NULL,
635  &RegType,
636  NULL,
637  &RegSize);
638 
639  DatabasePath = HeapAlloc(GetProcessHeap(), 0, RegSize);
640  if (!DatabasePath)
641  {
642  HeapFree(GetProcessHeap(), 0, ExpandedPath);
643  return INVALID_HANDLE_VALUE;
644  }
645 
646  /* Read the actual path */
647  ErrorCode = RegQueryValueEx(DatabaseKey,
648  L"DatabasePath",
649  NULL,
650  &RegType,
652  &RegSize);
653 
654  /* Close the key */
655  RegCloseKey(DatabaseKey);
656 
657  /* Expand the name */
659 
661  }
662  else
663  {
664  /* Use defalt path */
665  GetSystemDirectory(ExpandedPath, MAX_PATH);
666  StringCchLength(ExpandedPath, MAX_PATH, &StringLength);
667  if (ExpandedPath[StringLength - 1] != L'\\')
668  {
669  /* It isn't, so add it ourselves */
670  StringCchCat(ExpandedPath, MAX_PATH, L"\\");
671  }
672  StringCchCat(ExpandedPath, MAX_PATH, L"DRIVERS\\ETC\\");
673  }
674 
675  /* Make sure that the path is backslash-terminated */
676  StringCchLength(ExpandedPath, MAX_PATH, &StringLength);
677  if (ExpandedPath[StringLength - 1] != L'\\')
678  {
679  /* It isn't, so add it ourselves */
680  StringCchCat(ExpandedPath, MAX_PATH, L"\\");
681  }
682 
683  /* Add the database name */
684  StringCchCat(ExpandedPath, MAX_PATH, Name);
685 
686  /* Return a handle to the file */
687  ret = CreateFile(ExpandedPath,
690  NULL,
693  NULL);
694 
695  HeapFree(GetProcessHeap(), 0, ExpandedPath);
696  return ret;
697 }
698 
699 INT
701  _In_ DWORD dwControlFlags,
702  _Out_ PWSHOSTINFOINTERN hostinfo)
703 {
704  BOOL Found = FALSE;
705  HANDLE ServicesFile;
706  CHAR ServiceDBData[BUFSIZ * sizeof(WCHAR)] = {0};
707  PCHAR ThisLine = 0, NextLine = 0, ServiceName = 0, PortNumberStr = 0,
708  ProtocolStr = 0, Comment = 0, EndValid;
709  PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS] = {0};
710  PCHAR* AliasPtr;
711  UINT i = 0;
712  DWORD ReadSize = 0;
713  HANDLE hHeap;
714  PCHAR nameA = NULL;
715  PCHAR nameServiceA = NULL;
716  PCHAR nameProtoA = NULL;
718 
719  if (!data->hostnameW)
720  {
722  goto End;
723  }
724 
725  hHeap = GetProcessHeap();
726  nameA = StrW2AHeapAlloc(hHeap, data->hostnameW);
727 
728  /* nameA has the form <service-name>/<protocol>
729  we split these now */
730  nameProtoA = strchr(nameA, '/');
731  if (nameProtoA == NULL)
732  {
734  goto End;
735  }
736 
737  nameProtoA++;
738  i = (DWORD)(nameProtoA - nameA - 1);
739  nameServiceA = (PCHAR)HeapAlloc(hHeap, 0, i + 1);
740  StringCbCopyA(nameServiceA, i + 1, nameA);
741  nameServiceA[i] = '\0';
742 
743  ServicesFile = OpenNetworkDatabase(L"services");
744  if (ServicesFile == INVALID_HANDLE_VALUE)
745  {
746  return WSANO_RECOVERY;
747  }
748 
749  /* Scan the services file ...
750  *
751  * We will be share the buffer on the lines. If the line does not fit in
752  * the buffer, then moving it to the beginning of the buffer and read
753  * the remnants of line from file.
754  */
755 
756  /* Initial Read */
757  ReadFile(ServicesFile,
758  ServiceDBData,
759  sizeof( ServiceDBData ) - 1,
760  &ReadSize,
761  NULL);
762 
763  ThisLine = NextLine = ServiceDBData;
764  EndValid = ServiceDBData + ReadSize;
765  ServiceDBData[sizeof(ServiceDBData) - 1] = '\0';
766 
767  while (ReadSize)
768  {
769  for (; *NextLine != '\r' && *NextLine != '\n'; NextLine++)
770  {
771  if (NextLine == EndValid)
772  {
773  int LineLen = NextLine - ThisLine;
774 
775  if (ThisLine == ServiceDBData)
776  {
777  //WS_DbgPrint(MIN_TRACE,("Line too long"));
778  return WSANO_RECOVERY;
779  }
780 
781  memmove(ServiceDBData, ThisLine, LineLen);
782 
783  ReadFile(ServicesFile,
784  ServiceDBData + LineLen,
785  sizeof( ServiceDBData )-1 - LineLen,
786  &ReadSize,
787  NULL);
788 
789  EndValid = ServiceDBData + LineLen + ReadSize;
790  NextLine = ServiceDBData + LineLen;
791  ThisLine = ServiceDBData;
792 
793  if (!ReadSize) break;
794  }
795  }
796 
797  *NextLine = '\0';
798  Comment = strchr(ThisLine, '#');
799 
800  if (Comment)
801  *Comment = '\0'; /* Terminate at comment start */
802 
803  if (DecodeServEntFromString(ThisLine,
804  &ServiceName,
805  &PortNumberStr,
806  &ProtocolStr,
807  Aliases,
809  (strlen(nameProtoA) == 0 || strcmp(ProtocolStr, nameProtoA) == 0))
810  {
811  Found = (strcmp(ServiceName, nameServiceA) == 0 || strcmp(PortNumberStr, nameServiceA) == 0);
812  AliasPtr = Aliases;
813  while ((!Found) && (*AliasPtr != NULL))
814  {
815  Found = (strcmp(*AliasPtr, nameServiceA) == 0);
816  AliasPtr++;
817  }
818  if (Found)
819  break;
820  }
821  NextLine++;
822  ThisLine = NextLine;
823  }
824 
825  /* This we'll do no matter what */
826  CloseHandle(ServicesFile);
827 
828  if (!Found)
829  {
830  return WSANO_DATA;
831  }
832 
833  hostinfo->addr4 = 0;
834  hostinfo->servnameW = StrA2WHeapAlloc(hHeap, ServiceName);
835  hostinfo->servprotoW = StrA2WHeapAlloc(hHeap, ProtocolStr);
836  hostinfo->servaliasesA = StrAryCpyHeapAllocA(hHeap, (char**)&Aliases);
837  hostinfo->servport = atoi(PortNumberStr);
838 
839  res = NO_ERROR;
840 
841 End:
842  if (nameA != NULL)
843  HeapFree(hHeap, 0, nameA);
844 
845  if (nameServiceA != NULL)
846  HeapFree(hHeap, 0, nameServiceA);
847 
848  return res;
849 }
850 
851 INT
853  _In_ DWORD dwControlFlags,
854  _Inout_ LPWSAQUERYSETW lpRes,
855  _Inout_ LPDWORD lpResLen)
856 {
857  MSW_BUFFER buf;
858  WSHOSTINFOINTERN hostinfo;
859  INT result;
860  HANDLE hHeap = GetProcessHeap();
861  WCHAR* ServiceInstanceNameW = NULL;
862  /* cleanup-vars */
863  CHAR* ServiceInstanceNameA = NULL;
864  CHAR* ServiceProtocolNameA = NULL;
865 
866  RtlZeroMemory(&hostinfo, sizeof(hostinfo));
867 
868  /* init and build result-buffer */
869  mswBufferInit(&buf, (BYTE*)lpRes, *lpResLen);
870  mswBufferIncUsed(&buf, sizeof(*lpRes));
871 
872  /* QueryDataSet-Size without "blob-data"-size! */
873  lpRes->dwSize = sizeof(*lpRes);
874  lpRes->dwNameSpace = NS_DNS;
875 
876  if ((data->CallID == NSP_CALLID_HOSTNAME) ||
877  (data->CallID == NSP_CALLID_HOSTBYNAME) ||
878  (data->CallID == NSP_CALLID_SERVICEBYNAME))
879  {
880  if (data->CallIDCounter >= 1)
881  {
882  result = WSAENOMORE;
883  goto End;
884  }
885  }
886  else
887  {
889  goto End;
890  }
891  data->CallIDCounter++;
892 
893  if (data->CallID == NSP_CALLID_HOSTNAME)
894  {
896 
897  if (result != ERROR_SUCCESS)
898  goto End;
899 
900  hostinfo.addr4 = 0;
901  }
902  else if (data->CallID == NSP_CALLID_HOSTBYNAME)
903  {
905  dwControlFlags,
906  &hostinfo);
907  if (result != ERROR_SUCCESS)
908  goto End;
909  }
910  else
911  {
914  dwControlFlags,
915  &hostinfo);
916  if (result != ERROR_SUCCESS)
917  goto End;
918  }
919 
920  if (((LUP_RETURN_BLOB & data->dwControlFlags) != 0) ||
921  ((LUP_RETURN_NAME & data->dwControlFlags) != 0))
922  {
923  if (data->CallID == NSP_CALLID_HOSTNAME || data->CallID == NSP_CALLID_HOSTBYNAME)
924  {
925  ServiceInstanceNameW = hostinfo.hostnameW;
926  ServiceInstanceNameA = StrW2AHeapAlloc(hHeap, ServiceInstanceNameW);
927  if (ServiceInstanceNameA == NULL)
928  {
929  result = WSAEFAULT;
930  goto End;
931 
932  }
933  }
934  if (data->CallID == NSP_CALLID_SERVICEBYNAME)
935  {
936  ServiceInstanceNameW = hostinfo.servnameW;
937  ServiceInstanceNameA = StrW2AHeapAlloc(hHeap, ServiceInstanceNameW);
938  if (ServiceInstanceNameA == NULL)
939  {
940  result = WSAEFAULT;
941  goto End;
942 
943  }
944  ServiceProtocolNameA = StrW2AHeapAlloc(hHeap, hostinfo.servprotoW);
945  if (ServiceProtocolNameA == NULL)
946  {
947  result = WSAEFAULT;
948  goto End;
949 
950  }
951  }
952  }
953 
954  if ((LUP_RETURN_ADDR & data->dwControlFlags) != 0)
955  {
956  if (!mswBufferAppendAddr_AddrInfoW(&buf, lpRes, hostinfo.addr4))
957  {
958  *lpResLen = buf.bytesUsed;
959  result = WSAEFAULT;
960  goto End;
961  }
962  }
963 
964  if ((LUP_RETURN_BLOB & data->dwControlFlags) != 0)
965  {
966  if (data->CallID == NSP_CALLID_HOSTBYNAME)
967  {
968  /* Write data for PBLOB (hostent) */
970  lpRes,
971  (LUP_RETURN_ALIASES & data->dwControlFlags) != 0 ? hostinfo.servaliasesA : NULL,
972  ServiceInstanceNameA,
973  hostinfo.addr4))
974  {
975  *lpResLen = buf.bytesUsed;
976  result = WSAEFAULT;
977  goto End;
978  }
979  }
980  else if (data->CallID == NSP_CALLID_SERVICEBYNAME)
981  {
982  /* Write data for PBLOB (servent) */
984  lpRes,
985  ServiceInstanceNameA,/* ServiceName */
986  (LUP_RETURN_ALIASES & data->dwControlFlags) != 0 ? hostinfo.servaliasesA : NULL,
987  ServiceProtocolNameA,
988  hostinfo.servport))
989  {
990  *lpResLen = buf.bytesUsed;
991  result = WSAEFAULT;
992  goto End;
993  }
994  }
995  else
996  {
998  goto End;
999  }
1000  }
1001 
1002  if ((LUP_RETURN_NAME & data->dwControlFlags) != 0)
1003  {
1004  /* HostByName sets the ServiceInstanceName to a
1005  (UNICODE)copy of hostent.h_name */
1006  lpRes->lpszServiceInstanceName = (LPWSTR)mswBufferEndPtr(&buf);
1007  if (!mswBufferAppendStrW(&buf, ServiceInstanceNameW))
1008  {
1009  lpRes->lpszServiceInstanceName = NULL;
1010  *lpResLen = buf.bytesUsed;
1011  result = WSAEFAULT;
1012  goto End;
1013  }
1014  }
1015 
1016  *lpResLen = buf.bytesUsed;
1017 
1019 End:
1020  /* cleanup */
1021  if (ServiceInstanceNameA != NULL)
1022  HeapFree(hHeap, 0, ServiceInstanceNameA);
1023 
1024  if (ServiceProtocolNameA != NULL)
1025  HeapFree(hHeap, 0, ServiceProtocolNameA);
1026 
1027  if (hostinfo.hostnameW != NULL)
1028  HeapFree(hHeap, 0, hostinfo.hostnameW);
1029 
1030  if (hostinfo.servnameW != NULL)
1031  HeapFree(hHeap, 0, hostinfo.servnameW);
1032 
1033  if (hostinfo.servprotoW != NULL)
1034  HeapFree(hHeap, 0, hostinfo.servprotoW);
1035 
1036  return result;
1037 }
1038 
1039 /* Implementations - Exports */
1040 /*
1041  * @implemented
1042  */
1043 int
1044 WINAPI
1045 NSPStartup(_In_ LPGUID lpProviderId,
1046  _Out_ LPNSP_ROUTINE lpRout)
1047 {
1048  INT ret;
1049 
1050  if ((lpRout == NULL) ||
1051  (lpRout->cbSize != sizeof(NSP_ROUTINE)))
1052  {
1054  return ERROR_INVALID_PARAMETER;
1055  }
1056 
1057  mwsNSPInit();
1058 
1059  /* set own Provider GUID - maybe we need
1060  here to set the original mswsock-GUID?! */
1061 
1062  /* Win2k3 returns
1063  - Version 1.1
1064  - no NSPIoctl
1065  - sets cbSize to 44! */
1066  lpRout->dwMajorVersion = 1;
1067  lpRout->dwMinorVersion = 1;
1068  lpRout->cbSize = sizeof(*lpRout) - sizeof(lpRout->NSPIoctl);
1069  lpRout->NSPCleanup = &mwsNSPCleanUp;
1070  lpRout->NSPLookupServiceBegin = &mwsNSPLookupServiceBegin;
1071  lpRout->NSPLookupServiceNext = &mwsNSPLookupServiceNext;
1072  lpRout->NSPLookupServiceEnd = &mwsNSPLookupServiceEnd;
1073  lpRout->NSPSetService = &mwsNSPSetService;
1074  lpRout->NSPInstallServiceClass = &mwsNSPInstallServiceClass;
1075  lpRout->NSPRemoveServiceClass = &mwsNSPRemoveServiceClass;
1076  lpRout->NSPGetServiceClassInfo = &mwsNSPGetServiceClassInfo;
1077  lpRout->NSPIoctl = NULL;// &mwsNSPIoCtl;
1078 
1079  ret = NO_ERROR;
1080 
1081  return ret;
1082 }
#define NSP_CALLID_HOSTNAME
Definition: nsplookup.c:20
#define RegQueryValueEx
Definition: winreg.h:524
DNS_A_DATA A
Definition: windns.h:609
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define StringCchLength
Definition: strsafe.h:829
#define SOCKET_ERROR
Definition: winsock.h:333
static const GUID guid_INET_HOSTADDRBYNAME
Definition: nsplookup.c:59
PWSTR DatabasePath
Definition: database.c:31
#define IN
Definition: typedefs.h:39
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define CloseHandle
Definition: compat.h:598
#define WSAEFAULT
Definition: winerror.h:1945
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define WSAHOST_NOT_FOUND
Definition: winerror.h:2000
WCHAR * StrCpyHeapAllocW(_In_opt_ HANDLE hHeap, _In_ WCHAR *wStr)
Definition: mswhelper.c:484
BOOL mswBufferAppendStrW(_Inout_ PMSW_BUFFER mswBuf, _In_ WCHAR *str)
Definition: mswhelper.c:78
#define _In_opt_
Definition: ms_sal.h:309
#define _Inout_
Definition: ms_sal.h:378
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint64EXT * result
Definition: glext.h:11304
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define WSASERVICE_NOT_FOUND
Definition: winerror.h:1995
#define LUP_RETURN_NAME
Definition: winsock2.h:514
#define _Out_
Definition: ms_sal.h:345
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NSP_CALLID_SERVICEBYNAME
Definition: nsplookup.c:22
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define WS2_INTERNAL_MAX_ALIAS
Definition: nsplookup.c:28
#define DNS_TYPE_A
Definition: windns.h:41
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD dwControlFlags
Definition: nsplookup.c:46
BOOL mswBufferAppendBlob_Servent(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ char *serviceNameA, _In_ char **serviceAliasesA, _In_ char *protocolNameA, _In_ WORD port)
Definition: mswhelper.c:294
char CHAR
Definition: xmlstorage.h:175
#define ExpandEnvironmentStrings
Definition: winbase.h:3635
#define INT
Definition: polytest.cpp:20
#define CALLBACK
Definition: compat.h:35
static const GUID guid_INET_HOSTADDRBYINETSTRING
Definition: nsplookup.c:58
INT WSAAPI mwsNSPIoCtl(_In_ HANDLE hLookup, _In_ DWORD dwControlCode, _In_reads_bytes_(cbInBuffer) LPVOID lpvInBuffer, _In_ DWORD cbInBuffer, _Out_writes_bytes_to_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer, _In_ DWORD cbOutBuffer, _Out_ LPDWORD lpcbBytesReturned, _In_opt_ LPWSACOMPLETION lpCompletion, _In_ LPWSATHREADID lpThreadId)
Definition: nsplookup.c:323
void mswBufferInit(_Inout_ PMSW_BUFFER mswBuf, _In_ BYTE *buffer, _In_ DWORD bufferSize)
Definition: mswhelper.c:15
static LPWSAQUERYSETW
Definition: sock.c:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define LUP_DEEP
Definition: winsock2.h:510
#define BUFSIZ
Definition: nsplookup.c:25
#define StringCchCat
Definition: strsafe.h:317
#define NS_DNS
Definition: nspapi.h:16
uint16_t * PWCHAR
Definition: typedefs.h:56
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
#define DNS_TYPE_CNAME
Definition: windns.h:45
char * StrW2AHeapAlloc(_In_opt_ HANDLE hHeap, _In_ WCHAR *wStr)
Definition: mswhelper.c:442
#define NO_ERROR
Definition: dderror.h:5
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:58
WCHAR * servnameW
Definition: nsplookup.c:38
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD nSize)
Definition: compname.c:216
INT WSAAPI mwsNSPGetServiceClassInfo(_In_ LPGUID lpProviderId, _In_ LPDWORD lpdwBufSize, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
Definition: nsplookup.c:392
BOOLEAN NextLine(PCHAR LineBuffer, ULONG BufferSize, FILE *File)
Definition: parser.c:230
static const GUID guid_mswsock_NLA
Definition: nsplookup.c:71
char * hostname
Definition: ftp.c:88
WCHAR * servprotoW
Definition: nsplookup.c:39
#define DNS_QUERY_NO_RECURSION
Definition: windns.h:11
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
INT NSP_GetHostNameHeapAllocW(_Out_ WCHAR **hostname)
Definition: nsplookup.c:443
INT NSP_LookupServiceNextW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Inout_ LPWSAQUERYSETW lpRes, _Inout_ LPDWORD lpResLen)
Definition: nsplookup.c:852
#define L(x)
Definition: ntvdm.h:50
GUID providerId
Definition: nsplookup.c:45
unsigned char * LPBYTE
Definition: typedefs.h:53
char ** StrAryCpyHeapAllocA(_In_opt_ HANDLE hHeap, _In_ char **aStrAry)
Definition: mswhelper.c:530
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _Out_writes_bytes_to_(size, count)
Definition: ms_sal.h:360
HANDLE WSAAPI OpenNetworkDatabase(_In_ LPCWSTR Name)
Definition: nsplookup.c:608
#define FILE_READ_DATA
Definition: nt_native.h:628
DWORD CallIDCounter
Definition: nsplookup.c:48
WCHAR * StrA2WHeapAlloc(_In_opt_ HANDLE hHeap, _In_ char *aStr)
Definition: mswhelper.c:399
DNS_STATUS WINAPI DnsQuery_W(LPCWSTR Name, WORD Type, DWORD Options, PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved)
Definition: query.c:469
STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:161
#define _In_
Definition: ms_sal.h:308
INT WSAAPI mwsNSPInstallServiceClass(_In_ LPGUID lpProviderId, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
Definition: nsplookup.c:374
LPWSTR pNameHost
Definition: windns.h:319
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:123
return Found
Definition: dirsup.c:1270
struct WSHOSTINFOINTERN * PWSHOSTINFOINTERN
IP4_ADDRESS IpAddress
Definition: windns.h:246
#define OPEN_EXISTING
Definition: compat.h:634
#define SKIPWS(ptr, act)
Definition: nsplookup.c:547
CHAR ** servaliasesA
Definition: nsplookup.c:40
INT NSP_GetServiceByNameHeapAllocW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Out_ PWSHOSTINFOINTERN hostinfo)
Definition: nsplookup.c:700
WCHAR * hostnameW
Definition: nsplookup.c:49
#define SVCID_HOSTNAME
Definition: svcguid.h:8
#define PCHAR
Definition: match.c:90
#define NSP_CALLID_HOSTBYNAME
Definition: nsplookup.c:21
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
static BOOL DecodeServEntFromString(IN PCHAR ServiceString, OUT PCHAR *ServiceName, OUT PCHAR *PortNumberStr, OUT PCHAR *ProtocolStr, IN PCHAR *Aliases, IN DWORD MaxAlias)
Definition: nsplookup.c:556
#define WSANO_RECOVERY
Definition: winerror.h:2002
LPTSTR ServiceName
Definition: ServiceMain.c:15
#define GetProcessHeap()
Definition: compat.h:595
BYTE * mswBufferEndPtr(_Inout_ PMSW_BUFFER mswBuf)
Definition: mswhelper.c:51
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
enum _WSAESETSERVICEOP WSAESETSERVICEOP
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
static const GUID guid_NULL
Definition: nsplookup.c:56
#define WSANO_DATA
Definition: winerror.h:2003
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WSAAPI mwsNSPLookupServiceNext(_In_ HANDLE hLookup, _In_ DWORD dwControlFlags, _Inout_ LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults)
Definition: nsplookup.c:269
#define SVCID_INET_SERVICEBYNAME
Definition: svcguid.h:10
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int WINAPI NSPStartup(_In_ LPGUID lpProviderId, _Out_ LPNSP_ROUTINE lpRout)
Definition: nsplookup.c:1045
INT NSP_LookupServiceBeginW(PWSHANDLEINTERN data, CHAR *hostnameA, WCHAR *hostnameW, DWORD CallID)
Definition: nsplookup.c:407
INT mwsNSPInit(VOID)
Definition: nsplookup.c:140
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
INT WSAAPI mwsNSPSetService(_In_ LPGUID lpProviderId, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo, _In_ LPWSAQUERYSETW lpqsRegInfo, _In_ WSAESETSERVICEOP essOperation, _In_ DWORD dwControlFlags)
Definition: nsplookup.c:362
#define GetSystemDirectory
Definition: winbase.h:3703
unsigned char BYTE
Definition: xxhash.c:193
WORD wType
Definition: windns.h:600
static const GUID guid_mswsock_TcpIp
Definition: nsplookup.c:64
#define LUP_RETURN_ADDR
Definition: winsock2.h:518
#define SKIPANDMARKSTR(ptr, act)
Definition: nsplookup.c:550
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
INT WSAAPI mwsNSPRemoveServiceClass(_In_ LPGUID lpProviderId, _In_ LPGUID lpServiceClassId)
Definition: nsplookup.c:383
char ** StrAryCpyHeapAllocWToA(_In_opt_ HANDLE hHeap, _In_ WCHAR **wStrAry)
Definition: mswhelper.c:596
#define RegOpenKeyEx
Definition: winreg.h:520
#define LUP_RETURN_BLOB
Definition: winsock2.h:519
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
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
INT NSP_GetHostByNameHeapAllocW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Out_ PWSHOSTINFOINTERN hostinfo)
Definition: nsplookup.c:466
#define WSAAPI
Definition: winsock2.h:584
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
INT WSAAPI mwsNSPLookupServiceBegin(_In_ LPGUID lpProviderId, _In_ LPWSAQUERYSETW lpqsRestrictions, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo, _In_ DWORD dwControlFlags, _Out_ LPHANDLE lphLookup)
Definition: nsplookup.c:147
#define DNS_QUERY_STANDARD
Definition: windns.h:8
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
BOOL mswBufferIncUsed(_Inout_ PMSW_BUFFER mswBuf, _In_ DWORD count)
Definition: mswhelper.c:39
char * strchr(const char *String, int ch)
Definition: utclib.c:501
INT WSAAPI mwsNSPCleanUp(_In_ LPGUID lpProviderId)
Definition: nsplookup.c:132
WCHAR * hostnameW
Definition: nsplookup.c:36
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:38
struct _DnsRecordW * pNext
Definition: windns.h:598
#define OUT
Definition: typedefs.h:40
GLuint res
Definition: glext.h:9613
uint32_t * LPDWORD
Definition: typedefs.h:59
#define WSAENOMORE
Definition: winerror.h:1989
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
INT WINAPI mswNSPStartup(LPGUID lpProviderId, LPNSP_ROUTINE lpRout)
INT WSAAPI mwsNSPLookupServiceEnd(_In_ HANDLE hLookup)
Definition: nsplookup.c:339
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_INVALID_NAME
Definition: compat.h:103
BOOL mswBufferAppendAddr_AddrInfoW(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ DWORD ip4addr)
Definition: mswhelper.c:352
_In_ _In_opt_ _Out_writes_bytes_to_opt_ lpdwBufferLength _Inout_ LPDWORD lpdwBufferLength
Definition: winhttp.h:675
static const GUID guid_HOSTNAME
Definition: nsplookup.c:57
#define SVCID_INET_HOSTADDRBYINETSTRING
Definition: svcguid.h:9
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL mswBufferAppendBlob_Hostent(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ char **hostAliasesA, _In_ char *hostnameA, _In_ DWORD ip4addr)
Definition: mswhelper.c:227
union _DnsRecordW::@3254 Data
DNS_PTR_DATAW Cname
Definition: windns.h:611
#define HeapFree(x, y, z)
Definition: compat.h:594
static const GUID guid_INET_SERVICEBYNAME
Definition: nsplookup.c:60
#define RegCloseKey(hKey)
Definition: registry.h:47
struct WSHANDLEINTERN * PWSHANDLEINTERN
#define SVCID_INET_HOSTADDRBYNAME
Definition: svcguid.h:11
DWORD CallID
Definition: nsplookup.c:47
LPWSTR pName
Definition: windns.h:599
#define LUP_RETURN_ALIASES
Definition: winsock2.h:520
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
GLuint const GLchar * name
Definition: glext.h:6031