2004-04-07 22:39:00 +02:00
|
|
|
/*
|
|
|
|
* DirectPlay8 Address
|
|
|
|
*
|
|
|
|
* Copyright 2004 Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-07 22:39:00 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2006-06-10 11:57:38 +02:00
|
|
|
#define COBJMACROS
|
2004-04-07 22:39:00 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "objbase.h"
|
2014-04-11 01:02:56 +02:00
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "dpnet_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
|
|
|
|
static char *heap_strdupA( const char *str )
|
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
|
|
|
|
if (!str) return NULL;
|
|
|
|
if ((ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 ))) strcpy( ret, str );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
static BOOL add_component(IDirectPlay8AddressImpl *This, struct component *item)
|
|
|
|
{
|
|
|
|
if(This->comp_count == This->comp_array_size)
|
|
|
|
{
|
|
|
|
struct component **temp;
|
|
|
|
|
|
|
|
temp = heap_realloc(This->components, sizeof(*temp) * This->comp_array_size * 2 );
|
|
|
|
if(!temp)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->comp_array_size *= 2;
|
|
|
|
This->components = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->components[This->comp_count] = item;
|
|
|
|
This->comp_count++;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static inline IDirectPlay8AddressImpl *impl_from_IDirectPlay8Address(IDirectPlay8Address *iface)
|
2004-04-07 22:39:00 +02:00
|
|
|
{
|
2011-07-27 23:32:47 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectPlay8AddressImpl, IDirectPlay8Address_iface);
|
|
|
|
}
|
2004-04-07 22:39:00 +02:00
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
/* IDirectPlay8Address IUnknown parts follow: */
|
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(IDirectPlay8Address *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
|
2006-06-10 11:57:38 +02:00
|
|
|
IUnknown_AddRef(iface);
|
2011-07-27 23:32:47 +02:00
|
|
|
*ppv = iface;
|
2004-04-07 22:39:00 +02:00
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
|
2004-04-07 22:39:00 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(IDirectPlay8Address *iface)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2014-04-11 01:55:59 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p) ref=%lu\n", This, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2014-04-11 01:55:59 +02:00
|
|
|
return ref;
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static ULONG WINAPI IDirectPlay8AddressImpl_Release(IDirectPlay8Address *iface)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2014-04-11 01:55:59 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p) ref=%lu\n", This, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
if (!ref)
|
|
|
|
{
|
2015-03-11 06:38:59 +01:00
|
|
|
struct component *entry;
|
|
|
|
DWORD i;
|
2014-04-11 01:02:56 +02:00
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
for(i=0; i < This->comp_count; i++)
|
2014-04-11 01:02:56 +02:00
|
|
|
{
|
2015-03-11 06:38:59 +01:00
|
|
|
entry = This->components[i];
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
switch(entry->type)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_STRING:
|
|
|
|
heap_free(entry->data.string);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
heap_free(entry->data.ansi);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
|
|
|
heap_free(entry->data.binary);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-29 09:21:23 +01:00
|
|
|
heap_free(entry->name);
|
2015-03-11 06:38:59 +01:00
|
|
|
heap_free(entry);
|
2014-04-11 01:02:56 +02:00
|
|
|
}
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
heap_free(This->components);
|
|
|
|
heap_free(This);
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
2014-04-11 01:55:59 +02:00
|
|
|
return ref;
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2009-01-03 13:53:38 +01:00
|
|
|
/* returns name of given GUID */
|
|
|
|
static const char *debugstr_SP(const GUID *id) {
|
|
|
|
static const guid_info guids[] = {
|
|
|
|
/* CLSIDs */
|
|
|
|
GE(CLSID_DP8SP_IPX),
|
|
|
|
GE(CLSID_DP8SP_TCPIP),
|
|
|
|
GE(CLSID_DP8SP_SERIAL),
|
|
|
|
GE(CLSID_DP8SP_MODEM)
|
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!id) return "(null)";
|
|
|
|
|
2018-07-20 21:45:48 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(guids); i++) {
|
2009-01-03 13:53:38 +01:00
|
|
|
if (IsEqualGUID(id, guids[i].guid))
|
|
|
|
return guids[i].name;
|
|
|
|
}
|
|
|
|
/* if we didn't find it, act like standard debugstr_guid */
|
|
|
|
return debugstr_guid(id);
|
|
|
|
}
|
|
|
|
|
2004-04-07 22:39:00 +02:00
|
|
|
/* IDirectPlay8Address Interface follow: */
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(IDirectPlay8Address *iface,
|
|
|
|
WCHAR *pwszSourceURL)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address *iface,
|
|
|
|
CHAR *pszSourceURL)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p, %s): stub\n", This, pszSourceURL);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *iface,
|
|
|
|
IDirectPlay8Address **ppdpaNewAddress)
|
|
|
|
{
|
2014-05-13 04:57:47 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
IDirectPlay8Address *dup;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", This, ppdpaNewAddress);
|
|
|
|
|
|
|
|
if(!ppdpaNewAddress)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
hr = DPNET_CreateDirectPlay8Address(NULL, NULL, &IID_IDirectPlay8Address, (LPVOID*)&dup);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *DupThis = impl_from_IDirectPlay8Address(dup);
|
2015-03-11 06:38:59 +01:00
|
|
|
DWORD i;
|
2014-05-13 04:57:47 +02:00
|
|
|
|
|
|
|
DupThis->SP_guid = This->SP_guid;
|
|
|
|
DupThis->init = This->init;
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
for(i=0; i < This->comp_count; i++)
|
2014-05-13 04:57:47 +02:00
|
|
|
{
|
2015-03-11 06:38:59 +01:00
|
|
|
struct component *entry = This->components[i];
|
|
|
|
|
2015-06-11 00:55:48 +02:00
|
|
|
switch (entry->type)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
|
|
|
hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data.value, entry->size, entry->type);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data.guid, entry->size, entry->type);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
|
|
|
hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.string, entry->size, entry->type);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.ansi, entry->size, entry->type);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
|
|
|
hr = IDirectPlay8Address_AddComponent(dup, entry->name, entry->data.binary, entry->size, entry->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:57:47 +02:00
|
|
|
if(hr != S_OK)
|
2015-06-11 00:55:48 +02:00
|
|
|
{
|
2015-06-26 02:53:32 +02:00
|
|
|
IDirectPlay8Address_Release(dup);
|
|
|
|
dup = NULL;
|
2022-02-02 10:40:06 +01:00
|
|
|
ERR("Failed to copy component: %s - 0x%08lx\n", debugstr_w(entry->name), hr);
|
2015-06-11 00:55:48 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-05-13 04:57:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppdpaNewAddress = dup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface,
|
|
|
|
IDirectPlay8Address *pdpaAddress)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p, %p): stub\n", This, pdpaAddress);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(IDirectPlay8Address *iface,
|
|
|
|
IDirectPlay8Address *pdpaAddress)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p, %p): stub\n", This, pdpaAddress);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(IDirectPlay8Address *iface)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-25 10:04:59 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(IDirectPlay8Address *iface, WCHAR *url, DWORD *length)
|
2011-07-27 23:32:47 +02:00
|
|
|
{
|
2021-08-25 10:04:59 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
HRESULT hr = DPNERR_BUFFERTOOSMALL;
|
|
|
|
int i;
|
|
|
|
WCHAR buffer[1024];
|
|
|
|
int position = 0;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", This, url, length);
|
|
|
|
|
|
|
|
if(!length || (!url && *length != 0))
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
|
|
|
for(i=0; i < This->comp_count; i++)
|
|
|
|
{
|
|
|
|
struct component *entry = This->components[i];
|
|
|
|
|
|
|
|
if (position) buffer[position++] = ';';
|
|
|
|
|
|
|
|
switch(entry->type)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
position += swprintf( &buffer[position], ARRAY_SIZE(buffer) - position,
|
|
|
|
L"%s=%%7B%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X%%7D",
|
|
|
|
entry->name, entry->data.guid.Data1, entry->data.guid.Data2, entry->data.guid.Data3,
|
|
|
|
entry->data.guid.Data4[0], entry->data.guid.Data4[1], entry->data.guid.Data4[2],
|
|
|
|
entry->data.guid.Data4[3], entry->data.guid.Data4[4], entry->data.guid.Data4[5],
|
|
|
|
entry->data.guid.Data4[6], entry->data.guid.Data4[7] );
|
|
|
|
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
|
|
|
position += swprintf(&buffer[position], ARRAY_SIZE(buffer) - position, L"%s=%s", entry->name, entry->data.string);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
2022-02-02 10:40:06 +01:00
|
|
|
position += swprintf(&buffer[position], ARRAY_SIZE(buffer) - position, L"%s=%ld", entry->name, entry->data.value);
|
2021-08-25 10:04:59 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
position += swprintf(&buffer[position], ARRAY_SIZE(buffer) - position, L"%s=%hs", entry->name, entry->data.ansi);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
|
|
|
default:
|
2022-02-02 10:40:06 +01:00
|
|
|
FIXME("Unsupported type %ld\n", entry->type);
|
2021-08-25 10:04:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
buffer[position] = 0;
|
|
|
|
|
|
|
|
if(url && *length >= lstrlenW(buffer) + lstrlenW(DPNA_HEADER) + 1)
|
|
|
|
{
|
|
|
|
lstrcpyW(url, DPNA_HEADER);
|
|
|
|
lstrcatW(url, buffer);
|
|
|
|
hr = DPN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*length = lstrlenW(buffer) + lstrlenW(DPNA_HEADER) + 1;
|
|
|
|
|
|
|
|
return hr;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2021-08-25 10:04:59 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(IDirectPlay8Address *iface, char *url, DWORD *length)
|
2011-07-27 23:32:47 +02:00
|
|
|
{
|
2021-08-25 10:04:59 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR *buffer = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p, %p %p)\n", This, url, length);
|
|
|
|
|
|
|
|
if(!length || (!url && *length != 0))
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
|
|
|
if(url && *length)
|
|
|
|
buffer = heap_alloc(*length * sizeof(WCHAR));
|
|
|
|
|
|
|
|
hr = IDirectPlay8Address_GetURLW(iface, buffer, length);
|
|
|
|
if(hr == DPN_OK)
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
size = WideCharToMultiByte(CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL);
|
|
|
|
if(size <= *length)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, buffer, -1, url, *length, NULL, NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*length = size;
|
|
|
|
hr = DPNERR_BUFFERTOOSMALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
heap_free(buffer);
|
|
|
|
return hr;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(IDirectPlay8Address *iface, GUID *pguidSP)
|
|
|
|
{
|
2014-04-11 01:52:20 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2011-07-27 23:32:47 +02:00
|
|
|
|
2014-04-11 01:52:20 +02:00
|
|
|
TRACE("(%p, %p)\n", iface, pguidSP);
|
2011-07-27 23:32:47 +02:00
|
|
|
|
2014-04-11 01:52:20 +02:00
|
|
|
if(!pguidSP)
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
|
|
|
if(!This->init)
|
|
|
|
return DPNERR_DOESNOTEXIST;
|
|
|
|
|
|
|
|
*pguidSP = This->SP_guid;
|
|
|
|
return DPN_OK;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *iface,
|
|
|
|
void *pvUserData, DWORD *pdwBufferSize)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address *iface,
|
|
|
|
const GUID *const pguidSP)
|
|
|
|
{
|
2014-04-11 01:52:20 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2011-07-27 23:32:47 +02:00
|
|
|
|
2014-04-11 01:52:20 +02:00
|
|
|
TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
|
2011-07-27 23:32:47 +02:00
|
|
|
|
2014-04-11 01:52:20 +02:00
|
|
|
if(!pguidSP)
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
|
|
|
This->init = TRUE;
|
|
|
|
This->SP_guid = *pguidSP;
|
2014-09-26 05:28:53 +02:00
|
|
|
|
|
|
|
IDirectPlay8Address_AddComponent(iface, DPNA_KEY_PROVIDER, &This->SP_guid, sizeof(GUID), DPNA_DATATYPE_GUID);
|
|
|
|
|
2014-04-11 01:52:20 +02:00
|
|
|
return DPN_OK;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *iface,
|
|
|
|
const void *const pvUserData, const DWORD dwDataSize)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address *iface,
|
|
|
|
DWORD *pdwNumComponents)
|
|
|
|
{
|
2014-04-11 01:02:56 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
|
|
|
|
if(!pdwNumComponents)
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
*pdwNumComponents = This->comp_count;
|
2014-04-11 01:02:56 +02:00
|
|
|
|
|
|
|
return DPN_OK;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface,
|
|
|
|
const WCHAR *const pwszName, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType)
|
|
|
|
{
|
2014-09-29 08:11:46 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
struct component *entry;
|
2015-03-11 06:38:59 +01:00
|
|
|
DWORD i;
|
2014-09-29 08:11:46 +02:00
|
|
|
|
2016-10-13 12:07:08 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %p)\n", This, debugstr_w(pwszName), pvBuffer, pdwBufferSize, pdwDataType);
|
2014-09-29 08:11:46 +02:00
|
|
|
|
2016-10-13 12:07:08 +02:00
|
|
|
if(!pwszName || !pdwBufferSize || !pdwDataType || (!pvBuffer && *pdwBufferSize))
|
2014-09-29 08:11:46 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
for(i=0; i < This->comp_count; i++)
|
2014-09-29 08:11:46 +02:00
|
|
|
{
|
2015-03-11 06:38:59 +01:00
|
|
|
entry = This->components[i];
|
|
|
|
|
2014-09-29 08:11:46 +02:00
|
|
|
if (lstrcmpW(pwszName, entry->name) == 0)
|
|
|
|
{
|
|
|
|
TRACE("Found %s\n", debugstr_w(pwszName));
|
|
|
|
|
|
|
|
if(*pdwBufferSize < entry->size)
|
|
|
|
{
|
|
|
|
*pdwBufferSize = entry->size;
|
|
|
|
return DPNERR_BUFFERTOOSMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdwBufferSize = entry->size;
|
|
|
|
*pdwDataType = entry->type;
|
|
|
|
|
|
|
|
switch (entry->type)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
|
|
|
memcpy(pvBuffer, &entry->data.value, sizeof(DWORD));
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
memcpy(pvBuffer, &entry->data.guid, sizeof(GUID));
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
2015-03-05 23:05:56 +01:00
|
|
|
memcpy(pvBuffer, entry->data.string, entry->size);
|
2014-09-29 08:11:46 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
2015-03-05 23:05:56 +01:00
|
|
|
memcpy(pvBuffer, entry->data.ansi, entry->size);
|
2014-09-29 08:11:46 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
2015-03-05 23:05:56 +01:00
|
|
|
memcpy(pvBuffer, entry->data.binary, entry->size);
|
2014-09-29 08:11:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DPNERR_DOESNOTEXIST;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address *iface,
|
|
|
|
const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer,
|
|
|
|
DWORD *pdwBufferSize, DWORD *pdwDataType)
|
|
|
|
{
|
2014-11-27 05:57:44 +01:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
struct component *entry;
|
|
|
|
int namesize;
|
|
|
|
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p)->(%lu %p %p %p %p %p)\n", This, dwComponentID, pwszName, pdwNameLen, pvBuffer, pdwBufferSize, pdwDataType);
|
2014-11-27 05:57:44 +01:00
|
|
|
|
|
|
|
if(!pdwNameLen || !pdwBufferSize || !pdwDataType)
|
|
|
|
{
|
|
|
|
WARN("Invalid buffer (%p, %p, %p)\n", pdwNameLen, pdwBufferSize, pdwDataType);
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dwComponentID > This->comp_count)
|
|
|
|
{
|
|
|
|
WARN("dwComponentID out of range\n");
|
|
|
|
return DPNERR_DOESNOTEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = This->components[dwComponentID];
|
|
|
|
|
2019-06-03 10:32:20 +02:00
|
|
|
namesize = lstrlenW(entry->name);
|
2014-11-27 05:57:44 +01:00
|
|
|
if(*pdwBufferSize < entry->size || *pdwNameLen < namesize)
|
|
|
|
{
|
|
|
|
WARN("Buffer too small\n");
|
|
|
|
|
|
|
|
*pdwNameLen = namesize + 1;
|
|
|
|
*pdwBufferSize = entry->size;
|
|
|
|
*pdwDataType = entry->type;
|
|
|
|
return DPNERR_BUFFERTOOSMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!pwszName || !pvBuffer)
|
|
|
|
{
|
|
|
|
WARN("Invalid buffer (%p, %p)\n", pwszName, pvBuffer);
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW(pwszName, entry->name);
|
|
|
|
|
|
|
|
*pdwNameLen = namesize + 1;
|
|
|
|
*pdwBufferSize = entry->size;
|
|
|
|
*pdwDataType = entry->type;
|
|
|
|
|
|
|
|
switch (entry->type)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
|
|
|
*(DWORD*)pvBuffer = entry->data.value;
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
*(GUID*)pvBuffer = entry->data.guid;
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
|
|
|
memcpy(pvBuffer, entry->data.string, entry->size);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
memcpy(pvBuffer, entry->data.ansi, entry->size);
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
|
|
|
memcpy(pvBuffer, entry->data.binary, entry->size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *iface,
|
|
|
|
const WCHAR *const pwszName, const void* const lpvData, const DWORD dwDataSize,
|
|
|
|
const DWORD dwDataType)
|
|
|
|
{
|
2014-04-11 01:02:56 +02:00
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
|
|
|
struct component *entry;
|
|
|
|
BOOL found = FALSE;
|
2015-03-11 06:38:59 +01:00
|
|
|
DWORD i;
|
2014-04-11 01:02:56 +02:00
|
|
|
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %s, %p, %lu, %lx)\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
|
2014-04-11 01:02:56 +02:00
|
|
|
|
|
|
|
if (NULL == lpvData)
|
|
|
|
return DPNERR_INVALIDPOINTER;
|
|
|
|
|
2015-03-02 22:38:23 +01:00
|
|
|
switch (dwDataType)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
|
|
|
if (sizeof(DWORD) != dwDataSize)
|
|
|
|
{
|
|
|
|
WARN("Invalid DWORD size, returning DPNERR_INVALIDPARAM\n");
|
|
|
|
return DPNERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
if (sizeof(GUID) != dwDataSize)
|
|
|
|
{
|
|
|
|
WARN("Invalid GUID size, returning DPNERR_INVALIDPARAM\n");
|
|
|
|
return DPNERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
2019-06-03 10:32:20 +02:00
|
|
|
if (((lstrlenW((WCHAR*)lpvData)+1)*sizeof(WCHAR)) != dwDataSize)
|
2015-03-02 22:38:23 +01:00
|
|
|
{
|
|
|
|
WARN("Invalid STRING size, returning DPNERR_INVALIDPARAM\n");
|
|
|
|
return DPNERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
if ((strlen((const CHAR*)lpvData)+1) != dwDataSize)
|
|
|
|
{
|
2021-08-24 10:24:51 +02:00
|
|
|
WARN("Invalid ANSI size, returning DPNERR_INVALIDPARAM\n");
|
2015-03-02 22:38:23 +01:00
|
|
|
return DPNERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
for(i=0; i < This->comp_count; i++)
|
2014-04-11 01:02:56 +02:00
|
|
|
{
|
2015-03-11 06:38:59 +01:00
|
|
|
entry = This->components[i];
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
if (lstrcmpW(pwszName, entry->name) == 0)
|
|
|
|
{
|
|
|
|
TRACE("Found %s\n", debugstr_w(pwszName));
|
|
|
|
found = TRUE;
|
|
|
|
|
2015-03-02 22:43:55 +01:00
|
|
|
if(entry->type == DPNA_DATATYPE_STRING_ANSI)
|
2015-03-11 06:38:59 +01:00
|
|
|
heap_free(entry->data.ansi);
|
2015-03-02 22:43:55 +01:00
|
|
|
else if(entry->type == DPNA_DATATYPE_STRING)
|
|
|
|
heap_free(entry->data.string);
|
|
|
|
else if(entry->type == DPNA_DATATYPE_BINARY)
|
|
|
|
heap_free(entry->data.binary);
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!found)
|
|
|
|
{
|
|
|
|
/* Create a new one */
|
|
|
|
entry = heap_alloc(sizeof(struct component));
|
2015-03-11 06:38:59 +01:00
|
|
|
if(!entry)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
entry->name = heap_strdupW(pwszName);
|
2015-03-11 06:38:59 +01:00
|
|
|
if(!entry->name)
|
|
|
|
{
|
|
|
|
heap_free(entry);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-04-11 01:02:56 +02:00
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
if(!add_component(This, entry))
|
|
|
|
{
|
|
|
|
heap_free(entry->name);
|
|
|
|
heap_free(entry);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-04-11 01:02:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (dwDataType)
|
|
|
|
{
|
|
|
|
case DPNA_DATATYPE_DWORD:
|
|
|
|
entry->data.value = *(DWORD*)lpvData;
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %lu): DWORD Type -> %lu\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_GUID:
|
|
|
|
entry->data.guid = *(GUID*)lpvData;
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %lu): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid(lpvData));
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING:
|
|
|
|
entry->data.string = heap_strdupW((WCHAR*)lpvData);
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %lu): STRING Type -> %s\n", lpvData, dwDataSize, debugstr_w((WCHAR*)lpvData));
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_STRING_ANSI:
|
|
|
|
entry->data.ansi = heap_strdupA((CHAR*)lpvData);
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %lu): ANSI STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
case DPNA_DATATYPE_BINARY:
|
|
|
|
entry->data.binary = heap_alloc(dwDataSize);
|
|
|
|
memcpy(entry->data.binary, lpvData, dwDataSize);
|
2022-02-02 10:40:06 +01:00
|
|
|
TRACE("(%p, %lu): BINARY Type\n", lpvData, dwDataSize);
|
2014-04-11 01:02:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-03-05 09:53:03 +01:00
|
|
|
entry->type = dwDataType;
|
2014-09-29 08:11:46 +02:00
|
|
|
entry->size = dwDataSize;
|
|
|
|
|
2014-04-11 01:02:56 +02:00
|
|
|
return DPN_OK;
|
2004-04-08 06:38:26 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(IDirectPlay8Address *iface, GUID *pDevGuid) {
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(IDirectPlay8Address *iface,
|
|
|
|
const GUID *const devGuid)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-27 23:32:47 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(IDirectPlay8Address *iface,
|
|
|
|
void *pvAddress, DWORD dwDataSize)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
|
2004-04-08 06:38:26 +02:00
|
|
|
TRACE("(%p): stub\n", This);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
2004-04-07 22:39:00 +02:00
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
|
2004-04-07 22:39:00 +02:00
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl_QueryInterface,
|
|
|
|
IDirectPlay8AddressImpl_AddRef,
|
|
|
|
IDirectPlay8AddressImpl_Release,
|
|
|
|
IDirectPlay8AddressImpl_BuildFromURLW,
|
|
|
|
IDirectPlay8AddressImpl_BuildFromURLA,
|
|
|
|
IDirectPlay8AddressImpl_Duplicate,
|
|
|
|
IDirectPlay8AddressImpl_SetEqual,
|
|
|
|
IDirectPlay8AddressImpl_IsEqual,
|
|
|
|
IDirectPlay8AddressImpl_Clear,
|
|
|
|
IDirectPlay8AddressImpl_GetURLW,
|
|
|
|
IDirectPlay8AddressImpl_GetURLA,
|
|
|
|
IDirectPlay8AddressImpl_GetSP,
|
|
|
|
IDirectPlay8AddressImpl_GetUserData,
|
|
|
|
IDirectPlay8AddressImpl_SetSP,
|
|
|
|
IDirectPlay8AddressImpl_SetUserData,
|
|
|
|
IDirectPlay8AddressImpl_GetNumComponents,
|
|
|
|
IDirectPlay8AddressImpl_GetComponentByName,
|
|
|
|
IDirectPlay8AddressImpl_GetComponentByIndex,
|
|
|
|
IDirectPlay8AddressImpl_AddComponent,
|
|
|
|
IDirectPlay8AddressImpl_GetDevice,
|
|
|
|
IDirectPlay8AddressImpl_SetDevice,
|
|
|
|
IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
|
|
|
|
};
|
|
|
|
|
2014-04-11 01:55:59 +02:00
|
|
|
HRESULT DPNET_CreateDirectPlay8Address(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
IDirectPlay8AddressImpl* client;
|
|
|
|
HRESULT ret;
|
2004-04-07 22:39:00 +02:00
|
|
|
|
2014-04-11 01:55:59 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppobj);
|
|
|
|
|
2015-03-11 06:38:59 +01:00
|
|
|
*ppobj = NULL;
|
2014-04-11 01:55:59 +02:00
|
|
|
|
|
|
|
client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
|
|
|
|
if (!client)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
|
|
|
|
client->ref = 1;
|
2015-03-11 06:38:59 +01:00
|
|
|
client->comp_array_size = 4;
|
|
|
|
client->components = heap_alloc( sizeof(*client->components) * client->comp_array_size );
|
|
|
|
if(!client->components)
|
|
|
|
{
|
|
|
|
heap_free(client);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-04-11 01:02:56 +02:00
|
|
|
|
2014-04-11 01:55:59 +02:00
|
|
|
ret = IDirectPlay8AddressImpl_QueryInterface(&client->IDirectPlay8Address_iface, riid, ppobj);
|
|
|
|
IDirectPlay8AddressImpl_Release(&client->IDirectPlay8Address_iface);
|
|
|
|
|
|
|
|
return ret;
|
2004-04-07 22:39:00 +02:00
|
|
|
}
|