19#define NSP_CALLID_DNS 0x0001
20#define NSP_CALLID_HOSTNAME 0x0002
21#define NSP_CALLID_HOSTBYNAME 0x0003
22#define NSP_CALLID_SERVICEBYNAME 0x0004
27#ifndef WS2_INTERNAL_MAX_ALIAS
28#define WS2_INTERNAL_MAX_ALIAS 512
67 {0xAE, 0x5A, 0x00, 0xAA, 0x00, 0xA7, 0x11, 0x2B}};
74 {0xBA, 0xA5, 0x2E, 0x0B, 0xD7, 0x1F, 0xDD, 0x83}};
83const rdrLib =
"mswsock.dll-original";
84lpRdrNSPStartup rdrNSPStartup;
178 *lphLookup = (
HANDLE)pLook;
192 pLook->rdrproc = rdrproc_tcpip;
196 pLook->rdrproc = rdrproc_nla;
203 if (pLook->rdrproc.NSPLookupServiceBegin(lpProviderId,
235 else if (
IsEqualGUID(lpqsRestrictions->lpServiceClassId,
240 lpqsRestrictions->lpszServiceInstanceName,
243 else if (
IsEqualGUID(lpqsRestrictions->lpServiceClassId,
248 lpqsRestrictions->lpszServiceInstanceName,
251 else if (
IsEqualGUID(lpqsRestrictions->lpServiceClassId,
280 INT res = pLook->rdrproc.NSPLookupServiceNext(pLook->rdrLookup,
302 lpqsResults->dwSize =
sizeof(*lpqsResults);
330 _In_opt_ LPWSACOMPLETION lpCompletion,
350 res = pLook->rdrproc.NSPLookupServiceEnd(pLook->rdrLookup);
414 if (
data->CallID != 0)
417 data->CallID = CallID;
427 if (hostnameA !=
NULL)
448 DWORD bufByteLen = bufCharLen *
sizeof(
WCHAR);
471 DNS_STATUS dns_status = { 0 };
509 if ((dns_status != 0) || (dp ==
NULL))
547#define SKIPWS(ptr, act) \
548{while(*ptr && isspace(*ptr)) ptr++; if(!*ptr) act;}
550#define SKIPANDMARKSTR(ptr, act) \
551{while(*ptr && !isspace(*ptr)) ptr++; \
552 if(!*ptr) {act;} else { *ptr = 0; ptr++; }}
571 *PortNumberStr = ServiceString;
574 while (*ServiceString && NAliases < MaxAlias - 1)
576 SKIPWS(ServiceString,
break);
580 if (
strlen(ServiceString))
583 *Aliases++ = ServiceString;
591 *ProtocolStr =
strchr(*PortNumberStr,
'/');
625 L"System\\CurrentControlSet\\Services\\Tcpip\\Parameters",
667 if (ExpandedPath[StringLength - 1] !=
L'\\')
677 if (ExpandedPath[StringLength - 1] !=
L'\\')
708 ProtocolStr = 0,
Comment = 0, EndValid;
719 if (!
data->hostnameW)
730 nameProtoA =
strchr(nameA,
'/');
731 if (nameProtoA ==
NULL)
738 i = (
DWORD)(nameProtoA - nameA - 1);
741 nameServiceA[
i] =
'\0';
759 sizeof( ServiceDBData ) - 1,
763 ThisLine =
NextLine = ServiceDBData;
764 EndValid = ServiceDBData + ReadSize;
765 ServiceDBData[
sizeof(ServiceDBData) - 1] =
'\0';
775 if (ThisLine == ServiceDBData)
781 memmove(ServiceDBData, ThisLine, LineLen);
784 ServiceDBData + LineLen,
785 sizeof( ServiceDBData )-1 - LineLen,
789 EndValid = ServiceDBData + LineLen + ReadSize;
791 ThisLine = ServiceDBData;
793 if (!ReadSize)
break;
809 (
strlen(nameProtoA) == 0 ||
strcmp(ProtocolStr, nameProtoA) == 0))
837 hostinfo->servport =
atoi(PortNumberStr);
845 if (nameServiceA !=
NULL)
873 lpRes->dwSize =
sizeof(*lpRes);
874 lpRes->dwNameSpace =
NS_DNS;
880 if (
data->CallIDCounter >= 1)
891 data->CallIDCounter++;
925 ServiceInstanceNameW = hostinfo.
hostnameW;
927 if (ServiceInstanceNameA ==
NULL)
936 ServiceInstanceNameW = hostinfo.
servnameW;
938 if (ServiceInstanceNameA ==
NULL)
945 if (ServiceProtocolNameA ==
NULL)
958 *lpResLen =
buf.bytesUsed;
972 ServiceInstanceNameA,
975 *lpResLen =
buf.bytesUsed;
985 ServiceInstanceNameA,
987 ServiceProtocolNameA,
990 *lpResLen =
buf.bytesUsed;
1009 lpRes->lpszServiceInstanceName =
NULL;
1010 *lpResLen =
buf.bytesUsed;
1016 *lpResLen =
buf.bytesUsed;
1021 if (ServiceInstanceNameA !=
NULL)
1022 HeapFree(hHeap, 0, ServiceInstanceNameA);
1024 if (ServiceProtocolNameA !=
NULL)
1025 HeapFree(hHeap, 0, ServiceProtocolNameA);
1050 if ((lpRout ==
NULL) ||
1066 lpRout->dwMajorVersion = 1;
1067 lpRout->dwMinorVersion = 1;
1068 lpRout->cbSize =
sizeof(*lpRout) -
sizeof(lpRout->NSPIoctl);
1077 lpRout->NSPIoctl =
NULL;
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
static WCHAR ServiceName[]
#define RegCloseKey(hKey)
BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD nSize)
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
#define FILE_ATTRIBUTE_NORMAL
#define ERROR_INVALID_NAME
DNS_STATUS WINAPI DnsQuery_W(LPCWSTR Name, WORD Type, DWORD Options, PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved)
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
static void cleanup(void)
VOID WSAAPI WSASetLastError(IN INT iError)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
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
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define memmove(s1, s2, n)
#define _In_reads_bytes_(size)
#define _Out_writes_bytes_to_(size, count)
BOOL mswBufferIncUsed(_Inout_ PMSW_BUFFER mswBuf, _In_ DWORD count)
WCHAR * StrA2WHeapAlloc(_In_opt_ HANDLE hHeap, _In_ char *aStr)
char * StrW2AHeapAlloc(_In_opt_ HANDLE hHeap, _In_ WCHAR *wStr)
BOOL mswBufferAppendAddr_AddrInfoW(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ DWORD ip4addr)
BOOL mswBufferAppendStrW(_Inout_ PMSW_BUFFER mswBuf, _In_ WCHAR *str)
BOOL mswBufferAppendBlob_Hostent(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ char **hostAliasesA, _In_ char *hostnameA, _In_ DWORD ip4addr)
char ** StrAryCpyHeapAllocA(_In_opt_ HANDLE hHeap, _In_ char **aStrAry)
void mswBufferInit(_Inout_ PMSW_BUFFER mswBuf, _In_ BYTE *buffer, _In_ DWORD bufferSize)
BYTE * mswBufferEndPtr(_Inout_ PMSW_BUFFER mswBuf)
char ** StrAryCpyHeapAllocWToA(_In_opt_ HANDLE hHeap, _In_ WCHAR **wStrAry)
WCHAR * StrCpyHeapAllocW(_In_opt_ HANDLE hHeap, _In_ WCHAR *wStr)
BOOL mswBufferAppendBlob_Servent(_Inout_ PMSW_BUFFER mswBuf, _Inout_ LPWSAQUERYSETW lpRes, _In_ char *serviceNameA, _In_ char **serviceAliasesA, _In_ char *protocolNameA, _In_ WORD port)
_In_ NDIS_ERROR_CODE ErrorCode
static const GUID guid_INET_HOSTADDRBYINETSTRING
HANDLE WSAAPI OpenNetworkDatabase(_In_ LPCWSTR Name)
INT WSAAPI mwsNSPCleanUp(_In_ LPGUID lpProviderId)
static const GUID guid_mswsock_TcpIp
static const GUID guid_NULL
INT WINAPI mswNSPStartup(LPGUID lpProviderId, LPNSP_ROUTINE lpRout)
#define NSP_CALLID_SERVICEBYNAME
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)
static const GUID guid_HOSTNAME
static const GUID guid_INET_SERVICEBYNAME
INT NSP_LookupServiceNextW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Inout_ LPWSAQUERYSETW lpRes, _Inout_ LPDWORD lpResLen)
INT WSAAPI mwsNSPLookupServiceEnd(_In_ HANDLE hLookup)
static const GUID guid_INET_HOSTADDRBYNAME
INT NSP_LookupServiceBeginW(PWSHANDLEINTERN data, CHAR *hostnameA, WCHAR *hostnameW, DWORD CallID)
int WINAPI NSPStartup(_In_ LPGUID lpProviderId, _Out_ LPNSP_ROUTINE lpRout)
INT NSP_GetHostNameHeapAllocW(_Out_ WCHAR **hostname)
struct WSHANDLEINTERN * PWSHANDLEINTERN
INT WSAAPI mwsNSPLookupServiceBegin(_In_ LPGUID lpProviderId, _In_ LPWSAQUERYSETW lpqsRestrictions, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo, _In_ DWORD dwControlFlags, _Out_ LPHANDLE lphLookup)
INT WSAAPI mwsNSPInstallServiceClass(_In_ LPGUID lpProviderId, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
INT WSAAPI mwsNSPSetService(_In_ LPGUID lpProviderId, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo, _In_ LPWSAQUERYSETW lpqsRegInfo, _In_ WSAESETSERVICEOP essOperation, _In_ DWORD dwControlFlags)
INT WSAAPI mwsNSPRemoveServiceClass(_In_ LPGUID lpProviderId, _In_ LPGUID lpServiceClassId)
static const GUID guid_mswsock_NLA
INT NSP_GetServiceByNameHeapAllocW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Out_ PWSHOSTINFOINTERN hostinfo)
INT WSAAPI mwsNSPGetServiceClassInfo(_In_ LPGUID lpProviderId, _In_ LPDWORD lpdwBufSize, _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo)
struct WSHOSTINFOINTERN * PWSHOSTINFOINTERN
#define WS2_INTERNAL_MAX_ALIAS
INT NSP_GetHostByNameHeapAllocW(_In_ PWSHANDLEINTERN data, _In_ DWORD dwControlFlags, _Out_ PWSHOSTINFOINTERN hostinfo)
static BOOL DecodeServEntFromString(IN PCHAR ServiceString, OUT PCHAR *ServiceName, OUT PCHAR *PortNumberStr, OUT PCHAR *ProtocolStr, IN PCHAR *Aliases, IN DWORD MaxAlias)
#define NSP_CALLID_HOSTNAME
#define NSP_CALLID_HOSTBYNAME
INT WSAAPI mwsNSPLookupServiceNext(_In_ HANDLE hLookup, _In_ DWORD dwControlFlags, _Inout_ LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults)
#define SKIPANDMARKSTR(ptr, act)
#define IsEqualGUID(rguid1, rguid2)
STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszSrc)
struct _DnsRecordW * pNext
union _DnsRecordW::@3300 Data
#define SVCID_INET_SERVICEBYNAME
#define SVCID_INET_HOSTADDRBYNAME
#define SVCID_INET_HOSTADDRBYINETSTRING
#define RtlZeroMemory(Destination, Length)
#define GetSystemDirectory
#define ExpandEnvironmentStrings
#define MAX_COMPUTERNAME_LENGTH
#define DNS_QUERY_NO_RECURSION
#define DNS_QUERY_STANDARD
#define WSAHOST_NOT_FOUND
#define WSASERVICE_NOT_FOUND
_In_ _In_opt_ _Out_writes_bytes_to_opt_ lpdwBufferLength _Inout_ LPDWORD lpdwBufferLength
#define HKEY_LOCAL_MACHINE
enum _WSAESETSERVICEOP WSAESETSERVICEOP
#define LUP_RETURN_ALIASES
#define WSA_NOT_ENOUGH_MEMORY
int PASCAL FAR WSAGetLastError(void)