1 /*
2 * 16 bit ole functions
3 *
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 Justin Bradford
6 * Copyright 1999 Francis Beaudet
7 * Copyright 1999 Sylvain St-Germain
8 * Copyright 2002 Marcus Meissner
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25 #include "config.h"
26
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <assert.h>
32
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winuser.h"
36 #include "objbase.h"
37 #include "ole2.h"
38 #include "rpc.h"
39 #include "winerror.h"
40 #include "winreg.h"
41 #include "wownt32.h"
42 #include "wtypes.h"
43 #include "wine/unicode.h"
44 #include "wine/winbase16.h"
45
46 #include "wine/debug.h"
47
48 WINE_DEFAULT_DEBUG_CHANNEL(ole);
49
50 typedef LPSTR LPOLESTR16;
51 typedef LPCSTR LPCOLESTR16;
52
53 #define STDMETHOD16CALLTYPE __cdecl
54 #define STDMETHOD16(m) HRESULT (STDMETHOD16CALLTYPE *m)
55 #define STDMETHOD16_(t,m) t (STDMETHOD16CALLTYPE *m)
56
57
58 /***********************************************************************
59 * IMalloc16 interface
60 */
61
62 typedef struct IMalloc16 *LPMALLOC16;
63
64 #define INTERFACE IMalloc16
65 DECLARE_INTERFACE_(IMalloc16,IUnknown)
66 {
67 /*** IUnknown methods ***/
68 STDMETHOD16_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
69 STDMETHOD16_(ULONG,AddRef)(THIS) PURE;
70 STDMETHOD16_(ULONG,Release)(THIS) PURE;
71 /*** IMalloc16 methods ***/
72 STDMETHOD16_(LPVOID,Alloc)(THIS_ DWORD cb) PURE;
73 STDMETHOD16_(LPVOID,Realloc)(THIS_ LPVOID pv, DWORD cb) PURE;
74 STDMETHOD16_(void,Free)(THIS_ LPVOID pv) PURE;
75 STDMETHOD16_(DWORD,GetSize)(THIS_ LPVOID pv) PURE;
76 STDMETHOD16_(INT16,DidAlloc)(THIS_ LPVOID pv) PURE;
77 STDMETHOD16_(LPVOID,HeapMinimize)(THIS) PURE;
78 };
79 #undef INTERFACE
80
81 static HTASK16 hETask = 0;
82 static WORD Table_ETask[62];
83
84 static LPMALLOC16 currentMalloc16=NULL;
85
86 /* --- IMalloc16 implementation */
87
88
89 typedef struct
90 {
91 /* IUnknown fields */
92 const IMalloc16Vtbl *lpVtbl;
93 DWORD ref;
94 /* IMalloc16 fields */
95 } IMalloc16Impl;
96
97 /******************************************************************************
98 * IMalloc16_QueryInterface [COMPOBJ.500]
99 */
100 HRESULT CDECL IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
101 IMalloc16Impl *This = (IMalloc16Impl *)iface;
102
103 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
104 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
105 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
106 ) {
107 *obj = This;
108 return 0;
109 }
110 return OLE_E_ENUM_NOMORE;
111 }
112
113 /******************************************************************************
114 * IMalloc16_AddRef [COMPOBJ.501]
115 */
116 ULONG CDECL IMalloc16_fnAddRef(IMalloc16* iface) {
117 IMalloc16Impl *This = (IMalloc16Impl *)iface;
118 TRACE("(%p)->AddRef()\n",This);
119 return 1; /* cannot be freed */
120 }
121
122 /******************************************************************************
123 * IMalloc16_Release [COMPOBJ.502]
124 */
125 ULONG CDECL IMalloc16_fnRelease(IMalloc16* iface) {
126 IMalloc16Impl *This = (IMalloc16Impl *)iface;
127 TRACE("(%p)->Release()\n",This);
128 return 1; /* cannot be freed */
129 }
130
131 /******************************************************************************
132 * IMalloc16_Alloc [COMPOBJ.503]
133 */
134 SEGPTR CDECL IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
135 IMalloc16Impl *This = (IMalloc16Impl *)iface;
136 TRACE("(%p)->Alloc(%d)\n",This,cb);
137 return MapLS( HeapAlloc( GetProcessHeap(), 0, cb ) );
138 }
139
140 /******************************************************************************
141 * IMalloc16_Free [COMPOBJ.505]
142 */
143 VOID CDECL IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
144 {
145 void *ptr = MapSL(pv);
146 IMalloc16Impl *This = (IMalloc16Impl *)iface;
147 TRACE("(%p)->Free(%08x)\n",This,pv);
148 UnMapLS(pv);
149 HeapFree( GetProcessHeap(), 0, ptr );
150 }
151
152 /******************************************************************************
153 * IMalloc16_Realloc [COMPOBJ.504]
154 */
155 SEGPTR CDECL IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
156 {
157 SEGPTR ret;
158 IMalloc16Impl *This = (IMalloc16Impl *)iface;
159 TRACE("(%p)->Realloc(%08x,%d)\n",This,pv,cb);
160 if (!pv)
161 ret = IMalloc16_fnAlloc(iface, cb);
162 else if (cb) {
163 ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) );
164 UnMapLS(pv);
165 } else {
166 IMalloc16_fnFree(iface, pv);
167 ret = 0;
168 }
169 return ret;
170 }
171
172 /******************************************************************************
173 * IMalloc16_GetSize [COMPOBJ.506]
174 */
175 DWORD CDECL IMalloc16_fnGetSize(IMalloc16* iface,SEGPTR pv)
176 {
177 IMalloc16Impl *This = (IMalloc16Impl *)iface;
178 TRACE("(%p)->GetSize(%08x)\n",This,pv);
179 return HeapSize( GetProcessHeap(), 0, MapSL(pv) );
180 }
181
182 /******************************************************************************
183 * IMalloc16_DidAlloc [COMPOBJ.507]
184 */
185 INT16 CDECL IMalloc16_fnDidAlloc(IMalloc16* iface,LPVOID pv) {
186 IMalloc16 *This = iface;
187 TRACE("(%p)->DidAlloc(%p)\n",This,pv);
188 return (INT16)-1;
189 }
190
191 /******************************************************************************
192 * IMalloc16_HeapMinimize [COMPOBJ.508]
193 */
194 LPVOID CDECL IMalloc16_fnHeapMinimize(IMalloc16* iface) {
195 IMalloc16Impl *This = (IMalloc16Impl *)iface;
196 TRACE("(%p)->HeapMinimize()\n",This);
197 return NULL;
198 }
199
200 /******************************************************************************
201 * IMalloc16_Constructor [VTABLE]
202 */
203 static LPMALLOC16
204 IMalloc16_Constructor(void)
205 {
206 static IMalloc16Vtbl vt16;
207 static SEGPTR msegvt16;
208 IMalloc16Impl* This;
209 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ");
210
211 This = HeapAlloc( GetProcessHeap(), 0, sizeof(IMalloc16Impl) );
212 if (!msegvt16)
213 {
214 #define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"IMalloc16_"#x);assert(vt16.x)
215 VTENT(QueryInterface);
216 VTENT(AddRef);
217 VTENT(Release);
218 VTENT(Alloc);
219 VTENT(Realloc);
220 VTENT(Free);
221 VTENT(GetSize);
222 VTENT(DidAlloc);
223 VTENT(HeapMinimize);
224 #undef VTENT
225 msegvt16 = MapLS( &vt16 );
226 }
227 This->lpVtbl = (const IMalloc16Vtbl*)msegvt16;
228 This->ref = 1;
229 return (LPMALLOC16)MapLS( This );
230 }
231
232
233 /******************************************************************************
234 * CoBuildVersion [COMPOBJ.1]
235 */
236 DWORD WINAPI CoBuildVersion16(void)
237 {
238 return CoBuildVersion();
239 }
240
241 /***********************************************************************
242 * CoGetMalloc [COMPOBJ.4]
243 *
244 * Retrieve the current win16 IMalloc interface.
245 *
246 * RETURNS
247 * The current win16 IMalloc
248 */
249 HRESULT WINAPI CoGetMalloc16(
250 DWORD dwMemContext, /* [in] unknown */
251 LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */
252 ) {
253 if(!currentMalloc16)
254 currentMalloc16 = IMalloc16_Constructor();
255 *lpMalloc = currentMalloc16;
256 return S_OK;
257 }
258
259 /***********************************************************************
260 * CoCreateStandardMalloc [COMPOBJ.71]
261 */
262 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
263 LPMALLOC16 *lpMalloc)
264 {
265 /* FIXME: docu says we shouldn't return the same allocator as in
266 * CoGetMalloc16 */
267 *lpMalloc = IMalloc16_Constructor();
268 return S_OK;
269 }
270
271 /******************************************************************************
272 * CoInitialize [COMPOBJ.2]
273 * Set the win16 IMalloc used for memory management
274 */
275 HRESULT WINAPI CoInitialize16(
276 LPVOID lpReserved /* [in] pointer to win16 malloc interface */
277 ) {
278 currentMalloc16 = (LPMALLOC16)lpReserved;
279 return S_OK;
280 }
281
282 /***********************************************************************
283 * CoUninitialize [COMPOBJ.3]
284 * Don't know what it does.
285 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
286 * believe is the correct spelling
287 */
288 void WINAPI CoUninitialize16(void)
289 {
290 TRACE("()\n");
291 CoFreeAllLibraries();
292 }
293
294 /***********************************************************************
295 * CoFreeUnusedLibraries [COMPOBJ.17]
296 */
297 void WINAPI CoFreeUnusedLibraries16(void)
298 {
299 return CoFreeUnusedLibraries();
300 }
301
302 /***********************************************************************
303 * IsEqualGUID [COMPOBJ.18]
304 *
305 * Compares two Unique Identifiers.
306 *
307 * RETURNS
308 * TRUE if equal
309 */
310 BOOL16 WINAPI IsEqualGUID16(
311 GUID* g1, /* [in] unique id 1 */
312 GUID* g2) /* [in] unique id 2 */
313 {
314 return !memcmp( g1, g2, sizeof(GUID) );
315 }
316
317 /******************************************************************************
318 * CLSIDFromString [COMPOBJ.20]
319 * Converts a unique identifier from its string representation into
320 * the GUID struct.
321 *
322 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
323 *
324 * RETURNS
325 * the converted GUID
326 */
327 HRESULT WINAPI CLSIDFromString16(
328 LPCOLESTR16 idstr, /* [in] string representation of guid */
329 CLSID *id) /* [out] GUID converted from string */
330 {
331 const BYTE *s;
332 int i;
333 BYTE table[256];
334
335 if (!idstr) {
336 memset( id, 0, sizeof (CLSID) );
337 return S_OK;
338 }
339
340 /* validate the CLSID string */
341 if (strlen(idstr) != 38)
342 return CO_E_CLASSSTRING;
343
344 s = (const BYTE *) idstr;
345 if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
346 return CO_E_CLASSSTRING;
347
348 for (i=1; i<37; i++) {
349 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
350 if (!(((s[i] >= '') && (s[i] <= '9')) ||
351 ((s[i] >= 'a') && (s[i] <= 'f')) ||
352 ((s[i] >= 'A') && (s[i] <= 'F'))))
353 return CO_E_CLASSSTRING;
354 }
355
356 TRACE("%s -> %p\n", s, id);
357
358 /* quick lookup table */
359 memset(table, 0, 256);
360
361 for (i = 0; i < 10; i++) {
362 table['' + i] = i;
363 }
364 for (i = 0; i < 6; i++) {
365 table['A' + i] = i+10;
366 table['a' + i] = i+10;
367 }
368
369 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
370
371 id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 |
372 table[s[5]] << 12 | table[s[6]] << 8 | table[s[7]] << 4 | table[s[8]]);
373 id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]];
374 id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]];
375
376 /* these are just sequential bytes */
377 id->Data4[0] = table[s[20]] << 4 | table[s[21]];
378 id->Data4[1] = table[s[22]] << 4 | table[s[23]];
379 id->Data4[2] = table[s[25]] << 4 | table[s[26]];
380 id->Data4[3] = table[s[27]] << 4 | table[s[28]];
381 id->Data4[4] = table[s[29]] << 4 | table[s[30]];
382 id->Data4[5] = table[s[31]] << 4 | table[s[32]];
383 id->Data4[6] = table[s[33]] << 4 | table[s[34]];
384 id->Data4[7] = table[s[35]] << 4 | table[s[36]];
385
386 return S_OK;
387 }
388
389 /******************************************************************************
390 * _xmalloc16 [internal]
391 * Allocates size bytes from the standard ole16 allocator.
392 *
393 * RETURNS
394 * the allocated segmented pointer and a HRESULT
395 */
396 static HRESULT
397 _xmalloc16(DWORD size, SEGPTR *ptr) {
398 LPMALLOC16 mllc;
399 DWORD args[2];
400
401 if (CoGetMalloc16(0,&mllc))
402 return E_OUTOFMEMORY;
403
404 args[0] = (DWORD)mllc;
405 args[1] = size;
406 /* No need for a Callback entry, we have WOWCallback16Ex which does
407 * everything we need.
408 */
409 if (!WOWCallback16Ex(
410 (DWORD)((const IMalloc16Vtbl*)MapSL(
411 (SEGPTR)((LPMALLOC16)MapSL((SEGPTR)mllc))->lpVtbl )
412 )->Alloc,
413 WCB16_CDECL,
414 2*sizeof(DWORD),
415 (LPVOID)args,
416 (LPDWORD)ptr
417 )) {
418 ERR("CallTo16 IMalloc16 (%d) failed\n",size);
419 return E_FAIL;
420 }
421 return S_OK;
422 }
423
424 /******************************************************************************
425 * StringFromCLSID [COMPOBJ.19]
426 * Converts a GUID into the respective string representation.
427 * The target string is allocated using the OLE IMalloc.
428 *
429 * RETURNS
430 * the string representation and HRESULT
431 */
432
433 HRESULT WINAPI StringFromCLSID16(
434 REFCLSID id, /* [in] the GUID to be converted */
435 LPOLESTR16 *idstr ) /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
436 {
437 WCHAR buffer[40];
438 HRESULT ret;
439
440 ret = _xmalloc16(40,(SEGPTR*)idstr);
441 if (ret != S_OK)
442 return ret;
443 StringFromGUID2( id, buffer, 40 );
444 WideCharToMultiByte( CP_ACP, 0, buffer, -1, MapSL((SEGPTR)*idstr), 40, NULL, NULL );
445 return ret;
446 }
447
448 /******************************************************************************
449 * ProgIDFromCLSID [COMPOBJ.62]
450 *
451 * Converts a class id into the respective Program ID. (By using a registry lookup)
452 *
453 * RETURNS
454 * S_OK on success
455 * riid associated with the progid
456 */
457 HRESULT WINAPI ProgIDFromCLSID16(
458 REFCLSID clsid, /* [in] class id as found in registry */
459 LPOLESTR16 *lplpszProgID )/* [out] associated Program ID */
460 {
461 LPOLESTR progid;
462 HRESULT ret;
463
464 ret = ProgIDFromCLSID( clsid, &progid );
465 if (ret == S_OK)
466 {
467 INT len = WideCharToMultiByte( CP_ACP, 0, progid, -1, NULL, 0, NULL, NULL );
468 ret = _xmalloc16(len, (SEGPTR*)lplpszProgID);
469 if (ret == S_OK)
470 WideCharToMultiByte( CP_ACP, 0, progid, -1, MapSL((SEGPTR)*lplpszProgID), len, NULL, NULL );
471 CoTaskMemFree( progid );
472 }
473 return ret;
474 }
475
476 /***********************************************************************
477 * LookupETask (COMPOBJ.94)
478 */
479 HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) {
480 FIXME("(%p,%p),stub!\n",hTask,p);
481 if ((*hTask = GetCurrentTask()) == hETask) {
482 memcpy(p, Table_ETask, sizeof(Table_ETask));
483 }
484 return 0;
485 }
486
487 /***********************************************************************
488 * SetETask (COMPOBJ.95)
489 */
490 HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) {
491 FIXME("(%04x,%p),stub!\n",hTask,p);
492 hETask = hTask;
493 return 0;
494 }
495
496 /***********************************************************************
497 * CALLOBJECTINWOW (COMPOBJ.201)
498 */
499 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
500 FIXME("(%p,%p),stub!\n",p1,p2);
501 return 0;
502 }
503
504 /******************************************************************************
505 * CoRegisterClassObject [COMPOBJ.5]
506 *
507 * Don't know where it registers it ...
508 */
509 HRESULT WINAPI CoRegisterClassObject16(
510 REFCLSID rclsid,
511 LPUNKNOWN pUnk,
512 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
513 DWORD flags, /* [in] REGCLS flags indicating how connections are made */
514 LPDWORD lpdwRegister
515 ) {
516 FIXME("(%s,%p,0x%08x,0x%08x,%p),stub\n",
517 debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister
518 );
519 return 0;
520 }
521
522 /******************************************************************************
523 * CoRevokeClassObject [COMPOBJ.6]
524 *
525 */
526 HRESULT WINAPI CoRevokeClassObject16(DWORD dwRegister) /* [in] token on class obj */
527 {
528 FIXME("(0x%08x),stub!\n", dwRegister);
529 return 0;
530 }
531
532 /******************************************************************************
533 * IsValidInterface [COMPOBJ.23]
534 *
535 * Determines whether a pointer is a valid interface.
536 *
537 * PARAMS
538 * punk [I] Interface to be tested.
539 *
540 * RETURNS
541 * TRUE, if the passed pointer is a valid interface, or FALSE otherwise.
542 */
543 BOOL WINAPI IsValidInterface16(SEGPTR punk)
544 {
545 DWORD **ptr;
546
547 if (IsBadReadPtr16(punk,4))
548 return FALSE;
549 ptr = MapSL(punk);
550 if (IsBadReadPtr16((SEGPTR)ptr[0],4)) /* check vtable ptr */
551 return FALSE;
552 ptr = MapSL((SEGPTR)ptr[0]); /* ptr to first method */
553 if (IsBadReadPtr16((SEGPTR)ptr[0],2))
554 return FALSE;
555 return TRUE;
556 }
557
558 /******************************************************************************
559 * CoFileTimeToDosDateTime [COMPOBJ.30]
560 */
561 BOOL16 WINAPI CoFileTimeToDosDateTime16(const FILETIME *ft, LPWORD lpDosDate, LPWORD lpDosTime)
562 {
563 return FileTimeToDosDateTime(ft, lpDosDate, lpDosTime);
564 }
565
566 /******************************************************************************
567 * CoDosDateTimeToFileTime [COMPOBJ.31]
568 */
569 BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft)
570 {
571 return DosDateTimeToFileTime(wDosDate, wDosTime, ft);
572 }
573
574 /******************************************************************************
575 * CoGetCurrentProcess [COMPOBJ.34]
576 */
577 DWORD WINAPI CoGetCurrentProcess16(void)
578 {
579 return CoGetCurrentProcess();
580 }
581
582 /******************************************************************************
583 * CoRegisterMessageFilter [COMPOBJ.27]
584 */
585 HRESULT WINAPI CoRegisterMessageFilter16(
586 LPMESSAGEFILTER lpMessageFilter,
587 LPMESSAGEFILTER *lplpMessageFilter
588 ) {
589 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
590 return 0;
591 }
592
593 /******************************************************************************
594 * CoLockObjectExternal [COMPOBJ.63]
595 */
596 HRESULT WINAPI CoLockObjectExternal16(
597 LPUNKNOWN pUnk, /* [in] object to be locked */
598 BOOL16 fLock, /* [in] do lock */
599 BOOL16 fLastUnlockReleases /* [in] ? */
600 ) {
601 FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases);
602 return S_OK;
603 }
604
605 /***********************************************************************
606 * CoGetState [COMPOBJ.115]
607 */
608 HRESULT WINAPI CoGetState16(LPDWORD state)
609 {
610 FIXME("(%p),stub!\n", state);
611
612 *state = 0;
613 return S_OK;
614 }
615
616 /***********************************************************************
617 * DllEntryPoint [COMPOBJ.116]
618 *
619 * Initialization code for the COMPOBJ DLL
620 *
621 * RETURNS:
622 */
623 BOOL WINAPI COMPOBJ_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD HeapSize, DWORD res1, WORD res2)
624 {
625 TRACE("(%08x, %04x, %04x, %04x, %08x, %04x)\n", Reason, hInst, ds, HeapSize, res1, res2);
626 return TRUE;
627 }
628
629 /***********************************************************************
630 * CoMemAlloc [COMPOBJ.151]
631 */
632 SEGPTR WINAPI CoMemAlloc(DWORD size, DWORD dwMemContext, DWORD x) {
633 HRESULT hres;
634 SEGPTR segptr;
635
636 /* FIXME: check context handling */
637 TRACE("(%d, 0x%08x, 0x%08x)\n", size, dwMemContext, x);
638 hres = _xmalloc16(size, &segptr);
639 if (hres != S_OK)
640 return 0;
641 return segptr;
642 }
643
644 /******************************************************************************
645 * CLSIDFromProgID [COMPOBJ.61]
646 *
647 * Converts a program ID into the respective GUID.
648 *
649 * PARAMS
650 * progid [I] program id as found in registry
651 * riid [O] associated CLSID
652 *
653 * RETURNS
654 * Success: S_OK
655 * Failure: CO_E_CLASSSTRING - the given ProgID cannot be found.
656 */
657 HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid)
658 {
659 char *buf,buf2[80];
660 LONG buf2len;
661 HRESULT err;
662 HKEY xhkey;
663
664 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
665 sprintf(buf,"%s\\CLSID",progid);
666 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
667 HeapFree(GetProcessHeap(),0,buf);
668 return CO_E_CLASSSTRING;
669 }
670 HeapFree(GetProcessHeap(),0,buf);
671 buf2len = sizeof(buf2);
672 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
673 RegCloseKey(xhkey);
674 return CO_E_CLASSSTRING;
675 }
676 RegCloseKey(xhkey);
677 return CLSIDFromString16(buf2,riid);
678 }
679
680 /******************************************************************************
681 * StringFromGUID2 [COMPOBJ.76]
682 */
683 INT WINAPI StringFromGUID216(REFGUID id, LPOLESTR str, INT cmax)
684 {
685 return StringFromGUID2( id, str, cmax );
686 }
687
688
689 /***********************************************************************
690 * CoFileTimeNow [COMPOBJ.82]
691 */
692 HRESULT WINAPI CoFileTimeNow16( FILETIME *lpFileTime )
693 {
694 return CoFileTimeNow( lpFileTime );
695 }
696
697 /***********************************************************************
698 * CoGetClassObject [COMPOBJ.7]
699 *
700 */
701 HRESULT WINAPI CoGetClassObject16(
702 REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
703 REFIID iid, LPVOID *ppv)
704 {
705 FIXME(", stub!\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
706
707 if (pServerInfo) {
708 FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
709 FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
710 }
711 return E_NOTIMPL;
712 }
713
714 /******************************************************************************
715 * CoCreateGuid [COMPOBJ.73]
716 */
717 HRESULT WINAPI CoCreateGuid16(GUID *pguid)
718 {
719 return CoCreateGuid( pguid );
720 }
721
722 /***********************************************************************
723 * CoCreateInstance [COMPOBJ.13]
724 */
725 HRESULT WINAPI CoCreateInstance16(
726 REFCLSID rclsid,
727 LPUNKNOWN pUnkOuter,
728 DWORD dwClsContext,
729 REFIID iid,
730 LPVOID *ppv)
731 {
732 FIXME("(%s, %p, %x, %s, %p), stub!\n",
733 debugstr_guid(rclsid), pUnkOuter, dwClsContext, debugstr_guid(iid),
734 ppv
735 );
736 return E_NOTIMPL;
737 }
738
739 /***********************************************************************
740 * CoDisconnectObject [COMPOBJ.15]
741 */
742 HRESULT WINAPI CoDisconnectObject16( LPUNKNOWN lpUnk, DWORD reserved )
743 {
744 FIXME("(%p, 0x%08x): stub!\n", lpUnk, reserved);
745 return E_NOTIMPL;
746 }
747
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.