2002-08-03 02:17:10 +02:00
|
|
|
/*
|
|
|
|
* 16 bit ole functions
|
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis
|
|
|
|
* Copyright 1998 Justin Bradford
|
|
|
|
* Copyright 1999 Francis Beaudet
|
|
|
|
* Copyright 1999 Sylvain St-Germain
|
|
|
|
* Copyright 2002 Marcus Meissner
|
|
|
|
*
|
|
|
|
* 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
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-08-03 02:17:10 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2002-08-03 02:17:10 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "rpc.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wownt32.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
2009-03-11 17:05:20 +01:00
|
|
|
typedef LPCSTR LPCOLESTR16;
|
|
|
|
|
2016-04-14 21:01:03 +02:00
|
|
|
#define CHARS_IN_GUID 39
|
2009-03-11 17:05:20 +01:00
|
|
|
|
2020-01-15 07:24:27 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
SEGPTR QueryInterface;
|
|
|
|
SEGPTR AddRef;
|
|
|
|
SEGPTR Release;
|
|
|
|
SEGPTR Alloc;
|
|
|
|
SEGPTR Realloc;
|
|
|
|
SEGPTR Free;
|
|
|
|
SEGPTR GetSize;
|
|
|
|
SEGPTR DidAlloc;
|
|
|
|
SEGPTR HeapMinimize;
|
|
|
|
} IMalloc16Vtbl;
|
2009-03-11 17:05:20 +01:00
|
|
|
|
2020-01-15 07:24:27 +01:00
|
|
|
typedef struct
|
2009-03-11 17:05:20 +01:00
|
|
|
{
|
2020-01-15 07:24:27 +01:00
|
|
|
SEGPTR lpVtbl;
|
2020-01-15 07:24:29 +01:00
|
|
|
} IMalloc16;
|
2009-03-11 17:05:20 +01:00
|
|
|
|
2020-01-15 07:24:31 +01:00
|
|
|
static ULONG call_IMalloc_AddRef(SEGPTR iface)
|
|
|
|
{
|
|
|
|
IMalloc16 *malloc = MapSL(iface);
|
|
|
|
IMalloc16Vtbl *vtbl = MapSL(malloc->lpVtbl);
|
|
|
|
DWORD args[1], ret;
|
|
|
|
|
|
|
|
args[0] = iface;
|
|
|
|
WOWCallback16Ex(vtbl->AddRef, WCB16_CDECL, sizeof(args), args, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG call_IMalloc_Release(SEGPTR iface)
|
|
|
|
{
|
|
|
|
IMalloc16 *malloc = MapSL(iface);
|
|
|
|
IMalloc16Vtbl *vtbl = MapSL(malloc->lpVtbl);
|
|
|
|
DWORD args[1], ret;
|
|
|
|
|
|
|
|
args[0] = iface;
|
|
|
|
WOWCallback16Ex(vtbl->Release, WCB16_CDECL, sizeof(args), args, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-15 07:24:28 +01:00
|
|
|
static SEGPTR call_IMalloc_Alloc(SEGPTR iface, DWORD size)
|
|
|
|
{
|
|
|
|
IMalloc16 *malloc = MapSL(iface);
|
|
|
|
IMalloc16Vtbl *vtbl = MapSL(malloc->lpVtbl);
|
|
|
|
DWORD args[2], ret;
|
|
|
|
|
|
|
|
args[0] = iface;
|
|
|
|
args[1] = size;
|
|
|
|
WOWCallback16Ex(vtbl->Alloc, WCB16_CDECL, sizeof(args), args, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static HTASK16 hETask = 0;
|
|
|
|
static WORD Table_ETask[62];
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2020-01-15 07:24:29 +01:00
|
|
|
static SEGPTR compobj_malloc;
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
/* --- IMalloc16 implementation */
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2020-01-15 07:24:33 +01:00
|
|
|
IMalloc16 IMalloc16_iface;
|
|
|
|
LONG refcount;
|
2002-08-03 02:17:10 +02:00
|
|
|
} IMalloc16Impl;
|
|
|
|
|
2011-01-20 02:00:29 +01:00
|
|
|
static inline IMalloc16Impl *impl_from_IMalloc16(IMalloc16 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IMalloc16Impl, IMalloc16_iface);
|
|
|
|
}
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_QueryInterface [COMPOBJ.500]
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
2002-08-03 02:17:10 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
|
|
|
|
if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
|
|
|
|
!memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
|
|
|
|
) {
|
|
|
|
*obj = This;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OLE_E_ENUM_NOMORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_AddRef [COMPOBJ.501]
|
|
|
|
*/
|
2020-01-15 07:24:33 +01:00
|
|
|
ULONG CDECL IMalloc16_fnAddRef(IMalloc16 *iface)
|
|
|
|
{
|
|
|
|
IMalloc16Impl *malloc = impl_from_IMalloc16(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&malloc->refcount);
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("%p increasing refcount to %lu.\n", malloc, refcount);
|
2020-01-15 07:24:33 +01:00
|
|
|
return refcount;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_Release [COMPOBJ.502]
|
|
|
|
*/
|
2020-01-15 07:24:33 +01:00
|
|
|
ULONG CDECL IMalloc16_fnRelease(SEGPTR iface)
|
|
|
|
{
|
|
|
|
IMalloc16Impl *malloc = impl_from_IMalloc16(MapSL(iface));
|
|
|
|
ULONG refcount = InterlockedDecrement(&malloc->refcount);
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("%p decreasing refcount to %lu.\n", malloc, refcount);
|
2020-01-15 07:24:33 +01:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
UnMapLS(iface);
|
|
|
|
HeapFree(GetProcessHeap(), 0, malloc);
|
|
|
|
}
|
|
|
|
return refcount;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_Alloc [COMPOBJ.503]
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
SEGPTR CDECL IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
|
|
|
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("(%p)->Alloc(%ld)\n",This,cb);
|
2002-08-03 02:17:10 +02:00
|
|
|
return MapLS( HeapAlloc( GetProcessHeap(), 0, cb ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-11-26 04:34:51 +01:00
|
|
|
* IMalloc16_Free [COMPOBJ.505]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
VOID CDECL IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2003-11-26 04:34:51 +01:00
|
|
|
void *ptr = MapSL(pv);
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("(%p)->Free(%08lx)\n",This,pv);
|
2002-08-03 02:17:10 +02:00
|
|
|
UnMapLS(pv);
|
2003-11-26 04:34:51 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, ptr );
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-11-26 04:34:51 +01:00
|
|
|
* IMalloc16_Realloc [COMPOBJ.504]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
SEGPTR CDECL IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2003-11-26 04:34:51 +01:00
|
|
|
SEGPTR ret;
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
|
|
|
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("(%p)->Realloc(%08lx,%ld)\n",This,pv,cb);
|
2009-03-11 17:12:32 +01:00
|
|
|
if (!pv)
|
2003-11-26 04:34:51 +01:00
|
|
|
ret = IMalloc16_fnAlloc(iface, cb);
|
|
|
|
else if (cb) {
|
|
|
|
ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) );
|
|
|
|
UnMapLS(pv);
|
|
|
|
} else {
|
|
|
|
IMalloc16_fnFree(iface, pv);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
return ret;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_GetSize [COMPOBJ.506]
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
DWORD CDECL IMalloc16_fnGetSize(IMalloc16* iface,SEGPTR pv)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
|
|
|
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("(%p)->GetSize(%08lx)\n",This,pv);
|
2002-08-03 02:17:10 +02:00
|
|
|
return HeapSize( GetProcessHeap(), 0, MapSL(pv) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_DidAlloc [COMPOBJ.507]
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
INT16 CDECL IMalloc16_fnDidAlloc(IMalloc16* iface,LPVOID pv) {
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
TRACE("(%p)->DidAlloc(%p)\n",This,pv);
|
|
|
|
return (INT16)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_HeapMinimize [COMPOBJ.508]
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
LPVOID CDECL IMalloc16_fnHeapMinimize(IMalloc16* iface) {
|
2011-01-20 02:00:29 +01:00
|
|
|
IMalloc16Impl *This = impl_from_IMalloc16(iface);
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
TRACE("(%p)->HeapMinimize()\n",This);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IMalloc16_Constructor [VTABLE]
|
|
|
|
*/
|
2020-01-15 07:24:29 +01:00
|
|
|
static SEGPTR IMalloc16_Constructor(void)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
2004-08-13 01:00:51 +02:00
|
|
|
static IMalloc16Vtbl vt16;
|
2002-08-03 02:17:10 +02:00
|
|
|
static SEGPTR msegvt16;
|
|
|
|
IMalloc16Impl* This;
|
|
|
|
HMODULE16 hcomp = GetModuleHandle16("COMPOBJ");
|
|
|
|
|
|
|
|
This = HeapAlloc( GetProcessHeap(), 0, sizeof(IMalloc16Impl) );
|
|
|
|
if (!msegvt16)
|
|
|
|
{
|
2020-01-15 07:24:27 +01:00
|
|
|
#define VTENT(x) vt16.x = (SEGPTR)GetProcAddress16(hcomp,"IMalloc16_"#x);assert(vt16.x)
|
2002-08-03 02:17:10 +02:00
|
|
|
VTENT(QueryInterface);
|
|
|
|
VTENT(AddRef);
|
|
|
|
VTENT(Release);
|
|
|
|
VTENT(Alloc);
|
|
|
|
VTENT(Realloc);
|
|
|
|
VTENT(Free);
|
|
|
|
VTENT(GetSize);
|
|
|
|
VTENT(DidAlloc);
|
|
|
|
VTENT(HeapMinimize);
|
|
|
|
#undef VTENT
|
|
|
|
msegvt16 = MapLS( &vt16 );
|
|
|
|
}
|
2020-01-15 07:24:27 +01:00
|
|
|
This->IMalloc16_iface.lpVtbl = msegvt16;
|
2020-01-15 07:24:33 +01:00
|
|
|
This->refcount = 1;
|
2020-01-15 07:24:29 +01:00
|
|
|
return MapLS(This);
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CoBuildVersion [COMPOBJ.1]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CoBuildVersion16(void)
|
|
|
|
{
|
|
|
|
return CoBuildVersion();
|
|
|
|
}
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
/***********************************************************************
|
2020-01-15 07:24:29 +01:00
|
|
|
* CoGetMalloc [COMPOBJ.4]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2020-01-15 07:24:29 +01:00
|
|
|
HRESULT WINAPI CoGetMalloc16(MEMCTX context, SEGPTR *malloc)
|
|
|
|
{
|
2020-01-15 07:24:32 +01:00
|
|
|
call_IMalloc_AddRef(*malloc = compobj_malloc);
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CoCreateStandardMalloc [COMPOBJ.71]
|
|
|
|
*/
|
2020-01-15 07:24:29 +01:00
|
|
|
HRESULT WINAPI CoCreateStandardMalloc16(MEMCTX context, SEGPTR *malloc)
|
2002-08-03 02:17:10 +02:00
|
|
|
{
|
|
|
|
/* FIXME: docu says we shouldn't return the same allocator as in
|
|
|
|
* CoGetMalloc16 */
|
2020-01-15 07:24:29 +01:00
|
|
|
*malloc = IMalloc16_Constructor();
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-01-15 07:24:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CoMemAlloc [COMPOBJ.151]
|
|
|
|
*/
|
|
|
|
SEGPTR WINAPI CoMemAlloc(DWORD size, MEMCTX context, DWORD unknown)
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("size %lu, context %d, unknown %#lx.\n", size, context, unknown);
|
2020-01-15 07:24:28 +01:00
|
|
|
if (context != MEMCTX_TASK)
|
|
|
|
FIXME("Ignoring context %d.\n", context);
|
|
|
|
if (unknown)
|
2022-02-09 09:25:38 +01:00
|
|
|
FIXME("Ignoring unknown parameter %#lx.\n", unknown);
|
2020-01-15 07:24:28 +01:00
|
|
|
|
2020-01-15 07:24:30 +01:00
|
|
|
return call_IMalloc_Alloc(compobj_malloc, size);
|
2020-01-15 07:24:28 +01:00
|
|
|
}
|
|
|
|
|
2020-01-15 07:24:29 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CoInitialize [COMPOBJ.2]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2020-01-15 07:24:29 +01:00
|
|
|
HRESULT WINAPI CoInitialize16(SEGPTR malloc)
|
|
|
|
{
|
2020-01-15 07:24:30 +01:00
|
|
|
if (!malloc)
|
2020-01-15 07:24:31 +01:00
|
|
|
CoCreateStandardMalloc16(MEMCTX_TASK, &compobj_malloc);
|
|
|
|
else
|
|
|
|
call_IMalloc_AddRef(compobj_malloc = malloc);
|
2002-08-03 02:17:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CoUninitialize [COMPOBJ.3]
|
|
|
|
* Don't know what it does.
|
|
|
|
* 3-Nov-98 -- this was originally misspelled, I changed it to what I
|
|
|
|
* believe is the correct spelling
|
|
|
|
*/
|
|
|
|
void WINAPI CoUninitialize16(void)
|
|
|
|
{
|
2020-01-15 07:24:31 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
CoFreeAllLibraries();
|
|
|
|
call_IMalloc_Release(compobj_malloc);
|
|
|
|
compobj_malloc = 0;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CoFreeUnusedLibraries [COMPOBJ.17]
|
|
|
|
*/
|
|
|
|
void WINAPI CoFreeUnusedLibraries16(void)
|
|
|
|
{
|
2011-08-06 13:51:13 +02:00
|
|
|
CoFreeUnusedLibraries();
|
2009-03-11 17:12:32 +01:00
|
|
|
}
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IsEqualGUID [COMPOBJ.18]
|
|
|
|
*
|
|
|
|
* Compares two Unique Identifiers.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if equal
|
|
|
|
*/
|
|
|
|
BOOL16 WINAPI IsEqualGUID16(
|
|
|
|
GUID* g1, /* [in] unique id 1 */
|
|
|
|
GUID* g2) /* [in] unique id 2 */
|
|
|
|
{
|
|
|
|
return !memcmp( g1, g2, sizeof(GUID) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CLSIDFromString [COMPOBJ.20]
|
|
|
|
* Converts a unique identifier from its string representation into
|
|
|
|
* the GUID struct.
|
|
|
|
*
|
|
|
|
* Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* the converted GUID
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CLSIDFromString16(
|
|
|
|
LPCOLESTR16 idstr, /* [in] string representation of guid */
|
|
|
|
CLSID *id) /* [out] GUID converted from string */
|
|
|
|
{
|
2006-01-09 18:40:17 +01:00
|
|
|
const BYTE *s;
|
|
|
|
int i;
|
|
|
|
BYTE table[256];
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2006-01-09 18:40:17 +01:00
|
|
|
if (!idstr) {
|
|
|
|
memset( id, 0, sizeof (CLSID) );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* validate the CLSID string */
|
|
|
|
if (strlen(idstr) != 38)
|
|
|
|
return CO_E_CLASSSTRING;
|
|
|
|
|
|
|
|
s = (const BYTE *) idstr;
|
|
|
|
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
|
|
|
|
return CO_E_CLASSSTRING;
|
|
|
|
|
|
|
|
for (i=1; i<37; i++) {
|
|
|
|
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
|
|
|
|
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
|
|
|
|
((s[i] >= 'a') && (s[i] <= 'f')) ||
|
|
|
|
((s[i] >= 'A') && (s[i] <= 'F'))))
|
|
|
|
return CO_E_CLASSSTRING;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%s -> %p\n", s, id);
|
|
|
|
|
|
|
|
/* quick lookup table */
|
|
|
|
memset(table, 0, 256);
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
table['0' + i] = i;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
table['A' + i] = i+10;
|
|
|
|
table['a' + i] = i+10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
|
|
|
|
|
|
|
|
id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 |
|
|
|
|
table[s[5]] << 12 | table[s[6]] << 8 | table[s[7]] << 4 | table[s[8]]);
|
|
|
|
id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]];
|
|
|
|
id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]];
|
|
|
|
|
|
|
|
/* these are just sequential bytes */
|
|
|
|
id->Data4[0] = table[s[20]] << 4 | table[s[21]];
|
|
|
|
id->Data4[1] = table[s[22]] << 4 | table[s[23]];
|
|
|
|
id->Data4[2] = table[s[25]] << 4 | table[s[26]];
|
|
|
|
id->Data4[3] = table[s[27]] << 4 | table[s[28]];
|
|
|
|
id->Data4[4] = table[s[29]] << 4 | table[s[30]];
|
|
|
|
id->Data4[5] = table[s[31]] << 4 | table[s[32]];
|
|
|
|
id->Data4[6] = table[s[33]] << 4 | table[s[34]];
|
|
|
|
id->Data4[7] = table[s[35]] << 4 | table[s[36]];
|
|
|
|
|
|
|
|
return S_OK;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2020-01-15 07:24:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* StringFromCLSID [COMPOBJ.151]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2020-01-15 07:24:28 +01:00
|
|
|
HRESULT WINAPI StringFromCLSID16(REFCLSID id, SEGPTR *str)
|
2009-03-11 17:12:32 +01:00
|
|
|
{
|
|
|
|
WCHAR buffer[40];
|
2020-01-15 07:24:28 +01:00
|
|
|
if (!(*str = CoMemAlloc(40, MEMCTX_TASK, 0)))
|
|
|
|
return E_OUTOFMEMORY;
|
2009-03-11 17:12:32 +01:00
|
|
|
StringFromGUID2( id, buffer, 40 );
|
2020-01-15 07:24:28 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, buffer, -1, MapSL(*str), 40, NULL, NULL );
|
|
|
|
return S_OK;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
2020-01-15 07:24:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ProgIDFromCLSID [COMPOBJ.151]
|
2002-08-03 02:17:10 +02:00
|
|
|
*/
|
2020-01-15 07:24:28 +01:00
|
|
|
HRESULT WINAPI ProgIDFromCLSID16(REFCLSID clsid, SEGPTR *str)
|
2009-03-11 17:12:32 +01:00
|
|
|
{
|
|
|
|
LPOLESTR progid;
|
|
|
|
HRESULT ret;
|
2002-08-03 02:17:10 +02:00
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
ret = ProgIDFromCLSID( clsid, &progid );
|
2002-08-03 02:17:10 +02:00
|
|
|
if (ret == S_OK)
|
|
|
|
{
|
2009-03-11 17:12:32 +01:00
|
|
|
INT len = WideCharToMultiByte( CP_ACP, 0, progid, -1, NULL, 0, NULL, NULL );
|
2020-01-15 07:24:28 +01:00
|
|
|
if ((*str = CoMemAlloc(len, MEMCTX_TASK, 0)))
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, progid, -1, MapSL(*str), len, NULL, NULL );
|
2009-03-11 17:12:32 +01:00
|
|
|
CoTaskMemFree( progid );
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
2009-03-11 17:12:32 +01:00
|
|
|
return ret;
|
2002-08-03 02:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* LookupETask (COMPOBJ.94)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) {
|
|
|
|
FIXME("(%p,%p),stub!\n",hTask,p);
|
|
|
|
if ((*hTask = GetCurrentTask()) == hETask) {
|
|
|
|
memcpy(p, Table_ETask, sizeof(Table_ETask));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetETask (COMPOBJ.95)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) {
|
|
|
|
FIXME("(%04x,%p),stub!\n",hTask,p);
|
|
|
|
hETask = hTask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CALLOBJECTINWOW (COMPOBJ.201)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
|
|
|
|
FIXME("(%p,%p),stub!\n",p1,p2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CoRegisterClassObject [COMPOBJ.5]
|
|
|
|
*
|
|
|
|
* Don't know where it registers it ...
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoRegisterClassObject16(
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPUNKNOWN pUnk,
|
|
|
|
DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
|
|
|
|
DWORD flags, /* [in] REGCLS flags indicating how connections are made */
|
|
|
|
LPDWORD lpdwRegister
|
|
|
|
) {
|
2022-02-09 09:25:38 +01:00
|
|
|
FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
|
2005-06-20 15:14:22 +02:00
|
|
|
debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister
|
2002-08-03 02:17:10 +02:00
|
|
|
);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CoRevokeClassObject [COMPOBJ.6]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoRevokeClassObject16(DWORD dwRegister) /* [in] token on class obj */
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
FIXME("(0x%08lx),stub!\n", dwRegister);
|
2002-08-03 02:17:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-11 17:05:20 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IsValidInterface [COMPOBJ.23]
|
|
|
|
*
|
|
|
|
* Determines whether a pointer is a valid interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* punk [I] Interface to be tested.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE, if the passed pointer is a valid interface, or FALSE otherwise.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsValidInterface16(SEGPTR punk)
|
|
|
|
{
|
|
|
|
DWORD **ptr;
|
|
|
|
|
|
|
|
if (IsBadReadPtr16(punk,4))
|
|
|
|
return FALSE;
|
|
|
|
ptr = MapSL(punk);
|
|
|
|
if (IsBadReadPtr16((SEGPTR)ptr[0],4)) /* check vtable ptr */
|
|
|
|
return FALSE;
|
|
|
|
ptr = MapSL((SEGPTR)ptr[0]); /* ptr to first method */
|
|
|
|
if (IsBadReadPtr16((SEGPTR)ptr[0],2))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CoFileTimeToDosDateTime [COMPOBJ.30]
|
|
|
|
*/
|
|
|
|
BOOL16 WINAPI CoFileTimeToDosDateTime16(const FILETIME *ft, LPWORD lpDosDate, LPWORD lpDosTime)
|
|
|
|
{
|
|
|
|
return FileTimeToDosDateTime(ft, lpDosDate, lpDosTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CoDosDateTimeToFileTime [COMPOBJ.31]
|
|
|
|
*/
|
|
|
|
BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft)
|
|
|
|
{
|
|
|
|
return DosDateTimeToFileTime(wDosDate, wDosTime, ft);
|
|
|
|
}
|
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CoGetCurrentProcess [COMPOBJ.34]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CoGetCurrentProcess16(void)
|
|
|
|
{
|
|
|
|
return CoGetCurrentProcess();
|
|
|
|
}
|
|
|
|
|
2002-08-03 02:17:10 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CoRegisterMessageFilter [COMPOBJ.27]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoRegisterMessageFilter16(
|
|
|
|
LPMESSAGEFILTER lpMessageFilter,
|
|
|
|
LPMESSAGEFILTER *lplpMessageFilter
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CoLockObjectExternal [COMPOBJ.63]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoLockObjectExternal16(
|
|
|
|
LPUNKNOWN pUnk, /* [in] object to be locked */
|
|
|
|
BOOL16 fLock, /* [in] do lock */
|
|
|
|
BOOL16 fLastUnlockReleases /* [in] ? */
|
|
|
|
) {
|
|
|
|
FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CoGetState [COMPOBJ.115]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoGetState16(LPDWORD state)
|
|
|
|
{
|
|
|
|
FIXME("(%p),stub!\n", state);
|
|
|
|
|
|
|
|
*state = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllEntryPoint [COMPOBJ.116]
|
|
|
|
*
|
|
|
|
* Initialization code for the COMPOBJ DLL
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*/
|
|
|
|
BOOL WINAPI COMPOBJ_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD HeapSize, DWORD res1, WORD res2)
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
TRACE("(%08lx, %04x, %04x, %04x, %08lx, %04x)\n", Reason, hInst, ds, HeapSize, res1, res2);
|
2002-08-03 02:17:10 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-07-24 18:15:24 +02:00
|
|
|
|
2005-09-25 17:17:10 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CLSIDFromProgID [COMPOBJ.61]
|
|
|
|
*
|
|
|
|
* Converts a program ID into the respective GUID.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* progid [I] program id as found in registry
|
|
|
|
* riid [O] associated CLSID
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: CO_E_CLASSSTRING - the given ProgID cannot be found.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid)
|
|
|
|
{
|
|
|
|
char *buf,buf2[80];
|
|
|
|
LONG buf2len;
|
|
|
|
HKEY xhkey;
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
|
|
|
|
sprintf(buf,"%s\\CLSID",progid);
|
2014-11-01 02:44:39 +01:00
|
|
|
if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey)) {
|
2005-09-25 17:17:10 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,buf);
|
|
|
|
return CO_E_CLASSSTRING;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(),0,buf);
|
|
|
|
buf2len = sizeof(buf2);
|
2014-11-01 02:44:39 +01:00
|
|
|
if (RegQueryValueA(xhkey,NULL,buf2,&buf2len)) {
|
2005-09-25 17:17:10 +02:00
|
|
|
RegCloseKey(xhkey);
|
|
|
|
return CO_E_CLASSSTRING;
|
|
|
|
}
|
|
|
|
RegCloseKey(xhkey);
|
2006-01-09 18:40:17 +01:00
|
|
|
return CLSIDFromString16(buf2,riid);
|
2005-09-25 17:17:10 +02:00
|
|
|
}
|
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* StringFromGUID2 [COMPOBJ.76]
|
|
|
|
*/
|
2020-01-15 07:24:28 +01:00
|
|
|
INT16 WINAPI StringFromGUID216(REFGUID id, char *str, INT16 cmax)
|
2009-03-11 17:12:32 +01:00
|
|
|
{
|
2022-01-31 14:13:15 +01:00
|
|
|
static const char format[] = "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}";
|
2016-04-14 21:01:03 +02:00
|
|
|
if (!id || cmax < CHARS_IN_GUID) return 0;
|
|
|
|
sprintf( str, format, id->Data1, id->Data2, id->Data3,
|
|
|
|
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
|
|
|
|
id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
|
|
|
|
return CHARS_IN_GUID;
|
2009-03-11 17:12:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CoFileTimeNow [COMPOBJ.82]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoFileTimeNow16( FILETIME *lpFileTime )
|
|
|
|
{
|
|
|
|
return CoFileTimeNow( lpFileTime );
|
|
|
|
}
|
|
|
|
|
2005-09-25 17:17:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CoGetClassObject [COMPOBJ.7]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoGetClassObject16(
|
2017-02-17 23:32:12 +01:00
|
|
|
SEGPTR rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
|
|
|
|
SEGPTR riid, SEGPTR ppv)
|
2005-09-25 17:17:10 +02:00
|
|
|
{
|
2017-02-17 23:32:12 +01:00
|
|
|
LPVOID *ppvl = MapSL(ppv);
|
|
|
|
|
|
|
|
TRACE("CLSID: %s, IID: %s\n", debugstr_guid(MapSL(rclsid)), debugstr_guid(MapSL(riid)));
|
|
|
|
|
|
|
|
*ppvl = NULL;
|
2005-09-25 17:17:10 +02:00
|
|
|
|
|
|
|
if (pServerInfo) {
|
2017-02-17 23:32:12 +01:00
|
|
|
FIXME("pServerInfo->name=%s pAuthInfo=%p\n",
|
|
|
|
debugstr_w(pServerInfo->pwszName), pServerInfo->pAuthInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CLSCTX_INPROC_SERVER & dwClsContext)
|
|
|
|
{
|
|
|
|
char idstr[CHARS_IN_GUID];
|
|
|
|
char buf_key[CHARS_IN_GUID+19], dllpath[MAX_PATH+1];
|
|
|
|
LONG dllpath_len = sizeof(dllpath);
|
|
|
|
|
|
|
|
HMODULE16 dll;
|
|
|
|
FARPROC16 DllGetClassObject;
|
|
|
|
|
|
|
|
WORD args[6];
|
|
|
|
DWORD dwRet;
|
|
|
|
|
|
|
|
StringFromGUID216(MapSL(rclsid), idstr, CHARS_IN_GUID);
|
|
|
|
sprintf(buf_key, "CLSID\\%s\\InprocServer", idstr);
|
|
|
|
if (RegQueryValueA(HKEY_CLASSES_ROOT, buf_key, dllpath, &dllpath_len))
|
|
|
|
{
|
|
|
|
ERR("class %s not registered\n", debugstr_guid(MapSL(rclsid)));
|
|
|
|
return REGDB_E_CLASSNOTREG;
|
|
|
|
}
|
|
|
|
|
|
|
|
dll = LoadLibrary16(dllpath);
|
|
|
|
if (!dll)
|
|
|
|
{
|
|
|
|
ERR("couldn't load in-process dll %s\n", debugstr_a(dllpath));
|
|
|
|
return E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */
|
|
|
|
}
|
|
|
|
|
|
|
|
DllGetClassObject = GetProcAddress16(dll, "DllGetClassObject");
|
|
|
|
if (!DllGetClassObject)
|
|
|
|
{
|
|
|
|
ERR("couldn't find function DllGetClassObject in %s\n", debugstr_a(dllpath));
|
|
|
|
FreeLibrary16(dll);
|
|
|
|
return CO_E_DLLNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("calling DllGetClassObject %p\n", DllGetClassObject);
|
|
|
|
args[5] = SELECTOROF(rclsid);
|
|
|
|
args[4] = OFFSETOF(rclsid);
|
|
|
|
args[3] = SELECTOROF(riid);
|
|
|
|
args[2] = OFFSETOF(riid);
|
|
|
|
args[1] = SELECTOROF(ppv);
|
|
|
|
args[0] = OFFSETOF(ppv);
|
|
|
|
WOWCallback16Ex((DWORD) DllGetClassObject, WCB16_PASCAL, sizeof(args), args, &dwRet);
|
|
|
|
if (dwRet != S_OK)
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
ERR("DllGetClassObject returned error 0x%08lx\n", dwRet);
|
2017-02-17 23:32:12 +01:00
|
|
|
FreeLibrary16(dll);
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-09-25 17:17:10 +02:00
|
|
|
}
|
2017-02-17 23:32:12 +01:00
|
|
|
|
|
|
|
FIXME("semi-stub\n");
|
2005-09-25 17:17:10 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-11 17:12:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CoCreateGuid [COMPOBJ.73]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoCreateGuid16(GUID *pguid)
|
|
|
|
{
|
|
|
|
return CoCreateGuid( pguid );
|
|
|
|
}
|
|
|
|
|
2005-09-25 17:17:10 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CoCreateInstance [COMPOBJ.13]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoCreateInstance16(
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
DWORD dwClsContext,
|
|
|
|
REFIID iid,
|
|
|
|
LPVOID *ppv)
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
FIXME("(%s, %p, %lx, %s, %p), stub!\n",
|
2005-09-25 17:17:10 +02:00
|
|
|
debugstr_guid(rclsid), pUnkOuter, dwClsContext, debugstr_guid(iid),
|
|
|
|
ppv
|
|
|
|
);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-03-21 13:37:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CoDisconnectObject [COMPOBJ.15]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CoDisconnectObject16( LPUNKNOWN lpUnk, DWORD reserved )
|
|
|
|
{
|
2022-02-09 09:25:38 +01:00
|
|
|
FIXME("(%p, 0x%08lx): stub!\n", lpUnk, reserved);
|
2007-03-21 13:37:08 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|