Changeset 6711 for trunk/src/ole32/compobj.c
- Timestamp:
- Sep 15, 2001, 11:32:00 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/compobj.c
r6648 r6711 1 /* $Id: compobj.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */2 1 /* 3 * 4 * 5 * Copyright 1995Martin von Loewis6 * Copyright 1998Justin Bradford2 * COMPOBJ library 3 * 4 * Copyright 1995 Martin von Loewis 5 * Copyright 1998 Justin Bradford 7 6 * Copyright 1999 Francis Beaudet 8 7 * Copyright 1999 Sylvain St-Germain … … 38 37 #ifdef __WIN32OS2__ 39 38 #include <heapstring.h> 39 40 #undef FIXME 41 #undef TRACE 42 #ifdef DEBUG 43 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 44 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 45 #else 46 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 47 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 48 #endif 40 49 #endif 41 50 … … 45 54 * COM External Lock structures and methods declaration 46 55 * 47 * This api provides a linked list to managed external references to 48 * COM objects. 49 * 50 * The public interface consists of three calls: 56 * This api provides a linked list to managed external references to 57 * COM objects. 58 * 59 * The public interface consists of three calls: 51 60 * COM_ExternalLockAddRef 52 61 * COM_ExternalLockRelease … … 58 67 59 68 /* 60 * Declaration of the static structure that manage the 69 * Declaration of the static structure that manage the 61 70 * external lock to COM objects. 62 71 */ … … 83 92 84 93 /* 85 * Public Interface to the external lock list 94 * Public Interface to the external lock list 86 95 */ 87 96 static void COM_ExternalLockFreeList(); … … 91 100 92 101 /* 93 * Private methods used to managed the linked list 102 * Private methods used to managed the linked list 94 103 */ 95 104 static BOOL COM_ExternalLockInsert( … … 153 162 */ 154 163 typedef struct tagOpenDll { 155 HINSTANCE hLibrary; 164 HINSTANCE hLibrary; 156 165 struct tagOpenDll *next; 157 166 } OpenDll; … … 164 173 */ 165 174 static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, 166 167 175 DWORD dwClsContext, 176 LPUNKNOWN* ppUnk); 168 177 169 178 static void COM_RevokeAllClasses(); … … 174 183 * 175 184 * RETURNS 176 * 185 * Current build version, hiword is majornumber, loword is minornumber 177 186 */ 178 187 DWORD WINAPI CoBuildVersion(void) … … 184 193 #ifndef __WIN32OS2__ 185 194 /****************************************************************************** 186 * CoInitialize16[COMPOBJ.2]195 * CoInitialize16 [COMPOBJ.2] 187 196 * Set the win16 IMalloc used for memory management 188 197 */ 189 198 HRESULT WINAPI CoInitialize16( 190 LPVOID lpReserved/* [in] pointer to win16 malloc interface */199 LPVOID lpReserved /* [in] pointer to win16 malloc interface */ 191 200 ) { 192 201 currentMalloc16 = (LPMALLOC16)lpReserved; … … 196 205 197 206 /****************************************************************************** 198 * CoInitialize[OLE32.26]207 * CoInitialize [OLE32.26] 199 208 * 200 209 * Initializes the COM libraries. … … 203 212 */ 204 213 HRESULT WINAPI CoInitialize( 205 LPVOID lpReserved/* [in] pointer to win32 malloc interface214 LPVOID lpReserved /* [in] pointer to win32 malloc interface 206 215 (obsolete, should be NULL) */ 207 ) 216 ) 208 217 { 209 218 /* … … 214 223 215 224 /****************************************************************************** 216 * CoInitializeEx[OLE32.163]225 * CoInitializeEx [OLE32.163] 217 226 * 218 227 * Initializes the COM libraries. The behavior used to set the win32 IMalloc … … 226 235 * 227 236 * BUGS 228 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 237 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 229 238 * is never returned. 230 239 * … … 232 241 */ 233 242 HRESULT WINAPI CoInitializeEx( 234 LPVOID lpReserved,/* [in] pointer to win32 malloc interface243 LPVOID lpReserved, /* [in] pointer to win32 malloc interface 235 244 (obsolete, should be NULL) */ 236 DWORD dwCoInit/* [in] A value from COINIT specifies the threading model */237 ) 245 DWORD dwCoInit /* [in] A value from COINIT specifies the threading model */ 246 ) 238 247 { 239 248 HRESULT hr; … … 249 258 * Check for unsupported features. 250 259 */ 251 if (dwCoInit!=COINIT_APARTMENTTHREADED) 260 if (dwCoInit!=COINIT_APARTMENTTHREADED) 252 261 { 253 262 FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit); … … 284 293 /*********************************************************************** 285 294 * CoUninitialize16 [COMPOBJ.3] 286 * Don't know what it does. 295 * Don't know what it does. 287 296 * 3-Nov-98 -- this was originally misspelled, I changed it to what I 288 297 * believe is the correct spelling … … 305 314 { 306 315 TRACE("()\n"); 307 316 308 317 /* 309 318 * Decrease the reference count. 310 319 */ 311 320 s_COMLockCount--; 312 321 313 322 /* 314 323 * If we are back to 0 locks on the COM library, make sure we free … … 344 353 * CoGetMalloc16 [COMPOBJ.4] 345 354 * RETURNS 346 * 355 * The current win16 IMalloc 347 356 */ 348 357 HRESULT WINAPI CoGetMalloc16( 349 DWORD dwMemContext,/* [in] unknown */350 LPMALLOC16 * lpMalloc/* [out] current win16 malloc interface */358 DWORD dwMemContext, /* [in] unknown */ 359 LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */ 351 360 ) { 352 361 if(!currentMalloc16) 353 362 currentMalloc16 = IMalloc16_Constructor(); 354 363 *lpMalloc = currentMalloc16; 355 364 return S_OK; … … 358 367 359 368 /****************************************************************************** 360 * CoGetMalloc[OLE32.20]369 * CoGetMalloc [OLE32.20] 361 370 * 362 371 * RETURNS 363 * 372 * The current win32 IMalloc 364 373 */ 365 374 HRESULT WINAPI CoGetMalloc( 366 DWORD dwMemContext,/* [in] unknown */367 LPMALLOC *lpMalloc/* [out] current win32 malloc interface */375 DWORD dwMemContext, /* [in] unknown */ 376 LPMALLOC *lpMalloc /* [out] current win32 malloc interface */ 368 377 ) { 369 378 if(!currentMalloc32) 370 379 currentMalloc32 = IMalloc_Constructor(); 371 380 *lpMalloc = currentMalloc32; 372 381 return S_OK; … … 378 387 */ 379 388 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, 380 389 LPMALLOC16 *lpMalloc) 381 390 { 382 391 /* FIXME: docu says we shouldn't return the same allocator as in … … 387 396 388 397 /****************************************************************************** 389 * CoDisconnectObject[COMPOBJ.15]398 * CoDisconnectObject [COMPOBJ.15] 390 399 */ 391 400 HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) … … 401 410 * 402 411 * RETURNS 403 * 412 * TRUE if equal 404 413 */ 405 414 BOOL16 WINAPI IsEqualGUID16( 406 GUID* g1,/* [in] unique id 1 */407 GUID* g2/* [in] unique id 2 */415 GUID* g1, /* [in] unique id 1 */ 416 GUID* g2 /* [in] unique id 2 */ 408 417 ) { 409 418 return !memcmp( g1, g2, sizeof(GUID) ); … … 412 421 413 422 /****************************************************************************** 414 * CLSIDFromString16[COMPOBJ.20]415 * Converts a unique identifier from its string representation into 423 * CLSIDFromString16 [COMPOBJ.20] 424 * Converts a unique identifier from its string representation into 416 425 * the GUID struct. 417 426 * 418 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 427 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 419 428 * 420 429 * RETURNS 421 * 430 * the converted GUID 422 431 */ 423 432 HRESULT WINAPI CLSIDFromString16( 424 LPCOLESTR16 idstr,/* [in] string representation of guid */425 CLSID *id/* [out] GUID converted from string */433 LPCOLESTR16 idstr, /* [in] string representation of guid */ 434 CLSID *id /* [out] GUID converted from string */ 426 435 ) { 427 436 BYTE *s = (BYTE *) idstr; 428 437 BYTE *p; 429 int 438 int i; 430 439 BYTE table[256]; 431 440 432 441 if (!s) 433 442 s = "{00000000-0000-0000-0000-000000000000}"; 434 443 else { /* validate the CLSID string */ 435 444 … … 468 477 p = (BYTE *) id; 469 478 470 s++; 479 s++; /* skip leading brace */ 471 480 for (i = 0; i < 4; i++) { 472 481 p[3 - i] = table[*s]<<4 | table[*(s+1)]; … … 474 483 } 475 484 p += 4; 476 s++; 485 s++; /* skip - */ 477 486 478 487 for (i = 0; i < 2; i++) { … … 481 490 } 482 491 p += 2; 483 s++; 492 s++; /* skip - */ 484 493 485 494 for (i = 0; i < 2; i++) { … … 488 497 } 489 498 p += 2; 490 s++; 499 s++; /* skip - */ 491 500 492 501 /* these are just sequential bytes */ … … 495 504 s += 2; 496 505 } 497 s++; 506 s++; /* skip - */ 498 507 499 508 for (i = 0; i < 6; i++) { … … 506 515 507 516 /****************************************************************************** 508 * 517 * CoCreateGuid[OLE32.6] 509 518 * 510 519 */ 511 520 HRESULT WINAPI CoCreateGuid( 512 521 GUID *pguid /* [out] points to the GUID to initialize */ 513 522 ) { 514 523 return UuidCreate(pguid); … … 516 525 517 526 /****************************************************************************** 518 * CLSIDFromString[OLE32.3]519 * Converts a unique identifier from its string representation into 527 * CLSIDFromString [OLE32.3] 528 * Converts a unique identifier from its string representation into 520 529 * the GUID struct. 521 530 * … … 524 533 * 525 534 * RETURNS 526 * 535 * the converted GUID 527 536 */ 528 537 HRESULT WINAPI CLSIDFromString( 529 LPCOLESTR idstr,/* [in] string representation of GUID */530 CLSID *id/* [out] GUID represented by above string */538 LPCOLESTR idstr, /* [in] string representation of GUID */ 539 CLSID *id /* [out] GUID represented by above string */ 531 540 ) { 532 541 LPOLESTR16 xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr); … … 541 550 542 551 /****************************************************************************** 543 * WINE_StringFromCLSID[Internal]552 * WINE_StringFromCLSID [Internal] 544 553 * Converts a GUID into the respective string representation. 545 554 * … … 547 556 * 548 557 * RETURNS 549 * 558 * the string representation and HRESULT 550 559 */ 551 560 #ifdef __WIN32OS2__ 552 561 HRESULT WINAPI WINE_StringFromCLSID( 553 const CLSID *id,/* [in] GUID to be converted */554 LPSTR idstr/* [out] pointer to buffer to contain converted guid */562 const CLSID *id, /* [in] GUID to be converted */ 563 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 555 564 #else 556 565 static HRESULT WINE_StringFromCLSID( 557 const CLSID *id,/* [in] GUID to be converted */558 LPSTR idstr/* [out] pointer to buffer to contain converted guid */566 const CLSID *id, /* [in] GUID to be converted */ 567 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 559 568 #endif 560 569 ) { 561 570 static const char *hex = "0123456789ABCDEF"; 562 571 char *s; 563 int 572 int i; 564 573 565 574 if (!id) 566 567 568 569 570 575 { ERR("called with id=Null\n"); 576 *idstr = 0x00; 577 return E_FAIL; 578 } 579 571 580 sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-", 572 573 581 id->Data1, id->Data2, id->Data3, 582 id->Data4[0], id->Data4[1]); 574 583 s = &idstr[25]; 575 584 … … 589 598 #ifndef __WIN32OS2__ 590 599 /****************************************************************************** 591 * StringFromCLSID16[COMPOBJ.19]600 * StringFromCLSID16 [COMPOBJ.19] 592 601 * Converts a GUID into the respective string representation. 593 602 * The target string is allocated using the OLE IMalloc. 594 603 * RETURNS 595 * 604 * the string representation and HRESULT 596 605 */ 597 606 HRESULT WINAPI StringFromCLSID16( 598 607 REFCLSID id, /* [in] the GUID to be converted */ 599 LPOLESTR16 *idstr/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */608 LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */ 600 609 601 610 ) { 602 611 extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, 603 612 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode ); 604 LPMALLOC16 605 HRESULT 606 DWORD 613 LPMALLOC16 mllc; 614 HRESULT ret; 615 DWORD args[2]; 607 616 608 617 ret = CoGetMalloc16(0,&mllc); … … 616 625 */ 617 626 if (!K32WOWCallback16Ex( 618 627 (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL( 619 628 (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc)))) 620 621 622 623 624 629 )->Alloc, 630 WCB16_CDECL, 631 2*sizeof(DWORD), 632 (LPVOID)args, 633 (LPDWORD)idstr 625 634 )) { 626 627 635 WARN("CallTo16 IMalloc16 failed\n"); 636 return E_FAIL; 628 637 } 629 638 return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr)); … … 631 640 #endif 632 641 /****************************************************************************** 633 * StringFromCLSID[OLE32.151]642 * StringFromCLSID [OLE32.151] 634 643 * Converts a GUID into the respective string representation. 635 644 * The target string is allocated using the OLE IMalloc. 636 645 * RETURNS 637 * 646 * the string representation and HRESULT 638 647 */ 639 648 HRESULT WINAPI StringFromCLSID( 640 649 REFCLSID id, /* [in] the GUID to be converted */ 641 LPOLESTR *idstr/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */650 LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */ 642 651 ) { 643 644 645 LPMALLOCmllc;646 647 648 649 650 651 652 char buf[80]; 653 HRESULT ret; 654 LPMALLOC mllc; 655 656 if ((ret=CoGetMalloc(0,&mllc))) 657 return ret; 658 659 ret=WINE_StringFromCLSID(id,buf); 660 if (!ret) { 652 661 DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); 653 662 *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) ); 654 663 MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len ); 655 656 657 } 658 659 /****************************************************************************** 660 * StringFromGUID2[COMPOBJ.76] [OLE32.152]664 } 665 return ret; 666 } 667 668 /****************************************************************************** 669 * StringFromGUID2 [COMPOBJ.76] [OLE32.152] 661 670 * 662 671 * Converts a global unique identifier into a string of an API- … … 664 673 * 665 674 * RETURNS 666 * 667 * 675 * The (UNICODE) string representation of the GUID in 'str' 676 * The length of the resulting string, 0 if there was any problem. 668 677 */ 669 678 INT WINAPI 670 679 StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) 671 680 { 672 char 681 char xguid[80]; 673 682 674 683 if (WINE_StringFromCLSID(id,xguid)) 675 684 return 0; 676 685 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax ); 677 686 } … … 730 739 731 740 /****************************************************************************** 732 * CLSIDFromProgID16[COMPOBJ.61]741 * CLSIDFromProgID16 [COMPOBJ.61] 733 742 * Converts a program id into the respective GUID. (By using a registry lookup) 734 743 * RETURNS 735 * 744 * riid associated with the progid 736 745 */ 737 746 HRESULT WINAPI CLSIDFromProgID16( 738 LPCOLESTR16 progid,/* [in] program id as found in registry */739 LPCLSID riid/* [out] associated CLSID */747 LPCOLESTR16 progid, /* [in] program id as found in registry */ 748 LPCLSID riid /* [out] associated CLSID */ 740 749 ) { 741 char*buf,buf2[80];742 DWORDbuf2len;743 HRESULTerr;744 HKEYxhkey;745 746 747 748 749 750 char *buf,buf2[80]; 751 DWORD buf2len; 752 HRESULT err; 753 HKEY xhkey; 754 755 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8); 756 sprintf(buf,"%s\\CLSID",progid); 757 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) { 758 HeapFree(GetProcessHeap(),0,buf); 750 759 return CO_E_CLASSSTRING; 751 752 753 754 755 760 } 761 HeapFree(GetProcessHeap(),0,buf); 762 buf2len = sizeof(buf2); 763 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) { 764 RegCloseKey(xhkey); 756 765 return CO_E_CLASSSTRING; 757 758 759 760 } 761 762 /****************************************************************************** 763 * CLSIDFromProgID[OLE32.2]766 } 767 RegCloseKey(xhkey); 768 return CLSIDFromString16(buf2,riid); 769 } 770 771 /****************************************************************************** 772 * CLSIDFromProgID [OLE32.2] 764 773 * Converts a program id into the respective GUID. (By using a registry lookup) 765 774 * RETURNS 766 * 775 * riid associated with the progid 767 776 */ 768 777 HRESULT WINAPI CLSIDFromProgID( 769 LPCOLESTR progid,/* [in] program id as found in registry */770 LPCLSID riid/* [out] associated CLSID */778 LPCOLESTR progid, /* [in] program id as found in registry */ 779 LPCLSID riid /* [out] associated CLSID */ 771 780 ) { 772 773 774 775 776 781 LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid); 782 HRESULT ret = CLSIDFromProgID16(pid,riid); 783 784 HeapFree(GetProcessHeap(),0,pid); 785 return ret; 777 786 } 778 787 … … 783 792 * 784 793 * This function returns the CLSID of the DLL that implements the proxy and stub 785 * for the specified interface. 786 * 787 * It determines this by searching the 794 * for the specified interface. 795 * 796 * It determines this by searching the 788 797 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry 789 798 * and any interface id registered by CoRegisterPSClsid within the current process. 790 * 799 * 791 800 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid. 792 801 */ … … 823 832 824 833 /* ... Once we have the key, query the registry to get the 825 value of CLSID as a string, and convert it into a 834 value of CLSID as a string, and convert it into a 826 835 proper CLSID structure to be passed back to the app */ 827 836 buf2len = sizeof(buf2); … … 847 856 848 857 /*********************************************************************** 849 * 858 * WriteClassStm 850 859 * 851 860 * This function write a CLSID on stream … … 862 871 863 872 /*********************************************************************** 864 * 873 * ReadClassStm 865 874 * 866 875 * This function read a CLSID from a stream … … 870 879 ULONG nbByte; 871 880 HRESULT res; 872 881 873 882 TRACE("(%p,%p)\n",pStm,rclsid); 874 883 875 884 if (rclsid==NULL) 876 885 return E_INVALIDARG; 877 886 878 887 res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte); 879 888 880 889 if (FAILED(res)) 881 890 return res; 882 891 883 892 if (nbByte != sizeof(CLSID)) 884 893 return S_FALSE; … … 893 902 */ 894 903 HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) { 895 896 897 898 899 904 FIXME("(%p,%p),stub!\n",hTask,p); 905 if ((*hTask = GetCurrentTask()) == hETask) { 906 memcpy(p, Table_ETask, sizeof(Table_ETask)); 907 } 908 return 0; 900 909 } 901 910 … … 906 915 HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) { 907 916 FIXME("(%04x,%p),stub!\n",hTask,p); 908 909 917 hETask = hTask; 918 return 0; 910 919 } 911 920 … … 915 924 */ 916 925 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) { 917 918 919 } 920 921 /****************************************************************************** 922 * CoRegisterClassObject16[COMPOBJ.5]926 FIXME("(%p,%p),stub!\n",p1,p2); 927 return 0; 928 } 929 930 /****************************************************************************** 931 * CoRegisterClassObject16 [COMPOBJ.5] 923 932 * 924 933 * Don't know where it registers it ... 925 934 */ 926 935 HRESULT WINAPI CoRegisterClassObject16( 927 928 929 930 931 936 REFCLSID rclsid, 937 LPUNKNOWN pUnk, 938 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 939 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 940 LPDWORD lpdwRegister 932 941 ) { 933 charbuf[80];934 935 936 937 938 939 940 942 char buf[80]; 943 944 WINE_StringFromCLSID(rclsid,buf); 945 946 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n", 947 buf,pUnk,dwClsContext,flags,lpdwRegister 948 ); 949 return 0; 941 950 } 942 951 … … 957 966 * COM_GetRegisteredClassObject 958 967 * 959 * This internal method is used to scan the registered class list to 968 * This internal method is used to scan the registered class list to 960 969 * find a class object. 961 970 * 962 * Params: 971 * Params: 963 972 * rclsid Class ID of the class to find. 964 973 * dwClsContext Class context to match. … … 968 977 */ 969 978 static HRESULT COM_GetRegisteredClassObject( 970 971 972 979 REFCLSID rclsid, 980 DWORD dwClsContext, 981 LPUNKNOWN* ppUnk) 973 982 { 974 983 RegisteredClass* curClass; … … 1019 1028 1020 1029 /****************************************************************************** 1021 * CoRegisterClassObject[OLE32.36]1030 * CoRegisterClassObject [OLE32.36] 1022 1031 * 1023 1032 * This method will register the class object for a given class ID. … … 1026 1035 */ 1027 1036 HRESULT WINAPI CoRegisterClassObject( 1028 1029 1030 1031 1032 1033 ) 1037 REFCLSID rclsid, 1038 LPUNKNOWN pUnk, 1039 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 1040 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 1041 LPDWORD lpdwRegister 1042 ) 1034 1043 { 1035 1044 RegisteredClass* newClass; … … 1041 1050 1042 1051 TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n", 1043 1052 buf,pUnk,dwClsContext,flags,lpdwRegister); 1044 1053 1045 1054 /* … … 1072 1081 return CO_E_OBJISREG; 1073 1082 } 1074 1083 1075 1084 /* 1076 1085 * If it is not registered, we must create a new entry for this class and … … 1103 1112 */ 1104 1113 *lpdwRegister = newClass->dwCookie; 1105 1114 1106 1115 /* 1107 1116 * We're successful Yippee! … … 1118 1127 */ 1119 1128 HRESULT WINAPI CoRevokeClassObject( 1120 DWORD dwRegister) 1129 DWORD dwRegister) 1121 1130 { 1122 1131 RegisteredClass** prevClassLink; … … 1176 1185 REFIID iid, LPVOID *ppv 1177 1186 ) { 1178 LPUNKNOWN 1179 HRESULT 1180 char 1187 LPUNKNOWN regClassObject; 1188 HRESULT hres = E_UNEXPECTED; 1189 char xclsid[80]; 1181 1190 WCHAR dllName[MAX_PATH+1]; 1182 1191 DWORD dllNameLen = sizeof(dllName); 1183 1192 HINSTANCE hLibrary; 1184 1193 #ifdef __WIN32OS2__ 1185 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1186 1194 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1195 REFIID iid, LPVOID *ppv); 1187 1196 #else 1188 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1189 1197 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1198 REFIID iid, LPVOID *ppv); 1190 1199 #endif 1191 1200 DllGetClassObjectFunc DllGetClassObject; … … 1194 1203 1195 1204 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", 1196 1197 1205 debugstr_guid(rclsid), 1206 debugstr_guid(iid) 1198 1207 ); 1199 1208 1200 1209 if (pServerInfo) { 1201 1202 1210 FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName)); 1211 FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo); 1203 1212 } 1204 1213 1205 1214 /* 1206 * First, try and see if we can't match the class ID with one of the 1215 * First, try and see if we can't match the class ID with one of the 1207 1216 * registered classes. 1208 1217 */ … … 1229 1238 ){ 1230 1239 FIXME("%s %s not supported!\n", 1231 1232 1233 1234 1240 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"", 1241 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":"" 1242 ); 1243 return E_ACCESSDENIED; 1235 1244 } 1236 1245 1237 1246 if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) { 1238 1247 HKEY key; 1239 1240 1241 1248 char buf[200]; 1249 1250 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); 1242 1251 hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); 1243 1252 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 1272 1253 if (hres != ERROR_SUCCESS) { 1254 return REGDB_E_CLASSNOTREG; 1255 } 1256 1257 memset(dllName,0,sizeof(dllName)); 1258 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen); 1259 if (hres) 1260 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */ 1261 RegCloseKey(key); 1262 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName)); 1263 1264 /* open dll, call DllGetClassObject */ 1265 hLibrary = CoLoadLibrary(dllName, TRUE); 1266 if (hLibrary == 0) { 1267 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName)); 1268 return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1269 } 1270 DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"); 1271 if (!DllGetClassObject) { 1272 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1273 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName)); 1274 return E_ACCESSDENIED; 1275 } 1276 1277 /* 1278 * Ask the DLL for its class object. (there was a note here about class 1279 * factories but this is good. 1280 */ 1281 return DllGetClassObject(rclsid, iid, ppv); 1273 1282 } 1274 1283 return hres; … … 1282 1291 HRESULT WINAPI CoResumeClassObjects(void) 1283 1292 { 1284 1285 1293 FIXME("\n"); 1294 return S_OK; 1286 1295 } 1287 1296 … … 1317 1326 pattern in the registry. this case is not frequently used ! so I present only the psodocode for 1318 1327 this case 1319 1328 1320 1329 for(i=0;i<nFileTypes;i++) 1321 1330 … … 1350 1359 length=lstrlenW(absFile); 1351 1360 for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); 1352 1361 1353 1362 /* get the progId associated to the extension */ 1354 1363 progId=CoTaskMemAlloc(sizeProgId); … … 1378 1387 #ifndef __WIN32OS2__ 1379 1388 /****************************************************************************** 1380 * CoRegisterMessageFilter16[COMPOBJ.27]1389 * CoRegisterMessageFilter16 [COMPOBJ.27] 1381 1390 */ 1382 1391 HRESULT WINAPI CoRegisterMessageFilter16( 1383 1384 1392 LPMESSAGEFILTER lpMessageFilter, 1393 LPMESSAGEFILTER *lplpMessageFilter 1385 1394 ) { 1386 1387 1395 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter); 1396 return 0; 1388 1397 } 1389 1398 #endif … … 1393 1402 */ 1394 1403 HRESULT WINAPI CoCreateInstance( 1395 1396 1397 1398 1399 LPVOID *ppv) 1400 { 1401 1402 1404 REFCLSID rclsid, 1405 LPUNKNOWN pUnkOuter, 1406 DWORD dwClsContext, 1407 REFIID iid, 1408 LPVOID *ppv) 1409 { 1410 HRESULT hres; 1411 LPCLASSFACTORY lpclf = 0; 1403 1412 1404 1413 /* … … 1412 1421 */ 1413 1422 *ppv = 0; 1414 1423 1415 1424 /* 1416 1425 * Get a class factory to construct the object we want. 1417 1426 */ 1418 1427 hres = CoGetClassObject(rclsid, 1419 1420 1421 1422 1428 dwClsContext, 1429 NULL, 1430 &IID_IClassFactory, 1431 (LPVOID)&lpclf); 1423 1432 1424 1433 if (FAILED(hres)) { … … 1430 1439 * Create the object and don't forget to release the factory 1431 1440 */ 1432 1433 1434 1435 1441 hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv); 1442 IClassFactory_Release(lpclf); 1443 1444 return hres; 1436 1445 } 1437 1446 … … 1440 1449 */ 1441 1450 HRESULT WINAPI CoCreateInstanceEx( 1442 REFCLSID rclsid, 1451 REFCLSID rclsid, 1443 1452 LPUNKNOWN pUnkOuter, 1444 DWORD dwClsContext, 1453 DWORD dwClsContext, 1445 1454 COSERVERINFO* pServerInfo, 1446 1455 ULONG cmq, … … 1473 1482 * Get the object and get its IUnknown pointer. 1474 1483 */ 1475 hr = CoCreateInstance(rclsid, 1476 1477 1478 1479 1484 hr = CoCreateInstance(rclsid, 1485 pUnkOuter, 1486 dwClsContext, 1487 &IID_IUnknown, 1488 (VOID**)&pUnk); 1480 1489 1481 1490 if (hr) … … 1488 1497 { 1489 1498 pResults[index].hr = IUnknown_QueryInterface(pUnk, 1490 1491 1499 pResults[index].pIID, 1500 (VOID**)&(pResults[index].pItf)); 1492 1501 1493 1502 if (pResults[index].hr == S_OK) … … 1520 1529 prev = NULL; 1521 1530 for (ptr = openDllList; ptr != NULL; ptr=ptr->next) { 1522 1523 1524 1525 1531 if (ptr->hLibrary == hLibrary) { 1532 break; 1533 } 1534 prev = ptr; 1526 1535 } 1527 1536 1528 1537 if (ptr == NULL) { 1529 1530 1538 /* shouldn't happen if user passed in a valid hLibrary */ 1539 return; 1531 1540 } 1532 1541 /* assert: ptr points to the library entry to free */ … … 1535 1544 FreeLibrary(hLibrary); 1536 1545 if (ptr == openDllList) { 1537 1538 1539 1546 tmp = openDllList->next; 1547 HeapFree(GetProcessHeap(), 0, openDllList); 1548 openDllList = tmp; 1540 1549 } else { 1541 1542 1543 1550 tmp = ptr->next; 1551 HeapFree(GetProcessHeap(), 0, ptr); 1552 prev->next = tmp; 1544 1553 } 1545 1554 … … 1555 1564 1556 1565 for (ptr = openDllList; ptr != NULL; ) { 1557 1558 1559 1566 tmp=ptr->next; 1567 CoFreeLibrary(ptr->hLibrary); 1568 ptr = tmp; 1560 1569 } 1561 1570 } … … 1573 1582 1574 1583 for (ptr = openDllList; ptr != NULL; ) { 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1584 DllCanUnloadNow = (DllCanUnloadNowFunc) 1585 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow"); 1586 1587 if ( (DllCanUnloadNow != NULL) && 1588 (DllCanUnloadNow() == S_OK) ) { 1589 tmp=ptr->next; 1590 CoFreeLibrary(ptr->hLibrary); 1591 ptr = tmp; 1592 } else { 1593 ptr=ptr->next; 1594 } 1586 1595 } 1587 1596 } … … 1590 1599 * CoFileTimeNow [COMPOBJ.82, OLE32.10] 1591 1600 * RETURNS 1592 * 1601 * the current system time in lpFileTime 1593 1602 */ 1594 1603 HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */ … … 1601 1610 * CoTaskMemAlloc (OLE32.43) 1602 1611 * RETURNS 1603 * 1612 * pointer to newly allocated block 1604 1613 */ 1605 1614 LPVOID WINAPI CoTaskMemAlloc( 1606 ULONG size/* [in] size of memoryblock to be allocated */1615 ULONG size /* [in] size of memoryblock to be allocated */ 1607 1616 ) { 1608 LPMALLOC 1609 HRESULT 1610 1611 if (FAILED(ret)) 1612 1617 LPMALLOC lpmalloc; 1618 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1619 1620 if (FAILED(ret)) 1621 return NULL; 1613 1622 1614 1623 return IMalloc_Alloc(lpmalloc,size); … … 1618 1627 */ 1619 1628 VOID WINAPI CoTaskMemFree( 1620 LPVOID ptr/* [in] pointer to be freed */1629 LPVOID ptr /* [in] pointer to be freed */ 1621 1630 ) { 1622 LPMALLOC 1623 HRESULT 1624 1625 if (FAILED(ret)) 1631 LPMALLOC lpmalloc; 1632 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1633 1634 if (FAILED(ret)) 1626 1635 return; 1627 1636 … … 1632 1641 * CoTaskMemRealloc (OLE32.45) 1633 1642 * RETURNS 1634 * 1643 * pointer to newly allocated block 1635 1644 */ 1636 1645 LPVOID WINAPI CoTaskMemRealloc( 1637 1646 LPVOID pvOld, 1638 ULONG size) 1647 ULONG size) /* [in] size of memoryblock to be allocated */ 1639 1648 { 1640 1649 LPMALLOC lpmalloc; 1641 1650 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1642 1643 if (FAILED(ret)) 1651 1652 if (FAILED(ret)) 1644 1653 return NULL; 1645 1654 … … 1655 1664 OpenDll *ptr; 1656 1665 OpenDll *tmp; 1657 1666 1658 1667 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1659 1668 … … 1661 1670 1662 1671 if (!bAutoFree) 1663 1672 return hLibrary; 1664 1673 1665 1674 if (openDllList == NULL) { 1666 1675 /* empty list -- add first node */ 1667 1676 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1668 1669 1677 openDllList->hLibrary=hLibrary; 1678 openDllList->next = NULL; 1670 1679 } else { 1671 1680 /* search for this dll */ 1672 1681 int found = FALSE; 1673 1682 for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) { 1674 if (ptr->hLibrary == hLibrary) { 1675 found = TRUE; 1676 break; 1683 if (ptr->hLibrary == hLibrary) { 1684 found = TRUE; 1685 break; 1686 } 1677 1687 } 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 1688 if (!found) { 1689 /* dll not found, add it */ 1690 tmp = openDllList; 1691 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1692 openDllList->hLibrary = hLibrary; 1693 openDllList->next = tmp; 1694 } 1695 } 1696 1688 1697 return hLibrary; 1689 1698 } … … 1699 1708 #ifndef __WIN32OS2__ 1700 1709 /****************************************************************************** 1701 * CoLockObjectExternal16[COMPOBJ.63]1710 * CoLockObjectExternal16 [COMPOBJ.63] 1702 1711 */ 1703 1712 HRESULT WINAPI CoLockObjectExternal16( 1704 LPUNKNOWN pUnk, 1705 BOOL16 fLock, 1706 BOOL16 fLastUnlockReleases 1713 LPUNKNOWN pUnk, /* [in] object to be locked */ 1714 BOOL16 fLock, /* [in] do lock */ 1715 BOOL16 fLastUnlockReleases /* [in] ? */ 1707 1716 ) { 1708 1717 FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases); … … 1712 1721 1713 1722 /****************************************************************************** 1714 * CoLockObjectExternal[OLE32.31]1723 * CoLockObjectExternal [OLE32.31] 1715 1724 */ 1716 1725 HRESULT WINAPI CoLockObjectExternal( 1717 LPUNKNOWN pUnk, 1718 BOOL fLock, 1726 LPUNKNOWN pUnk, /* [in] object to be locked */ 1727 BOOL fLock, /* [in] do lock */ 1719 1728 BOOL fLastUnlockReleases) /* [in] unlock all */ 1720 1729 { 1721 1730 1722 if (fLock) 1731 if (fLock) 1723 1732 { 1724 /* 1733 /* 1725 1734 * Increment the external lock coutner, COM_ExternalLockAddRef also 1726 1735 * increment the object's internal lock counter. 1727 1736 */ 1728 COM_ExternalLockAddRef( pUnk); 1737 COM_ExternalLockAddRef( pUnk); 1729 1738 } 1730 1739 else 1731 1740 { 1732 /* 1741 /* 1733 1742 * Decrement the external lock coutner, COM_ExternalLockRelease also 1734 1743 * decrement the object's internal lock counter. … … 1766 1775 { 1767 1776 FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal); 1768 1777 1769 1778 return S_OK; 1770 1779 } … … 1775 1784 */ 1776 1785 HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) 1777 { 1778 1779 1780 1786 { 1787 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); 1788 *ppv = NULL; 1789 return CLASS_E_CLASSNOTAVAILABLE; 1781 1790 } 1782 1791 … … 1785 1794 * COM_RevokeAllClasses 1786 1795 * 1787 * This method is called when the COM libraries are uninitialized to 1796 * This method is called when the COM libraries are uninitialized to 1788 1797 * release all the references to the class objects registered with 1789 1798 * the library … … 1802 1811 1803 1812 /**************************************************************************** 1804 * Public - Method that increments the count for a IUnknown* in the linked 1813 * Public - Method that increments the count for a IUnknown* in the linked 1805 1814 * list. The item is inserted if not already in the list. 1806 1815 */ … … 1823 1832 * Add an internal lock to the object 1824 1833 */ 1825 IUnknown_AddRef(pUnk); 1834 IUnknown_AddRef(pUnk); 1826 1835 } 1827 1836 1828 1837 /**************************************************************************** 1829 * Public - Method that decrements the count for a IUnknown* in the linked 1838 * Public - Method that decrements the count for a IUnknown* in the linked 1830 1839 * list. The item is removed from the list if its count end up at zero or if 1831 1840 * bRelAll is TRUE. … … 1844 1853 IUnknown_Release(pUnk); /* release local locks as well */ 1845 1854 1846 if ( bRelAll == FALSE ) 1855 if ( bRelAll == FALSE ) 1847 1856 break; /* perform single release */ 1848 1857 1849 } while ( externalLock->uRefCount > 0 ); 1858 } while ( externalLock->uRefCount > 0 ); 1850 1859 1851 1860 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ … … 1865 1874 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 1866 1875 1867 head = elList.head; /* get the new head... */ 1876 head = elList.head; /* get the new head... */ 1868 1877 } 1869 1878 } … … 1881 1890 { 1882 1891 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 1883 1884 /* Skip to the next item */ 1892 1893 /* Skip to the next item */ 1885 1894 current = current->next; 1886 } 1895 } 1887 1896 1888 1897 } … … 1904 1913 IUnknown *pUnk) 1905 1914 { 1906 if ( element == EL_END_OF_LIST ) 1915 if ( element == EL_END_OF_LIST ) 1907 1916 return EL_NOT_FOUND; 1908 1917 … … 1910 1919 return element; 1911 1920 1912 else /* Not the right guy, keep on looking */ 1921 else /* Not the right guy, keep on looking */ 1913 1922 return COM_ExternalLockLocate( element->next, pUnk); 1914 1923 } … … 1930 1939 if (newLock!=NULL) 1931 1940 { 1932 if ( elList.head == EL_END_OF_LIST ) 1941 if ( elList.head == EL_END_OF_LIST ) 1933 1942 { 1934 1943 elList.head = newLock; /* The list is empty */ 1935 1944 } 1936 else 1945 else 1937 1946 { 1938 /* 1947 /* 1939 1948 * insert does it at the head 1940 1949 */ … … 1944 1953 1945 1954 /* 1946 * Set new list item data member 1955 * Set new list item data member 1947 1956 */ 1948 1957 newLock->pUnk = pUnk; 1949 1958 newLock->uRefCount = 1; 1950 1959 newLock->next = previousHead; 1951 1960 1952 1961 return TRUE; 1953 1962 } … … 1966 1975 if ( current == itemList ) 1967 1976 { 1968 /* 1969 * this section handles the deletion of the first node 1977 /* 1978 * this section handles the deletion of the first node 1970 1979 */ 1971 1980 elList.head = itemList->next; 1972 HeapFree( GetProcessHeap(), 0, itemList); 1981 HeapFree( GetProcessHeap(), 0, itemList); 1973 1982 } 1974 1983 else 1975 1984 { 1976 do 1985 do 1977 1986 { 1978 1987 if ( current->next == itemList ) /* We found the item to free */ 1979 1988 { 1980 1989 current->next = itemList->next; /* readjust the list pointers */ 1981 1982 HeapFree( GetProcessHeap(), 0, itemList); 1983 break; 1990 1991 HeapFree( GetProcessHeap(), 0, itemList); 1992 break; 1984 1993 } 1985 1986 /* Skip to the next item */ 1994 1995 /* Skip to the next item */ 1987 1996 current = current->next; 1988 1997 1989 1998 } while ( current != EL_END_OF_LIST ); 1990 1999 } … … 2032 2041 { 2033 2042 res = REGDB_E_CLASSNOTREG; 2034 2043 goto done; 2035 2044 } 2036 2045 len = 200; … … 2040 2049 { 2041 2050 res = REGDB_E_KEYMISSING; 2042 2051 goto done; 2043 2052 } 2044 2053 MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) ); … … 2065 2074 { 2066 2075 res = REGDB_E_CLASSNOTREG; 2067 2076 goto done; 2068 2077 } 2069 2078 if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert)) 2070 2079 { 2071 2080 res = REGDB_E_WRITEREGDB; 2072 2081 goto done; 2073 2082 } 2074 2083 if (RegSetValueExA(hkeyConvert, NULL, 0, … … 2076 2085 { 2077 2086 res = REGDB_E_WRITEREGDB; 2078 2087 goto done; 2079 2088 } 2080 2089 … … 2092 2101 * 2093 2102 * RETURNS 2094 * 2103 * TRUE if equal 2095 2104 */ 2096 2105 #undef IsEqualGUID … … 2111 2120 2112 2121 HRESULT WIN32API CLSIDFromStringA( 2113 LPCSTR lpsz,// [in] - ASCII string CLSID2114 LPCLSID pclsid)// [out] - Binary CLSID2122 LPCSTR lpsz, // [in] - ASCII string CLSID 2123 LPCLSID pclsid) // [out] - Binary CLSID 2115 2124 { 2116 2125 return CLSIDFromString16(lpsz, pclsid);
Note:
See TracChangeset
for help on using the changeset viewer.