mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 00:50:23 +00:00

[WINESYNC] propsys/tests: Merge test files. wine commit id d189b55d2ffb038474cb6656dc8743eb34c35a3d by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Add a semi-stub for PSCreatePropertyStoreFromObject(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47958 wine commit id acb2e4fc7a4242c74ac91657edb97bf1e402656a by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Allow only ASCII digits in PSPropertyKeyFromString. wine commit id 6e8c2d836e637e1fbd83c231cfd846ecb9333964 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] propsys/tests: Get rid of strcmp_wa(). wine commit id 2340212ee9c48c731c85bbad8c81ed833458bf15 by Michael Stefaniuc <mstefani@winehq.org> [WINESYNC] propsys: Use wide-char string literals. wine commit id b72440fa2e1016681cbfcebcdc4792b6ced3eb53 by Michael Stefaniuc <mstefani@winehq.org> reduce wine diff and add stuff from previous commit [WINESYNC] propsys: Use --prefer_native instead of DLL_WINE_PREATTACH. wine commit id f99113192ffac37506a905827415d3d21d0ebbf8 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Use nameless unions. wine commit id 1d8e5079f0e53a767a783e5107f57f04c1897951 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] propsys/tests: Use nameless unions. wine commit id 497de3cc19f971808ca4105f52038e61dc818db1 by Jacek Caban <jacek@codeweavers.com> [WINESYNC] winecrt0: Add a default implementation for DllCanUnloadNow(). wine commit id bd6b53740c28c6974300e15f965c12feb0252085 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] winecrt0: Add a default implementation DllRegisterServer()/DllUnregisterServer(). wine commit id 5d82baf9747b7b133cad3be77c0cc9e24cc09582 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Add support for VT_VECTOR|VT_UI1 type in PropVariantCompareEx(). wine commit id e91b05bb5be6fd70a767bea9991e818a49cc5547 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Fix VT_UI4 comparison, use ulVal instead of uiVal. wine commit id 58eeb1a86433db1104d3a9ccf9ad7435ec81443a by Rémi Bernon <rbernon@codeweavers.com> [WINESYNC] propsys/tests: Add a VT_UI4 test for PropVariantCompareEx(). A test for 58eeb1a86433db1104d3a9ccf9ad7435ec81443a. wine commit id 10359e17ce64f39461a7b7b54f73857e6458d1fb by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys/tests: Avoid "misleading indentation" warnings. wine commit id 7cd6681b3be35cf6c02f056cb5131c90c0674c16 by Fabian Maurer <dark.shadow4@web.de> [WINESYNC] propsys: Enable compilation with long types. wine commit id a9c797e4538a37716e62bb81c3fed3de39561b41 by Eric Pouech <eric.pouech@gmail.com> [WINESYNC] propsys/tests: Enable compilation with long types. wine commit id c1c393595d43bd95390d3ddf86dcbc46bc4f52ba by Eric Pouech <eric.pouech@gmail.com> [WINESYNC] propsys: Implement InitVariantFromFileTime. wine commit id f2b8ccb7b0b22b7b5d661d908f8f8ee02f22647d by Daniel Lehman <dlehman@esri.com> [WINESYNC] propsys/tests: Add some InitVariantFromFileTime tests. wine commit id 083dea7fce4372840ac18176496a7d05dadd5ad8 by Daniel Lehman <dlehman@esri.com> [WINESYNC] propsys: Implement VariantToStringWithDefault. wine commit id bf0f1fdcf80657a42116b79a0953181191cf9221 by Mohamad Al-Jaf <mohamadaljaf@gmail.com> [WINESYNC] propsys/tests: Add VariantToStringWithDefault tests. wine commit id 89aba13dc381dbbda62d1019e1af2af5a589b0cf by Mohamad Al-Jaf <mohamadaljaf@gmail.com> [WINESYNC] include: Add Stg functions declaration in propvarutil.h. wine commit id 0d294ad26544913414277daa164004d731ae6e33 by Biswapriyo Nath <nathbappai@gmail.com> [WINESYNC] propsys: Add InitPropVariantFromStringVector(). wine commit id 3a1146d8e63d7ceff38441fee08f7f7080527020 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] Remove unused NONAMELESS defines. wine commit id 20afe438320f77d103a96d1d8cd562d0899ebac7 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Partially implement VariantToString(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55708 wine commit id f7ef02bd8f74ea052d61e48cd84b226d8a5867a8 by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Handle VT_I4 type in VariantToString(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55708 wine commit id 001e0543bfd5aea060053af0c76233bb90fbb43b by Nikolay Sivov <nsivov@codeweavers.com> [WINESYNC] propsys: Implement PropVariantToUInt32WithDefault. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55713 wine commit id d177709b10ce07ddd234b0e8e00764ae4b1d8488 by Fabian Maurer <dark.shadow4@web.de> [WINESYNC] include: Use proper dllimports for propsys functions. wine commit id f0b2e0d00c86fb04d47467f39e49c587250ffec5 by Alexandre Julliard <julliard@winehq.org> [WINESYNC] propsys: Remove DECLSPEC_HIDDEN usage. wine commit id e9ff53e098ef3871d692c7b907151cfbb2f0673f by Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Update propsys_private.h [WINESYNC] propsys: Force debug info in critical sections. wine commit id 67bea281cc851eda6a08430c70f6c9e848d3fbe1 by Paul Gofman <pgofman@codeweavers.com> [WINESYNC] include: Fix typos in IID_IPropertyEnumType2 and CLSID_PropertySystem. wine commit id 66e6b61705a66459ed3a9e0cf9457d8b180e4564 by Alfred Agrell <floating@muncher.se> [WINESYNC] propsys: Add stubs for variant conversion functions. wine commit id c21f04f7adaa4a8d0ca2d2659bf9a6facdc168c3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Add tests for VariantToPropVariant. wine commit id 8877889f2a8e36d22dcad061e6da84476efb3750 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Initially implement VariantToPropVariant. wine commit id 6985637ed59e81e7d1716095a343cc5681082306 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Add tests for PropVariantToVariant. wine commit id 3277de5572b7f6c41ebeeb89f781e378a6a2c2d3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test converting clsid to string. wine commit id 7a4f9f83c51883f41ae1363e27700452472ec18f by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Support converting clsid to string for PropVariant. wine commit id 67b097ff46c65d525de6a7f560f019de6828320c by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Initially implement PropVariantToVariant. wine commit id 808b398549350fffc9fc023d637ef8de9e4bba37 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Add PropVariantToBSTR stub. wine commit id 86558a4b83ebf9a0c6e76888a3d0f3fe3e36bf57 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test PropVariantToBSTR. wine commit id b4ac03f1f622120906a8b6e691caa05f6539c2dd by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Test truncating for PropVariantToString. wine commit id df16802582a56f8076ebbcf9cb6178f65bb8b9b6 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Implement PropVariantToBSTR. wine commit id 66220be403ce5c3634c13da3546f0c19f04059cc by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Use debugstr_variant for the trace in VariantToPropVariant. wine commit id 3517aded4090229dbb11e413bde8349d1eca0be3 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys: Support converting to BSTR for PropVariantToVariant. wine commit id c33fdc27650045a754a05a8f25e250e6e72c8072 by Ziqing Hui <zhui@codeweavers.com> [WINESYNC] propsys/tests: Fix a test that fails on some Windows versions. wine commit id c09f828f43101cf2dfe11d7e13f1fc6ef4b19853 by Alexandre Julliard <julliard@winehq.org> [WINESYNC]: propsys is now in sync with wine-staging wine-10.0 Co-authored-by: winesync <ros-dev@reactos.org> [PROPSYS] Remove duplicate uuid [PROPSYS] Fix headers/idl file
483 lines
13 KiB
C
483 lines
13 KiB
C
/*
|
|
* propsys main
|
|
*
|
|
* Copyright 1997, 2002 Alexandre Julliard
|
|
* Copyright 2008 James Hawkins
|
|
*
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
*/
|
|
|
|
#define COBJMACROS
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
#include "winbase.h"
|
|
#include "objbase.h"
|
|
#include "rpcproxy.h"
|
|
#include "propsys.h"
|
|
#include "wine/debug.h"
|
|
|
|
#include "propsys_private.h"
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
|
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
{
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
|
*ppv = iface;
|
|
}else if(IsEqualGUID(&IID_IClassFactory, riid)) {
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
|
|
*ppv = iface;
|
|
}
|
|
|
|
if(*ppv) {
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
return S_OK;
|
|
}
|
|
|
|
FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
|
|
return E_NOINTERFACE;
|
|
}
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
{
|
|
TRACE("(%p)\n", iface);
|
|
return 2;
|
|
}
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
{
|
|
TRACE("(%p)\n", iface);
|
|
return 1;
|
|
}
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
|
|
{
|
|
TRACE("(%p)->(%x)\n", iface, fLock);
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
static HRESULT WINAPI InMemoryPropertyStoreFactory_CreateInstance(IClassFactory *iface, IUnknown *outer,
|
|
REFIID riid, void **ppv)
|
|
{
|
|
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
|
|
|
|
return PropertyStore_CreateInstance(outer, riid, ppv);
|
|
}
|
|
|
|
static const IClassFactoryVtbl InMemoryPropertyStoreFactoryVtbl = {
|
|
ClassFactory_QueryInterface,
|
|
ClassFactory_AddRef,
|
|
ClassFactory_Release,
|
|
InMemoryPropertyStoreFactory_CreateInstance,
|
|
ClassFactory_LockServer
|
|
};
|
|
|
|
static IClassFactory InMemoryPropertyStoreFactory = { &InMemoryPropertyStoreFactoryVtbl };
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
{
|
|
if(IsEqualGUID(&CLSID_InMemoryPropertyStore, rclsid)) {
|
|
TRACE("(CLSID_InMemoryPropertyStore %s %p)\n", debugstr_guid(riid), ppv);
|
|
return IClassFactory_QueryInterface(&InMemoryPropertyStoreFactory, riid, ppv);
|
|
}
|
|
|
|
FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_QueryInterface(IPropertySystem *iface, REFIID riid, void **obj)
|
|
{
|
|
*obj = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IPropertySystem) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
*obj = iface;
|
|
IPropertySystem_AddRef(iface);
|
|
return S_OK;
|
|
}
|
|
|
|
FIXME("%s\n", debugstr_guid(riid));
|
|
return E_NOINTERFACE;
|
|
}
|
|
|
|
static ULONG WINAPI propsys_AddRef(IPropertySystem *iface)
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
static ULONG WINAPI propsys_Release(IPropertySystem *iface)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_GetPropertyDescription(IPropertySystem *iface,
|
|
REFPROPERTYKEY propkey, REFIID riid, void **ppv)
|
|
{
|
|
return PSGetPropertyDescription(propkey, riid, ppv);
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_GetPropertyDescriptionByName(IPropertySystem *iface,
|
|
LPCWSTR canonical_name, REFIID riid, void **ppv)
|
|
{
|
|
FIXME("%s %s %p: stub\n", debugstr_w(canonical_name), debugstr_guid(riid), ppv);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_GetPropertyDescriptionListFromString(IPropertySystem *iface,
|
|
LPCWSTR proplist, REFIID riid, void **ppv)
|
|
{
|
|
return PSGetPropertyDescriptionListFromString(proplist, riid, ppv);
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_EnumeratePropertyDescriptions(IPropertySystem *iface,
|
|
PROPDESC_ENUMFILTER filter, REFIID riid, void **ppv)
|
|
{
|
|
FIXME("%d %s %p: stub\n", filter, debugstr_guid(riid), ppv);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_FormatForDisplay(IPropertySystem *iface,
|
|
REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags,
|
|
LPWSTR dest, DWORD destlen)
|
|
{
|
|
FIXME("%p %p %x %p %ld: stub\n", key, propvar, flags, dest, destlen);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_FormatForDisplayAlloc(IPropertySystem *iface,
|
|
REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags,
|
|
LPWSTR *text)
|
|
{
|
|
FIXME("%p %p %x %p: stub\n", key, propvar, flags, text);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_RegisterPropertySchema(IPropertySystem *iface, LPCWSTR path)
|
|
{
|
|
return PSRegisterPropertySchema(path);
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_UnregisterPropertySchema(IPropertySystem *iface, LPCWSTR path)
|
|
{
|
|
return PSUnregisterPropertySchema(path);
|
|
}
|
|
|
|
static HRESULT WINAPI propsys_RefreshPropertySchema(IPropertySystem *iface)
|
|
{
|
|
return PSRefreshPropertySchema();
|
|
}
|
|
|
|
static const IPropertySystemVtbl propsysvtbl = {
|
|
propsys_QueryInterface,
|
|
propsys_AddRef,
|
|
propsys_Release,
|
|
propsys_GetPropertyDescription,
|
|
propsys_GetPropertyDescriptionByName,
|
|
propsys_GetPropertyDescriptionListFromString,
|
|
propsys_EnumeratePropertyDescriptions,
|
|
propsys_FormatForDisplay,
|
|
propsys_FormatForDisplayAlloc,
|
|
propsys_RegisterPropertySchema,
|
|
propsys_UnregisterPropertySchema,
|
|
propsys_RefreshPropertySchema
|
|
};
|
|
|
|
static IPropertySystem propsys = { &propsysvtbl };
|
|
|
|
HRESULT WINAPI PSGetPropertySystem(REFIID riid, void **obj)
|
|
{
|
|
return IPropertySystem_QueryInterface(&propsys, riid, obj);
|
|
}
|
|
|
|
HRESULT WINAPI PSRegisterPropertySchema(PCWSTR path)
|
|
{
|
|
FIXME("%s stub\n", debugstr_w(path));
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI PSUnregisterPropertySchema(PCWSTR path)
|
|
{
|
|
FIXME("%s stub\n", debugstr_w(path));
|
|
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
HRESULT WINAPI PSGetPropertyDescription(REFPROPERTYKEY propkey, REFIID riid, void **ppv)
|
|
{
|
|
FIXME("%p, %p, %p\n", propkey, riid, ppv);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
HRESULT WINAPI PSGetPropertyDescriptionListFromString(LPCWSTR proplist, REFIID riid, void **ppv)
|
|
{
|
|
FIXME("%s, %p, %p\n", debugstr_w(proplist), riid, ppv);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
HRESULT WINAPI PSGetPropertyKeyFromName(PCWSTR name, PROPERTYKEY *key)
|
|
{
|
|
FIXME("%s, %p\n", debugstr_w(name), key);
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
HRESULT WINAPI PSRefreshPropertySchema(void)
|
|
{
|
|
FIXME("\n");
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch)
|
|
{
|
|
WCHAR pidW[PKEY_PIDSTR_MAX + 1];
|
|
LPWSTR p = psz;
|
|
int len;
|
|
|
|
TRACE("(%p, %p, %u)\n", pkey, psz, cch);
|
|
|
|
if (!psz)
|
|
return E_POINTER;
|
|
|
|
/* GUIDSTRING_MAX accounts for null terminator, +1 for space character. */
|
|
if (cch <= GUIDSTRING_MAX + 1)
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
if (!pkey)
|
|
{
|
|
psz[0] = '\0';
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
}
|
|
|
|
swprintf(psz, cch, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", pkey->fmtid.Data1,
|
|
pkey->fmtid.Data2, pkey->fmtid.Data3, pkey->fmtid.Data4[0], pkey->fmtid.Data4[1],
|
|
pkey->fmtid.Data4[2], pkey->fmtid.Data4[3], pkey->fmtid.Data4[4],
|
|
pkey->fmtid.Data4[5], pkey->fmtid.Data4[6], pkey->fmtid.Data4[7]);
|
|
|
|
/* Overwrite the null terminator with the space character. */
|
|
p += GUIDSTRING_MAX - 1;
|
|
*p++ = ' ';
|
|
cch -= GUIDSTRING_MAX - 1 + 1;
|
|
|
|
len = swprintf(pidW, ARRAY_SIZE(pidW), L"%u", pkey->pid);
|
|
|
|
if (cch >= len + 1)
|
|
{
|
|
lstrcpyW(p, pidW);
|
|
return S_OK;
|
|
}
|
|
else
|
|
{
|
|
WCHAR *ptr = pidW + len - 1;
|
|
|
|
psz[0] = '\0';
|
|
*p++ = '\0';
|
|
cch--;
|
|
|
|
/* Replicate a quirk of the native implementation where the contents
|
|
* of the property ID string are written backwards to the output
|
|
* buffer, skipping the rightmost digit. */
|
|
if (cch)
|
|
{
|
|
ptr--;
|
|
while (cch--)
|
|
*p++ = *ptr--;
|
|
}
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
}
|
|
}
|
|
|
|
static const BYTE hex2bin[] =
|
|
{
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
|
|
0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
|
|
0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
|
|
0,10,11,12,13,14,15 /* 0x60 */
|
|
};
|
|
|
|
static BOOL validate_indices(LPCWSTR s, int min, int max)
|
|
{
|
|
int i;
|
|
|
|
for (i = min; i <= max; i++)
|
|
{
|
|
if (!s[i])
|
|
return FALSE;
|
|
|
|
if (i == 0)
|
|
{
|
|
if (s[i] != '{')
|
|
return FALSE;
|
|
}
|
|
else if (i == 9 || i == 14 || i == 19 || i == 24)
|
|
{
|
|
if (s[i] != '-')
|
|
return FALSE;
|
|
}
|
|
else if (i == 37)
|
|
{
|
|
if (s[i] != '}')
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0'))
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
/* Adapted from CLSIDFromString helper in dlls/ole32/compobj.c and
|
|
* UuidFromString in dlls/rpcrt4/rpcrt4_main.c. */
|
|
static BOOL string_to_guid(LPCWSTR s, LPGUID id)
|
|
{
|
|
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
|
|
|
|
if (!validate_indices(s, 0, 8)) return FALSE;
|
|
id->Data1 = (hex2bin[s[1]] << 28 | hex2bin[s[2]] << 24 | hex2bin[s[3]] << 20 | hex2bin[s[4]] << 16 |
|
|
hex2bin[s[5]] << 12 | hex2bin[s[6]] << 8 | hex2bin[s[7]] << 4 | hex2bin[s[8]]);
|
|
if (!validate_indices(s, 9, 14)) return FALSE;
|
|
id->Data2 = hex2bin[s[10]] << 12 | hex2bin[s[11]] << 8 | hex2bin[s[12]] << 4 | hex2bin[s[13]];
|
|
if (!validate_indices(s, 15, 19)) return FALSE;
|
|
id->Data3 = hex2bin[s[15]] << 12 | hex2bin[s[16]] << 8 | hex2bin[s[17]] << 4 | hex2bin[s[18]];
|
|
|
|
/* these are just sequential bytes */
|
|
|
|
if (!validate_indices(s, 20, 21)) return FALSE;
|
|
id->Data4[0] = hex2bin[s[20]] << 4 | hex2bin[s[21]];
|
|
if (!validate_indices(s, 22, 24)) return FALSE;
|
|
id->Data4[1] = hex2bin[s[22]] << 4 | hex2bin[s[23]];
|
|
|
|
if (!validate_indices(s, 25, 26)) return FALSE;
|
|
id->Data4[2] = hex2bin[s[25]] << 4 | hex2bin[s[26]];
|
|
if (!validate_indices(s, 27, 28)) return FALSE;
|
|
id->Data4[3] = hex2bin[s[27]] << 4 | hex2bin[s[28]];
|
|
if (!validate_indices(s, 29, 30)) return FALSE;
|
|
id->Data4[4] = hex2bin[s[29]] << 4 | hex2bin[s[30]];
|
|
if (!validate_indices(s, 31, 32)) return FALSE;
|
|
id->Data4[5] = hex2bin[s[31]] << 4 | hex2bin[s[32]];
|
|
if (!validate_indices(s, 33, 34)) return FALSE;
|
|
id->Data4[6] = hex2bin[s[33]] << 4 | hex2bin[s[34]];
|
|
if (!validate_indices(s, 35, 37)) return FALSE;
|
|
id->Data4[7] = hex2bin[s[35]] << 4 | hex2bin[s[36]];
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
|
|
{
|
|
BOOL has_minus = FALSE, has_comma = FALSE;
|
|
|
|
TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
|
|
|
|
if (!pszString || !pkey)
|
|
return E_POINTER;
|
|
|
|
memset(pkey, 0, sizeof(PROPERTYKEY));
|
|
|
|
if (!string_to_guid(pszString, &pkey->fmtid))
|
|
return E_INVALIDARG;
|
|
|
|
pszString += GUIDSTRING_MAX - 1;
|
|
|
|
if (!*pszString)
|
|
return E_INVALIDARG;
|
|
|
|
/* Only the space seems to be recognized as whitespace. The comma is only
|
|
* recognized once and processing terminates if another comma is found. */
|
|
while (*pszString == ' ' || *pszString == ',')
|
|
{
|
|
if (*pszString == ',')
|
|
{
|
|
if (has_comma)
|
|
return S_OK;
|
|
else
|
|
has_comma = TRUE;
|
|
}
|
|
pszString++;
|
|
}
|
|
|
|
if (!*pszString)
|
|
return E_INVALIDARG;
|
|
|
|
/* Only two minus signs are recognized if no comma is detected. The first
|
|
* sign is ignored, and the second is interpreted. If a comma is detected
|
|
* before the minus sign, then only one minus sign counts, and property ID
|
|
* interpretation begins with the next character. */
|
|
if (has_comma)
|
|
{
|
|
if (*pszString == '-')
|
|
{
|
|
has_minus = TRUE;
|
|
pszString++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (*pszString == '-')
|
|
pszString++;
|
|
|
|
/* Skip any intermediate spaces after the first minus sign. */
|
|
while (*pszString == ' ')
|
|
pszString++;
|
|
|
|
if (*pszString == '-')
|
|
{
|
|
has_minus = TRUE;
|
|
pszString++;
|
|
}
|
|
|
|
/* Skip any remaining spaces after minus sign. */
|
|
while (*pszString == ' ')
|
|
pszString++;
|
|
}
|
|
|
|
/* Overflow is not checked. */
|
|
while ('0' <= *pszString && *pszString <= '9')
|
|
{
|
|
pkey->pid *= 10;
|
|
pkey->pid += (*pszString - '0');
|
|
pszString++;
|
|
}
|
|
|
|
if (has_minus)
|
|
pkey->pid = ~pkey->pid + 1;
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv)
|
|
{
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
return PropertyStore_CreateInstance(NULL, riid, ppv);
|
|
}
|
|
|
|
#ifdef __REACTOS__
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
{
|
|
return S_FALSE;
|
|
}
|
|
#endif
|