4 * Copyright 1995 Martin von Loewis
5 * Copyright 1998 Justin Bradford
6 * Copyright 1999 Francis Beaudet
7 * Copyright 1999 Sylvain St-Germain
19 #include "wine/winbase16.h"
23 #include "debugtools.h"
30 #include "wine/obj_base.h"
31 #include "wine/obj_misc.h"
32 #include "wine/obj_storage.h"
33 #include "wine/obj_clientserver.h"
38 DEFAULT_DEBUG_CHANNEL(ole
);
40 /****************************************************************************
41 * COM External Lock structures and methods declaration
43 * This api provides a linked list to managed external references to
46 * The public interface consists of three calls:
47 * COM_ExternalLockAddRef
48 * COM_ExternalLockRelease
49 * COM_ExternalLockFreeList
52 #define EL_END_OF_LIST 0
53 #define EL_NOT_FOUND 0
56 * Declaration of the static structure that manage the
57 * external lock to COM objects.
59 typedef struct COM_ExternalLock COM_ExternalLock
;
60 typedef struct COM_ExternalLockList COM_ExternalLockList
;
62 struct COM_ExternalLock
64 IUnknown
*pUnk
; /* IUnknown referenced */
65 ULONG uRefCount
; /* external lock counter to IUnknown object*/
66 COM_ExternalLock
*next
; /* Pointer to next element in list */
69 struct COM_ExternalLockList
71 COM_ExternalLock
*head
; /* head of list */
75 * Declaration and initialization of the static structure that manages
76 * the external lock to COM objects.
78 static COM_ExternalLockList elList
= { EL_END_OF_LIST
};
81 * Public Interface to the external lock list
83 static void COM_ExternalLockFreeList();
84 static void COM_ExternalLockAddRef(IUnknown
*pUnk
);
85 static void COM_ExternalLockRelease(IUnknown
*pUnk
, BOOL bRelAll
);
86 void COM_ExternalLockDump(); /* testing purposes, not static to avoid warning */
89 * Private methods used to managed the linked list
91 static BOOL
COM_ExternalLockInsert(
94 static void COM_ExternalLockDelete(
95 COM_ExternalLock
*element
);
97 static COM_ExternalLock
* COM_ExternalLockFind(
100 static COM_ExternalLock
* COM_ExternalLockLocate(
101 COM_ExternalLock
*element
,
104 /****************************************************************************
105 * This section defines variables internal to the COM module.
107 * TODO: Most of these things will have to be made thread-safe.
109 HINSTANCE16 COMPOBJ_hInstance
= 0;
110 HINSTANCE COMPOBJ_hInstance32
= 0;
111 static int COMPOBJ_Attach
= 0;
113 LPMALLOC16 currentMalloc16
=NULL
;
114 LPMALLOC currentMalloc32
=NULL
;
117 WORD Table_ETask
[62];
120 * This lock count counts the number of times CoInitialize is called. It is
121 * decreased every time CoUninitialize is called. When it hits 0, the COM
122 * libraries are freed
124 static ULONG s_COMLockCount
= 0;
127 * This linked list contains the list of registered class objects. These
128 * are mostly used to register the factories for out-of-proc servers of OLE
131 * TODO: Make this data structure aware of inter-process communication. This
132 * means that parts of this will be exported to the Wine Server.
134 typedef struct tagRegisteredClass
136 CLSID classIdentifier
;
137 LPUNKNOWN classObject
;
141 struct tagRegisteredClass
* nextClass
;
144 static RegisteredClass
* firstRegisteredClass
= NULL
;
146 /* this open DLL table belongs in a per process table, but my guess is that
147 * it shouldn't live in the kernel, so I'll put them out here in DLL
148 * space assuming that there is one OLE32 per process.
150 typedef struct tagOpenDll
{
152 struct tagOpenDll
*next
;
155 static OpenDll
*openDllList
= NULL
; /* linked list of open dlls */
157 /*****************************************************************************
158 * This section contains prototypes to internal methods for this
161 static HRESULT
COM_GetRegisteredClassObject(REFCLSID rclsid
,
165 static void COM_RevokeAllClasses();
168 /******************************************************************************
169 * CoBuildVersion [COMPOBJ.1]
172 * Current build version, hiword is majornumber, loword is minornumber
174 DWORD WINAPI
CoBuildVersion(void)
176 TRACE("Returning version %d, build %d.\n", rmm
, rup
);
177 return (rmm
<<16)+rup
;
180 /******************************************************************************
181 * CoInitialize16 [COMPOBJ.2]
182 * Set the win16 IMalloc used for memory management
184 HRESULT WINAPI
CoInitialize16(
185 LPVOID lpReserved
/* [in] pointer to win16 malloc interface */
187 currentMalloc16
= (LPMALLOC16
)lpReserved
;
191 /******************************************************************************
192 * CoInitialize [OLE32.26]
194 * Initializes the COM libraries.
198 HRESULT WINAPI
CoInitialize(
199 LPVOID lpReserved
/* [in] pointer to win32 malloc interface
200 (obsolete, should be NULL) */
204 * Just delegate to the newer method.
206 return CoInitializeEx(lpReserved
, COINIT_APARTMENTTHREADED
);
209 /******************************************************************************
210 * CoInitializeEx [OLE32.163]
212 * Initializes the COM libraries. The behavior used to set the win32 IMalloc
213 * used for memory management is obsolete.
216 * S_OK if successful,
217 * S_FALSE if this function was called already.
218 * RPC_E_CHANGED_MODE if a previous call to CoInitialize specified another
222 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE
225 * See the windows documentation for more details.
227 HRESULT WINAPI
CoInitializeEx(
228 LPVOID lpReserved
, /* [in] pointer to win32 malloc interface
229 (obsolete, should be NULL) */
230 DWORD dwCoInit
/* [in] A value from COINIT specifies the threading model */
235 TRACE("(%p, %x)\n", lpReserved
, (int)dwCoInit
);
237 if (lpReserved
!=NULL
)
239 ERR("(%p, %x) - Bad parameter passed-in %p, must be an old Windows Application\n", lpReserved
, (int)dwCoInit
, lpReserved
);
243 * Check for unsupported features.
245 if (dwCoInit
!=COINIT_APARTMENTTHREADED
)
247 FIXME(":(%p,%x): unsupported flag %x\n", lpReserved
, (int)dwCoInit
, (int)dwCoInit
);
248 /* Hope for the best and continue anyway */
252 * Check the lock count. If this is the first time going through the initialize
253 * process, we have to initialize the libraries.
255 if (s_COMLockCount
==0)
258 * Initialize the various COM libraries and data structures.
260 TRACE("() - Initializing the COM libraries\n");
262 RunningObjectTableImpl_Initialize();
270 * Crank-up that lock count.
277 /***********************************************************************
278 * CoUninitialize16 [COMPOBJ.3]
279 * Don't know what it does.
280 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
281 * believe is the correct spelling
283 void WINAPI
CoUninitialize16(void)
286 CoFreeAllLibraries();
289 /***********************************************************************
290 * CoUninitialize [OLE32.47]
292 * This method will release the COM libraries.
294 * See the windows documentation for more details.
296 void WINAPI
CoUninitialize(void)
301 * Decrease the reference count.
306 * If we are back to 0 locks on the COM library, make sure we free
307 * all the associated data structures.
309 if (s_COMLockCount
==0)
312 * Release the various COM libraries and data structures.
314 TRACE("() - Releasing the COM libraries\n");
316 RunningObjectTableImpl_UnInitialize();
318 * Release the references to the registered class objects.
320 COM_RevokeAllClasses();
323 * This will free the loaded COM Dlls.
325 CoFreeAllLibraries();
328 * This will free list of external references to COM objects.
330 COM_ExternalLockFreeList();
334 /***********************************************************************
335 * CoGetMalloc16 [COMPOBJ.4]
337 * The current win16 IMalloc
339 HRESULT WINAPI
CoGetMalloc16(
340 DWORD dwMemContext
, /* [in] unknown */
341 LPMALLOC16
* lpMalloc
/* [out] current win16 malloc interface */
344 currentMalloc16
= IMalloc16_Constructor();
345 *lpMalloc
= currentMalloc16
;
349 /******************************************************************************
350 * CoGetMalloc [OLE32.20]
353 * The current win32 IMalloc
355 HRESULT WINAPI
CoGetMalloc(
356 DWORD dwMemContext
, /* [in] unknown */
357 LPMALLOC
*lpMalloc
/* [out] current win32 malloc interface */
360 currentMalloc32
= IMalloc_Constructor();
361 *lpMalloc
= currentMalloc32
;
365 /***********************************************************************
366 * CoCreateStandardMalloc16 [COMPOBJ.71]
368 HRESULT WINAPI
CoCreateStandardMalloc16(DWORD dwMemContext
,
369 LPMALLOC16
*lpMalloc
)
371 /* FIXME: docu says we shouldn't return the same allocator as in
373 *lpMalloc
= IMalloc16_Constructor();
377 /******************************************************************************
378 * CoDisconnectObject [COMPOBJ.15]
380 HRESULT WINAPI
CoDisconnectObject( LPUNKNOWN lpUnk
, DWORD reserved
)
382 TRACE("%p %lx\n",lpUnk
,reserved
);
386 /***********************************************************************
387 * IsEqualGUID16 [COMPOBJ.18]
389 * Compares two Unique Identifiers.
394 BOOL16 WINAPI
IsEqualGUID16(
395 GUID
* g1
, /* [in] unique id 1 */
396 GUID
* g2
/* [in] unique id 2 */
398 return !memcmp( g1
, g2
, sizeof(GUID
) );
401 /******************************************************************************
402 * CLSIDFromString16 [COMPOBJ.20]
403 * Converts a unique identifier from its string representation into
406 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
411 HRESULT WINAPI
CLSIDFromString16(
412 LPCOLESTR16 idstr
, /* [in] string representation of guid */
413 CLSID
*id
/* [out] GUID converted from string */
415 BYTE
*s
= (BYTE
*) idstr
;
421 s
= "{00000000-0000-0000-0000-000000000000}";
422 else { /* validate the CLSID string */
425 return CO_E_CLASSSTRING
;
427 if ((s
[0]!='{') || (s
[9]!='-') || (s
[14]!='-') || (s
[19]!='-') || (s
[24]!='-') || (s
[37]!='}'))
428 return CO_E_CLASSSTRING
;
432 if ((i
== 9)||(i
== 14)||(i
== 19)||(i
== 24)) continue;
433 if (!(((s
[i
] >= '0') && (s
[i
] <= '9')) ||
434 ((s
[i
] >= 'a') && (s
[i
] <= 'f')) ||
435 ((s
[i
] >= 'A') && (s
[i
] <= 'F')))
437 return CO_E_CLASSSTRING
;
441 TRACE("%s -> %p\n", s
, id
);
443 /* quick lookup table */
444 memset(table
, 0, 256);
446 for (i
= 0; i
< 10; i
++) {
449 for (i
= 0; i
< 6; i
++) {
450 table
['A' + i
] = i
+10;
451 table
['a' + i
] = i
+10;
454 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
458 s
++; /* skip leading brace */
459 for (i
= 0; i
< 4; i
++) {
460 p
[3 - i
] = table
[*s
]<<4 | table
[*(s
+1)];
466 for (i
= 0; i
< 2; i
++) {
467 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
473 for (i
= 0; i
< 2; i
++) {
474 p
[1-i
] = table
[*s
]<<4 | table
[*(s
+1)];
480 /* these are just sequential bytes */
481 for (i
= 0; i
< 2; i
++) {
482 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
487 for (i
= 0; i
< 6; i
++) {
488 *p
++ = table
[*s
]<<4 | table
[*(s
+1)];
495 /******************************************************************************
496 * CoCreateGuid[OLE32.6]
499 HRESULT WINAPI
CoCreateGuid(
500 GUID
*pguid
/* [out] points to the GUID to initialize */
502 return UuidCreate(pguid
);
505 /******************************************************************************
506 * CLSIDFromString [OLE32.3]
507 * Converts a unique identifier from its string representation into
511 * If idstr is not a valid CLSID string then it gets treated as a ProgID
516 HRESULT WINAPI
CLSIDFromString(
517 LPCOLESTR idstr
, /* [in] string representation of GUID */
518 CLSID
*id
/* [out] GUID represented by above string */
520 LPOLESTR16 xid
= HEAP_strdupWtoA(GetProcessHeap(),0,idstr
);
521 HRESULT ret
= CLSIDFromString16(xid
,id
);
523 HeapFree(GetProcessHeap(),0,xid
);
524 if(ret
!= S_OK
) { /* It appears a ProgID is also valid */
525 ret
= CLSIDFromProgID(idstr
, id
);
530 /******************************************************************************
531 * WINE_StringFromCLSID [Internal]
532 * Converts a GUID into the respective string representation.
537 * the string representation and HRESULT
539 static HRESULT
WINE_StringFromCLSID(
540 const CLSID
*id
, /* [in] GUID to be converted */
541 LPSTR idstr
/* [out] pointer to buffer to contain converted guid */
543 static const char *hex
= "0123456789ABCDEF";
548 { ERR("called with id=Null\n");
553 sprintf(idstr
, "{%08lX-%04X-%04X-%02X%02X-",
554 id
->Data1
, id
->Data2
, id
->Data3
,
555 id
->Data4
[0], id
->Data4
[1]);
559 for (i
= 2; i
< 8; i
++) {
560 *s
++ = hex
[id
->Data4
[i
]>>4];
561 *s
++ = hex
[id
->Data4
[i
] & 0xf];
567 TRACE("%p->%s\n", id
, idstr
);
572 /******************************************************************************
573 * StringFromCLSID16 [COMPOBJ.19]
574 * Converts a GUID into the respective string representation.
575 * The target string is allocated using the OLE IMalloc.
577 * the string representation and HRESULT
579 HRESULT WINAPI
StringFromCLSID16(
580 REFCLSID id
, /* [in] the GUID to be converted */
581 LPOLESTR16
*idstr
/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
588 ret
= CoGetMalloc16(0,&mllc
);
591 args
[0] = (DWORD
)mllc
;
594 /* No need for a Callback entry, we have WOWCallback16Ex which does
595 * everything we need.
597 if (!WOWCallback16Ex(
598 (DWORD
)((ICOM_VTABLE(IMalloc16
)*)PTR_SEG_TO_LIN(
599 ICOM_VTBL(((LPMALLOC16
)PTR_SEG_TO_LIN(mllc
))))
606 WARN("CallTo16 IMalloc16 failed\n");
609 return WINE_StringFromCLSID(id
,PTR_SEG_TO_LIN(*idstr
));
612 /******************************************************************************
613 * StringFromCLSID [OLE32.151]
614 * Converts a GUID into the respective string representation.
615 * The target string is allocated using the OLE IMalloc.
617 * the string representation and HRESULT
619 HRESULT WINAPI
StringFromCLSID(
620 REFCLSID id
, /* [in] the GUID to be converted */
621 LPOLESTR
*idstr
/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
627 if ((ret
=CoGetMalloc(0,&mllc
)))
630 ret
=WINE_StringFromCLSID(id
,buf
);
632 *idstr
= IMalloc_Alloc(mllc
,strlen(buf
)*2+2);
633 lstrcpyAtoW(*idstr
,buf
);
638 /******************************************************************************
639 * StringFromGUID2 [COMPOBJ.76] [OLE32.152]
641 * Converts a global unique identifier into a string of an API-
642 * specified fixed format. (The usual {.....} stuff.)
645 * The (UNICODE) string representation of the GUID in 'str'
646 * The length of the resulting string, 0 if there was any problem.
649 StringFromGUID2(REFGUID id
, LPOLESTR str
, INT cmax
)
653 if (WINE_StringFromCLSID(id
,xguid
))
655 if (strlen(xguid
)>=cmax
)
657 lstrcpyAtoW(str
,xguid
);
658 return strlen(xguid
) + 1;
661 /******************************************************************************
662 * ProgIDFromCLSID [OLE32.133]
663 * Converts a class id into the respective Program ID. (By using a registry lookup)
664 * RETURNS S_OK on success
665 * riid associated with the progid
668 HRESULT WINAPI
ProgIDFromCLSID(
669 REFCLSID clsid
, /* [in] class id as found in registry */
670 LPOLESTR
*lplpszProgID
/* [out] associated Prog ID */
673 char strCLSID
[50], *buf
, *buf2
;
679 WINE_StringFromCLSID(clsid
, strCLSID
);
681 buf
= HeapAlloc(GetProcessHeap(), 0, strlen(strCLSID
)+14);
682 sprintf(buf
,"CLSID\\%s\\ProgID", strCLSID
);
683 if (RegOpenKeyA(HKEY_CLASSES_ROOT
, buf
, &xhkey
))
684 ret
= REGDB_E_CLASSNOTREG
;
686 HeapFree(GetProcessHeap(), 0, buf
);
690 buf2
= HeapAlloc(GetProcessHeap(), 0, 255);
692 if (RegQueryValueA(xhkey
, NULL
, buf2
, &buf2len
))
693 ret
= REGDB_E_CLASSNOTREG
;
697 if (CoGetMalloc(0,&mllc
))
701 *lplpszProgID
= IMalloc_Alloc(mllc
, (buf2len
+1)*2);
702 lstrcpyAtoW(*lplpszProgID
, buf2
);
705 HeapFree(GetProcessHeap(), 0, buf2
);
712 /******************************************************************************
713 * CLSIDFromProgID16 [COMPOBJ.61]
714 * Converts a program id into the respective GUID. (By using a registry lookup)
716 * riid associated with the progid
718 HRESULT WINAPI
CLSIDFromProgID16(
719 LPCOLESTR16 progid
, /* [in] program id as found in registry */
720 LPCLSID riid
/* [out] associated CLSID */
727 buf
= HeapAlloc(GetProcessHeap(),0,strlen(progid
)+8);
728 sprintf(buf
,"%s\\CLSID",progid
);
729 if ((err
=RegOpenKeyA(HKEY_CLASSES_ROOT
,buf
,&xhkey
))) {
730 HeapFree(GetProcessHeap(),0,buf
);
731 return CO_E_CLASSSTRING
;
733 HeapFree(GetProcessHeap(),0,buf
);
734 buf2len
= sizeof(buf2
);
735 if ((err
=RegQueryValueA(xhkey
,NULL
,buf2
,&buf2len
))) {
737 return CO_E_CLASSSTRING
;
740 return CLSIDFromString16(buf2
,riid
);
743 /******************************************************************************
744 * CLSIDFromProgID [OLE32.2]
745 * Converts a program id into the respective GUID. (By using a registry lookup)
747 * riid associated with the progid
749 HRESULT WINAPI
CLSIDFromProgID(
750 LPCOLESTR progid
, /* [in] program id as found in registry */
751 LPCLSID riid
/* [out] associated CLSID */
753 LPOLESTR16 pid
= HEAP_strdupWtoA(GetProcessHeap(),0,progid
);
754 HRESULT ret
= CLSIDFromProgID16(pid
,riid
);
756 HeapFree(GetProcessHeap(),0,pid
);
760 /***********************************************************************
763 * This function write a CLSID on stream
765 HRESULT WINAPI
WriteClassStm(IStream
*pStm
,REFCLSID rclsid
)
767 TRACE("(%p,%p)\n",pStm
,rclsid
);
772 return IStream_Write(pStm
,rclsid
,sizeof(CLSID
),NULL
);
775 /***********************************************************************
778 * This function read a CLSID from a stream
780 HRESULT WINAPI
ReadClassStm(IStream
*pStm
,REFCLSID rclsid
)
785 TRACE("(%p,%p)\n",pStm
,rclsid
);
790 res
= IStream_Read(pStm
,(void*)rclsid
,sizeof(CLSID
),&nbByte
);
795 if (nbByte
!= sizeof(CLSID
))
801 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
802 /***********************************************************************
803 * LookupETask (COMPOBJ.94)
805 HRESULT WINAPI
LookupETask16(HTASK16
*hTask
,LPVOID p
) {
806 FIXME("(%p,%p),stub!\n",hTask
,p
);
807 if ((*hTask
= GetCurrentTask()) == hETask
) {
808 memcpy(p
, Table_ETask
, sizeof(Table_ETask
));
813 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
814 /***********************************************************************
815 * SetETask (COMPOBJ.95)
817 HRESULT WINAPI
SetETask16(HTASK16 hTask
, LPVOID p
) {
818 FIXME("(%04x,%p),stub!\n",hTask
,p
);
823 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
824 /***********************************************************************
825 * CallObjectInWOW (COMPOBJ.201)
827 HRESULT WINAPI
CallObjectInWOW(LPVOID p1
,LPVOID p2
) {
828 FIXME("(%p,%p),stub!\n",p1
,p2
);
832 /******************************************************************************
833 * CoRegisterClassObject16 [COMPOBJ.5]
835 * Don't know where it registers it ...
837 HRESULT WINAPI
CoRegisterClassObject16(
840 DWORD dwClsContext
, /* [in] CLSCTX flags indicating the context in which to run the executable */
841 DWORD flags
, /* [in] REGCLS flags indicating how connections are made */
846 WINE_StringFromCLSID(rclsid
,buf
);
848 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
849 buf
,pUnk
,dwClsContext
,flags
,lpdwRegister
855 /******************************************************************************
856 * CoRevokeClassObject16 [COMPOBJ.6]
859 HRESULT WINAPI
CoRevokeClassObject16(DWORD dwRegister
/* token on class obj */)
861 FIXME("(0x%08lx),stub!\n", dwRegister
);
867 * COM_GetRegisteredClassObject
869 * This internal method is used to scan the registered class list to
870 * find a class object.
873 * rclsid Class ID of the class to find.
874 * dwClsContext Class context to match.
875 * ppv [out] returns a pointer to the class object. Complying
876 * to normal COM usage, this method will increase the
877 * reference count on this object.
879 static HRESULT
COM_GetRegisteredClassObject(
884 RegisteredClass
* curClass
;
892 * Iterate through the whole list and try to match the class ID.
894 curClass
= firstRegisteredClass
;
896 while (curClass
!= 0)
899 * Check if we have a match on the class ID.
901 if (IsEqualGUID(&(curClass
->classIdentifier
), rclsid
))
904 * Since we don't do out-of process or DCOM just right away, let's ignore the
909 * We have a match, return the pointer to the class object.
911 *ppUnk
= curClass
->classObject
;
913 IUnknown_AddRef(curClass
->classObject
);
919 * Step to the next class in the list.
921 curClass
= curClass
->nextClass
;
925 * If we get to here, we haven't found our class.
930 /******************************************************************************
931 * CoRegisterClassObject [OLE32.36]
933 * This method will register the class object for a given class ID.
935 * See the Windows documentation for more details.
937 HRESULT WINAPI
CoRegisterClassObject(
940 DWORD dwClsContext
, /* [in] CLSCTX flags indicating the context in which to run the executable */
941 DWORD flags
, /* [in] REGCLS flags indicating how connections are made */
945 RegisteredClass
* newClass
;
946 LPUNKNOWN foundObject
;
950 WINE_StringFromCLSID(rclsid
,buf
);
952 TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n",
953 buf
,pUnk
,dwClsContext
,flags
,lpdwRegister
);
956 * Perform a sanity check on the parameters
958 if ( (lpdwRegister
==0) || (pUnk
==0) )
964 * Initialize the cookie (out parameter)
969 * First, check if the class is already registered.
970 * If it is, this should cause an error.
972 hr
= COM_GetRegisteredClassObject(rclsid
, dwClsContext
, &foundObject
);
977 * The COM_GetRegisteredClassObject increased the reference count on the
978 * object so it has to be released.
980 IUnknown_Release(foundObject
);
982 return CO_E_OBJISREG
;
986 * If it is not registered, we must create a new entry for this class and
987 * append it to the registered class list.
988 * We use the address of the chain node as the cookie since we are sure it's
991 newClass
= HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass
));
994 * Initialize the node.
996 newClass
->classIdentifier
= *rclsid
;
997 newClass
->runContext
= dwClsContext
;
998 newClass
->connectFlags
= flags
;
999 newClass
->dwCookie
= (DWORD
)newClass
;
1000 newClass
->nextClass
= firstRegisteredClass
;
1003 * Since we're making a copy of the object pointer, we have to increase its
1006 newClass
->classObject
= pUnk
;
1007 IUnknown_AddRef(newClass
->classObject
);
1009 firstRegisteredClass
= newClass
;
1012 * Assign the out parameter (cookie)
1014 *lpdwRegister
= newClass
->dwCookie
;
1017 * We're successful Yippee!
1022 /***********************************************************************
1023 * CoRevokeClassObject [OLE32.40]
1025 * This method will remove a class object from the class registry
1027 * See the Windows documentation for more details.
1029 HRESULT WINAPI
CoRevokeClassObject(
1032 RegisteredClass
** prevClassLink
;
1033 RegisteredClass
* curClass
;
1035 TRACE("(%08lx)\n",dwRegister
);
1038 * Iterate through the whole list and try to match the cookie.
1040 curClass
= firstRegisteredClass
;
1041 prevClassLink
= &firstRegisteredClass
;
1043 while (curClass
!= 0)
1046 * Check if we have a match on the cookie.
1048 if (curClass
->dwCookie
== dwRegister
)
1051 * Remove the class from the chain.
1053 *prevClassLink
= curClass
->nextClass
;
1056 * Release the reference to the class object.
1058 IUnknown_Release(curClass
->classObject
);
1061 * Free the memory used by the chain node.
1063 HeapFree(GetProcessHeap(), 0, curClass
);
1069 * Step to the next class in the list.
1071 prevClassLink
= &(curClass
->nextClass
);
1072 curClass
= curClass
->nextClass
;
1076 * If we get to here, we haven't found our class.
1078 return E_INVALIDARG
;
1081 /***********************************************************************
1082 * CoGetClassObject [COMPOBJ.7]
1084 HRESULT WINAPI
CoGetClassObject(REFCLSID rclsid
, DWORD dwClsContext
,
1085 LPVOID pvReserved
, REFIID iid
, LPVOID
*ppv
)
1087 LPUNKNOWN regClassObject
;
1088 HRESULT hres
= E_UNEXPECTED
;
1090 WCHAR dllName
[MAX_PATH
+1];
1091 DWORD dllNameLen
= sizeof(dllName
);
1093 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
,
1094 REFIID iid
, LPVOID
*ppv
);
1095 DllGetClassObjectFunc DllGetClassObject
;
1097 WINE_StringFromCLSID((LPCLSID
)rclsid
,xclsid
);
1099 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",
1100 debugstr_guid(rclsid
),
1105 * First, try and see if we can't match the class ID with one of the
1106 * registered classes.
1108 if (S_OK
== COM_GetRegisteredClassObject(rclsid
, dwClsContext
, ®ClassObject
))
1111 * Get the required interface from the retrieved pointer.
1113 hres
= IUnknown_QueryInterface(regClassObject
, iid
, ppv
);
1116 * Since QI got another reference on the pointer, we want to release the
1117 * one we already have. If QI was unsuccessful, this will release the object. This
1118 * is good since we are not returning it in the "out" parameter.
1120 IUnknown_Release(regClassObject
);
1125 /* out of process and remote servers not supported yet */
1126 if (((CLSCTX_LOCAL_SERVER
|CLSCTX_REMOTE_SERVER
) & dwClsContext
)
1127 && !((CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
) & dwClsContext
)){
1128 FIXME("CLSCTX_LOCAL_SERVER and CLSCTX_REMOTE_SERVER not supported!\n");
1129 return E_ACCESSDENIED
;
1132 if ((CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
) & dwClsContext
) {
1134 WCHAR valname
[]={ 'I','n','p','r','o','c',
1135 'S','e','r','v','e','r','3','2',0};
1137 /* lookup CLSID in registry key HKCR/CLSID */
1138 hres
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "CLSID", 0,
1139 KEY_READ
, &CLSIDkey
);
1141 if (hres
!= ERROR_SUCCESS
)
1142 return REGDB_E_READREGDB
;
1143 hres
= RegOpenKeyExA(CLSIDkey
,xclsid
,0,KEY_QUERY_VALUE
,&key
);
1144 if (hres
!= ERROR_SUCCESS
) {
1145 RegCloseKey(CLSIDkey
);
1146 return REGDB_E_CLASSNOTREG
;
1148 memset(dllName
,0,sizeof(dllName
));
1149 hres
= RegQueryValueW(key
, valname
, dllName
, &dllNameLen
);
1151 ERR("RegQueryValue of %s failed with hres %lx\n",debugstr_w(dllName
),hres
);
1152 return REGDB_E_CLASSNOTREG
; /* FIXME: check retval */
1155 RegCloseKey(CLSIDkey
);
1156 if (hres
!= ERROR_SUCCESS
)
1157 return REGDB_E_READREGDB
;
1158 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName
));
1160 /* open dll, call DllGetClassObject */
1161 hLibrary
= CoLoadLibrary(dllName
, TRUE
);
1162 if (hLibrary
== 0) {
1163 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName
));
1164 return E_ACCESSDENIED
; /* or should this be CO_E_DLLNOTFOUND? */
1166 DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject");
1167 if (!DllGetClassObject
) {
1168 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
1169 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName
));
1170 return E_ACCESSDENIED
;
1174 * Ask the DLL for its class object. (there was a note here about class
1175 * factories but this is good.
1177 return DllGetClassObject(rclsid
, iid
, ppv
);
1182 /***********************************************************************
1183 * CoResumeClassObjects
1185 * Resumes classobjects registered with REGCLS suspended
1187 HRESULT WINAPI
CoResumeClassObjects(void)
1193 /***********************************************************************
1196 * This function supplies the CLSID associated with the given filename.
1198 HRESULT WINAPI
GetClassFile(LPOLESTR filePathName
,CLSID
*pclsid
)
1202 int nbElm
=0,length
=0,i
=0;
1204 LPOLESTR
*pathDec
=0,absFile
=0,progId
=0;
1205 WCHAR extention
[100]={0};
1209 /* if the file contain a storage object the return the CLSID writen by IStorage_SetClass method*/
1210 if((StgIsStorageFile(filePathName
))==S_OK
){
1212 res
=StgOpenStorage(filePathName
,NULL
,STGM_READ
| STGM_SHARE_DENY_WRITE
,NULL
,0,&pstg
);
1215 res
=ReadClassStg(pstg
,pclsid
);
1217 IStorage_Release(pstg
);
1221 /* if the file is not a storage object then attemps to match various bits in the file against a
1222 pattern in the registry. this case is not frequently used ! so I present only the psodocode for
1225 for(i=0;i<nFileTypes;i++)
1227 for(i=0;j<nPatternsForType;j++){
1232 pat=ReadPatternFromRegistry(i,j);
1233 hFile=CreateFileW(filePathName,,,,,,hFile);
1234 SetFilePosition(hFile,pat.offset);
1235 ReadFile(hFile,buf,pat.size,NULL,NULL);
1236 if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
1238 *pclsid=ReadCLSIDFromRegistry(i);
1244 /* if the obove strategies fail then search for the extension key in the registry */
1246 /* get the last element (absolute file) in the path name */
1247 nbElm
=FileMonikerImpl_DecomposePath(filePathName
,&pathDec
);
1248 absFile
=pathDec
[nbElm
-1];
1250 /* failed if the path represente a directory and not an absolute file name*/
1251 if (lstrcmpW(absFile
,(LPOLESTR
)"\\"))
1252 return MK_E_INVALIDEXTENSION
;
1254 /* get the extension of the file */
1255 length
=lstrlenW(absFile
);
1256 for(i
=length
-1; ( (i
>=0) && (extention
[i
]=absFile
[i
]) );i
--);
1258 /* get the progId associated to the extension */
1259 progId
=CoTaskMemAlloc(sizeProgId
);
1261 res
=RegQueryValueW(HKEY_CLASSES_ROOT
,extention
,progId
,&sizeProgId
);
1263 if (res
==ERROR_MORE_DATA
){
1265 progId
= CoTaskMemRealloc(progId
,sizeProgId
);
1266 res
=RegQueryValueW(HKEY_CLASSES_ROOT
,extention
,progId
,&sizeProgId
);
1268 if (res
==ERROR_SUCCESS
)
1269 /* return the clsid associated to the progId */
1270 res
= CLSIDFromProgID(progId
,pclsid
);
1272 for(i
=0; pathDec
[i
]!=NULL
;i
++)
1273 CoTaskMemFree(pathDec
[i
]);
1274 CoTaskMemFree(pathDec
);
1276 CoTaskMemFree(progId
);
1278 if (res
==ERROR_SUCCESS
)
1281 return MK_E_INVALIDEXTENSION
;
1283 /******************************************************************************
1284 * CoRegisterMessageFilter16 [COMPOBJ.27]
1286 HRESULT WINAPI
CoRegisterMessageFilter16(
1287 LPMESSAGEFILTER lpMessageFilter
,
1288 LPMESSAGEFILTER
*lplpMessageFilter
1290 FIXME("(%p,%p),stub!\n",lpMessageFilter
,lplpMessageFilter
);
1294 /***********************************************************************
1295 * CoCreateInstance [COMPOBJ.13, OLE32.7]
1297 HRESULT WINAPI
CoCreateInstance(
1299 LPUNKNOWN pUnkOuter
,
1305 LPCLASSFACTORY lpclf
= 0;
1314 * Initialize the "out" parameter
1319 * Get a class factory to construct the object we want.
1321 hres
= CoGetClassObject(rclsid
,
1331 * Create the object and don't forget to release the factory
1333 hres
= IClassFactory_CreateInstance(lpclf
, pUnkOuter
, iid
, ppv
);
1334 IClassFactory_Release(lpclf
);
1339 /***********************************************************************
1340 * CoCreateInstanceEx [OLE32.165]
1342 HRESULT WINAPI
CoCreateInstanceEx(
1344 LPUNKNOWN pUnkOuter
,
1346 COSERVERINFO
* pServerInfo
,
1350 IUnknown
* pUnk
= NULL
;
1353 int successCount
= 0;
1358 if ( (cmq
==0) || (pResults
==NULL
))
1359 return E_INVALIDARG
;
1361 if (pServerInfo
!=NULL
)
1362 FIXME("() non-NULL pServerInfo not supported!\n");
1365 * Initialize all the "out" parameters.
1367 for (index
= 0; index
< cmq
; index
++)
1369 pResults
[index
].pItf
= NULL
;
1370 pResults
[index
].hr
= E_NOINTERFACE
;
1374 * Get the object and get its IUnknown pointer.
1376 hr
= CoCreateInstance(rclsid
,
1386 * Then, query for all the interfaces requested.
1388 for (index
= 0; index
< cmq
; index
++)
1390 pResults
[index
].hr
= IUnknown_QueryInterface(pUnk
,
1391 pResults
[index
].pIID
,
1392 (VOID
**)&(pResults
[index
].pItf
));
1394 if (pResults
[index
].hr
== S_OK
)
1399 * Release our temporary unknown pointer.
1401 IUnknown_Release(pUnk
);
1403 if (successCount
== 0)
1404 return E_NOINTERFACE
;
1406 if (successCount
!=cmq
)
1407 return CO_S_NOTALLINTERFACES
;
1412 /***********************************************************************
1413 * CoFreeLibrary [COMPOBJ.13]
1415 void WINAPI
CoFreeLibrary(HINSTANCE hLibrary
)
1417 OpenDll
*ptr
, *prev
;
1420 /* lookup library in linked list */
1422 for (ptr
= openDllList
; ptr
!= NULL
; ptr
=ptr
->next
) {
1423 if (ptr
->hLibrary
== hLibrary
) {
1430 /* shouldn't happen if user passed in a valid hLibrary */
1433 /* assert: ptr points to the library entry to free */
1435 /* free library and remove node from list */
1436 FreeLibrary(hLibrary
);
1437 if (ptr
== openDllList
) {
1438 tmp
= openDllList
->next
;
1439 HeapFree(GetProcessHeap(), 0, openDllList
);
1443 HeapFree(GetProcessHeap(), 0, ptr
);
1450 /***********************************************************************
1451 * CoFreeAllLibraries [COMPOBJ.12]
1453 void WINAPI
CoFreeAllLibraries(void)
1457 for (ptr
= openDllList
; ptr
!= NULL
; ) {
1459 CoFreeLibrary(ptr
->hLibrary
);
1466 /***********************************************************************
1467 * CoFreeUnusedLibraries [COMPOBJ.17]
1469 void WINAPI
CoFreeUnusedLibraries(void)
1472 typedef HRESULT(*DllCanUnloadNowFunc
)(void);
1473 DllCanUnloadNowFunc DllCanUnloadNow
;
1475 for (ptr
= openDllList
; ptr
!= NULL
; ) {
1476 DllCanUnloadNow
= (DllCanUnloadNowFunc
)
1477 GetProcAddress(ptr
->hLibrary
, "DllCanUnloadNow");
1479 if ( (DllCanUnloadNow
!= NULL
) &&
1480 (DllCanUnloadNow() == S_OK
) ) {
1482 CoFreeLibrary(ptr
->hLibrary
);
1490 /***********************************************************************
1491 * CoFileTimeNow [COMPOBJ.82, OLE32.10]
1493 * the current system time in lpFileTime
1495 HRESULT WINAPI
CoFileTimeNow(
1496 FILETIME
*lpFileTime
/* [out] the current time */
1498 DOSFS_UnixTimeToFileTime(time(NULL
), lpFileTime
, 0);
1502 /***********************************************************************
1503 * CoTaskMemAlloc (OLE32.43)
1505 * pointer to newly allocated block
1507 LPVOID WINAPI
CoTaskMemAlloc(
1508 ULONG size
/* [in] size of memoryblock to be allocated */
1511 HRESULT ret
= CoGetMalloc(0,&lpmalloc
);
1516 return IMalloc_Alloc(lpmalloc
,size
);
1518 /***********************************************************************
1519 * CoTaskMemFree (OLE32.44)
1521 VOID WINAPI
CoTaskMemFree(
1522 LPVOID ptr
/* [in] pointer to be freed */
1525 HRESULT ret
= CoGetMalloc(0,&lpmalloc
);
1530 IMalloc_Free(lpmalloc
, ptr
);
1533 /***********************************************************************
1534 * CoTaskMemRealloc (OLE32.45)
1536 * pointer to newly allocated block
1538 LPVOID WINAPI
CoTaskMemRealloc(
1540 ULONG size
) /* [in] size of memoryblock to be allocated */
1543 HRESULT ret
= CoGetMalloc(0,&lpmalloc
);
1548 return IMalloc_Realloc(lpmalloc
, pvOld
, size
);
1551 /***********************************************************************
1552 * CoLoadLibrary (OLE32.30)
1554 HINSTANCE WINAPI
CoLoadLibrary(LPOLESTR lpszLibName
, BOOL bAutoFree
)
1560 TRACE("CoLoadLibrary(%p, %d\n", debugstr_w(lpszLibName
), bAutoFree
);
1562 hLibrary
= LoadLibraryExW(lpszLibName
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
);
1567 if (openDllList
== NULL
) {
1568 /* empty list -- add first node */
1569 openDllList
= (OpenDll
*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll
));
1570 openDllList
->hLibrary
=hLibrary
;
1571 openDllList
->next
= NULL
;
1573 /* search for this dll */
1575 for (ptr
= openDllList
; ptr
->next
!= NULL
; ptr
=ptr
->next
) {
1576 if (ptr
->hLibrary
== hLibrary
) {
1582 /* dll not found, add it */
1584 openDllList
= (OpenDll
*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll
));
1585 openDllList
->hLibrary
= hLibrary
;
1586 openDllList
->next
= tmp
;
1593 /***********************************************************************
1594 * CoInitializeWOW (OLE32.27)
1596 HRESULT WINAPI
CoInitializeWOW(DWORD x
,DWORD y
) {
1597 FIXME("(0x%08lx,0x%08lx),stub!\n",x
,y
);
1601 /******************************************************************************
1602 * CoLockObjectExternal16 [COMPOBJ.63]
1604 HRESULT WINAPI
CoLockObjectExternal16(
1605 LPUNKNOWN pUnk
, /* [in] object to be locked */
1606 BOOL16 fLock
, /* [in] do lock */
1607 BOOL16 fLastUnlockReleases
/* [in] ? */
1609 FIXME("(%p,%d,%d),stub!\n",pUnk
,fLock
,fLastUnlockReleases
);
1613 /******************************************************************************
1614 * CoLockObjectExternal [OLE32.31]
1616 HRESULT WINAPI
CoLockObjectExternal(
1617 LPUNKNOWN pUnk
, /* [in] object to be locked */
1618 BOOL fLock
, /* [in] do lock */
1619 BOOL fLastUnlockReleases
) /* [in] unlock all */
1625 * Increment the external lock coutner, COM_ExternalLockAddRef also
1626 * increment the object's internal lock counter.
1628 COM_ExternalLockAddRef( pUnk
);
1633 * Decrement the external lock coutner, COM_ExternalLockRelease also
1634 * decrement the object's internal lock counter.
1636 COM_ExternalLockRelease( pUnk
, fLastUnlockReleases
);
1642 /***********************************************************************
1643 * CoGetState16 [COMPOBJ.115]
1645 HRESULT WINAPI
CoGetState16(LPDWORD state
)
1647 FIXME("(%p),stub!\n", state
);
1651 /***********************************************************************
1652 * CoSetState [COM32.42]
1654 HRESULT WINAPI
CoSetState(LPDWORD state
)
1656 FIXME("(%p),stub!\n", state
);
1657 if (state
) *state
= 0;
1660 /***********************************************************************
1661 * CoCreateFreeThreadedMarshaler [OLE32.5]
1663 HRESULT WINAPI
CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter
, LPUNKNOWN
* ppunkMarshal
)
1665 FIXME ("(%p %p): stub\n", punkOuter
, ppunkMarshal
);
1671 /***********************************************************************
1672 * DllGetClassObject [OLE32.63]
1674 HRESULT WINAPI
OLE32_DllGetClassObject(REFCLSID rclsid
, REFIID iid
,LPVOID
*ppv
)
1676 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid
),debugstr_guid(iid
));
1678 return CLASS_E_CLASSNOTAVAILABLE
;
1683 * COM_RevokeAllClasses
1685 * This method is called when the COM libraries are uninitialized to
1686 * release all the references to the class objects registered with
1689 static void COM_RevokeAllClasses()
1691 while (firstRegisteredClass
!=0)
1693 CoRevokeClassObject(firstRegisteredClass
->dwCookie
);
1697 /****************************************************************************
1698 * COM External Lock methods implementation
1701 /****************************************************************************
1702 * Public - Method that increments the count for a IUnknown* in the linked
1703 * list. The item is inserted if not already in the list.
1705 static void COM_ExternalLockAddRef(
1708 COM_ExternalLock
*externalLock
= COM_ExternalLockFind(pUnk
);
1711 * Add an external lock to the object. If it was already externally
1712 * locked, just increase the reference count. If it was not.
1713 * add the item to the list.
1715 if ( externalLock
== EL_NOT_FOUND
)
1716 COM_ExternalLockInsert(pUnk
);
1718 externalLock
->uRefCount
++;
1721 * Add an internal lock to the object
1723 IUnknown_AddRef(pUnk
);
1726 /****************************************************************************
1727 * Public - Method that decrements the count for a IUnknown* in the linked
1728 * list. The item is removed from the list if its count end up at zero or if
1731 static void COM_ExternalLockRelease(
1735 COM_ExternalLock
*externalLock
= COM_ExternalLockFind(pUnk
);
1737 if ( externalLock
!= EL_NOT_FOUND
)
1741 externalLock
->uRefCount
--; /* release external locks */
1742 IUnknown_Release(pUnk
); /* release local locks as well */
1744 if ( bRelAll
== FALSE
)
1745 break; /* perform single release */
1747 } while ( externalLock
->uRefCount
> 0 );
1749 if ( externalLock
->uRefCount
== 0 ) /* get rid of the list entry */
1750 COM_ExternalLockDelete(externalLock
);
1753 /****************************************************************************
1754 * Public - Method that frees the content of the list.
1756 static void COM_ExternalLockFreeList()
1758 COM_ExternalLock
*head
;
1760 head
= elList
.head
; /* grab it by the head */
1761 while ( head
!= EL_END_OF_LIST
)
1763 COM_ExternalLockDelete(head
); /* get rid of the head stuff */
1765 head
= elList
.head
; /* get the new head... */
1769 /****************************************************************************
1770 * Public - Method that dump the content of the list.
1772 void COM_ExternalLockDump()
1774 COM_ExternalLock
*current
= elList
.head
;
1776 DPRINTF("\nExternal lock list contains:\n");
1778 while ( current
!= EL_END_OF_LIST
)
1780 DPRINTF( "\t%p with %lu references count.\n", current
->pUnk
, current
->uRefCount
);
1782 /* Skip to the next item */
1783 current
= current
->next
;
1788 /****************************************************************************
1789 * Internal - Find a IUnknown* in the linked list
1791 static COM_ExternalLock
* COM_ExternalLockFind(
1794 return COM_ExternalLockLocate(elList
.head
, pUnk
);
1797 /****************************************************************************
1798 * Internal - Recursivity agent for IUnknownExternalLockList_Find
1800 static COM_ExternalLock
* COM_ExternalLockLocate(
1801 COM_ExternalLock
*element
,
1804 if ( element
== EL_END_OF_LIST
)
1805 return EL_NOT_FOUND
;
1807 else if ( element
->pUnk
== pUnk
) /* We found it */
1810 else /* Not the right guy, keep on looking */
1811 return COM_ExternalLockLocate( element
->next
, pUnk
);
1814 /****************************************************************************
1815 * Internal - Insert a new IUnknown* to the linked list
1817 static BOOL
COM_ExternalLockInsert(
1820 COM_ExternalLock
*newLock
= NULL
;
1821 COM_ExternalLock
*previousHead
= NULL
;
1824 * Allocate space for the new storage object
1826 newLock
= HeapAlloc(GetProcessHeap(), 0, sizeof(COM_ExternalLock
));
1830 if ( elList
.head
== EL_END_OF_LIST
)
1832 elList
.head
= newLock
; /* The list is empty */
1837 * insert does it at the head
1839 previousHead
= elList
.head
;
1840 elList
.head
= newLock
;
1844 * Set new list item data member
1846 newLock
->pUnk
= pUnk
;
1847 newLock
->uRefCount
= 1;
1848 newLock
->next
= previousHead
;
1856 /****************************************************************************
1857 * Internal - Method that removes an item from the linked list.
1859 static void COM_ExternalLockDelete(
1860 COM_ExternalLock
*itemList
)
1862 COM_ExternalLock
*current
= elList
.head
;
1864 if ( current
== itemList
)
1867 * this section handles the deletion of the first node
1869 elList
.head
= itemList
->next
;
1870 HeapFree( GetProcessHeap(), 0, itemList
);
1876 if ( current
->next
== itemList
) /* We found the item to free */
1878 current
->next
= itemList
->next
; /* readjust the list pointers */
1880 HeapFree( GetProcessHeap(), 0, itemList
);
1884 /* Skip to the next item */
1885 current
= current
->next
;
1887 } while ( current
!= EL_END_OF_LIST
);
1891 /***********************************************************************
1892 * COMPOBJ_DllEntryPoint [COMPOBJ.entry]
1894 * Initialization code for the COMPOBJ DLL
1898 BOOL WINAPI
COMPOBJ_DllEntryPoint(DWORD Reason
, HINSTANCE16 hInst
, WORD ds
, WORD HeapSize
, DWORD res1
, WORD res2
)
1900 TRACE("(%08lx, %04x, %04x, %04x, %08lx, %04x)\n", Reason
, hInst
, ds
, HeapSize
,
1904 case DLL_PROCESS_ATTACH
:
1906 if(COMPOBJ_hInstance
)
1908 ERR("compobj.dll instantiated twice!\n");
1910 * We should return FALSE here, but that will break
1911 * most apps that use CreateProcess because we do
1912 * not yet support seperate address-spaces.
1917 COMPOBJ_hInstance
= hInst
;
1920 case DLL_PROCESS_DETACH
:
1921 if(!--COMPOBJ_Attach
)
1922 COMPOBJ_hInstance
= 0;
1928 /******************************************************************************
1929 * OleGetAutoConvert [OLE32.104]
1931 HRESULT WINAPI
OleGetAutoConvert(REFCLSID clsidOld
, LPCLSID pClsidNew
)
1938 sprintf(buf
,"CLSID\\");WINE_StringFromCLSID(clsidOld
,&buf
[6]);
1939 if (RegOpenKeyA(HKEY_CLASSES_ROOT
,buf
,&hkey
))
1940 return REGDB_E_CLASSNOTREG
;
1942 if (RegQueryValueA(hkey
,"AutoConvertTo",buf
,&len
))
1943 return REGDB_E_KEYMISSING
;
1945 lstrcpyAtoW(wbuf
,buf
);
1946 CLSIDFromString(wbuf
,pClsidNew
);
1950 /***********************************************************************
1951 * IsEqualGUID [OLE32.76]
1953 * Compares two Unique Identifiers.
1959 BOOL WINAPI
IsEqualGUID(
1960 REFGUID rguid1
, /* [in] unique id 1 */
1961 REFGUID rguid2
/* [in] unique id 2 */
1964 return !memcmp(rguid1
,rguid2
,sizeof(GUID
));