ReactOS  0.4.14-dev-49-gfb4591c
getxbyxx.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for getxbyxx.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID WSAAPI FixList (PCHAR **List, ULONG_PTR Base)
 
VOID WSAAPI UnpackServEnt (PSERVENT Servent)
 
VOID WSAAPI UnpackHostEnt (PHOSTENT Hostent)
 
VOID WSAAPI Local_Ip4AddresstoString (IN PCHAR AddressBuffer, IN PCHAR Address)
 
VOID WSAAPI Local_Ip6AddresstoString (IN PCHAR AddressBuffer, IN PCHAR Address)
 
LPBLOB WSAAPI getxyDataEnt (IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
 
PHOSTENT WSAAPI gethostbyname (IN const char FAR *name)
 
PHOSTENT WSAAPI gethostbyaddr (IN const char FAR *addr, IN int len, IN int type)
 
INT WSAAPI gethostname (OUT char FAR *name, IN INT namelen)
 
PSERVENT WSAAPI getservbyport (IN int port, IN const char FAR *proto)
 
PSERVENT WSAAPI getservbyname (IN const char FAR *name, IN const char FAR *proto)
 
HANDLE WSAAPI WSAAsyncGetHostByAddr (IN HWND hWnd, IN UINT wMsg, IN CONST CHAR FAR *Address, IN INT Length, IN INT Type, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
HANDLE WSAAPI WSAAsyncGetHostByName (IN HWND hWnd, IN UINT wMsg, IN CONST CHAR FAR *Name, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
HANDLE WSAAPI WSAAsyncGetProtoByName (IN HWND hWnd, IN UINT wMsg, IN CONST CHAR FAR *Name, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
HANDLE WSAAPI WSAAsyncGetProtoByNumber (IN HWND hWnd, IN UINT wMsg, IN INT Number, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
HANDLE WSAAPI WSAAsyncGetServByName (IN HWND hWnd, IN UINT wMsg, IN CONST CHAR FAR *Name, IN CONST CHAR FAR *Protocol, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
HANDLE WSAAPI WSAAsyncGetServByPort (IN HWND hWnd, IN UINT wMsg, IN INT Port, IN CONST CHAR FAR *Protocol, OUT CHAR FAR *Buffer, IN INT BufferLength)
 
INT WSAAPI WSACancelAsyncRequest (IN HANDLE hAsyncTaskHandle)
 

Variables

AFPROTOCOLS afp [2] = {{AF_INET, IPPROTO_UDP}, {AF_INET, IPPROTO_TCP}}
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file getxbyxx.c.

Function Documentation

◆ FixList()

VOID WSAAPI FixList ( PCHAR **  List,
ULONG_PTR  Base 
)

Definition at line 24 of file getxbyxx.c.

26 {
27  /* Make sure it's valid */
28  if (*List)
29  {
30  PCHAR *Addr;
31 
32  /* Get the right base */
33  Addr = *List = (PCHAR*)(((ULONG_PTR)*List + Base));
34 
35  /* Loop the pointers */
36  while (*Addr)
37  {
38  /* Rebase them too */
39  *Addr = (PCHAR)(((ULONG_PTR)*Addr + Base));
40  Addr++;
41  }
42  }
43 }
signed char * PCHAR
Definition: retypes.h:7
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PCHAR
Definition: match.c:90
LIST_ENTRY List
Definition: psmgr.c:57

Referenced by UnpackHostEnt(), and UnpackServEnt().

◆ gethostbyaddr()

PHOSTENT WSAAPI gethostbyaddr ( IN const char FAR addr,
IN int  len,
IN int  type 
)

Definition at line 309 of file getxbyxx.c.

312 {
313  CHAR AddressBuffer[100];
314  PHOSTENT Hostent;
315  LPBLOB Blob;
316  CHAR ResultsBuffer[RNR_BUFFER_SIZE];
317  PCHAR Results = ResultsBuffer;
320  INT ErrorCode;
321  DPRINT("gethostbyaddr: %s\n", addr);
322 
323  /* Enter prolog */
325  {
326  /* Leave now */
328  return NULL;
329  }
330 
331  /* Check for valid address pointer */
332  if (!addr)
333  {
334  /* Fail */
336  return NULL;
337  }
338 
339  /* Check which type it is */
340  if (type == AF_INET)
341  {
342  /* Use IPV4 Address to String */
343  Local_Ip4AddresstoString(AddressBuffer, (PCHAR)addr);
344  }
345  else if (type == AF_INET6)
346  {
347  /* Use IPV6 Address to String */
348  Local_Ip6AddresstoString(AddressBuffer, (PCHAR)addr);
349  }
350  else
351  {
352  /* Invalid address type; fail */
354  return NULL;
355  }
356 
357  /* Get the Hostname in a Blob Structure */
358  Blob = getxyDataEnt(&Results,
360  AddressBuffer,
361  &AddressGuid,
362  0);
363 
364  /* Check if we got a blob */
365  if (Blob)
366  {
367  /* Copy the blob to our buffer and convert it */
368  Hostent = WsThreadBlobToHostent(Thread, Blob);
369 
370  /* Unpack the hostent */
371  if (Hostent) UnpackHostEnt(Hostent);
372  }
373  else
374  {
375  /* We failed, so zero it out */
376  Hostent = NULL;
377 
378  /* Normalize the error message */
380  {
382  }
383  }
384 
385  /* Check if we received a newly allocated buffer; free it. */
386  if (Results != ResultsBuffer) HeapFree(WsSockHeap, 0, Results);
387 
388  /* Return the hostent */
389  return Hostent;
390 }
signed char * PCHAR
Definition: retypes.h:7
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define WSAHOST_NOT_FOUND
Definition: winerror.h:2000
PHOSTENT WSAAPI WsThreadBlobToHostent(IN PWSTHREAD Thread, IN LPBLOB Blob)
Definition: dthread.c:316
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WSASERVICE_NOT_FOUND
Definition: winerror.h:1995
VOID WSAAPI Local_Ip4AddresstoString(IN PCHAR AddressBuffer, IN PCHAR Address)
Definition: getxbyxx.c:75
#define WSAEINVAL
Definition: winerror.h:1946
char CHAR
Definition: xmlstorage.h:175
VOID WSAAPI Local_Ip6AddresstoString(IN PCHAR AddressBuffer, IN PCHAR Address)
Definition: getxbyxx.c:88
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
Definition: nspapi.h:57
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
void DPRINT(...)
Definition: polytest.cpp:61
const GUID DECLSPEC_SELECTANY AddressGuid
Definition: nsp_dns.h:18
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
GLenum const GLvoid * addr
Definition: glext.h:9621
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define AF_INET
Definition: tcpip.h:117
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:394
VOID WSAAPI UnpackHostEnt(PHOSTENT Hostent)
Definition: getxbyxx.c:61
LPBLOB WSAAPI getxyDataEnt(IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
Definition: getxbyxx.c:103

Referenced by AddrToAddrStr(), GetHostEntry(), WsAsyncGetHost(), and WspiapiLegacyGetNameInfo().

◆ gethostbyname()

PHOSTENT WSAAPI gethostbyname ( IN const char FAR name)

Definition at line 221 of file getxbyxx.c.

222 {
223  PHOSTENT Hostent;
224  LPBLOB Blob;
225  INT ErrorCode;
226  CHAR ResultsBuffer[RNR_BUFFER_SIZE];
227  PCHAR Results = ResultsBuffer;
228  CHAR szLocalName[MAX_HOSTNAME_LEN];
229  PCHAR pszName;
232  DPRINT("gethostbyname: %s\n", name);
233 
234  /* Enter prolog */
236  {
237  /* Leave now */
239  return NULL;
240  }
241 
242  /* Check if no name was given */
243  if (!name || !*name)
244  {
245  /* This means we should do a local lookup first */
246  if (gethostname(szLocalName, MAX_HOSTNAME_LEN) != NO_ERROR) return(NULL);
247  pszName = szLocalName;
248  }
249  else
250  {
251  /* Use the name tha twas given to us */
252  pszName = (PCHAR)name;
253  }
254 
255  /* Get the Hostname in a Blob Structure */
256  Blob = getxyDataEnt(&Results,
258  pszName,
260  0);
261 
262  /* Check if we didn't get a blob, or if we got an empty name */
263  if (!(Blob) && (!(name) || !(*name)))
264  {
265  /* Try a new query */
266  Blob = getxyDataEnt(&Results,
268  NULL,
270  0);
271  }
272 
273  /* Check if we got a blob */
274  if (Blob)
275  {
276  /* Copy the blob to our buffer and convert it */
277  Hostent = WsThreadBlobToHostent(Thread, Blob);
278 
279  /* Unpack the hostent */
280  if (Hostent) UnpackHostEnt(Hostent);
281  }
282  else
283  {
284  /* We failed, so zero it out */
285  Hostent = NULL;
286 
287  /* Normalize the error message */
289  {
291  }
292  }
293 
294  /* Check if we received a newly allocated buffer; free it. */
295  if (Results != ResultsBuffer) HeapFree(WsSockHeap, 0, Results);
296 
297  /* Notify RAS Auto-dial helper */
298  if (Hostent) WSNoteSuccessfulHostentLookup(name, *Hostent->h_addr);
299 
300  /* Return the hostent */
301  return Hostent;
302 }
signed char * PCHAR
Definition: retypes.h:7
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define WSAHOST_NOT_FOUND
Definition: winerror.h:2000
PHOSTENT WSAAPI WsThreadBlobToHostent(IN PWSTHREAD Thread, IN LPBLOB Blob)
Definition: dthread.c:316
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WSASERVICE_NOT_FOUND
Definition: winerror.h:1995
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
VOID WINAPI WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR *Name, IN CONST ULONG Address)
Definition: winsock.c:119
Definition: nspapi.h:57
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define PCHAR
Definition: match.c:90
#define MAX_HOSTNAME_LEN
Definition: iptypes.h:30
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
Definition: name.c:36
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:394
const GUID DECLSPEC_SELECTANY HostAddrByNameGuid
Definition: nsp_dns.h:19
VOID WSAAPI UnpackHostEnt(PHOSTENT Hostent)
Definition: getxbyxx.c:61
LPBLOB WSAAPI getxyDataEnt(IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
Definition: getxbyxx.c:103

Referenced by AddrStrToAddr(), Telnet::Connect(), ConnectToReactOSWebsite(), do_host_lookup(), get_server(), GetHostByName(), GetHostEntry(), GetOurHostName(), getrpcport(), hookup(), init_logger_addr(), InitConnection(), IsWinsockInitialized(), main(), NetBTinetResolve(), netfinger(), open_http(), QueryDNS(), resolve_hostname(), Setup(), START_TEST(), tcp_connect(), test_communication(), test_dns(), test_gethostbyname(), test_gethostbyname_hack(), test_gethostname(), test_getsockname(), test_sioAddressListChange(), test_WithoutWSAStartup(), test_WithWSAStartup(), write_packet(), WsAsyncGetHost(), and WspiapiQueryDNS().

◆ gethostname()

INT WSAAPI gethostname ( OUT char FAR name,
IN INT  namelen 
)

Definition at line 397 of file getxbyxx.c.

399 {
400  PCHAR Name = NULL;
401  CHAR ResultsBuffer[RNR_BUFFER_SIZE];
402  PCHAR Results = ResultsBuffer;
403  DPRINT("gethostname: %p\n", name);
404 
405  if (!name || namelen < 1)
406  {
408  return SOCKET_ERROR;
409  }
410  /* Get the Hostname in a String */
411  /* getxyDataEnt does not return blob for HostnameGuid */
413  if (Name)
414  {
415  /* Copy it */
416  strncpy(name, Name, namelen-1);
417  }
418 
419  /* Check if we received a newly allocated buffer; free it. */
420  if (Results != ResultsBuffer) HeapFree(WsSockHeap, 0, Results);
421 
422  /* Return success */
423  return ERROR_SUCCESS;
424 }
signed char * PCHAR
Definition: retypes.h:7
#define SOCKET_ERROR
Definition: winsock.h:333
#define WSAEFAULT
Definition: winerror.h:1945
#define ERROR_SUCCESS
Definition: deptool.c:10
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char CHAR
Definition: xmlstorage.h:175
GLint namelen
Definition: glext.h:7232
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define SetLastError(x)
Definition: compat.h:409
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
Definition: name.c:36
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:394
const GUID DECLSPEC_SELECTANY HostnameGuid
Definition: nsp_dns.h:17
LPBLOB WSAAPI getxyDataEnt(IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
Definition: getxbyxx.c:103

Referenced by authunix_create_default(), create_new_rpc_auth(), get_username_and_hostname(), gethostbyname(), GetIpHostName(), GetOurHostName(), host2netname(), main(), nfs41_rpc_clnt_create(), ruserpass(), START_TEST(), and UserLoginThread().

◆ getservbyname()

PSERVENT WSAAPI getservbyname ( IN const char FAR name,
IN const char FAR proto 
)

Definition at line 500 of file getxbyxx.c.

502 {
503  PSERVENT Servent;
504  LPBLOB Blob;
505  CHAR ResultsBuffer[RNR_BUFFER_SIZE];
506  PCHAR Results = ResultsBuffer;
507  PCHAR PortName;
510  INT ErrorCode;
511  DPRINT("getservbyname: %s\n", name);
512 
513  /* Enter prolog */
515  {
516  /* Leave now */
518  return NULL;
519  }
520 
521  /* No protocol specified */
522  if (!proto) proto = "";
523 
524  /* Allocate buffer for it */
525  PortName = HeapAlloc(WsSockHeap, 0, strlen(proto) + 1 + strlen(name) + 1);
526  if (!PortName)
527  {
528  /* Fail */
530  return NULL;
531  }
532 
533  /* Put it into the right syntax */
534  sprintf(PortName, "%s/%s", name, proto);
535 
536  /* Get the Service in a Blob */
537  Blob = getxyDataEnt(&Results, RNR_BUFFER_SIZE, PortName, &IANAGuid, 0);
538 
539  /* Free the string we sent */
541 
542  /* Check if we got a blob */
543  if (Blob)
544  {
545  /* Copy the blob to our buffer and convert it */
546  Servent = WsThreadBlobToServent(Thread, Blob);
547 
548  /* Unpack the hostent */
549  if (Servent) UnpackServEnt(Servent);
550  }
551  else
552  {
553  /* We failed, so zero it out */
554  Servent = 0;
555  }
556 
557  /* Check if we received a newly allocated buffer; free it. */
558  if (Results != ResultsBuffer) HeapFree(WsSockHeap, 0, Results);
559 
560  /* Return the hostent */
561  return Servent;
562 }
signed char * PCHAR
Definition: retypes.h:7
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PSERVENT WSAAPI WsThreadBlobToServent(IN PWSTHREAD Thread, IN LPBLOB Blob)
Definition: dthread.c:349
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
Definition: nspapi.h:57
int32_t INT
Definition: typedefs.h:56
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
const GUID DECLSPEC_SELECTANY IANAGuid
Definition: nsp_dns.h:20
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
VOID WSAAPI UnpackServEnt(PSERVENT Servent)
Definition: getxbyxx.c:47
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
Definition: name.c:36
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:394
LPBLOB WSAAPI getxyDataEnt(IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
Definition: getxbyxx.c:103
IN PUNICODE_STRING PortName
Definition: conport.c:35

Referenced by Telnet::Connect(), do_getservbyname(), FTPInitLibrary(), GetAddrInfoW(), main(), netfinger(), rtime(), ServiceNameToPortNumber(), START_TEST(), WsAsyncGetServ(), and WspiapiLegacyGetAddrInfo().

◆ getservbyport()

PSERVENT WSAAPI getservbyport ( IN int  port,
IN const char FAR proto 
)

Definition at line 431 of file getxbyxx.c.

433 {
434  PSERVENT Servent;
435  LPBLOB Blob;
436  CHAR ResultsBuffer[RNR_BUFFER_SIZE];
437  PCHAR Results = ResultsBuffer;
438  PCHAR PortName;
441  INT ErrorCode;
442  DPRINT("getservbyport: %s\n", proto);
443 
444  /* Enter prolog */
446  {
447  /* Leave now */
449  return NULL;
450  }
451 
452  /* No protocol specified */
453  if (!proto) proto = "";
454 
455  /* Allocate memory for the port name */
456  PortName = HeapAlloc(WsSockHeap, 0, strlen(proto) + 1 + 1 + 5);
457  if (!PortName)
458  {
459  /* Fail */
461  return NULL;
462  }
463 
464  /* Put it into the right syntax */
465  sprintf(PortName, "%d/%s", (ntohs(port) & 0xffff), proto);
466 
467  /* Get the Service in a Blob */
468  Blob = getxyDataEnt(&Results, RNR_BUFFER_SIZE, PortName, &IANAGuid, 0);
469 
470  /* Free the string we sent */
472 
473  /* Check if we got a blob */
474  if (Blob)
475  {
476  /* Copy the blob to our buffer and convert it */
477  Servent = WsThreadBlobToServent(Thread, Blob);
478 
479  /* Unpack the hostent */
480  if (Servent) UnpackServEnt(Servent);
481  }
482  else
483  {
484  /* We failed, so zero it out */
485  Servent = 0;
486  }
487 
488  /* Check if we received a newly allocated buffer; free it. */
489  if (Results != ResultsBuffer) HeapFree(WsSockHeap, 0, Results);
490 
491  /* Return the hostent */
492  return Servent;
493 }
signed char * PCHAR
Definition: retypes.h:7
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PSERVENT WSAAPI WsThreadBlobToServent(IN PWSTHREAD Thread, IN LPBLOB Blob)
Definition: dthread.c:349
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
Definition: nspapi.h:57
int32_t INT
Definition: typedefs.h:56
#define ntohs(x)
Definition: module.h:208
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
const GUID DECLSPEC_SELECTANY IANAGuid
Definition: nsp_dns.h:20
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
VOID WSAAPI UnpackServEnt(PSERVENT Servent)
Definition: getxbyxx.c:47
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
USHORT port
Definition: uri.c:227
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:394
LPBLOB WSAAPI getxyDataEnt(IN OUT PCHAR *Results, IN DWORD Length, IN LPSTR Name, IN LPCGUID Type, IN LPSTR *NewName)
Definition: getxbyxx.c:103
IN PUNICODE_STRING PortName
Definition: conport.c:35

Referenced by AddrToAddrStr(), GetPortName(), START_TEST(), WsAsyncGetServ(), and WspiapiLegacyGetNameInfo().

◆ getxyDataEnt()

LPBLOB WSAAPI getxyDataEnt ( IN OUT PCHAR Results,
IN DWORD  Length,
IN LPSTR  Name,
IN LPCGUID  Type,
IN LPSTR NewName 
)

Definition at line 103 of file getxbyxx.c.

108 {
109  PWSAQUERYSETA WsaQuery = (PWSAQUERYSETA)*Results;
110  INT ErrorCode;
112  HANDLE RnRHandle;
113  LPBLOB Blob = NULL;
114  PVOID NewResults = NULL;
115  DWORD dwControlFlags = LUP_RETURN_NAME;
116 
117  /* Assume empty return name */
118  if (NewName) *NewName = NULL;
119 
120  /* Set up the Winsock Service Query */
121  RtlZeroMemory(WsaQuery, sizeof(*WsaQuery));
122  WsaQuery->dwSize = sizeof(*WsaQuery);
123  WsaQuery->lpszServiceInstanceName = Name;
124  WsaQuery->lpServiceClassId = (LPGUID)Type;
125  WsaQuery->dwNameSpace = NS_ALL;
126  WsaQuery->dwNumberOfProtocols = sizeof(afp)/sizeof(afp[0]);
127  WsaQuery->lpafpProtocols = afp;
128 
129  if (!IsEqualGUID(Type, &HostnameGuid))
130  dwControlFlags |= LUP_RETURN_BLOB;
131 
132  /* Send the Query Request to find a Service */
134  dwControlFlags,
135  &RnRHandle);
136 
137  if (ErrorCode == ERROR_SUCCESS)
138  {
139  while (TRUE)
140  {
141  /* Service was found, send the real query */
142  ErrorCode = WSALookupServiceNextA(RnRHandle,
143  0,
144  &NewLength,
145  WsaQuery);
146 
147  /* Return the information requested */
148  if (ErrorCode == ERROR_SUCCESS)
149  {
150  /* Get the Blob and check if we have one */
151  Blob = WsaQuery->lpBlob;
152  if (Blob)
153  {
154  /* Did they want the name back? */
155  if (NewName) *NewName = WsaQuery->lpszServiceInstanceName;
156  }
157  else
158  {
159  /* Check if this was a Hostname lookup */
161  {
162  /* Return the name anyways */
163  if (NewName) *NewName = WsaQuery->lpszServiceInstanceName;
164  }
165  else
166  {
167  /* We don't have a blob, sorry */
169  }
170  }
171  }
172  else
173  {
174  /* WSALookupServiceEnd will set its own error, so save ours */
176 
177  /* Check if we failed because of missing buffer space */
178  if ((ErrorCode == WSAEFAULT) && (Length > RNR_BUFFER_SIZE))
179  {
180  /* Allocate a new buffer */
181  NewResults = HeapAlloc(WsSockHeap, 0, Length);
182  if (NewResults)
183  {
184  /* Tell the caller his new buffer */
185  *Results = NewResults;
186 
187  /* Update the WSA Query's location */
188  WsaQuery = (PWSAQUERYSETA)NewResults;
189 
190  /* Loop again */
191  continue;
192  }
193  else
194  {
195  /* No memory to allocate the new buffer */
197  }
198  }
199  }
200 
201  /* Finish the Query Request */
202  WSALookupServiceEnd(RnRHandle);
203 
204  /* Now set the Last Error */
206 
207  /* Leave the loop */
208  break;
209  }
210  }
211 
212  /* Return the blob */
213  return Blob;
214 }
#define TRUE
Definition: types.h:120
#define WSAEFAULT
Definition: winerror.h:1945
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LUP_RETURN_NAME
Definition: winsock2.h:514
DWORD dwSize
Definition: winsock2.h:802
INT WSAAPI WSALookupServiceBeginA(IN LPWSAQUERYSETA lpqsRestrictions, IN DWORD dwControlFlags, OUT LPHANDLE lphLookup)
Definition: rnr.c:245
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD dwNameSpace
Definition: winsock2.h:807
Definition: nspapi.h:57
int32_t INT
Definition: typedefs.h:56
static USHORT USHORT * NewLength
LPBLOB lpBlob
Definition: winsock2.h:816
INT WSAAPI WSALookupServiceEnd(IN HANDLE hLookup)
Definition: rnr.c:202
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
#define NS_ALL
Definition: nspapi.h:8
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _WSAQuerySetA * PWSAQUERYSETA
#define WSANO_DATA
Definition: winerror.h:2003
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:593
#define RNR_BUFFER_SIZE
Definition: nsp_dns.h:25
INT WSAAPI WSALookupServiceNextA(IN HANDLE hLookup, IN DWORD dwControlFlags, IN OUT LPDWORD lpdwBufferLength, OUT LPWSAQUERYSETA lpqsResults)
Definition: rnr.c:444
#define LUP_RETURN_BLOB
Definition: winsock2.h:519
AFPROTOCOLS afp[2]
Definition: getxbyxx.c:18
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
_In_ PUNICODE_STRING NewName
Definition: zwfuncs.h:1203
LPGUID lpServiceClassId
Definition: winsock2.h:804
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
HANDLE WsSockHeap
Definition: dllmain.c:21
DWORD dwNumberOfProtocols
Definition: winsock2.h:810
LPSTR lpszServiceInstanceName
Definition: winsock2.h:803
const GUID DECLSPEC_SELECTANY HostnameGuid
Definition: nsp_dns.h:17
GUID * LPGUID
Definition: guiddef.h:81

Referenced by gethostbyaddr(), gethostbyname(), gethostname(), getservbyname(), and getservbyport().

◆ Local_Ip4AddresstoString()

VOID WSAAPI Local_Ip4AddresstoString ( IN PCHAR  AddressBuffer,
IN PCHAR  Address 
)

Definition at line 75 of file getxbyxx.c.

77 {
78  /* Convert the address into IPv4 format */
79  sprintf(AddressBuffer, "%u.%u.%u.%u",
80  ((unsigned)Address[0] & 0xff),
81  ((unsigned)Address[1] & 0xff),
82  ((unsigned)Address[2] & 0xff),
83  ((unsigned)Address[3] & 0xff));
84 }
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static WCHAR Address[46]
Definition: ping.c:68

Referenced by gethostbyaddr().

◆ Local_Ip6AddresstoString()

VOID WSAAPI Local_Ip6AddresstoString ( IN PCHAR  AddressBuffer,
IN PCHAR  Address 
)

Definition at line 88 of file getxbyxx.c.

90 {
91  DWORD i;
92 
93  /* Convert the address into IPv6 format */
94  for (i = 0; i < 8; i++)
95  {
96  sprintf(AddressBuffer, "%x:",
97  ((unsigned)Address[0] & 0xff));
98  }
99 }
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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
static WCHAR Address[46]
Definition: ping.c:68
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by gethostbyaddr().

◆ UnpackHostEnt()

VOID WSAAPI UnpackHostEnt ( PHOSTENT  Hostent)

Definition at line 61 of file getxbyxx.c.

62 {
63  ULONG_PTR HostentPtr = (ULONG_PTR)Hostent;
64 
65  /* Convert the Name Offset to a Pointer */
66  if (Hostent->h_name) Hostent->h_name = (PCHAR)(Hostent->h_name + HostentPtr);
67 
68  /* Convert all the List Offsets to Pointers */
69  FixList(&Hostent->h_aliases, HostentPtr);
70  FixList(&Hostent->h_addr_list, HostentPtr);
71 }
char ** h_addr_list
Definition: winsock.h:138
VOID WSAAPI FixList(PCHAR **List, ULONG_PTR Base)
Definition: getxbyxx.c:24
char * h_name
Definition: winsock.h:134
char ** h_aliases
Definition: winsock.h:135
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PCHAR
Definition: match.c:90
#define ULONG_PTR
Definition: config.h:101

Referenced by gethostbyaddr(), and gethostbyname().

◆ UnpackServEnt()

VOID WSAAPI UnpackServEnt ( PSERVENT  Servent)

Definition at line 47 of file getxbyxx.c.

48 {
49  ULONG_PTR ServentPtr = (ULONG_PTR)Servent;
50 
51  /* Convert all the List Offsets to Pointers */
52  FixList(&Servent->s_aliases, ServentPtr);
53 
54  /* Convert the Name and Protocol Offsets to Pointers */
55  Servent->s_name = (PCHAR)(Servent->s_name + ServentPtr);
56  Servent->s_proto = (PCHAR)(Servent->s_proto + ServentPtr);
57 }
VOID WSAAPI FixList(PCHAR **List, ULONG_PTR Base)
Definition: getxbyxx.c:24
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PCHAR
Definition: match.c:90
char * s_name
Definition: winsock.h:159
char * s_proto
Definition: winsock.h:166
char ** s_aliases
Definition: winsock.h:160
#define ULONG_PTR
Definition: config.h:101

Referenced by getservbyname(), and getservbyport().

◆ WSAAsyncGetHostByAddr()

HANDLE WSAAPI WSAAsyncGetHostByAddr ( IN HWND  hWnd,
IN UINT  wMsg,
IN CONST CHAR FAR Address,
IN INT  Length,
IN INT  Type,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 569 of file getxbyxx.c.

576 {
577  HANDLE TaskHandle;
580  PVOID AddressCopy;
581  PWSASYNCBLOCK AsyncBlock;
582  INT ErrorCode;
583  DPRINT("WSAAsyncGetHostByAddr: %lx, %lx, %s\n", hWnd, wMsg, Address);
584 
585  /* Enter prolog */
587  {
588  /* Leave now */
590  return NULL;
591  }
592 
593  /* Initialize the Async Thread */
595  {
596  /* Fail */
598  return NULL;
599  }
600 
601  /* Allocate an async block */
602  if (!(AsyncBlock = WsAsyncAllocateBlock(Length)))
603  {
604  /* Fail */
606  return NULL;
607  }
608 
609  /* Make a copy of the address */
610  AddressCopy = AsyncBlock + 1;
611  RtlMoveMemory(AddressCopy, Address, Length);
612 
613  /* Initialize the Async Block */
614  AsyncBlock->Operation = WsAsyncGetHostByAddr;
615  AsyncBlock->GetHost.hWnd = hWnd;
616  AsyncBlock->GetHost.wMsg = wMsg;
617  AsyncBlock->GetHost.ByWhat = AddressCopy;
618  AsyncBlock->GetHost.Length = Length;
619  AsyncBlock->GetHost.Type = Type;
620  AsyncBlock->GetHost.Buffer = Buffer;
621  AsyncBlock->GetHost.BufferLength = BufferLength;
622 
623  /* Save the task handle and queue the request */
624  TaskHandle = AsyncBlock->TaskHandle;
625  WsAsyncQueueRequest(AsyncBlock);
626 
627  /* Return the task handle */
628  return TaskHandle;
629 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
struct _WSASYNCBLOCK::@572::@574 GetHost
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968

◆ WSAAsyncGetHostByName()

HANDLE WSAAPI WSAAsyncGetHostByName ( IN HWND  hWnd,
IN UINT  wMsg,
IN CONST CHAR FAR Name,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 636 of file getxbyxx.c.

641 {
642  HANDLE TaskHandle;
645  PWSASYNCBLOCK AsyncBlock;
646  INT ErrorCode;
647  PVOID NameCopy;
648  DPRINT("WSAAsyncGetProtoByNumber: %lx, %lx, %s\n", hWnd, wMsg, Name);
649 
650  /* Enter prolog */
652  {
653  /* Leave now */
655  return NULL;
656  }
657 
658  /* Initialize the Async Thread */
660  {
661  /* Fail */
663  return NULL;
664  }
665 
666  /* Allocate an async block */
667  if (!(AsyncBlock = WsAsyncAllocateBlock(strlen(Name) + sizeof(CHAR))))
668  {
669  /* Fail */
671  return NULL;
672  }
673 
674  /* Make a copy of the address */
675  NameCopy = AsyncBlock + 1;
676  strcpy(NameCopy, Name);
677 
678  /* Initialize the Async Block */
679  AsyncBlock->Operation = WsAsyncGetHostByName;
680  AsyncBlock->GetHost.hWnd = hWnd;
681  AsyncBlock->GetHost.wMsg = wMsg;
682  AsyncBlock->GetHost.ByWhat = NameCopy;
683  AsyncBlock->GetHost.Buffer = Buffer;
684  AsyncBlock->GetHost.BufferLength = BufferLength;
685 
686  /* Save the task handle and queue the request */
687  TaskHandle = AsyncBlock->TaskHandle;
688  WsAsyncQueueRequest(AsyncBlock);
689 
690  /* Return the task handle */
691  return TaskHandle;
692 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
struct _WSASYNCBLOCK::@572::@574 GetHost
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
char CHAR
Definition: xmlstorage.h:175
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968

◆ WSAAsyncGetProtoByName()

HANDLE WSAAPI WSAAsyncGetProtoByName ( IN HWND  hWnd,
IN UINT  wMsg,
IN CONST CHAR FAR Name,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 699 of file getxbyxx.c.

704 {
705  HANDLE TaskHandle;
708  PWSASYNCBLOCK AsyncBlock;
709  INT ErrorCode;
710  PVOID NameCopy;
711  DPRINT("WSAAsyncGetProtoByName: %lx, %lx, %s\n", hWnd, wMsg, Name);
712 
713  /* Enter prolog */
715  {
716  /* Leave now */
718  return NULL;
719  }
720 
721  /* Initialize the Async Thread */
723  {
724  /* Fail */
726  return NULL;
727  }
728 
729  /* Allocate an async block */
730  if (!(AsyncBlock = WsAsyncAllocateBlock(strlen(Name) + sizeof(CHAR))))
731  {
732  /* Fail */
734  return NULL;
735  }
736 
737  /* Make a copy of the address */
738  NameCopy = AsyncBlock + 1;
739  strcpy(NameCopy, Name);
740 
741  /* Initialize the Async Block */
742  AsyncBlock->Operation = WsAsyncGetProtoByName;
743  AsyncBlock->GetProto.hWnd = hWnd;
744  AsyncBlock->GetProto.wMsg = wMsg;
745  AsyncBlock->GetProto.ByWhat = NameCopy;
746  AsyncBlock->GetProto.Buffer = Buffer;
747  AsyncBlock->GetProto.BufferLength = BufferLength;
748 
749  /* Save the task handle and queue the request */
750  TaskHandle = AsyncBlock->TaskHandle;
751  WsAsyncQueueRequest(AsyncBlock);
752 
753  /* Return the task handle */
754  return TaskHandle;
755 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
char CHAR
Definition: xmlstorage.h:175
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
struct _WSASYNCBLOCK::@572::@575 GetProto
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968

◆ WSAAsyncGetProtoByNumber()

HANDLE WSAAPI WSAAsyncGetProtoByNumber ( IN HWND  hWnd,
IN UINT  wMsg,
IN INT  Number,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 762 of file getxbyxx.c.

767 {
768  HANDLE TaskHandle;
771  PWSASYNCBLOCK AsyncBlock;
772  INT ErrorCode;
773  DPRINT("WSAAsyncGetProtoByNumber: %lx, %lx, %lx\n", hWnd, wMsg, Number);
774 
775  /* Enter prolog */
777  {
778  /* Leave now */
780  return NULL;
781  }
782 
783  /* Initialize the Async Thread */
785  {
786  /* Fail */
788  return NULL;
789  }
790 
791  /* Allocate an async block */
792  if (!(AsyncBlock = WsAsyncAllocateBlock(0)))
793  {
794  /* Fail */
796  return NULL;
797  }
798 
799  /* Initialize the Async Block */
800  AsyncBlock->Operation = WsAsyncGetProtoByNumber;
801  AsyncBlock->GetProto.hWnd = hWnd;
802  AsyncBlock->GetProto.wMsg = wMsg;
803  AsyncBlock->GetProto.ByWhat = UlongToPtr(Number);
804  AsyncBlock->GetProto.Buffer = Buffer;
805  AsyncBlock->GetProto.BufferLength = BufferLength;
806 
807  /* Save the task handle and queue the request */
808  TaskHandle = AsyncBlock->TaskHandle;
809  WsAsyncQueueRequest(AsyncBlock);
810 
811  /* Return the task handle */
812  return TaskHandle;
813 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define UlongToPtr(u)
Definition: config.h:106
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
struct _WSASYNCBLOCK::@572::@575 GetProto
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968

◆ WSAAsyncGetServByName()

HANDLE WSAAPI WSAAsyncGetServByName ( IN HWND  hWnd,
IN UINT  wMsg,
IN CONST CHAR FAR Name,
IN CONST CHAR FAR Protocol,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 820 of file getxbyxx.c.

826 {
827  HANDLE TaskHandle;
830  PWSASYNCBLOCK AsyncBlock;
831  INT ErrorCode;
832  PVOID NameCopy;
833  DPRINT("WSAAsyncGetProtoByNumber: %lx, %lx, %s\n", hWnd, wMsg, Name);
834 
835  /* Enter prolog */
837  {
838  /* Leave now */
840  return NULL;
841  }
842 
843  /* Initialize the Async Thread */
845  {
846  /* Fail */
848  return NULL;
849  }
850 
851  /* Allocate an async block */
852  if (!(AsyncBlock = WsAsyncAllocateBlock(strlen(Name) + sizeof(CHAR))))
853  {
854  /* Fail */
856  return NULL;
857  }
858 
859  /* Make a copy of the address */
860  NameCopy = AsyncBlock + 1;
861  strcpy(NameCopy, Name);
862 
863  /* Initialize the Async Block */
864  AsyncBlock->Operation = WsAsyncGetProtoByName;
865  AsyncBlock->GetServ.hWnd = hWnd;
866  AsyncBlock->GetServ.wMsg = wMsg;
867  AsyncBlock->GetServ.ByWhat = NameCopy;
868  AsyncBlock->GetServ.Protocol = (PCHAR)Protocol;
869  AsyncBlock->GetServ.Buffer = Buffer;
870  AsyncBlock->GetServ.BufferLength = BufferLength;
871 
872  /* Save the task handle and queue the request */
873  TaskHandle = AsyncBlock->TaskHandle;
874  WsAsyncQueueRequest(AsyncBlock);
875 
876  /* Return the task handle */
877  return TaskHandle;
878 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
char CHAR
Definition: xmlstorage.h:175
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
#define PCHAR
Definition: match.c:90
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968
struct _WSASYNCBLOCK::@572::@576 GetServ

Referenced by test_WSAAsyncGetServByName().

◆ WSAAsyncGetServByPort()

HANDLE WSAAPI WSAAsyncGetServByPort ( IN HWND  hWnd,
IN UINT  wMsg,
IN INT  Port,
IN CONST CHAR FAR Protocol,
OUT CHAR FAR Buffer,
IN INT  BufferLength 
)

Definition at line 885 of file getxbyxx.c.

891 {
892  HANDLE TaskHandle;
895  PWSASYNCBLOCK AsyncBlock;
896  INT ErrorCode;
897  DPRINT("WSAAsyncGetProtoByNumber: %lx, %lx, %lx\n", hWnd, wMsg, Port);
898 
899  /* Enter prolog */
901  {
902  /* Leave now */
904  return NULL;
905  }
906 
907  /* Initialize the Async Thread */
909  {
910  /* Fail */
912  return NULL;
913  }
914 
915  /* Allocate an async block */
916  if (!(AsyncBlock = WsAsyncAllocateBlock(0)))
917  {
918  /* Fail */
920  return NULL;
921  }
922 
923  /* Initialize the Async Block */
924  AsyncBlock->Operation = WsAsyncGetServByPort;
925  AsyncBlock->GetServ.hWnd = hWnd;
926  AsyncBlock->GetServ.wMsg = wMsg;
927  AsyncBlock->GetServ.ByWhat = UlongToPtr(Port);
928  AsyncBlock->GetServ.Protocol = (PCHAR)Protocol;
929  AsyncBlock->GetServ.Buffer = Buffer;
930  AsyncBlock->GetServ.BufferLength = BufferLength;
931 
932  /* Save the task handle and queue the request */
933  TaskHandle = AsyncBlock->TaskHandle;
934  WsAsyncQueueRequest(AsyncBlock);
935 
936  /* Return the task handle */
937  return TaskHandle;
938 }
HANDLE TaskHandle
Definition: ws2_32p.h:27
CPPORT Port[4]
Definition: headless.c:34
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:56
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define UlongToPtr(u)
Definition: config.h:106
BOOL WSAAPI WsAsyncCheckAndInitThread(VOID)
Definition: async.c:832
#define PCHAR
Definition: match.c:90
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
WSASYNCOPS Operation
Definition: ws2_32p.h:28
#define WSAENOBUFS
Definition: winerror.h:1968
struct _WSASYNCBLOCK::@572::@576 GetServ

Referenced by test_WSAAsyncGetServByPort().

◆ WSACancelAsyncRequest()

INT WSAAPI WSACancelAsyncRequest ( IN HANDLE  hAsyncTaskHandle)

Definition at line 945 of file getxbyxx.c.

946 {
949  INT ErrorCode;
950  DPRINT("WSACancelAsyncRequest: %lx\n", hAsyncTaskHandle);
951 
952  /* Enter prolog */
954  {
955  /* Call the Async code */
956  ErrorCode = WsAsyncCancelRequest(hAsyncTaskHandle);
957 
958  /* Return */
959  if (ErrorCode == ERROR_SUCCESS) return ERROR_SUCCESS;
960  }
961 
962  /* Fail */
964  return SOCKET_ERROR;
965 }
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:56
INT WSAAPI WsAsyncCancelRequest(IN HANDLE TaskHandle)
Definition: async.c:936
void DPRINT(...)
Definition: polytest.cpp:61
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:409
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Variable Documentation

◆ afp

Definition at line 18 of file getxbyxx.c.

Referenced by getxyDataEnt().