Changeset 7926 for trunk/src/ole32/compobj.c
- Timestamp:
- Feb 15, 2002, 6:18:52 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/compobj.c
r7508 r7926 6 6 * Copyright 1999 Francis Beaudet 7 7 * Copyright 1999 Sylvain St-Germain 8 * Copyright 2002 Marcus Meissner 8 9 */ 9 10 … … 14 15 #include <string.h> 15 16 #include <assert.h> 17 16 18 #include "windef.h" 19 #include "objbase.h" 20 #include "ole2.h" 21 #include "ole2ver.h" 22 #include "rpc.h" 23 #include "winerror.h" 24 #include "winreg.h" 25 #include "wownt32.h" 17 26 #include "wtypes.h" 18 #include "wingdi.h" 27 #include "wine/unicode.h" 28 #include "wine/obj_base.h" 29 #include "wine/obj_clientserver.h" 30 #include "wine/obj_misc.h" 31 #include "wine/obj_marshal.h" 32 #include "wine/obj_storage.h" 33 #include "wine/obj_channel.h" 19 34 #include "wine/winbase16.h" 20 #include " winerror.h"21 #include " wownt32.h"22 #include "ole2ver.h" 35 #include "compobj_private.h" 36 #include "ifs.h" 37 23 38 #include "debugtools.h" 24 #include "heap.h"25 #include "winreg.h"26 #include "rpc.h"27 28 #include "wine/obj_base.h"29 #include "wine/obj_misc.h"30 #include "wine/obj_storage.h"31 #include "wine/obj_clientserver.h"32 33 #include "ole.h"34 #include "ifs.h"35 #include "compobj_private.h"36 37 #ifdef __WIN32OS2__38 #include <heapstring.h>39 #endif40 39 41 40 DEFAULT_DEBUG_CHANNEL(ole); … … 44 43 * COM External Lock structures and methods declaration 45 44 * 46 * This api provides a linked list to managed external references to 47 * COM objects. 48 * 49 * The public interface consists of three calls: 45 * This api provides a linked list to managed external references to 46 * COM objects. 47 * 48 * The public interface consists of three calls: 50 49 * COM_ExternalLockAddRef 51 50 * COM_ExternalLockRelease … … 57 56 58 57 /* 59 * Declaration of the static structure that manage the 58 * Declaration of the static structure that manage the 60 59 * external lock to COM objects. 61 60 */ … … 82 81 83 82 /* 84 * Public Interface to the external lock list 83 * Public Interface to the external lock list 85 84 */ 86 85 static void COM_ExternalLockFreeList(); … … 90 89 91 90 /* 92 * Private methods used to managed the linked list 91 * Private methods used to managed the linked list 93 92 */ 94 93 static BOOL COM_ExternalLockInsert( … … 125 124 * libraries are freed 126 125 */ 127 static ULONG s_COMLockCount = 0;126 static LONG s_COMLockCount = 0; 128 127 129 128 /* … … 142 141 DWORD connectFlags; 143 142 DWORD dwCookie; 143 HANDLE hThread; /* only for localserver */ 144 144 struct tagRegisteredClass* nextClass; 145 145 } RegisteredClass; 146 146 147 static CRITICAL_SECTION csRegisteredClassList; 147 148 static RegisteredClass* firstRegisteredClass = NULL; 148 149 … … 152 153 */ 153 154 typedef struct tagOpenDll { 154 HINSTANCE hLibrary; 155 HINSTANCE hLibrary; 155 156 struct tagOpenDll *next; 156 157 } OpenDll; 157 158 159 static CRITICAL_SECTION csOpenDllList; 158 160 static OpenDll *openDllList = NULL; /* linked list of open dlls */ 159 161 … … 170 172 171 173 /****************************************************************************** 174 * Initialize/Uninitialize critical sections. 175 */ 176 void COMPOBJ_InitProcess( void ) 177 { 178 InitializeCriticalSection( &csRegisteredClassList ); 179 InitializeCriticalSection( &csOpenDllList ); 180 } 181 182 void COMPOBJ_UninitProcess( void ) 183 { 184 DeleteCriticalSection( &csRegisteredClassList ); 185 DeleteCriticalSection( &csOpenDllList ); 186 } 187 188 /****************************************************************************** 172 189 * CoBuildVersion [COMPOBJ.1] 190 * CoBuildVersion [OLE32.4] 173 191 * 174 192 * RETURNS … … 181 199 } 182 200 183 #ifndef __WIN32OS2__ 184 /****************************************************************************** 185 * CoInitialize16 [COMPOBJ.2] 201 /****************************************************************************** 202 * CoInitialize [COMPOBJ.2] 186 203 * Set the win16 IMalloc used for memory management 187 204 */ … … 192 209 return S_OK; 193 210 } 194 #endif195 211 196 212 /****************************************************************************** … … 204 220 LPVOID lpReserved /* [in] pointer to win32 malloc interface 205 221 (obsolete, should be NULL) */ 206 ) 222 ) 207 223 { 208 224 /* … … 225 241 * 226 242 * BUGS 227 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 243 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 228 244 * is never returned. 229 245 * … … 234 250 (obsolete, should be NULL) */ 235 251 DWORD dwCoInit /* [in] A value from COINIT specifies the threading model */ 236 ) 252 ) 237 253 { 238 254 HRESULT hr; … … 248 264 * Check for unsupported features. 249 265 */ 250 if (dwCoInit!=COINIT_APARTMENTTHREADED) 266 if (dwCoInit!=COINIT_APARTMENTTHREADED) 251 267 { 252 268 FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit); … … 257 273 * Check the lock count. If this is the first time going through the initialize 258 274 * process, we have to initialize the libraries. 275 * 276 * And crank-up that lock count. 259 277 */ 260 if ( s_COMLockCount==0)278 if (InterlockedExchangeAdd(&s_COMLockCount,1)==0) 261 279 { 262 280 /* … … 265 283 TRACE("() - Initializing the COM libraries\n"); 266 284 285 267 286 RunningObjectTableImpl_Initialize(); 268 287 … … 272 291 hr = S_FALSE; 273 292 274 /*275 * Crank-up that lock count.276 */277 s_COMLockCount++;278 279 293 return hr; 280 294 } 281 295 282 #ifndef __WIN32OS2__ 283 /*********************************************************************** 284 * CoUninitialize16 [COMPOBJ.3] 285 * Don't know what it does. 296 /*********************************************************************** 297 * CoUninitialize [COMPOBJ.3] 298 * Don't know what it does. 286 299 * 3-Nov-98 -- this was originally misspelled, I changed it to what I 287 300 * believe is the correct spelling … … 292 305 CoFreeAllLibraries(); 293 306 } 294 #endif295 307 296 308 /*********************************************************************** … … 303 315 void WINAPI CoUninitialize(void) 304 316 { 317 LONG lCOMRefCnt; 305 318 TRACE("()\n"); 306 319 307 320 /* 308 321 * Decrease the reference count. 309 */310 s_COMLockCount--;311 312 /*313 322 * If we are back to 0 locks on the COM library, make sure we free 314 323 * all the associated data structures. 315 324 */ 316 if (s_COMLockCount==0) 325 lCOMRefCnt = InterlockedExchangeAdd(&s_COMLockCount,-1); 326 if (lCOMRefCnt==1) 317 327 { 318 328 /* … … 336 346 */ 337 347 COM_ExternalLockFreeList(); 338 } 348 349 } 350 else if (lCOMRefCnt<1) { 351 ERR( "CoUninitialize() - not CoInitialized.\n" ); 352 InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */ 353 } 339 354 } 340 355 341 356 #ifndef __WIN32OS2__ 342 357 /*********************************************************************** 343 * CoGetMalloc 16[COMPOBJ.4]358 * CoGetMalloc [COMPOBJ.4] 344 359 * RETURNS 345 360 * The current win16 IMalloc … … 355 370 } 356 371 #endif 357 358 372 /****************************************************************************** 359 373 * CoGetMalloc [OLE32.20] … … 374 388 #ifndef __WIN32OS2__ 375 389 /*********************************************************************** 376 * CoCreateStandardMalloc 16[COMPOBJ.71]390 * CoCreateStandardMalloc [COMPOBJ.71] 377 391 */ 378 392 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, … … 384 398 return S_OK; 385 399 } 400 #endif 386 401 387 402 /****************************************************************************** 388 403 * CoDisconnectObject [COMPOBJ.15] 404 * CoDisconnectObject [OLE32.8] 389 405 */ 390 406 HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) … … 395 411 396 412 /*********************************************************************** 397 * IsEqualGUID 16[COMPOBJ.18]413 * IsEqualGUID [COMPOBJ.18] 398 414 * 399 415 * Compares two Unique Identifiers. … … 408 424 return !memcmp( g1, g2, sizeof(GUID) ); 409 425 } 410 #endif 411 412 /****************************************************************************** 413 * CLSIDFromString16 [COMPOBJ.20] 414 * Converts a unique identifier from its string representation into 426 427 /****************************************************************************** 428 * CLSIDFromString [COMPOBJ.20] 429 * Converts a unique identifier from its string representation into 415 430 * the GUID struct. 416 431 * 417 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 432 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 418 433 * 419 434 * RETURNS … … 516 531 /****************************************************************************** 517 532 * CLSIDFromString [OLE32.3] 518 * Converts a unique identifier from its string representation into 533 * IIDFromString [OLE32.74] 534 * Converts a unique identifier from its string representation into 519 535 * the GUID struct. 520 536 * … … 527 543 HRESULT WINAPI CLSIDFromString( 528 544 LPCOLESTR idstr, /* [in] string representation of GUID */ 529 CLSID *id /* [out] GUID represented by above string */ 530 ) { 531 LPOLESTR16 xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr); 532 HRESULT ret = CLSIDFromString16(xid,id); 533 534 HeapFree(GetProcessHeap(),0,xid); 545 CLSID *id ) /* [out] GUID represented by above string */ 546 { 547 char xid[40]; 548 HRESULT ret; 549 550 if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL )) 551 return CO_E_CLASSSTRING; 552 ret = CLSIDFromString16(xid,id); 535 553 if(ret != S_OK) { /* It appears a ProgID is also valid */ 536 554 ret = CLSIDFromProgID(idstr, id); … … 548 566 * the string representation and HRESULT 549 567 */ 550 #ifdef __WIN32OS2__ 551 HRESULT WINAPI WINE_StringFromCLSID( 568 HRESULT WINE_StringFromCLSID( 552 569 const CLSID *id, /* [in] GUID to be converted */ 553 570 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 554 #else555 static HRESULT WINE_StringFromCLSID(556 const CLSID *id, /* [in] GUID to be converted */557 LPSTR idstr /* [out] pointer to buffer to contain converted guid */558 #endif559 571 ) { 560 572 static const char *hex = "0123456789ABCDEF"; … … 567 579 return E_FAIL; 568 580 } 569 581 570 582 sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-", 571 583 id->Data1, id->Data2, id->Data3, … … 586 598 return S_OK; 587 599 } 600 588 601 #ifndef __WIN32OS2__ 589 602 /****************************************************************************** 590 * StringFromCLSID 16[COMPOBJ.19]603 * StringFromCLSID [COMPOBJ.19] 591 604 * Converts a GUID into the respective string representation. 592 605 * The target string is allocated using the OLE IMalloc. … … 629 642 } 630 643 #endif 644 631 645 /****************************************************************************** 632 646 * StringFromCLSID [OLE32.151] 647 * StringFromIID [OLE32.153] 633 648 * Converts a GUID into the respective string representation. 634 649 * The target string is allocated using the OLE IMalloc. … … 657 672 658 673 /****************************************************************************** 659 * StringFromGUID2 [COMPOBJ.76] [OLE32.152] 674 * StringFromGUID2 [COMPOBJ.76] 675 * StringFromGUID2 [OLE32.152] 660 676 * 661 677 * Converts a global unique identifier into a string of an API- … … 729 745 730 746 /****************************************************************************** 731 * CLSIDFromProgID 16[COMPOBJ.61]747 * CLSIDFromProgID [COMPOBJ.61] 732 748 * Converts a program id into the respective GUID. (By using a registry lookup) 733 749 * RETURNS … … 767 783 HRESULT WINAPI CLSIDFromProgID( 768 784 LPCOLESTR progid, /* [in] program id as found in registry */ 769 LPCLSID riid /* [out] associated CLSID */ 770 ) { 771 LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid); 772 HRESULT ret = CLSIDFromProgID16(pid,riid); 773 774 HeapFree(GetProcessHeap(),0,pid); 775 return ret; 785 LPCLSID riid ) /* [out] associated CLSID */ 786 { 787 static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 }; 788 char buf2[80]; 789 DWORD buf2len = sizeof(buf2); 790 HKEY xhkey; 791 792 WCHAR *buf = HeapAlloc( GetProcessHeap(),0,(strlenW(progid)+8) * sizeof(WCHAR) ); 793 strcpyW( buf, progid ); 794 strcatW( buf, clsidW ); 795 if (RegOpenKeyW(HKEY_CLASSES_ROOT,buf,&xhkey)) 796 { 797 HeapFree(GetProcessHeap(),0,buf); 798 return CO_E_CLASSSTRING; 799 } 800 HeapFree(GetProcessHeap(),0,buf); 801 802 if (RegQueryValueA(xhkey,NULL,buf2,&buf2len)) 803 { 804 RegCloseKey(xhkey); 805 return CO_E_CLASSSTRING; 806 } 807 RegCloseKey(xhkey); 808 return CLSIDFromString16(buf2,riid); 776 809 } 777 810 … … 782 815 * 783 816 * This function returns the CLSID of the DLL that implements the proxy and stub 784 * for the specified interface. 785 * 786 * It determines this by searching the 817 * for the specified interface. 818 * 819 * It determines this by searching the 787 820 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry 788 821 * and any interface id registered by CoRegisterPSClsid within the current process. 789 * 822 * 790 823 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid. 791 824 */ … … 822 855 823 856 /* ... Once we have the key, query the registry to get the 824 value of CLSID as a string, and convert it into a 857 value of CLSID as a string, and convert it into a 825 858 proper CLSID structure to be passed back to the app */ 826 859 buf2len = sizeof(buf2); … … 846 879 847 880 /*********************************************************************** 848 * WriteClassStm 881 * WriteClassStm (OLE32.159) 849 882 * 850 883 * This function write a CLSID on stream … … 861 894 862 895 /*********************************************************************** 863 * ReadClassStm 896 * ReadClassStm (OLE32.135) 864 897 * 865 898 * This function read a CLSID from a stream 866 899 */ 867 HRESULT WINAPI ReadClassStm(IStream *pStm, REFCLSID rclsid)900 HRESULT WINAPI ReadClassStm(IStream *pStm,CLSID *pclsid) 868 901 { 869 902 ULONG nbByte; 870 903 HRESULT res; 871 872 TRACE("(%p,%p)\n",pStm, rclsid);873 874 if ( rclsid==NULL)904 905 TRACE("(%p,%p)\n",pStm,pclsid); 906 907 if (pclsid==NULL) 875 908 return E_INVALIDARG; 876 877 res = IStream_Read(pStm,(void*) rclsid,sizeof(CLSID),&nbByte);909 910 res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte); 878 911 879 912 if (FAILED(res)) 880 913 return res; 881 914 882 915 if (nbByte != sizeof(CLSID)) 883 916 return S_FALSE; … … 908 941 return 0; 909 942 } 910 943 #endif 911 944 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */ 912 945 /*********************************************************************** 913 * C allObjectInWOW (COMPOBJ.201)946 * CALLOBJECTINWOW (COMPOBJ.201) 914 947 */ 915 948 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) { … … 919 952 920 953 /****************************************************************************** 921 * CoRegisterClassObject 16[COMPOBJ.5]954 * CoRegisterClassObject [COMPOBJ.5] 922 955 * 923 956 * Don't know where it registers it ... … … 942 975 943 976 /****************************************************************************** 944 * CoRevokeClassObject 16[COMPOBJ.6]977 * CoRevokeClassObject [COMPOBJ.6] 945 978 * 946 979 */ … … 950 983 return 0; 951 984 } 952 #endif 953 985 986 /****************************************************************************** 987 * CoFileTimeToDosDateTime [COMPOBJ.30] 988 */ 989 BOOL16 WINAPI CoFileTimeToDosDateTime16(const FILETIME *ft, LPWORD lpDosDate, LPWORD lpDosTime) 990 { 991 return FileTimeToDosDateTime(ft, lpDosDate, lpDosTime); 992 } 993 994 /****************************************************************************** 995 * CoDosDateTimeToFileTime [COMPOBJ.31] 996 */ 997 BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft) 998 { 999 return DosDateTimeToFileTime(wDosDate, wDosTime, ft); 1000 } 954 1001 955 1002 /*** 956 1003 * COM_GetRegisteredClassObject 957 1004 * 958 * This internal method is used to scan the registered class list to 1005 * This internal method is used to scan the registered class list to 959 1006 * find a class object. 960 1007 * 961 * Params: 1008 * Params: 962 1009 * rclsid Class ID of the class to find. 963 1010 * dwClsContext Class context to match. … … 971 1018 LPUNKNOWN* ppUnk) 972 1019 { 1020 HRESULT hr = S_FALSE; 973 1021 RegisteredClass* curClass; 1022 1023 EnterCriticalSection( &csRegisteredClassList ); 974 1024 975 1025 /* … … 1002 1052 IUnknown_AddRef(curClass->classObject); 1003 1053 1004 return S_OK; 1054 hr = S_OK; 1055 goto end; 1005 1056 } 1006 1057 … … 1011 1062 } 1012 1063 1064 end: 1065 LeaveCriticalSection( &csRegisteredClassList ); 1013 1066 /* 1014 1067 * If we get to here, we haven't found our class. 1015 1068 */ 1016 return S_FALSE; 1069 return hr; 1070 } 1071 1072 static DWORD WINAPI 1073 _LocalServerThread(LPVOID param) { 1074 HANDLE hPipe; 1075 char pipefn[200]; 1076 RegisteredClass *newClass = (RegisteredClass*)param; 1077 HRESULT hres; 1078 IStream *pStm; 1079 STATSTG ststg; 1080 unsigned char *buffer; 1081 int buflen; 1082 IClassFactory *classfac; 1083 LARGE_INTEGER seekto; 1084 ULARGE_INTEGER newpos; 1085 ULONG res; 1086 1087 TRACE("Starting threader for %s.\n",debugstr_guid(&newClass->classIdentifier)); 1088 strcpy(pipefn,PIPEPREF); 1089 WINE_StringFromCLSID(&newClass->classIdentifier,pipefn+strlen(PIPEPREF)); 1090 1091 hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac); 1092 if (hres) return hres; 1093 1094 hres = CreateStreamOnHGlobal(0,TRUE,&pStm); 1095 if (hres) { 1096 FIXME("Failed to create stream on hglobal.\n"); 1097 return hres; 1098 } 1099 hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0); 1100 if (hres) { 1101 FIXME("CoMarshalInterface failed, %lx!\n",hres); 1102 return hres; 1103 } 1104 hres = IStream_Stat(pStm,&ststg,0); 1105 if (hres) return hres; 1106 1107 buflen = ststg.cbSize.s.LowPart; 1108 buffer = HeapAlloc(GetProcessHeap(),0,buflen); 1109 seekto.s.LowPart = 0; 1110 seekto.s.HighPart = 0; 1111 hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos); 1112 if (hres) { 1113 FIXME("IStream_Seek failed, %lx\n",hres); 1114 return hres; 1115 } 1116 hres = IStream_Read(pStm,buffer,buflen,&res); 1117 if (hres) { 1118 FIXME("Stream Read failed, %lx\n",hres); 1119 return hres; 1120 } 1121 IStream_Release(pStm); 1122 1123 while (1) { 1124 hPipe = CreateNamedPipeA( 1125 pipefn, 1126 PIPE_ACCESS_DUPLEX, 1127 PIPE_TYPE_BYTE|PIPE_WAIT, 1128 PIPE_UNLIMITED_INSTANCES, 1129 4096, 1130 4096, 1131 NMPWAIT_USE_DEFAULT_WAIT, 1132 NULL 1133 ); 1134 if (hPipe == INVALID_HANDLE_VALUE) { 1135 FIXME("pipe creation failed for %s, le is %lx\n",pipefn,GetLastError()); 1136 return 1; 1137 } 1138 if (!ConnectNamedPipe(hPipe,NULL)) { 1139 ERR("Failure during ConnectNamedPipe %lx, ABORT!\n",GetLastError()); 1140 CloseHandle(hPipe); 1141 continue; 1142 } 1143 WriteFile(hPipe,buffer,buflen,&res,NULL); 1144 CloseHandle(hPipe); 1145 } 1146 return 0; 1017 1147 } 1018 1148 … … 1030 1160 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 1031 1161 LPDWORD lpdwRegister 1032 ) 1162 ) 1033 1163 { 1034 1164 RegisteredClass* newClass; 1035 1165 LPUNKNOWN foundObject; 1036 1166 HRESULT hr; 1037 char buf[80];1038 1039 WINE_StringFromCLSID(rclsid,buf);1040 1167 1041 1168 TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n", 1042 buf,pUnk,dwClsContext,flags,lpdwRegister); 1043 1044 /* 1045 * Perform a sanity check on the parameters 1046 */ 1169 debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister); 1170 1047 1171 if ( (lpdwRegister==0) || (pUnk==0) ) 1048 {1049 1172 return E_INVALIDARG; 1050 } 1051 1052 /* 1053 * Initialize the cookie (out parameter) 1054 */ 1173 1055 1174 *lpdwRegister = 0; 1056 1175 … … 1060 1179 */ 1061 1180 hr = COM_GetRegisteredClassObject(rclsid, dwClsContext, &foundObject); 1062 1063 if (hr == S_OK) 1064 { 1065 /* 1066 * The COM_GetRegisteredClassObject increased the reference count on the 1067 * object so it has to be released. 1068 */ 1181 if (hr == S_OK) { 1069 1182 IUnknown_Release(foundObject); 1070 1071 1183 return CO_E_OBJISREG; 1072 1184 } 1073 1074 /* 1075 * If it is not registered, we must create a new entry for this class and 1076 * append it to the registered class list. 1077 * We use the address of the chain node as the cookie since we are sure it's 1078 * unique. 1079 */ 1185 1080 1186 newClass = HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass)); 1081 1082 /* 1083 * Initialize the node. 1084 */ 1187 if ( newClass == NULL ) 1188 return E_OUTOFMEMORY; 1189 1190 EnterCriticalSection( &csRegisteredClassList ); 1191 1085 1192 newClass->classIdentifier = *rclsid; 1086 1193 newClass->runContext = dwClsContext; 1087 1194 newClass->connectFlags = flags; 1195 /* 1196 * Use the address of the chain node as the cookie since we are sure it's 1197 * unique. 1198 */ 1088 1199 newClass->dwCookie = (DWORD)newClass; 1089 1200 newClass->nextClass = firstRegisteredClass; … … 1097 1208 1098 1209 firstRegisteredClass = newClass; 1099 1100 /* 1101 * Assign the out parameter (cookie) 1102 */ 1210 LeaveCriticalSection( &csRegisteredClassList ); 1211 1103 1212 *lpdwRegister = newClass->dwCookie; 1104 1105 /* 1106 * We're successful Yippee! 1107 */ 1213 1214 if (dwClsContext & CLSCTX_LOCAL_SERVER) { 1215 DWORD tid; 1216 1217 STUBMGR_Start(); 1218 newClass->hThread=CreateThread(NULL,0,_LocalServerThread,newClass,0,&tid); 1219 } 1108 1220 return S_OK; 1109 1221 } … … 1117 1229 */ 1118 1230 HRESULT WINAPI CoRevokeClassObject( 1119 DWORD dwRegister) 1120 { 1231 DWORD dwRegister) 1232 { 1233 HRESULT hr = E_INVALIDARG; 1121 1234 RegisteredClass** prevClassLink; 1122 1235 RegisteredClass* curClass; 1123 1236 1124 1237 TRACE("(%08lx)\n",dwRegister); 1238 1239 EnterCriticalSection( &csRegisteredClassList ); 1125 1240 1126 1241 /* … … 1149 1264 /* 1150 1265 * Free the memory used by the chain node. 1151 */1266 */ 1152 1267 HeapFree(GetProcessHeap(), 0, curClass); 1153 1268 1154 return S_OK; 1155 } 1269 hr = S_OK; 1270 goto end; 1271 } 1156 1272 1157 1273 /* … … 1162 1278 } 1163 1279 1280 end: 1281 LeaveCriticalSection( &csRegisteredClassList ); 1164 1282 /* 1165 1283 * If we get to here, we haven't found our class. 1166 1284 */ 1167 return E_INVALIDARG; 1285 return hr; 1286 } 1287 1288 static HRESULT WINAPI Remote_CoGetClassObject( 1289 REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, 1290 REFIID iid, LPVOID *ppv 1291 ) { 1292 HKEY key; 1293 char buf[200]; 1294 HRESULT hres = E_UNEXPECTED; 1295 char xclsid[80]; 1296 WCHAR dllName[MAX_PATH+1]; 1297 DWORD dllNameLen = sizeof(dllName); 1298 STARTUPINFOW sinfo; 1299 PROCESS_INFORMATION pinfo; 1300 1301 WINE_StringFromCLSID((LPCLSID)rclsid,xclsid); 1302 1303 sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid); 1304 hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); 1305 1306 if (hres != ERROR_SUCCESS) 1307 return REGDB_E_CLASSNOTREG; 1308 1309 memset(dllName,0,sizeof(dllName)); 1310 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen); 1311 if (hres) 1312 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */ 1313 RegCloseKey(key); 1314 1315 TRACE("found LocalServer32 exe %s\n", debugstr_w(dllName)); 1316 1317 memset(&sinfo,0,sizeof(sinfo)); 1318 sinfo.cb = sizeof(sinfo); 1319 if (!CreateProcessW(NULL,dllName,NULL,NULL,FALSE,0,NULL,NULL,&sinfo,&pinfo)) 1320 return E_FAIL; 1321 return create_marshalled_proxy(rclsid,iid,ppv); 1168 1322 } 1169 1323 1170 1324 /*********************************************************************** 1171 1325 * CoGetClassObject [COMPOBJ.7] 1326 * CoGetClassObject [OLE32.16] 1327 * 1328 * FIXME. If request allows of several options and there is a failure 1329 * with one (other than not being registered) do we try the 1330 * others or return failure? (E.g. inprocess is registered but 1331 * the DLL is not found but the server version works) 1172 1332 */ 1173 1333 HRESULT WINAPI CoGetClassObject( … … 1178 1338 HRESULT hres = E_UNEXPECTED; 1179 1339 char xclsid[80]; 1180 WCHAR dllName[MAX_PATH+1];1181 DWORD dllNameLen = sizeof(dllName);1340 WCHAR ProviderName[MAX_PATH+1]; 1341 DWORD ProviderNameLen = sizeof(ProviderName); 1182 1342 HINSTANCE hLibrary; 1183 1343 #ifdef __WIN32OS2__ 1184 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1344 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1185 1345 REFIID iid, LPVOID *ppv); 1186 1346 #else 1187 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid,1347 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, 1188 1348 REFIID iid, LPVOID *ppv); 1189 1349 #endif 1190 1350 DllGetClassObjectFunc DllGetClassObject; 1351 HKEY key; 1352 char buf[200]; 1191 1353 1192 1354 WINE_StringFromCLSID((LPCLSID)rclsid,xclsid); … … 1203 1365 1204 1366 /* 1205 * First, try and see if we can't match the class ID with one of the 1367 * First, try and see if we can't match the class ID with one of the 1206 1368 * registered classes. 1207 1369 */ … … 1223 1385 } 1224 1386 1225 /* out of process and remote servers not supported yet */ 1226 if ( ((CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER) & dwClsContext) 1387 if (((CLSCTX_LOCAL_SERVER) & dwClsContext) 1388 && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext)) 1389 return Remote_CoGetClassObject(rclsid,dwClsContext,pServerInfo,iid,ppv); 1390 1391 /* remote servers not supported yet */ 1392 if ( ((CLSCTX_REMOTE_SERVER) & dwClsContext) 1227 1393 && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) 1228 1394 ){ 1229 FIXME("%s %s not supported!\n", 1230 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"", 1231 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":"" 1232 ); 1233 return E_ACCESSDENIED; 1395 FIXME("CLSCTX_REMOTE_SERVER not supported!\n"); 1396 return E_NOINTERFACE; 1234 1397 } 1235 1398 … … 1238 1401 char buf[200]; 1239 1402 1403 memset(ProviderName,0,sizeof(ProviderName)); 1240 1404 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); 1241 hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); 1242 1243 if (hres != ERROR_SUCCESS) { 1244 return REGDB_E_CLASSNOTREG; 1405 if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) || 1406 ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)), 1407 RegCloseKey (key), 1408 hres != ERROR_SUCCESS)) 1409 { 1410 hres = REGDB_E_CLASSNOTREG; 1411 } 1412 /* Don't ask me. MSDN says that CoGetClassObject does NOT call CoLoadLibrary */ 1413 else if ((hLibrary = CoLoadLibrary(ProviderName, TRUE)) == 0) 1414 { 1415 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(ProviderName)); 1416 hres = E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1245 1417 } 1246 1247 memset(dllName,0,sizeof(dllName)); 1248 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen); 1249 if (hres) 1250 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */ 1251 RegCloseKey(key); 1252 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName)); 1253 1254 /* open dll, call DllGetClassObject */ 1255 hLibrary = CoLoadLibrary(dllName, TRUE); 1256 if (hLibrary == 0) { 1257 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName)); 1258 return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1418 else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) 1419 { 1420 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1421 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(ProviderName)); 1422 hres = E_ACCESSDENIED; 1259 1423 } 1260 DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"); 1261 if (!DllGetClassObject) { 1262 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1263 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName)); 1264 return E_ACCESSDENIED; 1424 else 1425 { 1426 /* Ask the DLL for its class object. (there was a note here about 1427 * class factories but this is good. 1428 */ 1429 return DllGetClassObject(rclsid, iid, ppv); 1430 } 1431 } 1432 1433 1434 /* Finally try out of process */ 1435 /* out of process and remote servers not supported yet */ 1436 if (CLSCTX_LOCAL_SERVER & dwClsContext) 1437 { 1438 memset(ProviderName,0,sizeof(ProviderName)); 1439 sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid); 1440 if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) || 1441 ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)), 1442 RegCloseKey (key), 1443 hres != ERROR_SUCCESS)) 1444 { 1445 hres = REGDB_E_CLASSNOTREG; 1446 } 1447 else 1448 { 1449 /* CO_E_APPNOTFOUND if no exe */ 1450 FIXME("CLSCTX_LOCAL_SERVER %s registered but not yet supported!\n",debugstr_w(ProviderName)); 1451 hres = E_ACCESSDENIED; 1265 1452 } 1266 1267 /* 1268 * Ask the DLL for its class object. (there was a note here about class 1269 * factories but this is good. 1270 */ 1271 return DllGetClassObject(rclsid, iid, ppv); 1272 } 1453 } 1454 1455 if (CLSCTX_REMOTE_SERVER & dwClsContext) 1456 { 1457 FIXME ("CLSCTX_REMOTE_SERVER not supported\n"); 1458 hres = E_ACCESSDENIED; 1459 } 1460 1273 1461 return hres; 1274 1462 } 1275 1276 /*********************************************************************** 1277 * CoResumeClassObjects 1463 /*********************************************************************** 1464 * CoResumeClassObjects (OLE32.173) 1278 1465 * 1279 1466 * Resumes classobjects registered with REGCLS suspended … … 1286 1473 1287 1474 /*********************************************************************** 1288 * GetClassFile 1475 * GetClassFile (OLE32.67) 1289 1476 * 1290 1477 * This function supplies the CLSID associated with the given filename. 1291 1478 */ 1292 HRESULT WINAPI GetClassFile(LP OLESTR filePathName,CLSID *pclsid)1479 HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid) 1293 1480 { 1294 1481 IStorage *pstg=0; … … 1316 1503 pattern in the registry. this case is not frequently used ! so I present only the psodocode for 1317 1504 this case 1318 1505 1319 1506 for(i=0;i<nFileTypes;i++) 1320 1507 … … 1349 1536 length=lstrlenW(absFile); 1350 1537 for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); 1351 1538 1352 1539 /* get the progId associated to the extension */ 1353 1540 progId=CoTaskMemAlloc(sizeProgId); … … 1377 1564 #ifndef __WIN32OS2__ 1378 1565 /****************************************************************************** 1379 * CoRegisterMessageFilter 16[COMPOBJ.27]1566 * CoRegisterMessageFilter [COMPOBJ.27] 1380 1567 */ 1381 1568 HRESULT WINAPI CoRegisterMessageFilter16( … … 1387 1574 } 1388 1575 #endif 1389 1390 /*********************************************************************** 1391 * CoCreateInstance [ COMPOBJ.13,OLE32.7]1576 /*********************************************************************** 1577 * CoCreateInstance [COMPOBJ.13] 1578 * CoCreateInstance [OLE32.7] 1392 1579 */ 1393 1580 HRESULT WINAPI CoCreateInstance( … … 1396 1583 DWORD dwClsContext, 1397 1584 REFIID iid, 1398 LPVOID *ppv) 1585 LPVOID *ppv) 1399 1586 { 1400 1587 HRESULT hres; … … 1411 1598 */ 1412 1599 *ppv = 0; 1413 1600 1414 1601 /* 1415 1602 * Get a class factory to construct the object we want. … … 1422 1609 1423 1610 if (FAILED(hres)) { 1424 FIXME("no instance created for %s, hres is 0x%08lx\n",debugstr_guid(iid),hres); 1611 FIXME("no classfactory created for CLSID %s, hres is 0x%08lx\n", 1612 debugstr_guid(rclsid),hres); 1425 1613 return hres; 1426 1614 } … … 1431 1619 hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv); 1432 1620 IClassFactory_Release(lpclf); 1621 if(FAILED(hres)) 1622 FIXME("no instance created for interface %s of class %s, hres is 0x%08lx\n", 1623 debugstr_guid(iid), debugstr_guid(rclsid),hres); 1433 1624 1434 1625 return hres; … … 1439 1630 */ 1440 1631 HRESULT WINAPI CoCreateInstanceEx( 1441 REFCLSID rclsid, 1632 REFCLSID rclsid, 1442 1633 LPUNKNOWN pUnkOuter, 1443 DWORD dwClsContext, 1634 DWORD dwClsContext, 1444 1635 COSERVERINFO* pServerInfo, 1445 1636 ULONG cmq, … … 1472 1663 * Get the object and get its IUnknown pointer. 1473 1664 */ 1474 hr = CoCreateInstance(rclsid, 1665 hr = CoCreateInstance(rclsid, 1475 1666 pUnkOuter, 1476 1667 dwClsContext, … … 1509 1700 1510 1701 /*********************************************************************** 1511 * CoFreeLibrary [ COMPOBJ.13]1702 * CoFreeLibrary [OLE32.13] 1512 1703 */ 1513 1704 void WINAPI CoFreeLibrary(HINSTANCE hLibrary) … … 1515 1706 OpenDll *ptr, *prev; 1516 1707 OpenDll *tmp; 1708 1709 EnterCriticalSection( &csOpenDllList ); 1517 1710 1518 1711 /* lookup library in linked list */ … … 1527 1720 if (ptr == NULL) { 1528 1721 /* shouldn't happen if user passed in a valid hLibrary */ 1529 return;1722 goto end; 1530 1723 } 1531 1724 /* assert: ptr points to the library entry to free */ … … 1542 1735 prev->next = tmp; 1543 1736 } 1544 1545 } 1546 1547 1548 /*********************************************************************** 1549 * CoFreeAllLibraries [COMPOBJ.12] 1737 end: 1738 LeaveCriticalSection( &csOpenDllList ); 1739 } 1740 1741 1742 /*********************************************************************** 1743 * CoFreeAllLibraries [OLE32.12] 1550 1744 */ 1551 1745 void WINAPI CoFreeAllLibraries(void) 1552 1746 { 1553 1747 OpenDll *ptr, *tmp; 1748 1749 EnterCriticalSection( &csOpenDllList ); 1554 1750 1555 1751 for (ptr = openDllList; ptr != NULL; ) { … … 1558 1754 ptr = tmp; 1559 1755 } 1756 1757 LeaveCriticalSection( &csOpenDllList ); 1560 1758 } 1561 1759 … … 1564 1762 /*********************************************************************** 1565 1763 * CoFreeUnusedLibraries [COMPOBJ.17] 1764 * CoFreeUnusedLibraries [OLE32.14] 1566 1765 */ 1567 1766 void WINAPI CoFreeUnusedLibraries(void) … … 1571 1770 DllCanUnloadNowFunc DllCanUnloadNow; 1572 1771 1772 EnterCriticalSection( &csOpenDllList ); 1773 1573 1774 for (ptr = openDllList; ptr != NULL; ) { 1574 1775 DllCanUnloadNow = (DllCanUnloadNowFunc) 1575 1776 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow"); 1576 1777 1577 1778 if ( (DllCanUnloadNow != NULL) && 1578 1779 (DllCanUnloadNow() == S_OK) ) { … … 1584 1785 } 1585 1786 } 1586 } 1587 1588 /*********************************************************************** 1589 * CoFileTimeNow [COMPOBJ.82, OLE32.10] 1787 1788 LeaveCriticalSection( &csOpenDllList ); 1789 } 1790 1791 /*********************************************************************** 1792 * CoFileTimeNow [COMPOBJ.82] 1793 * CoFileTimeNow [OLE32.10] 1794 * 1590 1795 * RETURNS 1591 1796 * the current system time in lpFileTime … … 1608 1813 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1609 1814 1610 if (FAILED(ret)) 1815 if (FAILED(ret)) 1611 1816 return NULL; 1612 1817 … … 1622 1827 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1623 1828 1624 if (FAILED(ret)) 1829 if (FAILED(ret)) 1625 1830 return; 1626 1831 … … 1639 1844 LPMALLOC lpmalloc; 1640 1845 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1641 1642 if (FAILED(ret)) 1846 1847 if (FAILED(ret)) 1643 1848 return NULL; 1644 1849 … … 1654 1859 OpenDll *ptr; 1655 1860 OpenDll *tmp; 1656 1861 1657 1862 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1658 1863 … … 1661 1866 if (!bAutoFree) 1662 1867 return hLibrary; 1868 1869 EnterCriticalSection( &csOpenDllList ); 1663 1870 1664 1871 if (openDllList == NULL) { … … 1684 1891 } 1685 1892 } 1686 1893 1894 LeaveCriticalSection( &csOpenDllList ); 1895 1687 1896 return hLibrary; 1688 1897 } … … 1696 1905 } 1697 1906 1698 #ifndef __WIN32OS2__ 1699 /****************************************************************************** 1700 * CoLockObjectExternal16 [COMPOBJ.63] 1907 /****************************************************************************** 1908 * CoLockObjectExternal [COMPOBJ.63] 1701 1909 */ 1702 1910 HRESULT WINAPI CoLockObjectExternal16( … … 1708 1916 return S_OK; 1709 1917 } 1710 #endif1711 1918 1712 1919 /****************************************************************************** … … 1719 1926 { 1720 1927 1721 if (fLock) 1928 if (fLock) 1722 1929 { 1723 /* 1930 /* 1724 1931 * Increment the external lock coutner, COM_ExternalLockAddRef also 1725 1932 * increment the object's internal lock counter. 1726 1933 */ 1727 COM_ExternalLockAddRef( pUnk); 1934 COM_ExternalLockAddRef( pUnk); 1728 1935 } 1729 1936 else 1730 1937 { 1731 /* 1938 /* 1732 1939 * Decrement the external lock coutner, COM_ExternalLockRelease also 1733 1940 * decrement the object's internal lock counter. … … 1739 1946 } 1740 1947 1741 #ifndef __WIN32OS2__ 1742 /*********************************************************************** 1743 * CoGetState16 [COMPOBJ.115] 1948 /*********************************************************************** 1949 * CoGetState [COMPOBJ.115] 1744 1950 */ 1745 1951 HRESULT WINAPI CoGetState16(LPDWORD state) … … 1750 1956 } 1751 1957 /*********************************************************************** 1752 * CoSetState [ COM32.42]1958 * CoSetState [OLE32.42] 1753 1959 */ 1754 1960 HRESULT WINAPI CoSetState(LPDWORD state) … … 1758 1964 return S_OK; 1759 1965 } 1760 #endif1761 1966 /*********************************************************************** 1762 1967 * CoCreateFreeThreadedMarshaler [OLE32.5] … … 1765 1970 { 1766 1971 FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal); 1767 1972 1768 1973 return S_OK; 1769 1974 } 1770 1771 1772 /***********************************************************************1773 * DllGetClassObject [OLE32.63]1774 */1775 HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)1776 {1777 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));1778 *ppv = NULL;1779 return CLASS_E_CLASSNOTAVAILABLE;1780 }1781 1782 1975 1783 1976 /*** 1784 1977 * COM_RevokeAllClasses 1785 1978 * 1786 * This method is called when the COM libraries are uninitialized to 1979 * This method is called when the COM libraries are uninitialized to 1787 1980 * release all the references to the class objects registered with 1788 1981 * the library … … 1790 1983 static void COM_RevokeAllClasses() 1791 1984 { 1985 EnterCriticalSection( &csRegisteredClassList ); 1986 1792 1987 while (firstRegisteredClass!=0) 1793 1988 { 1794 1989 CoRevokeClassObject(firstRegisteredClass->dwCookie); 1795 1990 } 1991 1992 LeaveCriticalSection( &csRegisteredClassList ); 1796 1993 } 1797 1994 … … 1801 1998 1802 1999 /**************************************************************************** 1803 * Public - Method that increments the count for a IUnknown* in the linked 2000 * Public - Method that increments the count for a IUnknown* in the linked 1804 2001 * list. The item is inserted if not already in the list. 1805 2002 */ … … 1822 2019 * Add an internal lock to the object 1823 2020 */ 1824 IUnknown_AddRef(pUnk); 2021 IUnknown_AddRef(pUnk); 1825 2022 } 1826 2023 1827 2024 /**************************************************************************** 1828 * Public - Method that decrements the count for a IUnknown* in the linked 2025 * Public - Method that decrements the count for a IUnknown* in the linked 1829 2026 * list. The item is removed from the list if its count end up at zero or if 1830 2027 * bRelAll is TRUE. … … 1843 2040 IUnknown_Release(pUnk); /* release local locks as well */ 1844 2041 1845 if ( bRelAll == FALSE ) 2042 if ( bRelAll == FALSE ) 1846 2043 break; /* perform single release */ 1847 2044 1848 } while ( externalLock->uRefCount > 0 ); 2045 } while ( externalLock->uRefCount > 0 ); 1849 2046 1850 2047 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ … … 1864 2061 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 1865 2062 1866 head = elList.head; /* get the new head... */ 2063 head = elList.head; /* get the new head... */ 1867 2064 } 1868 2065 } … … 1880 2077 { 1881 2078 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 1882 1883 /* Skip to the next item */ 2079 2080 /* Skip to the next item */ 1884 2081 current = current->next; 1885 } 2082 } 1886 2083 1887 2084 } … … 1903 2100 IUnknown *pUnk) 1904 2101 { 1905 if ( element == EL_END_OF_LIST ) 2102 if ( element == EL_END_OF_LIST ) 1906 2103 return EL_NOT_FOUND; 1907 2104 … … 1909 2106 return element; 1910 2107 1911 else /* Not the right guy, keep on looking */ 2108 else /* Not the right guy, keep on looking */ 1912 2109 return COM_ExternalLockLocate( element->next, pUnk); 1913 2110 } … … 1929 2126 if (newLock!=NULL) 1930 2127 { 1931 if ( elList.head == EL_END_OF_LIST ) 2128 if ( elList.head == EL_END_OF_LIST ) 1932 2129 { 1933 2130 elList.head = newLock; /* The list is empty */ 1934 2131 } 1935 else 2132 else 1936 2133 { 1937 /* 2134 /* 1938 2135 * insert does it at the head 1939 2136 */ … … 1943 2140 1944 2141 /* 1945 * Set new list item data member 2142 * Set new list item data member 1946 2143 */ 1947 2144 newLock->pUnk = pUnk; 1948 2145 newLock->uRefCount = 1; 1949 2146 newLock->next = previousHead; 1950 2147 1951 2148 return TRUE; 1952 2149 } … … 1965 2162 if ( current == itemList ) 1966 2163 { 1967 /* 1968 * this section handles the deletion of the first node 2164 /* 2165 * this section handles the deletion of the first node 1969 2166 */ 1970 2167 elList.head = itemList->next; 1971 HeapFree( GetProcessHeap(), 0, itemList); 2168 HeapFree( GetProcessHeap(), 0, itemList); 1972 2169 } 1973 2170 else 1974 2171 { 1975 do 2172 do 1976 2173 { 1977 2174 if ( current->next == itemList ) /* We found the item to free */ 1978 2175 { 1979 2176 current->next = itemList->next; /* readjust the list pointers */ 1980 1981 HeapFree( GetProcessHeap(), 0, itemList); 1982 break; 2177 2178 HeapFree( GetProcessHeap(), 0, itemList); 2179 break; 1983 2180 } 1984 1985 /* Skip to the next item */ 2181 2182 /* Skip to the next item */ 1986 2183 current = current->next; 1987 2184 1988 2185 } while ( current != EL_END_OF_LIST ); 1989 2186 } 1990 2187 } 1991 2188 1992 #ifndef __WIN32OS2__ 1993 /*********************************************************************** 1994 * COMPOBJ_DllEntryPoint [COMPOBJ.entry] 2189 /*********************************************************************** 2190 * DllEntryPoint [COMPOBJ.116] 1995 2191 * 1996 2192 * Initialization code for the COMPOBJ DLL … … 2015 2211 return TRUE; 2016 2212 } 2017 #endif 2213 2018 2214 /****************************************************************************** 2019 2215 * OleGetAutoConvert [OLE32.104] … … 2054 2250 HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew) 2055 2251 { 2056 HKEY hkey = 0 , hkeyConvert = 0;2252 HKEY hkey = 0; 2057 2253 char buf[200], szClsidNew[200]; 2058 2254 HRESULT res = S_OK; 2059 2255 2060 TRACE("(% p,%p);\n", clsidOld, clsidNew);2256 TRACE("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew)); 2061 2257 sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]); 2062 2258 WINE_StringFromCLSID(clsidNew, szClsidNew); … … 2066 2262 goto done; 2067 2263 } 2068 if (Reg CreateKeyA(hkey, "AutoConvertTo", &hkeyConvert))2264 if (RegSetValueA(hkey, "AutoConvertTo", REG_SZ, szClsidNew, strlen(szClsidNew)+1)) 2069 2265 { 2070 2266 res = REGDB_E_WRITEREGDB; 2071 2267 goto done; 2072 2268 } 2073 if (RegSetValueExA(hkeyConvert, NULL, 0, 2074 REG_SZ, (LPBYTE)szClsidNew, strlen(szClsidNew)+1)) 2269 2270 done: 2271 if (hkey) RegCloseKey(hkey); 2272 return res; 2273 } 2274 2275 /****************************************************************************** 2276 * CoTreatAsClass [OLE32.46] 2277 */ 2278 HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew) 2279 { 2280 HKEY hkey = 0; 2281 char buf[200], szClsidNew[200]; 2282 HRESULT res = S_OK; 2283 2284 FIXME("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew)); 2285 sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]); 2286 WINE_StringFromCLSID(clsidNew, szClsidNew); 2287 if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey)) 2288 { 2289 res = REGDB_E_CLASSNOTREG; 2290 goto done; 2291 } 2292 if (RegSetValueA(hkey, "AutoTreatAs", REG_SZ, szClsidNew, strlen(szClsidNew)+1)) 2075 2293 { 2076 2294 res = REGDB_E_WRITEREGDB; … … 2079 2297 2080 2298 done: 2081 if (hkeyConvert) RegCloseKey(hkeyConvert);2082 2299 if (hkey) RegCloseKey(hkey); 2083 2084 2300 return res; 2085 2301 } 2302 2086 2303 2087 2304 /*********************************************************************** … … 2101 2318 return !memcmp(rguid1,rguid2,sizeof(GUID)); 2102 2319 } 2103 2104 #ifdef __WIN32OS2__2105 // ----------------------------------------------------------------------2106 // CLSIDFromStringA()2107 // @@@PH: this is not a WINE API, but a replacement for CLSIDFromString162108 // which used to accept ASCII strings instead of OLE strings2109 // ----------------------------------------------------------------------2110 2111 HRESULT WIN32API CLSIDFromStringA(2112 LPCSTR lpsz, // [in] - ASCII string CLSID2113 LPCLSID pclsid) // [out] - Binary CLSID2114 {2115 return CLSIDFromString16(lpsz, pclsid);2116 }2117 #endif
Note:
See TracChangeset
for help on using the changeset viewer.