1999-09-10 15:52:12 +02:00
|
|
|
/*
|
|
|
|
* OLEAUT32
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 1999, 2000 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-09-10 15:52:12 +02:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-09-10 15:52:12 +02:00
|
|
|
#include <string.h>
|
2000-12-19 05:53:20 +01:00
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-09-10 15:52:12 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
2000-08-03 06:22:35 +02:00
|
|
|
|
2000-12-06 02:50:47 +01:00
|
|
|
#include "ole2.h"
|
2001-07-24 02:59:28 +02:00
|
|
|
#include "olectl.h"
|
2002-12-12 23:24:45 +01:00
|
|
|
#include "oleauto.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
|
|
|
#include "tmarshal.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-09-10 15:52:12 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
2000-01-23 04:15:25 +01:00
|
|
|
|
2003-01-05 21:32:30 +01:00
|
|
|
/* The OLE Automation ProxyStub Interface Class (aka Typelib Marshaler) */
|
|
|
|
extern const GUID CLSID_PSOAInterface;
|
|
|
|
|
2003-05-20 06:13:58 +02:00
|
|
|
/* IDispatch marshaler */
|
|
|
|
extern const GUID CLSID_PSDispatch;
|
|
|
|
|
2003-09-24 07:12:52 +02:00
|
|
|
static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */
|
|
|
|
|
2003-10-15 22:50:24 +02:00
|
|
|
HMODULE OLEAUT32_hModule = NULL;
|
|
|
|
|
2003-09-24 07:12:52 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BSTR {OLEAUT32}
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* BSTR is a simple typedef for a wide-character string used as the principle
|
|
|
|
* string type in ole automation. When encapsulated in a Variant type they are
|
|
|
|
* automatically copied and destroyed as the variant is processed.
|
|
|
|
*
|
|
|
|
* The low level BSTR Api allows manipulation of these strings and is used by
|
|
|
|
* higher level Api calls to manage the strings transparently to the caller.
|
|
|
|
*
|
|
|
|
* Internally the BSTR type is allocated with space for a DWORD byte count before
|
|
|
|
* the string data begins. This is undocumented and non-system code should not
|
|
|
|
* access the count directly. Use SysStringLen() or SysStringByteLen()
|
|
|
|
* instead. Note that the byte count does not include the terminating NUL.
|
|
|
|
*
|
|
|
|
* To create a new BSTR, use SysAllocString(), SysAllocStringLen() or
|
|
|
|
* SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString()
|
|
|
|
* or SysReAllocStringLen(). Finally to destroy a string use SysFreeString().
|
|
|
|
*
|
|
|
|
* BSTR's are cached by Ole Automation by default. To override this behaviour
|
|
|
|
* either set the environment variable 'OANOCACHE', or call SetOaNoCache().
|
|
|
|
*
|
|
|
|
* SEE ALSO
|
|
|
|
* 'Inside OLE, second edition' by Kraig Brockshmidt.
|
|
|
|
*/
|
|
|
|
|
2002-12-12 23:24:45 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* SysStringLen [OLEAUT32.7]
|
|
|
|
*
|
2003-09-24 07:12:52 +02:00
|
|
|
* Get the allocated length of a BSTR in wide characters.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] BSTR to find the length of
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The allocated length of str, or 0 if str is NULL.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR.
|
|
|
|
* The returned length may be different from the length of the string as
|
|
|
|
* calculated by lstrlenW(), since it returns the length that was used to
|
|
|
|
* allocate the string by SysAllocStringLen().
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
|
|
|
int WINAPI SysStringLen(BSTR str)
|
|
|
|
{
|
|
|
|
DWORD* bufferPointer;
|
|
|
|
|
|
|
|
if (!str) return 0;
|
|
|
|
/*
|
|
|
|
* The length of the string (in bytes) is contained in a DWORD placed
|
|
|
|
* just before the BSTR pointer
|
|
|
|
*/
|
|
|
|
bufferPointer = (DWORD*)str;
|
|
|
|
|
|
|
|
bufferPointer--;
|
|
|
|
|
|
|
|
return (int)(*bufferPointer/sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysStringByteLen [OLEAUT32.149]
|
|
|
|
*
|
2003-09-24 07:12:52 +02:00
|
|
|
* Get the allocated length of a BSTR in bytes.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] BSTR to find the length of
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The allocated length of str, or 0 if str is NULL.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See SysStringLen(), BSTR().
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
|
|
|
int WINAPI SysStringByteLen(BSTR str)
|
|
|
|
{
|
|
|
|
DWORD* bufferPointer;
|
|
|
|
|
|
|
|
if (!str) return 0;
|
|
|
|
/*
|
|
|
|
* The length of the string (in bytes) is contained in a DWORD placed
|
|
|
|
* just before the BSTR pointer
|
|
|
|
*/
|
|
|
|
bufferPointer = (DWORD*)str;
|
|
|
|
|
|
|
|
bufferPointer--;
|
|
|
|
|
|
|
|
return (int)(*bufferPointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysAllocString [OLEAUT32.2]
|
|
|
|
*
|
2003-09-24 07:12:52 +02:00
|
|
|
* Create a BSTR from an OLESTR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] Source to create BSTR from
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A BSTR allocated with SysAllocStringLen().
|
|
|
|
* Failure: NULL, if oleStr is NULL.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR.
|
|
|
|
* MSDN (October 2001) incorrectly states that NULL is returned if oleStr has
|
|
|
|
* a length of 0. Native Win32 and this implementation both return a valid
|
|
|
|
* empty BSTR in this case.
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
BSTR WINAPI SysAllocString(LPCOLESTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2003-09-24 07:12:52 +02:00
|
|
|
if (!str) return 0;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
/* Delegate this to the SysAllocStringLen32 method. */
|
2003-09-24 07:12:52 +02:00
|
|
|
return SysAllocStringLen(str, lstrlenW(str));
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysFreeString [OLEAUT32.6]
|
2003-09-24 07:12:52 +02:00
|
|
|
*
|
|
|
|
* Free a BSTR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] BSTR to free.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR.
|
|
|
|
* str may be NULL, in which case this function does nothing.
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
void WINAPI SysFreeString(BSTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
|
|
|
DWORD* bufferPointer;
|
|
|
|
|
|
|
|
/* NULL is a valid parameter */
|
2003-09-24 07:12:52 +02:00
|
|
|
if(!str) return;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to be careful when we free a BSTR pointer, it points to
|
|
|
|
* the beginning of the string but it skips the byte count contained
|
|
|
|
* before the string.
|
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
bufferPointer = (DWORD*)str;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
bufferPointer--;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the memory from its "real" origin.
|
|
|
|
*/
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferPointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysAllocStringLen [OLEAUT32.4]
|
|
|
|
*
|
2003-09-24 07:12:52 +02:00
|
|
|
* Create a BSTR from an OLESTR of a given wide character length.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] Source to create BSTR from
|
|
|
|
* len [I] Length of oleStr in wide characters
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A newly allocated BSTR from SysAllocStringByteLen()
|
|
|
|
* Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR(), SysAllocStringByteLen().
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
|
|
|
DWORD bufferSize;
|
|
|
|
DWORD* newBuffer;
|
|
|
|
WCHAR* stringBuffer;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the length of the buffer passed-in in bytes.
|
|
|
|
*/
|
|
|
|
bufferSize = len * sizeof (WCHAR);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a new buffer to hold the string.
|
2004-01-06 23:08:33 +01:00
|
|
|
* don't forget to keep an empty spot at the beginning of the
|
2002-12-12 23:24:45 +01:00
|
|
|
* buffer for the character count and an extra character at the
|
|
|
|
* end for the NULL.
|
|
|
|
*/
|
|
|
|
newBuffer = (DWORD*)HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
bufferSize + sizeof(WCHAR) + sizeof(DWORD));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the memory allocation failed, return a null pointer.
|
|
|
|
*/
|
|
|
|
if (newBuffer==0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the length of the string in the placeholder.
|
|
|
|
*/
|
|
|
|
*newBuffer = bufferSize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip the byte count.
|
|
|
|
*/
|
|
|
|
newBuffer++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the information in the buffer.
|
|
|
|
* Since it is valid to pass a NULL pointer here, we'll initialize the
|
|
|
|
* buffer to nul if it is the case.
|
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
if (str != 0)
|
|
|
|
memcpy(newBuffer, str, bufferSize);
|
2002-12-12 23:24:45 +01:00
|
|
|
else
|
|
|
|
memset(newBuffer, 0, bufferSize);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that there is a nul character at the end of the
|
|
|
|
* string.
|
|
|
|
*/
|
|
|
|
stringBuffer = (WCHAR*)newBuffer;
|
|
|
|
stringBuffer[len] = L'\0';
|
|
|
|
|
|
|
|
return (LPWSTR)stringBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysReAllocStringLen [OLEAUT32.5]
|
2003-09-24 07:12:52 +02:00
|
|
|
*
|
|
|
|
* Change the length of a previously created BSTR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* old [O] BSTR to change the length of
|
|
|
|
* str [I] New source for pbstr
|
|
|
|
* len [I] Length of oleStr in wide characters
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 1. The size of pbstr is updated.
|
|
|
|
* Failure: 0, if len >= 0x80000000 or memory allocation fails.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR(), SysAllocStringByteLen().
|
|
|
|
* *pbstr may be changed by this function.
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2003-01-28 01:30:29 +01:00
|
|
|
if (*old!=NULL) {
|
|
|
|
DWORD newbytelen = len*sizeof(WCHAR);
|
|
|
|
DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
|
|
|
|
*old = (BSTR)(ptr+1);
|
|
|
|
*ptr = newbytelen;
|
2003-09-24 07:12:52 +02:00
|
|
|
if (str) {
|
|
|
|
memcpy(*old, str, newbytelen);
|
2003-01-28 01:30:29 +01:00
|
|
|
(*old)[len] = 0;
|
|
|
|
} else {
|
|
|
|
/* Subtle hidden feature: The old string data is still there
|
2003-09-24 07:12:52 +02:00
|
|
|
* when 'in' is NULL!
|
2003-01-28 01:30:29 +01:00
|
|
|
* Some Microsoft program needs it.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Allocate the new string
|
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
*old = SysAllocStringLen(str, len);
|
2003-01-28 01:30:29 +01:00
|
|
|
}
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysAllocStringByteLen [OLEAUT32.150]
|
|
|
|
*
|
2003-09-24 07:12:52 +02:00
|
|
|
* Create a BSTR from an OLESTR of a given byte length.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I] Source to create BSTR from
|
|
|
|
* len [I] Length of oleStr in bytes
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A newly allocated BSTR
|
|
|
|
* Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* -If len is 0 or oleStr is NULL the resulting string is empty ("").
|
|
|
|
* -This function always NUL terminates the resulting BSTR.
|
|
|
|
* -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied
|
|
|
|
* without checking for a terminating NUL.
|
|
|
|
* See BSTR.
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
|
|
|
DWORD* newBuffer;
|
|
|
|
char* stringBuffer;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a new buffer to hold the string.
|
2004-01-06 23:08:33 +01:00
|
|
|
* don't forget to keep an empty spot at the beginning of the
|
2002-12-12 23:24:45 +01:00
|
|
|
* buffer for the character count and an extra character at the
|
|
|
|
* end for the NULL.
|
|
|
|
*/
|
|
|
|
newBuffer = (DWORD*)HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
len + sizeof(WCHAR) + sizeof(DWORD));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the memory allocation failed, return a null pointer.
|
|
|
|
*/
|
|
|
|
if (newBuffer==0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the length of the string in the placeholder.
|
|
|
|
*/
|
|
|
|
*newBuffer = len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip the byte count.
|
|
|
|
*/
|
|
|
|
newBuffer++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the information in the buffer.
|
|
|
|
* Since it is valid to pass a NULL pointer here, we'll initialize the
|
|
|
|
* buffer to nul if it is the case.
|
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
if (str != 0)
|
|
|
|
memcpy(newBuffer, str, len);
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that there is a nul character at the end of the
|
|
|
|
* string.
|
|
|
|
*/
|
|
|
|
stringBuffer = (char *)newBuffer;
|
|
|
|
stringBuffer[len] = 0;
|
|
|
|
stringBuffer[len+1] = 0;
|
|
|
|
|
|
|
|
return (LPWSTR)stringBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysReAllocString [OLEAUT32.3]
|
2003-09-24 07:12:52 +02:00
|
|
|
*
|
|
|
|
* Change the length of a previously created BSTR.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* old [I/O] BSTR to change the length of
|
|
|
|
* str [I] New source for pbstr
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: 1
|
|
|
|
* Failure: 0.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR(), SysAllocStringStringLen().
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (old==NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we free the old string.
|
|
|
|
*/
|
|
|
|
if (*old!=NULL)
|
|
|
|
SysFreeString(*old);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the new string
|
|
|
|
*/
|
2003-09-24 07:12:52 +02:00
|
|
|
*old = SysAllocString(str);
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-09-24 07:12:52 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetOaNoCache (OLEAUT32.327)
|
|
|
|
*
|
|
|
|
* Instruct Ole Automation not to cache BSTR allocations.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See BSTR.
|
|
|
|
*/
|
|
|
|
void WINAPI SetOaNoCache(void)
|
|
|
|
{
|
|
|
|
BSTR_bCache = FALSE;
|
|
|
|
}
|
|
|
|
|
2000-01-23 04:15:25 +01:00
|
|
|
static WCHAR _delimiter[2] = {'!',0}; /* default delimiter apparently */
|
|
|
|
static WCHAR *pdelimiter = &_delimiter[0];
|
1999-09-10 15:52:12 +02:00
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RegisterActiveObject (OLEAUT32.33)
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
1999-10-13 14:19:09 +02:00
|
|
|
HRESULT WINAPI RegisterActiveObject(
|
|
|
|
LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
|
|
|
|
) {
|
2000-01-23 04:15:25 +01:00
|
|
|
WCHAR guidbuf[80];
|
|
|
|
HRESULT ret;
|
|
|
|
LPRUNNINGOBJECTTABLE runobtable;
|
|
|
|
LPMONIKER moniker;
|
|
|
|
|
|
|
|
StringFromGUID2(rcid,guidbuf,39);
|
|
|
|
ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (FAILED(ret))
|
2000-01-23 04:15:25 +01:00
|
|
|
return ret;
|
|
|
|
ret = GetRunningObjectTable(0,&runobtable);
|
|
|
|
if (FAILED(ret)) {
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister);
|
|
|
|
IRunningObjectTable_Release(runobtable);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
return ret;
|
1999-10-13 14:19:09 +02:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RevokeActiveObject (OLEAUT32.34)
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
1999-10-13 14:19:09 +02:00
|
|
|
HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved)
|
1999-09-10 15:52:12 +02:00
|
|
|
{
|
2000-01-23 04:15:25 +01:00
|
|
|
LPRUNNINGOBJECTTABLE runobtable;
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
ret = GetRunningObjectTable(0,&runobtable);
|
|
|
|
if (FAILED(ret)) return ret;
|
|
|
|
ret = IRunningObjectTable_Revoke(runobtable,xregister);
|
|
|
|
if (SUCCEEDED(ret)) ret = S_OK;
|
|
|
|
IRunningObjectTable_Release(runobtable);
|
|
|
|
return ret;
|
1999-10-13 14:19:09 +02:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* GetActiveObject (OLEAUT32.35)
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
1999-10-13 14:19:09 +02:00
|
|
|
HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
|
|
|
|
{
|
2000-01-23 04:15:25 +01:00
|
|
|
WCHAR guidbuf[80];
|
|
|
|
HRESULT ret;
|
|
|
|
LPRUNNINGOBJECTTABLE runobtable;
|
|
|
|
LPMONIKER moniker;
|
|
|
|
|
|
|
|
StringFromGUID2(rcid,guidbuf,39);
|
|
|
|
ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (FAILED(ret))
|
2000-01-23 04:15:25 +01:00
|
|
|
return ret;
|
|
|
|
ret = GetRunningObjectTable(0,&runobtable);
|
|
|
|
if (FAILED(ret)) {
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
|
|
|
|
IRunningObjectTable_Release(runobtable);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
return ret;
|
1999-09-10 15:52:12 +02:00
|
|
|
}
|
1999-12-06 00:52:56 +01:00
|
|
|
|
2001-10-02 20:28:31 +02:00
|
|
|
|
1999-12-06 00:52:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* OaBuildVersion [OLEAUT32.170]
|
|
|
|
*
|
2003-10-11 01:33:59 +02:00
|
|
|
* Get the Ole Automation build version.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The build version.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Known oleaut32.dll versions:
|
|
|
|
*| OLE Ver. Comments Date Build Ver.
|
|
|
|
*| -------- ------------------------- ---- ---------
|
|
|
|
*| OLE 2.1 NT 1993-95 10 3023
|
|
|
|
*| OLE 2.1 10 3027
|
|
|
|
*| Win32s Ver 1.1e 20 4049
|
|
|
|
*| OLE 2.20 W95/NT 1993-96 20 4112
|
|
|
|
*| OLE 2.20 W95/NT 1993-96 20 4118
|
|
|
|
*| OLE 2.20 W95/NT 1993-96 20 4122
|
|
|
|
*| OLE 2.30 W95/NT 1993-98 30 4265
|
|
|
|
*| OLE 2.40 NT?? 1993-98 40 4267
|
|
|
|
*| OLE 2.40 W98 SE orig. file 1993-98 40 4275
|
|
|
|
*| OLE 2.40 W2K orig. file 1993-XX 40 4514
|
|
|
|
*
|
|
|
|
* Currently the versions returned are 2.20 for Win3.1, 2.30 for Win95 & NT 3.51,
|
|
|
|
* and 2.40 for all later versions. The build number is maximum, i.e. 0xffff.
|
1999-12-06 00:52:56 +01:00
|
|
|
*/
|
2003-11-14 22:01:15 +01:00
|
|
|
ULONG WINAPI OaBuildVersion()
|
1999-12-06 00:52:56 +01:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
switch(GetVersion() & 0x8000ffff) /* mask off build number */
|
1999-12-06 00:52:56 +01:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
case 0x80000a03: /* WIN31 */
|
2001-10-02 20:28:31 +02:00
|
|
|
return MAKELONG(0xffff, 20);
|
2000-08-14 16:35:01 +02:00
|
|
|
case 0x00003303: /* NT351 */
|
2001-10-02 20:28:31 +02:00
|
|
|
return MAKELONG(0xffff, 30);
|
|
|
|
case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor
|
|
|
|
version here (30), but as we still use w95
|
|
|
|
as default winver (which is good IMHO), I better
|
|
|
|
play safe and use the latest value for w95 for now.
|
|
|
|
Change this as soon as default winver gets changed
|
|
|
|
to something more recent */
|
|
|
|
case 0x80000a04: /* WIN98 */
|
2000-08-14 16:35:01 +02:00
|
|
|
case 0x00000004: /* NT40 */
|
2001-10-02 20:28:31 +02:00
|
|
|
case 0x00000005: /* W2K */
|
|
|
|
return MAKELONG(0xffff, 40);
|
2000-08-14 16:35:01 +02:00
|
|
|
default:
|
1999-12-06 00:52:56 +01:00
|
|
|
ERR("Version value not known yet. Please investigate it !\n");
|
|
|
|
return 0x0;
|
|
|
|
}
|
|
|
|
}
|
2000-03-26 15:36:40 +02:00
|
|
|
|
2002-12-12 23:24:45 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* OleTranslateColor [OLEAUT32.421]
|
|
|
|
*
|
2003-10-11 01:33:59 +02:00
|
|
|
* Convert an OLE_COLOR to a COLORREF.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* clr [I] Color to convert
|
|
|
|
* hpal [I] Handle to a palette for the conversion
|
|
|
|
* pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* Document the conversion rules.
|
2002-12-12 23:24:45 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI OleTranslateColor(
|
|
|
|
OLE_COLOR clr,
|
|
|
|
HPALETTE hpal,
|
|
|
|
COLORREF* pColorRef)
|
|
|
|
{
|
|
|
|
COLORREF colorref;
|
|
|
|
BYTE b = HIBYTE(HIWORD(clr));
|
|
|
|
|
|
|
|
TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In case pColorRef is NULL, provide our own to simplify the code.
|
|
|
|
*/
|
|
|
|
if (pColorRef == NULL)
|
|
|
|
pColorRef = &colorref;
|
|
|
|
|
|
|
|
switch (b)
|
|
|
|
{
|
|
|
|
case 0x00:
|
|
|
|
{
|
|
|
|
if (hpal != 0)
|
|
|
|
*pColorRef = PALETTERGB(GetRValue(clr),
|
|
|
|
GetGValue(clr),
|
|
|
|
GetBValue(clr));
|
|
|
|
else
|
|
|
|
*pColorRef = clr;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x01:
|
|
|
|
{
|
|
|
|
if (hpal != 0)
|
|
|
|
{
|
|
|
|
PALETTEENTRY pe;
|
|
|
|
/*
|
|
|
|
* Validate the palette index.
|
|
|
|
*/
|
|
|
|
if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pColorRef = clr;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x02:
|
|
|
|
*pColorRef = clr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x80:
|
|
|
|
{
|
|
|
|
int index = LOBYTE(LOWORD(clr));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate GetSysColor index.
|
|
|
|
*/
|
|
|
|
if ((index < COLOR_SCROLLBAR) || (index > COLOR_GRADIENTINACTIVECAPTION))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pColorRef = GetSysColor(index);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-20 06:13:58 +02:00
|
|
|
extern HRESULT OLEAUTPS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
|
|
|
|
|
2001-07-24 02:59:28 +02:00
|
|
|
extern void _get_STDFONT_CF(LPVOID);
|
2003-01-02 18:54:57 +01:00
|
|
|
extern void _get_STDPIC_CF(LPVOID);
|
2001-07-24 02:59:28 +02:00
|
|
|
|
2001-07-26 23:44:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (OLEAUT32.1)
|
|
|
|
*/
|
2003-05-20 06:13:58 +02:00
|
|
|
HRESULT WINAPI OLEAUT32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
|
2001-07-24 02:59:28 +02:00
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualGUID(rclsid,&CLSID_StdFont)) {
|
|
|
|
if (IsEqualGUID(iid,&IID_IClassFactory)) {
|
|
|
|
_get_STDFONT_CF(ppv);
|
|
|
|
IClassFactory_AddRef((IClassFactory*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-01-02 18:54:57 +01:00
|
|
|
if (IsEqualGUID(rclsid,&CLSID_StdPicture)) {
|
|
|
|
if (IsEqualGUID(iid,&IID_IClassFactory)) {
|
|
|
|
_get_STDPIC_CF(ppv);
|
|
|
|
IClassFactory_AddRef((IClassFactory*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-05-20 06:13:58 +02:00
|
|
|
if (IsEqualGUID(rclsid,&CLSID_PSDispatch)) {
|
|
|
|
return OLEAUTPS_DllGetClassObject(rclsid,iid,ppv);
|
|
|
|
}
|
2002-02-05 19:11:17 +01:00
|
|
|
if (IsEqualGUID(rclsid,&CLSID_PSOAInterface)) {
|
|
|
|
if (S_OK==TypeLibFac_DllGetClassObject(rclsid,iid,ppv))
|
|
|
|
return S_OK;
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
}
|
2001-07-24 02:59:28 +02:00
|
|
|
FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2001-07-26 23:44:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (OLEAUT32.410)
|
2003-10-11 01:33:59 +02:00
|
|
|
*
|
|
|
|
* Determine if this dll can be unloaded from the callers address space.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Always returns S_FALSE. This dll cannot be unloaded.
|
2001-07-26 23:44:23 +02:00
|
|
|
*/
|
2003-10-11 01:33:59 +02:00
|
|
|
HRESULT WINAPI OLEAUT32_DllCanUnloadNow()
|
|
|
|
{
|
2001-07-24 02:59:28 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
2003-10-15 22:50:24 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* DllMain [OLEAUT32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%lu,%p)\n", hInstDll, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hInstDll);
|
|
|
|
OLEAUT32_hModule = (HMODULE)hInstDll;
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|