mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[MSWSOCK] Partially implement Name Service Provider in mswsock. Brought to you by Andreas Maier aka andy-123 with small fixes by Peter Hater and formatting by me. CORE-10024 CORE-10440
svn path=/trunk/; revision=72735
This commit is contained in:
parent
be31da9af7
commit
0fc28afe45
5 changed files with 1935 additions and 17 deletions
|
@ -5,6 +5,8 @@ spec2def(mswsock.dll mswsock.spec ADD_IMPORTLIB)
|
|||
|
||||
list(APPEND SOURCE
|
||||
extensions.c
|
||||
mswhelper.c
|
||||
nsplookup.c
|
||||
stubs.c
|
||||
precomp.h)
|
||||
|
||||
|
@ -13,7 +15,7 @@ add_library(mswsock SHARED
|
|||
mswsock.rc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mswsock.def)
|
||||
|
||||
set_module_type(mswsock win32dll UNICODE)
|
||||
add_importlibs(mswsock ws2_32 msvcrt kernel32)
|
||||
set_module_type(mswsock win32dll)
|
||||
add_importlibs(mswsock ws2_32 dnsapi msvcrt kernel32)
|
||||
add_pch(mswsock precomp.h SOURCE)
|
||||
add_cd_file(TARGET mswsock DESTINATION reactos/system32 FOR all)
|
||||
|
|
576
reactos/dll/win32/mswsock/mswhelper.c
Normal file
576
reactos/dll/win32/mswsock/mswhelper.c
Normal file
|
@ -0,0 +1,576 @@
|
|||
|
||||
#include "precomp.h"
|
||||
|
||||
#include <winuser.h>
|
||||
#include <winnls.h>
|
||||
#include <wchar.h>
|
||||
#include <sal.h>
|
||||
|
||||
#include "mswhelper.h"
|
||||
|
||||
#define MSW_BUFSIZE 512
|
||||
#define MAX_ARRAY_SIZE 5
|
||||
|
||||
void
|
||||
mswBufferInit(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ BYTE* buffer,
|
||||
_In_ DWORD bufferSize)
|
||||
{
|
||||
RtlZeroMemory(mswBuf, sizeof(*mswBuf));
|
||||
RtlZeroMemory(buffer, bufferSize);
|
||||
mswBuf->bytesMax = bufferSize;
|
||||
mswBuf->buffer = buffer;
|
||||
mswBuf->bufendptr = buffer;
|
||||
mswBuf->bufok = TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferCheck(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ DWORD count)
|
||||
{
|
||||
if (mswBuf->bytesUsed + count <= mswBuf->bytesMax)
|
||||
return TRUE;
|
||||
|
||||
mswBuf->bufok = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferIncUsed(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ DWORD count)
|
||||
{
|
||||
if (!mswBufferCheck(mswBuf, count))
|
||||
return FALSE;
|
||||
|
||||
mswBuf->bytesUsed += count;
|
||||
mswBuf->bufendptr += count;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE*
|
||||
mswBufferEndPtr(_Inout_ PMSW_BUFFER mswBuf)
|
||||
{
|
||||
return mswBuf->bufendptr;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppend(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void *dataToAppend,
|
||||
_In_ DWORD dataSize)
|
||||
{
|
||||
if (!mswBufferCheck(mswBuf, dataSize))
|
||||
return FALSE;
|
||||
|
||||
RtlCopyMemory(mswBuf->bufendptr, dataToAppend, dataSize);
|
||||
mswBuf->bytesUsed += dataSize;
|
||||
mswBuf->bufendptr += dataSize;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL mswBufferAppendStrA(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ char* str)
|
||||
{
|
||||
return mswBufferAppend(mswBuf, str, strlen(str) + sizeof(char));
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendStrW(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ WCHAR* str)
|
||||
{
|
||||
int bytelen = (wcslen(str) + 1) * sizeof(WCHAR);
|
||||
return mswBufferAppend(mswBuf, str, bytelen);
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendPtr(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void* ptr)
|
||||
{
|
||||
return mswBufferAppend(mswBuf, &ptr, sizeof(ptr));
|
||||
}
|
||||
|
||||
/* lst = pointer to pointer of items
|
||||
|
||||
*lst[0] = 1st item
|
||||
*lst[1] = 2nd item
|
||||
...
|
||||
lst[n] = NULL = End of List
|
||||
|
||||
itemLength = data in Bytes for each item.
|
||||
|
||||
ptrofs = delta relative to mswBuf.buffer
|
||||
*/
|
||||
BOOL
|
||||
mswBufferAppendLst(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void **lst,
|
||||
_In_ DWORD itemByteLength,
|
||||
_In_opt_ int ptrofs)
|
||||
{
|
||||
DWORD lstItemCount;
|
||||
DWORD lstByteSize;
|
||||
DWORD lstDataPos;
|
||||
DWORD i1;
|
||||
UINT_PTR *ptrSrcLstPos;
|
||||
|
||||
/* calculate size of list */
|
||||
ptrSrcLstPos = (UINT_PTR*)lst;
|
||||
lstItemCount = 0;
|
||||
while (*ptrSrcLstPos != (UINT_PTR)NULL)
|
||||
{
|
||||
lstItemCount++;
|
||||
ptrSrcLstPos++;
|
||||
}
|
||||
|
||||
lstByteSize = ((lstItemCount + 1) * sizeof(UINT_PTR)) + /* item-pointer + null-ptr (for end) */
|
||||
(lstItemCount * itemByteLength); /* item-data */
|
||||
|
||||
if (mswBuf->bytesUsed + lstByteSize > mswBuf->bytesMax)
|
||||
return FALSE;
|
||||
|
||||
/* calculate position for the data of the first item */
|
||||
lstDataPos = ((lstItemCount + 1) * sizeof(UINT_PTR)) +
|
||||
(DWORD)mswBufferEndPtr(mswBuf);
|
||||
/* add ptrofs */
|
||||
lstDataPos += ptrofs;
|
||||
|
||||
/* write array of Pointer to data */
|
||||
for (i1 = 0; i1 < lstItemCount; i1++)
|
||||
{
|
||||
if (!mswBufferAppendPtr(mswBuf, (void*)lstDataPos))
|
||||
return FALSE;
|
||||
|
||||
lstDataPos += sizeof(UINT_PTR);
|
||||
}
|
||||
|
||||
/* end of list */
|
||||
if (!mswBufferAppendPtr(mswBuf, NULL))
|
||||
return FALSE;
|
||||
|
||||
/* write data */
|
||||
ptrSrcLstPos = (UINT_PTR*)lst;
|
||||
for (i1 = 0; i1 < lstItemCount; i1++)
|
||||
{
|
||||
mswBufferAppend(mswBuf, *(BYTE**)ptrSrcLstPos, itemByteLength);
|
||||
ptrSrcLstPos++;
|
||||
}
|
||||
return mswBuf->bufok;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendStrLstA(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void **lst,
|
||||
_In_opt_ int ptrofs)
|
||||
{
|
||||
DWORD lstItemLen[MAX_ARRAY_SIZE];
|
||||
DWORD lstItemCount;
|
||||
DWORD lstByteSize;
|
||||
DWORD lstDataPos;
|
||||
DWORD lstDataSize;
|
||||
DWORD i1;
|
||||
UINT_PTR *ptrSrcLstPos;
|
||||
|
||||
/* calculate size of list */
|
||||
ptrSrcLstPos = (UINT_PTR*)lst;
|
||||
lstItemCount = 0;
|
||||
lstDataSize = 0;
|
||||
|
||||
while (*ptrSrcLstPos != (UINT_PTR)NULL)
|
||||
{
|
||||
if (lstItemCount >= MAX_ARRAY_SIZE)
|
||||
return FALSE;
|
||||
|
||||
i1 = strlen((char*)*ptrSrcLstPos) + sizeof(char);
|
||||
lstItemLen[lstItemCount] = i1;
|
||||
lstItemCount++;
|
||||
lstDataSize += i1;
|
||||
ptrSrcLstPos++;
|
||||
}
|
||||
|
||||
lstByteSize = ((lstItemCount + 1) * sizeof(UINT_PTR)) + /* item-pointer + null-ptr (for end) */
|
||||
lstDataSize; /* item-data */
|
||||
|
||||
if (mswBuf->bytesUsed + lstByteSize > mswBuf->bytesMax)
|
||||
return FALSE;
|
||||
|
||||
/* calculate position for the data of the first item */
|
||||
lstDataPos = ((lstItemCount + 1) * sizeof(UINT_PTR)) +
|
||||
(DWORD)mswBufferEndPtr(mswBuf);
|
||||
|
||||
/* add ptrofs */
|
||||
lstDataPos += ptrofs;
|
||||
|
||||
for (i1 = 0; i1 < lstItemCount; i1++)
|
||||
{
|
||||
if (!mswBufferAppendPtr(mswBuf, (void*)lstDataPos))
|
||||
return FALSE;
|
||||
|
||||
lstDataPos += lstItemLen[i1];
|
||||
}
|
||||
|
||||
/* end of list */
|
||||
if (!mswBufferAppendPtr(mswBuf, NULL))
|
||||
return FALSE;
|
||||
|
||||
/* write data */
|
||||
ptrSrcLstPos = (UINT_PTR*)lst;
|
||||
for (i1 = 0; i1 < lstItemCount; i1++)
|
||||
{
|
||||
if (!mswBufferAppendStrA(mswBuf, *(char**)ptrSrcLstPos))
|
||||
return FALSE;
|
||||
|
||||
ptrSrcLstPos++;
|
||||
}
|
||||
return mswBuf->bufok;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendBlob_Hostent(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ char* hostnameA,
|
||||
_In_ DWORD ip4addr)
|
||||
{
|
||||
PHOSTENT phe;
|
||||
void* lst[2];
|
||||
BYTE* bytesOfs;
|
||||
|
||||
/* blob */
|
||||
lpRes->lpBlob = (LPBLOB)mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*lpRes->lpBlob)))
|
||||
return FALSE;
|
||||
|
||||
/* cbSize will be set later */
|
||||
lpRes->lpBlob->cbSize = 0;
|
||||
lpRes->lpBlob->pBlobData = mswBufferEndPtr(mswBuf);
|
||||
|
||||
/* hostent */
|
||||
phe = (PHOSTENT)lpRes->lpBlob->pBlobData;
|
||||
bytesOfs = mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*phe)))
|
||||
return FALSE;
|
||||
|
||||
phe->h_addrtype = AF_INET;
|
||||
phe->h_length = 4; /* 4 Byte (IPv4) */
|
||||
|
||||
/* aliases */
|
||||
phe->h_aliases = (char**)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendPtr(mswBuf, NULL))
|
||||
return FALSE;
|
||||
|
||||
/* addr_list */
|
||||
RtlZeroMemory(lst, sizeof(lst));
|
||||
|
||||
if (ip4addr != 0)
|
||||
lst[0] = (void*)&ip4addr;
|
||||
|
||||
phe->h_addr_list = (char**)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendLst(mswBuf, lst, 4, -(DWORD)bytesOfs))
|
||||
return FALSE;
|
||||
|
||||
/* name */
|
||||
phe->h_name = (char*)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendStrA(mswBuf, hostnameA))
|
||||
return FALSE;
|
||||
|
||||
lpRes->lpBlob->cbSize = (DWORD)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
return mswBuf->bufok;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendBlob_Servent(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ char* serviceNameA,
|
||||
_In_ char** serviceAliasesA,
|
||||
_In_ char* protocolNameA,
|
||||
_In_ WORD port)
|
||||
{
|
||||
PSERVENT pse;
|
||||
BYTE* bytesOfs;
|
||||
|
||||
/* blob */
|
||||
lpRes->lpBlob = (LPBLOB)mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*lpRes->lpBlob)))
|
||||
return FALSE;
|
||||
|
||||
lpRes->lpBlob->cbSize = 0;//later
|
||||
lpRes->lpBlob->pBlobData = mswBufferEndPtr(mswBuf);
|
||||
|
||||
/* servent */
|
||||
pse = (LPSERVENT)lpRes->lpBlob->pBlobData;
|
||||
bytesOfs = mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*pse)))
|
||||
return FALSE;
|
||||
|
||||
pse->s_aliases = (char**)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendStrLstA(mswBuf,
|
||||
(void**)serviceAliasesA,
|
||||
-(DWORD)bytesOfs))
|
||||
return FALSE;
|
||||
|
||||
pse->s_name = (char*)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendStrA(mswBuf, serviceNameA))
|
||||
return FALSE;
|
||||
|
||||
pse->s_port = htons(port);
|
||||
|
||||
pse->s_proto = (char*)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
|
||||
if (!mswBufferAppendStrA(mswBuf, protocolNameA))
|
||||
return FALSE;
|
||||
|
||||
lpRes->lpBlob->cbSize = (DWORD)(mswBufferEndPtr(mswBuf) - bytesOfs);
|
||||
return mswBuf->bufok;
|
||||
}
|
||||
|
||||
BOOL
|
||||
mswBufferAppendAddr_AddrInfoW(_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ DWORD ip4addr)
|
||||
{
|
||||
LPCSADDR_INFO paddrinfo;
|
||||
LPSOCKADDR_IN psa;
|
||||
|
||||
lpRes->dwNumberOfCsAddrs = 1;
|
||||
lpRes->lpcsaBuffer = (LPCSADDR_INFO)mswBufferEndPtr(mswBuf);
|
||||
|
||||
paddrinfo = lpRes->lpcsaBuffer;
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*paddrinfo)))
|
||||
return FALSE;
|
||||
|
||||
paddrinfo->LocalAddr.lpSockaddr = (LPSOCKADDR)mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*paddrinfo->LocalAddr.lpSockaddr)))
|
||||
return FALSE;
|
||||
|
||||
paddrinfo->RemoteAddr.lpSockaddr = (LPSOCKADDR)mswBufferEndPtr(mswBuf);
|
||||
|
||||
if (!mswBufferIncUsed(mswBuf, sizeof(*paddrinfo->RemoteAddr.lpSockaddr)))
|
||||
return FALSE;
|
||||
|
||||
paddrinfo->iSocketType = SOCK_DGRAM;
|
||||
paddrinfo->iProtocol = IPPROTO_UDP;
|
||||
|
||||
psa = (LPSOCKADDR_IN)paddrinfo->LocalAddr.lpSockaddr;
|
||||
paddrinfo->LocalAddr.iSockaddrLength = sizeof(*psa);
|
||||
psa->sin_family = AF_INET;
|
||||
psa->sin_port = 0;
|
||||
psa->sin_addr.s_addr = 0;
|
||||
RtlZeroMemory(psa->sin_zero, sizeof(psa->sin_zero));
|
||||
|
||||
psa = (LPSOCKADDR_IN)paddrinfo->RemoteAddr.lpSockaddr;
|
||||
paddrinfo->RemoteAddr.iSockaddrLength = sizeof(*psa);
|
||||
psa->sin_family = AF_INET;
|
||||
psa->sin_port = 0;
|
||||
psa->sin_addr.s_addr = ip4addr;
|
||||
RtlZeroMemory(psa->sin_zero, sizeof(psa->sin_zero));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ansicode <-> unicode */
|
||||
WCHAR*
|
||||
StrA2WHeapAlloc(_In_opt_ HANDLE hHeap,
|
||||
_In_ char* aStr)
|
||||
{
|
||||
int aStrByteLen;
|
||||
int wStrByteLen;
|
||||
int charLen;
|
||||
int ret;
|
||||
WCHAR* wStr;
|
||||
|
||||
if (aStr == NULL)
|
||||
return NULL;
|
||||
|
||||
charLen = strlen(aStr) + 1;
|
||||
|
||||
aStrByteLen = (charLen * sizeof(char));
|
||||
wStrByteLen = (charLen * sizeof(WCHAR));
|
||||
|
||||
if (hHeap == 0)
|
||||
hHeap = GetProcessHeap();
|
||||
|
||||
wStr = HeapAlloc(hHeap, 0, wStrByteLen);
|
||||
if (wStr == NULL)
|
||||
{
|
||||
HeapFree(hHeap, 0, wStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = MultiByteToWideChar(1252,
|
||||
0,
|
||||
aStr,
|
||||
aStrByteLen,
|
||||
wStr,
|
||||
charLen);
|
||||
|
||||
if (ret != charLen)
|
||||
{
|
||||
HeapFree(hHeap, 0, wStr);
|
||||
return NULL;
|
||||
}
|
||||
return wStr;
|
||||
}
|
||||
|
||||
char*
|
||||
StrW2AHeapAlloc(_In_opt_ HANDLE hHeap,
|
||||
_In_ WCHAR* wStr)
|
||||
{
|
||||
int charLen;
|
||||
int aStrByteLen;
|
||||
int ret;
|
||||
char* aStr;
|
||||
|
||||
if (wStr == NULL)
|
||||
return NULL;
|
||||
|
||||
charLen = wcslen(wStr) + 1;
|
||||
|
||||
aStrByteLen = (charLen * sizeof(char));
|
||||
|
||||
if (hHeap == 0)
|
||||
hHeap = GetProcessHeap();
|
||||
|
||||
aStr = HeapAlloc(hHeap, 0, aStrByteLen);
|
||||
if (aStr == NULL)
|
||||
{
|
||||
HeapFree(hHeap, 0, aStr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = WideCharToMultiByte(1252,
|
||||
0,
|
||||
wStr,
|
||||
charLen,
|
||||
aStr,
|
||||
aStrByteLen,
|
||||
NULL,
|
||||
NULL);
|
||||
if (ret != aStrByteLen)
|
||||
{
|
||||
HeapFree(hHeap, 0, aStr);
|
||||
return NULL;
|
||||
}
|
||||
return aStr;
|
||||
}
|
||||
|
||||
WCHAR*
|
||||
StrCpyHeapAllocW(_In_opt_ HANDLE hHeap,
|
||||
_In_ WCHAR* wStr)
|
||||
{
|
||||
int chLen;
|
||||
int bLen;
|
||||
WCHAR* resW;
|
||||
|
||||
if (wStr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (hHeap == 0)
|
||||
hHeap = GetProcessHeap();
|
||||
|
||||
chLen = wcslen(wStr);
|
||||
|
||||
bLen = (chLen + 1) * sizeof(WCHAR);
|
||||
|
||||
resW = HeapAlloc(hHeap, 0, bLen);
|
||||
RtlCopyMemory(resW, wStr, bLen);
|
||||
return resW;
|
||||
}
|
||||
|
||||
char*
|
||||
StrCpyHeapAllocA(_In_opt_ HANDLE hHeap,
|
||||
_In_ char* aStr)
|
||||
{
|
||||
int chLen;
|
||||
int bLen;
|
||||
char* resA;
|
||||
|
||||
if (aStr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (hHeap == 0)
|
||||
hHeap = GetProcessHeap();
|
||||
|
||||
chLen = strlen(aStr);
|
||||
|
||||
bLen = (chLen + 1) * sizeof(char);
|
||||
|
||||
resA = HeapAlloc(hHeap, 0, bLen);
|
||||
RtlCopyMemory(resA, aStr, bLen);
|
||||
return resA;
|
||||
}
|
||||
|
||||
char**
|
||||
StrAryCpyHeapAllocA(_In_opt_ HANDLE hHeap,
|
||||
_In_ char** aStrAry)
|
||||
{
|
||||
char** aSrcPtr;
|
||||
char** aDstPtr;
|
||||
char* aDstNextStr;
|
||||
DWORD aStrByteLen[MAX_ARRAY_SIZE];
|
||||
int bLen;
|
||||
int bItmLen;
|
||||
int aCount;
|
||||
int i1;
|
||||
char** resA;
|
||||
|
||||
if (hHeap == 0)
|
||||
hHeap = GetProcessHeap();
|
||||
|
||||
/* Calculating size of array ... */
|
||||
aSrcPtr = aStrAry;
|
||||
bLen = 0;
|
||||
aCount = 0;
|
||||
|
||||
while (*aSrcPtr != NULL)
|
||||
{
|
||||
if (aCount >= MAX_ARRAY_SIZE)
|
||||
return NULL;
|
||||
|
||||
bItmLen = (strlen(*aSrcPtr) + 1) * sizeof(char);
|
||||
aStrByteLen[aCount] = bItmLen;
|
||||
|
||||
bLen += sizeof(*aSrcPtr) + bItmLen;
|
||||
|
||||
aSrcPtr++;
|
||||
aCount++;
|
||||
}
|
||||
|
||||
/* size for NULL-terminator */
|
||||
bLen += sizeof(*aSrcPtr);
|
||||
|
||||
/* get memory */
|
||||
resA = HeapAlloc(hHeap, 0, bLen);
|
||||
|
||||
/* copy data */
|
||||
aSrcPtr = aStrAry;
|
||||
aDstPtr = resA;
|
||||
|
||||
/* pos for the first string */
|
||||
aDstNextStr = (char*)(resA + aCount + 1);
|
||||
for (i1 = 0; i1 < aCount; i1++)
|
||||
{
|
||||
bItmLen = aStrByteLen[i1];
|
||||
|
||||
*aDstPtr = aDstNextStr;
|
||||
RtlCopyMemory(*aDstPtr, *aSrcPtr, bItmLen);
|
||||
|
||||
aDstNextStr = (char*)((DWORD)aDstNextStr + (DWORD)bItmLen);
|
||||
aDstPtr++;
|
||||
aSrcPtr++;
|
||||
}
|
||||
|
||||
/* terminate with NULL */
|
||||
*aDstPtr = NULL;
|
||||
|
||||
return resA;
|
||||
}
|
121
reactos/dll/win32/mswsock/mswhelper.h
Normal file
121
reactos/dll/win32/mswsock/mswhelper.h
Normal file
|
@ -0,0 +1,121 @@
|
|||
#ifndef _MSWHELPER_H
|
||||
#define _MSWHELPER_H
|
||||
|
||||
#include <ws2spi.h>
|
||||
|
||||
typedef struct {
|
||||
DWORD bytesUsed;
|
||||
DWORD bytesMax;
|
||||
BYTE* buffer;
|
||||
BYTE* bufendptr; // Pointer to the first "unused" byte
|
||||
BOOL bufok; // FALSE if on mswBuffer-Function fails
|
||||
} MSW_BUFFER, *PMSW_BUFFER;
|
||||
|
||||
void
|
||||
mswBufferInit(
|
||||
_Out_ PMSW_BUFFER mswBuf,
|
||||
_In_ BYTE* buffer,
|
||||
_In_ DWORD bufferSize);
|
||||
|
||||
inline
|
||||
BOOL
|
||||
mswBufferCheck(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ DWORD count);
|
||||
|
||||
BOOL
|
||||
mswBufferIncUsed(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ DWORD count);
|
||||
|
||||
inline
|
||||
BYTE*
|
||||
mswBufferEndPtr(
|
||||
_Inout_ PMSW_BUFFER mswBuf);
|
||||
|
||||
BOOL
|
||||
mswBufferAppend(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void *dataToAppend,
|
||||
_In_ DWORD dataSize);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendStrA(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ char* str);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendStrW(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ WCHAR* str);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendPtr(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void* ptr);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendLst(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void **lst,
|
||||
_In_ DWORD itemByteLength,
|
||||
_In_opt_ int deltaofs);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendStrLstA(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_In_ void **lst,
|
||||
_In_opt_ int ptrofs);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendBlob_Hostent(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ char* hostnameA,
|
||||
_In_ DWORD ip4addr);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendBlob_Servent(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ char* serviceNameA,
|
||||
_In_ char** serviceAliasesA,
|
||||
_In_ char* protocolNameA,
|
||||
_In_ WORD port);
|
||||
|
||||
BOOL
|
||||
mswBufferAppendAddr_AddrInfoW(
|
||||
_Inout_ PMSW_BUFFER mswBuf,
|
||||
_Inout_ LPWSAQUERYSETW lpRes,
|
||||
_In_ DWORD ip4addr);
|
||||
|
||||
WCHAR*
|
||||
StrA2WHeapAlloc(
|
||||
_In_opt_ HANDLE hHeap,
|
||||
_In_ char* aStr);
|
||||
|
||||
char*
|
||||
StrW2AHeapAlloc(
|
||||
_In_opt_ HANDLE hHeap,
|
||||
_In_ WCHAR* wStr);
|
||||
|
||||
WCHAR*
|
||||
StrCpyHeapAllocW(
|
||||
_In_opt_ HANDLE hHeap,
|
||||
_In_ WCHAR* wStr);
|
||||
|
||||
char*
|
||||
StrCpyHeapAllocA(
|
||||
_In_opt_ HANDLE hHeap,
|
||||
_In_ char* aStr);
|
||||
|
||||
/* strary:
|
||||
ptr1 ... ptrn \0
|
||||
data1 ... datan
|
||||
*/
|
||||
char**
|
||||
StrAryCpyHeapAllocA(
|
||||
_In_opt_ HANDLE hHeap,
|
||||
_In_ char** aStrAry);
|
||||
|
||||
#endif // _MSWHELPER_H
|
1233
reactos/dll/win32/mswsock/nsplookup.c
Normal file
1233
reactos/dll/win32/mswsock/nsplookup.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "precomp.h"
|
||||
|
||||
#include <windef.h>
|
||||
#include <ws2spi.h>
|
||||
#include <nspapi.h>
|
||||
|
||||
|
@ -417,21 +418,6 @@ GetNameByTypeW(LPGUID lpServiceType,LPWSTR lpServiceName,DWORD dwNameLength)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
INT
|
||||
WINAPI
|
||||
NSPStartup(
|
||||
LPGUID lpProviderId,
|
||||
LPNSP_ROUTINE lpnspRoutines
|
||||
)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue