ReactOS  0.4.14-dev-98-gb0d4763
rnr.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS WinSock 2 API
4  * FILE: dll/win32/ws2_32_new/src/rnr.c
5  * PURPOSE: Registration and Resolution Support
6  * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ws2_32.h>
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* FUNCTIONS *****************************************************************/
17 
18 /*
19  * @implemented
20  */
21 INT
22 WSAAPI
24  IN DWORD dwAddressLength,
25  IN LPWSAPROTOCOL_INFOA lpProtocolInfo,
26  OUT LPSTR lpszAddressString,
27  IN OUT LPDWORD lpdwAddressStringLength)
28 {
33  PTCATALOG Catalog;
34  PTCATALOG_ENTRY CatalogEntry;
36  DWORD Length = *lpdwAddressStringLength;
37 
38  DPRINT("WSAAddressToStringA: %p\n", lpsaAddress);
39 
40  /* Enter prolog */
42  {
43  /* Leave now */
45  return SOCKET_ERROR;
46  }
47 
48  /* Allocate the unicode string */
50  if (!UnicodeString)
51  {
52  /* No memory; fail */
54  return SOCKET_ERROR;
55  }
56 
57  /* Get the catalog */
58  Catalog = WsProcGetTCatalog(Process);
59 
60  /* Check if we got custom protocol info */
61  if (lpProtocolInfo)
62  {
63  /* Get the entry ID */
64  CatalogEntryId = lpProtocolInfo->dwCatalogEntryId;
65 
66  /* Get the entry associated with it */
69  &CatalogEntry);
70  }
71  else
72  {
73  /* Get it from the address family */
74  ErrorCode = WsTcGetEntryFromAf(Catalog,
75  lpsaAddress->sa_family,
76  &CatalogEntry);
77  }
78 
79  /* Check for success */
80  if (ErrorCode == ERROR_SUCCESS)
81  {
82  /* Call the provider */
83  Status = CatalogEntry->Provider->Service.lpWSPAddressToString(lpsaAddress,
84  dwAddressLength,
85  &CatalogEntry->
86  ProtocolInfo,
88  lpdwAddressStringLength,
89  &ErrorCode);
90  if (Status == ERROR_SUCCESS)
91  {
92  /* Convert the string */
94  0,
96  -1,
97  lpszAddressString,
98  Length,
99  NULL,
100  NULL);
101  }
102 
103  /* Dereference the entry */
104  WsTcEntryDereference(CatalogEntry);
105 
106  /* Free the unicode string */
108 
109  /* Check for success and return */
110  if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
111  }
112  else
113  {
114  /* Free the unicode string */
116  }
117 
118  /* Set the error and return */
120  return SOCKET_ERROR;
121 }
122 
123 /*
124  * @implemented
125  */
126 INT
127 WSAAPI
129  IN DWORD dwAddressLength,
130  IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
131  OUT LPWSTR lpszAddressString,
132  IN OUT LPDWORD lpdwAddressStringLength)
133 {
138  PTCATALOG Catalog;
139  PTCATALOG_ENTRY CatalogEntry;
140 
141  DPRINT("WSAAddressToStringW: %p\n", lpsaAddress);
142 
143  /* Enter prolog */
145  {
146  /* Leave now */
148  return SOCKET_ERROR;
149  }
150 
151  /* Get the catalog */
152  Catalog = WsProcGetTCatalog(Process);
153 
154  /* Check if we got custom protocol info */
155  if (lpProtocolInfo)
156  {
157  /* Get the entry ID */
158  CatalogEntryId = lpProtocolInfo->dwCatalogEntryId;
159 
160  /* Get the entry associated with it */
163  &CatalogEntry);
164  }
165  else
166  {
167  /* Get it from the address family */
168  ErrorCode = WsTcGetEntryFromAf(Catalog,
169  lpsaAddress->sa_family,
170  &CatalogEntry);
171  }
172 
173  /* Check for success */
174  if (ErrorCode == ERROR_SUCCESS)
175  {
176  /* Call the provider */
177  Status = CatalogEntry->Provider->Service.lpWSPAddressToString(lpsaAddress,
178  dwAddressLength,
179  &CatalogEntry->
180  ProtocolInfo,
181  lpszAddressString,
182  lpdwAddressStringLength,
183  &ErrorCode);
184 
185  /* Dereference the entry */
186  WsTcEntryDereference(CatalogEntry);
187 
188  /* Check for success and return */
189  if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
190  }
191 
192  /* Set the error and return */
194  return SOCKET_ERROR;
195 }
196 
197 /*
198  * @implemented
199  */
200 INT
201 WSAAPI
203 {
206  INT ErrorCode;
207  PNSQUERY Query = hLookup;
208 
209  DPRINT("WSALookupServiceEnd: %lx\n", hLookup);
210 
211  /* Enter prolog */
213  {
214  /* Leave now */
216  return SOCKET_ERROR;
217  }
218 
219  /* Check for a valid handle, then validate and reference it */
221  {
222  /* Fail */
224  return SOCKET_ERROR;
225  }
226 
227  /* Do the lookup */
229 
230  /* Remove the validation reference */
232 
233  /* Remove the keep-alive */
235 
236  /* Return */
237  return ERROR_SUCCESS;
238 }
239 
240 /*
241  * @implemented
242  */
243 INT
244 WSAAPI
246  IN DWORD dwControlFlags,
247  OUT LPHANDLE lphLookup)
248 {
249  INT ErrorCode;
250  LPWSAQUERYSETW UnicodeQuerySet = NULL;
251  SIZE_T UnicodeQuerySetSize = 0;
252 
253  DPRINT("WSALookupServiceBeginA: %p\n", lpqsRestrictions);
254 
255  /* Verify pointer */
256  if (IsBadReadPtr(lpqsRestrictions, sizeof(*lpqsRestrictions)) ||
257  IsBadReadPtr(lpqsRestrictions->lpServiceClassId, sizeof(*lpqsRestrictions->lpServiceClassId)))
258  {
259  /* Invalid */
261  return SOCKET_ERROR;
262  }
263 
264  /* Clear the reserved fields */
265  lpqsRestrictions->dwOutputFlags = 0;
266  lpqsRestrictions->lpszComment = NULL;
267  lpqsRestrictions->dwNumberOfCsAddrs = 0;
268 
269  /* Find out the side we'll need */
270  ErrorCode = MapAnsiQuerySetToUnicode(lpqsRestrictions,
271  &UnicodeQuerySetSize,
272  UnicodeQuerySet);
273 
274  /* We should've failed */
275  if (ErrorCode == WSAEFAULT)
276  {
277  /* Allocate the buffer we'll need */
278  UnicodeQuerySet = HeapAlloc(WsSockHeap, 0, UnicodeQuerySetSize);
279  if (UnicodeQuerySet)
280  {
281  /* Do the conversion for real */
282  ErrorCode = MapAnsiQuerySetToUnicode(lpqsRestrictions,
283  &UnicodeQuerySetSize,
284  UnicodeQuerySet);
285  if (ErrorCode == ERROR_SUCCESS)
286  {
287  /* Now call the Unicode function */
288  ErrorCode = WSALookupServiceBeginW(UnicodeQuerySet,
289  dwControlFlags,
290  lphLookup);
291  }
292 
293  /* Free our buffer */
294  HeapFree(WsSockHeap, 0, UnicodeQuerySet);
295  }
296  else
297  {
298  /* No memory to allocate */
300  }
301  }
302 
303  /* Set the error in case of failure */
304  if (ErrorCode != ERROR_SUCCESS)
306 
307  /* Return to caller */
309 }
310 
311 /*
312  * @implemented
313  */
314 INT
315 WINAPI
317  IN DWORD dwControlFlags,
318  OUT LPHANDLE lphLookup)
319 {
322  INT ErrorCode;
323  PNSQUERY Query;
324 
325  DPRINT("WSALookupServiceBeginW: %p\n", lpqsRestrictions);
326 
327  /* Enter prolog */
329  {
330  /* Leave now */
332  return SOCKET_ERROR;
333  }
334 
335  /* Verify pointers */
336  if (IsBadWritePtr(lphLookup, sizeof(*lphLookup)) ||
337  IsBadReadPtr(lpqsRestrictions, sizeof(*lpqsRestrictions)) ||
338  IsBadReadPtr(lpqsRestrictions->lpServiceClassId, sizeof(*lpqsRestrictions->lpServiceClassId)))
339  {
340  /* They are invalid; fail */
342  return SOCKET_ERROR;
343  }
344 
345  /* Create a new query object */
346  if ((Query = WsNqAllocate()))
347  {
348  /* Initialize it */
350 
351  /* Do the lookup */
353  lpqsRestrictions,
354  dwControlFlags,
356 
357  /* Check for success */
358  if (ErrorCode == ERROR_SUCCESS)
359  {
360  /* Return the handle */
361  *lphLookup = Query;
362  }
363  else
364  {
365  /* Fail */
366  *lphLookup = NULL;
367  WsNqDelete(Query);
368  }
369  }
370  else
371  {
372  /* No memory */
375  }
376 
377  /* Return */
378  return ErrorCode;
379 }
380 
381 /*
382  * @implemented
383  */
384 INT
385 WINAPI
387  IN DWORD dwControlFlags,
389  OUT LPWSAQUERYSETW lpqsResults)
390 {
393  INT ErrorCode;
394  PNSQUERY Query = hLookup;
395 
396  DPRINT("WSALookupServiceNextW: %lx\n", hLookup);
397 
398  /* Enter prolog */
400  {
401  /* Leave now */
403  return SOCKET_ERROR;
404  }
405 
406  /*
407  * Verify pointers. Note that the size of the buffer
408  * pointed by lpqsResults is given by *lpdwBufferLength.
409  */
411  IsBadWritePtr(lpqsResults, *lpdwBufferLength))
412  {
413  /* It is invalid; fail */
415  return SOCKET_ERROR;
416  }
417 
418  /* Check for a valid handle, then validate and reference it */
420  {
421  /* Fail */
423  return SOCKET_ERROR;
424  }
425 
426  /* Do the lookup */
428  dwControlFlags,
430  lpqsResults);
431 
432  /* Remove the validation reference */
434 
435  /* Return */
436  return ErrorCode;
437 }
438 
439 /*
440  * @implemented
441  */
442 INT
443 WSAAPI
445  IN DWORD dwControlFlags,
447  OUT LPWSAQUERYSETA lpqsResults)
448 {
449  LPWSAQUERYSETW UnicodeQuerySet;
450  DWORD UnicodeQuerySetSize;
451  INT ErrorCode;
452 
453  DPRINT("WSALookupServiceNextA: %lx\n", hLookup);
454 
455  /*
456  * Verify pointers. Note that the size of the buffer
457  * pointed by lpqsResults is given by *lpdwBufferLength.
458  */
460  IsBadWritePtr(lpqsResults, *lpdwBufferLength))
461  {
462  /* It is invalid; fail */
464  return SOCKET_ERROR;
465  }
466 
467  UnicodeQuerySetSize = *lpdwBufferLength;
468 
469  /* Check how much the user is giving */
470  if (UnicodeQuerySetSize >= sizeof(WSAQUERYSETW))
471  {
472  /* Allocate the buffer we'll use */
473  UnicodeQuerySet = HeapAlloc(WsSockHeap, 0, UnicodeQuerySetSize);
474  if (!UnicodeQuerySet)
475  {
476  /*
477  * We failed, possibly because the specified size was too large?
478  * Retrieve the needed buffer size with the WSALookupServiceNextW
479  * call and retry again a second time.
480  */
481  UnicodeQuerySetSize = 0;
482  }
483  }
484  else
485  {
486  /*
487  * The buffer is too small. Retrieve the needed buffer size with
488  * the WSALookupServiceNextW call and return it to the caller.
489  */
490  UnicodeQuerySet = NULL;
491  UnicodeQuerySetSize = 0;
492  }
493 
494  /* Call the Unicode Function */
496  dwControlFlags,
497  &UnicodeQuerySetSize,
498  UnicodeQuerySet);
499 
500  /*
501  * Check whether we actually just retrieved the needed buffer size
502  * because our previous local allocation did fail. If so, allocate
503  * a new buffer and retry again.
504  */
505  if ( (!UnicodeQuerySet) && (*lpdwBufferLength >= sizeof(WSAQUERYSETW)) &&
507  {
508  /* Allocate the buffer we'll use */
509  UnicodeQuerySet = HeapAlloc(WsSockHeap, 0, UnicodeQuerySetSize);
510  if (UnicodeQuerySet)
511  {
512  /* Call the Unicode Function */
514  dwControlFlags,
515  &UnicodeQuerySetSize,
516  UnicodeQuerySet);
517  }
518  /*
519  * Otherwise the allocation failed and we
520  * fall back into the error checks below.
521  */
522  }
523 
524  if (ErrorCode == ERROR_SUCCESS)
525  {
526  SIZE_T SetSize = *lpdwBufferLength;
527 
528  /* Now convert back to ANSI */
529  ErrorCode = MapUnicodeQuerySetToAnsi(UnicodeQuerySet,
530  &SetSize,
531  lpqsResults);
532  if (ErrorCode != ERROR_SUCCESS)
533  {
535  }
536  else if (SetSize > MAXDWORD)
537  {
540  }
541  else
542  {
543  *lpdwBufferLength = SetSize;
544  }
545  }
546  else
547  {
548  /* Check if we ran out of space */
549  if (GetLastError() == WSAEFAULT)
550  {
551  /* Return how much space we'll need, including padding */
552  *lpdwBufferLength = UnicodeQuerySetSize +
553  ((sizeof(ULONG) * 6) - (6 * 1));
554  }
555  }
556 
557  /* If we had a local buffer, free it */
558  if (UnicodeQuerySet)
559  HeapFree(WsSockHeap, 0, UnicodeQuerySet);
560 
561  /* Return to caller */
563 }
564 
565 /*
566  * @unimplemented
567  */
568 INT
569 WSPAPI
571  DWORD dwControlCode,
572  LPVOID lpvInBuffer,
573  DWORD cbInBuffer,
574  LPVOID lpvOutBuffer,
575  DWORD cbOutBuffer,
576  LPDWORD lpcbBytesReturned,
577  LPWSACOMPLETION lpCompletion)
578 {
579  DPRINT("WSANSPIoctl: %lx\n", hLookup);
580  return 0;
581 }
582 
583 /*
584  * @unimplemented
585  */
586 INT
587 WSAAPI
588 WSARemoveServiceClass(IN LPGUID lpServiceClassId)
589 {
590  DPRINT("WSARemoveServiceClass: %lx\n", lpServiceClassId);
592  return SOCKET_ERROR;
593 }
594 
595 /*
596  * @unimplemented
597  */
598 INT
599 WSAAPI
601  IN WSAESETSERVICEOP essOperation,
602  IN DWORD dwControlFlags)
603 {
604  DPRINT("WSASetServiceA: %lx\n", lpqsRegInfo);
606  return SOCKET_ERROR;
607 }
608 
609 /*
610  * @unimplemented
611  */
612 INT
613 WSAAPI
615  IN WSAESETSERVICEOP essOperation,
616  IN DWORD dwControlFlags)
617 {
618  DPRINT("WSASetServiceW: %lx\n", lpqsRegInfo);
620  return SOCKET_ERROR;
621 }
622 
623 /*
624  * @unimplemented
625  */
626 INT
627 WSAAPI
629  IN LPGUID lpServiceClassId,
631  OUT LPWSASERVICECLASSINFOA lpServiceClassInfo)
632 {
633  DPRINT("WSAGetServiceClassInfoA: %lx\n", lpProviderId);
635  return SOCKET_ERROR;
636 }
637 
638 /*
639  * @unimplemented
640  */
641 INT
642 WSAAPI
644  IN LPGUID lpServiceClassId,
646  OUT LPWSASERVICECLASSINFOW lpServiceClassInfo)
647 {
648  DPRINT("WSAGetServiceClassInfoW: %lx\n", lpProviderId);
650  return SOCKET_ERROR;
651 }
652 
653 /*
654  * @unimplemented
655  */
656 INT
657 WSAAPI
661 {
662  DPRINT("WSAGetServiceClassNameByClassIdA: %lx\n", lpServiceClassId);
664  return SOCKET_ERROR;
665 }
666 
667 /*
668  * @unimplemented
669  */
670 INT
671 WSAAPI
675 {
676  DPRINT("WSAGetServiceClassNameByClassIdW: %lx\n", lpServiceClassId);
678  return SOCKET_ERROR;
679 }
680 
681 /*
682  * @unimplemented
683  */
684 INT
685 WSAAPI
687 {
688  DPRINT("WSAInstallServiceClassA: %lx\n", lpServiceClassInfo);
690  return SOCKET_ERROR;
691 }
692 
693 /*
694 * @unimplemented
695 */
696 INT
697 WSAAPI
699 {
700  DPRINT("WSAInstallServiceClassW: %lx\n", lpServiceClassInfo);
702  return SOCKET_ERROR;
703 }
704 
705 VOID
706 WSAAPI
709 {
710  INT size = Context->Unicode ? sizeof(WSANAMESPACE_INFOW) : sizeof(WSANAMESPACE_INFOA);
711  /* Calculate ProviderName string size */
712  INT size1 = Entry->ProviderName ? wcslen(Entry->ProviderName) + 1 : 0;
713  INT size2 = Context->Unicode ? size1 * sizeof(WCHAR) : size1 * sizeof(CHAR);
715  /* Fill NS Provider data */
716  infoW.dwNameSpace = Entry->NamespaceId;
717  infoW.dwVersion = Entry->Version;
718  infoW.fActive = Entry->Enabled;
719  RtlMoveMemory(&infoW.NSProviderId,
720  &Entry->ProviderId,
721  sizeof(infoW.NSProviderId));
722  if (size2)
723  {
724  /* Calculate ProviderName string pointer */
725  infoW.lpszIdentifier = (LPWSTR)((ULONG_PTR)Context->ProtocolBuffer +
726  Context->BufferUsed + size);
727  }
728  else
729  {
730  infoW.lpszIdentifier = NULL;
731  }
732 
733  /* Check if we'll have space */
734  if ((Context->BufferUsed + size + size2) <=
735  (Context->BufferLength))
736  {
737  /* Copy the data */
738  RtlMoveMemory((PVOID)((ULONG_PTR)Context->ProtocolBuffer +
739  Context->BufferUsed),
740  &infoW,
741  size);
742  if (size2)
743  {
744  /* Entry->ProviderName is LPWSTR */
745  if (Context->Unicode)
746  {
747  RtlMoveMemory((PVOID)((ULONG_PTR)Context->ProtocolBuffer +
748  Context->BufferUsed + size),
749  Entry->ProviderName,
750  size2);
751  }
752  else
753  {
754  /* Call the conversion function */
756  0,
757  Entry->ProviderName,
758  -1,
759  (LPSTR)((ULONG_PTR)Context->ProtocolBuffer +
760  Context->BufferUsed + size),
761  size2,
762  NULL,
763  NULL);
764 
765  }
766  }
767 
768  /* Increase the count */
769  Context->Count++;
770  }
771 }
772 
773 BOOL
774 WSAAPI
777 {
779 
780  /* Calculate ProviderName string size */
781  INT size1 = Entry->ProviderName ? wcslen(Entry->ProviderName) + 1 : 0;
782  INT size2 = Context->Unicode ? size1 * sizeof(WCHAR) : size1 * sizeof(CHAR);
783 
784  /* Copy the information */
786  Context->BufferUsed += Context->Unicode ? (sizeof(WSANAMESPACE_INFOW)+size2) : (sizeof(WSANAMESPACE_INFOA)+size2);
787 
788  /* Continue enumeration */
789  return TRUE;
790 }
791 
792 INT
793 WSAAPI
795  OUT LPWSANAMESPACE_INFOA lpnspBuffer, BOOLEAN Unicode)
796 {
797  INT Status;
798  PWSPROCESS WsProcess;
799  PNSCATALOG Catalog;
801 
802  DPRINT("WSAEnumNameSpaceProvidersInternal: %lx\n", lpnspBuffer);
803 
804  if (!lpdwBufferLength)
805  {
807  return SOCKET_ERROR;
808  }
809  WsProcess = WsGetProcess();
810  /* Create a catalog object from the current one */
811  Catalog = WsProcGetNsCatalog(WsProcess);
812  if (!Catalog)
813  {
814  /* Fail if we couldn't */
816  return SOCKET_ERROR;
817  }
818 
819  Context.ProtocolBuffer = lpnspBuffer;
820  Context.BufferLength = lpnspBuffer ? *lpdwBufferLength : 0;
821  Context.BufferUsed = 0;
822  Context.Count = 0;
823  Context.Unicode = Unicode;
824  Context.ErrorCode = ERROR_SUCCESS;
825 
827 
828  /* Get status */
829  Status = Context.Count;
830 
831  /* Check the error code */
832  if (Context.ErrorCode == ERROR_SUCCESS)
833  {
834  /* Check if enough space was available */
835  if (Context.BufferLength < Context.BufferUsed)
836  {
837  /* Fail and tell them how much we need */
838  *lpdwBufferLength = Context.BufferUsed;
841  }
842  }
843  else
844  {
845  /* Failure, normalize error */
847  WSASetLastError(Context.ErrorCode);
848  }
849 
850  /* Return */
851  return Status;
852 }
853 
854 /*
855  * @implemented
856  */
857 INT
858 WSAAPI
860  OUT LPWSANAMESPACE_INFOA lpnspBuffer)
861 {
862  DPRINT("WSAEnumNameSpaceProvidersA: %lx\n", lpnspBuffer);
864 }
865 
866 /*
867  * @implemented
868  */
869 INT
870 WSAAPI
872  OUT LPWSANAMESPACE_INFOW lpnspBuffer)
873 {
874  DPRINT("WSAEnumNameSpaceProvidersW: %lx\n", lpnspBuffer);
876 }
877 
878 /*
879  * @implemented
880  */
881 INT
882 WSAAPI
885  IN LPWSAPROTOCOL_INFOA lpProtocolInfo,
886  OUT LPSOCKADDR lpAddress,
887  IN OUT LPINT lpAddressLength)
888 {
893  PTCATALOG Catalog;
894  PTCATALOG_ENTRY CatalogEntry;
896  DWORD Length = (DWORD)strlen(AddressString) + 1;
897 
898  DPRINT("WSAStringToAddressA: %s\n", AddressString);
899 
900  /* Enter prolog */
902  {
903  /* Leave now */
905  return SOCKET_ERROR;
906  }
907 
908  /* Allocate the unicode string */
910  if (!UnicodeString)
911  {
912  /* No memory; fail */
914  return SOCKET_ERROR;
915  }
916 
917  /* Convert the string */
918  MultiByteToWideChar(CP_ACP, 0, AddressString, -1, UnicodeString, Length);
919 
920  /* Get the catalog */
921  Catalog = WsProcGetTCatalog(Process);
922 
923  /* Check if we got custom protocol info */
924  if (lpProtocolInfo)
925  {
926  /* Get the entry ID */
927  CatalogEntryId = lpProtocolInfo->dwCatalogEntryId;
928 
929  /* Get the entry associated with it */
932  &CatalogEntry);
933  }
934  else
935  {
936  /* Get it from the address family */
937  ErrorCode = WsTcGetEntryFromAf(Catalog, AddressFamily, &CatalogEntry);
938  }
939 
940  /* Check for success */
941  if (ErrorCode == ERROR_SUCCESS)
942  {
943  /* Call the provider */
946  &CatalogEntry->
947  ProtocolInfo,
948  lpAddress,
949  lpAddressLength,
950  &ErrorCode);
951 
952  /* Dereference the entry */
953  WsTcEntryDereference(CatalogEntry);
954 
955  /* Free the unicode string */
957 
958  /* Check for success and return */
959  if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
960  }
961  else
962  {
963  /* Free the unicode string */
965  }
966 
967  /* Set the error and return */
969  return SOCKET_ERROR;
970 }
971 
972 /*
973  * @implemented
974  */
975 INT
976 WSAAPI
979  IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
980  OUT LPSOCKADDR lpAddress,
981  IN OUT LPINT lpAddressLength)
982 {
987  PTCATALOG Catalog;
988  PTCATALOG_ENTRY CatalogEntry;
989 
990  DPRINT("WSAStringToAddressW: %S\n", AddressString);
991 
992  /* Enter prolog */
994  {
995  /* Leave now */
997  return SOCKET_ERROR;
998  }
999 
1000  /* Get the catalog */
1001  Catalog = WsProcGetTCatalog(Process);
1002 
1003  /* Check if we got custom protocol info */
1004  if (lpProtocolInfo)
1005  {
1006  /* Get the entry ID */
1007  CatalogEntryId = lpProtocolInfo->dwCatalogEntryId;
1008 
1009  /* Get the entry associated with it */
1012  &CatalogEntry);
1013  }
1014  else
1015  {
1016  /* Get it from the address family */
1017  ErrorCode = WsTcGetEntryFromAf(Catalog, AddressFamily, &CatalogEntry);
1018  }
1019 
1020  /* Check for success */
1021  if (ErrorCode == ERROR_SUCCESS)
1022  {
1023  /* Call the provider */
1024  Status = CatalogEntry->Provider->Service.lpWSPStringToAddress(AddressString,
1025  AddressFamily,
1026  &CatalogEntry->
1027  ProtocolInfo,
1028  lpAddress,
1029  lpAddressLength,
1030  &ErrorCode);
1031 
1032  /* Dereference the entry */
1033  WsTcEntryDereference(CatalogEntry);
1034 
1035  /* Check for success and return */
1036  if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
1037  }
1038 
1039  /* Set the error and return */
1041  return SOCKET_ERROR;
1042 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define IN
Definition: typedefs.h:38
struct _WSANAMESPACE_INFOW WSANAMESPACE_INFOW
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
#define TRUE
Definition: types.h:120
#define WSAEFAULT
Definition: winerror.h:1945
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
Definition: ws2_32p.h:85
INT WSPAPI WSANSPIoctl(HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion)
Definition: rnr.c:570
DWORD CatalogEntryId
Definition: dllmain.c:21
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
INT WSAAPI WSASetServiceA(IN LPWSAQUERYSETA lpqsRegInfo, IN WSAESETSERVICEOP essOperation, IN DWORD dwControlFlags)
Definition: rnr.c:600
INT WSAAPI WSAAddressToStringW(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:128
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WSAEINVAL
Definition: winerror.h:1946
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
VOID WSAAPI WsNqDelete(IN PNSQUERY NsQuery)
Definition: nsquery.c:74
INT WSAAPI WSALookupServiceBeginA(IN LPWSAQUERYSETA lpqsRestrictions, IN DWORD dwControlFlags, OUT LPHANDLE lphLookup)
Definition: rnr.c:245
static LPWSAQUERYSETW
Definition: sock.c:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WSAAPI NSProvidersEnumerationProc(PVOID EnumContext, PNSCATALOG_ENTRY Entry)
Definition: rnr.c:775
INT WSAAPI WSASetServiceW(IN LPWSAQUERYSETW lpqsRegInfo, IN WSAESETSERVICEOP essOperation, IN DWORD dwControlFlags)
Definition: rnr.c:614
DWORD WSAAPI WsTcGetEntryFromCatalogEntryId(IN PTCATALOG TCatalog, IN DWORD CatalogEntryId, IN PTCATALOG_ENTRY *CatalogEntry)
Definition: dcatalog.c:434
char * LPSTR
Definition: xmlstorage.h:182
INT WSAAPI WSAGetServiceClassNameByClassIdW(IN LPGUID lpServiceClassId, OUT LPWSTR lpszServiceClassName, IN OUT LPDWORD lpdwBufferLength)
Definition: rnr.c:672
PTPROVIDER Provider
Definition: ws2_32p.h:89
Definition: ws2_32p.h:121
INT WSAAPI WSAGetServiceClassInfoW(IN LPGUID lpProviderId, IN LPGUID lpServiceClassId, IN OUT LPDWORD lpdwBufferLength, OUT LPWSASERVICECLASSINFOW lpServiceClassInfo)
Definition: rnr.c:643
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID WSAAPI WsNqDereference(IN PNSQUERY Query)
Definition: nsquery.c:105
INT WSAAPI WSAEnumNameSpaceProvidersA(IN OUT LPDWORD lpdwBufferLength, OUT LPWSANAMESPACE_INFOA lpnspBuffer)
Definition: rnr.c:859
INT WSAAPI MapUnicodeQuerySetToAnsi(IN LPWSAQUERYSETW UnicodeSet, IN OUT PSIZE_T SetSize, OUT LPWSAQUERYSETA AnsiSet)
Definition: qshelpr.c:929
DWORD WSAAPI WsNqInitialize(IN PNSQUERY NsQuery)
Definition: nsquery.c:42
INT WSAAPI WSALookupServiceEnd(IN HANDLE hLookup)
Definition: rnr.c:202
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WSAAPI WSAInstallServiceClassA(IN LPWSASERVICECLASSINFOA lpServiceClassInfo)
Definition: rnr.c:686
DWORD WSAAPI WsNqLookupServiceEnd(IN PNSQUERY NsQuery)
Definition: nsquery.c:164
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PWSPROCESS WsGetProcess(VOID)
Definition: ws2_32p.h:885
#define MAXDWORD
INT WSAAPI MapAnsiQuerySetToUnicode(IN LPWSAQUERYSETA AnsiSet, IN OUT PSIZE_T SetSize, OUT LPWSAQUERYSETW UnicodeSet)
Definition: qshelpr.c:808
void DPRINT(...)
Definition: polytest.cpp:61
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:123
#define ERROR_ARITHMETIC_OVERFLOW
Definition: winerror.h:351
INT WSAAPI WSAEnumNameSpaceProvidersInternal(IN OUT LPDWORD lpdwBufferLength, OUT LPWSANAMESPACE_INFOA lpnspBuffer, BOOLEAN Unicode)
Definition: rnr.c:794
INT WSAAPI WSAInstallServiceClassW(IN LPWSASERVICECLASSINFOW lpServiceClassInfo)
Definition: rnr.c:698
PNSQUERY WSAAPI WsNqAllocate(VOID)
Definition: nsquery.c:22
_Out_writes_bytes_to_ lpdwBufferLength LPSTR lpszServiceClassName
Definition: winsock2.h:2598
DWORD WSAAPI WsNqLookupServiceNext(PNSQUERY NsQuery, DWORD, PDWORD, OUT LPWSAQUERYSETW QuerySet)
VOID WSAAPI WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatitem.c:51
GLsizeiptr size
Definition: glext.h:5919
INT WSAAPI WSAStringToAddressA(IN LPSTR AddressString, IN INT AddressFamily, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, OUT LPSOCKADDR lpAddress, IN OUT LPINT lpAddressLength)
Definition: rnr.c:883
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const SecPkgInfoW infoW
Definition: kerberos.c:293
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT WINAPI WSALookupServiceNextW(IN HANDLE hLookup, IN DWORD dwControlFlags, IN OUT LPDWORD lpdwBufferLength, OUT LPWSAQUERYSETW lpqsResults)
Definition: rnr.c:386
enum _WSAESETSERVICEOP WSAESETSERVICEOP
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WSAAPI WsNqValidateAndReference(IN PNSQUERY Query)
Definition: nsquery.c:57
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WSAEnumNameSpaceProvidersW(IN OUT LPDWORD lpdwBufferLength, OUT LPWSANAMESPACE_INFOW lpnspBuffer)
Definition: rnr.c:871
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
INT WSAAPI WSARemoveServiceClass(IN LPGUID lpServiceClassId)
Definition: rnr.c:588
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
LPWSPSTRINGTOADDRESS lpWSPStringToAddress
Definition: ws2spi.h:490
INT WSAAPI WSAStringToAddressW(IN LPWSTR AddressString, IN INT AddressFamily, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPSOCKADDR lpAddress, IN OUT LPINT lpAddressLength)
Definition: rnr.c:977
WSAQUERYSETW
Definition: winsock2.h:836
LPWSPADDRESSTOSTRING lpWSPAddressToString
Definition: ws2spi.h:462
VOID WSAAPI WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: nscatalo.c:350
INT WSAAPI WSAGetServiceClassNameByClassIdA(IN LPGUID lpServiceClassId, OUT LPSTR lpszServiceClassName, IN OUT LPDWORD lpdwBufferLength)
Definition: rnr.c:658
Status
Definition: gdiplustypes.h:24
INT WSAAPI WSALookupServiceNextA(IN HANDLE hLookup, IN DWORD dwControlFlags, IN OUT LPDWORD lpdwBufferLength, OUT LPWSAQUERYSETA lpqsResults)
Definition: rnr.c:444
ULONG_PTR SIZE_T
Definition: typedefs.h:78
struct _NSPROVIDER_ENUM_CONTEXT * PNSPROVIDER_ENUM_CONTEXT
#define WSA_INVALID_HANDLE
Definition: winsock2.h:591
PNSCATALOG WSAAPI WsProcGetNsCatalog(IN PWSPROCESS Process)
Definition: dprocess.c:166
#define WSAAPI
Definition: winsock2.h:584
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:807
VOID WSAAPI NSProviderInfoFromContext(IN PNSCATALOG_ENTRY Entry, IN PNSPROVIDER_ENUM_CONTEXT Context)
Definition: rnr.c:707
#define MultiByteToWideChar
Definition: compat.h:100
DWORD WSAAPI WsNqLookupServiceBegin(IN PNSQUERY NsQuery, IN LPWSAQUERYSETW QuerySet, IN DWORD ControlFlags, IN PNSCATALOG Catalog)
Definition: nsquery.c:347
INT WINAPI WSALookupServiceBeginW(IN LPWSAQUERYSETW lpqsRestrictions, IN DWORD dwControlFlags, OUT LPHANDLE lphLookup)
Definition: rnr.c:316
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
INT WSAAPI WSAGetServiceClassInfoA(IN LPGUID lpProviderId, IN LPGUID lpServiceClassId, IN OUT LPDWORD lpdwBufferLength, OUT LPWSASERVICECLASSINFOA lpServiceClassInfo)
Definition: rnr.c:628
#define OUT
Definition: typedefs.h:39
uint32_t * LPDWORD
Definition: typedefs.h:57
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
_In_ _In_opt_ _Out_writes_bytes_to_opt_ lpdwBufferLength _Inout_ LPDWORD lpdwBufferLength
Definition: winhttp.h:675
WCHAR * LPWSTR
Definition: xmlstorage.h:184
INT WSAAPI WSAAddressToStringA(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, OUT LPSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:23
HANDLE WsSockHeap
Definition: dllmain.c:21
#define WSAENOBUFS
Definition: winerror.h:1968
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD WSAAPI WsTcGetEntryFromAf(IN PTCATALOG TCatalog, IN INT AddressFamily, IN PTCATALOG_ENTRY *CatalogEntry)
Definition: dcatalog.c:382
base of all file and directory entries
Definition: entries.h:82
PTCATALOG WSAAPI WsProcGetTCatalog(IN PWSPROCESS Process)
Definition: dprocess.c:150
int * LPINT
Definition: windef.h:178
#define WSPAPI
Definition: ws2spi.h:39
struct _WSANAMESPACE_INFOA WSANAMESPACE_INFOA