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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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>
|
2018-11-10 01:02:00 +01:00
|
|
|
#include <stdio.h>
|
1999-09-10 15:52:12 +02:00
|
|
|
#include <string.h>
|
2006-11-24 08:45:57 +01:00
|
|
|
#include <limits.h>
|
2000-12-19 05:53:20 +01:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
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"
|
2010-11-24 17:29:27 +01:00
|
|
|
#include "initguid.h"
|
2005-08-09 12:38:54 +02:00
|
|
|
#include "typelib.h"
|
2011-08-01 14:27:00 +02:00
|
|
|
#include "oleaut32_oaidl.h"
|
2002-02-05 19:11:17 +01:00
|
|
|
|
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);
|
2012-05-02 16:25:11 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(heap);
|
2000-01-23 04:15:25 +01:00
|
|
|
|
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.
|
|
|
|
*
|
2012-05-15 10:15:32 +02:00
|
|
|
* 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.
|
2003-09-24 07:12:52 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
static BOOL bstr_cache_enabled;
|
|
|
|
|
|
|
|
static CRITICAL_SECTION cs_bstr_cache;
|
|
|
|
static CRITICAL_SECTION_DEBUG cs_bstr_cache_dbg =
|
|
|
|
{
|
|
|
|
0, 0, &cs_bstr_cache,
|
|
|
|
{ &cs_bstr_cache_dbg.ProcessLocksList, &cs_bstr_cache_dbg.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": bstr_cache") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION cs_bstr_cache = { &cs_bstr_cache_dbg, -1, 0, 0, 0, 0 };
|
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
typedef struct {
|
2016-01-21 11:29:50 +01:00
|
|
|
#ifdef _WIN64
|
|
|
|
DWORD pad;
|
|
|
|
#endif
|
2012-05-02 16:24:57 +02:00
|
|
|
DWORD size;
|
|
|
|
union {
|
|
|
|
char ptr[1];
|
|
|
|
WCHAR str[1];
|
|
|
|
DWORD dwptr[1];
|
|
|
|
} u;
|
|
|
|
} bstr_t;
|
|
|
|
|
2013-02-13 18:57:21 +01:00
|
|
|
#define BUCKET_SIZE 16
|
|
|
|
#define BUCKET_BUFFER_SIZE 6
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
typedef struct {
|
|
|
|
unsigned short head;
|
|
|
|
unsigned short cnt;
|
2013-02-13 18:57:21 +01:00
|
|
|
bstr_t *buf[BUCKET_BUFFER_SIZE];
|
2012-04-27 17:34:28 +02:00
|
|
|
} bstr_cache_entry_t;
|
|
|
|
|
2012-05-02 16:25:11 +02:00
|
|
|
#define ARENA_INUSE_FILLER 0x55
|
|
|
|
#define ARENA_TAIL_FILLER 0xab
|
|
|
|
#define ARENA_FREE_FILLER 0xfeeefeee
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
static bstr_cache_entry_t bstr_cache[0x10000/BUCKET_SIZE];
|
|
|
|
|
|
|
|
static inline size_t bstr_alloc_size(size_t size)
|
|
|
|
{
|
2012-05-02 16:24:57 +02:00
|
|
|
return (FIELD_OFFSET(bstr_t, u.ptr[size]) + sizeof(WCHAR) + BUCKET_SIZE-1) & ~(BUCKET_SIZE-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bstr_t *bstr_from_str(BSTR str)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(str, bstr_t, u.str);
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-21 11:29:51 +01:00
|
|
|
static inline bstr_cache_entry_t *get_cache_entry_from_idx(unsigned cache_idx)
|
2012-04-27 17:34:28 +02:00
|
|
|
{
|
2018-08-29 21:05:39 +02:00
|
|
|
return bstr_cache_enabled && cache_idx < ARRAY_SIZE(bstr_cache) ? bstr_cache + cache_idx : NULL;
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-21 11:29:51 +01:00
|
|
|
static inline bstr_cache_entry_t *get_cache_entry(size_t size)
|
|
|
|
{
|
|
|
|
unsigned cache_idx = FIELD_OFFSET(bstr_t, u.ptr[size+sizeof(WCHAR)-1])/BUCKET_SIZE;
|
|
|
|
return get_cache_entry_from_idx(cache_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bstr_cache_entry_t *get_cache_entry_from_alloc_size(SIZE_T alloc_size)
|
|
|
|
{
|
|
|
|
unsigned cache_idx;
|
|
|
|
if (alloc_size < BUCKET_SIZE) return NULL;
|
|
|
|
cache_idx = (alloc_size - BUCKET_SIZE) / BUCKET_SIZE;
|
|
|
|
return get_cache_entry_from_idx(cache_idx);
|
|
|
|
}
|
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
static bstr_t *alloc_bstr(size_t size)
|
2012-04-27 17:34:28 +02:00
|
|
|
{
|
2015-12-25 06:37:44 +01:00
|
|
|
bstr_cache_entry_t *cache_entry = get_cache_entry(size);
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr_t *ret;
|
2012-04-27 17:34:28 +02:00
|
|
|
|
|
|
|
if(cache_entry) {
|
|
|
|
EnterCriticalSection(&cs_bstr_cache);
|
|
|
|
|
|
|
|
if(!cache_entry->cnt) {
|
2015-12-25 06:37:44 +01:00
|
|
|
cache_entry = get_cache_entry(size+BUCKET_SIZE);
|
2012-04-27 17:34:28 +02:00
|
|
|
if(cache_entry && !cache_entry->cnt)
|
|
|
|
cache_entry = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cache_entry) {
|
|
|
|
ret = cache_entry->buf[cache_entry->head++];
|
2013-02-13 18:57:21 +01:00
|
|
|
cache_entry->head %= BUCKET_BUFFER_SIZE;
|
2012-04-27 17:34:28 +02:00
|
|
|
cache_entry->cnt--;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&cs_bstr_cache);
|
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
if(cache_entry) {
|
2012-05-02 16:25:11 +02:00
|
|
|
if(WARN_ON(heap)) {
|
2015-12-25 06:38:10 +01:00
|
|
|
size_t fill_size = (FIELD_OFFSET(bstr_t, u.ptr[size])+2*sizeof(WCHAR)-1) & ~(sizeof(WCHAR)-1);
|
|
|
|
memset(ret, ARENA_INUSE_FILLER, fill_size);
|
|
|
|
memset((char *)ret+fill_size, ARENA_TAIL_FILLER, bstr_alloc_size(size)-fill_size);
|
2012-05-02 16:25:11 +02:00
|
|
|
}
|
2012-05-02 16:24:57 +02:00
|
|
|
ret->size = size;
|
2012-04-27 17:34:28 +02:00
|
|
|
return ret;
|
2012-05-02 16:24:57 +02:00
|
|
|
}
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-22 10:39:21 +01:00
|
|
|
ret = CoTaskMemAlloc(bstr_alloc_size(size));
|
2012-05-02 16:24:57 +02:00
|
|
|
if(ret)
|
|
|
|
ret->size = size;
|
|
|
|
return ret;
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2004-03-01 22:22:59 +01:00
|
|
|
UINT WINAPI SysStringLen(BSTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2012-05-02 16:24:57 +02:00
|
|
|
return str ? bstr_from_str(str)->size/sizeof(WCHAR) : 0;
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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
|
|
|
*/
|
2004-03-01 22:22:59 +01:00
|
|
|
UINT WINAPI SysStringByteLen(BSTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2012-05-02 16:24:57 +02:00
|
|
|
return str ? bstr_from_str(str)->size : 0;
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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
|
|
|
}
|
|
|
|
|
2016-01-21 11:29:51 +01:00
|
|
|
static inline IMalloc *get_malloc(void)
|
|
|
|
{
|
|
|
|
static IMalloc *malloc;
|
|
|
|
|
|
|
|
if (!malloc)
|
|
|
|
CoGetMalloc(1, &malloc);
|
|
|
|
|
|
|
|
return malloc;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2018-09-18 08:58:59 +02:00
|
|
|
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2012-04-27 17:34:28 +02:00
|
|
|
bstr_cache_entry_t *cache_entry;
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr_t *bstr;
|
2016-01-21 11:29:51 +01:00
|
|
|
IMalloc *malloc = get_malloc();
|
|
|
|
SIZE_T alloc_size;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
if(!str)
|
|
|
|
return;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr = bstr_from_str(str);
|
2016-01-21 11:29:51 +01:00
|
|
|
|
|
|
|
alloc_size = IMalloc_GetSize(malloc, bstr);
|
|
|
|
if (alloc_size == ~0UL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cache_entry = get_cache_entry_from_alloc_size(alloc_size);
|
2012-04-27 17:34:28 +02:00
|
|
|
if(cache_entry) {
|
2013-02-13 18:57:21 +01:00
|
|
|
unsigned i;
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
EnterCriticalSection(&cs_bstr_cache);
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2013-02-13 18:57:21 +01:00
|
|
|
/* According to tests, freeing a string that's already in cache doesn't corrupt anything.
|
|
|
|
* For that to work we need to search the cache. */
|
|
|
|
for(i=0; i < cache_entry->cnt; i++) {
|
2013-02-19 12:13:08 +01:00
|
|
|
if(cache_entry->buf[(cache_entry->head+i) % BUCKET_BUFFER_SIZE] == bstr) {
|
2013-02-13 18:57:21 +01:00
|
|
|
WARN_(heap)("String already is in cache!\n");
|
|
|
|
LeaveCriticalSection(&cs_bstr_cache);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:05:39 +02:00
|
|
|
if(cache_entry->cnt < ARRAY_SIZE(cache_entry->buf)) {
|
2013-02-13 18:57:21 +01:00
|
|
|
cache_entry->buf[(cache_entry->head+cache_entry->cnt) % BUCKET_BUFFER_SIZE] = bstr;
|
2012-04-27 17:34:28 +02:00
|
|
|
cache_entry->cnt++;
|
2012-05-02 16:24:57 +02:00
|
|
|
|
2012-05-02 16:25:11 +02:00
|
|
|
if(WARN_ON(heap)) {
|
2016-01-22 07:03:08 +01:00
|
|
|
unsigned n = (alloc_size-FIELD_OFFSET(bstr_t, u.ptr))/sizeof(DWORD);
|
2012-05-02 16:25:11 +02:00
|
|
|
for(i=0; i<n; i++)
|
|
|
|
bstr->u.dwptr[i] = ARENA_FREE_FILLER;
|
|
|
|
}
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
LeaveCriticalSection(&cs_bstr_cache);
|
|
|
|
return;
|
|
|
|
}
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
LeaveCriticalSection(&cs_bstr_cache);
|
|
|
|
}
|
|
|
|
|
2016-01-22 10:39:21 +01:00
|
|
|
CoTaskMemFree(bstr);
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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
|
|
|
{
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr_t *bstr;
|
|
|
|
DWORD size;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2006-11-24 08:45:57 +01:00
|
|
|
/* Detect integer overflow. */
|
|
|
|
if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
|
|
|
|
return NULL;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
TRACE("%s\n", debugstr_wn(str, len));
|
|
|
|
|
2012-04-27 17:34:28 +02:00
|
|
|
size = len*sizeof(WCHAR);
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr = alloc_bstr(size);
|
|
|
|
if(!bstr)
|
2012-04-27 17:34:28 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(str) {
|
2012-05-02 16:24:57 +02:00
|
|
|
memcpy(bstr->u.str, str, size);
|
|
|
|
bstr->u.str[len] = 0;
|
2012-04-27 17:34:28 +02:00
|
|
|
}else {
|
2012-05-02 16:24:57 +02:00
|
|
|
memset(bstr->u.str, 0, size+sizeof(WCHAR));
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
return bstr->u.str;
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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().
|
2008-07-06 17:42:27 +02:00
|
|
|
* *old 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
|
|
|
{
|
2007-11-27 23:43:00 +01:00
|
|
|
/* Detect integer overflow. */
|
|
|
|
if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
|
2016-01-22 10:39:21 +01:00
|
|
|
return FALSE;
|
2007-11-27 23:43:00 +01:00
|
|
|
|
2003-01-28 01:30:29 +01:00
|
|
|
if (*old!=NULL) {
|
|
|
|
DWORD newbytelen = len*sizeof(WCHAR);
|
2016-01-21 11:29:49 +01:00
|
|
|
bstr_t *old_bstr = bstr_from_str(*old);
|
2016-01-22 10:39:21 +01:00
|
|
|
bstr_t *bstr = CoTaskMemRealloc(old_bstr, bstr_alloc_size(newbytelen));
|
|
|
|
|
|
|
|
if (!bstr) return FALSE;
|
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
*old = bstr->u.str;
|
|
|
|
bstr->size = newbytelen;
|
2016-01-22 10:39:21 +01:00
|
|
|
/* The old string data is still there when str is NULL */
|
|
|
|
if (str && old_bstr->u.str != str) memmove(bstr->u.str, str, newbytelen);
|
|
|
|
bstr->u.str[len] = 0;
|
2003-01-28 01:30:29 +01:00
|
|
|
} else {
|
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
|
|
|
|
2016-01-22 10:39:21 +01:00
|
|
|
return TRUE;
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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
|
|
|
*/
|
2018-10-03 05:30:45 +02:00
|
|
|
BSTR WINAPI DECLSPEC_HOTPATCH SysAllocStringByteLen(LPCSTR str, UINT len)
|
2002-12-12 23:24:45 +01:00
|
|
|
{
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr_t *bstr;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2007-11-27 23:43:00 +01:00
|
|
|
/* Detect integer overflow. */
|
|
|
|
if (len >= (UINT_MAX-sizeof(WCHAR)-sizeof(DWORD)))
|
|
|
|
return NULL;
|
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
bstr = alloc_bstr(len);
|
|
|
|
if(!bstr)
|
2012-04-27 17:34:28 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(str) {
|
2012-05-02 16:24:57 +02:00
|
|
|
memcpy(bstr->u.ptr, str, len);
|
2015-12-25 06:38:10 +01:00
|
|
|
bstr->u.ptr[len] = 0;
|
2012-04-27 17:34:28 +02:00
|
|
|
}else {
|
2015-12-25 06:38:10 +01:00
|
|
|
memset(bstr->u.ptr, 0, len+1);
|
2012-04-27 17:34:28 +02:00
|
|
|
}
|
2015-12-25 06:38:10 +01:00
|
|
|
bstr->u.str[(len+sizeof(WCHAR)-1)/sizeof(WCHAR)] = 0;
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2012-05-02 16:24:57 +02:00
|
|
|
return bstr->u.str;
|
2002-12-12 23:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-09-24 23:04:49 +02:00
|
|
|
SysFreeString(*old);
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2012-04-27 17:34:28 +02:00
|
|
|
* SetOaNoCache does not release cached strings, so it leaks by design.
|
2003-09-24 07:12:52 +02:00
|
|
|
*/
|
|
|
|
void WINAPI SetOaNoCache(void)
|
|
|
|
{
|
2012-04-27 17:34:28 +02:00
|
|
|
TRACE("\n");
|
|
|
|
bstr_cache_enabled = FALSE;
|
2003-09-24 07:12:52 +02:00
|
|
|
}
|
|
|
|
|
2000-03-24 21:46:04 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RegisterActiveObject (OLEAUT32.33)
|
2005-07-05 13:02:19 +02:00
|
|
|
*
|
|
|
|
* Registers an object in the global item table.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* punk [I] Object to register.
|
|
|
|
* rcid [I] CLSID of the object.
|
|
|
|
* dwFlags [I] Flags.
|
|
|
|
* pdwRegister [O] Address to store cookie of object registration in.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: HRESULT code.
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
2015-11-12 16:07:55 +01:00
|
|
|
HRESULT WINAPI DECLSPEC_HOTPATCH RegisterActiveObject(
|
1999-10-13 14:19:09 +02:00
|
|
|
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;
|
2011-03-04 02:03:40 +01:00
|
|
|
DWORD rot_flags = ROTFLAGS_REGISTRATIONKEEPSALIVE; /* default registration is strong */
|
2000-01-23 04:15:25 +01:00
|
|
|
|
|
|
|
StringFromGUID2(rcid,guidbuf,39);
|
2020-11-26 09:07:57 +01:00
|
|
|
ret = CreateItemMoniker(L"!", 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;
|
|
|
|
}
|
2011-03-04 02:03:40 +01:00
|
|
|
if(dwFlags == ACTIVEOBJECT_WEAK)
|
|
|
|
rot_flags = 0;
|
|
|
|
ret = IRunningObjectTable_Register(runobtable,rot_flags,punk,moniker,pdwRegister);
|
2000-01-23 04:15:25 +01:00
|
|
|
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)
|
2005-07-05 13:02:19 +02:00
|
|
|
*
|
|
|
|
* Revokes an object from the global item table.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* xregister [I] Registration cookie.
|
|
|
|
* reserved [I] Reserved. Set to NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: HRESULT code.
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
2015-11-12 16:07:55 +01:00
|
|
|
HRESULT WINAPI DECLSPEC_HOTPATCH 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)
|
2005-07-05 13:02:19 +02:00
|
|
|
*
|
|
|
|
* Gets an object from the global item table.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* rcid [I] CLSID of the object.
|
|
|
|
* preserved [I] Reserved. Set to NULL.
|
|
|
|
* ppunk [O] Address to store object into.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: HRESULT code.
|
2000-03-24 21:46:04 +01:00
|
|
|
*/
|
2015-11-12 16:07:55 +01:00
|
|
|
HRESULT WINAPI DECLSPEC_HOTPATCH GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
|
1999-10-13 14:19:09 +02:00
|
|
|
{
|
2000-01-23 04:15:25 +01:00
|
|
|
WCHAR guidbuf[80];
|
|
|
|
HRESULT ret;
|
|
|
|
LPRUNNINGOBJECTTABLE runobtable;
|
|
|
|
LPMONIKER moniker;
|
|
|
|
|
|
|
|
StringFromGUID2(rcid,guidbuf,39);
|
2020-11-26 09:07:57 +01:00
|
|
|
ret = CreateItemMoniker(L"!", 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
|
|
|
*/
|
2007-08-29 21:42:28 +02:00
|
|
|
ULONG WINAPI OaBuildVersion(void)
|
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);
|
2011-05-21 19:30:51 +02:00
|
|
|
case 0x00000105: /* WinXP */
|
|
|
|
case 0x00000006: /* Vista */
|
|
|
|
case 0x00000106: /* Win7 */
|
|
|
|
return MAKELONG(0xffff, 50);
|
2000-08-14 16:35:01 +02:00
|
|
|
default:
|
2005-02-08 13:12:40 +01:00
|
|
|
FIXME("Version value not known yet. Please investigate it !\n");
|
|
|
|
return MAKELONG(0xffff, 40); /* for now return the same value as for w2k */
|
1999-12-06 00:52:56 +01:00
|
|
|
}
|
|
|
|
}
|
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));
|
|
|
|
|
2006-10-12 20:57:10 +02:00
|
|
|
TRACE("(%08x, %p, %p)\n", clr, hpal, pColorRef);
|
2002-12-12 23:24:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2004-11-08 21:24:50 +01:00
|
|
|
if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR))
|
2002-12-12 23:24:45 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pColorRef = GetSysColor(index);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-12-01 18:56:35 +01:00
|
|
|
extern HRESULT WINAPI OLEAUTPS_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
|
2008-12-02 21:20:32 +01:00
|
|
|
extern BOOL WINAPI OLEAUTPS_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
|
2010-11-24 17:29:27 +01:00
|
|
|
extern HRESULT WINAPI OLEAUTPS_DllRegisterServer(void) DECLSPEC_HIDDEN;
|
|
|
|
extern HRESULT WINAPI OLEAUTPS_DllUnregisterServer(void) DECLSPEC_HIDDEN;
|
2003-05-20 06:13:58 +02:00
|
|
|
|
2018-11-10 01:02:00 +01:00
|
|
|
extern HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo,
|
|
|
|
IUnknown *outer, REFIID iid, IRpcProxyBuffer **proxy, void **obj);
|
|
|
|
extern HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
|
|
|
|
IUnknown *server, IRpcStubBuffer **stub);
|
|
|
|
|
|
|
|
struct ifacepsredirect_data
|
|
|
|
{
|
|
|
|
ULONG size;
|
|
|
|
DWORD mask;
|
|
|
|
GUID iid;
|
|
|
|
ULONG nummethods;
|
|
|
|
GUID tlbid;
|
|
|
|
GUID base;
|
|
|
|
ULONG name_len;
|
|
|
|
ULONG name_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tlibredirect_data
|
|
|
|
{
|
|
|
|
ULONG size;
|
|
|
|
DWORD res;
|
|
|
|
ULONG name_len;
|
|
|
|
ULONG name_offset;
|
|
|
|
LANGID langid;
|
|
|
|
WORD flags;
|
|
|
|
ULONG help_len;
|
|
|
|
ULONG help_offset;
|
|
|
|
WORD major_version;
|
|
|
|
WORD minor_version;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL actctx_get_typelib_module(REFIID iid, WCHAR *module, DWORD len)
|
|
|
|
{
|
|
|
|
struct ifacepsredirect_data *iface;
|
|
|
|
struct tlibredirect_data *tlib;
|
|
|
|
ACTCTX_SECTION_KEYED_DATA data;
|
|
|
|
WCHAR *ptrW;
|
|
|
|
|
|
|
|
data.cbSize = sizeof(data);
|
|
|
|
if (!FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
|
|
|
|
iid, &data))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
iface = (struct ifacepsredirect_data *)data.lpData;
|
|
|
|
if (!FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
|
|
|
|
&iface->tlbid, &data))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tlib = (struct tlibredirect_data *)data.lpData;
|
|
|
|
ptrW = (WCHAR *)((BYTE *)data.lpSectionBase + tlib->name_offset);
|
|
|
|
|
|
|
|
if (tlib->name_len/sizeof(WCHAR) >= len)
|
|
|
|
{
|
|
|
|
ERR("need larger module buffer, %u\n", tlib->name_len);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(module, ptrW, tlib->name_len);
|
|
|
|
module[tlib->name_len/sizeof(WCHAR)] = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT reg_get_typelib_module(REFIID iid, WCHAR *module, DWORD len)
|
|
|
|
{
|
|
|
|
REGSAM opposite = (sizeof(void*) == 8) ? KEY_WOW64_32KEY : KEY_WOW64_64KEY;
|
2019-11-13 14:51:20 +01:00
|
|
|
char tlguid[200], typelibkey[316], interfacekey[300], ver[100], tlfn[260];
|
2018-11-10 01:02:00 +01:00
|
|
|
DWORD tlguidlen, verlen, type;
|
|
|
|
LONG tlfnlen, err;
|
|
|
|
BOOL is_wow64;
|
|
|
|
HKEY ikey;
|
|
|
|
|
|
|
|
sprintf( interfacekey, "Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
|
|
|
|
iid->Data1, iid->Data2, iid->Data3,
|
|
|
|
iid->Data4[0], iid->Data4[1], iid->Data4[2], iid->Data4[3],
|
|
|
|
iid->Data4[4], iid->Data4[5], iid->Data4[6], iid->Data4[7]
|
|
|
|
);
|
|
|
|
|
|
|
|
err = RegOpenKeyExA(HKEY_CLASSES_ROOT,interfacekey,0,KEY_READ,&ikey);
|
|
|
|
if (err && (opposite == KEY_WOW64_32KEY || (IsWow64Process(GetCurrentProcess(), &is_wow64)
|
|
|
|
&& is_wow64)))
|
|
|
|
err = RegOpenKeyExA(HKEY_CLASSES_ROOT,interfacekey,0,KEY_READ|opposite,&ikey);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
ERR("No %s key found.\n", interfacekey);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
tlguidlen = sizeof(tlguid);
|
|
|
|
if (RegQueryValueExA(ikey, NULL, NULL, &type, (BYTE *)tlguid, &tlguidlen))
|
|
|
|
{
|
|
|
|
ERR("Getting typelib guid failed.\n");
|
|
|
|
RegCloseKey(ikey);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
verlen = sizeof(ver);
|
|
|
|
if (RegQueryValueExA(ikey, "Version", NULL, &type, (BYTE *)ver, &verlen))
|
|
|
|
{
|
|
|
|
ERR("Could not get version value?\n");
|
|
|
|
RegCloseKey(ikey);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(ikey);
|
|
|
|
|
|
|
|
sprintf(typelibkey, "Typelib\\%s\\%s\\0\\win%u", tlguid, ver, sizeof(void *) == 8 ? 64 : 32);
|
|
|
|
tlfnlen = sizeof(tlfn);
|
|
|
|
if (RegQueryValueA(HKEY_CLASSES_ROOT, typelibkey, tlfn, &tlfnlen))
|
|
|
|
{
|
|
|
|
#ifdef _WIN64
|
|
|
|
sprintf(typelibkey, "Typelib\\%s\\%s\\0\\win32", tlguid, ver);
|
|
|
|
tlfnlen = sizeof(tlfn);
|
|
|
|
if (RegQueryValueA(HKEY_CLASSES_ROOT, typelibkey, tlfn, &tlfnlen))
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
ERR("Could not get typelib fn?\n");
|
|
|
|
return E_FAIL;
|
|
|
|
#ifdef _WIN64
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, tlfn, -1, module, len);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_typeinfo_for_iid(REFIID iid, ITypeInfo **typeinfo)
|
|
|
|
{
|
|
|
|
WCHAR module[MAX_PATH];
|
|
|
|
ITypeLib *typelib;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*typeinfo = NULL;
|
|
|
|
|
|
|
|
module[0] = 0;
|
|
|
|
if (!actctx_get_typelib_module(iid, module, ARRAY_SIZE(module)))
|
|
|
|
{
|
|
|
|
hr = reg_get_typelib_module(iid, module, ARRAY_SIZE(module));
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = LoadTypeLib(module, &typelib);
|
|
|
|
if (hr != S_OK) {
|
|
|
|
ERR("Failed to load typelib for %s, but it should be there.\n", debugstr_guid(iid));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ITypeLib_GetTypeInfoOfGuid(typelib, iid, typeinfo);
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
if (hr != S_OK)
|
|
|
|
ERR("typelib does not contain info for %s\n", debugstr_guid(iid));
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static HRESULT WINAPI dispatch_typelib_ps_QueryInterface(IPSFactoryBuffer *iface, REFIID iid, void **out)
|
2018-11-10 01:02:00 +01:00
|
|
|
{
|
|
|
|
if (IsEqualIID(iid, &IID_IPSFactoryBuffer) || IsEqualIID(iid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("No interface for %s.\n", debugstr_guid(iid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static ULONG WINAPI dispatch_typelib_ps_AddRef(IPSFactoryBuffer *iface)
|
2018-11-10 01:02:00 +01:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static ULONG WINAPI dispatch_typelib_ps_Release(IPSFactoryBuffer *iface)
|
2018-11-10 01:02:00 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static HRESULT dispatch_create_proxy(IUnknown *outer, IRpcProxyBuffer **proxy, void **out)
|
2018-11-10 01:02:00 +01:00
|
|
|
{
|
2019-02-28 18:26:56 +01:00
|
|
|
IPSFactoryBuffer *factory;
|
2018-11-10 01:02:00 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&factory);
|
2018-11-10 01:02:00 +01:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = IPSFactoryBuffer_CreateProxy(factory, outer, &IID_IDispatch, proxy, out);
|
|
|
|
IPSFactoryBuffer_Release(factory);
|
2018-11-10 01:02:00 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static HRESULT WINAPI dispatch_typelib_ps_CreateProxy(IPSFactoryBuffer *iface,
|
|
|
|
IUnknown *outer, REFIID iid, IRpcProxyBuffer **proxy, void **out)
|
2018-11-10 01:02:00 +01:00
|
|
|
{
|
|
|
|
ITypeInfo *typeinfo;
|
2019-02-28 18:26:56 +01:00
|
|
|
TYPEATTR *attr;
|
2018-11-10 01:02:00 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
if (IsEqualGUID(iid, &IID_IDispatch))
|
|
|
|
return dispatch_create_proxy(outer, proxy, out);
|
|
|
|
|
2018-11-10 01:02:00 +01:00
|
|
|
hr = get_typeinfo_for_iid(iid, &typeinfo);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
2018-11-10 01:02:00 +01:00
|
|
|
if (FAILED(hr))
|
2005-11-02 11:54:52 +01:00
|
|
|
{
|
2019-02-28 18:26:56 +01:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
if (attr->typekind == TKIND_INTERFACE || (attr->wTypeFlags & TYPEFLAG_FDUAL))
|
|
|
|
hr = CreateProxyFromTypeInfo(typeinfo, outer, iid, proxy, out);
|
|
|
|
else
|
|
|
|
hr = dispatch_create_proxy(outer, proxy, out);
|
2005-11-02 11:54:52 +01:00
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Failed to create proxy, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static HRESULT dispatch_create_stub(IUnknown *server, IRpcStubBuffer **stub)
|
2005-11-02 11:54:52 +01:00
|
|
|
{
|
2018-11-10 01:02:00 +01:00
|
|
|
IPSFactoryBuffer *factory;
|
2005-11-02 11:54:52 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&factory);
|
|
|
|
if (FAILED(hr)) return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = IPSFactoryBuffer_CreateStub(factory, &IID_IDispatch, server, stub);
|
|
|
|
IPSFactoryBuffer_Release(factory);
|
|
|
|
return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static HRESULT WINAPI dispatch_typelib_ps_CreateStub(IPSFactoryBuffer *iface,
|
2018-11-10 01:02:00 +01:00
|
|
|
REFIID iid, IUnknown *server, IRpcStubBuffer **stub)
|
2005-11-02 11:54:52 +01:00
|
|
|
{
|
2019-02-28 18:26:56 +01:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
TYPEATTR *attr;
|
2005-11-02 11:54:52 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
if (IsEqualGUID(iid, &IID_IDispatch))
|
|
|
|
return dispatch_create_stub(server, stub);
|
|
|
|
|
|
|
|
hr = get_typeinfo_for_iid(iid, &typeinfo);
|
|
|
|
if (FAILED(hr)) return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ITypeInfo_Release(typeinfo);
|
2018-11-10 01:02:00 +01:00
|
|
|
return hr;
|
|
|
|
}
|
2019-02-28 18:26:56 +01:00
|
|
|
|
|
|
|
if (attr->typekind == TKIND_INTERFACE || (attr->wTypeFlags & TYPEFLAG_FDUAL))
|
|
|
|
hr = CreateStubFromTypeInfo(typeinfo, iid, server, stub);
|
2018-11-10 01:02:00 +01:00
|
|
|
else
|
2019-02-28 18:26:56 +01:00
|
|
|
hr = dispatch_create_stub(server, stub);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Failed to create proxy, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
return hr;
|
2005-11-02 11:54:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static const IPSFactoryBufferVtbl dispatch_typelib_ps_vtbl =
|
2005-11-02 11:54:52 +01:00
|
|
|
{
|
2019-02-28 18:26:56 +01:00
|
|
|
dispatch_typelib_ps_QueryInterface,
|
|
|
|
dispatch_typelib_ps_AddRef,
|
|
|
|
dispatch_typelib_ps_Release,
|
|
|
|
dispatch_typelib_ps_CreateProxy,
|
|
|
|
dispatch_typelib_ps_CreateStub,
|
2005-11-02 11:54:52 +01:00
|
|
|
};
|
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
static IPSFactoryBuffer dispatch_typelib_ps = { &dispatch_typelib_ps_vtbl };
|
|
|
|
|
|
|
|
extern void _get_STDFONT_CF(LPVOID *);
|
|
|
|
extern void _get_STDPIC_CF(LPVOID *);
|
2005-11-02 11:54:52 +01:00
|
|
|
|
2001-07-26 23:44:23 +02:00
|
|
|
/***********************************************************************
|
2005-08-10 15:02:43 +02:00
|
|
|
* DllGetClassObject (OLEAUT32.@)
|
2001-07-26 23:44:23 +02:00
|
|
|
*/
|
2005-06-29 22:16:41 +02:00
|
|
|
HRESULT WINAPI 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;
|
|
|
|
}
|
|
|
|
}
|
2018-11-10 01:02:00 +01:00
|
|
|
|
2019-02-28 18:26:56 +01:00
|
|
|
if (IsEqualGUID(rclsid, &CLSID_PSDispatch) || IsEqualGUID(rclsid, &CLSID_PSOAInterface))
|
|
|
|
return IPSFactoryBuffer_QueryInterface(&dispatch_typelib_ps, iid, ppv);
|
2018-11-10 01:02:00 +01:00
|
|
|
|
2016-08-25 19:57:17 +02:00
|
|
|
if (IsEqualCLSID(rclsid, &CLSID_PSTypeComp) ||
|
|
|
|
IsEqualCLSID(rclsid, &CLSID_PSTypeInfo) ||
|
2009-09-23 14:32:01 +02:00
|
|
|
IsEqualCLSID(rclsid, &CLSID_PSTypeLib) ||
|
|
|
|
IsEqualCLSID(rclsid, &CLSID_PSDispatch) ||
|
|
|
|
IsEqualCLSID(rclsid, &CLSID_PSEnumVariant))
|
|
|
|
return OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, iid, ppv);
|
|
|
|
|
2008-09-02 18:02:04 +02:00
|
|
|
return OLEAUTPS_DllGetClassObject(rclsid, iid, ppv);
|
2001-07-24 02:59:28 +02:00
|
|
|
}
|
|
|
|
|
2001-07-26 23:44:23 +02:00
|
|
|
/***********************************************************************
|
2005-08-10 15:02:43 +02:00
|
|
|
* DllCanUnloadNow (OLEAUT32.@)
|
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
|
|
|
*/
|
2005-06-29 22:16:41 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2003-10-11 01:33:59 +02:00
|
|
|
{
|
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)
|
|
|
|
{
|
2013-12-11 16:15:02 +01:00
|
|
|
if(fdwReason == DLL_PROCESS_ATTACH)
|
2020-11-26 09:07:57 +01:00
|
|
|
bstr_cache_enabled = !GetEnvironmentVariableW(L"oanocache", NULL, 0);
|
2012-04-27 17:34:28 +02:00
|
|
|
|
2008-12-02 21:20:32 +01:00
|
|
|
return OLEAUTPS_DllMain( hInstDll, fdwReason, lpvReserved );
|
2003-10-15 22:50:24 +02:00
|
|
|
}
|
2006-12-30 04:49:27 +01:00
|
|
|
|
2010-11-24 17:29:27 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (OLEAUT32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2011-08-02 15:37:14 +02:00
|
|
|
return OLEAUTPS_DllRegisterServer();
|
2010-11-24 17:29:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (OLEAUT32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
|
|
|
return OLEAUTPS_DllUnregisterServer();
|
|
|
|
}
|
|
|
|
|
2006-12-30 04:49:27 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* OleIconToCursor (OLEAUT32.415)
|
|
|
|
*/
|
|
|
|
HCURSOR WINAPI OleIconToCursor( HINSTANCE hinstExe, HICON hIcon)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p), partially implemented.\n",hinstExe,hIcon);
|
2013-12-03 14:25:04 +01:00
|
|
|
/* FIXME: make an extended conversation from HICON to HCURSOR */
|
2006-12-30 04:49:27 +01:00
|
|
|
return CopyCursor(hIcon);
|
|
|
|
}
|
2017-03-26 09:06:00 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetAltMonthNames (OLEAUT32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetAltMonthNames(LCID lcid, LPOLESTR **str)
|
|
|
|
{
|
|
|
|
static const WCHAR *arabic_hijri[] =
|
|
|
|
{
|
2020-11-28 23:07:23 +01:00
|
|
|
L"\x0645\x062d\x0631\x0645",
|
|
|
|
L"\x0635\x0641\x0631",
|
|
|
|
L"\x0631\x0628\x064a\x0639 \x0627\x0644\x0627\x0648\x0644",
|
|
|
|
L"\x0631\x0628\x064a\x0639 \x0627\x0644\x062b\x0627\x0646\x064a",
|
|
|
|
L"\x062c\x0645\x0627\x062f\x0649 \x0627\x0644\x0627\x0648\x0644\x0649",
|
|
|
|
L"\x062c\x0645\x0627\x062f\x0649 \x0627\x0644\x062b\x0627\x0646\x064a\x0629",
|
|
|
|
L"\x0631\x062c\x0628",
|
|
|
|
L"\x0634\x0639\x0628\x0627\x0646",
|
|
|
|
L"\x0631\x0645\x0636\x0627\x0646",
|
|
|
|
L"\x0634\x0648\x0627\x0643",
|
|
|
|
L"\x0630\x0648 \x0627\x0644\x0642\x0639\x062f\x0629",
|
|
|
|
L"\x0630\x0648 \x0627\x0644\x062d\x062c\x0629",
|
2017-03-26 09:06:00 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR *polish_genitive_names[] =
|
|
|
|
{
|
2020-11-26 09:07:57 +01:00
|
|
|
L"stycznia",
|
|
|
|
L"lutego",
|
|
|
|
L"marca",
|
|
|
|
L"kwietnia",
|
|
|
|
L"maja",
|
|
|
|
L"czerwca",
|
|
|
|
L"lipca",
|
|
|
|
L"sierpnia",
|
2020-11-28 23:07:23 +01:00
|
|
|
L"wrze\x015bnia",
|
|
|
|
L"pa\x017a" "dziernika",
|
2020-11-26 09:07:57 +01:00
|
|
|
L"listopada",
|
|
|
|
L"grudnia",
|
2017-03-26 09:06:00 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR *russian_genitive_names[] =
|
|
|
|
{
|
2020-11-28 23:07:23 +01:00
|
|
|
L"\x044f\x043d\x0432\x0430\x0440\x044f",
|
|
|
|
L"\x0444\x0435\x0432\x0440\x0430\x043b\x044f",
|
|
|
|
L"\x043c\x0430\x0440\x0442\x0430",
|
|
|
|
L"\x0430\x043f\x0440\x0435\x043b\x044f",
|
|
|
|
L"\x043c\x0430\x044f",
|
|
|
|
L"\x0438\x044e\x043d\x044f",
|
|
|
|
L"\x0438\x044e\x043b\x044f",
|
|
|
|
L"\x0430\x0432\x0433\x0443\x0441\x0442\x0430",
|
|
|
|
L"\x0441\x0435\x043d\x0442\x044f\x0431\x0440\x044f",
|
|
|
|
L"\x043e\x043a\x0442\x044f\x0431\x0440\x044f",
|
|
|
|
L"\x043d\x043e\x044f\x0431\x0440\x044f",
|
|
|
|
L"\x0434\x0435\x043a\x0430\x0431\x0440\x044f",
|
2017-03-26 09:06:00 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("%#x, %p\n", lcid, str);
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_ARABIC)
|
|
|
|
*str = (LPOLESTR *)arabic_hijri;
|
|
|
|
else if (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_POLISH)
|
|
|
|
*str = (LPOLESTR *)polish_genitive_names;
|
|
|
|
else if (PRIMARYLANGID(LANGIDFROMLCID(lcid)) == LANG_RUSSIAN)
|
|
|
|
*str = (LPOLESTR *)russian_genitive_names;
|
|
|
|
else
|
|
|
|
*str = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|