4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 Justin Bradford
15 #include <sys/types.h>
19 #include <sys/ioctl.h>
20 #include <sys/socket.h>
21 #ifdef HAVE_SYS_SOCKIO_H
22 #include <sys/sockio.h>
27 #ifdef HAVE_NETINET_IN_H
28 #include <netinet/in.h>
42 #include "interfaces.h"
53 LPMALLOC16 currentMalloc16
=NULL
;
54 LPMALLOC32 currentMalloc32
=NULL
;
60 /* this open DLL table belongs in a per process table, but my guess is that
61 * it shouldn't live in the kernel, so I'll put them out here in DLL
62 * space assuming that there is one OLE32 per process.
64 typedef struct tagOpenDll
{
65 char *DllName
; /* really only needed for debugging */
67 struct tagOpenDll
*next
;
70 static OpenDll
*openDllList
= NULL
; /* linked list of open dlls */
73 /******************************************************************************
74 * CoBuildVersion [COMPOBJ.1]
77 * Current built version, hiword is majornumber, loword is minornumber
79 DWORD WINAPI
CoBuildVersion(void)
81 TRACE(ole
,"(void)\n");
85 /******************************************************************************
86 * CoInitialize16 [COMPOBJ.2]
87 * Set the win16 IMalloc used for memory management
89 HRESULT WINAPI
CoInitialize16(
90 LPMALLOC16 lpReserved
/* [in] pointer to win16 malloc interface */
92 currentMalloc16
= lpReserved
;
96 /******************************************************************************
97 * CoInitialize32 [OLE32.26]
98 * Set the win32 IMalloc used for memorymanagement
100 HRESULT WINAPI
CoInitialize32(
101 LPMALLOC32 lpReserved
/* [in] pointer to win32 malloc interface */
103 /* FIXME: there really should be something here that incrememts a refcount
104 * but I'm supposing that it is a real COM object, so I won't bother
105 * creating one here. (Decrement done in CoUnitialize()) */
106 currentMalloc32
= lpReserved
;
110 /***********************************************************************
111 * CoUnitialize [COMPOBJ.3]
112 * Don't know what it does.
113 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
114 * believe is the correct spelling
116 void WINAPI
CoUninitialize(void)
118 TRACE(ole
,"(void)\n");
119 CoFreeAllLibraries();
122 /***********************************************************************
123 * CoGetMalloc16 [COMPOBJ.4]
125 * The current win16 IMalloc
127 HRESULT WINAPI
CoGetMalloc16(
128 DWORD dwMemContext
, /* [in] unknown */
129 LPMALLOC16
* lpMalloc
/* [out] current win16 malloc interface */
132 currentMalloc16
= IMalloc16_Constructor();
133 *lpMalloc
= currentMalloc16
;
137 /******************************************************************************
138 * CoGetMalloc32 [OLE32.20]
141 * The current win32 IMalloc
143 HRESULT WINAPI
CoGetMalloc32(
144 DWORD dwMemContext
, /* [in] unknown */
145 LPMALLOC32
*lpMalloc
/* [out] current win32 malloc interface */
148 currentMalloc32
= IMalloc32_Constructor();
149 *lpMalloc
= currentMalloc32
;
153 /***********************************************************************
154 * CoCreateStandardMalloc16 [COMPOBJ.71]
156 OLESTATUS WINAPI
CoCreateStandardMalloc16(DWORD dwMemContext
,
157 LPMALLOC16
*lpMalloc
)
159 /* FIXME: docu says we shouldn't return the same allocator as in
161 *lpMalloc
= IMalloc16_Constructor();
165 /******************************************************************************
166 * CoDisconnectObject [COMPOBJ.15]
168 OLESTATUS WINAPI
CoDisconnectObject( LPUNKNOWN lpUnk
, DWORD reserved
)
170 TRACE(ole
,"%p %lx\n",lpUnk
,reserved
);
174 /***********************************************************************
175 * IsEqualGUID [COMPOBJ.18]
176 * Compares two Unique Identifiers
180 BOOL16 WINAPI
IsEqualGUID(
181 GUID
* g1
, /* [in] unique id 1 */
182 GUID
* g2
/* [in] unique id 2 */
184 return !memcmp( g1
, g2
, sizeof(GUID
) );
187 /******************************************************************************
188 * CLSIDFromString16 [COMPOBJ.20]
189 * Converts a unique identifier from it's string representation into
192 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
197 OLESTATUS WINAPI
CLSIDFromString16(
198 LPCOLESTR16 idstr
, /* [in] string representation of guid */
199 CLSID
*id
/* [out] GUID converted from string */
201 BYTE
*s
= (BYTE
*) idstr
;
206 TRACE(ole
,"%s -> %p\n", idstr
, id
);
208 /* quick lookup table */
209 memset(table
, 0, 256);
211 for (i
= 0; i
< 10; i
++) {
214 for (i
= 0; i
< 6; i
++) {
215 table
['A' + i
] = i
+10;
216 table
['a' + i
] = i
+10;
219 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
221 if (strlen(idstr
) != 38)
222 return OLE_ERROR_OBJECT
;
226 s
++; /* skip leading brace */
227 for (i
= 0; i
< 4; i
++) {
228 p
[3 - i
] = table
[*s
]<<4 | table
[*(s
+1)];
234 for (i
= 0; i
< 2; i
++) {
235 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
241 for (i
= 0; i
< 2; i
++) {
242 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
248 /* these are just sequential bytes */
249 for (i
= 0; i
< 2; i
++) {
250 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
255 for (i
= 0; i
< 6; i
++) {
256 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
263 /******************************************************************************
264 * CoCreateGuid[OLE32.6]
265 * Implemented according the DCE specification for UUID generation.
266 * Code is based upon uuid library in e2fsprogs by Theodore Ts'o.
267 * Copyright (C) 1996, 1997 Theodore Ts'o.
269 int CoCreateGuid(GUID
*pguid
) {
270 static char has_init
= 0;
272 static int adjustment
= 0;
273 static struct timeval last
= {0, 0};
274 static UINT16 clock_seq
;
276 unsigned long long clock_reg
;
277 UINT32 clock_high
, clock_low
;
278 UINT16 temp_clock_seq
, temp_clock_mid
, temp_clock_hi_and_version
;
281 struct ifreq ifr
, *ifrp
;
287 /* Have we already tried to get the MAC address? */
290 /* BSD 4.4 defines the size of an ifreq to be
291 * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
292 * However, under earlier systems, sa_len isn't present, so
293 * the size is just sizeof(struct ifreq)
297 # define max(a,b) ((a) > (b) ? (a) : (b))
299 # define ifreq_size(i) max(sizeof(struct ifreq),\
300 sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
302 # define ifreq_size(i) sizeof(struct ifreq)
303 # endif /* HAVE_SA_LEN */
305 sd
= socket(AF_INET
, SOCK_DGRAM
, IPPROTO_IP
);
307 /* if we can't open a socket, just use random numbers */
308 /* set the multicast bit to prevent conflicts with real cards */
309 a
[0] = (rand() & 0xff) | 0x80;
310 a
[1] = rand() & 0xff;
311 a
[2] = rand() & 0xff;
312 a
[3] = rand() & 0xff;
313 a
[4] = rand() & 0xff;
314 a
[5] = rand() & 0xff;
316 memset(buf
, 0, sizeof(buf
));
317 ifc
.ifc_len
= sizeof(buf
);
319 /* get the ifconf interface */
320 if (ioctl (sd
, SIOCGIFCONF
, (char *)&ifc
) < 0) {
322 /* no ifconf, so just use random numbers */
323 /* set the multicast bit to prevent conflicts with real cards */
324 a
[0] = (rand() & 0xff) | 0x80;
325 a
[1] = rand() & 0xff;
326 a
[2] = rand() & 0xff;
327 a
[3] = rand() & 0xff;
328 a
[4] = rand() & 0xff;
329 a
[5] = rand() & 0xff;
331 /* loop through the interfaces, looking for a valid one */
333 for (i
= 0; i
< n
; i
+= ifreq_size(*ifr
) ) {
334 ifrp
= (struct ifreq
*)((char *) ifc
.ifc_buf
+i
);
335 strncpy(ifr
.ifr_name
, ifrp
->ifr_name
, IFNAMSIZ
);
336 /* try to get the address for this interface */
337 # ifdef SIOCGIFHWADDR
338 if (ioctl(sd
, SIOCGIFHWADDR
, &ifr
) < 0)
340 memcpy(a
, (unsigned char *)&ifr
.ifr_hwaddr
.sa_data
, 6);
343 if (ioctl(sd
, SIOCGENADDR
, &ifr
) < 0)
345 memcpy(a
, (unsigned char *) ifr
.ifr_enaddr
, 6);
347 /* XXX we don't have a way of getting the hardware address */
351 # endif /* SIOCGENADDR */
352 # endif /* SIOCGIFHWADDR */
353 /* make sure it's not blank */
354 if (!a
[0] && !a
[1] && !a
[2] && !a
[3] && !a
[4] && !a
[5])
359 /* if we didn't find a valid address, make a random one */
360 /* once again, set multicast bit to avoid conflicts */
361 a
[0] = (rand() & 0xff) | 0x80;
362 a
[1] = rand() & 0xff;
363 a
[2] = rand() & 0xff;
364 a
[3] = rand() & 0xff;
365 a
[4] = rand() & 0xff;
366 a
[5] = rand() & 0xff;
373 /* no networking info, so generate a random address */
374 a
[0] = (rand() & 0xff) | 0x80;
375 a
[1] = rand() & 0xff;
376 a
[2] = rand() & 0xff;
377 a
[3] = rand() & 0xff;
378 a
[4] = rand() & 0xff;
379 a
[5] = rand() & 0xff;
380 #endif /* HAVE_NET_IF_H */
384 /* generate time element of GUID */
386 /* Assume that the gettimeofday() has microsecond granularity */
387 #define MAX_ADJUSTMENT 10
390 gettimeofday(&tv
, 0);
391 if ((last
.tv_sec
== 0) && (last
.tv_usec
== 0)) {
392 clock_seq
= ((rand() & 0xff) << 8) + (rand() & 0xff);
397 if ((tv
.tv_sec
< last
.tv_sec
) ||
398 ((tv
.tv_sec
== last
.tv_sec
) &&
399 (tv
.tv_usec
< last
.tv_usec
))) {
400 clock_seq
= (clock_seq
+1) & 0x1FFF;
402 } else if ((tv
.tv_sec
== last
.tv_sec
) &&
403 (tv
.tv_usec
== last
.tv_usec
)) {
404 if (adjustment
>= MAX_ADJUSTMENT
)
410 clock_reg
= tv
.tv_usec
*10 + adjustment
;
411 clock_reg
+= ((unsigned long long) tv
.tv_sec
)*10000000;
412 clock_reg
+= (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000;
414 clock_high
= clock_reg
>> 32;
415 clock_low
= clock_reg
;
416 temp_clock_seq
= clock_seq
| 0x8000;
417 temp_clock_mid
= (UINT16
)clock_high
;
418 temp_clock_hi_and_version
= (clock_high
>> 16) | 0x1000;
420 /* pack the information into the GUID structure */
422 ((unsigned char*)&pguid
->Data1
)[3] = (unsigned char)clock_low
;
424 ((unsigned char*)&pguid
->Data1
)[2] = (unsigned char)clock_low
;
426 ((unsigned char*)&pguid
->Data1
)[1] = (unsigned char)clock_low
;
428 ((unsigned char*)&pguid
->Data1
)[0] = (unsigned char)clock_low
;
430 ((unsigned char*)&pguid
->Data2
)[1] = (unsigned char)temp_clock_mid
;
431 temp_clock_mid
>>= 8;
432 ((unsigned char*)&pguid
->Data2
)[0] = (unsigned char)temp_clock_mid
;
434 ((unsigned char*)&pguid
->Data3
)[1] = (unsigned char)temp_clock_hi_and_version
;
435 temp_clock_hi_and_version
>>= 8;
436 ((unsigned char*)&pguid
->Data3
)[0] = (unsigned char)temp_clock_hi_and_version
;
438 ((unsigned char*)pguid
->Data4
)[1] = (unsigned char)temp_clock_seq
;
439 temp_clock_seq
>>= 8;
440 ((unsigned char*)pguid
->Data4
)[0] = (unsigned char)temp_clock_seq
;
442 ((unsigned char*)pguid
->Data4
)[2] = a
[0];
443 ((unsigned char*)pguid
->Data4
)[3] = a
[1];
444 ((unsigned char*)pguid
->Data4
)[4] = a
[2];
445 ((unsigned char*)pguid
->Data4
)[5] = a
[3];
446 ((unsigned char*)pguid
->Data4
)[6] = a
[4];
447 ((unsigned char*)pguid
->Data4
)[7] = a
[5];
449 TRACE(ole
, "%p", pguid
);
454 /******************************************************************************
455 * CLSIDFromString32 [OLE32.3]
456 * Converts a unique identifier from it's string representation into
461 OLESTATUS WINAPI
CLSIDFromString32(
462 LPCOLESTR32 idstr
, /* [in] string representation of GUID */
463 CLSID
*id
/* [out] GUID represented by above string */
465 LPOLESTR16 xid
= HEAP_strdupWtoA(GetProcessHeap(),0,idstr
);
466 OLESTATUS ret
= CLSIDFromString16(xid
,id
);
468 HeapFree(GetProcessHeap(),0,xid
);
472 /******************************************************************************
473 * WINE_StringFromCLSID [???]
474 * Converts a GUID into the respective string representation.
477 * Why is this WINAPI?
480 * the string representation and OLESTATUS
482 OLESTATUS WINAPI
WINE_StringFromCLSID(
483 const CLSID
*id
, /* [in] GUID to be converted */
484 LPSTR idstr
/* [out] pointer to buffer to contain converted guid */
486 static const char *hex
= "0123456789ABCDEF";
491 { ERR(ole
,"called with id=Null\n");
496 sprintf(idstr
, "{%08lX-%04X-%04X-%02x%02X-",
497 id
->Data1
, id
->Data2
, id
->Data3
,
498 id
->Data4
[0], id
->Data4
[1]);
502 for (i
= 2; i
< 8; i
++) {
503 *s
++ = hex
[id
->Data4
[i
]>>4];
504 *s
++ = hex
[id
->Data4
[i
] & 0xf];
510 TRACE(ole
,"%p->%s\n", id
, idstr
);
515 /******************************************************************************
516 * StringFromCLSID16 [COMPOBJ.19]
517 * Converts a GUID into the respective string representation.
518 * The target string is allocated using the OLE IMalloc.
520 * the string representation and OLESTATUS
522 OLESTATUS WINAPI
StringFromCLSID16(
523 const CLSID
*id
, /* [in] the GUID to be converted */
524 LPOLESTR16
*idstr
/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
531 ret
= CoGetMalloc16(0,&mllc
);
534 args
[0] = (DWORD
)mllc
;
537 /* No need for a Callback entry, we have WOWCallback16Ex which does
538 * everything we need.
540 if (!WOWCallback16Ex(
541 (FARPROC16
)((LPMALLOC16_VTABLE
)PTR_SEG_TO_LIN(
542 ((LPMALLOC16
)PTR_SEG_TO_LIN(mllc
))->lpvtbl
)
549 WARN(ole
,"CallTo16 IMalloc16 failed\n");
552 return WINE_StringFromCLSID(id
,PTR_SEG_TO_LIN(*idstr
));
555 /******************************************************************************
556 * StringFromCLSID32 [OLE32.151]
557 * Converts a GUID into the respective string representation.
558 * The target string is allocated using the OLE IMalloc.
560 * the string representation and OLESTATUS
562 OLESTATUS WINAPI
StringFromCLSID32(
563 const CLSID
*id
, /* [in] the GUID to be converted */
564 LPOLESTR32
*idstr
/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
570 if ((ret
=CoGetMalloc32(0,&mllc
)))
573 ret
=WINE_StringFromCLSID(id
,buf
);
575 *idstr
= mllc
->lpvtbl
->fnAlloc(mllc
,strlen(buf
)*2+2);
576 lstrcpyAtoW(*idstr
,buf
);
581 /******************************************************************************
582 * StringFromGUID2 [COMPOBJ.76] [OLE32.152]
584 * Converts a global unique identifier into a string of an API-
585 * specified fixed format. (The usual {.....} stuff.)
588 * The (UNICODE) string representation of the GUID in 'str'
589 * The length of the resulting string, 0 if there was any problem.
592 StringFromGUID2(REFGUID id
, LPOLESTR32 str
, INT32 cmax
)
596 if (WINE_StringFromCLSID(id
,xguid
))
598 if (strlen(xguid
)>=cmax
)
600 lstrcpyAtoW(str
,xguid
);
601 return strlen(xguid
);
604 /******************************************************************************
605 * CLSIDFromProgID16 [COMPOBJ.61]
606 * Converts a program id into the respective GUID. (By using a registry lookup)
608 * riid associated with the progid
610 OLESTATUS WINAPI
CLSIDFromProgID16(
611 LPCOLESTR16 progid
, /* [in] program id as found in registry */
612 LPCLSID riid
/* [out] associated CLSID */
619 buf
= HeapAlloc(GetProcessHeap(),0,strlen(progid
)+8);
620 sprintf(buf
,"%s\\CLSID",progid
);
621 if ((err
=RegOpenKey32A(HKEY_CLASSES_ROOT
,buf
,&xhkey
))) {
622 HeapFree(GetProcessHeap(),0,buf
);
623 return OLE_ERROR_GENERIC
;
625 HeapFree(GetProcessHeap(),0,buf
);
626 buf2len
= sizeof(buf2
);
627 if ((err
=RegQueryValue32A(xhkey
,NULL
,buf2
,&buf2len
))) {
629 return OLE_ERROR_GENERIC
;
632 return CLSIDFromString16(buf2
,riid
);
635 /******************************************************************************
636 * CLSIDFromProgID32 [OLE32.2]
637 * Converts a program id into the respective GUID. (By using a registry lookup)
639 * riid associated with the progid
641 OLESTATUS WINAPI
CLSIDFromProgID32(
642 LPCOLESTR32 progid
, /* [in] program id as found in registry */
643 LPCLSID riid
/* [out] associated CLSID */
645 LPOLESTR16 pid
= HEAP_strdupWtoA(GetProcessHeap(),0,progid
);
646 OLESTATUS ret
= CLSIDFromProgID16(pid
,riid
);
648 HeapFree(GetProcessHeap(),0,pid
);
652 /***********************************************************************
653 * LookupETask (COMPOBJ.94)
655 OLESTATUS WINAPI
LookupETask(HTASK16
*hTask
,LPVOID p
) {
656 FIXME(ole
,"(%p,%p),stub!\n",hTask
,p
);
657 if ((*hTask
= GetCurrentTask()) == hETask
) {
658 memcpy(p
, Table_ETask
, sizeof(Table_ETask
));
663 /***********************************************************************
664 * SetETask (COMPOBJ.95)
666 OLESTATUS WINAPI
SetETask(HTASK16 hTask
, LPVOID p
) {
667 FIXME(ole
,"(%04x,%p),stub!\n",hTask
,p
);
672 /***********************************************************************
673 * CallObjectInWOW (COMPOBJ.201)
675 OLESTATUS WINAPI
CallObjectInWOW(LPVOID p1
,LPVOID p2
) {
676 FIXME(ole
,"(%p,%p),stub!\n",p1
,p2
);
680 /******************************************************************************
681 * CoRegisterClassObject16 [COMPOBJ.5]
683 * Don't know where it registers it ...
685 OLESTATUS WINAPI
CoRegisterClassObject16(
694 WINE_StringFromCLSID(rclsid
,buf
);
696 FIXME(ole
,"(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
697 buf
,pUnk
,dwClsContext
,flags
,lpdwRegister
702 /******************************************************************************
703 * CoRegisterClassObject32 [OLE32.36]
705 * Don't know where it registers it ...
707 OLESTATUS WINAPI
CoRegisterClassObject32(
716 WINE_StringFromCLSID(rclsid
,buf
);
718 FIXME(ole
,"(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
719 buf
,pUnk
,dwClsContext
,flags
,lpdwRegister
724 /***********************************************************************
725 * CoRevokeClassObject [OLE32.40]
727 HRESULT WINAPI
CoRevokeClassObject(DWORD dwRegister
) {
728 FIXME(ole
,"(%08lx),stub!\n",dwRegister
);
732 /***********************************************************************
733 * CoGetClassObject [COMPOBJ.7]
735 HRESULT WINAPI
CoGetClassObject(REFCLSID rclsid
, DWORD dwClsContext
,
736 LPVOID pvReserved
, const REFIID iid
, LPVOID
*ppv
)
738 char xclsid
[50],xiid
[50];
739 HRESULT hres
= E_UNEXPECTED
;
741 char dllName
[MAX_PATH
+1];
742 LONG dllNameLen
= sizeof(dllName
);
743 HINSTANCE32 hLibrary
;
744 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
,
745 REFIID iid
, LPVOID
*ppv
);
746 DllGetClassObjectFunc DllGetClassObject
;
748 WINE_StringFromCLSID((LPCLSID
)rclsid
,xclsid
);
749 WINE_StringFromCLSID((LPCLSID
)iid
,xiid
);
750 TRACE(ole
,"\n\tCLSID:\t%s,\n\tIID:\t%s\n",xclsid
,xiid
);
752 /* out of process and remote servers not supported yet */
753 if ((CLSCTX_LOCAL_SERVER
|CLSCTX_REMOTE_SERVER
) & dwClsContext
) {
754 FIXME(ole
, "CLSCTX_LOCAL_SERVER and CLSCTX_REMOTE_SERVER not supported!\n");
755 return E_ACCESSDENIED
;
758 if ((CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
) & dwClsContext
) {
761 /* lookup CLSID in registry key HKCR/CLSID */
762 hres
= RegOpenKeyEx32A(HKEY_CLASSES_ROOT
, "CLSID", 0,
763 KEY_READ
, &CLSIDkey
);
765 if (hres
!= ERROR_SUCCESS
)
766 return REGDB_E_READREGDB
;
767 hres
= RegOpenKeyEx32A(CLSIDkey
,xclsid
,0,KEY_QUERY_VALUE
,&key
);
768 if (hres
!= ERROR_SUCCESS
) {
769 RegCloseKey(CLSIDkey
);
770 return REGDB_E_CLASSNOTREG
;
772 hres
= RegQueryValue32A(key
, "InprocServer32", dllName
, &dllNameLen
);
774 RegCloseKey(CLSIDkey
);
775 if (hres
!= ERROR_SUCCESS
)
776 return REGDB_E_READREGDB
;
777 TRACE(ole
,"found InprocServer32 dll %s\n", dllName
);
779 /* open dll, call DllGetClassFactory */
780 hLibrary
= CoLoadLibrary(dllName
, TRUE
);
782 TRACE(ole
,"couldn't load InprocServer32 dll %s\n", dllName
);
783 return E_ACCESSDENIED
; /* or should this be CO_E_DLLNOTFOUND? */
785 DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress32(hLibrary
, "DllGetClassObject");
786 if (!DllGetClassObject
) {
787 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
788 TRACE(ole
,"couldn't find function DllGetClassObject in %s\n", dllName
);
789 return E_ACCESSDENIED
;
791 /* FIXME: Shouldn't we get a classfactory and use this to create
792 * the required object?
794 return DllGetClassObject(rclsid
, iid
, ppv
);
799 /******************************************************************************
800 * CoRegisterMessageFilter16 [COMPOBJ.27]
802 OLESTATUS WINAPI
CoRegisterMessageFilter16(
803 LPMESSAGEFILTER lpMessageFilter
,
804 LPMESSAGEFILTER
*lplpMessageFilter
806 FIXME(ole
,"(%p,%p),stub!\n",lpMessageFilter
,lplpMessageFilter
);
810 /***********************************************************************
811 * CoCreateInstance [COMPOBJ.13, OLE32.7]
813 HRESULT WINAPI
CoCreateInstance(
821 char buf
[80],xbuf
[80];
824 WINE_StringFromCLSID(rclsid
,buf
);
826 sprintf(buf
,"<rclsid-0x%08lx>",(DWORD
)rclsid
);
828 WINE_StringFromCLSID(iid
,xbuf
);
830 sprintf(xbuf
,"<iid-0x%08lx>",(DWORD
)iid
);
832 FIXME(ole
,"(%s,%p,0x%08lx,%s,%p): stub !\n",buf
,pUnkOuter
,dwClsContext
,xbuf
,ppv
);
836 LPCLASSFACTORY lpclf
= 0;
838 hres
= CoGetClassObject(rclsid
, dwClsContext
, NULL
, (const REFIID
) &IID_IClassFactory
, (LPVOID
)&lpclf
);
839 if (!SUCCEEDED(hres
)) return hres
;
840 hres
= lpclf
->lpvtbl
->fnCreateInstance(lpclf
, pUnkOuter
, iid
, ppv
);
841 lpclf
->lpvtbl
->fnRelease(lpclf
);
848 /***********************************************************************
849 * CoFreeLibrary [COMPOBJ.13]
851 void WINAPI
CoFreeLibrary(HINSTANCE32 hLibrary
)
856 /* lookup library in linked list */
858 for (ptr
= openDllList
; ptr
!= NULL
; ptr
=ptr
->next
) {
859 if (ptr
->hLibrary
== hLibrary
) {
866 /* shouldn't happen if user passed in a valid hLibrary */
869 /* assert: ptr points to the library entry to free */
871 /* free library and remove node from list */
872 FreeLibrary32(hLibrary
);
873 if (ptr
== openDllList
) {
874 tmp
= openDllList
->next
;
875 HeapFree(GetProcessHeap(), 0, openDllList
->DllName
);
876 HeapFree(GetProcessHeap(), 0, openDllList
);
880 HeapFree(GetProcessHeap(), 0, ptr
->DllName
);
881 HeapFree(GetProcessHeap(), 0, ptr
);
888 /***********************************************************************
889 * CoFreeAllLibraries [COMPOBJ.12]
891 void WINAPI
CoFreeAllLibraries(void)
895 for (ptr
= openDllList
; ptr
!= NULL
; ) {
897 CoFreeLibrary(ptr
->hLibrary
);
904 /***********************************************************************
905 * CoFreeUnusedLibraries [COMPOBJ.17]
907 void WINAPI
CoFreeUnusedLibraries(void)
910 typedef HRESULT(*DllCanUnloadNowFunc
)(void);
911 DllCanUnloadNowFunc DllCanUnloadNow
;
913 for (ptr
= openDllList
; ptr
!= NULL
; ) {
914 DllCanUnloadNow
= (DllCanUnloadNowFunc
)
915 GetProcAddress32(ptr
->hLibrary
, "DllCanUnloadNow");
917 if (DllCanUnloadNow() == S_OK
) {
919 CoFreeLibrary(ptr
->hLibrary
);
927 /***********************************************************************
928 * CoFileTimeNow [COMPOBJ.82, OLE32.10]
930 * the current system time in lpFileTime
932 HRESULT WINAPI
CoFileTimeNow(
933 FILETIME
*lpFileTime
/* [out] the current time */
935 DOSFS_UnixTimeToFileTime(time(NULL
), lpFileTime
, 0);
939 /***********************************************************************
940 * CoTaskMemAlloc (OLE32.43)
942 * pointer to newly allocated block
944 LPVOID WINAPI
CoTaskMemAlloc(
945 ULONG size
/* [in] size of memoryblock to be allocated */
948 HRESULT ret
= CoGetMalloc32(0,&lpmalloc
);
952 return lpmalloc
->lpvtbl
->fnAlloc(lpmalloc
,size
);
955 /***********************************************************************
956 * CoTaskMemFree (OLE32.44)
958 VOID WINAPI
CoTaskMemFree(
959 LPVOID ptr
/* [in] pointer to be freed */
962 HRESULT ret
= CoGetMalloc32(0,&lpmalloc
);
965 return lpmalloc
->lpvtbl
->fnFree(lpmalloc
,ptr
);
968 /***********************************************************************
969 * CoLoadLibrary (OLE32.30)
971 HINSTANCE32 WINAPI
CoLoadLibrary(LPSTR lpszLibName
, BOOL32 bAutoFree
)
973 HINSTANCE32 hLibrary
;
977 TRACE(ole
,"CoLoadLibrary(%p, %d\n", lpszLibName
, bAutoFree
);
979 hLibrary
= LoadLibrary32A(lpszLibName
);
984 if (openDllList
== NULL
) {
985 /* empty list -- add first node */
986 openDllList
= (OpenDll
*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll
));
987 openDllList
->DllName
= HEAP_strdupA(GetProcessHeap(), 0, lpszLibName
);
988 openDllList
->hLibrary
= hLibrary
;
989 openDllList
->next
= NULL
;
991 /* search for this dll */
993 for (ptr
= openDllList
; ptr
->next
!= NULL
; ptr
=ptr
->next
) {
994 if (ptr
->hLibrary
== hLibrary
) {
1000 /* dll not found, add it */
1002 openDllList
= (OpenDll
*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll
));
1003 openDllList
->DllName
= HEAP_strdupA(GetProcessHeap(), 0, lpszLibName
);
1004 openDllList
->hLibrary
= hLibrary
;
1005 openDllList
->next
= tmp
;
1012 /***********************************************************************
1013 * CoInitializeWOW (OLE32.27)
1015 HRESULT WINAPI
CoInitializeWOW(DWORD x
,DWORD y
) {
1016 FIXME(ole
,"(0x%08lx,0x%08lx),stub!\n",x
,y
);
1020 /******************************************************************************
1021 * CoLockObjectExternal16 [COMPOBJ.63]
1023 HRESULT WINAPI
CoLockObjectExternal16(
1024 LPUNKNOWN pUnk
, /* [in] object to be locked */
1025 BOOL16 fLock
, /* [in] do lock */
1026 BOOL16 fLastUnlockReleases
/* [in] ? */
1028 FIXME(ole
,"(%p,%d,%d),stub!\n",pUnk
,fLock
,fLastUnlockReleases
);
1032 /******************************************************************************
1033 * CoLockObjectExternal32 [OLE32.31]
1035 HRESULT WINAPI
CoLockObjectExternal32(
1036 LPUNKNOWN pUnk
, /* [in] object to be locked */
1037 BOOL32 fLock
, /* [in] do lock */
1038 BOOL32 fLastUnlockReleases
/* [in] ? */
1040 FIXME(ole
,"(%p,%d,%d),stub!\n",pUnk
,fLock
,fLastUnlockReleases
);
1044 /***********************************************************************
1045 * CoGetState16 [COMPOBJ.115]
1047 HRESULT WINAPI
CoGetState16(LPDWORD state
)
1049 FIXME(ole
, "(%p),stub!\n", state
);
1053 /***********************************************************************
1054 * CoSetState32 [COM32.42]
1056 HRESULT WINAPI
CoSetState32(LPDWORD state
)
1058 FIXME(ole
, "(%p),stub!\n", state
);