Changeset 6648 for trunk/src/ole32/compobj.c
- Timestamp:
- Sep 5, 2001, 3:19:02 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/compobj.c
r5602 r6648 1 /* $Id: compobj.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */ 1 2 /* 2 * 3 * 4 * Copyright 1995Martin von Loewis5 * Copyright 1998Justin Bradford3 * COMPOBJ library 4 * 5 * Copyright 1995 Martin von Loewis 6 * Copyright 1998 Justin Bradford 6 7 * Copyright 1999 Francis Beaudet 7 8 * Copyright 1999 Sylvain St-Germain … … 44 45 * COM External Lock structures and methods declaration 45 46 * 46 * This api provides a linked list to managed external references to 47 * COM objects. 48 * 49 * The public interface consists of three calls: 47 * This api provides a linked list to managed external references to 48 * COM objects. 49 * 50 * The public interface consists of three calls: 50 51 * COM_ExternalLockAddRef 51 52 * COM_ExternalLockRelease … … 57 58 58 59 /* 59 * Declaration of the static structure that manage the 60 * Declaration of the static structure that manage the 60 61 * external lock to COM objects. 61 62 */ … … 82 83 83 84 /* 84 * Public Interface to the external lock list 85 * Public Interface to the external lock list 85 86 */ 86 87 static void COM_ExternalLockFreeList(); … … 90 91 91 92 /* 92 * Private methods used to managed the linked list 93 * Private methods used to managed the linked list 93 94 */ 94 95 static BOOL COM_ExternalLockInsert( … … 152 153 */ 153 154 typedef struct tagOpenDll { 154 HINSTANCE hLibrary; 155 HINSTANCE hLibrary; 155 156 struct tagOpenDll *next; 156 157 } OpenDll; … … 163 164 */ 164 165 static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, 165 166 166 DWORD dwClsContext, 167 LPUNKNOWN* ppUnk); 167 168 168 169 static void COM_RevokeAllClasses(); … … 173 174 * 174 175 * RETURNS 175 * 176 * Current build version, hiword is majornumber, loword is minornumber 176 177 */ 177 178 DWORD WINAPI CoBuildVersion(void) … … 183 184 #ifndef __WIN32OS2__ 184 185 /****************************************************************************** 185 * CoInitialize16[COMPOBJ.2]186 * CoInitialize16 [COMPOBJ.2] 186 187 * Set the win16 IMalloc used for memory management 187 188 */ 188 189 HRESULT WINAPI CoInitialize16( 189 LPVOID lpReserved/* [in] pointer to win16 malloc interface */190 LPVOID lpReserved /* [in] pointer to win16 malloc interface */ 190 191 ) { 191 192 currentMalloc16 = (LPMALLOC16)lpReserved; … … 195 196 196 197 /****************************************************************************** 197 * CoInitialize[OLE32.26]198 * CoInitialize [OLE32.26] 198 199 * 199 200 * Initializes the COM libraries. … … 202 203 */ 203 204 HRESULT WINAPI CoInitialize( 204 LPVOID lpReserved/* [in] pointer to win32 malloc interface205 LPVOID lpReserved /* [in] pointer to win32 malloc interface 205 206 (obsolete, should be NULL) */ 206 ) 207 ) 207 208 { 208 209 /* … … 213 214 214 215 /****************************************************************************** 215 * CoInitializeEx[OLE32.163]216 * CoInitializeEx [OLE32.163] 216 217 * 217 218 * Initializes the COM libraries. The behavior used to set the win32 IMalloc … … 225 226 * 226 227 * BUGS 227 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 228 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 228 229 * is never returned. 229 230 * … … 231 232 */ 232 233 HRESULT WINAPI CoInitializeEx( 233 LPVOID lpReserved,/* [in] pointer to win32 malloc interface234 LPVOID lpReserved, /* [in] pointer to win32 malloc interface 234 235 (obsolete, should be NULL) */ 235 DWORD dwCoInit/* [in] A value from COINIT specifies the threading model */236 ) 236 DWORD dwCoInit /* [in] A value from COINIT specifies the threading model */ 237 ) 237 238 { 238 239 HRESULT hr; … … 248 249 * Check for unsupported features. 249 250 */ 250 if (dwCoInit!=COINIT_APARTMENTTHREADED) 251 if (dwCoInit!=COINIT_APARTMENTTHREADED) 251 252 { 252 253 FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit); … … 283 284 /*********************************************************************** 284 285 * CoUninitialize16 [COMPOBJ.3] 285 * Don't know what it does. 286 * Don't know what it does. 286 287 * 3-Nov-98 -- this was originally misspelled, I changed it to what I 287 288 * believe is the correct spelling … … 304 305 { 305 306 TRACE("()\n"); 306 307 307 308 /* 308 309 * Decrease the reference count. 309 310 */ 310 311 s_COMLockCount--; 311 312 312 313 /* 313 314 * If we are back to 0 locks on the COM library, make sure we free … … 343 344 * CoGetMalloc16 [COMPOBJ.4] 344 345 * RETURNS 345 * 346 * The current win16 IMalloc 346 347 */ 347 348 HRESULT WINAPI CoGetMalloc16( 348 DWORD dwMemContext,/* [in] unknown */349 LPMALLOC16 * lpMalloc/* [out] current win16 malloc interface */349 DWORD dwMemContext, /* [in] unknown */ 350 LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */ 350 351 ) { 351 352 if(!currentMalloc16) 352 353 currentMalloc16 = IMalloc16_Constructor(); 353 354 *lpMalloc = currentMalloc16; 354 355 return S_OK; … … 357 358 358 359 /****************************************************************************** 359 * CoGetMalloc[OLE32.20]360 * CoGetMalloc [OLE32.20] 360 361 * 361 362 * RETURNS 362 * 363 * The current win32 IMalloc 363 364 */ 364 365 HRESULT WINAPI CoGetMalloc( 365 DWORD dwMemContext,/* [in] unknown */366 LPMALLOC *lpMalloc/* [out] current win32 malloc interface */366 DWORD dwMemContext, /* [in] unknown */ 367 LPMALLOC *lpMalloc /* [out] current win32 malloc interface */ 367 368 ) { 368 369 if(!currentMalloc32) 369 370 currentMalloc32 = IMalloc_Constructor(); 370 371 *lpMalloc = currentMalloc32; 371 372 return S_OK; … … 377 378 */ 378 379 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, 379 380 LPMALLOC16 *lpMalloc) 380 381 { 381 382 /* FIXME: docu says we shouldn't return the same allocator as in … … 386 387 387 388 /****************************************************************************** 388 * CoDisconnectObject[COMPOBJ.15]389 * CoDisconnectObject [COMPOBJ.15] 389 390 */ 390 391 HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) … … 400 401 * 401 402 * RETURNS 402 * 403 * TRUE if equal 403 404 */ 404 405 BOOL16 WINAPI IsEqualGUID16( 405 GUID* g1,/* [in] unique id 1 */406 GUID* g2/* [in] unique id 2 */406 GUID* g1, /* [in] unique id 1 */ 407 GUID* g2 /* [in] unique id 2 */ 407 408 ) { 408 409 return !memcmp( g1, g2, sizeof(GUID) ); … … 411 412 412 413 /****************************************************************************** 413 * CLSIDFromString16[COMPOBJ.20]414 * Converts a unique identifier from its string representation into 414 * CLSIDFromString16 [COMPOBJ.20] 415 * Converts a unique identifier from its string representation into 415 416 * the GUID struct. 416 417 * 417 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 418 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 418 419 * 419 420 * RETURNS 420 * 421 * the converted GUID 421 422 */ 422 423 HRESULT WINAPI CLSIDFromString16( 423 LPCOLESTR16 idstr,/* [in] string representation of guid */424 CLSID *id/* [out] GUID converted from string */424 LPCOLESTR16 idstr, /* [in] string representation of guid */ 425 CLSID *id /* [out] GUID converted from string */ 425 426 ) { 426 427 BYTE *s = (BYTE *) idstr; 427 428 BYTE *p; 428 int 429 int i; 429 430 BYTE table[256]; 430 431 431 432 if (!s) 432 433 s = "{00000000-0000-0000-0000-000000000000}"; 433 434 else { /* validate the CLSID string */ 434 435 … … 467 468 p = (BYTE *) id; 468 469 469 s++; 470 s++; /* skip leading brace */ 470 471 for (i = 0; i < 4; i++) { 471 472 p[3 - i] = table[*s]<<4 | table[*(s+1)]; … … 473 474 } 474 475 p += 4; 475 s++; 476 s++; /* skip - */ 476 477 477 478 for (i = 0; i < 2; i++) { … … 480 481 } 481 482 p += 2; 482 s++; 483 s++; /* skip - */ 483 484 484 485 for (i = 0; i < 2; i++) { … … 487 488 } 488 489 p += 2; 489 s++; 490 s++; /* skip - */ 490 491 491 492 /* these are just sequential bytes */ … … 494 495 s += 2; 495 496 } 496 s++; 497 s++; /* skip - */ 497 498 498 499 for (i = 0; i < 6; i++) { … … 505 506 506 507 /****************************************************************************** 507 * 508 * CoCreateGuid[OLE32.6] 508 509 * 509 510 */ 510 511 HRESULT WINAPI CoCreateGuid( 511 512 GUID *pguid /* [out] points to the GUID to initialize */ 512 513 ) { 513 514 return UuidCreate(pguid); … … 515 516 516 517 /****************************************************************************** 517 * CLSIDFromString[OLE32.3]518 * Converts a unique identifier from its string representation into 518 * CLSIDFromString [OLE32.3] 519 * Converts a unique identifier from its string representation into 519 520 * the GUID struct. 520 521 * … … 523 524 * 524 525 * RETURNS 525 * 526 * the converted GUID 526 527 */ 527 528 HRESULT WINAPI CLSIDFromString( 528 LPCOLESTR idstr,/* [in] string representation of GUID */529 CLSID *id/* [out] GUID represented by above string */529 LPCOLESTR idstr, /* [in] string representation of GUID */ 530 CLSID *id /* [out] GUID represented by above string */ 530 531 ) { 531 532 LPOLESTR16 xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr); … … 540 541 541 542 /****************************************************************************** 542 * WINE_StringFromCLSID[Internal]543 * WINE_StringFromCLSID [Internal] 543 544 * Converts a GUID into the respective string representation. 544 545 * … … 546 547 * 547 548 * RETURNS 548 * 549 * the string representation and HRESULT 549 550 */ 550 551 #ifdef __WIN32OS2__ 551 552 HRESULT WINAPI WINE_StringFromCLSID( 552 const CLSID *id,/* [in] GUID to be converted */553 LPSTR idstr/* [out] pointer to buffer to contain converted guid */553 const CLSID *id, /* [in] GUID to be converted */ 554 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 554 555 #else 555 556 static HRESULT WINE_StringFromCLSID( 556 const CLSID *id,/* [in] GUID to be converted */557 LPSTR idstr/* [out] pointer to buffer to contain converted guid */557 const CLSID *id, /* [in] GUID to be converted */ 558 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 558 559 #endif 559 560 ) { 560 561 static const char *hex = "0123456789ABCDEF"; 561 562 char *s; 562 int 563 int i; 563 564 564 565 if (!id) 565 566 567 568 569 566 { ERR("called with id=Null\n"); 567 *idstr = 0x00; 568 return E_FAIL; 569 } 570 570 571 sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-", 571 572 572 id->Data1, id->Data2, id->Data3, 573 id->Data4[0], id->Data4[1]); 573 574 s = &idstr[25]; 574 575 … … 588 589 #ifndef __WIN32OS2__ 589 590 /****************************************************************************** 590 * StringFromCLSID16[COMPOBJ.19]591 * StringFromCLSID16 [COMPOBJ.19] 591 592 * Converts a GUID into the respective string representation. 592 593 * The target string is allocated using the OLE IMalloc. 593 594 * RETURNS 594 * 595 * the string representation and HRESULT 595 596 */ 596 597 HRESULT WINAPI StringFromCLSID16( 597 598 REFCLSID id, /* [in] the GUID to be converted */ 598 LPOLESTR16 *idstr/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */599 LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */ 599 600 600 601 ) { 601 602 extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, 602 603 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode ); 603 LPMALLOC16 604 HRESULT 605 DWORD 604 LPMALLOC16 mllc; 605 HRESULT ret; 606 DWORD args[2]; 606 607 607 608 ret = CoGetMalloc16(0,&mllc); … … 615 616 */ 616 617 if (!K32WOWCallback16Ex( 617 618 (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL( 618 619 (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc)))) 619 620 621 622 623 620 )->Alloc, 621 WCB16_CDECL, 622 2*sizeof(DWORD), 623 (LPVOID)args, 624 (LPDWORD)idstr 624 625 )) { 625 626 626 WARN("CallTo16 IMalloc16 failed\n"); 627 return E_FAIL; 627 628 } 628 629 return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr)); … … 630 631 #endif 631 632 /****************************************************************************** 632 * StringFromCLSID[OLE32.151]633 * StringFromCLSID [OLE32.151] 633 634 * Converts a GUID into the respective string representation. 634 635 * The target string is allocated using the OLE IMalloc. 635 636 * RETURNS 636 * 637 * the string representation and HRESULT 637 638 */ 638 639 HRESULT WINAPI StringFromCLSID( 639 640 REFCLSID id, /* [in] the GUID to be converted */ 640 LPOLESTR *idstr/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */641 LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */ 641 642 ) { 642 643 644 LPMALLOCmllc;645 646 647 648 649 650 643 char buf[80]; 644 HRESULT ret; 645 LPMALLOC mllc; 646 647 if ((ret=CoGetMalloc(0,&mllc))) 648 return ret; 649 650 ret=WINE_StringFromCLSID(id,buf); 651 if (!ret) { 651 652 DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); 652 653 *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) ); 653 654 MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len ); 654 655 656 } 657 658 /****************************************************************************** 659 * StringFromGUID2[COMPOBJ.76] [OLE32.152]655 } 656 return ret; 657 } 658 659 /****************************************************************************** 660 * StringFromGUID2 [COMPOBJ.76] [OLE32.152] 660 661 * 661 662 * Converts a global unique identifier into a string of an API- … … 663 664 * 664 665 * RETURNS 665 * 666 * 666 * The (UNICODE) string representation of the GUID in 'str' 667 * The length of the resulting string, 0 if there was any problem. 667 668 */ 668 669 INT WINAPI 669 670 StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) 670 671 { 671 char 672 char xguid[80]; 672 673 673 674 if (WINE_StringFromCLSID(id,xguid)) 674 675 return 0; 675 676 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax ); 676 677 } … … 729 730 730 731 /****************************************************************************** 731 * CLSIDFromProgID16[COMPOBJ.61]732 * CLSIDFromProgID16 [COMPOBJ.61] 732 733 * Converts a program id into the respective GUID. (By using a registry lookup) 733 734 * RETURNS 734 * 735 * riid associated with the progid 735 736 */ 736 737 HRESULT WINAPI CLSIDFromProgID16( 737 LPCOLESTR16 progid,/* [in] program id as found in registry */738 LPCLSID riid/* [out] associated CLSID */738 LPCOLESTR16 progid, /* [in] program id as found in registry */ 739 LPCLSID riid /* [out] associated CLSID */ 739 740 ) { 740 char*buf,buf2[80];741 DWORDbuf2len;742 HRESULTerr;743 HKEYxhkey;744 745 746 747 748 741 char *buf,buf2[80]; 742 DWORD buf2len; 743 HRESULT err; 744 HKEY xhkey; 745 746 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8); 747 sprintf(buf,"%s\\CLSID",progid); 748 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) { 749 HeapFree(GetProcessHeap(),0,buf); 749 750 return CO_E_CLASSSTRING; 750 751 752 753 754 751 } 752 HeapFree(GetProcessHeap(),0,buf); 753 buf2len = sizeof(buf2); 754 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) { 755 RegCloseKey(xhkey); 755 756 return CO_E_CLASSSTRING; 756 757 758 759 } 760 761 /****************************************************************************** 762 * CLSIDFromProgID[OLE32.2]757 } 758 RegCloseKey(xhkey); 759 return CLSIDFromString16(buf2,riid); 760 } 761 762 /****************************************************************************** 763 * CLSIDFromProgID [OLE32.2] 763 764 * Converts a program id into the respective GUID. (By using a registry lookup) 764 765 * RETURNS 765 * 766 * riid associated with the progid 766 767 */ 767 768 HRESULT WINAPI CLSIDFromProgID( 768 LPCOLESTR progid,/* [in] program id as found in registry */769 LPCLSID riid/* [out] associated CLSID */769 LPCOLESTR progid, /* [in] program id as found in registry */ 770 LPCLSID riid /* [out] associated CLSID */ 770 771 ) { 771 772 773 774 775 772 LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid); 773 HRESULT ret = CLSIDFromProgID16(pid,riid); 774 775 HeapFree(GetProcessHeap(),0,pid); 776 return ret; 776 777 } 777 778 … … 782 783 * 783 784 * 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 785 * for the specified interface. 786 * 787 * It determines this by searching the 787 788 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry 788 789 * and any interface id registered by CoRegisterPSClsid within the current process. 789 * 790 * 790 791 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid. 791 792 */ … … 822 823 823 824 /* ... Once we have the key, query the registry to get the 824 value of CLSID as a string, and convert it into a 825 value of CLSID as a string, and convert it into a 825 826 proper CLSID structure to be passed back to the app */ 826 827 buf2len = sizeof(buf2); … … 846 847 847 848 /*********************************************************************** 848 * 849 * WriteClassStm 849 850 * 850 851 * This function write a CLSID on stream … … 861 862 862 863 /*********************************************************************** 863 * 864 * ReadClassStm 864 865 * 865 866 * This function read a CLSID from a stream … … 869 870 ULONG nbByte; 870 871 HRESULT res; 871 872 872 873 TRACE("(%p,%p)\n",pStm,rclsid); 873 874 874 875 if (rclsid==NULL) 875 876 return E_INVALIDARG; 876 877 877 878 res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte); 878 879 879 880 if (FAILED(res)) 880 881 return res; 881 882 882 883 if (nbByte != sizeof(CLSID)) 883 884 return S_FALSE; … … 892 893 */ 893 894 HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) { 894 895 896 897 898 895 FIXME("(%p,%p),stub!\n",hTask,p); 896 if ((*hTask = GetCurrentTask()) == hETask) { 897 memcpy(p, Table_ETask, sizeof(Table_ETask)); 898 } 899 return 0; 899 900 } 900 901 … … 905 906 HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) { 906 907 FIXME("(%04x,%p),stub!\n",hTask,p); 907 908 908 hETask = hTask; 909 return 0; 909 910 } 910 911 … … 914 915 */ 915 916 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) { 916 917 918 } 919 920 /****************************************************************************** 921 * CoRegisterClassObject16[COMPOBJ.5]917 FIXME("(%p,%p),stub!\n",p1,p2); 918 return 0; 919 } 920 921 /****************************************************************************** 922 * CoRegisterClassObject16 [COMPOBJ.5] 922 923 * 923 924 * Don't know where it registers it ... 924 925 */ 925 926 HRESULT WINAPI CoRegisterClassObject16( 926 927 928 929 930 927 REFCLSID rclsid, 928 LPUNKNOWN pUnk, 929 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 930 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 931 LPDWORD lpdwRegister 931 932 ) { 932 charbuf[80];933 934 935 936 937 938 939 933 char buf[80]; 934 935 WINE_StringFromCLSID(rclsid,buf); 936 937 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n", 938 buf,pUnk,dwClsContext,flags,lpdwRegister 939 ); 940 return 0; 940 941 } 941 942 … … 956 957 * COM_GetRegisteredClassObject 957 958 * 958 * This internal method is used to scan the registered class list to 959 * This internal method is used to scan the registered class list to 959 960 * find a class object. 960 961 * 961 * Params: 962 * Params: 962 963 * rclsid Class ID of the class to find. 963 964 * dwClsContext Class context to match. … … 967 968 */ 968 969 static HRESULT COM_GetRegisteredClassObject( 969 970 971 970 REFCLSID rclsid, 971 DWORD dwClsContext, 972 LPUNKNOWN* ppUnk) 972 973 { 973 974 RegisteredClass* curClass; … … 1018 1019 1019 1020 /****************************************************************************** 1020 * CoRegisterClassObject[OLE32.36]1021 * CoRegisterClassObject [OLE32.36] 1021 1022 * 1022 1023 * This method will register the class object for a given class ID. … … 1025 1026 */ 1026 1027 HRESULT WINAPI CoRegisterClassObject( 1027 1028 1029 1030 1031 1032 ) 1028 REFCLSID rclsid, 1029 LPUNKNOWN pUnk, 1030 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 1031 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 1032 LPDWORD lpdwRegister 1033 ) 1033 1034 { 1034 1035 RegisteredClass* newClass; … … 1040 1041 1041 1042 TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n", 1042 1043 buf,pUnk,dwClsContext,flags,lpdwRegister); 1043 1044 1044 1045 /* … … 1071 1072 return CO_E_OBJISREG; 1072 1073 } 1073 1074 1074 1075 /* 1075 1076 * If it is not registered, we must create a new entry for this class and … … 1102 1103 */ 1103 1104 *lpdwRegister = newClass->dwCookie; 1104 1105 1105 1106 /* 1106 1107 * We're successful Yippee! … … 1117 1118 */ 1118 1119 HRESULT WINAPI CoRevokeClassObject( 1119 DWORD dwRegister) 1120 DWORD dwRegister) 1120 1121 { 1121 1122 RegisteredClass** prevClassLink; … … 1175 1176 REFIID iid, LPVOID *ppv 1176 1177 ) { 1177 LPUNKNOWN 1178 HRESULT 1179 char 1178 LPUNKNOWN regClassObject; 1179 HRESULT hres = E_UNEXPECTED; 1180 char xclsid[80]; 1180 1181 WCHAR dllName[MAX_PATH+1]; 1181 1182 DWORD dllNameLen = sizeof(dllName); 1182 1183 HINSTANCE hLibrary; 1183 1184 #ifdef __WIN32OS2__ 1184 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1185 1185 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1186 REFIID iid, LPVOID *ppv); 1186 1187 #else 1187 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1188 1188 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1189 REFIID iid, LPVOID *ppv); 1189 1190 #endif 1190 1191 DllGetClassObjectFunc DllGetClassObject; … … 1193 1194 1194 1195 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", 1195 1196 1196 debugstr_guid(rclsid), 1197 debugstr_guid(iid) 1197 1198 ); 1198 1199 1199 1200 if (pServerInfo) { 1200 1201 1201 FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName)); 1202 FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo); 1202 1203 } 1203 1204 1204 1205 /* 1205 * First, try and see if we can't match the class ID with one of the 1206 * First, try and see if we can't match the class ID with one of the 1206 1207 * registered classes. 1207 1208 */ … … 1228 1229 ){ 1229 1230 FIXME("%s %s not supported!\n", 1230 1231 1232 1233 1231 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"", 1232 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":"" 1233 ); 1234 return E_ACCESSDENIED; 1234 1235 } 1235 1236 1236 1237 if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) { 1237 1238 HKEY key; 1238 1239 1240 1239 char buf[200]; 1240 1241 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); 1241 1242 hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); 1242 1243 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1244 if (hres != ERROR_SUCCESS) { 1245 return REGDB_E_CLASSNOTREG; 1246 } 1247 1248 memset(dllName,0,sizeof(dllName)); 1249 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen); 1250 if (hres) 1251 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */ 1252 RegCloseKey(key); 1253 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName)); 1254 1255 /* open dll, call DllGetClassObject */ 1256 hLibrary = CoLoadLibrary(dllName, TRUE); 1257 if (hLibrary == 0) { 1258 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName)); 1259 return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1260 } 1261 DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"); 1262 if (!DllGetClassObject) { 1263 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1264 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName)); 1265 return E_ACCESSDENIED; 1266 } 1267 1268 /* 1269 * Ask the DLL for its class object. (there was a note here about class 1270 * factories but this is good. 1271 */ 1272 return DllGetClassObject(rclsid, iid, ppv); 1272 1273 } 1273 1274 return hres; … … 1281 1282 HRESULT WINAPI CoResumeClassObjects(void) 1282 1283 { 1283 1284 1284 FIXME("\n"); 1285 return S_OK; 1285 1286 } 1286 1287 … … 1316 1317 pattern in the registry. this case is not frequently used ! so I present only the psodocode for 1317 1318 this case 1318 1319 1319 1320 for(i=0;i<nFileTypes;i++) 1320 1321 … … 1349 1350 length=lstrlenW(absFile); 1350 1351 for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); 1351 1352 1352 1353 /* get the progId associated to the extension */ 1353 1354 progId=CoTaskMemAlloc(sizeProgId); … … 1377 1378 #ifndef __WIN32OS2__ 1378 1379 /****************************************************************************** 1379 * CoRegisterMessageFilter16[COMPOBJ.27]1380 * CoRegisterMessageFilter16 [COMPOBJ.27] 1380 1381 */ 1381 1382 HRESULT WINAPI CoRegisterMessageFilter16( 1382 1383 1383 LPMESSAGEFILTER lpMessageFilter, 1384 LPMESSAGEFILTER *lplpMessageFilter 1384 1385 ) { 1385 1386 1386 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter); 1387 return 0; 1387 1388 } 1388 1389 #endif … … 1392 1393 */ 1393 1394 HRESULT WINAPI CoCreateInstance( 1394 1395 1396 1397 1398 LPVOID *ppv) 1399 { 1400 1401 1395 REFCLSID rclsid, 1396 LPUNKNOWN pUnkOuter, 1397 DWORD dwClsContext, 1398 REFIID iid, 1399 LPVOID *ppv) 1400 { 1401 HRESULT hres; 1402 LPCLASSFACTORY lpclf = 0; 1402 1403 1403 1404 /* … … 1411 1412 */ 1412 1413 *ppv = 0; 1413 1414 1414 1415 /* 1415 1416 * Get a class factory to construct the object we want. 1416 1417 */ 1417 1418 hres = CoGetClassObject(rclsid, 1418 1419 1420 1421 1419 dwClsContext, 1420 NULL, 1421 &IID_IClassFactory, 1422 (LPVOID)&lpclf); 1422 1423 1423 1424 if (FAILED(hres)) { … … 1429 1430 * Create the object and don't forget to release the factory 1430 1431 */ 1431 1432 1433 1434 1432 hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv); 1433 IClassFactory_Release(lpclf); 1434 1435 return hres; 1435 1436 } 1436 1437 … … 1439 1440 */ 1440 1441 HRESULT WINAPI CoCreateInstanceEx( 1441 REFCLSID rclsid, 1442 REFCLSID rclsid, 1442 1443 LPUNKNOWN pUnkOuter, 1443 DWORD dwClsContext, 1444 DWORD dwClsContext, 1444 1445 COSERVERINFO* pServerInfo, 1445 1446 ULONG cmq, … … 1472 1473 * Get the object and get its IUnknown pointer. 1473 1474 */ 1474 hr = CoCreateInstance(rclsid, 1475 1476 1477 1478 1475 hr = CoCreateInstance(rclsid, 1476 pUnkOuter, 1477 dwClsContext, 1478 &IID_IUnknown, 1479 (VOID**)&pUnk); 1479 1480 1480 1481 if (hr) … … 1487 1488 { 1488 1489 pResults[index].hr = IUnknown_QueryInterface(pUnk, 1489 1490 1490 pResults[index].pIID, 1491 (VOID**)&(pResults[index].pItf)); 1491 1492 1492 1493 if (pResults[index].hr == S_OK) … … 1519 1520 prev = NULL; 1520 1521 for (ptr = openDllList; ptr != NULL; ptr=ptr->next) { 1521 1522 1523 1524 1522 if (ptr->hLibrary == hLibrary) { 1523 break; 1524 } 1525 prev = ptr; 1525 1526 } 1526 1527 1527 1528 if (ptr == NULL) { 1528 1529 1529 /* shouldn't happen if user passed in a valid hLibrary */ 1530 return; 1530 1531 } 1531 1532 /* assert: ptr points to the library entry to free */ … … 1534 1535 FreeLibrary(hLibrary); 1535 1536 if (ptr == openDllList) { 1536 1537 1538 1537 tmp = openDllList->next; 1538 HeapFree(GetProcessHeap(), 0, openDllList); 1539 openDllList = tmp; 1539 1540 } else { 1540 1541 1542 1541 tmp = ptr->next; 1542 HeapFree(GetProcessHeap(), 0, ptr); 1543 prev->next = tmp; 1543 1544 } 1544 1545 … … 1554 1555 1555 1556 for (ptr = openDllList; ptr != NULL; ) { 1556 1557 1558 1557 tmp=ptr->next; 1558 CoFreeLibrary(ptr->hLibrary); 1559 ptr = tmp; 1559 1560 } 1560 1561 } … … 1572 1573 1573 1574 for (ptr = openDllList; ptr != NULL; ) { 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1575 DllCanUnloadNow = (DllCanUnloadNowFunc) 1576 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow"); 1577 1578 if ( (DllCanUnloadNow != NULL) && 1579 (DllCanUnloadNow() == S_OK) ) { 1580 tmp=ptr->next; 1581 CoFreeLibrary(ptr->hLibrary); 1582 ptr = tmp; 1583 } else { 1584 ptr=ptr->next; 1585 } 1585 1586 } 1586 1587 } … … 1589 1590 * CoFileTimeNow [COMPOBJ.82, OLE32.10] 1590 1591 * RETURNS 1591 * 1592 * the current system time in lpFileTime 1592 1593 */ 1593 1594 HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */ … … 1600 1601 * CoTaskMemAlloc (OLE32.43) 1601 1602 * RETURNS 1602 * 1603 * pointer to newly allocated block 1603 1604 */ 1604 1605 LPVOID WINAPI CoTaskMemAlloc( 1605 ULONG size/* [in] size of memoryblock to be allocated */1606 ULONG size /* [in] size of memoryblock to be allocated */ 1606 1607 ) { 1607 LPMALLOC 1608 HRESULT 1609 1610 if (FAILED(ret)) 1611 1608 LPMALLOC lpmalloc; 1609 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1610 1611 if (FAILED(ret)) 1612 return NULL; 1612 1613 1613 1614 return IMalloc_Alloc(lpmalloc,size); … … 1617 1618 */ 1618 1619 VOID WINAPI CoTaskMemFree( 1619 LPVOID ptr/* [in] pointer to be freed */1620 LPVOID ptr /* [in] pointer to be freed */ 1620 1621 ) { 1621 LPMALLOC 1622 HRESULT 1623 1624 if (FAILED(ret)) 1622 LPMALLOC lpmalloc; 1623 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1624 1625 if (FAILED(ret)) 1625 1626 return; 1626 1627 … … 1631 1632 * CoTaskMemRealloc (OLE32.45) 1632 1633 * RETURNS 1633 * 1634 * pointer to newly allocated block 1634 1635 */ 1635 1636 LPVOID WINAPI CoTaskMemRealloc( 1636 1637 LPVOID pvOld, 1637 ULONG size) 1638 ULONG size) /* [in] size of memoryblock to be allocated */ 1638 1639 { 1639 1640 LPMALLOC lpmalloc; 1640 1641 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1641 1642 if (FAILED(ret)) 1642 1643 if (FAILED(ret)) 1643 1644 return NULL; 1644 1645 … … 1654 1655 OpenDll *ptr; 1655 1656 OpenDll *tmp; 1656 1657 1657 1658 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1658 1659 … … 1660 1661 1661 1662 if (!bAutoFree) 1662 1663 return hLibrary; 1663 1664 1664 1665 if (openDllList == NULL) { 1665 1666 /* empty list -- add first node */ 1666 1667 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1667 1668 1668 openDllList->hLibrary=hLibrary; 1669 openDllList->next = NULL; 1669 1670 } else { 1670 1671 /* search for this dll */ 1671 1672 int found = FALSE; 1672 1673 for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) { 1673 if (ptr->hLibrary == hLibrary) { 1674 found = TRUE; 1675 break; 1676 } 1674 if (ptr->hLibrary == hLibrary) { 1675 found = TRUE; 1676 break; 1677 1677 } 1678 if (!found) { 1679 /* dll not found, add it */ 1680 tmp = openDllList; 1681 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1682 openDllList->hLibrary = hLibrary; 1683 openDllList->next = tmp; 1684 } 1685 } 1686 1678 } 1679 if (!found) { 1680 /* dll not found, add it */ 1681 tmp = openDllList; 1682 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1683 openDllList->hLibrary = hLibrary; 1684 openDllList->next = tmp; 1685 } 1686 } 1687 1687 1688 return hLibrary; 1688 1689 } … … 1698 1699 #ifndef __WIN32OS2__ 1699 1700 /****************************************************************************** 1700 * CoLockObjectExternal16[COMPOBJ.63]1701 * CoLockObjectExternal16 [COMPOBJ.63] 1701 1702 */ 1702 1703 HRESULT WINAPI CoLockObjectExternal16( 1703 LPUNKNOWN pUnk, 1704 BOOL16 fLock, 1705 BOOL16 fLastUnlockReleases 1704 LPUNKNOWN pUnk, /* [in] object to be locked */ 1705 BOOL16 fLock, /* [in] do lock */ 1706 BOOL16 fLastUnlockReleases /* [in] ? */ 1706 1707 ) { 1707 1708 FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases); … … 1711 1712 1712 1713 /****************************************************************************** 1713 * CoLockObjectExternal[OLE32.31]1714 * CoLockObjectExternal [OLE32.31] 1714 1715 */ 1715 1716 HRESULT WINAPI CoLockObjectExternal( 1716 LPUNKNOWN pUnk, 1717 BOOL fLock, 1717 LPUNKNOWN pUnk, /* [in] object to be locked */ 1718 BOOL fLock, /* [in] do lock */ 1718 1719 BOOL fLastUnlockReleases) /* [in] unlock all */ 1719 1720 { 1720 1721 1721 if (fLock) 1722 if (fLock) 1722 1723 { 1723 /* 1724 /* 1724 1725 * Increment the external lock coutner, COM_ExternalLockAddRef also 1725 1726 * increment the object's internal lock counter. 1726 1727 */ 1727 COM_ExternalLockAddRef( pUnk); 1728 COM_ExternalLockAddRef( pUnk); 1728 1729 } 1729 1730 else 1730 1731 { 1731 /* 1732 /* 1732 1733 * Decrement the external lock coutner, COM_ExternalLockRelease also 1733 1734 * decrement the object's internal lock counter. … … 1765 1766 { 1766 1767 FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal); 1767 1768 1768 1769 return S_OK; 1769 1770 } … … 1774 1775 */ 1775 1776 HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) 1776 { 1777 1778 1779 1777 { 1778 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); 1779 *ppv = NULL; 1780 return CLASS_E_CLASSNOTAVAILABLE; 1780 1781 } 1781 1782 … … 1784 1785 * COM_RevokeAllClasses 1785 1786 * 1786 * This method is called when the COM libraries are uninitialized to 1787 * This method is called when the COM libraries are uninitialized to 1787 1788 * release all the references to the class objects registered with 1788 1789 * the library … … 1801 1802 1802 1803 /**************************************************************************** 1803 * Public - Method that increments the count for a IUnknown* in the linked 1804 * Public - Method that increments the count for a IUnknown* in the linked 1804 1805 * list. The item is inserted if not already in the list. 1805 1806 */ … … 1822 1823 * Add an internal lock to the object 1823 1824 */ 1824 IUnknown_AddRef(pUnk); 1825 IUnknown_AddRef(pUnk); 1825 1826 } 1826 1827 1827 1828 /**************************************************************************** 1828 * Public - Method that decrements the count for a IUnknown* in the linked 1829 * Public - Method that decrements the count for a IUnknown* in the linked 1829 1830 * list. The item is removed from the list if its count end up at zero or if 1830 1831 * bRelAll is TRUE. … … 1843 1844 IUnknown_Release(pUnk); /* release local locks as well */ 1844 1845 1845 if ( bRelAll == FALSE ) 1846 if ( bRelAll == FALSE ) 1846 1847 break; /* perform single release */ 1847 1848 1848 } while ( externalLock->uRefCount > 0 ); 1849 } while ( externalLock->uRefCount > 0 ); 1849 1850 1850 1851 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ … … 1864 1865 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 1865 1866 1866 head = elList.head; /* get the new head... */ 1867 head = elList.head; /* get the new head... */ 1867 1868 } 1868 1869 } … … 1880 1881 { 1881 1882 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 1882 1883 /* Skip to the next item */ 1883 1884 /* Skip to the next item */ 1884 1885 current = current->next; 1885 } 1886 } 1886 1887 1887 1888 } … … 1903 1904 IUnknown *pUnk) 1904 1905 { 1905 if ( element == EL_END_OF_LIST ) 1906 if ( element == EL_END_OF_LIST ) 1906 1907 return EL_NOT_FOUND; 1907 1908 … … 1909 1910 return element; 1910 1911 1911 else /* Not the right guy, keep on looking */ 1912 else /* Not the right guy, keep on looking */ 1912 1913 return COM_ExternalLockLocate( element->next, pUnk); 1913 1914 } … … 1929 1930 if (newLock!=NULL) 1930 1931 { 1931 if ( elList.head == EL_END_OF_LIST ) 1932 if ( elList.head == EL_END_OF_LIST ) 1932 1933 { 1933 1934 elList.head = newLock; /* The list is empty */ 1934 1935 } 1935 else 1936 else 1936 1937 { 1937 /* 1938 /* 1938 1939 * insert does it at the head 1939 1940 */ … … 1943 1944 1944 1945 /* 1945 * Set new list item data member 1946 * Set new list item data member 1946 1947 */ 1947 1948 newLock->pUnk = pUnk; 1948 1949 newLock->uRefCount = 1; 1949 1950 newLock->next = previousHead; 1950 1951 1951 1952 return TRUE; 1952 1953 } … … 1965 1966 if ( current == itemList ) 1966 1967 { 1967 /* 1968 * this section handles the deletion of the first node 1968 /* 1969 * this section handles the deletion of the first node 1969 1970 */ 1970 1971 elList.head = itemList->next; 1971 HeapFree( GetProcessHeap(), 0, itemList); 1972 HeapFree( GetProcessHeap(), 0, itemList); 1972 1973 } 1973 1974 else 1974 1975 { 1975 do 1976 do 1976 1977 { 1977 1978 if ( current->next == itemList ) /* We found the item to free */ 1978 1979 { 1979 1980 current->next = itemList->next; /* readjust the list pointers */ 1980 1981 HeapFree( GetProcessHeap(), 0, itemList); 1982 break; 1981 1982 HeapFree( GetProcessHeap(), 0, itemList); 1983 break; 1983 1984 } 1984 1985 /* Skip to the next item */ 1985 1986 /* Skip to the next item */ 1986 1987 current = current->next; 1987 1988 1988 1989 } while ( current != EL_END_OF_LIST ); 1989 1990 } … … 2031 2032 { 2032 2033 res = REGDB_E_CLASSNOTREG; 2033 2034 goto done; 2034 2035 } 2035 2036 len = 200; … … 2039 2040 { 2040 2041 res = REGDB_E_KEYMISSING; 2041 2042 goto done; 2042 2043 } 2043 2044 MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) ); … … 2064 2065 { 2065 2066 res = REGDB_E_CLASSNOTREG; 2066 2067 goto done; 2067 2068 } 2068 2069 if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert)) 2069 2070 { 2070 2071 res = REGDB_E_WRITEREGDB; 2071 2072 goto done; 2072 2073 } 2073 2074 if (RegSetValueExA(hkeyConvert, NULL, 0, … … 2075 2076 { 2076 2077 res = REGDB_E_WRITEREGDB; 2077 2078 goto done; 2078 2079 } 2079 2080 … … 2091 2092 * 2092 2093 * RETURNS 2093 * 2094 * TRUE if equal 2094 2095 */ 2095 2096 #undef IsEqualGUID … … 2110 2111 2111 2112 HRESULT WIN32API CLSIDFromStringA( 2112 LPCSTR lpsz,// [in] - ASCII string CLSID2113 LPCLSID pclsid)// [out] - Binary CLSID2113 LPCSTR lpsz, // [in] - ASCII string CLSID 2114 LPCLSID pclsid) // [out] - Binary CLSID 2114 2115 { 2115 2116 return CLSIDFromString16(lpsz, pclsid);
Note:
See TracChangeset
for help on using the changeset viewer.