ReactOS 0.4.16-dev-983-g23ad936
propsys_main.c
Go to the documentation of this file.
1/*
2 * propsys main
3 *
4 * Copyright 1997, 2002 Alexandre Julliard
5 * Copyright 2008 James Hawkins
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#define COBJMACROS
23
24#include <stdarg.h>
25
26#include "windef.h"
27#include "winbase.h"
28#include "objbase.h"
29#include "rpcproxy.h"
30#include "propsys.h"
31#include "wine/debug.h"
32
33#include "propsys_private.h"
34
36
38{
39 *ppv = NULL;
40
42 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
43 *ppv = iface;
45 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
46 *ppv = iface;
47 }
48
49 if(*ppv) {
50 IUnknown_AddRef((IUnknown*)*ppv);
51 return S_OK;
52 }
53
54 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
55 return E_NOINTERFACE;
56}
57
59{
60 TRACE("(%p)\n", iface);
61 return 2;
62}
63
65{
66 TRACE("(%p)\n", iface);
67 return 1;
68}
69
71{
72 TRACE("(%p)->(%x)\n", iface, fLock);
73
74 return S_OK;
75}
76
78 REFIID riid, void **ppv)
79{
80 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
81
83}
84
85static const IClassFactoryVtbl InMemoryPropertyStoreFactoryVtbl = {
91};
92
94
96{
97 if(IsEqualGUID(&CLSID_InMemoryPropertyStore, rclsid)) {
98 TRACE("(CLSID_InMemoryPropertyStore %s %p)\n", debugstr_guid(riid), ppv);
99 return IClassFactory_QueryInterface(&InMemoryPropertyStoreFactory, riid, ppv);
100 }
101
102 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
104}
105
107{
108 *obj = NULL;
109
110 if (IsEqualIID(riid, &IID_IPropertySystem) || IsEqualIID(riid, &IID_IUnknown)) {
111 *obj = iface;
112 IPropertySystem_AddRef(iface);
113 return S_OK;
114 }
115
116 FIXME("%s\n", debugstr_guid(riid));
117 return E_NOINTERFACE;
118}
119
121{
122 return 2;
123}
124
126{
127 return 1;
128}
129
131 REFPROPERTYKEY propkey, REFIID riid, void **ppv)
132{
133 return PSGetPropertyDescription(propkey, riid, ppv);
134}
135
137 LPCWSTR canonical_name, REFIID riid, void **ppv)
138{
139 FIXME("%s %s %p: stub\n", debugstr_w(canonical_name), debugstr_guid(riid), ppv);
140 return E_NOTIMPL;
141}
142
144 LPCWSTR proplist, REFIID riid, void **ppv)
145{
147}
148
151{
152 FIXME("%d %s %p: stub\n", filter, debugstr_guid(riid), ppv);
153 return E_NOTIMPL;
154}
155
157 REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags,
158 LPWSTR dest, DWORD destlen)
159{
160 FIXME("%p %p %x %p %ld: stub\n", key, propvar, flags, dest, destlen);
161 return E_NOTIMPL;
162}
163
165 REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags,
166 LPWSTR *text)
167{
168 FIXME("%p %p %x %p: stub\n", key, propvar, flags, text);
169 return E_NOTIMPL;
170}
171
173{
175}
176
178{
180}
181
183{
185}
186
187static const IPropertySystemVtbl propsysvtbl = {
200};
201
203
205{
206 return IPropertySystem_QueryInterface(&propsys, riid, obj);
207}
208
210{
211 FIXME("%s stub\n", debugstr_w(path));
212
213 return S_OK;
214}
215
217{
218 FIXME("%s stub\n", debugstr_w(path));
219
220 return E_NOTIMPL;
221}
222
224{
225 FIXME("%p, %p, %p\n", propkey, riid, ppv);
226 return E_NOTIMPL;
227}
228
230{
231 FIXME("%s, %p, %p\n", debugstr_w(proplist), riid, ppv);
232 return E_NOTIMPL;
233}
234
236{
237 FIXME("%s, %p\n", debugstr_w(name), key);
238 return E_NOTIMPL;
239}
240
242{
243 FIXME("\n");
244 return S_OK;
245}
246
248{
249 WCHAR pidW[PKEY_PIDSTR_MAX + 1];
250 LPWSTR p = psz;
251 int len;
252
253 TRACE("(%p, %p, %u)\n", pkey, psz, cch);
254
255 if (!psz)
256 return E_POINTER;
257
258 /* GUIDSTRING_MAX accounts for null terminator, +1 for space character. */
259 if (cch <= GUIDSTRING_MAX + 1)
261
262 if (!pkey)
263 {
264 psz[0] = '\0';
266 }
267
268 swprintf(psz, cch, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", pkey->fmtid.Data1,
269 pkey->fmtid.Data2, pkey->fmtid.Data3, pkey->fmtid.Data4[0], pkey->fmtid.Data4[1],
270 pkey->fmtid.Data4[2], pkey->fmtid.Data4[3], pkey->fmtid.Data4[4],
271 pkey->fmtid.Data4[5], pkey->fmtid.Data4[6], pkey->fmtid.Data4[7]);
272
273 /* Overwrite the null terminator with the space character. */
274 p += GUIDSTRING_MAX - 1;
275 *p++ = ' ';
276 cch -= GUIDSTRING_MAX - 1 + 1;
277
278 len = swprintf(pidW, ARRAY_SIZE(pidW), L"%u", pkey->pid);
279
280 if (cch >= len + 1)
281 {
282 lstrcpyW(p, pidW);
283 return S_OK;
284 }
285 else
286 {
287 WCHAR *ptr = pidW + len - 1;
288
289 psz[0] = '\0';
290 *p++ = '\0';
291 cch--;
292
293 /* Replicate a quirk of the native implementation where the contents
294 * of the property ID string are written backwards to the output
295 * buffer, skipping the rightmost digit. */
296 if (cch)
297 {
298 ptr--;
299 while (cch--)
300 *p++ = *ptr--;
301 }
302
304 }
305}
306
307static const BYTE hex2bin[] =
308{
309 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
310 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
311 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
312 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
313 0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
314 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
315 0,10,11,12,13,14,15 /* 0x60 */
316};
317
319{
320 int i;
321
322 for (i = min; i <= max; i++)
323 {
324 if (!s[i])
325 return FALSE;
326
327 if (i == 0)
328 {
329 if (s[i] != '{')
330 return FALSE;
331 }
332 else if (i == 9 || i == 14 || i == 19 || i == 24)
333 {
334 if (s[i] != '-')
335 return FALSE;
336 }
337 else if (i == 37)
338 {
339 if (s[i] != '}')
340 return FALSE;
341 }
342 else
343 {
344 if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0'))
345 return FALSE;
346 }
347 }
348
349 return TRUE;
350}
351
352/* Adapted from CLSIDFromString helper in dlls/ole32/compobj.c and
353 * UuidFromString in dlls/rpcrt4/rpcrt4_main.c. */
355{
356 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
357
358 if (!validate_indices(s, 0, 8)) return FALSE;
359 id->Data1 = (hex2bin[s[1]] << 28 | hex2bin[s[2]] << 24 | hex2bin[s[3]] << 20 | hex2bin[s[4]] << 16 |
360 hex2bin[s[5]] << 12 | hex2bin[s[6]] << 8 | hex2bin[s[7]] << 4 | hex2bin[s[8]]);
361 if (!validate_indices(s, 9, 14)) return FALSE;
362 id->Data2 = hex2bin[s[10]] << 12 | hex2bin[s[11]] << 8 | hex2bin[s[12]] << 4 | hex2bin[s[13]];
363 if (!validate_indices(s, 15, 19)) return FALSE;
364 id->Data3 = hex2bin[s[15]] << 12 | hex2bin[s[16]] << 8 | hex2bin[s[17]] << 4 | hex2bin[s[18]];
365
366 /* these are just sequential bytes */
367
368 if (!validate_indices(s, 20, 21)) return FALSE;
369 id->Data4[0] = hex2bin[s[20]] << 4 | hex2bin[s[21]];
370 if (!validate_indices(s, 22, 24)) return FALSE;
371 id->Data4[1] = hex2bin[s[22]] << 4 | hex2bin[s[23]];
372
373 if (!validate_indices(s, 25, 26)) return FALSE;
374 id->Data4[2] = hex2bin[s[25]] << 4 | hex2bin[s[26]];
375 if (!validate_indices(s, 27, 28)) return FALSE;
376 id->Data4[3] = hex2bin[s[27]] << 4 | hex2bin[s[28]];
377 if (!validate_indices(s, 29, 30)) return FALSE;
378 id->Data4[4] = hex2bin[s[29]] << 4 | hex2bin[s[30]];
379 if (!validate_indices(s, 31, 32)) return FALSE;
380 id->Data4[5] = hex2bin[s[31]] << 4 | hex2bin[s[32]];
381 if (!validate_indices(s, 33, 34)) return FALSE;
382 id->Data4[6] = hex2bin[s[33]] << 4 | hex2bin[s[34]];
383 if (!validate_indices(s, 35, 37)) return FALSE;
384 id->Data4[7] = hex2bin[s[35]] << 4 | hex2bin[s[36]];
385
386 return TRUE;
387}
388
390{
391 BOOL has_minus = FALSE, has_comma = FALSE;
392
393 TRACE("(%s, %p)\n", debugstr_w(pszString), pkey);
394
395 if (!pszString || !pkey)
396 return E_POINTER;
397
398 memset(pkey, 0, sizeof(PROPERTYKEY));
399
400 if (!string_to_guid(pszString, &pkey->fmtid))
401 return E_INVALIDARG;
402
403 pszString += GUIDSTRING_MAX - 1;
404
405 if (!*pszString)
406 return E_INVALIDARG;
407
408 /* Only the space seems to be recognized as whitespace. The comma is only
409 * recognized once and processing terminates if another comma is found. */
410 while (*pszString == ' ' || *pszString == ',')
411 {
412 if (*pszString == ',')
413 {
414 if (has_comma)
415 return S_OK;
416 else
417 has_comma = TRUE;
418 }
419 pszString++;
420 }
421
422 if (!*pszString)
423 return E_INVALIDARG;
424
425 /* Only two minus signs are recognized if no comma is detected. The first
426 * sign is ignored, and the second is interpreted. If a comma is detected
427 * before the minus sign, then only one minus sign counts, and property ID
428 * interpretation begins with the next character. */
429 if (has_comma)
430 {
431 if (*pszString == '-')
432 {
433 has_minus = TRUE;
434 pszString++;
435 }
436 }
437 else
438 {
439 if (*pszString == '-')
440 pszString++;
441
442 /* Skip any intermediate spaces after the first minus sign. */
443 while (*pszString == ' ')
444 pszString++;
445
446 if (*pszString == '-')
447 {
448 has_minus = TRUE;
449 pszString++;
450 }
451
452 /* Skip any remaining spaces after minus sign. */
453 while (*pszString == ' ')
454 pszString++;
455 }
456
457 /* Overflow is not checked. */
458 while ('0' <= *pszString && *pszString <= '9')
459 {
460 pkey->pid *= 10;
461 pkey->pid += (*pszString - '0');
462 pszString++;
463 }
464
465 if (has_minus)
466 pkey->pid = ~pkey->pid + 1;
467
468 return S_OK;
469}
470
472{
473 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
474
476}
477
478#ifdef __REACTOS__
480{
481 return S_FALSE;
482}
483#endif
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
HRESULT WINAPI DllCanUnloadNow(void)
Definition: misc.cpp:154
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
const WCHAR * text
Definition: package.c:1794
HRESULT PropertyStore_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppv)
Definition: propstore.c:451
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static char * dest
Definition: rtl.c:135
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
PROPERTYKEY * REFPROPERTYKEY
Definition: propsys.idl:40
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: propsys_main.c:70
static IClassFactory InMemoryPropertyStoreFactory
Definition: propsys_main.c:93
static const BYTE hex2bin[]
Definition: propsys_main.c:307
HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
Definition: propsys_main.c:389
HRESULT WINAPI PSGetPropertyKeyFromName(PCWSTR name, PROPERTYKEY *key)
Definition: propsys_main.c:235
static IPropertySystem propsys
Definition: propsys_main.c:202
static HRESULT WINAPI propsys_GetPropertyDescriptionListFromString(IPropertySystem *iface, LPCWSTR proplist, REFIID riid, void **ppv)
Definition: propsys_main.c:143
HRESULT WINAPI PSUnregisterPropertySchema(PCWSTR path)
Definition: propsys_main.c:216
static HRESULT WINAPI propsys_RefreshPropertySchema(IPropertySystem *iface)
Definition: propsys_main.c:182
static ULONG WINAPI propsys_Release(IPropertySystem *iface)
Definition: propsys_main.c:125
static BOOL string_to_guid(LPCWSTR s, LPGUID id)
Definition: propsys_main.c:354
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: propsys_main.c:64
HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv)
Definition: propsys_main.c:471
HRESULT WINAPI PSGetPropertyDescription(REFPROPERTYKEY propkey, REFIID riid, void **ppv)
Definition: propsys_main.c:223
static HRESULT WINAPI propsys_FormatForDisplayAlloc(IPropertySystem *iface, REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags, LPWSTR *text)
Definition: propsys_main.c:164
static HRESULT WINAPI propsys_UnregisterPropertySchema(IPropertySystem *iface, LPCWSTR path)
Definition: propsys_main.c:177
static const IClassFactoryVtbl InMemoryPropertyStoreFactoryVtbl
Definition: propsys_main.c:85
static ULONG WINAPI propsys_AddRef(IPropertySystem *iface)
Definition: propsys_main.c:120
static const IPropertySystemVtbl propsysvtbl
Definition: propsys_main.c:187
HRESULT WINAPI PSRegisterPropertySchema(PCWSTR path)
Definition: propsys_main.c:209
static HRESULT WINAPI propsys_FormatForDisplay(IPropertySystem *iface, REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS flags, LPWSTR dest, DWORD destlen)
Definition: propsys_main.c:156
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: propsys_main.c:37
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: propsys_main.c:95
static HRESULT WINAPI propsys_RegisterPropertySchema(IPropertySystem *iface, LPCWSTR path)
Definition: propsys_main.c:172
HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch)
Definition: propsys_main.c:247
static HRESULT WINAPI propsys_GetPropertyDescriptionByName(IPropertySystem *iface, LPCWSTR canonical_name, REFIID riid, void **ppv)
Definition: propsys_main.c:136
HRESULT WINAPI PSGetPropertySystem(REFIID riid, void **obj)
Definition: propsys_main.c:204
HRESULT WINAPI PSRefreshPropertySchema(void)
Definition: propsys_main.c:241
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: propsys_main.c:58
static BOOL validate_indices(LPCWSTR s, int min, int max)
Definition: propsys_main.c:318
static HRESULT WINAPI propsys_EnumeratePropertyDescriptions(IPropertySystem *iface, PROPDESC_ENUMFILTER filter, REFIID riid, void **ppv)
Definition: propsys_main.c:149
static HRESULT WINAPI InMemoryPropertyStoreFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: propsys_main.c:77
HRESULT WINAPI PSGetPropertyDescriptionListFromString(LPCWSTR proplist, REFIID riid, void **ppv)
Definition: propsys_main.c:229
static HRESULT WINAPI propsys_QueryInterface(IPropertySystem *iface, REFIID riid, void **obj)
Definition: propsys_main.c:106
static HRESULT WINAPI propsys_GetPropertyDescription(IPropertySystem *iface, REFPROPERTYKEY propkey, REFIID riid, void **ppv)
Definition: propsys_main.c:130
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: copy.c:22
Definition: name.c:39
#define max(a, b)
Definition: svc.c:63
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193