1 /*
2 * OLEAUT32
3 *
4 * Copyright 1999, 2000 Marcus Meissner
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdarg.h>
22 #include <string.h>
23 #include <limits.h>
24
25 #define COBJMACROS
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
32
33 #include "ole2.h"
34 #include "olectl.h"
35 #include "oleauto.h"
36 #include "typelib.h"
37
38 #include "wine/debug.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(ole);
41
42 static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */
43
44 /******************************************************************************
45 * BSTR {OLEAUT32}
46 *
47 * NOTES
48 * BSTR is a simple typedef for a wide-character string used as the principle
49 * string type in ole automation. When encapsulated in a Variant type they are
50 * automatically copied and destroyed as the variant is processed.
51 *
52 * The low level BSTR Api allows manipulation of these strings and is used by
53 * higher level Api calls to manage the strings transparently to the caller.
54 *
55 * Internally the BSTR type is allocated with space for a DWORD byte count before
56 * the string data begins. This is undocumented and non-system code should not
57 * access the count directly. Use SysStringLen() or SysStringByteLen()
58 * instead. Note that the byte count does not include the terminating NUL.
59 *
60 * To create a new BSTR, use SysAllocString(), SysAllocStringLen() or
61 * SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString()
62 * or SysReAllocStringLen(). Finally to destroy a string use SysFreeString().
63 *
64 * BSTR's are cached by Ole Automation by default. To override this behaviour
65 * either set the environment variable 'OANOCACHE', or call SetOaNoCache().
66 *
67 * SEE ALSO
68 * 'Inside OLE, second edition' by Kraig Brockshmidt.
69 */
70
71 /******************************************************************************
72 * SysStringLen [OLEAUT32.7]
73 *
74 * Get the allocated length of a BSTR in wide characters.
75 *
76 * PARAMS
77 * str [I] BSTR to find the length of
78 *
79 * RETURNS
80 * The allocated length of str, or 0 if str is NULL.
81 *
82 * NOTES
83 * See BSTR.
84 * The returned length may be different from the length of the string as
85 * calculated by lstrlenW(), since it returns the length that was used to
86 * allocate the string by SysAllocStringLen().
87 */
88 UINT WINAPI SysStringLen(BSTR str)
89 {
90 DWORD* bufferPointer;
91
92 if (!str) return 0;
93 /*
94 * The length of the string (in bytes) is contained in a DWORD placed
95 * just before the BSTR pointer
96 */
97 bufferPointer = (DWORD*)str;
98
99 bufferPointer--;
100
101 return (int)(*bufferPointer/sizeof(WCHAR));
102 }
103
104 /******************************************************************************
105 * SysStringByteLen [OLEAUT32.149]
106 *
107 * Get the allocated length of a BSTR in bytes.
108 *
109 * PARAMS
110 * str [I] BSTR to find the length of
111 *
112 * RETURNS
113 * The allocated length of str, or 0 if str is NULL.
114 *
115 * NOTES
116 * See SysStringLen(), BSTR().
117 */
118 UINT WINAPI SysStringByteLen(BSTR str)
119 {
120 DWORD* bufferPointer;
121
122 if (!str) return 0;
123 /*
124 * The length of the string (in bytes) is contained in a DWORD placed
125 * just before the BSTR pointer
126 */
127 bufferPointer = (DWORD*)str;
128
129 bufferPointer--;
130
131 return (int)(*bufferPointer);
132 }
133
134 /******************************************************************************
135 * SysAllocString [OLEAUT32.2]
136 *
137 * Create a BSTR from an OLESTR.
138 *
139 * PARAMS
140 * str [I] Source to create BSTR from
141 *
142 * RETURNS
143 * Success: A BSTR allocated with SysAllocStringLen().
144 * Failure: NULL, if oleStr is NULL.
145 *
146 * NOTES
147 * See BSTR.
148 * MSDN (October 2001) incorrectly states that NULL is returned if oleStr has
149 * a length of 0. Native Win32 and this implementation both return a valid
150 * empty BSTR in this case.
151 */
152 BSTR WINAPI SysAllocString(LPCOLESTR str)
153 {
154 if (!str) return 0;
155
156 /* Delegate this to the SysAllocStringLen32 method. */
157 return SysAllocStringLen(str, lstrlenW(str));
158 }
159
160 /******************************************************************************
161 * SysFreeString [OLEAUT32.6]
162 *
163 * Free a BSTR.
164 *
165 * PARAMS
166 * str [I] BSTR to free.
167 *
168 * RETURNS
169 * Nothing.
170 *
171 * NOTES
172 * See BSTR.
173 * str may be NULL, in which case this function does nothing.
174 */
175 void WINAPI SysFreeString(BSTR str)
176 {
177 DWORD* bufferPointer;
178
179 /* NULL is a valid parameter */
180 if(!str) return;
181
182 /*
183 * We have to be careful when we free a BSTR pointer, it points to
184 * the beginning of the string but it skips the byte count contained
185 * before the string.
186 */
187 bufferPointer = (DWORD*)str;
188
189 bufferPointer--;
190
191 /*
192 * Free the memory from its "real" origin.
193 */
194 HeapFree(GetProcessHeap(), 0, bufferPointer);
195 }
196
197 /******************************************************************************
198 * SysAllocStringLen [OLEAUT32.4]
199 *
200 * Create a BSTR from an OLESTR of a given wide character length.
201 *
202 * PARAMS
203 * str [I] Source to create BSTR from
204 * len [I] Length of oleStr in wide characters
205 *
206 * RETURNS
207 * Success: A newly allocated BSTR from SysAllocStringByteLen()
208 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
209 *
210 * NOTES
211 * See BSTR(), SysAllocStringByteLen().
212 */
213 BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
214 {
215 DWORD bufferSize;
216 DWORD* newBuffer;
217 WCHAR* stringBuffer;
218
219 /* Detect integer overflow. */
220 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
221 return NULL;
222 /*
223 * Find the length of the buffer passed-in, in bytes.
224 */
225 bufferSize = len * sizeof (WCHAR);
226
227 /*
228 * Allocate a new buffer to hold the string.
229 * don't forget to keep an empty spot at the beginning of the
230 * buffer for the character count and an extra character at the
231 * end for the NULL.
232 */
233 newBuffer = HeapAlloc(GetProcessHeap(), 0,
234 bufferSize + sizeof(WCHAR) + sizeof(DWORD));
235
236 /*
237 * If the memory allocation failed, return a null pointer.
238 */
239 if (!newBuffer)
240 return NULL;
241
242 /*
243 * Copy the length of the string in the placeholder.
244 */
245 *newBuffer = bufferSize;
246
247 /*
248 * Skip the byte count.
249 */
250 newBuffer++;
251
252 /*
253 * Copy the information in the buffer.
254 * Since it is valid to pass a NULL pointer here, we'll initialize the
255 * buffer to nul if it is the case.
256 */
257 if (str != 0)
258 memcpy(newBuffer, str, bufferSize);
259 else
260 memset(newBuffer, 0, bufferSize);
261
262 /*
263 * Make sure that there is a nul character at the end of the
264 * string.
265 */
266 stringBuffer = (WCHAR*)newBuffer;
267 stringBuffer[len] = '\0';
268
269 return stringBuffer;
270 }
271
272 /******************************************************************************
273 * SysReAllocStringLen [OLEAUT32.5]
274 *
275 * Change the length of a previously created BSTR.
276 *
277 * PARAMS
278 * old [O] BSTR to change the length of
279 * str [I] New source for pbstr
280 * len [I] Length of oleStr in wide characters
281 *
282 * RETURNS
283 * Success: 1. The size of pbstr is updated.
284 * Failure: 0, if len >= 0x80000000 or memory allocation fails.
285 *
286 * NOTES
287 * See BSTR(), SysAllocStringByteLen().
288 * *old may be changed by this function.
289 */
290 int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
291 {
292 /* Detect integer overflow. */
293 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
294 return 0;
295
296 if (*old!=NULL) {
297 DWORD newbytelen = len*sizeof(WCHAR);
298 DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
299 *old = (BSTR)(ptr+1);
300 *ptr = newbytelen;
301 /* Subtle hidden feature: The old string data is still there
302 * when 'in' is NULL!
303 * Some Microsoft program needs it.
304 */
305 if (str) memmove(*old, str, newbytelen);
306 (*old)[len] = 0;
307 } else {
308 /*
309 * Allocate the new string
310 */
311 *old = SysAllocStringLen(str, len);
312 }
313
314 return 1;
315 }
316
317 /******************************************************************************
318 * SysAllocStringByteLen [OLEAUT32.150]
319 *
320 * Create a BSTR from an OLESTR of a given byte length.
321 *
322 * PARAMS
323 * str [I] Source to create BSTR from
324 * len [I] Length of oleStr in bytes
325 *
326 * RETURNS
327 * Success: A newly allocated BSTR
328 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
329 *
330 * NOTES
331 * -If len is 0 or oleStr is NULL the resulting string is empty ("").
332 * -This function always NUL terminates the resulting BSTR.
333 * -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied
334 * without checking for a terminating NUL.
335 * See BSTR.
336 */
337 BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len)
338 {
339 DWORD* newBuffer;
340 char* stringBuffer;
341
342 /* Detect integer overflow. */
343 if (len >= (UINT_MAX-sizeof(WCHAR)-sizeof(DWORD)))
344 return NULL;
345
346 /*
347 * Allocate a new buffer to hold the string.
348 * don't forget to keep an empty spot at the beginning of the
349 * buffer for the character count and an extra character at the
350 * end for the NULL.
351 */
352 newBuffer = HeapAlloc(GetProcessHeap(), 0,
353 len + sizeof(WCHAR) + sizeof(DWORD));
354
355 /*
356 * If the memory allocation failed, return a null pointer.
357 */
358 if (newBuffer==0)
359 return 0;
360
361 /*
362 * Copy the length of the string in the placeholder.
363 */
364 *newBuffer = len;
365
366 /*
367 * Skip the byte count.
368 */
369 newBuffer++;
370
371 /*
372 * Copy the information in the buffer.
373 * Since it is valid to pass a NULL pointer here, we'll initialize the
374 * buffer to nul if it is the case.
375 */
376 if (str != 0)
377 memcpy(newBuffer, str, len);
378
379 /*
380 * Make sure that there is a nul character at the end of the
381 * string.
382 */
383 stringBuffer = (char *)newBuffer;
384 stringBuffer[len] = 0;
385 stringBuffer[len+1] = 0;
386
387 return (LPWSTR)stringBuffer;
388 }
389
390 /******************************************************************************
391 * SysReAllocString [OLEAUT32.3]
392 *
393 * Change the length of a previously created BSTR.
394 *
395 * PARAMS
396 * old [I/O] BSTR to change the length of
397 * str [I] New source for pbstr
398 *
399 * RETURNS
400 * Success: 1
401 * Failure: 0.
402 *
403 * NOTES
404 * See BSTR(), SysAllocStringStringLen().
405 */
406 INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str)
407 {
408 /*
409 * Sanity check
410 */
411 if (old==NULL)
412 return 0;
413
414 /*
415 * Make sure we free the old string.
416 */
417 SysFreeString(*old);
418
419 /*
420 * Allocate the new string
421 */
422 *old = SysAllocString(str);
423
424 return 1;
425 }
426
427 /******************************************************************************
428 * SetOaNoCache (OLEAUT32.327)
429 *
430 * Instruct Ole Automation not to cache BSTR allocations.
431 *
432 * PARAMS
433 * None.
434 *
435 * RETURNS
436 * Nothing.
437 *
438 * NOTES
439 * See BSTR.
440 */
441 void WINAPI SetOaNoCache(void)
442 {
443 BSTR_bCache = FALSE;
444 }
445
446 static const WCHAR _delimiter[2] = {'!',0}; /* default delimiter apparently */
447 static const WCHAR *pdelimiter = &_delimiter[0];
448
449 /***********************************************************************
450 * RegisterActiveObject (OLEAUT32.33)
451 *
452 * Registers an object in the global item table.
453 *
454 * PARAMS
455 * punk [I] Object to register.
456 * rcid [I] CLSID of the object.
457 * dwFlags [I] Flags.
458 * pdwRegister [O] Address to store cookie of object registration in.
459 *
460 * RETURNS
461 * Success: S_OK.
462 * Failure: HRESULT code.
463 */
464 HRESULT WINAPI RegisterActiveObject(
465 LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
466 ) {
467 WCHAR guidbuf[80];
468 HRESULT ret;
469 LPRUNNINGOBJECTTABLE runobtable;
470 LPMONIKER moniker;
471
472 StringFromGUID2(rcid,guidbuf,39);
473 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
474 if (FAILED(ret))
475 return ret;
476 ret = GetRunningObjectTable(0,&runobtable);
477 if (FAILED(ret)) {
478 IMoniker_Release(moniker);
479 return ret;
480 }
481 ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister);
482 IRunningObjectTable_Release(runobtable);
483 IMoniker_Release(moniker);
484 return ret;
485 }
486
487 /***********************************************************************
488 * RevokeActiveObject (OLEAUT32.34)
489 *
490 * Revokes an object from the global item table.
491 *
492 * PARAMS
493 * xregister [I] Registration cookie.
494 * reserved [I] Reserved. Set to NULL.
495 *
496 * RETURNS
497 * Success: S_OK.
498 * Failure: HRESULT code.
499 */
500 HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved)
501 {
502 LPRUNNINGOBJECTTABLE runobtable;
503 HRESULT ret;
504
505 ret = GetRunningObjectTable(0,&runobtable);
506 if (FAILED(ret)) return ret;
507 ret = IRunningObjectTable_Revoke(runobtable,xregister);
508 if (SUCCEEDED(ret)) ret = S_OK;
509 IRunningObjectTable_Release(runobtable);
510 return ret;
511 }
512
513 /***********************************************************************
514 * GetActiveObject (OLEAUT32.35)
515 *
516 * Gets an object from the global item table.
517 *
518 * PARAMS
519 * rcid [I] CLSID of the object.
520 * preserved [I] Reserved. Set to NULL.
521 * ppunk [O] Address to store object into.
522 *
523 * RETURNS
524 * Success: S_OK.
525 * Failure: HRESULT code.
526 */
527 HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
528 {
529 WCHAR guidbuf[80];
530 HRESULT ret;
531 LPRUNNINGOBJECTTABLE runobtable;
532 LPMONIKER moniker;
533
534 StringFromGUID2(rcid,guidbuf,39);
535 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
536 if (FAILED(ret))
537 return ret;
538 ret = GetRunningObjectTable(0,&runobtable);
539 if (FAILED(ret)) {
540 IMoniker_Release(moniker);
541 return ret;
542 }
543 ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
544 IRunningObjectTable_Release(runobtable);
545 IMoniker_Release(moniker);
546 return ret;
547 }
548
549
550 /***********************************************************************
551 * OaBuildVersion [OLEAUT32.170]
552 *
553 * Get the Ole Automation build version.
554 *
555 * PARAMS
556 * None
557 *
558 * RETURNS
559 * The build version.
560 *
561 * NOTES
562 * Known oleaut32.dll versions:
563 *| OLE Ver. Comments Date Build Ver.
564 *| -------- ------------------------- ---- ---------
565 *| OLE 2.1 NT 1993-95 10 3023
566 *| OLE 2.1 10 3027
567 *| Win32s Ver 1.1e 20 4049
568 *| OLE 2.20 W95/NT 1993-96 20 4112
569 *| OLE 2.20 W95/NT 1993-96 20 4118
570 *| OLE 2.20 W95/NT 1993-96 20 4122
571 *| OLE 2.30 W95/NT 1993-98 30 4265
572 *| OLE 2.40 NT?? 1993-98 40 4267
573 *| OLE 2.40 W98 SE orig. file 1993-98 40 4275
574 *| OLE 2.40 W2K orig. file 1993-XX 40 4514
575 *
576 * Currently the versions returned are 2.20 for Win3.1, 2.30 for Win95 & NT 3.51,
577 * and 2.40 for all later versions. The build number is maximum, i.e. 0xffff.
578 */
579 ULONG WINAPI OaBuildVersion(void)
580 {
581 switch(GetVersion() & 0x8000ffff) /* mask off build number */
582 {
583 case 0x80000a03: /* WIN31 */
584 return MAKELONG(0xffff, 20);
585 case 0x00003303: /* NT351 */
586 return MAKELONG(0xffff, 30);
587 case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor
588 version here (30), but as we still use w95
589 as default winver (which is good IMHO), I better
590 play safe and use the latest value for w95 for now.
591 Change this as soon as default winver gets changed
592 to something more recent */
593 case 0x80000a04: /* WIN98 */
594 case 0x00000004: /* NT40 */
595 case 0x00000005: /* W2K */
596 case 0x00000105: /* WinXP */
597 return MAKELONG(0xffff, 40);
598 default:
599 FIXME("Version value not known yet. Please investigate it !\n");
600 return MAKELONG(0xffff, 40); /* for now return the same value as for w2k */
601 }
602 }
603
604 /******************************************************************************
605 * OleTranslateColor [OLEAUT32.421]
606 *
607 * Convert an OLE_COLOR to a COLORREF.
608 *
609 * PARAMS
610 * clr [I] Color to convert
611 * hpal [I] Handle to a palette for the conversion
612 * pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok
613 *
614 * RETURNS
615 * Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL.
616 * Failure: E_INVALIDARG, if any argument is invalid.
617 *
618 * FIXME
619 * Document the conversion rules.
620 */
621 HRESULT WINAPI OleTranslateColor(
622 OLE_COLOR clr,
623 HPALETTE hpal,
624 COLORREF* pColorRef)
625 {
626 COLORREF colorref;
627 BYTE b = HIBYTE(HIWORD(clr));
628
629 TRACE("(%08x, %p, %p)\n", clr, hpal, pColorRef);
630
631 /*
632 * In case pColorRef is NULL, provide our own to simplify the code.
633 */
634 if (pColorRef == NULL)
635 pColorRef = &colorref;
636
637 switch (b)
638 {
639 case 0x00:
640 {
641 if (hpal != 0)
642 *pColorRef = PALETTERGB(GetRValue(clr),
643 GetGValue(clr),
644 GetBValue(clr));
645 else
646 *pColorRef = clr;
647
648 break;
649 }
650
651 case 0x01:
652 {
653 if (hpal != 0)
654 {
655 PALETTEENTRY pe;
656 /*
657 * Validate the palette index.
658 */
659 if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0)
660 return E_INVALIDARG;
661 }
662
663 *pColorRef = clr;
664
665 break;
666 }
667
668 case 0x02:
669 *pColorRef = clr;
670 break;
671
672 case 0x80:
673 {
674 int index = LOBYTE(LOWORD(clr));
675
676 /*
677 * Validate GetSysColor index.
678 */
679 if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR))
680 return E_INVALIDARG;
681
682 *pColorRef = GetSysColor(index);
683
684 break;
685 }
686
687 default:
688 return E_INVALIDARG;
689 }
690
691 return S_OK;
692 }
693
694 extern HRESULT WINAPI OLEAUTPS_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
695 extern BOOL WINAPI OLEAUTPS_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
696 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
697
698 extern void _get_STDFONT_CF(LPVOID *);
699 extern void _get_STDPIC_CF(LPVOID *);
700
701 static HRESULT WINAPI PSDispatchFacBuf_QueryInterface(IPSFactoryBuffer *iface, REFIID riid, void **ppv)
702 {
703 if (IsEqualIID(riid, &IID_IUnknown) ||
704 IsEqualIID(riid, &IID_IPSFactoryBuffer))
705 {
706 IUnknown_AddRef(iface);
707 *ppv = iface;
708 return S_OK;
709 }
710 return E_NOINTERFACE;
711 }
712
713 static ULONG WINAPI PSDispatchFacBuf_AddRef(IPSFactoryBuffer *iface)
714 {
715 return 2;
716 }
717
718 static ULONG WINAPI PSDispatchFacBuf_Release(IPSFactoryBuffer *iface)
719 {
720 return 1;
721 }
722
723 static HRESULT WINAPI PSDispatchFacBuf_CreateProxy(IPSFactoryBuffer *iface, IUnknown *pUnkOuter, REFIID riid, IRpcProxyBuffer **ppProxy, void **ppv)
724 {
725 IPSFactoryBuffer *pPSFB;
726 HRESULT hr;
727
728 if (IsEqualIID(riid, &IID_IDispatch))
729 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB);
730 else
731 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB);
732
733 if (FAILED(hr)) return hr;
734
735 hr = IPSFactoryBuffer_CreateProxy(pPSFB, pUnkOuter, riid, ppProxy, ppv);
736
737 IPSFactoryBuffer_Release(pPSFB);
738 return hr;
739 }
740
741 static HRESULT WINAPI PSDispatchFacBuf_CreateStub(IPSFactoryBuffer *iface, REFIID riid, IUnknown *pUnkOuter, IRpcStubBuffer **ppStub)
742 {
743 IPSFactoryBuffer *pPSFB;
744 HRESULT hr;
745
746 if (IsEqualIID(riid, &IID_IDispatch))
747 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB);
748 else
749 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB);
750
751 if (FAILED(hr)) return hr;
752
753 hr = IPSFactoryBuffer_CreateStub(pPSFB, riid, pUnkOuter, ppStub);
754
755 IPSFactoryBuffer_Release(pPSFB);
756 return hr;
757 }
758
759 static const IPSFactoryBufferVtbl PSDispatchFacBuf_Vtbl =
760 {
761 PSDispatchFacBuf_QueryInterface,
762 PSDispatchFacBuf_AddRef,
763 PSDispatchFacBuf_Release,
764 PSDispatchFacBuf_CreateProxy,
765 PSDispatchFacBuf_CreateStub
766 };
767
768 /* This is the whole PSFactoryBuffer object, just the vtableptr */
769 static const IPSFactoryBufferVtbl *pPSDispatchFacBuf = &PSDispatchFacBuf_Vtbl;
770
771 /***********************************************************************
772 * DllGetClassObject (OLEAUT32.@)
773 */
774 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
775 {
776 *ppv = NULL;
777 if (IsEqualGUID(rclsid,&CLSID_StdFont)) {
778 if (IsEqualGUID(iid,&IID_IClassFactory)) {
779 _get_STDFONT_CF(ppv);
780 IClassFactory_AddRef((IClassFactory*)*ppv);
781 return S_OK;
782 }
783 }
784 if (IsEqualGUID(rclsid,&CLSID_StdPicture)) {
785 if (IsEqualGUID(iid,&IID_IClassFactory)) {
786 _get_STDPIC_CF(ppv);
787 IClassFactory_AddRef((IClassFactory*)*ppv);
788 return S_OK;
789 }
790 }
791 if (IsEqualCLSID(rclsid, &CLSID_PSDispatch) && IsEqualIID(iid, &IID_IPSFactoryBuffer)) {
792 *ppv = &pPSDispatchFacBuf;
793 IPSFactoryBuffer_AddRef((IPSFactoryBuffer *)*ppv);
794 return S_OK;
795 }
796 if (IsEqualGUID(rclsid,&CLSID_PSOAInterface)) {
797 if (S_OK==TMARSHAL_DllGetClassObject(rclsid,iid,ppv))
798 return S_OK;
799 /*FALLTHROUGH*/
800 }
801 if (IsEqualCLSID(rclsid, &CLSID_PSTypeInfo) ||
802 IsEqualCLSID(rclsid, &CLSID_PSTypeLib) ||
803 IsEqualCLSID(rclsid, &CLSID_PSDispatch) ||
804 IsEqualCLSID(rclsid, &CLSID_PSEnumVariant))
805 return OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, iid, ppv);
806
807 return OLEAUTPS_DllGetClassObject(rclsid, iid, ppv);
808 }
809
810 /***********************************************************************
811 * DllCanUnloadNow (OLEAUT32.@)
812 *
813 * Determine if this dll can be unloaded from the callers address space.
814 *
815 * PARAMS
816 * None.
817 *
818 * RETURNS
819 * Always returns S_FALSE. This dll cannot be unloaded.
820 */
821 HRESULT WINAPI DllCanUnloadNow(void)
822 {
823 return S_FALSE;
824 }
825
826 /*****************************************************************************
827 * DllMain [OLEAUT32.@]
828 */
829 BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
830 {
831 return OLEAUTPS_DllMain( hInstDll, fdwReason, lpvReserved );
832 }
833
834 /***********************************************************************
835 * OleIconToCursor (OLEAUT32.415)
836 */
837 HCURSOR WINAPI OleIconToCursor( HINSTANCE hinstExe, HICON hIcon)
838 {
839 FIXME("(%p,%p), partially implemented.\n",hinstExe,hIcon);
840 /* FIXME: make a extended conversation from HICON to HCURSOR */
841 return CopyCursor(hIcon);
842 }
843
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.