Changeset 6711 for trunk/src/ole32
- Timestamp:
- Sep 15, 2001, 11:32:00 AM (24 years ago)
- Location:
- trunk/src/ole32
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/antimoniker.c
r6648 r6711 1 /* $Id: antimoniker.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */2 1 /*************************************************************************************** 3 * 2 * AntiMonikers implementation 4 3 * 5 4 * Copyright 1999 Noomen Hamza … … 16 15 #include "debugtools.h" 17 16 17 #ifdef __WIN32OS2__ 18 #undef FIXME 19 #undef TRACE 20 #ifdef DEBUG 21 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 22 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 23 #else 24 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 25 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 26 #endif 27 #endif 28 18 29 DEFAULT_DEBUG_CHANNEL(ole); 19 30 … … 23 34 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 24 35 25 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 36 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 26 37 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 27 38 */ … … 129 140 { 130 141 ICOM_THIS(AntiMonikerImpl,iface); 131 142 132 143 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 133 144 134 145 /* Perform a sanity check on the parameters.*/ 135 146 if ( (This==0) || (ppvObject==0) ) 136 137 147 return E_INVALIDARG; 148 138 149 /* Initialize the return parameter */ 139 150 *ppvObject = 0; … … 152 163 if ((*ppvObject)==0) 153 164 return E_NOINTERFACE; 154 165 155 166 /* Query Interface always increases the reference count by one when it is successful */ 156 167 AntiMonikerImpl_AddRef(iface); … … 201 212 if (pClassID==NULL) 202 213 return E_POINTER; 203 214 204 215 *pClassID = CLSID_AntiMoniker; 205 216 206 217 return S_OK; 207 218 } … … 245 256 DWORD constant=1; 246 257 HRESULT res; 247 258 248 259 /* data writen by this function is only a DWORD constant seted to 1 ! */ 249 260 res=IStream_Write(pStm,&constant,sizeof(constant),NULL); … … 264 275 265 276 /* for more details see AntiMonikerImpl_Save coments */ 266 277 267 278 /* Normaly the sizemax must be the size of DWORD ! but I tested this function it ususlly return 16 bytes */ 268 279 /* more than the number of bytes used by AntiMoniker::Save function */ … … 343 354 344 355 *ppmkReduced=iface; 345 356 346 357 return MK_S_REDUCED_TO_SELF; 347 358 } … … 358 369 359 370 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 360 371 return E_POINTER; 361 372 362 373 *ppmkComposite=0; 363 374 364 375 if (fOnlyIfNotGeneric) 365 376 return MK_E_NEEDGENERIC; … … 377 388 if (ppenumMoniker == NULL) 378 389 return E_POINTER; 379 390 380 391 *ppenumMoniker = NULL; 381 392 … … 389 400 { 390 401 DWORD mkSys; 391 402 392 403 TRACE("(%p,%p)\n",iface,pmkOtherMoniker); 393 404 394 405 if (pmkOtherMoniker==NULL) 395 406 return S_FALSE; 396 407 397 408 IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); 398 409 … … 477 488 { 478 489 DWORD mkSys; 479 490 480 491 IMoniker_IsSystemMoniker(pmkOther,&mkSys); 481 492 … … 487 498 488 499 IMoniker_AddRef(iface); 489 500 490 501 return MK_S_US; 491 502 } … … 520 531 { 521 532 WCHAR back[]={'\\','.','.',0}; 522 533 523 534 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName); 524 535 … … 537 548 538 549 strcpyW(*ppszDisplayName,back); 539 550 540 551 return S_OK; 541 552 } … … 564 575 if (!pwdMksys) 565 576 return E_POINTER; 566 577 567 578 (*pwdMksys)=MKSYS_ANTIMONIKER; 568 579 … … 601 612 { 602 613 ICOM_THIS_From_IROTData(IMoniker, iface); 603 614 604 615 TRACE("(%p)\n",iface); 605 616 … … 620 631 621 632 /****************************************************************************** 622 * CreateAntiMoniker 633 * CreateAntiMoniker [OLE.55] 623 634 ******************************************************************************/ 624 635 HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk) … … 627 638 HRESULT hr = S_OK; 628 639 IID riid=IID_IMoniker; 629 640 630 641 TRACE("(%p)\n",ppmk); 631 642 -
trunk/src/ole32/bindctx.c
r6648 r6711 1 /* $Id: bindctx.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */2 1 /*************************************************************************************** 3 * 2 * BindCtx implementation 4 3 * 5 4 * Copyright 1999 Noomen Hamza … … 18 17 #include "heap.h" 19 18 19 #ifdef __WIN32OS2__ 20 #undef FIXME 21 #undef TRACE 22 #ifdef DEBUG 23 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 24 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 25 #else 26 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 27 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 28 #endif 29 #endif 30 20 31 DEFAULT_DEBUG_CHANNEL(ole); 21 32 22 33 /* represent the first size table and it's increment block size */ 23 #define BLOCK_TAB_SIZE 10 34 #define BLOCK_TAB_SIZE 10 24 35 #define MAX_TAB_SIZE 0xFFFFFFFF 25 36 … … 39 50 40 51 ICOM_VFIELD(IBindCtx); /* VTable relative to the IBindCtx interface.*/ 41 52 42 53 ULONG ref; /* reference counter for this object */ 43 54 … … 103 114 if ( (This==0) || (ppvObject==0) ) 104 115 return E_INVALIDARG; 105 116 106 117 /* Initialize the return parameter.*/ 107 118 *ppvObject = 0; … … 117 128 if ((*ppvObject)==0) 118 129 return E_NOINTERFACE; 119 130 120 131 /* Query Interface always increases the reference count by one when it is successful */ 121 132 BindCtxImpl_AddRef(iface); … … 224 235 if (punk==NULL) 225 236 return E_POINTER; 226 237 227 238 IUnknown_AddRef(punk); 228 239 229 240 /* put the object in the first free element in the table */ 230 241 This->bindCtxTable[lastIndex].pObj = punk; … … 264 275 /* check if the object was registred or not */ 265 276 if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE) 266 277 267 278 return MK_E_NOTBOUND; 268 279 269 280 IUnknown_Release(This->bindCtxTable[index].pObj); 270 281 271 282 /* left-shift all elements in the right side of the current revoked object */ 272 283 for(j=index; j<This->bindCtxTableLastIndex-1; j++) 273 284 This->bindCtxTable[j]= This->bindCtxTable[j+1]; 274 285 275 286 This->bindCtxTableLastIndex--; 276 287 … … 308 319 if (pbindopts==NULL) 309 320 return E_POINTER; 310 321 311 322 if (pbindopts->cbStruct > sizeof(BIND_OPTS2)) 312 323 { … … 352 363 if (pprot==NULL) 353 364 return E_POINTER; 354 365 355 366 res=GetRunningObjectTable(0, pprot); 356 367 … … 369 380 if (punk==NULL) 370 381 return E_INVALIDARG; 371 382 372 383 IUnknown_AddRef(punk); 373 384 … … 390 401 391 402 This->bindCtxTableLastIndex++; 392 403 393 404 if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */ 394 405 … … 420 431 421 432 *punk=0; 422 433 423 434 if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE) 424 435 return E_FAIL; 425 436 426 437 IUnknown_AddRef(This->bindCtxTable[index].pObj); 427 438 428 439 *punk = This->bindCtxTable[index].pObj; 429 440 … … 447 458 /* release the object if it's found */ 448 459 IUnknown_Release(This->bindCtxTable[index].pObj); 449 460 450 461 /* remove the object from the table with a left-shifting of all objects in the right side */ 451 462 for(j=index; j<This->bindCtxTableLastIndex-1; j++) 452 463 This->bindCtxTable[j]= This->bindCtxTable[j+1]; 453 464 454 465 This->bindCtxTableLastIndex--; 455 466 … … 477 488 DWORD i; 478 489 BYTE found=0; 479 490 480 491 TRACE("(%p,%p,%p,%p)\n",This,punk,pszkey,index); 481 492 -
trunk/src/ole32/clipboard.c
r6648 r6711 1 /* $Id: clipboard.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */2 1 /* 3 2 * OLE 2 clipboard support … … 82 81 83 82 /* 84 * The hidden OLE clipboard window. This window is used as the bridge between the 83 * The hidden OLE clipboard window. This window is used as the bridge between the 85 84 * the OLE and windows clipboard API. (Windows creates one such window per process) 86 85 */ … … 115 114 * DO NOT add any members before the VTables declaration! 116 115 */ 117 typedef struct 116 typedef struct 118 117 { 119 118 /* IEnumFORMATETC VTable */ 120 119 ICOM_VFIELD(IEnumFORMATETC); 121 120 122 121 /* IEnumFORMATETC fields */ 123 122 UINT posFmt; /* current enumerator position */ … … 134 133 */ 135 134 IUnknown* pUnkDataObj; 136 135 137 136 } IEnumFORMATETCImpl; 138 137 … … 173 172 REFIID riid, 174 173 void** ppvObject); 175 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 174 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 176 175 IDataObject* iface); 177 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 176 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 178 177 IDataObject* iface); 179 178 static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( 180 181 LPFORMATETC pformatetcIn, 182 179 IDataObject* iface, 180 LPFORMATETC pformatetcIn, 181 STGMEDIUM* pmedium); 183 182 static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere( 184 IDataObject* iface, 185 186 183 IDataObject* iface, 184 LPFORMATETC pformatetc, 185 STGMEDIUM* pmedium); 187 186 static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData( 188 189 187 IDataObject* iface, 188 LPFORMATETC pformatetc); 190 189 static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc( 191 IDataObject* iface, 192 LPFORMATETC pformatectIn, 193 190 IDataObject* iface, 191 LPFORMATETC pformatectIn, 192 LPFORMATETC pformatetcOut); 194 193 static HRESULT WINAPI OLEClipbrd_IDataObject_SetData( 195 196 LPFORMATETC pformatetc, 197 STGMEDIUM* pmedium, 198 194 IDataObject* iface, 195 LPFORMATETC pformatetc, 196 STGMEDIUM* pmedium, 197 BOOL fRelease); 199 198 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( 200 IDataObject* iface, 201 202 199 IDataObject* iface, 200 DWORD dwDirection, 201 IEnumFORMATETC** ppenumFormatEtc); 203 202 static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise( 204 IDataObject* iface, 205 FORMATETC* pformatetc, 206 DWORD advf, 207 IAdviseSink* pAdvSink, 208 203 IDataObject* iface, 204 FORMATETC* pformatetc, 205 DWORD advf, 206 IAdviseSink* pAdvSink, 207 DWORD* pdwConnection); 209 208 static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise( 210 211 209 IDataObject* iface, 210 DWORD dwConnection); 212 211 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise( 213 214 212 IDataObject* iface, 213 IEnumSTATDATA** ppenumAdvise); 215 214 216 215 /* … … 266 265 267 266 /* 268 * Name of our registered OLE clipboard window class 267 * Name of our registered OLE clipboard window class 269 268 */ 270 269 CHAR OLEClipbrd_WNDCLASS[] = "CLIPBRDWNDCLASS"; … … 280 279 281 280 /*---------------------------------------------------------------------* 282 * Win32 OLE clipboard API 281 * Win32 OLE clipboard API 283 282 *---------------------------------------------------------------------*/ 284 283 … … 291 290 * 292 291 * S_OK IDataObject pointer placed on the clipboard 293 * CLIPBRD_E_CANT_OPEN OpenClipboard failed 294 * CLIPBRD_E_CANT_EMPTY EmptyClipboard failed 292 * CLIPBRD_E_CANT_OPEN OpenClipboard failed 293 * CLIPBRD_E_CANT_EMPTY EmptyClipboard failed 295 294 * CLIPBRD_E_CANT_CLOSE CloseClipboard failed 296 295 * CLIPBRD_E_CANT_SET SetClipboard failed … … 307 306 OLEClipbrd **ppDataObject; 308 307 */ 309 308 310 309 TRACE("(%p)\n", pDataObj); 311 310 312 311 /* 313 312 * Make sure we have a clipboard object … … 332 331 /* 333 332 * Empty the current clipboard and make our window the clipboard owner 334 * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 333 * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 335 334 */ 336 335 if ( !EmptyClipboard() ) … … 357 356 358 357 /* 359 * Enumerate all HGLOBAL formats supported by the source and make 358 * Enumerate all HGLOBAL formats supported by the source and make 360 359 * those formats available using delayed rendering using SetClipboardData. 361 * Only global memory based data items may be made available to non-OLE 362 * applications via the standard Windows clipboard API. Data based on other 360 * Only global memory based data items may be made available to non-OLE 361 * applications via the standard Windows clipboard API. Data based on other 363 362 * mediums(non TYMED_HGLOBAL) can only be accessed via the Ole Clipboard API. 364 363 * … … 374 373 HANDLE_ERROR( hr ); 375 374 } 376 375 377 376 while ( S_OK == IEnumFORMATETC_Next(penumFormatetc, 1, &rgelt, NULL) ) 378 377 { … … 383 382 GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1) 384 383 ? szFmtName : ""); 385 384 386 385 SetClipboardData( rgelt.cfFormat, (HANDLE)NULL); 387 386 } … … 392 391 /* 393 392 * Windows additionally creates a new "DataObject" clipboard format 394 * and stores in on the clipboard. We could possibly store a pointer 393 * and stores in on the clipboard. We could possibly store a pointer 395 394 * to our internal IDataObject interface on the clipboard. I'm not 396 395 * sure what the use of this is though. … … 403 402 if (hDataObject==0) 404 403 HANDLE_ERROR( E_OUTOFMEMORY ); 405 404 406 405 ppDataObject = (OLEClipbrd**)GlobalLock(hDataObject); 407 406 *ppDataObject = theOleClipboard; … … 411 410 HANDLE_ERROR( CLIPBRD_E_CANT_SET ); 412 411 */ 413 412 414 413 hr = S_OK; 415 414 … … 440 439 /*********************************************************************** 441 440 * OleGetClipboard [OLE32.105] 442 * Returns a pointer to our internal IDataObject which represents the conceptual 443 * state of the Windows clipboard. If the current clipboard already contains 441 * Returns a pointer to our internal IDataObject which represents the conceptual 442 * state of the Windows clipboard. If the current clipboard already contains 444 443 * an IDataObject, our internal IDataObject will delegate to this object. 445 444 */ … … 448 447 HRESULT hr = S_OK; 449 448 TRACE("()\n"); 450 449 451 450 /* 452 451 * Make sure we have a clipboard object … … 489 488 BOOL bClipboardOpen = FALSE; 490 489 IDataObject* pIDataObjectSrc = NULL; 491 490 492 491 TRACE("()\n"); 493 492 … … 509 508 pIDataObjectSrc = theOleClipboard->pIDataObjectSrc; 510 509 IDataObject_AddRef(pIDataObjectSrc); 511 510 512 511 /* 513 512 * Open the Windows clipboard … … 549 548 } 550 549 } 551 550 552 551 IEnumFORMATETC_Release(penumFormatetc); 553 552 554 553 /* 555 554 * Release the source data object we are holding on to … … 572 571 * OleIsCurrentClipboard [OLE32.110] 573 572 */ 574 HRESULT WINAPI OleIsCurrentClipboard ( IDataObject *pDataObject) 573 HRESULT WINAPI OleIsCurrentClipboard ( IDataObject *pDataObject) 575 574 { 576 575 TRACE("()\n"); … … 588 587 589 588 /*---------------------------------------------------------------------* 590 * Internal implementation methods for the OLE clipboard 589 * Internal implementation methods for the OLE clipboard 591 590 *---------------------------------------------------------------------*/ 592 591 593 592 /*********************************************************************** 594 593 * OLEClipbrd_Initialize() 595 * Initializes the OLE clipboard. 594 * Initializes the OLE clipboard. 596 595 */ 597 596 void OLEClipbrd_Initialize() 598 597 { 599 598 /* 600 * Create the clipboard if necessary 599 * Create the clipboard if necessary 601 600 */ 602 601 if ( !theOleClipboard ) … … 610 609 /*********************************************************************** 611 610 * OLEClipbrd_UnInitialize() 612 * Un-Initializes the OLE clipboard 611 * Un-Initializes the OLE clipboard 613 612 */ 614 613 void OLEClipbrd_UnInitialize() … … 637 636 OLEClipbrd* newObject = NULL; 638 637 HGLOBAL hNewObject = 0; 639 638 640 639 /* 641 640 * Allocate space for the object. We use GlobalAlloc since we need … … 651 650 */ 652 651 newObject = GlobalLock(hNewObject); 653 652 654 653 /* 655 654 * Initialize the virtual function table. … … 658 657 659 658 /* 660 * Start with one reference count. The caller of this function 659 * Start with one reference count. The caller of this function 661 660 * must release the interface pointer when it is done. 662 661 */ … … 664 663 665 664 newObject->hSelf = hNewObject; 666 665 667 666 /* 668 667 * The Ole clipboard is a singleton - save the global handle and pointer … … 677 676 { 678 677 TRACE("()\n"); 679 678 680 679 if ( !ptrToDestroy ) 681 680 return; 682 681 683 682 /* 684 * Destroy the Ole clipboard window 683 * Destroy the Ole clipboard window 685 684 */ 686 685 if ( ptrToDestroy->hWndClipboard ) … … 704 703 /*********************************************************************** 705 704 * OLEClipbrd_CreateWindow() 706 * Create the clipboard window 705 * Create the clipboard window 707 706 */ 708 707 static HWND OLEClipbrd_CreateWindow() … … 711 710 WNDCLASSEXA wcex; 712 711 713 /* 714 * Register the clipboard window class if necessary 712 /* 713 * Register the clipboard window class if necessary 715 714 */ 716 715 ZeroMemory( &wcex, sizeof(WNDCLASSEXA)); … … 728 727 729 728 /* 730 * Create a hidden window to receive OLE clipboard messages 729 * Create a hidden window to receive OLE clipboard messages 731 730 */ 732 731 … … 738 737 */ 739 738 740 hwnd = CreateWindowA(OLEClipbrd_WNDCLASS, 741 742 743 744 745 746 747 748 739 hwnd = CreateWindowA(OLEClipbrd_WNDCLASS, 740 "ClipboardWindow", 741 WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED, 742 CW_USEDEFAULT, CW_USEDEFAULT, 743 CW_USEDEFAULT, CW_USEDEFAULT, 744 0, 745 0, 746 0, 747 0 /*(LPVOID)&clipboardInfo */); 749 748 750 749 return hwnd; … … 757 756 static void OLEClipbrd_DestroyWindow(HWND hwnd) 758 757 { 759 /* 760 * Destroy clipboard window and unregister its WNDCLASS 758 /* 759 * Destroy clipboard window and unregister its WNDCLASS 761 760 */ 762 761 DestroyWindow(hwnd); … … 766 765 /*********************************************************************** 767 766 * OLEClipbrd_WndProc(HWND, unsigned, WORD, LONG) 768 * Processes messages sent to the OLE clipboard window. 769 * Note that we will intercept messages in our WndProc only when data 770 * has been placed in the clipboard via OleSetClipboard(). 767 * Processes messages sent to the OLE clipboard window. 768 * Note that we will intercept messages in our WndProc only when data 769 * has been placed in the clipboard via OleSetClipboard(). 771 770 * i.e. Only when OLE owns the windows clipboard. 772 771 */ … … 774 773 (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 775 774 { 776 switch (message) 775 switch (message) 777 776 { 778 777 /* 779 * WM_RENDERFORMAT 778 * WM_RENDERFORMAT 780 779 * We receive this message to allow us to handle delayed rendering of 781 * a specific clipboard format when an application requests data in 780 * a specific clipboard format when an application requests data in 782 781 * that format by calling GetClipboardData. 783 * (Recall that in OleSetClipboard, we used SetClipboardData to 782 * (Recall that in OleSetClipboard, we used SetClipboardData to 784 783 * make all HGLOBAL formats supported by the source IDataObject 785 784 * available using delayed rendering) 786 * On receiving this mesage we must actually render the data in the 787 * specified format and place it on the clipboard by calling the 788 * SetClipboardData function. 785 * On receiving this mesage we must actually render the data in the 786 * specified format and place it on the clipboard by calling the 787 * SetClipboardData function. 789 788 */ 790 789 case WM_RENDERFORMAT: 791 790 { 792 791 FORMATETC rgelt; 793 792 794 793 ZeroMemory( &rgelt, sizeof(FORMATETC)); 795 794 … … 803 802 804 803 TRACE("(): WM_RENDERFORMAT(cfFormat=%d)\n", rgelt.cfFormat); 805 804 806 805 /* 807 806 * Render the clipboard data. … … 827 826 IEnumFORMATETC* penumFormatetc = NULL; 828 827 FORMATETC rgelt; 829 828 830 829 TRACE("(): WM_RENDERALLFORMATS\n"); 831 830 832 831 /* 833 832 * Render all HGLOBAL formats supported by the source into … … 846 845 { 847 846 /* 848 * Render the clipboard data. 847 * Render the clipboard data. 849 848 */ 850 849 if ( FAILED(OLEClipbrd_RenderFormat( (IDataObject*)&(theOleClipboard->lpvtbl1), &rgelt )) ) 851 850 continue; 852 851 853 852 TRACE("(): WM_RENDERALLFORMATS(cfFormat=%d)\n", rgelt.cfFormat); 854 853 } 855 854 } 856 855 857 856 IEnumFORMATETC_Release(penumFormatetc); 858 857 … … 993 992 994 993 HeapFree(GetProcessHeap(), 0, mfBits); 995 994 996 995 GlobalUnlock(std2.u.hMetaFilePict); 997 996 … … 1021 1020 * Put a copy of the rendered data back on the clipboard 1022 1021 */ 1023 1022 1024 1023 if ( !(hDup = OLEClipbrd_GlobalDupMem(hStorage)) ) 1025 1024 HANDLE_ERROR( E_OUTOFMEMORY ); 1026 1025 1027 1026 if ( !SetClipboardData( pFormatetc->cfFormat, hDup ) ) 1028 1027 { … … 1032 1031 1033 1032 CLEANUP: 1034 1033 1035 1034 ReleaseStgMedium(&std); 1036 1035 1037 1036 return hr; 1038 1037 } … … 1048 1047 PVOID pGlobalSrc, pGlobalDest; 1049 1048 DWORD cBytes; 1050 1049 1051 1050 if ( !hGlobalSrc ) 1052 1051 return 0; … … 1055 1054 if ( 0 == cBytes ) 1056 1055 return 0; 1057 1056 1058 1057 hGlobalDest = GlobalAlloc( GMEM_DDESHARE|GMEM_MOVEABLE, 1059 1058 cBytes ); 1060 1059 if ( !hGlobalDest ) 1061 1060 return 0; 1062 1061 1063 1062 pGlobalSrc = GlobalLock(hGlobalSrc); 1064 1063 pGlobalDest = GlobalLock(hGlobalDest); … … 1067 1066 1068 1067 memcpy(pGlobalDest, pGlobalSrc, cBytes); 1069 1068 1070 1069 GlobalUnlock(hGlobalSrc); 1071 1070 GlobalUnlock(hGlobalDest); … … 1076 1075 1077 1076 /*---------------------------------------------------------------------* 1078 * Implementation of the internal IDataObject interface exposed by 1077 * Implementation of the internal IDataObject interface exposed by 1079 1078 * the OLE clipboard. 1080 1079 *---------------------------------------------------------------------*/ … … 1091 1090 void** ppvObject) 1092 1091 { 1093 /* 1094 * Declare "This" pointer 1092 /* 1093 * Declare "This" pointer 1095 1094 */ 1096 1095 ICOM_THIS(OLEClipbrd, iface); 1097 1096 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObject); 1098 1097 1099 1098 /* 1100 1099 * Perform a sanity check on the parameters. … … 1102 1101 if ( (This==0) || (ppvObject==0) ) 1103 1102 return E_INVALIDARG; 1104 1103 1105 1104 /* 1106 1105 * Initialize the return parameter. … … 1111 1110 * Compare the riid with the interface IDs implemented by this object. 1112 1111 */ 1113 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 1112 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 1114 1113 { 1115 1114 *ppvObject = iface; 1116 1115 } 1117 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 1116 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 1118 1117 { 1119 1118 *ppvObject = (IDataObject*)&(This->lpvtbl1); … … 1124 1123 return E_NOINTERFACE; 1125 1124 } 1126 1125 1127 1126 /* 1128 1127 * Query Interface always increases the reference count by one when it is 1129 * successful. 1128 * successful. 1130 1129 */ 1131 1130 IUnknown_AddRef((IUnknown*)*ppvObject); … … 1139 1138 * See Windows documentation for more details on IUnknown methods. 1140 1139 */ 1141 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 1140 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 1142 1141 IDataObject* iface) 1143 1142 { 1144 /* 1145 * Declare "This" pointer 1143 /* 1144 * Declare "This" pointer 1146 1145 */ 1147 1146 ICOM_THIS(OLEClipbrd, iface); 1148 1147 1149 1148 TRACE("(%p)->(count=%lu)\n",This, This->ref); 1150 1149 1151 1150 This->ref++; 1152 1151 … … 1159 1158 * See Windows documentation for more details on IUnknown methods. 1160 1159 */ 1161 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 1160 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 1162 1161 IDataObject* iface) 1163 1162 { 1164 /* 1165 * Declare "This" pointer 1163 /* 1164 * Declare "This" pointer 1166 1165 */ 1167 1166 ICOM_THIS(OLEClipbrd, iface); 1168 1167 1169 1168 TRACE("(%p)->(count=%lu)\n",This, This->ref); 1170 1169 1171 1170 /* 1172 1171 * Decrease the reference count on this object. … … 1181 1180 OLEClipbrd_Destroy(This); 1182 1181 } 1183 1182 1184 1183 return This->ref; 1185 1184 } 1186 1185 1187 1186 1188 1187 /************************************************************************ 1189 1188 * OLEClipbrd_IDataObject_GetData (IDataObject) 1190 1189 * 1191 * The OLE Clipboard's implementation of this method delegates to 1190 * The OLE Clipboard's implementation of this method delegates to 1192 1191 * a data source if there is one or wraps around the windows clipboard 1193 1192 * … … 1195 1194 */ 1196 1195 static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( 1197 1198 LPFORMATETC pformatetcIn, 1199 1196 IDataObject* iface, 1197 LPFORMATETC pformatetcIn, 1198 STGMEDIUM* pmedium) 1200 1199 { 1201 1200 HANDLE hData = 0; … … 1204 1203 1205 1204 /* 1206 * Declare "This" pointer 1205 * Declare "This" pointer 1207 1206 */ 1208 1207 ICOM_THIS(OLEClipbrd, iface); 1209 1208 1210 1209 TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium); 1211 1210 … … 1233 1232 */ 1234 1233 1235 /* 1234 /* 1236 1235 * Otherwise, get the data from the windows clipboard using GetClipboardData 1237 1236 */ … … 1241 1240 hData = GetClipboardData(pformatetcIn->cfFormat); 1242 1241 1243 /* 1242 /* 1244 1243 * Return the clipboard data in the storage medium structure 1245 1244 */ … … 1247 1246 pmedium->u.hGlobal = (HGLOBAL)hData; 1248 1247 pmedium->pUnkForRelease = NULL; 1249 1248 1250 1249 hr = S_OK; 1251 1250 1252 1251 CLEANUP: 1253 1252 /* … … 1263 1262 1264 1263 static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere( 1265 IDataObject* iface, 1266 1267 1264 IDataObject* iface, 1265 LPFORMATETC pformatetc, 1266 STGMEDIUM* pmedium) 1268 1267 { 1269 1268 FIXME(": Stub\n"); … … 1274 1273 * OLEClipbrd_IDataObject_QueryGetData (IDataObject) 1275 1274 * 1276 * The OLE Clipboard's implementation of this method delegates to 1275 * The OLE Clipboard's implementation of this method delegates to 1277 1276 * a data source if there is one or wraps around the windows clipboard 1278 1277 * function IsClipboardFormatAvailable() otherwise. … … 1281 1280 */ 1282 1281 static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData( 1283 1284 1285 { 1286 /* 1287 * Declare "This" pointer 1282 IDataObject* iface, 1283 LPFORMATETC pformatetc) 1284 { 1285 /* 1286 * Declare "This" pointer 1288 1287 */ 1289 1288 ICOM_THIS(OLEClipbrd, iface); … … 1315 1314 if ( pformatetc->tymed != TYMED_HGLOBAL ) 1316 1315 return DV_E_TYMED; 1317 1316 1318 1317 /* 1319 1318 * Delegate to the Windows clipboard function IsClipboardFormatAvailable … … 1328 1327 */ 1329 1328 static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc( 1330 IDataObject* iface, 1331 LPFORMATETC pformatectIn, 1332 1329 IDataObject* iface, 1330 LPFORMATETC pformatectIn, 1331 LPFORMATETC pformatetcOut) 1333 1332 { 1334 1333 TRACE("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut); … … 1344 1343 * OLEClipbrd_IDataObject_SetData (IDataObject) 1345 1344 * 1346 * The OLE Clipboard's does not implement this method 1345 * The OLE Clipboard's does not implement this method 1347 1346 * 1348 1347 * See Windows documentation for more details on IDataObject methods. 1349 1348 */ 1350 1349 static HRESULT WINAPI OLEClipbrd_IDataObject_SetData( 1351 1352 LPFORMATETC pformatetc, 1353 STGMEDIUM* pmedium, 1354 1350 IDataObject* iface, 1351 LPFORMATETC pformatetc, 1352 STGMEDIUM* pmedium, 1353 BOOL fRelease) 1355 1354 { 1356 1355 TRACE("\n"); … … 1364 1363 */ 1365 1364 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( 1366 1367 1368 1365 IDataObject* iface, 1366 DWORD dwDirection, 1367 IEnumFORMATETC** ppenumFormatEtc) 1369 1368 { 1370 1369 HRESULT hr = S_OK; … … 1373 1372 UINT format; 1374 1373 BOOL bClipboardOpen; 1375 1376 /* 1377 * Declare "This" pointer 1374 1375 /* 1376 * Declare "This" pointer 1378 1377 */ 1379 1378 ICOM_THIS(OLEClipbrd, iface); … … 1428 1427 HANDLE_ERROR( E_FAIL ); 1429 1428 } 1430 1429 1431 1430 /* Init the FORMATETC struct */ 1432 1431 afmt[i].cfFormat = format; … … 1447 1446 if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc))) 1448 1447 HANDLE_ERROR( hr ); 1449 1448 1450 1449 hr = S_OK; 1451 1450 1452 1451 CLEANUP: 1453 1452 /* … … 1456 1455 if (afmt) 1457 1456 HeapFree(GetProcessHeap(), 0, afmt); 1458 1457 1459 1458 /* 1460 1459 * Close Windows clipboard … … 1469 1468 * OLEClipbrd_IDataObject_DAdvise (IDataObject) 1470 1469 * 1471 * The OLE Clipboard's does not implement this method 1470 * The OLE Clipboard's does not implement this method 1472 1471 * 1473 1472 * See Windows documentation for more details on IDataObject methods. 1474 1473 */ 1475 1474 static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise( 1476 IDataObject* iface, 1477 FORMATETC* pformatetc, 1478 DWORD advf, 1479 IAdviseSink* pAdvSink, 1480 1475 IDataObject* iface, 1476 FORMATETC* pformatetc, 1477 DWORD advf, 1478 IAdviseSink* pAdvSink, 1479 DWORD* pdwConnection) 1481 1480 { 1482 1481 TRACE("\n"); … … 1487 1486 * OLEClipbrd_IDataObject_DUnadvise (IDataObject) 1488 1487 * 1489 * The OLE Clipboard's does not implement this method 1488 * The OLE Clipboard's does not implement this method 1490 1489 * 1491 1490 * See Windows documentation for more details on IDataObject methods. 1492 1491 */ 1493 1492 static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise( 1494 1495 1493 IDataObject* iface, 1494 DWORD dwConnection) 1496 1495 { 1497 1496 TRACE("\n"); … … 1507 1506 */ 1508 1507 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise( 1509 1510 1508 IDataObject* iface, 1509 IEnumSTATDATA** ppenumAdvise) 1511 1510 { 1512 1511 TRACE("\n"); … … 1534 1533 DWORD size=cfmt * sizeof(FORMATETC); 1535 1534 LPMALLOC pIMalloc; 1536 1535 1537 1536 ef = (IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(), 1538 1537 HEAP_ZERO_MEMORY, … … 1540 1539 if (!ef) 1541 1540 return NULL; 1542 1541 1543 1542 ef->ref = 0; 1544 1543 ICOM_VTBL(ef) = &efvt; 1545 1544 ef->pUnkDataObj = pUnkDataObj; 1546 1545 1547 1546 ef->posFmt = 0; 1548 1547 ef->countFmt = cfmt; … … 1551 1550 ef->pFmt = (LPFORMATETC)IMalloc_Alloc(pIMalloc, size); 1552 1551 IMalloc_Release(pIMalloc); 1553 1552 1554 1553 if (ef->pFmt) 1555 1554 memcpy(ef->pFmt, afmt, size); 1556 1555 1557 1556 TRACE("(%p)->()\n",ef); 1558 1557 return (LPENUMFORMATETC)ef; … … 1576 1575 * we only need to support the IUnknown and IEnumFORMATETC interfaces 1577 1576 */ 1578 1577 1579 1578 *ppvObj = NULL; 1580 1579 1581 1580 if(IsEqualIID(riid, &IID_IUnknown)) 1582 1581 { … … 1586 1585 { 1587 1586 *ppvObj = (IDataObject*)This; 1588 } 1589 1587 } 1588 1590 1589 if(*ppvObj) 1591 1590 { … … 1594 1593 return S_OK; 1595 1594 } 1596 1595 1597 1596 TRACE("-- Interface: E_NOINTERFACE\n"); 1598 1597 return E_NOINTERFACE; … … 1615 1614 if (This->pUnkDataObj) 1616 1615 IUnknown_AddRef(This->pUnkDataObj); 1617 1616 1618 1617 return ++(This->ref); 1619 1618 } … … 1633 1632 if (This->pUnkDataObj) 1634 1633 IUnknown_Release(This->pUnkDataObj); /* Release parent data object */ 1635 1636 if (!--(This->ref)) 1634 1635 if (!--(This->ref)) 1637 1636 { 1638 1637 TRACE("() - destroying IEnumFORMATETC(%p)\n",This); … … 1642 1641 IMalloc_Release(pIMalloc); 1643 1642 } 1644 1643 1645 1644 HeapFree(GetProcessHeap(),0,This); 1646 1645 return 0; … … 1661 1660 UINT cfetch; 1662 1661 HRESULT hres = S_FALSE; 1663 1662 1664 1663 TRACE("(%p)->(pos=%u)\n", This, This->posFmt); 1665 1664 1666 1665 if (This->posFmt < This->countFmt) 1667 1666 { … … 1672 1671 hres = S_OK; 1673 1672 } 1674 1673 1675 1674 memcpy(rgelt, &This->pFmt[This->posFmt], cfetch * sizeof(FORMATETC)); 1676 1675 This->posFmt += cfetch; … … 1680 1679 cfetch = 0; 1681 1680 } 1682 1681 1683 1682 if (pceltFethed) 1684 1683 { 1685 1684 *pceltFethed = cfetch; 1686 1685 } 1687 1686 1688 1687 return hres; 1689 1688 } … … 1698 1697 ICOM_THIS(IEnumFORMATETCImpl,iface); 1699 1698 TRACE("(%p)->(num=%lu)\n", This, celt); 1700 1699 1701 1700 This->posFmt += celt; 1702 1701 if (This->posFmt > This->countFmt) … … 1717 1716 ICOM_THIS(IEnumFORMATETCImpl,iface); 1718 1717 TRACE("(%p)->()\n", This); 1719 1718 1720 1719 This->posFmt = 0; 1721 1720 return S_OK; … … 1732 1731 ICOM_THIS(IEnumFORMATETCImpl,iface); 1733 1732 HRESULT hr = S_OK; 1734 1733 1735 1734 TRACE("(%p)->(ppenum=%p)\n", This, ppenum); 1736 1735 … … 1744 1743 if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum))) 1745 1744 return ( hr ); 1746 1745 1747 1746 return (*ppenum) ? S_OK : E_OUTOFMEMORY; 1748 1747 } -
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); -
trunk/src/ole32/compositemoniker.c
r6648 r6711 1 /* $Id: compositemoniker.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */2 1 /*************************************************************************************** 3 * 2 * CompositeMonikers implementation 4 3 * 5 4 * Copyright 1999 Noomen Hamza … … 18 17 #include "ole2.h" 19 18 19 #ifdef __WIN32OS2__ 20 #undef FIXME 21 #undef TRACE 22 #ifdef DEBUG 23 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 24 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 25 #else 26 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 27 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 28 #endif 29 #endif 30 20 31 DEFAULT_DEBUG_CHANNEL(ole); 21 32 … … 27 38 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 28 39 29 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 40 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 30 41 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 31 42 */ … … 187 198 { 188 199 ICOM_THIS(CompositeMonikerImpl,iface); 189 200 190 201 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 191 202 192 203 /* Perform a sanity check on the parameters.*/ 193 204 if ( (This==0) || (ppvObject==0) ) 194 195 205 return E_INVALIDARG; 206 196 207 /* Initialize the return parameter */ 197 208 *ppvObject = 0; … … 236 247 ICOM_THIS(CompositeMonikerImpl,iface); 237 248 ULONG i; 238 249 239 250 TRACE("(%p)\n",This); 240 251 … … 247 258 for (i=0;i<This->tabLastIndex;i++) 248 259 IMoniker_Release(This->tabMoniker[i]); 249 260 250 261 CompositeMonikerImpl_Destroy(This); 251 262 … … 264 275 if (pClassID==NULL) 265 276 return E_POINTER; 266 277 267 278 *pClassID = CLSID_CompositeMoniker; 268 279 269 280 return S_OK; 270 281 } … … 293 304 CLSID clsid; 294 305 WCHAR string[1]={0}; 295 296 ICOM_THIS(CompositeMonikerImpl,iface); 306 307 ICOM_THIS(CompositeMonikerImpl,iface); 297 308 298 309 TRACE("(%p,%p)\n",iface,pStm); … … 350 361 /* resize the table if needed */ 351 362 if (++This->tabLastIndex==This->tabSize){ 352 363 353 364 This->tabSize+=BLOCK_TAB_SIZE; 354 365 This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); … … 371 382 IMoniker *pmk; 372 383 DWORD constant=3; 373 384 374 385 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty); 375 386 … … 446 457 IMoniker *tempMk; 447 458 HRESULT res; 448 459 449 460 TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest); 450 461 … … 472 483 473 484 IMoniker_Enum(pmkFirst,TRUE,&enumMoniker); 474 485 475 486 while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){ 476 487 477 488 478 489 if (++This->tabLastIndex==This->tabSize){ 479 490 480 491 This->tabSize+=BLOCK_TAB_SIZE; 481 492 This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); … … 492 503 493 504 IMoniker_IsSystemMoniker(pmkRest,&mkSys); 494 505 495 506 if (mkSys!=MKSYS_GENERICCOMPOSITE){ 496 507 … … 499 510 res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],pmkRest,TRUE,&tempMk); 500 511 501 if (res==MK_E_NEEDGENERIC){ 512 if (res==MK_E_NEEDGENERIC){ 502 513 503 514 /* there's no simplification in this case */ … … 508 519 IMoniker_AddRef(pmkRest); 509 520 } 510 else if (tempMk==NULL){ 521 else if (tempMk==NULL){ 511 522 512 523 /* we have an antimoniker after a simple moniker so we can make a simplification in this case */ … … 526 537 /* resize tabMoniker if needed */ 527 538 if (This->tabLastIndex==This->tabSize){ 528 539 529 540 This->tabSize+=BLOCK_TAB_SIZE; 530 541 … … 563 574 564 575 if (This->tabLastIndex==This->tabSize){ 565 576 566 577 This->tabSize+=BLOCK_TAB_SIZE; 567 578 … … 606 617 IMoniker *tempMk,*antiMk,*mostRigthMk; 607 618 IEnumMoniker *enumMoniker; 608 619 609 620 TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); 610 621 611 622 if (ppvResult==NULL) 612 623 return E_POINTER; 613 624 614 625 *ppvResult=0; 615 626 /* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */ … … 635 646 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 636 647 IEnumMoniker_Release(enumMoniker); 637 648 638 649 res=CreateAntiMoniker(&antiMk); 639 650 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); 640 651 IMoniker_Release(antiMk); 641 652 642 653 res=CompositeMonikerImpl_BindToObject(mostRigthMk,pbc,tempMk,riid,ppvResult); 643 654 … … 670 681 671 682 if (pmkToLeft!=NULL){ 672 683 673 684 IMoniker_Enum(iface,FALSE,&enumMoniker); 674 685 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 675 686 IEnumMoniker_Release(enumMoniker); 676 687 677 688 res=CreateAntiMoniker(&antiMk); 678 689 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); 679 690 IMoniker_Release(antiMk); 680 691 681 692 res=CompositeMonikerImpl_BindToStorage(mostRigthMk,pbc,tempMk,riid,ppvResult); 682 693 … … 716 727 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 717 728 IEnumMoniker_Release(enumMoniker); 718 729 719 730 res=CreateAntiMoniker(&antiMk); 720 731 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); … … 733 744 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 734 745 IEnumMoniker_Release(enumMoniker); 735 746 736 747 res=CreateAntiMoniker(&antiMk); 737 748 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); … … 769 780 770 781 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 771 782 return E_POINTER; 772 783 773 784 *ppmkComposite=0; … … 776 787 /* otherwise, the method returns the result of combining the two monikers by calling the */ 777 788 /* CreateGenericComposite function */ 778 789 779 790 if (fOnlyIfNotGeneric) 780 791 return MK_E_NEEDGENERIC; 781 792 782 793 return CreateGenericComposite(iface,pmkRight,ppmkComposite); 783 794 } … … 794 805 if (ppenumMoniker == NULL) 795 806 return E_POINTER; 796 807 797 808 return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabLastIndex,0,fForward,ppenumMoniker); 798 809 } … … 806 817 IMoniker *tempMk1,*tempMk2; 807 818 HRESULT res1,res2,res; 808 819 809 820 TRACE("(%p,%p)\n",iface,pmkOtherMoniker); 810 821 … … 818 829 if (enumMoniker1==NULL) 819 830 return S_FALSE; 820 831 821 832 IMoniker_Enum(iface,TRUE,&enumMoniker2); 822 833 … … 825 836 res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL); 826 837 res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL); 827 838 828 839 if((res1==S_OK)&&(res2==S_OK)){ 829 840 … … 895 906 /* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */ 896 907 /* to this moniker */ 897 908 898 909 if (pmkNewlyRunning!=NULL) 899 910 … … 913 924 /* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */ 914 925 /* the composite as the pmkToLeft parameter for that call. */ 915 926 916 927 res=IBindCtx_GetRunningObjectTable(pbc,&rot); 917 928 … … 957 968 IMoniker *tempMk,*antiMk,*mostRigthMk; 958 969 IEnumMoniker *enumMoniker; 959 970 960 971 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime); 961 972 … … 1054 1065 IEnumMoniker *enumMoniker1,*enumMoniker2; 1055 1066 ULONG i,nbCommonMk=0; 1056 1067 1057 1068 /* If the other moniker is a composite, this method compares the components of each composite from left */ 1058 1069 /* to right. The returned common prefix moniker might also be a composite moniker, depending on how many */ … … 1061 1072 if (ppmkPrefix==NULL) 1062 1073 return E_POINTER; 1063 1074 1064 1075 *ppmkPrefix=0; 1065 1076 1066 1077 if (pmkOther==NULL) 1067 1078 return MK_E_NOPREFIX; 1068 1079 1069 1080 IMoniker_IsSystemMoniker(pmkOther,&mkSys); 1070 1081 … … 1130 1141 IMoniker_Release(tempMk1); 1131 1142 IMoniker_Release(tempMk2); 1132 1143 1133 1144 /* compose all common monikers in a composite moniker */ 1134 1145 for(i=0;i<nbCommonMk;i++){ … … 1141 1152 1142 1153 IMoniker_Release(tempMk1); 1143 1154 1144 1155 *ppmkPrefix=tempMk2; 1145 1156 } … … 1182 1193 DWORD mkSys; 1183 1194 HRESULT res1,res2; 1184 1195 1185 1196 *restMk=0; 1186 1197 … … 1280 1291 1281 1292 /* finds the common prefix of the two monikers */ 1282 res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk); 1293 res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk); 1283 1294 1284 1295 /* if there's no common prefix or the two moniker are equal the relative is the other moniker */ … … 1337 1348 if (ppszDisplayName==NULL) 1338 1349 return E_POINTER; 1339 1350 1340 1351 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)); 1341 1352 … … 1349 1360 1350 1361 IMoniker_Enum(iface,TRUE,&enumMoniker); 1351 1362 1352 1363 while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){ 1353 1364 … … 1409 1420 if (!pwdMksys) 1410 1421 return E_POINTER; 1411 1422 1412 1423 (*pwdMksys)=MKSYS_GENERICCOMPOSITE; 1413 1424 … … 1446 1457 { 1447 1458 ICOM_THIS_From_IROTData(IMoniker, iface); 1448 1459 1449 1460 TRACE("(%p)\n",iface); 1450 1461 … … 1470 1481 { 1471 1482 ICOM_THIS(EnumMonikerImpl,iface); 1472 1483 1473 1484 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 1474 1485 1475 1486 /* Perform a sanity check on the parameters.*/ 1476 1487 if ( (This==0) || (ppvObject==0) ) 1477 1478 1488 return E_INVALIDARG; 1489 1479 1490 /* Initialize the return parameter */ 1480 1491 *ppvObject = 0; … … 1521 1532 /* destroy the object if there's no more reference on it */ 1522 1533 if (This->ref==0){ 1523 1534 1524 1535 for(i=0;i<This->tabSize;i++) 1525 1536 IMoniker_Release(This->tabMoniker[i]); … … 1548 1559 if (pceltFethed!=NULL) 1549 1560 *pceltFethed= i; 1550 1561 1551 1562 if (i==celt) 1552 1563 return S_OK; … … 1566 1577 1567 1578 This->currentPos+=celt; 1568 1579 1569 1580 return S_OK; 1570 1581 } … … 1612 1623 if (currentPos > tabSize) 1613 1624 return E_INVALIDARG; 1614 1625 1615 1626 /* Initialize the virtual function table. */ 1616 1627 ICOM_VTBL(newEnumMoniker) = &VT_EnumMonikerImpl; … … 1644 1655 1645 1656 /****************************************************************************** 1646 * CreateGenericComposite 1657 * CreateGenericComposite [OLE.55] 1647 1658 ******************************************************************************/ 1648 1659 HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite) … … 1655 1666 if (ppmkComposite==NULL) 1656 1667 return E_POINTER; 1657 1668 1658 1669 *ppmkComposite=0; 1659 1670 … … 1693 1704 1694 1705 /****************************************************************************** 1695 * MonikerCommonPrefixWith 1706 * MonikerCommonPrefixWith [OLE.55] 1696 1707 ******************************************************************************/ 1697 1708 HRESULT WINAPI MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon) -
trunk/src/ole32/datacache.c
r6648 r6711 1 /* $Id: datacache.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */2 1 /* 3 * 2 * OLE 2 Data cache 4 3 * 5 4 * Copyright 1999 Francis Beaudet … … 18 17 * - This implementation of the datacache will let your application 19 18 * load documents that have embedded OLE objects in them and it will 20 * also retrieve the metafile representation of those objects. 19 * also retrieve the metafile representation of those objects. 21 20 * - This implementation of the datacache will also allow your 22 21 * application to save new documents with OLE objects in them. 23 * - The main thing that it doesn't do is allow you to activate 22 * - The main thing that it doesn't do is allow you to activate 24 23 * or modify the OLE objects in any way. 25 24 * - I haven't found any good documentation on the real usage of … … 28 27 * "\002OlePresXXX". It appears to just be a counter. 29 28 * - Also, I don't know the real content of the presentation stream 30 * header. I was able to figure-out where the extent of the object 29 * header. I was able to figure-out where the extent of the object 31 30 * was stored and the aspect, but that's about it. 32 31 */ … … 61 60 typedef struct PresentationDataHeader 62 61 { 63 DWORD unknown1; 64 DWORD unknown2; 65 DWORD unknown3; 62 DWORD unknown1; /* -1 */ 63 DWORD unknown2; /* 3, possibly CF_METAFILEPICT */ 64 DWORD unknown3; /* 4, possibly TYMED_ISTREAM */ 66 65 DVASPECT dvAspect; 67 DWORD unknown5; 66 DWORD unknown5; /* -1 */ 68 67 69 68 DWORD unknown6; 70 DWORD unknown7; 69 DWORD unknown7; /* 0 */ 71 70 DWORD dwObjectExtentX; 72 71 DWORD dwObjectExtentY; … … 82 81 * List all interface VTables here 83 82 */ 84 ICOM_VTABLE(IDataObject)* lpvtbl1; 83 ICOM_VTABLE(IDataObject)* lpvtbl1; 85 84 ICOM_VTABLE(IUnknown)* lpvtbl2; 86 85 ICOM_VTABLE(IPersistStorage)* lpvtbl3; 87 ICOM_VTABLE(IViewObject2)* lpvtbl4; 86 ICOM_VTABLE(IViewObject2)* lpvtbl4; 88 87 ICOM_VTABLE(IOleCache2)* lpvtbl5; 89 88 ICOM_VTABLE(IOleCacheControl)* lpvtbl6; … … 120 119 121 120 /* 122 * Here, I define utility macros to help with the casting of the 121 * Here, I define utility macros to help with the casting of the 123 122 * "this" parameter. 124 123 * There is a version to accomodate all of the VTables implemented … … 126 125 */ 127 126 #define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name; 128 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 129 #define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 130 #define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 131 #define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*)); 132 #define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*)); 127 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 128 #define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 129 #define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 130 #define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*)); 131 #define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*)); 133 132 134 133 /* … … 136 135 */ 137 136 static DataCache* DataCache_Construct(REFCLSID clsid, 138 137 LPUNKNOWN pUnkOuter); 139 138 static void DataCache_Destroy(DataCache* ptrToDestroy); 140 139 static HRESULT DataCache_ReadPresentationData(DataCache* this, 141 142 140 DWORD drawAspect, 141 PresentationDataHeader* header); 143 142 static HRESULT DataCache_OpenPresStream(DataCache *this, 144 145 143 DWORD drawAspect, 144 IStream **pStm); 146 145 static HMETAFILE DataCache_ReadPresMetafile(DataCache* this, 147 146 DWORD drawAspect); 148 147 static void DataCache_FireOnViewChange(DataCache* this, 149 150 148 DWORD aspect, 149 LONG lindex); 151 150 152 151 /* … … 158 157 REFIID riid, 159 158 void** ppvObject); 160 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 159 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 161 160 IUnknown* iface); 162 static ULONG WINAPI DataCache_NDIUnknown_Release( 161 static ULONG WINAPI DataCache_NDIUnknown_Release( 163 162 IUnknown* iface); 164 163 … … 171 170 REFIID riid, 172 171 void** ppvObject); 173 static ULONG WINAPI DataCache_IDataObject_AddRef( 172 static ULONG WINAPI DataCache_IDataObject_AddRef( 174 173 IDataObject* iface); 175 static ULONG WINAPI DataCache_IDataObject_Release( 174 static ULONG WINAPI DataCache_IDataObject_Release( 176 175 IDataObject* iface); 177 176 static HRESULT WINAPI DataCache_GetData( 178 179 LPFORMATETC pformatetcIn, 180 177 IDataObject* iface, 178 LPFORMATETC pformatetcIn, 179 STGMEDIUM* pmedium); 181 180 static HRESULT WINAPI DataCache_GetDataHere( 182 IDataObject* iface, 183 184 181 IDataObject* iface, 182 LPFORMATETC pformatetc, 183 STGMEDIUM* pmedium); 185 184 static HRESULT WINAPI DataCache_QueryGetData( 186 187 185 IDataObject* iface, 186 LPFORMATETC pformatetc); 188 187 static HRESULT WINAPI DataCache_GetCanonicalFormatEtc( 189 IDataObject* iface, 190 LPFORMATETC pformatectIn, 191 188 IDataObject* iface, 189 LPFORMATETC pformatectIn, 190 LPFORMATETC pformatetcOut); 192 191 static HRESULT WINAPI DataCache_IDataObject_SetData( 193 194 LPFORMATETC pformatetc, 195 STGMEDIUM* pmedium, 196 192 IDataObject* iface, 193 LPFORMATETC pformatetc, 194 STGMEDIUM* pmedium, 195 BOOL fRelease); 197 196 static HRESULT WINAPI DataCache_EnumFormatEtc( 198 IDataObject* iface, 199 200 197 IDataObject* iface, 198 DWORD dwDirection, 199 IEnumFORMATETC** ppenumFormatEtc); 201 200 static HRESULT WINAPI DataCache_DAdvise( 202 IDataObject* iface, 203 FORMATETC* pformatetc, 204 DWORD advf, 205 IAdviseSink* pAdvSink, 206 201 IDataObject* iface, 202 FORMATETC* pformatetc, 203 DWORD advf, 204 IAdviseSink* pAdvSink, 205 DWORD* pdwConnection); 207 206 static HRESULT WINAPI DataCache_DUnadvise( 208 209 207 IDataObject* iface, 208 DWORD dwConnection); 210 209 static HRESULT WINAPI DataCache_EnumDAdvise( 211 212 210 IDataObject* iface, 211 IEnumSTATDATA** ppenumAdvise); 213 212 214 213 /* … … 220 219 REFIID riid, 221 220 void** ppvObject); 222 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 221 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 223 222 IPersistStorage* iface); 224 static ULONG WINAPI DataCache_IPersistStorage_Release( 223 static ULONG WINAPI DataCache_IPersistStorage_Release( 225 224 IPersistStorage* iface); 226 static HRESULT WINAPI DataCache_GetClassID( 225 static HRESULT WINAPI DataCache_GetClassID( 227 226 IPersistStorage* iface, 228 229 static HRESULT WINAPI DataCache_IsDirty( 227 CLSID* pClassID); 228 static HRESULT WINAPI DataCache_IsDirty( 230 229 IPersistStorage* iface); 231 static HRESULT WINAPI DataCache_InitNew( 230 static HRESULT WINAPI DataCache_InitNew( 231 IPersistStorage* iface, 232 IStorage* pStg); 233 static HRESULT WINAPI DataCache_Load( 232 234 IPersistStorage* iface, 233 234 static HRESULT WINAPI DataCache_ Load(235 IStorage* pStg); 236 static HRESULT WINAPI DataCache_Save( 235 237 IPersistStorage* iface, 236 IStorage* pStg); 237 static HRESULT WINAPI DataCache_Save( 238 IPersistStorage* iface, 239 IStorage* pStg, 240 BOOL fSameAsLoad); 241 static HRESULT WINAPI DataCache_SaveCompleted( 242 IPersistStorage* iface, 243 IStorage* pStgNew); 238 IStorage* pStg, 239 BOOL fSameAsLoad); 240 static HRESULT WINAPI DataCache_SaveCompleted( 241 IPersistStorage* iface, 242 IStorage* pStgNew); 244 243 static HRESULT WINAPI DataCache_HandsOffStorage( 245 244 IPersistStorage* iface); … … 253 252 REFIID riid, 254 253 void** ppvObject); 255 static ULONG WINAPI DataCache_IViewObject2_AddRef( 254 static ULONG WINAPI DataCache_IViewObject2_AddRef( 256 255 IViewObject2* iface); 257 static ULONG WINAPI DataCache_IViewObject2_Release( 256 static ULONG WINAPI DataCache_IViewObject2_Release( 258 257 IViewObject2* iface); 259 258 static HRESULT WINAPI DataCache_Draw( 260 259 IViewObject2* iface, 261 262 263 264 DVTARGETDEVICE* ptd, 265 HDC hdcTargetDev, 266 267 268 269 270 260 DWORD dwDrawAspect, 261 LONG lindex, 262 void* pvAspect, 263 DVTARGETDEVICE* ptd, 264 HDC hdcTargetDev, 265 HDC hdcDraw, 266 LPCRECTL lprcBounds, 267 LPCRECTL lprcWBounds, 268 IVO_ContCallback pfnContinue, 269 DWORD dwContinue); 271 270 static HRESULT WINAPI DataCache_GetColorSet( 272 IViewObject2* iface, 273 DWORD dwDrawAspect, 274 LONG lindex, 275 void* pvAspect, 276 DVTARGETDEVICE* ptd, 277 HDC hicTargetDevice, 278 271 IViewObject2* iface, 272 DWORD dwDrawAspect, 273 LONG lindex, 274 void* pvAspect, 275 DVTARGETDEVICE* ptd, 276 HDC hicTargetDevice, 277 LOGPALETTE** ppColorSet); 279 278 static HRESULT WINAPI DataCache_Freeze( 280 279 IViewObject2* iface, 281 282 283 void* pvAspect, 284 280 DWORD dwDrawAspect, 281 LONG lindex, 282 void* pvAspect, 283 DWORD* pdwFreeze); 285 284 static HRESULT WINAPI DataCache_Unfreeze( 286 285 IViewObject2* iface, 287 286 DWORD dwFreeze); 288 287 static HRESULT WINAPI DataCache_SetAdvise( 289 288 IViewObject2* iface, 290 DWORD aspects, 291 DWORD advf, 292 289 DWORD aspects, 290 DWORD advf, 291 IAdviseSink* pAdvSink); 293 292 static HRESULT WINAPI DataCache_GetAdvise( 294 IViewObject2* iface, 295 DWORD* pAspects, 296 DWORD* pAdvf, 297 293 IViewObject2* iface, 294 DWORD* pAspects, 295 DWORD* pAdvf, 296 IAdviseSink** ppAdvSink); 298 297 static HRESULT WINAPI DataCache_GetExtent( 299 IViewObject2* iface, 300 DWORD dwDrawAspect, 301 LONG lindex, 302 DVTARGETDEVICE* ptd, 303 298 IViewObject2* iface, 299 DWORD dwDrawAspect, 300 LONG lindex, 301 DVTARGETDEVICE* ptd, 302 LPSIZEL lpsizel); 304 303 305 304 /* … … 311 310 REFIID riid, 312 311 void** ppvObject); 313 static ULONG WINAPI DataCache_IOleCache2_AddRef( 312 static ULONG WINAPI DataCache_IOleCache2_AddRef( 314 313 IOleCache2* iface); 315 static ULONG WINAPI DataCache_IOleCache2_Release( 314 static ULONG WINAPI DataCache_IOleCache2_Release( 316 315 IOleCache2* iface); 317 316 static HRESULT WINAPI DataCache_Cache( 318 317 IOleCache2* iface, 319 320 321 318 FORMATETC* pformatetc, 319 DWORD advf, 320 DWORD* pdwConnection); 322 321 static HRESULT WINAPI DataCache_Uncache( 323 324 322 IOleCache2* iface, 323 DWORD dwConnection); 325 324 static HRESULT WINAPI DataCache_EnumCache( 326 325 IOleCache2* iface, 327 326 IEnumSTATDATA** ppenumSTATDATA); 328 327 static HRESULT WINAPI DataCache_InitCache( 329 330 328 IOleCache2* iface, 329 IDataObject* pDataObject); 331 330 static HRESULT WINAPI DataCache_IOleCache2_SetData( 332 331 IOleCache2* iface, 333 334 335 332 FORMATETC* pformatetc, 333 STGMEDIUM* pmedium, 334 BOOL fRelease); 336 335 static HRESULT WINAPI DataCache_UpdateCache( 337 336 IOleCache2* iface, 338 LPDATAOBJECT pDataObject, 339 340 337 LPDATAOBJECT pDataObject, 338 DWORD grfUpdf, 339 LPVOID pReserved); 341 340 static HRESULT WINAPI DataCache_DiscardCache( 342 341 IOleCache2* iface, 343 342 DWORD dwDiscardOptions); 344 343 345 344 /* … … 351 350 REFIID riid, 352 351 void** ppvObject); 353 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 352 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 354 353 IOleCacheControl* iface); 355 static ULONG WINAPI DataCache_IOleCacheControl_Release( 354 static ULONG WINAPI DataCache_IOleCacheControl_Release( 356 355 IOleCacheControl* iface); 357 356 static HRESULT WINAPI DataCache_OnRun( 358 359 357 IOleCacheControl* iface, 358 LPDATAOBJECT pDataObject); 360 359 static HRESULT WINAPI DataCache_OnStop( 361 360 IOleCacheControl* iface); 362 361 363 362 /* … … 448 447 */ 449 448 HRESULT WINAPI CreateDataCache( 450 LPUNKNOWN pUnkOuter, 451 REFCLSID rclsid, 452 REFIID riid, 449 LPUNKNOWN pUnkOuter, 450 REFCLSID rclsid, 451 REFIID riid, 453 452 LPVOID* ppvObj) 454 453 { … … 472 471 * IUnknown pointer can be returned to the outside. 473 472 */ 474 if ( (pUnkOuter!=NULL) && 473 if ( (pUnkOuter!=NULL) && 475 474 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) ) 476 475 return CLASS_E_NOAGGREGATION; … … 479 478 * Try to construct a new instance of the class. 480 479 */ 481 newCache = DataCache_Construct(rclsid, 482 480 newCache = DataCache_Construct(rclsid, 481 pUnkOuter); 483 482 484 483 if (newCache == 0) … … 515 514 if (newObject==0) 516 515 return newObject; 517 516 518 517 /* 519 518 * Initialize the virtual function table. … … 525 524 newObject->lpvtbl5 = &DataCache_IOleCache2_VTable; 526 525 newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable; 527 528 /* 529 * Start with one reference count. The caller of this function 526 527 /* 528 * Start with one reference count. The caller of this function 530 529 * must release the interface pointer when it is done. 531 530 */ … … 534 533 /* 535 534 * Initialize the outer unknown 536 * We don't keep a reference on the outer unknown since, the way 535 * We don't keep a reference on the outer unknown since, the way 537 536 * aggregation works, our lifetime is at least as large as it's 538 537 * lifetime. … … 580 579 * DataCache_ReadPresentationData 581 580 * 582 * This method will read information for the requested presentation 581 * This method will read information for the requested presentation 583 582 * into the given structure. 584 583 * … … 602 601 hres = DataCache_OpenPresStream( 603 602 this, 604 605 603 drawAspect, 604 &presStream); 606 605 607 606 if (FAILED(hres)) … … 614 613 hres = IStream_Read( 615 614 presStream, 616 617 618 615 header, 616 sizeof(PresentationDataHeader), 617 NULL); 619 618 620 619 /* … … 658 657 { 659 658 IAdviseSink_OnViewChange(this->sinkInterface, 660 661 659 aspect, 660 lindex); 662 661 663 662 /* … … 667 666 if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0) 668 667 { 669 670 671 672 673 668 IAdviseSink_Release(this->sinkInterface); 669 670 this->sinkInterface = NULL; 671 this->sinkAspects = 0; 672 this->sinkAdviseFlag = 0; 674 673 } 675 674 } … … 687 686 688 687 return (elem->type == STGTY_STREAM) 689 690 691 692 693 694 688 && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader)) 689 && (strlenW(name) == 11) 690 && (strncmpW(name, OlePres, 8) == 0) 691 && (name[8] >= '0') && (name[8] <= '9') 692 && (name[9] >= '0') && (name[9] <= '9') 693 && (name[10] >= '0') && (name[10] <= '9'); 695 694 } 696 695 … … 708 707 * 709 708 * Errors: 710 * S_OK 711 * OLE_E_BLANK 709 * S_OK The requested stream has been opened. 710 * OLE_E_BLANK The requested stream could not be found. 712 711 * Quite a few others I'm too lazy to map correctly. 713 712 * 714 713 * Notes: 715 * Algorithm: 716 * 717 * 714 * Algorithm: Scan the elements of the presentation storage, looking 715 * for presentation streams. For each presentation stream, 716 * load the header and check to see if the aspect maches. 718 717 * 719 718 * If a fallback is desired, just opening the first presentation stream … … 736 735 while ((hr = IEnumSTATSTG_Next(pEnum, 1, &elem, NULL)) == S_OK) 737 736 { 738 if (DataCache_IsPresentationStream(&elem)) 739 { 740 IStream *pStm; 741 742 hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName, 743 NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, 744 &pStm); 745 if (SUCCEEDED(hr)) 746 { 747 PresentationDataHeader header; 748 ULONG actual_read; 749 750 hr = IStream_Read(pStm, &header, sizeof(header), &actual_read); 751 752 /* can't use SUCCEEDED(hr): S_FALSE counts as an error */ 753 if (hr == S_OK && actual_read == sizeof(header) 754 && header.dvAspect == drawAspect) 755 { 756 /* Rewind the stream before returning it. */ 757 LARGE_INTEGER offset; 758 offset.s.LowPart = 0; 759 offset.s.HighPart = 0; 760 IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL); 761 762 *ppStm = pStm; 763 764 CoTaskMemFree(elem.pwcsName); 765 IEnumSTATSTG_Release(pEnum); 766 767 return S_OK; 768 } 769 770 IStream_Release(pStm); 771 } 737 if (DataCache_IsPresentationStream(&elem)) 738 { 739 IStream *pStm; 740 741 hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName, 742 NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, 743 &pStm); 744 if (SUCCEEDED(hr)) 745 { 746 PresentationDataHeader header; 747 ULONG actual_read; 748 749 hr = IStream_Read(pStm, &header, sizeof(header), &actual_read); 750 751 /* can't use SUCCEEDED(hr): S_FALSE counts as an error */ 752 if (hr == S_OK && actual_read == sizeof(header) 753 && header.dvAspect == drawAspect) 754 { 755 /* Rewind the stream before returning it. */ 756 LARGE_INTEGER offset; 757 offset.s.LowPart = 0; 758 offset.s.HighPart = 0; 759 IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL); 760 761 *ppStm = pStm; 762 763 CoTaskMemFree(elem.pwcsName); 764 IEnumSTATSTG_Release(pEnum); 765 766 return S_OK; 767 } 768 769 IStream_Release(pStm); 770 } 771 } 772 773 CoTaskMemFree(elem.pwcsName); 772 774 } 773 775 774 CoTaskMemFree(elem.pwcsName);775 }776 777 776 IEnumSTATSTG_Release(pEnum); 778 777 … … 783 782 * DataCache_ReadPresentationData 784 783 * 785 * This method will read information for the requested presentation 784 * This method will read information for the requested presentation 786 785 * into the given structure. 787 786 * … … 809 808 */ 810 809 hres = DataCache_OpenPresStream( 811 this, 812 813 810 this, 811 drawAspect, 812 &presStream); 814 813 815 814 if (FAILED(hres)) … … 820 819 */ 821 820 hres = IStream_Stat(presStream, 822 823 821 &streamInfo, 822 STATFLAG_NONAME); 824 823 825 824 /* … … 831 830 hres = IStream_Seek( 832 831 presStream, 833 834 835 832 offset, 833 STREAM_SEEK_SET, 834 NULL); 836 835 837 836 streamInfo.cbSize.s.LowPart -= offset.s.LowPart; … … 840 839 * Allocate a buffer for the metafile bits. 841 840 */ 842 metafileBits = HeapAlloc(GetProcessHeap(), 843 0, 844 841 metafileBits = HeapAlloc(GetProcessHeap(), 842 0, 843 streamInfo.cbSize.s.LowPart); 845 844 846 845 /* … … 848 847 */ 849 848 hres = IStream_Read( 850 851 852 853 849 presStream, 850 metafileBits, 851 streamInfo.cbSize.s.LowPart, 852 NULL); 854 853 855 854 /* … … 898 897 if ( (this==0) || (ppvObject==0) ) 899 898 return E_INVALIDARG; 900 899 901 900 /* 902 901 * Initialize the return parameter. … … 907 906 * Compare the riid with the interface IDs implemented by this object. 908 907 */ 909 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 908 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 910 909 { 911 910 *ppvObject = iface; 912 911 } 913 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 912 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 914 913 { 915 914 *ppvObject = (IDataObject*)&(this->lpvtbl1); 916 915 } 917 916 else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0) || 918 917 (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) ) 919 918 { 920 919 *ppvObject = (IPersistStorage*)&(this->lpvtbl3); 921 920 } 922 921 else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) || 923 922 (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) ) 924 923 { 925 924 *ppvObject = (IViewObject2*)&(this->lpvtbl4); 926 925 } 927 926 else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) || 928 927 (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) ) 929 928 { 930 929 *ppvObject = (IOleCache2*)&(this->lpvtbl5); 931 930 } 932 else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 931 else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 933 932 { 934 933 *ppvObject = (IOleCacheControl*)&(this->lpvtbl6); … … 943 942 return E_NOINTERFACE; 944 943 } 945 944 946 945 /* 947 946 * Query Interface always increases the reference count by one when it is 948 * successful. 947 * successful. 949 948 */ 950 949 IUnknown_AddRef((IUnknown*)*ppvObject); 951 950 952 return S_OK;; 951 return S_OK;; 953 952 } 954 953 … … 961 960 * to the outer unknown. 962 961 */ 963 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 962 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 964 963 IUnknown* iface) 965 964 { … … 979 978 * to the outer unknown. 980 979 */ 981 static ULONG WINAPI DataCache_NDIUnknown_Release( 980 static ULONG WINAPI DataCache_NDIUnknown_Release( 982 981 IUnknown* iface) 983 982 { … … 998 997 return 0; 999 998 } 1000 999 1001 1000 return this->ref; 1002 1001 } … … 1019 1018 _ICOM_THIS_From_IDataObject(DataCache, iface); 1020 1019 1021 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1020 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1022 1021 } 1023 1022 … … 1027 1026 * See Windows documentation for more details on IUnknown methods. 1028 1027 */ 1029 static ULONG WINAPI DataCache_IDataObject_AddRef( 1028 static ULONG WINAPI DataCache_IDataObject_AddRef( 1030 1029 IDataObject* iface) 1031 1030 { 1032 1031 _ICOM_THIS_From_IDataObject(DataCache, iface); 1033 1032 1034 return IUnknown_AddRef(this->outerUnknown); 1033 return IUnknown_AddRef(this->outerUnknown); 1035 1034 } 1036 1035 … … 1040 1039 * See Windows documentation for more details on IUnknown methods. 1041 1040 */ 1042 static ULONG WINAPI DataCache_IDataObject_Release( 1041 static ULONG WINAPI DataCache_IDataObject_Release( 1043 1042 IDataObject* iface) 1044 1043 { 1045 1044 _ICOM_THIS_From_IDataObject(DataCache, iface); 1046 1045 1047 return IUnknown_Release(this->outerUnknown); 1046 return IUnknown_Release(this->outerUnknown); 1048 1047 } 1049 1048 … … 1056 1055 */ 1057 1056 static HRESULT WINAPI DataCache_GetData( 1058 1059 LPFORMATETC pformatetcIn, 1060 1057 IDataObject* iface, 1058 LPFORMATETC pformatetcIn, 1059 STGMEDIUM* pmedium) 1061 1060 { 1062 1061 HRESULT hr = 0; … … 1155 1154 1156 1155 static HRESULT WINAPI DataCache_GetDataHere( 1157 IDataObject* iface, 1158 1159 1156 IDataObject* iface, 1157 LPFORMATETC pformatetc, 1158 STGMEDIUM* pmedium) 1160 1159 { 1161 1160 FIXME("stub\n"); … … 1164 1163 1165 1164 static HRESULT WINAPI DataCache_QueryGetData( 1166 1167 1165 IDataObject* iface, 1166 LPFORMATETC pformatetc) 1168 1167 { 1169 1168 FIXME("stub\n"); … … 1179 1178 */ 1180 1179 static HRESULT WINAPI DataCache_GetCanonicalFormatEtc( 1181 IDataObject* iface, 1182 LPFORMATETC pformatectIn, 1183 1180 IDataObject* iface, 1181 LPFORMATETC pformatectIn, 1182 LPFORMATETC pformatetcOut) 1184 1183 { 1185 1184 TRACE("()\n"); … … 1195 1194 */ 1196 1195 static HRESULT WINAPI DataCache_IDataObject_SetData( 1197 1198 LPFORMATETC pformatetc, 1199 STGMEDIUM* pmedium, 1200 1196 IDataObject* iface, 1197 LPFORMATETC pformatetc, 1198 STGMEDIUM* pmedium, 1199 BOOL fRelease) 1201 1200 { 1202 1201 IOleCache2* oleCache = NULL; … … 1225 1224 */ 1226 1225 static HRESULT WINAPI DataCache_EnumFormatEtc( 1227 IDataObject* iface, 1228 1229 1226 IDataObject* iface, 1227 DWORD dwDirection, 1228 IEnumFORMATETC** ppenumFormatEtc) 1230 1229 { 1231 1230 TRACE("()\n"); … … 1241 1240 */ 1242 1241 static HRESULT WINAPI DataCache_DAdvise( 1243 IDataObject* iface, 1244 FORMATETC* pformatetc, 1245 DWORD advf, 1246 IAdviseSink* pAdvSink, 1247 1242 IDataObject* iface, 1243 FORMATETC* pformatetc, 1244 DWORD advf, 1245 IAdviseSink* pAdvSink, 1246 DWORD* pdwConnection) 1248 1247 { 1249 1248 TRACE("()\n"); … … 1259 1258 */ 1260 1259 static HRESULT WINAPI DataCache_DUnadvise( 1261 1262 1260 IDataObject* iface, 1261 DWORD dwConnection) 1263 1262 { 1264 1263 TRACE("()\n"); … … 1274 1273 */ 1275 1274 static HRESULT WINAPI DataCache_EnumDAdvise( 1276 1277 1275 IDataObject* iface, 1276 IEnumSTATDATA** ppenumAdvise) 1278 1277 { 1279 1278 TRACE("()\n"); … … 1298 1297 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1299 1298 1300 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1299 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1301 1300 } 1302 1301 … … 1306 1305 * See Windows documentation for more details on IUnknown methods. 1307 1306 */ 1308 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 1307 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 1309 1308 IPersistStorage* iface) 1310 1309 { 1311 1310 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1312 1311 1313 return IUnknown_AddRef(this->outerUnknown); 1312 return IUnknown_AddRef(this->outerUnknown); 1314 1313 } 1315 1314 … … 1319 1318 * See Windows documentation for more details on IUnknown methods. 1320 1319 */ 1321 static ULONG WINAPI DataCache_IPersistStorage_Release( 1320 static ULONG WINAPI DataCache_IPersistStorage_Release( 1322 1321 IPersistStorage* iface) 1323 1322 { 1324 1323 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1325 1324 1326 return IUnknown_Release(this->outerUnknown); 1325 return IUnknown_Release(this->outerUnknown); 1327 1326 } 1328 1327 … … 1334 1333 * See Windows documentation for more details on IPersistStorage methods. 1335 1334 */ 1336 static HRESULT WINAPI DataCache_GetClassID( 1335 static HRESULT WINAPI DataCache_GetClassID( 1337 1336 IPersistStorage* iface, 1338 1337 CLSID* pClassID) 1339 1338 { 1340 1339 TRACE("(%p, %p)\n", iface, pClassID); … … 1345 1344 * DataCache_IsDirty (IPersistStorage) 1346 1345 * 1347 * Until we actully connect to a running object and retrieve new 1346 * Until we actully connect to a running object and retrieve new 1348 1347 * information to it, we never get dirty. 1349 1348 * 1350 1349 * See Windows documentation for more details on IPersistStorage methods. 1351 1350 */ 1352 static HRESULT WINAPI DataCache_IsDirty( 1351 static HRESULT WINAPI DataCache_IsDirty( 1353 1352 IPersistStorage* iface) 1354 1353 { … … 1366 1365 * See Windows documentation for more details on IPersistStorage methods. 1367 1366 */ 1368 static HRESULT WINAPI DataCache_InitNew( 1367 static HRESULT WINAPI DataCache_InitNew( 1368 IPersistStorage* iface, 1369 IStorage* pStg) 1370 { 1371 TRACE("(%p, %p)\n", iface, pStg); 1372 1373 return DataCache_Load(iface, pStg); 1374 } 1375 1376 /************************************************************************ 1377 * DataCache_Load (IPersistStorage) 1378 * 1379 * The data cache implementation of IPersistStorage_Load doesn't 1380 * actually load anything. Instead, it holds on to the storage pointer 1381 * and it will load the presentation information when the 1382 * IDataObject_GetData or IViewObject2_Draw methods are called. 1383 * 1384 * See Windows documentation for more details on IPersistStorage methods. 1385 */ 1386 static HRESULT WINAPI DataCache_Load( 1369 1387 IPersistStorage* iface, 1370 IStorage* pStg) 1371 { 1388 IStorage* pStg) 1389 { 1390 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1391 1372 1392 TRACE("(%p, %p)\n", iface, pStg); 1373 1393 1374 return DataCache_Load(iface, pStg);1375 }1376 1377 /************************************************************************1378 * DataCache_Load (IPersistStorage)1379 *1380 * The data cache implementation of IPersistStorage_Load doesn't1381 * actually load anything. Instead, it holds on to the storage pointer1382 * and it will load the presentation information when the1383 * IDataObject_GetData or IViewObject2_Draw methods are called.1384 *1385 * See Windows documentation for more details on IPersistStorage methods.1386 */1387 static HRESULT WINAPI DataCache_Load(1388 IPersistStorage* iface,1389 IStorage* pStg)1390 {1391 _ICOM_THIS_From_IPersistStorage(DataCache, iface);1392 1393 TRACE("(%p, %p)\n", iface, pStg);1394 1395 1394 if (this->presentationStorage != NULL) 1396 1395 { … … 1410 1409 * DataCache_Save (IPersistStorage) 1411 1410 * 1412 * Until we actully connect to a running object and retrieve new 1411 * Until we actully connect to a running object and retrieve new 1413 1412 * information to it, we never have to save anything. However, it is 1414 1413 * our responsability to copy the information when saving to a new … … 1417 1416 * See Windows documentation for more details on IPersistStorage methods. 1418 1417 */ 1419 static HRESULT WINAPI DataCache_Save( 1418 static HRESULT WINAPI DataCache_Save( 1420 1419 IPersistStorage* iface, 1421 IStorage* pStg, 1422 1420 IStorage* pStg, 1421 BOOL fSameAsLoad) 1423 1422 { 1424 1423 _ICOM_THIS_From_IPersistStorage(DataCache, iface); … … 1426 1425 TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad); 1427 1426 1428 if ( (!fSameAsLoad) && 1427 if ( (!fSameAsLoad) && 1429 1428 (this->presentationStorage!=NULL) ) 1430 1429 { 1431 1430 return IStorage_CopyTo(this->presentationStorage, 1432 1433 1434 1435 1431 0, 1432 NULL, 1433 NULL, 1434 pStg); 1436 1435 } 1437 1436 … … 1447 1446 * See Windows documentation for more details on IPersistStorage methods. 1448 1447 */ 1449 static HRESULT WINAPI DataCache_SaveCompleted( 1450 IPersistStorage* iface, 1451 1448 static HRESULT WINAPI DataCache_SaveCompleted( 1449 IPersistStorage* iface, 1450 IStorage* pStgNew) 1452 1451 { 1453 1452 TRACE("(%p, %p)\n", iface, pStgNew); … … 1512 1511 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1513 1512 1514 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1513 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1515 1514 } 1516 1515 … … 1520 1519 * See Windows documentation for more details on IUnknown methods. 1521 1520 */ 1522 static ULONG WINAPI DataCache_IViewObject2_AddRef( 1521 static ULONG WINAPI DataCache_IViewObject2_AddRef( 1523 1522 IViewObject2* iface) 1524 1523 { 1525 1524 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1526 1525 1527 return IUnknown_AddRef(this->outerUnknown); 1526 return IUnknown_AddRef(this->outerUnknown); 1528 1527 } 1529 1528 … … 1533 1532 * See Windows documentation for more details on IUnknown methods. 1534 1533 */ 1535 static ULONG WINAPI DataCache_IViewObject2_Release( 1534 static ULONG WINAPI DataCache_IViewObject2_Release( 1536 1535 IViewObject2* iface) 1537 1536 { 1538 1537 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1539 1538 1540 return IUnknown_Release(this->outerUnknown); 1539 return IUnknown_Release(this->outerUnknown); 1541 1540 } 1542 1541 … … 1551 1550 static HRESULT WINAPI DataCache_Draw( 1552 1551 IViewObject2* iface, 1553 1554 1555 1556 DVTARGETDEVICE* ptd, 1557 HDC hdcTargetDev, 1558 1559 1560 1561 1562 1552 DWORD dwDrawAspect, 1553 LONG lindex, 1554 void* pvAspect, 1555 DVTARGETDEVICE* ptd, 1556 HDC hdcTargetDev, 1557 HDC hdcDraw, 1558 LPCRECTL lprcBounds, 1559 LPCRECTL lprcWBounds, 1560 IVO_ContCallback pfnContinue, 1561 DWORD dwContinue) 1563 1562 { 1564 1563 PresentationDataHeader presData; … … 1569 1568 1570 1569 TRACE("(%p, %lx, %ld, %p, %x, %x, %p, %p, %p, %lx)\n", 1571 1572 1573 1574 1575 hdcTargetDev, 1576 1577 1578 1579 1580 1570 iface, 1571 dwDrawAspect, 1572 lindex, 1573 pvAspect, 1574 hdcTargetDev, 1575 hdcDraw, 1576 lprcBounds, 1577 lprcWBounds, 1578 pfnContinue, 1579 dwContinue); 1581 1580 1582 1581 /* … … 1591 1590 */ 1592 1591 hres = DataCache_ReadPresentationData(this, 1593 1594 1592 dwDrawAspect, 1593 &presData); 1595 1594 1596 1595 if (FAILED(hres)) … … 1605 1604 */ 1606 1605 presMetafile = DataCache_ReadPresMetafile(this, 1607 1606 dwDrawAspect); 1608 1607 1609 1608 /* … … 1620 1619 1621 1620 SetWindowExtEx(hdcDraw, 1622 1623 1624 1625 1626 SetViewportExtEx(hdcDraw, 1627 1628 1629 1621 presData.dwObjectExtentX, 1622 presData.dwObjectExtentY, 1623 &oldWindowExt); 1624 1625 SetViewportExtEx(hdcDraw, 1626 lprcBounds->right - lprcBounds->left, 1627 lprcBounds->bottom - lprcBounds->top, 1628 &oldViewportExt); 1630 1629 1631 1630 SetViewportOrgEx(hdcDraw, 1632 1633 1634 1631 lprcBounds->left, 1632 lprcBounds->top, 1633 &oldViewportOrg); 1635 1634 1636 1635 PlayMetaFile(hdcDraw, presMetafile); 1637 1636 1638 1637 SetWindowExtEx(hdcDraw, 1639 1640 1641 1642 1643 SetViewportExtEx(hdcDraw, 1644 1645 1646 1638 oldWindowExt.cx, 1639 oldWindowExt.cy, 1640 NULL); 1641 1642 SetViewportExtEx(hdcDraw, 1643 oldViewportExt.cx, 1644 oldViewportExt.cy, 1645 NULL); 1647 1646 1648 1647 SetViewportOrgEx(hdcDraw, 1649 1650 1651 1648 oldViewportOrg.x, 1649 oldViewportOrg.y, 1650 NULL); 1652 1651 1653 1652 SetMapMode(hdcDraw, prevMapMode); … … 1660 1659 1661 1660 static HRESULT WINAPI DataCache_GetColorSet( 1662 IViewObject2* iface, 1663 DWORD dwDrawAspect, 1664 LONG lindex, 1665 void* pvAspect, 1666 DVTARGETDEVICE* ptd, 1667 HDC hicTargetDevice, 1668 1661 IViewObject2* iface, 1662 DWORD dwDrawAspect, 1663 LONG lindex, 1664 void* pvAspect, 1665 DVTARGETDEVICE* ptd, 1666 HDC hicTargetDevice, 1667 LOGPALETTE** ppColorSet) 1669 1668 { 1670 1669 FIXME("stub\n"); … … 1674 1673 static HRESULT WINAPI DataCache_Freeze( 1675 1674 IViewObject2* iface, 1676 1677 1678 void* pvAspect, 1679 1675 DWORD dwDrawAspect, 1676 LONG lindex, 1677 void* pvAspect, 1678 DWORD* pdwFreeze) 1680 1679 { 1681 1680 FIXME("stub\n"); … … 1685 1684 static HRESULT WINAPI DataCache_Unfreeze( 1686 1685 IViewObject2* iface, 1687 1686 DWORD dwFreeze) 1688 1687 { 1689 1688 FIXME("stub\n"); … … 1701 1700 static HRESULT WINAPI DataCache_SetAdvise( 1702 1701 IViewObject2* iface, 1703 DWORD aspects, 1704 DWORD advf, 1705 1702 DWORD aspects, 1703 DWORD advf, 1704 IAdviseSink* pAdvSink) 1706 1705 { 1707 1706 _ICOM_THIS_From_IViewObject2(DataCache, iface); … … 1716 1715 IAdviseSink_Release(this->sinkInterface); 1717 1716 this->sinkInterface = NULL; 1718 this->sinkAspects = 0; 1717 this->sinkAspects = 0; 1719 1718 this->sinkAdviseFlag = 0; 1720 1719 } … … 1726 1725 { 1727 1726 this->sinkInterface = pAdvSink; 1728 this->sinkAspects = aspects; 1729 this->sinkAdviseFlag = advf; 1727 this->sinkAspects = aspects; 1728 this->sinkAdviseFlag = advf; 1730 1729 1731 1730 IAdviseSink_AddRef(this->sinkInterface); … … 1739 1738 { 1740 1739 DataCache_FireOnViewChange(this, 1741 1742 1740 DVASPECT_CONTENT, 1741 -1); 1743 1742 } 1744 1743 … … 1749 1748 * DataCache_GetAdvise (IViewObject2) 1750 1749 * 1751 * This method queries the current state of the advise sink 1750 * This method queries the current state of the advise sink 1752 1751 * installed on the data cache. 1753 1752 * … … 1755 1754 */ 1756 1755 static HRESULT WINAPI DataCache_GetAdvise( 1757 IViewObject2* iface, 1758 DWORD* pAspects, 1759 DWORD* pAdvf, 1760 1756 IViewObject2* iface, 1757 DWORD* pAspects, 1758 DWORD* pAdvf, 1759 IAdviseSink** ppAdvSink) 1761 1760 { 1762 1761 _ICOM_THIS_From_IViewObject2(DataCache, iface); … … 1775 1774 if (ppAdvSink!=NULL) 1776 1775 { 1777 IAdviseSink_QueryInterface(this->sinkInterface, 1778 &IID_IAdviseSink, 1779 1776 IAdviseSink_QueryInterface(this->sinkInterface, 1777 &IID_IAdviseSink, 1778 (void**)ppAdvSink); 1780 1779 } 1781 1780 … … 1791 1790 */ 1792 1791 static HRESULT WINAPI DataCache_GetExtent( 1793 IViewObject2* iface, 1794 DWORD dwDrawAspect, 1795 LONG lindex, 1796 DVTARGETDEVICE* ptd, 1797 1792 IViewObject2* iface, 1793 DWORD dwDrawAspect, 1794 LONG lindex, 1795 DVTARGETDEVICE* ptd, 1796 LPSIZEL lpsizel) 1798 1797 { 1799 1798 PresentationDataHeader presData; … … 1802 1801 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1803 1802 1804 TRACE("(%p, %lx, %ld, %p, %p)\n", 1805 1803 TRACE("(%p, %lx, %ld, %p, %p)\n", 1804 iface, dwDrawAspect, lindex, ptd, lpsizel); 1806 1805 1807 1806 /* … … 1829 1828 if (ptd!=NULL) 1830 1829 FIXME("Unimplemented ptd = %p\n", ptd); 1831 1832 /* 1833 * Get the presentation information from the 1830 1831 /* 1832 * Get the presentation information from the 1834 1833 * cache. 1835 1834 */ 1836 1835 hres = DataCache_ReadPresentationData(this, 1837 1838 1836 dwDrawAspect, 1837 &presData); 1839 1838 1840 1839 if (SUCCEEDED(hres)) … … 1871 1870 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1872 1871 1873 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1872 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1874 1873 } 1875 1874 … … 1879 1878 * See Windows documentation for more details on IUnknown methods. 1880 1879 */ 1881 static ULONG WINAPI DataCache_IOleCache2_AddRef( 1880 static ULONG WINAPI DataCache_IOleCache2_AddRef( 1882 1881 IOleCache2* iface) 1883 1882 { 1884 1883 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1885 1884 1886 return IUnknown_AddRef(this->outerUnknown); 1885 return IUnknown_AddRef(this->outerUnknown); 1887 1886 } 1888 1887 … … 1892 1891 * See Windows documentation for more details on IUnknown methods. 1893 1892 */ 1894 static ULONG WINAPI DataCache_IOleCache2_Release( 1893 static ULONG WINAPI DataCache_IOleCache2_Release( 1895 1894 IOleCache2* iface) 1896 1895 { 1897 1896 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1898 1897 1899 return IUnknown_Release(this->outerUnknown); 1898 return IUnknown_Release(this->outerUnknown); 1900 1899 } 1901 1900 1902 1901 static HRESULT WINAPI DataCache_Cache( 1903 1902 IOleCache2* iface, 1904 1905 1906 1903 FORMATETC* pformatetc, 1904 DWORD advf, 1905 DWORD* pdwConnection) 1907 1906 { 1908 1907 FIXME("stub\n"); … … 1911 1910 1912 1911 static HRESULT WINAPI DataCache_Uncache( 1913 1914 1912 IOleCache2* iface, 1913 DWORD dwConnection) 1915 1914 { 1916 1915 FIXME("stub\n"); … … 1920 1919 static HRESULT WINAPI DataCache_EnumCache( 1921 1920 IOleCache2* iface, 1922 1921 IEnumSTATDATA** ppenumSTATDATA) 1923 1922 { 1924 1923 FIXME("stub\n"); … … 1927 1926 1928 1927 static HRESULT WINAPI DataCache_InitCache( 1929 1930 1928 IOleCache2* iface, 1929 IDataObject* pDataObject) 1931 1930 { 1932 1931 FIXME("stub\n"); … … 1936 1935 static HRESULT WINAPI DataCache_IOleCache2_SetData( 1937 1936 IOleCache2* iface, 1938 1939 1940 1937 FORMATETC* pformatetc, 1938 STGMEDIUM* pmedium, 1939 BOOL fRelease) 1941 1940 { 1942 1941 FIXME("stub\n"); … … 1946 1945 static HRESULT WINAPI DataCache_UpdateCache( 1947 1946 IOleCache2* iface, 1948 LPDATAOBJECT pDataObject, 1949 1950 1947 LPDATAOBJECT pDataObject, 1948 DWORD grfUpdf, 1949 LPVOID pReserved) 1951 1950 { 1952 1951 FIXME("stub\n"); … … 1956 1955 static HRESULT WINAPI DataCache_DiscardCache( 1957 1956 IOleCache2* iface, 1958 1957 DWORD dwDiscardOptions) 1959 1958 { 1960 1959 FIXME("stub\n"); … … 1980 1979 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 1981 1980 1982 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1981 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1983 1982 } 1984 1983 … … 1988 1987 * See Windows documentation for more details on IUnknown methods. 1989 1988 */ 1990 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 1989 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 1991 1990 IOleCacheControl* iface) 1992 1991 { 1993 1992 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 1994 1993 1995 return IUnknown_AddRef(this->outerUnknown); 1994 return IUnknown_AddRef(this->outerUnknown); 1996 1995 } 1997 1996 … … 2001 2000 * See Windows documentation for more details on IUnknown methods. 2002 2001 */ 2003 static ULONG WINAPI DataCache_IOleCacheControl_Release( 2002 static ULONG WINAPI DataCache_IOleCacheControl_Release( 2004 2003 IOleCacheControl* iface) 2005 2004 { 2006 2005 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 2007 2006 2008 return IUnknown_Release(this->outerUnknown); 2007 return IUnknown_Release(this->outerUnknown); 2009 2008 } 2010 2009 2011 2010 static HRESULT WINAPI DataCache_OnRun( 2012 2013 2011 IOleCacheControl* iface, 2012 LPDATAOBJECT pDataObject) 2014 2013 { 2015 2014 FIXME("stub\n"); … … 2018 2017 2019 2018 static HRESULT WINAPI DataCache_OnStop( 2020 2019 IOleCacheControl* iface) 2021 2020 { 2022 2021 FIXME("stub\n"); -
trunk/src/ole32/defaulthandler.c
r6648 r6711 1 /* $Id: defaulthandler.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */2 1 /* 3 * 2 * OLE 2 default object handler 4 3 * 5 4 * Copyright 1999 Francis Beaudet … … 26 25 * done in this area. 27 26 * 28 * - Some functions still return E_NOTIMPL they have to be 27 * - Some functions still return E_NOTIMPL they have to be 29 28 * implemented. Most of those are related to the running of the 30 29 * actual server. … … 54 53 * List all interface VTables here 55 54 */ 56 ICOM_VTABLE(IOleObject)* lpvtbl1; 55 ICOM_VTABLE(IOleObject)* lpvtbl1; 57 56 ICOM_VTABLE(IUnknown)* lpvtbl2; 58 57 ICOM_VTABLE(IDataObject)* lpvtbl3; … … 91 90 92 91 /* 93 * The IDataAdviseHolder maintains the data 92 * The IDataAdviseHolder maintains the data 94 93 * connections on behalf of the default handler. 95 94 */ … … 99 98 * Name of the container and object contained 100 99 */ 101 LPWSTR containerApp; 100 LPWSTR containerApp; 102 101 LPWSTR containerObj; 103 102 … … 107 106 108 107 /* 109 * Here, I define utility macros to help with the casting of the 108 * Here, I define utility macros to help with the casting of the 110 109 * "this" parameter. 111 110 * There is a version to accomodate all of the VTables implemented … … 113 112 */ 114 113 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name; 115 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 116 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 117 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 114 #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 115 #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 116 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 118 117 119 118 /* … … 121 120 */ 122 121 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid, 123 122 LPUNKNOWN pUnkOuter); 124 123 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy); 125 124 … … 132 131 REFIID riid, 133 132 void** ppvObject); 134 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 133 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 135 134 IUnknown* iface); 136 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 135 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 137 136 IUnknown* iface); 138 137 … … 145 144 REFIID riid, 146 145 void** ppvObject); 147 static ULONG WINAPI DefaultHandler_AddRef( 146 static ULONG WINAPI DefaultHandler_AddRef( 148 147 IOleObject* iface); 149 static ULONG WINAPI DefaultHandler_Release( 148 static ULONG WINAPI DefaultHandler_Release( 150 149 IOleObject* iface); 151 150 static HRESULT WINAPI DefaultHandler_SetClientSite( 152 153 151 IOleObject* iface, 152 IOleClientSite* pClientSite); 154 153 static HRESULT WINAPI DefaultHandler_GetClientSite( 155 156 154 IOleObject* iface, 155 IOleClientSite** ppClientSite); 157 156 static HRESULT WINAPI DefaultHandler_SetHostNames( 158 159 LPCOLESTR szContainerApp, 160 157 IOleObject* iface, 158 LPCOLESTR szContainerApp, 159 LPCOLESTR szContainerObj); 161 160 static HRESULT WINAPI DefaultHandler_Close( 162 IOleObject* iface, 163 161 IOleObject* iface, 162 DWORD dwSaveOption); 164 163 static HRESULT WINAPI DefaultHandler_SetMoniker( 165 IOleObject* iface, 166 167 164 IOleObject* iface, 165 DWORD dwWhichMoniker, 166 IMoniker* pmk); 168 167 static HRESULT WINAPI DefaultHandler_GetMoniker( 169 170 171 172 168 IOleObject* iface, 169 DWORD dwAssign, 170 DWORD dwWhichMoniker, 171 IMoniker** ppmk); 173 172 static HRESULT WINAPI DefaultHandler_InitFromData( 174 IOleObject* iface, 175 IDataObject* pDataObject, 176 177 173 IOleObject* iface, 174 IDataObject* pDataObject, 175 BOOL fCreation, 176 DWORD dwReserved); 178 177 static HRESULT WINAPI DefaultHandler_GetClipboardData( 179 IOleObject* iface, 180 DWORD dwReserved, 181 178 IOleObject* iface, 179 DWORD dwReserved, 180 IDataObject** ppDataObject); 182 181 static HRESULT WINAPI DefaultHandler_DoVerb( 183 IOleObject* iface, 184 LONG iVerb, 182 IOleObject* iface, 183 LONG iVerb, 185 184 #ifdef __WIN32OS2__ 186 LPMSG lpmsg, 185 LPMSG lpmsg, 187 186 #else 188 struct tagMSG* lpmsg, 187 struct tagMSG* lpmsg, 189 188 #endif 190 IOleClientSite* pActiveSite, 191 LONG lindex, 192 HWND hwndParent, 193 189 IOleClientSite* pActiveSite, 190 LONG lindex, 191 HWND hwndParent, 192 LPCRECT lprcPosRect); 194 193 static HRESULT WINAPI DefaultHandler_EnumVerbs( 195 IOleObject* iface, 196 194 IOleObject* iface, 195 IEnumOLEVERB** ppEnumOleVerb); 197 196 static HRESULT WINAPI DefaultHandler_Update( 198 197 IOleObject* iface); 199 198 static HRESULT WINAPI DefaultHandler_IsUpToDate( 200 199 IOleObject* iface); 201 200 static HRESULT WINAPI DefaultHandler_GetUserClassID( 202 IOleObject* iface, 203 201 IOleObject* iface, 202 CLSID* pClsid); 204 203 static HRESULT WINAPI DefaultHandler_GetUserType( 205 IOleObject* iface, 206 DWORD dwFormOfType, 207 204 IOleObject* iface, 205 DWORD dwFormOfType, 206 LPOLESTR* pszUserType); 208 207 static HRESULT WINAPI DefaultHandler_SetExtent( 209 IOleObject* iface, 210 DWORD dwDrawAspect, 211 208 IOleObject* iface, 209 DWORD dwDrawAspect, 210 SIZEL* psizel); 212 211 static HRESULT WINAPI DefaultHandler_GetExtent( 213 IOleObject* iface, 214 DWORD dwDrawAspect, 215 212 IOleObject* iface, 213 DWORD dwDrawAspect, 214 SIZEL* psizel); 216 215 static HRESULT WINAPI DefaultHandler_Advise( 217 IOleObject* iface, 218 IAdviseSink* pAdvSink, 219 216 IOleObject* iface, 217 IAdviseSink* pAdvSink, 218 DWORD* pdwConnection); 220 219 static HRESULT WINAPI DefaultHandler_Unadvise( 221 IOleObject* iface, 222 220 IOleObject* iface, 221 DWORD dwConnection); 223 222 static HRESULT WINAPI DefaultHandler_EnumAdvise( 224 IOleObject* iface, 225 223 IOleObject* iface, 224 IEnumSTATDATA** ppenumAdvise); 226 225 static HRESULT WINAPI DefaultHandler_GetMiscStatus( 227 IOleObject* iface, 228 DWORD dwAspect, 229 226 IOleObject* iface, 227 DWORD dwAspect, 228 DWORD* pdwStatus); 230 229 static HRESULT WINAPI DefaultHandler_SetColorScheme( 231 232 230 IOleObject* iface, 231 struct tagLOGPALETTE* pLogpal); 233 232 234 233 /* … … 240 239 REFIID riid, 241 240 void** ppvObject); 242 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 241 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 243 242 IDataObject* iface); 244 static ULONG WINAPI DefaultHandler_IDataObject_Release( 243 static ULONG WINAPI DefaultHandler_IDataObject_Release( 245 244 IDataObject* iface); 246 245 static HRESULT WINAPI DefaultHandler_GetData( 247 248 LPFORMATETC pformatetcIn, 249 246 IDataObject* iface, 247 LPFORMATETC pformatetcIn, 248 STGMEDIUM* pmedium); 250 249 static HRESULT WINAPI DefaultHandler_GetDataHere( 251 IDataObject* iface, 252 253 250 IDataObject* iface, 251 LPFORMATETC pformatetc, 252 STGMEDIUM* pmedium); 254 253 static HRESULT WINAPI DefaultHandler_QueryGetData( 255 256 254 IDataObject* iface, 255 LPFORMATETC pformatetc); 257 256 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc( 258 IDataObject* iface, 259 LPFORMATETC pformatectIn, 260 257 IDataObject* iface, 258 LPFORMATETC pformatectIn, 259 LPFORMATETC pformatetcOut); 261 260 static HRESULT WINAPI DefaultHandler_SetData( 262 263 LPFORMATETC pformatetc, 264 STGMEDIUM* pmedium, 265 261 IDataObject* iface, 262 LPFORMATETC pformatetc, 263 STGMEDIUM* pmedium, 264 BOOL fRelease); 266 265 static HRESULT WINAPI DefaultHandler_EnumFormatEtc( 267 IDataObject* iface, 268 269 266 IDataObject* iface, 267 DWORD dwDirection, 268 IEnumFORMATETC** ppenumFormatEtc); 270 269 static HRESULT WINAPI DefaultHandler_DAdvise( 271 IDataObject* iface, 272 FORMATETC* pformatetc, 273 DWORD advf, 274 IAdviseSink* pAdvSink, 275 270 IDataObject* iface, 271 FORMATETC* pformatetc, 272 DWORD advf, 273 IAdviseSink* pAdvSink, 274 DWORD* pdwConnection); 276 275 static HRESULT WINAPI DefaultHandler_DUnadvise( 277 278 276 IDataObject* iface, 277 DWORD dwConnection); 279 278 static HRESULT WINAPI DefaultHandler_EnumDAdvise( 280 281 279 IDataObject* iface, 280 IEnumSTATDATA** ppenumAdvise); 282 281 283 282 /* … … 289 288 REFIID riid, 290 289 void** ppvObject); 291 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 290 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 292 291 IRunnableObject* iface); 293 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 292 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 294 293 IRunnableObject* iface); 295 static HRESULT WINAPI DefaultHandler_GetRunningClass( 294 static HRESULT WINAPI DefaultHandler_GetRunningClass( 295 IRunnableObject* iface, 296 LPCLSID lpClsid); 297 static HRESULT WINAPI DefaultHandler_Run( 296 298 IRunnableObject* iface, 297 LPCLSID lpClsid); 298 static HRESULT WINAPI DefaultHandler_Run( 299 IRunnableObject* iface, 300 IBindCtx* pbc); 301 static BOOL WINAPI DefaultHandler_IsRunning( 299 IBindCtx* pbc); 300 static BOOL WINAPI DefaultHandler_IsRunning( 302 301 IRunnableObject* iface); 303 static HRESULT WINAPI DefaultHandler_LockRunning( 304 IRunnableObject* iface, 305 BOOL fLock, 306 307 static HRESULT WINAPI DefaultHandler_SetContainedObject( 308 IRunnableObject* iface, 309 302 static HRESULT WINAPI DefaultHandler_LockRunning( 303 IRunnableObject* iface, 304 BOOL fLock, 305 BOOL fLastUnlockCloses); 306 static HRESULT WINAPI DefaultHandler_SetContainedObject( 307 IRunnableObject* iface, 308 BOOL fContained); 310 309 311 310 … … 408 407 * IUnknown pointer can be returned to the outside. 409 408 */ 410 if ( (pUnkOuter!=NULL) && 409 if ( (pUnkOuter!=NULL) && 411 410 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) ) 412 411 return CLASS_E_NOAGGREGATION; … … 415 414 * Try to construct a new instance of the class. 416 415 */ 417 newHandler = DefaultHandler_Construct(clsid, 418 416 newHandler = DefaultHandler_Construct(clsid, 417 pUnkOuter); 419 418 420 419 if (newHandler == 0) … … 451 450 if (newObject==0) 452 451 return newObject; 453 452 454 453 /* 455 454 * Initialize the virtual function table. … … 461 460 462 461 /* 463 * Start with one reference count. The caller of this function 462 * Start with one reference count. The caller of this function 464 463 * must release the interface pointer when it is done. 465 464 */ … … 468 467 /* 469 468 * Initialize the outer unknown 470 * We don't keep a reference on the outer unknown since, the way 469 * We don't keep a reference on the outer unknown since, the way 471 470 * aggregation works, our lifetime is at least as large as it's 472 471 * lifetime. … … 480 479 * Create a datacache object. 481 480 * We aggregate with the datacache. Make sure we pass our outer 482 * unknown as the datacache's outer unknown. 481 * unknown as the datacache's outer unknown. 483 482 */ 484 483 CreateDataCache(newObject->outerUnknown, 485 486 487 484 clsid, 485 &IID_IUnknown, 486 (void**)&newObject->dataCache); 488 487 489 488 /* … … 517 516 ptrToDestroy->containerObj = NULL; 518 517 } 519 518 520 519 /* 521 520 * Release our reference to the data cache. … … 586 585 if ( (this==0) || (ppvObject==0) ) 587 586 return E_INVALIDARG; 588 587 589 588 /* 590 589 * Initialize the return parameter. … … 595 594 * Compare the riid with the interface IDs implemented by this object. 596 595 */ 597 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 596 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 598 597 { 599 598 *ppvObject = iface; 600 599 } 601 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 600 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 602 601 { 603 602 *ppvObject = (IOleObject*)&(this->lpvtbl1); 604 603 } 605 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 604 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 606 605 { 607 606 *ppvObject = (IDataObject*)&(this->lpvtbl3); 608 607 } 609 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 608 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 610 609 { 611 610 *ppvObject = (IRunnableObject*)&(this->lpvtbl4); … … 617 616 */ 618 617 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK) 619 620 } 621 618 return S_OK; 619 } 620 622 621 /* 623 622 * Check that we obtained an interface. … … 628 627 return E_NOINTERFACE; 629 628 } 630 629 631 630 /* 632 631 * Query Interface always increases the reference count by one when it is 633 * successful. 632 * successful. 634 633 */ 635 634 IUnknown_AddRef((IUnknown*)*ppvObject); 636 635 637 return S_OK;; 636 return S_OK;; 638 637 } 639 638 … … 646 645 * to the outer unknown. 647 646 */ 648 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 647 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 649 648 IUnknown* iface) 650 649 { … … 664 663 * to the outer unknown. 665 664 */ 666 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 665 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 667 666 IUnknown* iface) 668 667 { … … 683 682 return 0; 684 683 } 685 684 686 685 return this->ref; 687 686 } … … 704 703 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 705 704 706 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 705 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 707 706 } 708 707 … … 712 711 * See Windows documentation for more details on IUnknown methods. 713 712 */ 714 static ULONG WINAPI DefaultHandler_AddRef( 713 static ULONG WINAPI DefaultHandler_AddRef( 715 714 IOleObject* iface) 716 715 { … … 725 724 * See Windows documentation for more details on IUnknown methods. 726 725 */ 727 static ULONG WINAPI DefaultHandler_Release( 726 static ULONG WINAPI DefaultHandler_Release( 728 727 IOleObject* iface) 729 728 { … … 742 741 */ 743 742 static HRESULT WINAPI DefaultHandler_SetClientSite( 744 745 743 IOleObject* iface, 744 IOleClientSite* pClientSite) 746 745 { 747 746 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 777 776 */ 778 777 static HRESULT WINAPI DefaultHandler_GetClientSite( 779 780 778 IOleObject* iface, 779 IOleClientSite** ppClientSite) 781 780 { 782 781 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 807 806 */ 808 807 static HRESULT WINAPI DefaultHandler_SetHostNames( 809 810 LPCOLESTR szContainerApp, 811 808 IOleObject* iface, 809 LPCOLESTR szContainerApp, 810 LPCOLESTR szContainerObj) 812 811 { 813 812 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 814 813 815 814 TRACE("(%p, %s, %s)\n", 816 817 debugstr_w(szContainerApp), 818 815 iface, 816 debugstr_w(szContainerApp), 817 debugstr_w(szContainerObj)); 819 818 820 819 /* 821 820 * Be sure to cleanup before re-assinging the strings. 822 */ 821 */ 823 822 if (this->containerApp!=NULL) 824 823 { … … 861 860 */ 862 861 static HRESULT WINAPI DefaultHandler_Close( 863 IOleObject* iface, 864 862 IOleObject* iface, 863 DWORD dwSaveOption) 865 864 { 866 865 TRACE("()\n"); … … 876 875 */ 877 876 static HRESULT WINAPI DefaultHandler_SetMoniker( 878 IOleObject* iface, 879 880 877 IOleObject* iface, 878 DWORD dwWhichMoniker, 879 IMoniker* pmk) 881 880 { 882 881 TRACE("(%p, %ld, %p)\n", 883 iface, 884 dwWhichMoniker, 885 882 iface, 883 dwWhichMoniker, 884 pmk); 886 885 887 886 return S_OK; … … 896 895 */ 897 896 static HRESULT WINAPI DefaultHandler_GetMoniker( 898 899 900 901 897 IOleObject* iface, 898 DWORD dwAssign, 899 DWORD dwWhichMoniker, 900 IMoniker** ppmk) 902 901 { 903 902 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 904 903 905 904 TRACE("(%p, %ld, %ld, %p)\n", 906 905 iface, dwAssign, dwWhichMoniker, ppmk); 907 906 908 907 if (this->clientSite) 909 908 { 910 909 return IOleClientSite_GetMoniker(this->clientSite, 911 912 913 914 910 dwAssign, 911 dwWhichMoniker, 912 ppmk); 913 915 914 } 916 915 … … 922 921 * 923 922 * This method is meaningless if the server is not running 924 * 923 * 925 924 * See Windows documentation for more details on IOleObject methods. 926 925 */ 927 926 static HRESULT WINAPI DefaultHandler_InitFromData( 928 IOleObject* iface, 929 IDataObject* pDataObject, 930 931 927 IOleObject* iface, 928 IDataObject* pDataObject, 929 BOOL fCreation, 930 DWORD dwReserved) 932 931 { 933 932 TRACE("(%p, %p, %d, %ld)\n", 934 933 iface, pDataObject, fCreation, dwReserved); 935 934 936 935 return OLE_E_NOTRUNNING; … … 941 940 * 942 941 * This method is meaningless if the server is not running 943 * 942 * 944 943 * See Windows documentation for more details on IOleObject methods. 945 944 */ 946 945 static HRESULT WINAPI DefaultHandler_GetClipboardData( 947 IOleObject* iface, 948 DWORD dwReserved, 949 946 IOleObject* iface, 947 DWORD dwReserved, 948 IDataObject** ppDataObject) 950 949 { 951 950 TRACE("(%p, %ld, %p)\n", 952 951 iface, dwReserved, ppDataObject); 953 952 954 953 return OLE_E_NOTRUNNING; … … 956 955 957 956 static HRESULT WINAPI DefaultHandler_DoVerb( 958 IOleObject* iface, 959 LONG iVerb, 957 IOleObject* iface, 958 LONG iVerb, 960 959 #ifdef __WIN32OS2__ 961 LPMSG lpmsg, 960 LPMSG lpmsg, 962 961 #else 963 struct tagMSG* lpmsg, 962 struct tagMSG* lpmsg, 964 963 #endif 965 IOleClientSite* pActiveSite, 966 LONG lindex, 967 HWND hwndParent, 968 964 IOleClientSite* pActiveSite, 965 LONG lindex, 966 HWND hwndParent, 967 LPCRECT lprcPosRect) 969 968 { 970 969 FIXME(": Stub\n"); … … 977 976 * The default handler implementation of this method simply delegates 978 977 * to OleRegEnumVerbs 979 * 978 * 980 979 * See Windows documentation for more details on IOleObject methods. 981 980 */ 982 981 static HRESULT WINAPI DefaultHandler_EnumVerbs( 983 IOleObject* iface, 984 982 IOleObject* iface, 983 IEnumOLEVERB** ppEnumOleVerb) 985 984 { 986 985 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 992 991 993 992 static HRESULT WINAPI DefaultHandler_Update( 994 993 IOleObject* iface) 995 994 { 996 995 FIXME(": Stub\n"); … … 1002 1001 * 1003 1002 * This method is meaningless if the server is not running 1004 * 1003 * 1005 1004 * See Windows documentation for more details on IOleObject methods. 1006 1005 */ 1007 1006 static HRESULT WINAPI DefaultHandler_IsUpToDate( 1008 1007 IOleObject* iface) 1009 1008 { 1010 1009 TRACE("(%p)\n", iface); … … 1017 1016 * 1018 1017 * TODO: Map to a new class ID if emulation is active. 1019 * 1018 * 1020 1019 * See Windows documentation for more details on IOleObject methods. 1021 1020 */ 1022 1021 static HRESULT WINAPI DefaultHandler_GetUserClassID( 1023 IOleObject* iface, 1024 1022 IOleObject* iface, 1023 CLSID* pClsid) 1025 1024 { 1026 1025 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 1044 1043 * The default handler implementation of this method simply delegates 1045 1044 * to OleRegGetUserType 1046 * 1045 * 1047 1046 * See Windows documentation for more details on IOleObject methods. 1048 1047 */ 1049 1048 static HRESULT WINAPI DefaultHandler_GetUserType( 1050 IOleObject* iface, 1051 DWORD dwFormOfType, 1052 1049 IOleObject* iface, 1050 DWORD dwFormOfType, 1051 LPOLESTR* pszUserType) 1053 1052 { 1054 1053 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 1067 1066 */ 1068 1067 static HRESULT WINAPI DefaultHandler_SetExtent( 1069 IOleObject* iface, 1070 DWORD dwDrawAspect, 1071 1068 IOleObject* iface, 1069 DWORD dwDrawAspect, 1070 SIZEL* psizel) 1072 1071 { 1073 1072 TRACE("(%p, %lx, (%ld x %ld))\n", iface, … … 1085 1084 */ 1086 1085 static HRESULT WINAPI DefaultHandler_GetExtent( 1087 IOleObject* iface, 1088 DWORD dwDrawAspect, 1089 1086 IOleObject* iface, 1087 DWORD dwDrawAspect, 1088 SIZEL* psizel) 1090 1089 { 1091 1090 DVTARGETDEVICE* targetDevice; … … 1093 1092 HRESULT hres; 1094 1093 1095 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1094 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1096 1095 1097 1096 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel); … … 1106 1105 * 1107 1106 * Here we would build a valid DVTARGETDEVICE structure 1108 * but, since we are calling into the data cache, we 1109 * know it's implementation and we'll skip this 1107 * but, since we are calling into the data cache, we 1108 * know it's implementation and we'll skip this 1110 1109 * extra work until later. 1111 1110 */ … … 1113 1112 1114 1113 hres = IViewObject2_GetExtent(cacheView, 1115 1116 1117 1118 1114 dwDrawAspect, 1115 -1, 1116 targetDevice, 1117 psizel); 1119 1118 1120 1119 /* … … 1135 1134 */ 1136 1135 static HRESULT WINAPI DefaultHandler_Advise( 1137 IOleObject* iface, 1138 IAdviseSink* pAdvSink, 1139 1136 IOleObject* iface, 1137 IAdviseSink* pAdvSink, 1138 DWORD* pdwConnection) 1140 1139 { 1141 1140 HRESULT hres = S_OK; 1142 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1141 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1143 1142 1144 1143 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection); … … 1154 1153 if (SUCCEEDED(hres)) 1155 1154 { 1156 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 1157 pAdvSink, 1158 1155 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 1156 pAdvSink, 1157 pdwConnection); 1159 1158 } 1160 1159 … … 1171 1170 */ 1172 1171 static HRESULT WINAPI DefaultHandler_Unadvise( 1173 IOleObject* iface, 1174 1175 { 1176 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1172 IOleObject* iface, 1173 DWORD dwConnection) 1174 { 1175 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1177 1176 1178 1177 TRACE("(%p, %ld)\n", iface, dwConnection); … … 1186 1185 1187 1186 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder, 1188 1187 dwConnection); 1189 1188 } 1190 1189 … … 1198 1197 */ 1199 1198 static HRESULT WINAPI DefaultHandler_EnumAdvise( 1200 IOleObject* iface, 1201 1202 { 1203 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1199 IOleObject* iface, 1200 IEnumSTATDATA** ppenumAdvise) 1201 { 1202 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1204 1203 1205 1204 TRACE("(%p, %p)\n", iface, ppenumAdvise); … … 1218 1217 if (this->oleAdviseHolder==NULL) 1219 1218 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder, 1220 1219 ppenumAdvise); 1221 1220 1222 1221 return S_OK; … … 1232 1231 */ 1233 1232 static HRESULT WINAPI DefaultHandler_GetMiscStatus( 1234 IOleObject* iface, 1235 DWORD dwAspect, 1236 1233 IOleObject* iface, 1234 DWORD dwAspect, 1235 DWORD* pdwStatus) 1237 1236 { 1238 1237 HRESULT hres; … … 1257 1256 */ 1258 1257 static HRESULT WINAPI DefaultHandler_SetColorScheme( 1259 1260 1258 IOleObject* iface, 1259 struct tagLOGPALETTE* pLogpal) 1261 1260 { 1262 1261 TRACE("(%p, %p))\n", iface, pLogpal); … … 1275 1274 */ 1276 1275 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface( 1277 IDataObject* iface, 1276 IDataObject* iface, 1278 1277 REFIID riid, 1279 1278 void** ppvObject) … … 1281 1280 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1282 1281 1283 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1282 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1284 1283 } 1285 1284 … … 1289 1288 * See Windows documentation for more details on IUnknown methods. 1290 1289 */ 1291 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 1290 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 1292 1291 IDataObject* iface) 1293 1292 { 1294 1293 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1295 1294 1296 return IUnknown_AddRef(this->outerUnknown); 1295 return IUnknown_AddRef(this->outerUnknown); 1297 1296 } 1298 1297 … … 1302 1301 * See Windows documentation for more details on IUnknown methods. 1303 1302 */ 1304 static ULONG WINAPI DefaultHandler_IDataObject_Release( 1303 static ULONG WINAPI DefaultHandler_IDataObject_Release( 1305 1304 IDataObject* iface) 1306 1305 { 1307 1306 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1308 1307 1309 return IUnknown_Release(this->outerUnknown); 1308 return IUnknown_Release(this->outerUnknown); 1310 1309 } 1311 1310 … … 1318 1317 */ 1319 1318 static HRESULT WINAPI DefaultHandler_GetData( 1320 1321 LPFORMATETC pformatetcIn, 1322 1319 IDataObject* iface, 1320 LPFORMATETC pformatetcIn, 1321 STGMEDIUM* pmedium) 1323 1322 { 1324 1323 IDataObject* cacheDataObject = NULL; … … 1329 1328 TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium); 1330 1329 1331 hres = IUnknown_QueryInterface(this->dataCache, 1332 1333 1330 hres = IUnknown_QueryInterface(this->dataCache, 1331 &IID_IDataObject, 1332 (void**)&cacheDataObject); 1334 1333 1335 1334 if (FAILED(hres)) … … 1337 1336 1338 1337 hres = IDataObject_GetData(cacheDataObject, 1339 1340 1341 1338 pformatetcIn, 1339 pmedium); 1340 1342 1341 IDataObject_Release(cacheDataObject); 1343 1342 1344 1343 return hres; 1345 1344 } 1346 1345 1347 1346 static HRESULT WINAPI DefaultHandler_GetDataHere( 1348 IDataObject* iface, 1349 1350 1347 IDataObject* iface, 1348 LPFORMATETC pformatetc, 1349 STGMEDIUM* pmedium) 1351 1350 { 1352 1351 FIXME(": Stub\n"); … … 1357 1356 * DefaultHandler_QueryGetData (IDataObject) 1358 1357 * 1359 * The default handler's implementation of this method delegates to 1358 * The default handler's implementation of this method delegates to 1360 1359 * the cache. 1361 1360 * … … 1363 1362 */ 1364 1363 static HRESULT WINAPI DefaultHandler_QueryGetData( 1365 1366 1364 IDataObject* iface, 1365 LPFORMATETC pformatetc) 1367 1366 { 1368 1367 IDataObject* cacheDataObject = NULL; … … 1373 1372 TRACE("(%p, %p)\n", iface, pformatetc); 1374 1373 1375 hres = IUnknown_QueryInterface(this->dataCache, 1376 1377 1374 hres = IUnknown_QueryInterface(this->dataCache, 1375 &IID_IDataObject, 1376 (void**)&cacheDataObject); 1378 1377 1379 1378 if (FAILED(hres)) … … 1381 1380 1382 1381 hres = IDataObject_QueryGetData(cacheDataObject, 1383 1382 pformatetc); 1384 1383 1385 1384 IDataObject_Release(cacheDataObject); 1386 1385 1387 1386 return hres; 1388 1387 } … … 1396 1395 */ 1397 1396 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc( 1398 IDataObject* iface, 1399 LPFORMATETC pformatectIn, 1400 1397 IDataObject* iface, 1398 LPFORMATETC pformatectIn, 1399 LPFORMATETC pformatetcOut) 1401 1400 { 1402 1401 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut); … … 1408 1407 * DefaultHandler_SetData (IDataObject) 1409 1408 * 1410 * The default handler's implementation of this method delegates to 1409 * The default handler's implementation of this method delegates to 1411 1410 * the cache. 1412 1411 * … … 1414 1413 */ 1415 1414 static HRESULT WINAPI DefaultHandler_SetData( 1416 1417 LPFORMATETC pformatetc, 1418 STGMEDIUM* pmedium, 1419 1415 IDataObject* iface, 1416 LPFORMATETC pformatetc, 1417 STGMEDIUM* pmedium, 1418 BOOL fRelease) 1420 1419 { 1421 1420 IDataObject* cacheDataObject = NULL; … … 1426 1425 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease); 1427 1426 1428 hres = IUnknown_QueryInterface(this->dataCache, 1429 1430 1427 hres = IUnknown_QueryInterface(this->dataCache, 1428 &IID_IDataObject, 1429 (void**)&cacheDataObject); 1431 1430 1432 1431 if (FAILED(hres)) … … 1434 1433 1435 1434 hres = IDataObject_SetData(cacheDataObject, 1436 1437 1438 1439 1435 pformatetc, 1436 pmedium, 1437 fRelease); 1438 1440 1439 IDataObject_Release(cacheDataObject); 1441 1440 1442 1441 return hres; 1443 1442 } … … 1452 1451 */ 1453 1452 static HRESULT WINAPI DefaultHandler_EnumFormatEtc( 1454 IDataObject* iface, 1455 1456 1453 IDataObject* iface, 1454 DWORD dwDirection, 1455 IEnumFORMATETC** ppenumFormatEtc) 1457 1456 { 1458 1457 HRESULT hres; … … 1475 1474 */ 1476 1475 static HRESULT WINAPI DefaultHandler_DAdvise( 1477 IDataObject* iface, 1478 FORMATETC* pformatetc, 1479 DWORD advf, 1480 IAdviseSink* pAdvSink, 1481 1476 IDataObject* iface, 1477 FORMATETC* pformatetc, 1478 DWORD advf, 1479 IAdviseSink* pAdvSink, 1480 DWORD* pdwConnection) 1482 1481 { 1483 1482 HRESULT hres = S_OK; 1484 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1485 1486 TRACE("(%p, %p, %ld, %p, %p)\n", 1487 1483 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1484 1485 TRACE("(%p, %p, %ld, %p, %p)\n", 1486 iface, pformatetc, advf, pAdvSink, pdwConnection); 1488 1487 1489 1488 /* … … 1497 1496 if (SUCCEEDED(hres)) 1498 1497 { 1499 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 1500 1501 pformatetc, 1502 advf, 1503 pAdvSink, 1504 1498 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 1499 iface, 1500 pformatetc, 1501 advf, 1502 pAdvSink, 1503 pdwConnection); 1505 1504 } 1506 1505 … … 1517 1516 */ 1518 1517 static HRESULT WINAPI DefaultHandler_DUnadvise( 1519 1520 1521 { 1522 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1518 IDataObject* iface, 1519 DWORD dwConnection) 1520 { 1521 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1523 1522 1524 1523 TRACE("(%p, %ld)\n", iface, dwConnection); … … 1533 1532 } 1534 1533 1535 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 1536 1534 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 1535 dwConnection); 1537 1536 } 1538 1537 … … 1546 1545 */ 1547 1546 static HRESULT WINAPI DefaultHandler_EnumDAdvise( 1548 1549 1550 { 1551 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1547 IDataObject* iface, 1548 IEnumSTATDATA** ppenumAdvise) 1549 { 1550 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1552 1551 1553 1552 TRACE("(%p, %p)\n", iface, ppenumAdvise); … … 1569 1568 if (this->dataAdviseHolder!=NULL) 1570 1569 { 1571 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 1572 1570 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 1571 ppenumAdvise); 1573 1572 } 1574 1573 … … 1577 1576 1578 1577 /********************************************************* 1579 * Methods implementation for the IRunnableObject part 1578 * Methods implementation for the IRunnableObject part 1580 1579 * of the DefaultHandler class. 1581 1580 */ … … 1593 1592 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface); 1594 1593 1595 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1594 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1596 1595 } 1597 1596 … … 1601 1600 * See Windows documentation for more details on IUnknown methods. 1602 1601 */ 1603 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 1602 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 1604 1603 IRunnableObject* iface) 1605 1604 { … … 1614 1613 * See Windows documentation for more details on IUnknown methods. 1615 1614 */ 1616 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 1615 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 1617 1616 IRunnableObject* iface) 1618 1617 { … … 1625 1624 * DefaultHandler_GetRunningClass (IRunnableObject) 1626 1625 * 1627 * According to Brockscmidt, Chapter 19, the default handler's 1626 * According to Brockscmidt, Chapter 19, the default handler's 1628 1627 * implementation of IRunnableobject does nothing until the object 1629 1628 * is actually running. … … 1631 1630 * See Windows documentation for more details on IRunnableObject methods. 1632 1631 */ 1633 static HRESULT WINAPI DefaultHandler_GetRunningClass( 1634 IRunnableObject* iface, 1635 1632 static HRESULT WINAPI DefaultHandler_GetRunningClass( 1633 IRunnableObject* iface, 1634 LPCLSID lpClsid) 1636 1635 { 1637 1636 TRACE("()\n"); … … 1639 1638 } 1640 1639 1641 static HRESULT WINAPI DefaultHandler_Run( 1640 static HRESULT WINAPI DefaultHandler_Run( 1642 1641 IRunnableObject* iface, 1643 1642 IBindCtx* pbc) 1644 1643 { 1645 1644 FIXME(": Stub\n"); … … 1650 1649 * DefaultHandler_IsRunning (IRunnableObject) 1651 1650 * 1652 * According to Brockscmidt, Chapter 19, the default handler's 1651 * According to Brockscmidt, Chapter 19, the default handler's 1653 1652 * implementation of IRunnableobject does nothing until the object 1654 1653 * is actually running. … … 1656 1655 * See Windows documentation for more details on IRunnableObject methods. 1657 1656 */ 1658 static BOOL WINAPI DefaultHandler_IsRunning( 1657 static BOOL WINAPI DefaultHandler_IsRunning( 1659 1658 IRunnableObject* iface) 1660 1659 { … … 1666 1665 * DefaultHandler_LockRunning (IRunnableObject) 1667 1666 * 1668 * According to Brockscmidt, Chapter 19, the default handler's 1667 * According to Brockscmidt, Chapter 19, the default handler's 1669 1668 * implementation of IRunnableobject does nothing until the object 1670 1669 * is actually running. … … 1672 1671 * See Windows documentation for more details on IRunnableObject methods. 1673 1672 */ 1674 static HRESULT WINAPI DefaultHandler_LockRunning( 1675 IRunnableObject* iface, 1676 BOOL fLock, 1677 1673 static HRESULT WINAPI DefaultHandler_LockRunning( 1674 IRunnableObject* iface, 1675 BOOL fLock, 1676 BOOL fLastUnlockCloses) 1678 1677 { 1679 1678 TRACE("()\n"); … … 1684 1683 * DefaultHandler_SetContainedObject (IRunnableObject) 1685 1684 * 1686 * According to Brockscmidt, Chapter 19, the default handler's 1685 * According to Brockscmidt, Chapter 19, the default handler's 1687 1686 * implementation of IRunnableobject does nothing until the object 1688 1687 * is actually running. … … 1690 1689 * See Windows documentation for more details on IRunnableObject methods. 1691 1690 */ 1692 static HRESULT WINAPI DefaultHandler_SetContainedObject( 1693 IRunnableObject* iface, 1694 1691 static HRESULT WINAPI DefaultHandler_SetContainedObject( 1692 IRunnableObject* iface, 1693 BOOL fContained) 1695 1694 { 1696 1695 TRACE("()\n"); -
trunk/src/ole32/errorinfo.c
r6648 r6711 1 /* $Id: errorinfo.c,v 1.3 2001-09-05 13:17:09 bird Exp $ */2 1 /* 3 2 * ErrorInfo API … … 6 5 * 7 6 * 8 * The errorinfo is a per-thread object. The reference is stored in the 7 * The errorinfo is a per-thread object. The reference is stored in the 9 8 * TEB at offset 0xf80 10 9 */ … … 31 30 WCHAR* stringBuffer; 32 31 DWORD len; 33 32 34 33 if (in == NULL) 35 34 return NULL; 36 35 /* 37 36 * Find the lenth of the buffer passed-in in bytes. … … 90 89 { 91 90 DWORD* bufferPointer; 92 91 93 92 /* NULL is a valid parameter */ 94 93 if(!in) return; … … 112 111 typedef struct ErrorInfoImpl 113 112 { 114 ICOM_VTABLE(IErrorInfo)*lpvtei;115 ICOM_VTABLE(ICreateErrorInfo)*lpvtcei;116 ICOM_VTABLE(ISupportErrorInfo)*lpvtsei;117 DWORDref;118 119 120 121 122 123 113 ICOM_VTABLE(IErrorInfo) *lpvtei; 114 ICOM_VTABLE(ICreateErrorInfo) *lpvtcei; 115 ICOM_VTABLE(ISupportErrorInfo) *lpvtsei; 116 DWORD ref; 117 118 GUID m_Guid; 119 BSTR bstrSource; 120 BSTR bstrDescription; 121 BSTR bstrHelpFile; 122 DWORD m_dwHelpContext; 124 123 } ErrorInfoImpl; 125 124 126 static ICOM_VTABLE(IErrorInfo) 127 static ICOM_VTABLE(ICreateErrorInfo) 128 static ICOM_VTABLE(ISupportErrorInfo) 125 static ICOM_VTABLE(IErrorInfo) IErrorInfoImpl_VTable; 126 static ICOM_VTABLE(ICreateErrorInfo) ICreateErrorInfoImpl_VTable; 127 static ICOM_VTABLE(ISupportErrorInfo) ISupportErrorInfoImpl_VTable; 129 128 130 129 /* 131 130 converts a objectpointer to This 132 131 */ 133 #define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei))) 134 #define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset); 135 136 #define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei))) 137 #define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset); 138 139 #define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei))) 140 #define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset); 132 #define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei))) 133 #define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset); 134 135 #define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei))) 136 #define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset); 137 138 #define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei))) 139 #define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset); 141 140 142 141 /* 143 142 converts This to a objectpointer 144 143 */ 145 #define _IErrorInfo_(This) 146 #define _ICreateErrorInfo_(This) 147 #define _ISupportErrorInfo_(This) 144 #define _IErrorInfo_(This) (IErrorInfo*)&(This->lpvtei) 145 #define _ICreateErrorInfo_(This) (ICreateErrorInfo*)&(This->lpvtcei) 146 #define _ISupportErrorInfo_(This) (ISupportErrorInfo*)&(This->lpvtsei) 148 147 149 148 IErrorInfo * IErrorInfoImpl_Constructor() 150 149 { 151 152 153 154 155 156 157 158 159 160 161 162 163 150 ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl)); 151 if (ei) 152 { 153 ei->lpvtei = &IErrorInfoImpl_VTable; 154 ei->lpvtcei = &ICreateErrorInfoImpl_VTable; 155 ei->lpvtsei = &ISupportErrorInfoImpl_VTable; 156 ei->ref = 1; 157 ei->bstrSource = NULL; 158 ei->bstrDescription = NULL; 159 ei->bstrHelpFile = NULL; 160 ei->m_dwHelpContext = 0; 161 } 162 return (IErrorInfo *)ei; 164 163 } 165 164 166 165 167 166 static HRESULT WINAPI IErrorInfoImpl_QueryInterface( 168 169 170 171 { 172 173 174 175 176 177 178 179 *ppvoid = _IErrorInfo_(This); 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 167 IErrorInfo* iface, 168 REFIID riid, 169 VOID** ppvoid) 170 { 171 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 172 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid); 173 174 *ppvoid = NULL; 175 176 if(IsEqualIID(riid, &IID_IErrorInfo)) 177 { 178 *ppvoid = _IErrorInfo_(This); 179 } 180 else if(IsEqualIID(riid, &IID_ICreateErrorInfo)) 181 { 182 *ppvoid = _ICreateErrorInfo_(This); 183 } 184 else if(IsEqualIID(riid, &IID_ISupportErrorInfo)) 185 { 186 *ppvoid = _ISupportErrorInfo_(This); 187 } 188 189 if(*ppvoid) 190 { 191 IUnknown_AddRef( (IUnknown*)*ppvoid ); 192 TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid); 193 return S_OK; 194 } 195 TRACE("-- Interface: E_NOINTERFACE\n"); 196 return E_NOINTERFACE; 198 197 } 199 198 200 199 static ULONG WINAPI IErrorInfoImpl_AddRef( 201 202 { 203 204 205 200 IErrorInfo* iface) 201 { 202 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 203 TRACE("(%p)->(count=%lu)\n",This,This->ref); 204 return InterlockedIncrement(&This->ref); 206 205 } 207 206 208 207 static ULONG WINAPI IErrorInfoImpl_Release( 209 210 { 211 212 213 214 215 216 217 218 219 220 208 IErrorInfo* iface) 209 { 210 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 211 TRACE("(%p)->(count=%lu)\n",This,This->ref); 212 213 if (!InterlockedDecrement(&This->ref)) 214 { 215 TRACE("-- destroying IErrorInfo(%p)\n",This); 216 HeapFree(GetProcessHeap(),0,This); 217 return 0; 218 } 219 return This->ref; 221 220 } 222 221 223 222 static HRESULT WINAPI IErrorInfoImpl_GetGUID( 224 225 GUID * pGUID) 226 { 227 228 229 230 231 223 IErrorInfo* iface, 224 GUID * pGUID) 225 { 226 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 227 TRACE("(%p)->(count=%lu)\n",This,This->ref); 228 if(!pGUID )return E_INVALIDARG; 229 memcpy(pGUID, &This->m_Guid, sizeof(GUID)); 230 return S_OK; 232 231 } 233 232 234 233 static HRESULT WINAPI IErrorInfoImpl_GetSource( 235 236 237 { 238 239 240 241 242 243 234 IErrorInfo* iface, 235 BSTR *pBstrSource) 236 { 237 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 238 TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource); 239 if (pBstrSource == NULL) 240 return E_INVALIDARG; 241 *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource); 242 return S_OK; 244 243 } 245 244 246 245 static HRESULT WINAPI IErrorInfoImpl_GetDescription( 247 248 249 { 250 251 252 253 254 255 256 257 246 IErrorInfo* iface, 247 BSTR *pBstrDescription) 248 { 249 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 250 251 TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription); 252 if (pBstrDescription == NULL) 253 return E_INVALIDARG; 254 *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription); 255 256 return S_OK; 258 257 } 259 258 260 259 static HRESULT WINAPI IErrorInfoImpl_GetHelpFile( 261 262 263 { 264 265 266 267 268 269 270 271 260 IErrorInfo* iface, 261 BSTR *pBstrHelpFile) 262 { 263 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 264 265 TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile); 266 if (pBstrHelpFile == NULL) 267 return E_INVALIDARG; 268 *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile); 269 270 return S_OK; 272 271 } 273 272 274 273 static HRESULT WINAPI IErrorInfoImpl_GetHelpContext( 275 276 277 { 278 279 280 281 282 283 284 274 IErrorInfo* iface, 275 DWORD *pdwHelpContext) 276 { 277 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 278 TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext); 279 if (pdwHelpContext == NULL) 280 return E_INVALIDARG; 281 *pdwHelpContext = This->m_dwHelpContext; 282 283 return S_OK; 285 284 } 286 285 … … 291 290 IErrorInfoImpl_AddRef, 292 291 IErrorInfoImpl_Release, 293 292 294 293 IErrorInfoImpl_GetGUID, 295 294 IErrorInfoImpl_GetSource, … … 301 300 302 301 static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface( 303 304 305 306 { 307 308 309 302 ICreateErrorInfo* iface, 303 REFIID riid, 304 VOID** ppvoid) 305 { 306 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 307 TRACE("(%p)\n", This); 308 return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid); 310 309 } 311 310 312 311 static ULONG WINAPI ICreateErrorInfoImpl_AddRef( 313 314 { 315 316 317 312 ICreateErrorInfo* iface) 313 { 314 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 315 TRACE("(%p)\n", This); 316 return IErrorInfo_AddRef(_IErrorInfo_(This)); 318 317 } 319 318 320 319 static ULONG WINAPI ICreateErrorInfoImpl_Release( 321 322 { 323 324 325 320 ICreateErrorInfo* iface) 321 { 322 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 323 TRACE("(%p)\n", This); 324 return IErrorInfo_Release(_IErrorInfo_(This)); 326 325 } 327 326 328 327 329 328 static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID( 330 331 332 { 333 334 335 336 329 ICreateErrorInfo* iface, 330 REFGUID rguid) 331 { 332 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 333 TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid)); 334 memcpy(&This->m_Guid, rguid, sizeof(GUID)); 335 return S_OK; 337 336 } 338 337 339 338 static HRESULT WINAPI ICreateErrorInfoImpl_SetSource( 340 341 342 { 343 344 345 346 347 348 349 339 ICreateErrorInfo* iface, 340 LPOLESTR szSource) 341 { 342 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 343 TRACE("(%p)\n",This); 344 if (This->bstrSource != NULL) 345 ERRORINFO_SysFreeString(This->bstrSource); 346 This->bstrSource = ERRORINFO_SysAllocString(szSource); 347 348 return S_OK; 350 349 } 351 350 352 351 static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription( 353 354 355 { 356 357 358 359 360 361 362 352 ICreateErrorInfo* iface, 353 LPOLESTR szDescription) 354 { 355 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 356 TRACE("(%p)\n",This); 357 if (This->bstrDescription != NULL) 358 ERRORINFO_SysFreeString(This->bstrDescription); 359 This->bstrDescription = ERRORINFO_SysAllocString(szDescription); 360 361 return S_OK; 363 362 } 364 363 365 364 static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile( 366 367 368 { 369 370 371 372 373 374 375 365 ICreateErrorInfo* iface, 366 LPOLESTR szHelpFile) 367 { 368 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 369 TRACE("(%p)\n",This); 370 if (This->bstrHelpFile != NULL) 371 ERRORINFO_SysFreeString(This->bstrHelpFile); 372 This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile); 373 374 return S_OK; 376 375 } 377 376 378 377 static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext( 379 380 381 { 382 383 384 385 386 378 ICreateErrorInfo* iface, 379 DWORD dwHelpContext) 380 { 381 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 382 TRACE("(%p)\n",This); 383 This->m_dwHelpContext = dwHelpContext; 384 385 return S_OK; 387 386 } 388 387 … … 402 401 403 402 static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface( 404 405 406 407 { 408 409 410 411 403 ISupportErrorInfo* iface, 404 REFIID riid, 405 VOID** ppvoid) 406 { 407 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 408 TRACE("(%p)\n", This); 409 410 return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid); 412 411 } 413 412 414 413 static ULONG WINAPI ISupportErrorInfoImpl_AddRef( 415 416 { 417 418 419 414 ISupportErrorInfo* iface) 415 { 416 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 417 TRACE("(%p)\n", This); 418 return IErrorInfo_AddRef(_IErrorInfo_(This)); 420 419 } 421 420 422 421 static ULONG WINAPI ISupportErrorInfoImpl_Release( 423 424 { 425 426 427 422 ISupportErrorInfo* iface) 423 { 424 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 425 TRACE("(%p)\n", This); 426 return IErrorInfo_Release(_IErrorInfo_(This)); 428 427 } 429 428 430 429 431 430 static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo( 432 433 434 { 435 436 437 431 ISupportErrorInfo* iface, 432 REFIID riid) 433 { 434 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 435 TRACE("(%p)->(%s)\n", This, debugstr_guid(riid)); 436 return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE; 438 437 } 439 438 … … 449 448 }; 450 449 /*********************************************************************** 451 * 450 * CreateErrorInfo 452 451 */ 453 452 HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo) 454 453 { 455 456 457 458 459 460 461 462 463 454 IErrorInfo * pei; 455 HRESULT res; 456 TRACE("(%p): stub:\n", pperrinfo); 457 if(! pperrinfo ) return E_INVALIDARG; 458 if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY; 459 460 res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo); 461 IErrorInfo_Release(pei); 462 return res; 464 463 } 465 464 466 465 /*********************************************************************** 467 * 466 * GetErrorInfo 468 467 */ 469 468 HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo) 470 469 { 471 472 473 474 475 476 477 478 470 TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo); 471 472 if(! pperrinfo ) return E_INVALIDARG; 473 if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE; 474 475 /* clear thread error state */ 476 NtCurrentTeb()->ErrorInfo = NULL; 477 return S_OK; 479 478 } 480 479 481 480 /*********************************************************************** 482 * 481 * SetErrorInfo 483 482 */ 484 483 HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo) 485 484 { 486 487 488 489 490 491 492 493 494 495 496 497 } 485 IErrorInfo * pei; 486 TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo); 487 488 /* release old errorinfo */ 489 pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo; 490 if(pei) IErrorInfo_Release(pei); 491 492 /* set to new value */ 493 NtCurrentTeb()->ErrorInfo = perrinfo; 494 if(perrinfo) IErrorInfo_AddRef(perrinfo); 495 return S_OK; 496 } -
trunk/src/ole32/filemoniker.c
r6648 r6711 1 /* $Id: filemoniker.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */2 1 /*************************************************************************************** 3 * 2 * FileMonikers implementation 4 3 * 5 4 * Copyright 1999 Noomen Hamza … … 27 26 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 28 27 29 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 30 29 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 31 30 */ … … 137 136 { 138 137 ICOM_THIS(FileMonikerImpl,iface); 139 138 140 139 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 141 140 142 141 /* Perform a sanity check on the parameters.*/ 143 142 if ( (This==0) || (ppvObject==0) ) 144 145 143 return E_INVALIDARG; 144 146 145 /* Initialize the return parameter */ 147 146 *ppvObject = 0; … … 154 153 ) 155 154 *ppvObject = iface; 156 155 157 156 else if (IsEqualIID(&IID_IROTData, riid)) 158 157 *ppvObject = (IROTData*)&(This->lpvtbl2); … … 161 160 if ((*ppvObject)==0) 162 161 return E_NOINTERFACE; 163 162 164 163 /* Query Interface always increases the reference count by one when it is successful */ 165 164 FileMonikerImpl_AddRef(iface); … … 213 212 214 213 *pClassID = CLSID_FileMoniker; 215 214 216 215 return S_OK; 217 216 } … … 253 252 if (bread!=sizeof(WORD) || wbuffer!=0) 254 253 return E_FAIL; 255 254 256 255 /* read filePath string length (plus one) */ 257 256 res=IStream_Read(pStm,&length,sizeof(DWORD),&bread); … … 269 268 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF) 270 269 return E_FAIL; 271 270 272 271 length--; 273 272 274 273 for(i=0;i<10;i++){ 275 274 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread); … … 277 276 return E_FAIL; 278 277 } 279 278 280 279 if (length>8) 281 280 length=0; 282 281 283 282 doubleLenHex=doubleLenDec=2*length; 284 283 if (length > 5) … … 291 290 if (length==0) 292 291 return res; 293 292 294 293 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread); 295 294 if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex) … … 312 311 313 312 HeapFree(GetProcessHeap(),0,filePathA); 314 313 315 314 return res; 316 315 } … … 325 324 /* this function saves data of this object. In the begining I thougth that I have just to write 326 325 * the filePath string on Stream. But, when I tested this function whith windows programs samples ! 327 * I noted that it was not the case. So I analysed data written by this function on Windows system and 326 * I noted that it was not the case. So I analysed data written by this function on Windows system and 328 327 * what did this function do exactly ! but I have no idear a bout its logic ! 329 328 * I guessed data who must be written on stream wich is: … … 334 333 */ 335 334 336 ICOM_THIS(FileMonikerImpl,iface); 335 ICOM_THIS(FileMonikerImpl,iface); 337 336 338 337 HRESULT res; … … 369 368 /* write a DWORD set to 0xDEADFFFF: constant */ 370 369 res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL); 371 370 372 371 len--; 373 372 /* write 10 times a DWORD set to 0 : constants */ 374 373 for(i=0;i<10;i++) 375 374 res=IStream_Write(pStm,&zero,sizeof(WORD),NULL); 376 375 377 376 if (len>8) 378 377 len=0; 379 378 380 379 doubleLenHex=doubleLenDec=2*len; 381 380 if (len > 5) … … 416 415 417 416 /* for more details see FileMonikerImpl_Save coments */ 418 417 419 418 sizeMAx = sizeof(WORD) + /* first WORD is 0 */ 420 419 sizeof(DWORD)+ /* length of filePath including "\0" in the end of the string */ … … 426 425 if (len==0 || len > 8) 427 426 return S_OK; 428 427 429 428 sizeMAx += sizeof(DWORD)+ /* size of the unicode filePath: "\0" not included */ 430 429 sizeof(WORD)+ /* constant : 0x3 */ 431 430 len*sizeof(WCHAR); /* unicde filePath string */ 432 431 433 432 pcbSize->s.LowPart=sizeMAx; 434 433 pcbSize->s.HighPart=0; … … 448 447 WCHAR bkSlash[]={'\\',0}; 449 448 BYTE addBkSlash; 450 449 451 450 TRACE("(%p,%p)\n",This,lpszPathName); 452 451 … … 493 492 494 493 *This->filePathName=0; 495 494 496 495 for(i=0;tabStr[i]!=NULL;i++) 497 496 strcatW(This->filePathName,tabStr[i]); 498 497 499 498 if (addBkSlash) 500 499 strcatW(This->filePathName,bkSlash); … … 539 538 IClassFactory *pcf=0; 540 539 IClassActivator *pca=0; 541 542 ICOM_THIS(FileMonikerImpl,iface); 540 541 ICOM_THIS(FileMonikerImpl,iface); 543 542 544 543 *ppvResult=0; … … 547 546 548 547 if(pmkToLeft==NULL){ 549 548 550 549 res=IBindCtx_GetRunningObjectTable(pbc,&prot); 551 550 … … 579 578 580 579 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca); 581 580 582 581 if (res==E_NOINTERFACE) 583 582 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED; … … 598 597 599 598 FIXME("()"); 600 599 601 600 /*res=GetClassFile(This->filePathName,&clsID); 602 601 … … 634 633 if (pcf!=NULL) 635 634 IClassFactory_Release(pcf); 636 635 637 636 return res; 638 637 } … … 737 736 738 737 if (pmkRight==NULL) 739 738 return E_INVALIDARG; 740 739 741 740 *ppmkComposite=0; 742 741 743 742 IMoniker_IsSystemMoniker(pmkRight,&mkSys); 744 743 … … 769 768 /* the length of the composed path string is raised by the sum of the two paths lengths */ 770 769 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); 771 772 773 770 771 if (newStr==NULL) 772 return E_OUTOFMEMORY; 774 773 775 774 /* new path is the concatenation of the rest of str1 and str2 */ … … 779 778 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) 780 779 strcatW(newStr,bkSlash); 781 780 782 781 for(j=i;j<=lastIdx2;j++) 783 782 strcatW(newStr,strDec2[j]); 784 783 785 784 /* create a new moniker with the new string */ 786 785 res=CreateFileMoniker(newStr,ppmkComposite); … … 858 857 859 858 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath); 860 859 861 860 if (lstrcmpiW(filePath, 862 861 This->filePathName)!=0) 863 862 864 863 return S_FALSE; 865 864 866 865 return S_OK; 867 866 } … … 880 879 if (pdwHash==NULL) 881 880 return E_POINTER; 882 881 883 882 val = This->filePathName; 884 883 len = lstrlenW(val); … … 887 886 for (i = len ; i > 0; i--) { 888 887 h = (h * 37) + val[off++]; 889 888 } 890 889 } else { 891 890 /* only sample some characters */ 892 893 891 skip = len / 8; 892 for (i = len ; i > 0; i -= skip, off += skip) { 894 893 h = (h * 39) + val[off]; 895 894 } 896 895 } 897 896 … … 964 963 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info)) 965 964 return MK_E_NOOBJECT; 966 965 967 966 *pFileTime=info.ftLastWriteTime; 968 967 } … … 999 998 if (pmkOther==NULL) 1000 999 return E_INVALIDARG; 1001 1000 1002 1001 *ppmkPrefix=0; 1003 1002 1004 1003 /* check if we have the same type of moniker */ 1005 1004 IMoniker_IsSystemMoniker(pmkOther,&mkSys); … … 1023 1022 1024 1023 *commonPath=0; 1025 1024 1026 1025 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) && 1027 1026 (stringTable2[sameIdx]!=NULL) && … … 1042 1041 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\') 1043 1042 sameIdx--; 1044 1043 1045 1044 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) ) 1046 1045 return MK_E_NOPREFIX; … … 1048 1047 for(i=0;i<sameIdx;i++) 1049 1048 strcatW(commonPath,stringTable1[i]); 1050 1049 1051 1050 for(i=0;i<nb1;i++) 1052 1051 CoTaskMemFree(stringTable1[i]); … … 1060 1059 1061 1060 HeapFree(GetProcessHeap(),0,commonPath); 1062 1061 1063 1062 return CreateFileMoniker(commonPath,ppmkPrefix); 1064 1063 } … … 1080 1079 1081 1080 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR)); 1082 1081 1083 1082 if (strgtable==NULL) 1084 1085 1083 return E_OUTOFMEMORY; 1084 1086 1085 while(str[i]!=0){ 1087 1086 … … 1091 1090 1092 1091 if (strgtable[tabIndex]==NULL) 1093 1092 return E_OUTOFMEMORY; 1094 1093 1095 1094 strcpyW(strgtable[tabIndex++],bSlash); … … 1114 1113 } 1115 1114 strgtable[tabIndex]=NULL; 1116 1115 1117 1116 *stringTable=strgtable; 1118 1117 1119 1118 return tabIndex; 1120 1119 } … … 1130 1129 DWORD len1=0,len2=0,sameIdx=0,j=0; 1131 1130 WCHAR back[] ={'.','.','\\',0}; 1132 1131 1133 1132 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); 1134 1133 … … 1138 1137 if (pmOther==NULL) 1139 1138 return E_INVALIDARG; 1140 1139 1141 1140 res=CreateBindCtx(0,&bind); 1142 1141 if (FAILED(res)) 1143 1142 return res; 1144 1143 1145 1144 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1); 1146 1145 if (FAILED(res)) 1147 1146 return res; 1148 1147 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2); 1149 1148 if (FAILED(res)) 1150 1149 return res; 1151 1150 1152 1151 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1); … … 1154 1153 1155 1154 if (FAILED(len1) || FAILED(len2)) 1156 1157 1155 return E_OUTOFMEMORY; 1156 1158 1157 /* count the number of similar items from the begin of the two paths */ 1159 1158 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) && 1160 1159 (tabStr2[sameIdx]!=NULL) && 1161 1160 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++); 1162 1161 … … 1176 1175 for(j=sameIdx;tabStr2[j]!=NULL;j++) 1177 1176 strcatW(relPath,tabStr2[j]); 1178 1177 1179 1178 res=CreateFileMoniker(relPath,ppmkRelPath); 1180 1179 1181 1180 for(j=0; tabStr1[j]!=NULL;j++) 1182 1181 CoTaskMemFree(tabStr1[j]); … … 1220 1219 1221 1220 strcpyW(*ppszDisplayName,This->filePathName); 1222 1221 1223 1222 return S_OK; 1224 1223 } … … 1247 1246 if (!pwdMksys) 1248 1247 return E_POINTER; 1249 1248 1250 1249 (*pwdMksys)=MKSYS_FILEMONIKER; 1251 1250 … … 1284 1283 { 1285 1284 ICOM_THIS_From_IROTData(IMoniker, iface); 1286 1285 1287 1286 TRACE("(%p)\n",This); 1288 1287 … … 1328 1327 if(lpszPathName==NULL) 1329 1328 return MK_E_SYNTAX; 1330 1329 1331 1330 *ppmk=0; 1332 1331 1333 1332 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl)); 1334 1333 … … 1339 1338 1340 1339 if (SUCCEEDED(hr)) 1341 1340 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk); 1342 1341 else 1343 1342 HeapFree(GetProcessHeap(),0,newFileMoniker); -
trunk/src/ole32/hglobalstream.c
r6648 r6711 1 /* $Id: hglobalstream.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */2 1 /* 3 2 * HGLOBAL Stream implementation … … 30 29 { 31 30 ICOM_VFIELD(IStream); /* Needs to be the first item in the stuct 32 33 31 * since we want to cast this in a IStream pointer */ 32 34 33 /* 35 34 * Reference count 36 35 */ 37 ULONG 36 ULONG ref; 38 37 39 38 /* … … 65 64 */ 66 65 HGLOBALStreamImpl* HGLOBALStreamImpl_Construct( 67 68 66 HGLOBAL hGlobal, 67 BOOL fDeleteOnRelease); 69 68 70 69 void HGLOBALStreamImpl_Destroy( … … 75 74 76 75 HRESULT WINAPI HGLOBALStreamImpl_QueryInterface( 77 78 REFIID riid, /* [in] */ 79 void** ppvObject); /* [iid_is][out] */ 80 76 IStream* iface, 77 REFIID riid, /* [in] */ 78 void** ppvObject); /* [iid_is][out] */ 79 81 80 ULONG WINAPI HGLOBALStreamImpl_AddRef( 82 83 81 IStream* iface); 82 84 83 ULONG WINAPI HGLOBALStreamImpl_Release( 85 86 87 HRESULT WINAPI HGLOBALStreamImpl_Read( 88 89 90 ULONG cb, /* [in] */ 91 ULONG* pcbRead); /* [out] */ 92 84 IStream* iface); 85 86 HRESULT WINAPI HGLOBALStreamImpl_Read( 87 IStream* iface, 88 void* pv, /* [length_is][size_is][out] */ 89 ULONG cb, /* [in] */ 90 ULONG* pcbRead); /* [out] */ 91 93 92 HRESULT WINAPI HGLOBALStreamImpl_Write( 94 95 const void* pv, /* [size_is][in] */ 96 ULONG cb, /* [in] */ 97 ULONG* pcbWritten); /* [out] */ 98 99 HRESULT WINAPI HGLOBALStreamImpl_Seek( 100 101 LARGE_INTEGER dlibMove, /* [in] */ 102 DWORD dwOrigin, /* [in] */ 103 104 105 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 106 107 ULARGE_INTEGER libNewSize); /* [in] */ 108 109 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 110 111 IStream* pstm, /* [unique][in] */ 112 ULARGE_INTEGER cb, /* [in] */ 113 ULARGE_INTEGER* pcbRead, /* [out] */ 114 ULARGE_INTEGER* pcbWritten); /* [out] */ 115 116 HRESULT WINAPI HGLOBALStreamImpl_Commit( 117 118 DWORD grfCommitFlags); /* [in] */ 119 120 HRESULT WINAPI HGLOBALStreamImpl_Revert( 121 122 123 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 124 125 ULARGE_INTEGER libOffset, /* [in] */ 126 ULARGE_INTEGER cb, /* [in] */ 127 DWORD dwLockType); /* [in] */ 128 129 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 130 131 ULARGE_INTEGER libOffset, /* [in] */ 132 ULARGE_INTEGER cb, /* [in] */ 133 DWORD dwLockType); /* [in] */ 134 135 HRESULT WINAPI HGLOBALStreamImpl_Stat( 136 137 138 DWORD grfStatFlag); /* [in] */ 139 140 HRESULT WINAPI HGLOBALStreamImpl_Clone( 141 142 IStream** ppstm); /* [out] */ 93 IStream* iface, 94 const void* pv, /* [size_is][in] */ 95 ULONG cb, /* [in] */ 96 ULONG* pcbWritten); /* [out] */ 97 98 HRESULT WINAPI HGLOBALStreamImpl_Seek( 99 IStream* iface, 100 LARGE_INTEGER dlibMove, /* [in] */ 101 DWORD dwOrigin, /* [in] */ 102 ULARGE_INTEGER* plibNewPosition); /* [out] */ 103 104 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 105 IStream* iface, 106 ULARGE_INTEGER libNewSize); /* [in] */ 107 108 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 109 IStream* iface, 110 IStream* pstm, /* [unique][in] */ 111 ULARGE_INTEGER cb, /* [in] */ 112 ULARGE_INTEGER* pcbRead, /* [out] */ 113 ULARGE_INTEGER* pcbWritten); /* [out] */ 114 115 HRESULT WINAPI HGLOBALStreamImpl_Commit( 116 IStream* iface, 117 DWORD grfCommitFlags); /* [in] */ 118 119 HRESULT WINAPI HGLOBALStreamImpl_Revert( 120 IStream* iface); 121 122 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 123 IStream* iface, 124 ULARGE_INTEGER libOffset, /* [in] */ 125 ULARGE_INTEGER cb, /* [in] */ 126 DWORD dwLockType); /* [in] */ 127 128 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 129 IStream* iface, 130 ULARGE_INTEGER libOffset, /* [in] */ 131 ULARGE_INTEGER cb, /* [in] */ 132 DWORD dwLockType); /* [in] */ 133 134 HRESULT WINAPI HGLOBALStreamImpl_Stat( 135 IStream* iface, 136 STATSTG* pstatstg, /* [out] */ 137 DWORD grfStatFlag); /* [in] */ 138 139 HRESULT WINAPI HGLOBALStreamImpl_Clone( 140 IStream* iface, 141 IStream** ppstm); /* [out] */ 143 142 144 143 … … 169 168 */ 170 169 HRESULT WINAPI CreateStreamOnHGlobal( 171 HGLOBAL hGlobal, 172 BOOL fDeleteOnRelease, 173 170 HGLOBAL hGlobal, 171 BOOL fDeleteOnRelease, 172 LPSTREAM* ppstm) 174 173 { 175 174 HGLOBALStreamImpl* newStream; 176 175 177 176 newStream = HGLOBALStreamImpl_Construct(hGlobal, 178 177 fDeleteOnRelease); 179 178 180 179 if (newStream!=NULL) 181 180 { 182 return IUnknown_QueryInterface((IUnknown*)newStream, 183 184 181 return IUnknown_QueryInterface((IUnknown*)newStream, 182 &IID_IStream, 183 (void**)ppstm); 185 184 } 186 185 … … 223 222 * Params: 224 223 * hGlobal - Handle that will support the stream. can be NULL. 225 * fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 224 * fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 226 225 * when the IStream object is destroyed. 227 226 */ 228 227 HGLOBALStreamImpl* HGLOBALStreamImpl_Construct( 229 230 228 HGLOBAL hGlobal, 229 BOOL fDeleteOnRelease) 231 230 { 232 231 HGLOBALStreamImpl* newStream; 233 232 234 233 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl)); 235 234 236 235 if (newStream!=0) 237 236 { … … 241 240 ICOM_VTBL(newStream) = &HGLOBALStreamImpl_Vtbl; 242 241 newStream->ref = 0; 243 242 244 243 /* 245 244 * Initialize the support. … … 254 253 { 255 254 newStream->supportHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD | 256 255 GMEM_SHARE, 0); 257 256 } 258 257 259 258 /* 260 259 * Start the stream at the begining. … … 262 261 newStream->currentPosition.s.HighPart = 0; 263 262 newStream->currentPosition.s.LowPart = 0; 264 263 265 264 /* 266 265 * Initialize the size of the stream to the size of the handle. … … 269 268 newStream->streamSize.s.LowPart = GlobalSize(newStream->supportHandle); 270 269 } 271 270 272 271 return newStream; 273 272 } … … 276 275 * This is the destructor of the HGLOBALStreamImpl class. 277 276 * 278 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 277 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 279 278 * class. The pointer passed-in to this function will be freed and will not 280 279 * be valid anymore. … … 296 295 * Finally, free the memory used-up by the class. 297 296 */ 298 HeapFree(GetProcessHeap(), 0, This); 297 HeapFree(GetProcessHeap(), 0, This); 299 298 } 300 299 … … 304 303 */ 305 304 HRESULT WINAPI HGLOBALStreamImpl_QueryInterface( 306 307 REFIID riid, /* [in] */ 308 void** ppvObject) /* [iid_is][out] */ 305 IStream* iface, 306 REFIID riid, /* [in] */ 307 void** ppvObject) /* [iid_is][out] */ 309 308 { 310 309 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 315 314 if (ppvObject==0) 316 315 return E_INVALIDARG; 317 316 318 317 /* 319 318 * Initialize the return parameter. 320 319 */ 321 320 *ppvObject = 0; 322 321 323 322 /* 324 323 * Compare the riid with the interface IDs implemented by this object. 325 324 */ 326 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 325 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 327 326 { 328 327 *ppvObject = (IStream*)This; 329 328 } 330 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 329 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 331 330 { 332 331 *ppvObject = (IStream*)This; 333 332 } 334 333 335 334 /* 336 335 * Check that we obtained an interface. … … 338 337 if ((*ppvObject)==0) 339 338 return E_NOINTERFACE; 340 339 341 340 /* 342 341 * Query Interface always increases the reference count by one when it is … … 344 343 */ 345 344 HGLOBALStreamImpl_AddRef(iface); 346 345 347 346 return S_OK;; 348 347 } … … 353 352 */ 354 353 ULONG WINAPI HGLOBALStreamImpl_AddRef( 355 354 IStream* iface) 356 355 { 357 356 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; 358 357 359 358 This->ref++; 360 359 361 360 return This->ref; 362 361 } … … 367 366 */ 368 367 ULONG WINAPI HGLOBALStreamImpl_Release( 369 368 IStream* iface) 370 369 { 371 370 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; 372 371 373 372 ULONG newRef; 374 373 375 374 This->ref--; 376 375 377 376 newRef = This->ref; 378 377 379 378 /* 380 379 * If the reference count goes down to 0, perform suicide. … … 384 383 HGLOBALStreamImpl_Destroy(This); 385 384 } 386 385 387 386 return newRef; 388 387 } … … 397 396 * See the documentation of ISequentialStream for more info. 398 397 */ 399 HRESULT WINAPI HGLOBALStreamImpl_Read( 400 401 402 ULONG cb, /* [in] */ 403 ULONG* pcbRead) /* [out] */ 398 HRESULT WINAPI HGLOBALStreamImpl_Read( 399 IStream* iface, 400 void* pv, /* [length_is][size_is][out] */ 401 ULONG cb, /* [in] */ 402 ULONG* pcbRead) /* [out] */ 404 403 { 405 404 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 410 409 411 410 TRACE("(%p, %p, %ld, %p)\n", iface, 412 413 414 /* 411 pv, cb, pcbRead); 412 413 /* 415 414 * If the caller is not interested in the nubmer of bytes read, 416 415 * we use another buffer to avoid "if" statements in the code. … … 418 417 if (pcbRead==0) 419 418 pcbRead = &bytesReadBuffer; 420 419 421 420 /* 422 421 * Using the known size of the stream, calculate the number of bytes … … 446 445 */ 447 446 GlobalUnlock(This->supportHandle); 448 447 449 448 /* 450 449 * The function returns S_OK if the buffer was filled completely … … 454 453 if(*pcbRead == cb) 455 454 return S_OK; 456 455 457 456 return S_FALSE; 458 457 } 459 458 460 459 /*** 461 460 * This method is part of the ISequentialStream interface. … … 469 468 */ 470 469 HRESULT WINAPI HGLOBALStreamImpl_Write( 471 472 const void* pv, /* [size_is][in] */ 473 ULONG cb, /* [in] */ 474 ULONG* pcbWritten) /* [out] */ 470 IStream* iface, 471 const void* pv, /* [size_is][in] */ 472 ULONG cb, /* [in] */ 473 ULONG* pcbWritten) /* [out] */ 475 474 { 476 475 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 481 480 482 481 TRACE("(%p, %p, %ld, %p)\n", iface, 483 484 482 pv, cb, pcbWritten); 483 485 484 /* 486 485 * If the caller is not interested in the number of bytes written, … … 489 488 if (pcbWritten == 0) 490 489 pcbWritten = &bytesWritten; 491 490 492 491 if (cb == 0) 493 492 { … … 499 498 newSize.s.LowPart = This->currentPosition.s.LowPart + cb; 500 499 } 501 500 502 501 /* 503 502 * Verify if we need to grow the stream … … 508 507 IStream_SetSize(iface, newSize); 509 508 } 510 509 511 510 /* 512 511 * Lock the buffer in position and copy the data. … … 514 513 supportBuffer = GlobalLock(This->supportHandle); 515 514 516 memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 515 memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 517 516 518 517 /* … … 530 529 */ 531 530 GlobalUnlock(This->supportHandle); 532 531 533 532 return S_OK; 534 533 } … … 541 540 * 542 541 * See the documentation of IStream for more info. 543 */ 544 HRESULT WINAPI HGLOBALStreamImpl_Seek( 545 546 LARGE_INTEGER dlibMove, /* [in] */ 547 DWORD dwOrigin, /* [in] */ 548 542 */ 543 HRESULT WINAPI HGLOBALStreamImpl_Seek( 544 IStream* iface, 545 LARGE_INTEGER dlibMove, /* [in] */ 546 DWORD dwOrigin, /* [in] */ 547 ULARGE_INTEGER* plibNewPosition) /* [out] */ 549 548 { 550 549 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 553 552 554 553 TRACE("(%p, %ld, %ld, %p)\n", iface, 555 556 557 /* 554 dlibMove.s.LowPart, dwOrigin, plibNewPosition); 555 556 /* 558 557 * The caller is allowed to pass in NULL as the new position return value. 559 558 * If it happens, we assign it to a dynamic variable to avoid special cases … … 609 608 plibNewPosition->s.LowPart += dlibMove.s.LowPart; 610 609 This->currentPosition = *plibNewPosition; 611 610 612 611 return S_OK; 613 612 } … … 622 621 * See the documentation of IStream for more info. 623 622 */ 624 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 625 626 ULARGE_INTEGER libNewSize) /* [in] */ 623 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 624 IStream* iface, 625 ULARGE_INTEGER libNewSize) /* [in] */ 627 626 { 628 627 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 635 634 if (libNewSize.s.HighPart != 0) 636 635 return STG_E_INVALIDFUNCTION; 637 636 638 637 if (This->streamSize.s.LowPart == libNewSize.s.LowPart) 639 638 return S_OK; … … 642 641 * Re allocate the HGlobal to fit the new size of the stream. 643 642 */ 644 This->supportHandle = GlobalReAlloc(This->supportHandle, 645 646 643 This->supportHandle = GlobalReAlloc(This->supportHandle, 644 libNewSize.s.LowPart, 645 0); 647 646 648 647 This->streamSize.s.LowPart = libNewSize.s.LowPart; 649 648 650 649 return S_OK; 651 650 } 652 651 653 652 /*** 654 653 * This method is part of the IStream interface. … … 658 657 * See the documentation of IStream for more info. 659 658 */ 660 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 661 662 IStream* pstm, /* [unique][in] */ 663 ULARGE_INTEGER cb, /* [in] */ 664 ULARGE_INTEGER* pcbRead, /* [out] */ 665 ULARGE_INTEGER* pcbWritten) /* [out] */ 659 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 660 IStream* iface, 661 IStream* pstm, /* [unique][in] */ 662 ULARGE_INTEGER cb, /* [in] */ 663 ULARGE_INTEGER* pcbRead, /* [out] */ 664 ULARGE_INTEGER* pcbWritten) /* [out] */ 666 665 { 667 666 HRESULT hr = S_OK; … … 671 670 ULARGE_INTEGER totalBytesWritten; 672 671 673 TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 674 672 TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 673 cb.s.LowPart, pcbRead, pcbWritten); 675 674 676 675 /* … … 694 693 else 695 694 copySize = cb.s.LowPart; 696 695 697 696 IStream_Read(iface, tmpBuffer, copySize, &bytesRead); 698 697 699 698 totalBytesRead.s.LowPart += bytesRead; 700 699 701 700 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); 702 701 … … 711 710 break; 712 711 } 713 712 714 713 if (bytesRead!=copySize) 715 714 cb.s.LowPart = 0; … … 738 737 * This method is part of the IStream interface. 739 738 * 740 * For streams supported by HGLOBALS, this function does nothing. 739 * For streams supported by HGLOBALS, this function does nothing. 741 740 * This is what the documentation tells us. 742 741 * 743 742 * See the documentation of IStream for more info. 744 */ 745 HRESULT WINAPI HGLOBALStreamImpl_Commit( 746 747 DWORD grfCommitFlags) /* [in] */ 743 */ 744 HRESULT WINAPI HGLOBALStreamImpl_Commit( 745 IStream* iface, 746 DWORD grfCommitFlags) /* [in] */ 748 747 { 749 748 return S_OK; … … 753 752 * This method is part of the IStream interface. 754 753 * 755 * For streams supported by HGLOBALS, this function does nothing. 754 * For streams supported by HGLOBALS, this function does nothing. 756 755 * This is what the documentation tells us. 757 756 * 758 757 * See the documentation of IStream for more info. 759 */ 760 HRESULT WINAPI HGLOBALStreamImpl_Revert( 761 758 */ 759 HRESULT WINAPI HGLOBALStreamImpl_Revert( 760 IStream* iface) 762 761 { 763 762 return S_OK; … … 767 766 * This method is part of the IStream interface. 768 767 * 769 * For streams supported by HGLOBALS, this function does nothing. 768 * For streams supported by HGLOBALS, this function does nothing. 770 769 * This is what the documentation tells us. 771 770 * 772 771 * See the documentation of IStream for more info. 773 */ 774 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 775 776 ULARGE_INTEGER libOffset, /* [in] */ 777 ULARGE_INTEGER cb, /* [in] */ 778 DWORD dwLockType) /* [in] */ 772 */ 773 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 774 IStream* iface, 775 ULARGE_INTEGER libOffset, /* [in] */ 776 ULARGE_INTEGER cb, /* [in] */ 777 DWORD dwLockType) /* [in] */ 779 778 { 780 779 return S_OK; … … 784 783 * This method is part of the IStream interface. 785 784 * 786 * For streams supported by HGLOBALS, this function does nothing. 785 * For streams supported by HGLOBALS, this function does nothing. 787 786 * This is what the documentation tells us. 788 787 * 789 788 * See the documentation of IStream for more info. 790 */ 791 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 792 793 ULARGE_INTEGER libOffset, /* [in] */ 794 ULARGE_INTEGER cb, /* [in] */ 795 DWORD dwLockType) /* [in] */ 789 */ 790 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 791 IStream* iface, 792 ULARGE_INTEGER libOffset, /* [in] */ 793 ULARGE_INTEGER cb, /* [in] */ 794 DWORD dwLockType) /* [in] */ 796 795 { 797 796 return S_OK; … … 805 804 * 806 805 * See the documentation of IStream for more info. 807 */ 808 HRESULT WINAPI HGLOBALStreamImpl_Stat( 809 810 811 DWORD grfStatFlag) /* [in] */ 806 */ 807 HRESULT WINAPI HGLOBALStreamImpl_Stat( 808 IStream* iface, 809 STATSTG* pstatstg, /* [out] */ 810 DWORD grfStatFlag) /* [in] */ 812 811 { 813 812 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 821 820 return S_OK; 822 821 } 823 824 HRESULT WINAPI HGLOBALStreamImpl_Clone( 825 826 IStream** ppstm) /* [out] */ 822 823 HRESULT WINAPI HGLOBALStreamImpl_Clone( 824 IStream* iface, 825 IStream** ppstm) /* [out] */ 827 826 { 828 827 FIXME("not implemented!\n"); -
trunk/src/ole32/ifs.c
r6648 r6711 1 /* $Id: ifs.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */2 1 /* 3 * 2 * basic interfaces 4 3 * 5 * Copyright 1997Marcus Meissner4 * Copyright 1997 Marcus Meissner 6 5 */ 7 6 … … 31 30 32 31 /****************************************************************************** 33 * IUnknown_AddRef[VTABLE:IUNKNOWN.1]34 */ 35 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 36 37 38 32 * IUnknown_AddRef [VTABLE:IUNKNOWN.1] 33 */ 34 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 35 ICOM_THIS(IUnknownImpl,iface); 36 TRACE("(%p)->AddRef()\n",This); 37 return ++(This->ref); 39 38 } 40 39 … … 43 42 */ 44 43 static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) { 45 46 47 48 49 50 51 44 ICOM_THIS(IUnknownImpl,iface); 45 TRACE("(%p)->Release()\n",This); 46 if (!--(This->ref)) { 47 HeapFree(GetProcessHeap(),0,This); 48 return 0; 49 } 50 return This->ref; 52 51 } 53 52 … … 56 55 */ 57 56 static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) { 58 59 60 61 62 63 64 return 0; 65 66 return OLE_E_ENUM_NOMORE; 67 } 68 69 static ICOM_VTABLE(IUnknown) uvt = 70 { 71 72 73 74 57 ICOM_THIS(IUnknownImpl,iface); 58 59 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 60 61 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) { 62 *obj = This; 63 return 0; 64 } 65 return OLE_E_ENUM_NOMORE; 66 } 67 68 static ICOM_VTABLE(IUnknown) uvt = 69 { 70 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 71 IUnknown_fnQueryInterface, 72 IUnknown_fnAddRef, 73 IUnknown_fnRelease 75 74 }; 76 75 … … 80 79 LPUNKNOWN 81 80 IUnknown_Constructor() { 82 IUnknownImpl*unk;83 84 85 ICOM_VTBL(unk)= &uvt;86 unk->ref= 1;87 81 IUnknownImpl* unk; 82 83 unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl)); 84 ICOM_VTBL(unk) = &uvt; 85 unk->ref = 1; 86 return (LPUNKNOWN)unk; 88 87 } 89 88 … … 101 100 102 101 /****************************************************************************** 103 * IMalloc16_QueryInterface[COMPOBJ.500]102 * IMalloc16_QueryInterface [COMPOBJ.500] 104 103 */ 105 104 HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) { 106 105 ICOM_THIS(IMalloc16Impl,iface); 107 106 108 109 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||110 111 112 113 114 115 return OLE_E_ENUM_NOMORE; 116 } 117 118 /****************************************************************************** 119 * IMalloc16_AddRef[COMPOBJ.501]107 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 108 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 109 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 110 ) { 111 *obj = This; 112 return 0; 113 } 114 return OLE_E_ENUM_NOMORE; 115 } 116 117 /****************************************************************************** 118 * IMalloc16_AddRef [COMPOBJ.501] 120 119 */ 121 120 ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) { 122 121 ICOM_THIS(IMalloc16Impl,iface); 123 124 125 } 126 127 /****************************************************************************** 128 * IMalloc16_Release[COMPOBJ.502]122 TRACE("(%p)->AddRef()\n",This); 123 return 1; /* cannot be freed */ 124 } 125 126 /****************************************************************************** 127 * IMalloc16_Release [COMPOBJ.502] 129 128 */ 130 129 ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) { 131 130 ICOM_THIS(IMalloc16Impl,iface); 132 133 131 TRACE("(%p)->Release()\n",This); 132 return 1; /* cannot be freed */ 134 133 } 135 134 … … 139 138 SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) { 140 139 ICOM_THIS(IMalloc16Impl,iface); 141 140 TRACE("(%p)->Alloc(%ld)\n",This,cb); 142 141 return MapLS( HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, cb ) ); 143 142 } … … 166 165 DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,SEGPTR pv) 167 166 { 168 167 ICOM_CTHIS(IMalloc16Impl,iface); 169 168 TRACE("(%p)->GetSize(%08lx)\n",This,pv); 170 169 return HeapSize( GetProcessHeap(), HEAP_WINE_SEGPTR, MapSL(pv) ); … … 176 175 INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) { 177 176 ICOM_CTHIS(IMalloc16,iface); 178 179 177 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 178 return (INT16)-1; 180 179 } 181 180 … … 185 184 LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) { 186 185 ICOM_THIS(IMalloc16Impl,iface); 187 188 186 TRACE("(%p)->HeapMinimize()\n",This); 187 return NULL; 189 188 } 190 189 … … 196 195 LPMALLOC16 197 196 IMalloc16_Constructor() { 198 IMalloc16Impl*This;199 HMODULE16 200 201 197 IMalloc16Impl* This; 198 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ"); 199 200 This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl); 202 201 if (!msegvt16) { 203 202 msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16)); … … 214 213 VTENT(HeapMinimize); 215 214 #undef VTENT 216 215 } 217 216 ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16); 218 219 217 This->ref = 1; 218 return (LPMALLOC16)SEGPTR_GET(This); 220 219 } 221 220 #endif … … 231 230 232 231 /****************************************************************************** 233 * IMalloc32_QueryInterface[VTABLE]232 * IMalloc32_QueryInterface [VTABLE] 234 233 */ 235 234 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) { 236 237 238 239 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||240 241 242 243 244 245 return OLE_E_ENUM_NOMORE; 246 } 247 248 /****************************************************************************** 249 * IMalloc32_AddRef[VTABLE]235 ICOM_THIS(IMalloc32Impl,iface); 236 237 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 238 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 239 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 240 ) { 241 *obj = This; 242 return S_OK; 243 } 244 return OLE_E_ENUM_NOMORE; 245 } 246 247 /****************************************************************************** 248 * IMalloc32_AddRef [VTABLE] 250 249 */ 251 250 static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) { 252 253 254 255 } 256 257 /****************************************************************************** 258 * IMalloc32_Release[VTABLE]251 ICOM_THIS(IMalloc32Impl,iface); 252 TRACE("(%p)->AddRef()\n",This); 253 return 1; /* cannot be freed */ 254 } 255 256 /****************************************************************************** 257 * IMalloc32_Release [VTABLE] 259 258 */ 260 259 static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) { 261 262 263 260 ICOM_THIS(IMalloc32Impl,iface); 261 TRACE("(%p)->Release()\n",This); 262 return 1; /* cannot be freed */ 264 263 } 265 264 … … 268 267 */ 269 268 static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) { 270 271 272 273 274 269 LPVOID addr; 270 ICOM_THIS(IMalloc32Impl,iface); 271 addr = HeapAlloc(GetProcessHeap(),0,cb); 272 TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr); 273 return addr; 275 274 } 276 275 … … 279 278 */ 280 279 static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) { 281 282 283 280 ICOM_THIS(IMalloc32Impl,iface); 281 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb); 282 return HeapReAlloc(GetProcessHeap(),0,pv,cb); 284 283 } 285 284 … … 288 287 */ 289 288 static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) { 290 291 292 289 ICOM_THIS(IMalloc32Impl,iface); 290 TRACE("(%p)->Free(%p)\n",This,pv); 291 HeapFree(GetProcessHeap(),0,pv); 293 292 } 294 293 … … 297 296 */ 298 297 static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) { 299 300 301 298 ICOM_CTHIS(IMalloc,iface); 299 TRACE("(%p)->GetSize(%p)\n",This,pv); 300 return HeapSize(GetProcessHeap(),0,pv); 302 301 } 303 302 … … 306 305 */ 307 306 static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) { 308 309 310 307 ICOM_CTHIS(IMalloc32Impl,iface); 308 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 309 return -1; 311 310 } 312 311 … … 315 314 */ 316 315 static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) { 317 318 319 } 320 321 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 316 ICOM_THIS(IMalloc32Impl,iface); 317 TRACE("(%p)->HeapMinimize()\n",This); 318 } 319 320 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 322 321 { 323 322 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE … … 338 337 LPMALLOC 339 338 IMalloc_Constructor() { 340 341 342 343 344 345 339 IMalloc32Impl* This; 340 341 This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl)); 342 ICOM_VTBL(This) = &VT_IMalloc32; 343 This->ref = 1; 344 return (LPMALLOC)This; 346 345 } 347 346 … … 351 350 352 351 /****************************************************************************** 353 * IsValidInterface[OLE32.78]352 * IsValidInterface [OLE32.78] 354 353 * 355 354 * RETURNS … … 357 356 */ 358 357 BOOL WINAPI IsValidInterface( 359 LPUNKNOWN punk/* [in] interface to be tested */358 LPUNKNOWN punk /* [in] interface to be tested */ 360 359 ) { 361 362 IsBadReadPtr(punk,4)||363 IsBadReadPtr(ICOM_VTBL(punk),4)||360 return !( 361 IsBadReadPtr(punk,4) || 362 IsBadReadPtr(ICOM_VTBL(punk),4) || 364 363 #ifdef __WIN32OS2__ 365 IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)||366 364 IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9) || 365 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface) 367 366 #else 368 IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9)||369 367 IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) || 368 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface) 370 369 #endif 371 372 } 370 ); 371 } -
trunk/src/ole32/initole32.cpp
r6648 r6711 1 /* $Id: initole32.cpp,v 1.3 2001-09-05 13:17:10 bird Exp $1 /* 2 2 * DLL entry point 3 3 * … … 52 52 case DLL_THREAD_ATTACH: 53 53 case DLL_THREAD_DETACH: 54 54 return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 55 55 56 56 case DLL_PROCESS_DETACH: 57 57 OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 58 58 return TRUE; 59 59 } 60 60 return FALSE; … … 82 82 case 0 : 83 83 { 84 85 if(dllHandle == 0) 86 84 dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab); 85 if(dllHandle == 0) 86 return 0UL; 87 87 88 88 break; … … 90 90 case 1 : 91 91 if(dllHandle) { 92 92 UnregisterLxDll(dllHandle); 93 93 } 94 94 break; -
trunk/src/ole32/initterm.cpp
r6648 r6711 1 /* $Id: initterm.cpp,v 1.11 2001-09-05 13:17:10 bird Exp $ 2 * 1 /* 3 2 * DLL entry point 4 3 * -
trunk/src/ole32/itemmoniker.c
r6648 r6711 1 /* $Id: itemmoniker.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */2 1 /*************************************************************************************** 3 * 2 * ItemMonikers implementation 4 3 * 5 4 * Copyright 1999 Noomen Hamza … … 26 25 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 27 26 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 27 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 28 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 30 29 */ … … 36 35 37 36 LPOLESTR itemDelimiter; /* Delimiter string */ 38 37 39 38 } ItemMonikerImpl; 40 39 … … 141 140 /* Perform a sanity check on the parameters.*/ 142 141 if ( (This==0) || (ppvObject==0) ) 143 144 142 return E_INVALIDARG; 143 145 144 /* Initialize the return parameter */ 146 145 *ppvObject = 0; … … 153 152 ) 154 153 *ppvObject = iface; 155 154 156 155 else if (IsEqualIID(&IID_IROTData, riid)) 157 156 *ppvObject = (IROTData*)&(This->lpvtbl2); … … 160 159 if ((*ppvObject)==0) 161 160 return E_NOINTERFACE; 162 161 163 162 /* Query Interface always increases the reference count by one when it is successful */ 164 163 ItemMonikerImpl_AddRef(iface); … … 209 208 if (pClassID==NULL) 210 209 return E_POINTER; 211 210 212 211 *pClassID = CLSID_ItemMoniker; 213 212 214 213 return S_OK; 215 214 } … … 343 342 344 343 /* for more details see ItemMonikerImpl_Save coments */ 345 344 346 345 pcbSize->s.LowPart = sizeof(DWORD) + /* DWORD which contains delimiter length */ 347 346 delimiterLength + /* item delimiter string */ … … 363 362 int sizeStr1=lstrlenW(lpszItem), sizeStr2; 364 363 static const OLECHAR emptystr[1]; 365 LPCOLESTR 364 LPCOLESTR delim; 366 365 367 366 TRACE("(%p,%p)\n",This,lpszItem); … … 374 373 This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1)); 375 374 if (!This->itemName) 376 375 return E_OUTOFMEMORY; 377 376 strcpyW(This->itemName,lpszItem); 378 377 379 378 if (!lpszDelim) 380 379 FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n"); 381 380 382 381 delim = lpszDelim ? lpszDelim : emptystr; … … 385 384 This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); 386 385 if (!This->itemDelimiter) { 387 388 386 HeapFree(GetProcessHeap(),0,This->itemName); 387 return E_OUTOFMEMORY; 389 388 } 390 389 strcpyW(This->itemDelimiter,delim); … … 420 419 { 421 420 ICOM_THIS(ItemMonikerImpl,iface); 422 421 423 422 HRESULT res; 424 423 IID refid=IID_IOleItemContainer; … … 467 466 if(pmkToLeft==NULL) 468 467 return E_INVALIDARG; 469 468 470 469 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); 471 470 … … 497 496 498 497 *ppmkReduced=iface; 499 498 500 499 return MK_S_REDUCED_TO_SELF; 501 500 } … … 517 516 518 517 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 519 518 return E_POINTER; 520 519 521 520 *ppmkComposite=0; 522 521 523 522 IMoniker_IsSystemMoniker(pmkRight,&mkSys); 524 523 … … 530 529 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */ 531 530 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */ 532 531 533 532 if(mkSys==MKSYS_GENERICCOMPOSITE){ 534 533 … … 548 547 tempMkComposite=iface; 549 548 IMoniker_AddRef(iface); 550 549 551 550 while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){ 552 551 … … 605 604 if (pmkOtherMoniker==NULL) 606 605 return S_FALSE; 607 606 608 607 /* This method returns S_OK if both monikers are item monikers and their display names are */ 609 608 /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */ … … 620 619 IMoniker_GetDisplayName(iface,bind,NULL,&dispName1); 621 620 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2); 622 621 623 622 if (lstrcmpW(dispName1,dispName2)!=0) 624 623 return S_FALSE; 625 624 626 625 return S_OK; 627 626 } … … 640 639 if (pdwHash==NULL) 641 640 return E_POINTER; 642 641 643 642 val = This->itemName; 644 643 len = lstrlenW(val); … … 650 649 } else { 651 650 /* only sample some characters */ 652 653 651 skip = len / 8; 652 for (i = len ; i > 0; i -= skip, off += skip) { 654 653 h = (h * 39) + val[off]; 655 654 } 656 655 } 657 656 … … 699 698 /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/ 700 699 /* passing the string contained within this moniker. */ 701 700 702 701 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); 703 702 … … 780 779 781 780 *ppmkPrefix=iface; 782 781 783 782 IMoniker_AddRef(iface); 784 783 785 784 return MK_S_US; 786 785 } … … 802 801 803 802 *ppmkRelPath=0; 804 803 805 804 return MK_E_NOTBINDABLE; 806 805 } … … 832 831 strcpyW(*ppszDisplayName,This->itemDelimiter); 833 832 strcatW(*ppszDisplayName,This->itemName); 834 833 835 834 return S_OK; 836 835 } … … 886 885 if (!pwdMksys) 887 886 return E_POINTER; 888 887 889 888 (*pwdMksys)=MKSYS_ITEMMONIKER; 890 889 … … 923 922 { 924 923 ICOM_THIS_From_IROTData(IMoniker, iface); 925 924 926 925 TRACE("(%p)\n",iface); 927 926 … … 942 941 943 942 /****************************************************************************** 944 * CreateItemMoniker16 943 * CreateItemMoniker16 [OLE2.28] 945 944 ******************************************************************************/ 946 945 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR lpszItem,LPMONIKER* ppmk) … … 953 952 954 953 /****************************************************************************** 955 * CreateItemMoniker 954 * CreateItemMoniker [OLE.55] 956 955 ******************************************************************************/ 957 956 HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk) -
trunk/src/ole32/memlockbytes.c
r6648 r6711 1 /* $Id: memlockbytes.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */2 1 /****************************************************************************** 3 2 * … … 26 25 { 27 26 /* 28 * Needs to be the first item in the stuct 27 * Needs to be the first item in the stuct 29 28 * since we want to cast this in an ILockBytes pointer 30 29 */ … … 189 188 HGLOBALLockBytesImpl* newLockBytes; 190 189 newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl)); 191 190 192 191 if (newLockBytes!=0) 193 192 { … … 197 196 ICOM_VTBL(newLockBytes) = &HGLOBALLockBytesImpl_Vtbl; 198 197 newLockBytes->ref = 0; 199 198 200 199 /* 201 200 * Initialize the support. … … 399 398 * The function returns S_OK if the specified number of bytes were read 400 399 * or the end of the array was reached. 401 * It returns STG_E_READFAULT if the number of bytes to read does not equal 400 * It returns STG_E_READFAULT if the number of bytes to read does not equal 402 401 * the number of bytes actually read. 403 402 */ … … 504 503 if (libNewSize.s.HighPart != 0) 505 504 return STG_E_INVALIDFUNCTION; 506 505 507 506 if (This->byteArraySize.s.LowPart == libNewSize.s.LowPart) 508 507 return S_OK; … … 519 518 520 519 This->byteArraySize.s.LowPart = libNewSize.s.LowPart; 521 520 522 521 return S_OK; 523 522 } -
trunk/src/ole32/moniker.c
r6648 r6711 1 /* $Id: moniker.c,v 1.3 2001-09-05 13:17:10 bird Exp $ */2 1 /* 3 * 2 * Monikers 4 3 * 5 * Copyright 1998Marcus Meissner4 * Copyright 1998 Marcus Meissner 6 5 * Copyright 1999 Noomen Hamza 7 6 */ … … 23 22 #include "compobj_private.h" 24 23 24 #ifdef __WIN32OS2__ 25 #undef FIXME 26 #undef TRACE 27 #ifdef DEBUG 28 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 29 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 30 #else 31 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 32 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 33 #endif 34 #endif 35 25 36 DEFAULT_DEBUG_CHANNEL(ole); 26 37 … … 47 58 DWORD runObjTabLastIndx; /* first free index element in the table. */ 48 59 DWORD runObjTabRegister; /* registration key of the next registered object */ 49 60 50 61 } RunningObjectTableImpl; 51 62 … … 137 148 { 138 149 TRACE("()\n"); 139 150 140 151 if (runningObjectTableInstance==NULL) 141 152 return E_INVALIDARG; … … 170 181 if (( This->runObjTab[i].regTypeObj & ROTFLAGS_REGISTRATIONKEEPSALIVE) != 0) 171 182 IUnknown_Release(This->runObjTab[i].pObj); 172 183 173 184 IMoniker_Release(This->runObjTab[i].pmkObj); 174 185 } … … 230 241 if (runningObjectTableInstance==NULL) 231 242 return E_POINTER; 232 243 233 244 RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance); 234 245 … … 271 282 This->runObjTab[This->runObjTabLastIndx].identRegObj = This->runObjTabRegister; 272 283 CoFileTimeNow(&(This->runObjTab[This->runObjTabLastIndx].lastModifObj)); 273 284 274 285 /* gives a registration identifier to the registered object*/ 275 286 (*pdwRegister)= This->runObjTabRegister; … … 278 289 279 290 FIXME("runObjTabRegister: %ld is out of data limite \n",This->runObjTabRegister); 280 291 return E_FAIL; 281 292 } 282 293 This->runObjTabRegister++; 283 294 This->runObjTabLastIndx++; 284 295 285 296 if (This->runObjTabLastIndx == This->runObjTabSize){ /* table is full ! so it must be resized */ 286 297 … … 296 307 297 308 IMoniker_AddRef(pmkObjectName); 298 309 299 310 return res; 300 311 } … … 322 333 323 334 IMoniker_Release(This->runObjTab[index].pmkObj); 324 335 325 336 /* remove the object from the table */ 326 337 for(j=index; j<This->runObjTabLastIndx-1; j++) 327 338 This->runObjTab[j]= This->runObjTab[j+1]; 328 339 329 340 This->runObjTabLastIndx--; 330 341 … … 337 348 HRESULT WINAPI RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, 338 349 IMoniker *pmkObjectName) /* Pointer to the moniker of the object whose status is desired */ 339 { 350 { 340 351 ICOM_THIS(RunningObjectTableImpl,iface); 341 352 … … 359 370 if (ppunkObject==NULL) 360 371 return E_POINTER; 361 372 362 373 *ppunkObject=0; 363 374 … … 394 405 return S_OK; 395 406 } 396 407 397 408 /*********************************************************************** 398 409 * RunningObjectTable_GetTimeOfLastChange … … 448 459 /* search object identified by a register identifier */ 449 460 for(i=0;((i<This->runObjTabLastIndx)&&(This->runObjTab[i].identRegObj!=identReg));i++); 450 461 451 462 if (i==This->runObjTabLastIndx) return S_FALSE; 452 463 … … 457 468 458 469 /****************************************************************************** 459 * GetRunningObjectTable16[OLE2.30]470 * GetRunningObjectTable16 [OLE2.30] 460 471 */ 461 472 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot) 462 473 { 463 474 FIXME("(%ld,%p),stub!\n",reserved,pprot); 464 475 return E_NOTIMPL; 465 476 } … … 491 502 HRESULT WINAPI OleRun(LPUNKNOWN pUnknown) 492 503 { 493 IRunnableObject 504 IRunnableObject *runable; 494 505 ICOM_THIS(IRunnableObject,pUnknown); 495 LRESULT 506 LRESULT ret; 496 507 497 508 #ifdef __WIN32OS2__ … … 502 513 503 514 ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,(LPVOID*)&runable); 504 if (ret) 505 515 if (ret) 516 return 0; /* Appears to return no error. */ 506 517 ret = IRunnableObject_Run(runable,NULL); 507 518 IRunnableObject_Release(runable); … … 513 524 */ 514 525 HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName, 515 526 LPDWORD pchEaten, LPMONIKER *ppmk) 516 527 { 517 528 FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk); 518 529 if (!(IsValidInterface((LPUNKNOWN) pbc))) 519 530 return E_INVALIDARG; 520 531 521 532 return MK_E_SYNTAX; -
trunk/src/ole32/ole2.c
r6648 r6711 1 /* $Id: ole2.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 * 4 * 5 * Copyright 1995Martin von Loewis2 * OLE2 library 3 * 4 * Copyright 1995 Martin von Loewis 6 5 * Copyright 1999 Francis Beaudet 7 * Copyright 1999 Noel Borthwick 6 * Copyright 1999 Noel Borthwick 8 7 */ 9 8 … … 33 32 34 33 /****************************************************************************** 35 * These are static/global variables and internal data structures that the 34 * These are static/global variables and internal data structures that the 36 35 * OLE module uses to maintain it's state. 37 36 */ … … 95 94 96 95 /****************************************************************************** 97 * These are the prototypes of miscelaneous utility methods 96 * These are the prototypes of miscelaneous utility methods 98 97 */ 99 98 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue); … … 124 123 static void OLEDD_UnInitialize(); 125 124 static void OLEDD_InsertDropTarget( 126 125 DropTargetNode* nodeToAdd); 127 126 static DropTargetNode* OLEDD_ExtractDropTarget( 128 127 HWND hwndOfTarget); … … 130 129 HWND hwndOfTarget); 131 130 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 132 HWND hwnd, 133 134 WPARAM wParam, 135 131 HWND hwnd, 132 UINT uMsg, 133 WPARAM wParam, 134 LPARAM lParam); 136 135 static void OLEDD_TrackMouseMove( 137 136 TrackerWindowInfo* trackerInfo, 138 139 137 POINT mousePos, 138 DWORD keyState); 140 139 static void OLEDD_TrackStateChange( 141 140 TrackerWindowInfo* trackerInfo, 142 143 141 POINT mousePos, 142 DWORD keyState); 144 143 static DWORD OLEDD_GetButtonState(); 145 144 146 145 147 146 /****************************************************************************** 148 * OleBuildVersion[OLE2.1]147 * OleBuildVersion [OLE2.1] 149 148 */ 150 149 DWORD WINAPI OleBuildVersion(void) … … 169 168 170 169 /* 171 * If the CoInitializeEx call failed, the OLE libraries can't be 170 * If the CoInitializeEx call failed, the OLE libraries can't be 172 171 * initialized. 173 172 */ 174 173 if (FAILED(hr)) 175 return hr; 174 return hr; 176 175 177 176 /* … … 185 184 if (OLE_moduleLockCount==0) 186 185 { 187 /* 186 /* 188 187 * Initialize the libraries. 189 188 */ … … 209 208 * Then, we increase the lock count on the OLE module. 210 209 */ 211 OLE_moduleLockCount++; 210 OLE_moduleLockCount++; 212 211 213 212 return hr; … … 215 214 216 215 /****************************************************************************** 217 * CoGetCurrentProcess[COMPOBJ.34] [OLE2.2][OLE32.108]216 * CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108] 218 217 * 219 218 * NOTES … … 222 221 DWORD WINAPI CoGetCurrentProcess(void) 223 222 { 224 223 return GetCurrentProcessId(); 225 224 } 226 225 227 226 /****************************************************************************** 228 * OleUninitialize[OLE2.3] [OLE32.131]227 * OleUninitialize [OLE2.3] [OLE32.131] 229 228 */ 230 229 void WINAPI OleUninitialize(void) … … 256 255 */ 257 256 OLEDD_UnInitialize(); 258 257 259 258 /* 260 259 * OLE shared menu … … 262 261 OLEMenu_UnInitialize(); 263 262 } 264 263 265 264 /* 266 265 * Then, uninitialize the COM libraries. … … 272 271 //imessagefilter.cpp 273 272 /****************************************************************************** 274 * CoRegisterMessageFilter[OLE32.38]273 * CoRegisterMessageFilter [OLE32.38] 275 274 */ 276 275 HRESULT WINAPI CoRegisterMessageFilter( 277 LPMESSAGEFILTER lpMessageFilter, 278 LPMESSAGEFILTER *lplpMessageFilter 276 LPMESSAGEFILTER lpMessageFilter, /* [in] Pointer to interface */ 277 LPMESSAGEFILTER *lplpMessageFilter /* [out] Indirect pointer to prior instance if non-NULL */ 279 278 ) { 280 279 FIXME("stub\n"); 281 280 if (lplpMessageFilter) { 282 281 *lplpMessageFilter = NULL; 283 282 } 284 283 return S_OK; … … 287 286 288 287 /****************************************************************************** 289 * OleInitializeWOW[OLE32.109]288 * OleInitializeWOW [OLE32.109] 290 289 */ 291 290 HRESULT WINAPI OleInitializeWOW(DWORD x) { … … 298 297 */ 299 298 HRESULT WINAPI RegisterDragDrop16( 300 301 299 HWND16 hwnd, 300 LPDROPTARGET pDropTarget 302 301 ) { 303 304 302 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget); 303 return S_OK; 305 304 } 306 305 … … 309 308 */ 310 309 HRESULT WINAPI RegisterDragDrop( 311 312 LPDROPTARGET pDropTarget) 310 HWND hwnd, 311 LPDROPTARGET pDropTarget) 313 312 { 314 313 DropTargetNode* dropTargetInfo; … … 342 341 dropTargetInfo->dropTarget = pDropTarget; 343 342 IDropTarget_AddRef(dropTargetInfo->dropTarget); 344 343 345 344 OLEDD_InsertDropTarget(dropTargetInfo); 346 345 347 346 return S_OK; 348 347 } 349 348 … … 352 351 */ 353 352 HRESULT WINAPI RevokeDragDrop16( 354 353 HWND16 hwnd 355 354 ) { 356 357 355 FIXME("(0x%04x),stub!\n",hwnd); 356 return S_OK; 358 357 } 359 358 … … 362 361 */ 363 362 HRESULT WINAPI RevokeDragDrop( 364 363 HWND hwnd) 365 364 { 366 365 DropTargetNode* dropTargetInfo; … … 384 383 */ 385 384 IDropTarget_Release(dropTargetInfo->dropTarget); 386 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 387 388 385 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 386 387 return S_OK; 389 388 } 390 389 … … 397 396 * way they are registered. 398 397 */ 399 HRESULT WINAPI OleRegGetUserType( 400 REFCLSID clsid, 401 402 398 HRESULT WINAPI OleRegGetUserType( 399 REFCLSID clsid, 400 DWORD dwFormOfType, 401 LPOLESTR* pszUserType) 403 402 { 404 403 char keyName[60]; … … 428 427 */ 429 428 hres = RegOpenKeyA(HKEY_CLASSES_ROOT, 430 431 429 keyName, 430 &clsidKey); 432 431 433 432 if (hres != ERROR_SUCCESS) … … 440 439 441 440 hres = RegQueryValueExA(clsidKey, 442 443 444 445 446 441 "", 442 NULL, 443 &dwKeyType, 444 NULL, 445 &cbData); 447 446 448 447 if (hres!=ERROR_SUCCESS) … … 474 473 475 474 hres = RegQueryValueExA(clsidKey, 476 477 478 479 480 475 "", 476 NULL, 477 &dwKeyType, 478 buffer, 479 &cbData); 481 480 482 481 RegCloseKey(clsidKey); 483 482 484 483 485 484 if (hres!=ERROR_SUCCESS) 486 485 { … … 528 527 529 528 hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS, 530 531 532 533 534 535 536 537 529 "TrackerWindow", 530 WS_POPUP, 531 CW_USEDEFAULT, CW_USEDEFAULT, 532 CW_USEDEFAULT, CW_USEDEFAULT, 533 0, 534 0, 535 0, 536 (LPVOID)&trackerInfo); 538 537 539 538 if (hwndTrackWindow!=0) … … 549 548 while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) ) 550 549 { 551 if ( (msg.message >= WM_KEYFIRST) && 552 550 if ( (msg.message >= WM_KEYFIRST) && 551 (msg.message <= WM_KEYLAST) ) 553 552 { 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 */ 569 570 571 553 /* 554 * When keyboard messages are sent to windows on this thread, we 555 * want to ignore notify the drop source that the state changed. 556 * in the case of the Escape key, we also notify the drop source 557 * we give it a special meaning. 558 */ 559 if ( (msg.message==WM_KEYDOWN) && 560 (msg.wParam==VK_ESCAPE) ) 561 { 562 trackerInfo.escPressed = TRUE; 563 } 564 565 /* 566 * Notify the drop source. 567 */ 568 OLEDD_TrackStateChange(&trackerInfo, 569 msg.pt, 570 OLEDD_GetButtonState()); 572 571 } 573 572 else 574 573 { 575 576 577 578 574 /* 575 * Dispatch the messages only when it's not a keyboard message. 576 */ 577 DispatchMessageA(&msg); 579 578 } 580 579 } … … 634 633 */ 635 634 result = RegOpenKeyA(HKEY_CLASSES_ROOT, 636 637 635 keyName, 636 &clsidKey); 638 637 639 638 if (result != ERROR_SUCCESS) … … 644 643 */ 645 644 result = RegOpenKeyA(clsidKey, 646 647 648 649 645 "MiscStatus", 646 &miscStatusKey); 647 648 650 649 if (result != ERROR_SUCCESS) 651 650 { … … 665 664 666 665 result = RegOpenKeyA(miscStatusKey, 667 668 669 666 keyName, 667 &aspectKey); 668 670 669 if (result == ERROR_SUCCESS) 671 670 { … … 687 686 */ 688 687 HRESULT WINAPI OleSetContainedObject( 689 LPUNKNOWN pUnknown, 688 LPUNKNOWN pUnknown, 690 689 BOOL fContained) 691 690 { … … 696 695 697 696 hres = IUnknown_QueryInterface(pUnknown, 698 699 697 &IID_IRunnableObject, 698 (void**)&runnable); 700 699 701 700 if (SUCCEEDED(hres)) … … 715 714 */ 716 715 HRESULT WINAPI OleLoad( 717 LPSTORAGE pStg, 718 REFIID riid, 719 LPOLECLIENTSITE pClientSite, 716 LPSTORAGE pStg, 717 REFIID riid, 718 LPOLECLIENTSITE pClientSite, 720 719 LPVOID* ppvObj) 721 720 { … … 726 725 727 726 TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj); 728 727 729 728 /* 730 729 * TODO, Conversion ... OleDoAutoConvert … … 740 739 */ 741 740 hres = CoCreateInstance(&storageInfo.clsid, 742 743 744 745 741 NULL, 742 CLSCTX_INPROC_HANDLER, 743 &IID_IOleObject, 744 (void**)&oleObject); 746 745 747 746 /* … … 752 751 { 753 752 hres = OleCreateDefaultHandler(&storageInfo.clsid, 754 755 756 753 NULL, 754 &IID_IOleObject, 755 (void**)&oleObject); 757 756 } 758 757 … … 772 771 */ 773 772 hres = IOleObject_QueryInterface(oleObject, 774 775 776 777 if (SUCCEEDED(hres)) 773 &IID_IPersistStorage, 774 (void**)&persistStorage); 775 776 if (SUCCEEDED(hres)) 778 777 { 779 778 IPersistStorage_Load(persistStorage, pStg); … … 828 827 { 829 828 IStorage_Commit(pStg, 830 831 } 832 829 STGC_DEFAULT); 830 } 831 833 832 return hres; 834 833 } … … 838 837 * OleLockRunning [OLE32.114] 839 838 */ 840 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 839 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 841 840 { 842 841 IRunnableObject* runnable = NULL; … … 846 845 847 846 hres = IUnknown_QueryInterface(pUnknown, 848 849 847 &IID_IRunnableObject, 848 (void**)&runnable); 850 849 851 850 if (SUCCEEDED(hres)) … … 903 902 pHookItem->tid = tid; 904 903 pHookItem->hHeap = GetProcessHeap(); 905 904 906 905 /* Install a thread scope message hook for WH_GETMESSAGE */ 907 906 pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc, … … 919 918 pHookItem->next = hook_list; 920 919 hook_list = pHookItem; 921 920 922 921 return TRUE; 923 922 924 923 CLEANUP: 925 924 /* Unhook any hooks */ … … 930 929 /* Release the hook table entry */ 931 930 HeapFree(pHookItem->hHeap, 0, pHookItem ); 932 931 933 932 return FALSE; 934 933 } … … 995 994 return pHookItem; 996 995 } 997 996 998 997 return NULL; 999 998 } … … 1016 1015 { 1017 1016 HMENU hsubmenu; 1018 1017 1019 1018 /* Is the current item a submenu? */ 1020 1019 if ( (hsubmenu = GetSubMenu(hMainMenu, i)) ) … … 1063 1062 if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu, &nPos ) ) 1064 1063 return FALSE; 1065 1064 1066 1065 /* The group widths array has counts for the number of elements 1067 1066 * in the groups File, Edit, Container, Object, Window, Help. … … 1096 1095 OleMenuHookItem *pHookItem = NULL; 1097 1096 WORD fuFlags; 1098 1097 1099 1098 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1100 1099 … … 1102 1101 if ( HC_ACTION != code ) 1103 1102 goto NEXTHOOK; 1104 1103 1105 1104 /* Retrieve the current message being dispatched from lParam */ 1106 1105 pMsg = (LPCWPSTRUCT)lParam; … … 1132 1131 goto NEXTHOOK; 1133 1132 } 1134 1133 1135 1134 case WM_INITMENUPOPUP: 1136 1135 { … … 1139 1138 break; 1140 1139 } 1141 1140 1142 1141 case WM_MENUSELECT: 1143 1142 { … … 1152 1151 break; 1153 1152 } 1154 1153 1155 1154 case WM_DRAWITEM: 1156 1155 { … … 1172 1171 pMsg->message, pMsg->wParam, pMsg->lParam ); 1173 1172 } 1174 1173 1175 1174 NEXTHOOK: 1176 1175 if ( pOleMenuDescriptor ) 1177 1176 GlobalUnlock( hOleMenu ); 1178 1177 1179 1178 /* Lookup the hook item for the current thread */ 1180 1179 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1184 1183 return 0; 1185 1184 } 1186 1185 1187 1186 /* Pass on the message to the next hooker */ 1188 1187 return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam ); … … 1201 1200 OleMenuHookItem *pHookItem = NULL; 1202 1201 WORD wCode; 1203 1202 1204 1203 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1205 1204 … … 1207 1206 if ( HC_ACTION != code ) 1208 1207 goto NEXTHOOK; 1209 1208 1210 1209 /* Retrieve the current message being dispatched from lParam */ 1211 1210 pMsg = (LPMSG)lParam; … … 1246 1245 pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject; 1247 1246 } 1248 1247 1249 1248 NEXTHOOK: 1250 1249 if ( pOleMenuDescriptor ) 1251 1250 GlobalUnlock( hOleMenu ); 1252 1251 1253 1252 /* Lookup the hook item for the current thread */ 1254 1253 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1258 1257 return FALSE; 1259 1258 } 1260 1259 1261 1260 /* Pass on the message to the next hooker */ 1262 1261 return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam ); … … 1296 1295 for ( i = 0; i < 6; i++ ) 1297 1296 pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i]; 1298 1297 1299 1298 pOleMenuDescriptor->hmenuCombined = hmenuCombined; 1300 1299 pOleMenuDescriptor->bIsServerItem = FALSE; 1301 1300 GlobalUnlock( hOleMenu ); 1302 1301 1303 1302 return hOleMenu; 1304 1303 } … … 1313 1312 if ( hmenuDescriptor ) 1314 1313 GlobalFree( hmenuDescriptor ); 1315 1314 return S_OK; 1316 1315 } 1317 1316 … … 1322 1321 * OLE should install context sensitive help F1 filtering for the app when 1323 1322 * these are non null. 1324 * 1323 * 1325 1324 * PARAMS: 1326 1325 * hOleMenu Handle to composite menu descriptor … … 1350 1349 { 1351 1350 FIXME("(%x, %x, %x, %p, %p), Context sensitive help filtering not implemented!\n", 1352 1353 1354 1355 1356 1351 (unsigned int)hOleMenu, 1352 hwndFrame, 1353 hwndActiveObject, 1354 lpFrame, 1355 lpActiveObject); 1357 1356 } 1358 1357 … … 1370 1369 if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) 1371 1370 return E_FAIL; 1372 1371 1373 1372 /* Get the menu descriptor */ 1374 1373 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); … … 1382 1381 GlobalUnlock( hOleMenu ); 1383 1382 pOleMenuDescriptor = NULL; 1384 1383 1385 1384 /* Add a menu descriptor windows property to the frame window */ 1386 1385 SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu ); … … 1395 1394 if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) ) 1396 1395 return E_FAIL; 1397 1396 1398 1397 /* Remove the menu descriptor property from the frame window */ 1399 1398 RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" ); 1400 1399 } 1401 1400 1402 1401 return S_OK; 1403 1402 } … … 1420 1419 #endif 1421 1420 { 1422 1423 1421 WARN_(accel)("invalid accel handle=%04x\n", hAccel); 1422 return FALSE; 1424 1423 } 1425 1424 if((lpMsg->message != WM_KEYDOWN && 1426 1427 1428 1429 1425 lpMsg->message != WM_KEYUP && 1426 lpMsg->message != WM_SYSKEYDOWN && 1427 lpMsg->message != WM_SYSKEYUP && 1428 lpMsg->message != WM_CHAR)) return FALSE; 1430 1429 1431 1430 TRACE_(accel)("hAccel=%04x, cAccelEntries=%d," 1432 1433 1434 1431 "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n", 1432 hAccel, cAccelEntries, 1433 lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); 1435 1434 for(i = 0; i < cAccelEntries; i++) 1436 1435 { 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 {/* ^^ ALT pressed */1467 1468 1469 1470 1471 1472 1473 } 1436 if(lpAccelTbl[i].key != lpMsg->wParam) 1437 continue; 1438 1439 if(lpMsg->message == WM_CHAR) 1440 { 1441 if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY)) 1442 { 1443 TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff); 1444 goto found; 1445 } 1446 } 1447 else 1448 { 1449 if(lpAccelTbl[i].fVirt & FVIRTKEY) 1450 { 1451 INT mask = 0; 1452 TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n", 1453 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff); 1454 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; 1455 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; 1456 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT; 1457 if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found; 1458 TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n"); 1459 } 1460 else 1461 { 1462 if(!(lpMsg->lParam & 0x01000000)) /* no special_key */ 1463 { 1464 if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000)) 1465 { /* ^^ ALT pressed */ 1466 TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff); 1467 goto found; 1468 } 1469 } 1470 } 1471 } 1472 } 1474 1473 1475 1474 WARN_(accel)("couldn't translate accelerator key\n"); … … 1491 1490 case TYMED_HGLOBAL: 1492 1491 { 1493 if ( (pmedium->pUnkForRelease==0) && 1494 1495 1492 if ( (pmedium->pUnkForRelease==0) && 1493 (pmedium->u.hGlobal!=0) ) 1494 GlobalFree(pmedium->u.hGlobal); 1496 1495 1497 1496 pmedium->u.hGlobal = 0; … … 1502 1501 if (pmedium->u.lpszFileName!=0) 1503 1502 { 1504 1505 1506 1507 1508 1509 1503 if (pmedium->pUnkForRelease==0) 1504 { 1505 DeleteFileW(pmedium->u.lpszFileName); 1506 } 1507 1508 CoTaskMemFree(pmedium->u.lpszFileName); 1510 1509 } 1511 1510 … … 1517 1516 if (pmedium->u.pstm!=0) 1518 1517 { 1519 1518 IStream_Release(pmedium->u.pstm); 1520 1519 } 1521 1520 … … 1527 1526 if (pmedium->u.pstg!=0) 1528 1527 { 1529 1528 IStorage_Release(pmedium->u.pstg); 1530 1529 } 1531 1530 … … 1535 1534 case TYMED_GDI: 1536 1535 { 1537 if ( (pmedium->pUnkForRelease==0) && 1538 1539 1536 if ( (pmedium->pUnkForRelease==0) && 1537 (pmedium->u.hGlobal!=0) ) 1538 DeleteObject(pmedium->u.hGlobal); 1540 1539 1541 1540 pmedium->u.hGlobal = 0; … … 1544 1543 case TYMED_MFPICT: 1545 1544 { 1546 if ( (pmedium->pUnkForRelease==0) && 1547 1545 if ( (pmedium->pUnkForRelease==0) && 1546 (pmedium->u.hMetaFilePict!=0) ) 1548 1547 { 1549 1550 1551 1552 1548 LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict); 1549 DeleteMetaFile(pMP->hMF); 1550 GlobalUnlock(pmedium->u.hMetaFilePict); 1551 GlobalFree(pmedium->u.hMetaFilePict); 1553 1552 } 1554 1553 … … 1558 1557 case TYMED_ENHMF: 1559 1558 { 1560 if ( (pmedium->pUnkForRelease==0) && 1561 1559 if ( (pmedium->pUnkForRelease==0) && 1560 (pmedium->u.hEnhMetaFile!=0) ) 1562 1561 { 1563 1562 DeleteEnhMetaFile(pmedium->u.hEnhMetaFile); 1564 1563 } 1565 1564 … … 1599 1598 wndClass.hbrBackground = 0; 1600 1599 wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS; 1601 1600 1602 1601 RegisterClassA (&wndClass); 1603 1602 } … … 1665 1664 /* 1666 1665 * If we get here, we have found a spot for our item. The parentNodeLink 1667 * pointer points to the pointer that we have to modify. 1666 * pointer points to the pointer that we have to modify. 1668 1667 * The curNode should be NULL. We just have to establish the link and Voila! 1669 1668 */ … … 1712 1711 { 1713 1712 /* 1714 * The item was found in the list. Detach it from it's parent and 1713 * The item was found in the list. Detach it from it's parent and 1715 1714 * re-insert it's kids in the tree. 1716 1715 */ … … 1728 1727 if (curNode->nextDropTarget!=NULL) 1729 1728 { 1730 1729 OLEDD_InsertDropTarget(curNode->nextDropTarget); 1731 1730 } 1732 1731 … … 1802 1801 */ 1803 1802 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 1804 HWND hwnd, 1805 1806 WPARAM wParam, 1807 1803 HWND hwnd, 1804 UINT uMsg, 1805 WPARAM wParam, 1806 LPARAM lParam) 1808 1807 { 1809 1808 switch (uMsg) … … 1813 1812 LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam; 1814 1813 1815 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1816 1817 1814 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1815 1816 1818 1817 break; 1819 1818 } … … 1910 1909 * DragOver notification 1911 1910 */ 1912 if ( (trackerInfo->curDragTarget != 0) && 1911 if ( (trackerInfo->curDragTarget != 0) && 1913 1912 (trackerInfo->curDragTargetHWND==hwndNewTarget) ) 1914 1913 { 1915 1914 POINTL mousePosParam; 1916 1915 1917 1916 /* 1918 1917 * The documentation tells me that the coordinate should be in the target … … 1922 1921 mousePosParam.x = mousePos.x; 1923 1922 mousePosParam.y = mousePos.y; 1924 1923 1925 1924 IDropTarget_DragOver(trackerInfo->curDragTarget, 1926 1927 1928 1925 keyState, 1926 mousePosParam, 1927 trackerInfo->pdwEffect); 1929 1928 } 1930 1929 else 1931 1930 { 1932 1931 DropTargetNode* newDropTargetNode = 0; 1933 1932 1934 1933 /* 1935 1934 * If we changed window, we have to notify our old target and check for … … 1940 1939 IDropTarget_DragLeave(trackerInfo->curDragTarget); 1941 1940 } 1942 1941 1943 1942 /* 1944 1943 * Make sure we're hovering over a window. … … 1951 1950 HWND nexttar = hwndNewTarget; 1952 1951 do { 1953 1952 newDropTargetNode = OLEDD_FindDropTarget(nexttar); 1954 1953 } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0); 1955 1954 if(nexttar) hwndNewTarget = nexttar; … … 1957 1956 trackerInfo->curDragTargetHWND = hwndNewTarget; 1958 1957 trackerInfo->curDragTarget = newDropTargetNode ? newDropTargetNode->dropTarget : 0; 1959 1958 1960 1959 /* 1961 1960 * If there is, notify it that we just dragged-in … … 1963 1962 if (trackerInfo->curDragTarget!=0) 1964 1963 { 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1964 POINTL mousePosParam; 1965 1966 /* 1967 * The documentation tells me that the coordinate should be in the target 1968 * window's coordinate space. However, the tests I made tell me the 1969 * coordinates should be in screen coordinates. 1970 */ 1971 mousePosParam.x = mousePos.x; 1972 mousePosParam.y = mousePos.y; 1973 1974 IDropTarget_DragEnter(trackerInfo->curDragTarget, 1975 trackerInfo->dataObject, 1976 keyState, 1977 mousePosParam, 1978 trackerInfo->pdwEffect); 1980 1979 } 1981 1980 } … … 1991 1990 1992 1991 /* 1993 * Now that we have done that, we have to tell the source to give 1994 * us feedback on the work being done by the target. If we don't 1992 * Now that we have done that, we have to tell the source to give 1993 * us feedback on the work being done by the target. If we don't 1995 1994 * have a target, simulate no effect. 1996 1995 */ … … 2001 2000 2002 2001 hr = IDropSource_GiveFeedback(trackerInfo->dropSource, 2003 2002 *trackerInfo->pdwEffect); 2004 2003 2005 2004 /* … … 2027 2026 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0))); 2028 2027 } 2029 } 2028 } 2030 2029 } 2031 2030 … … 2055 2054 */ 2056 2055 trackerInfo->returnValue = IDropSource_QueryContinueDrag( 2057 2058 trackerInfo->escPressed, 2059 2060 2056 trackerInfo->dropSource, 2057 trackerInfo->escPressed, 2058 keyState); 2059 2061 2060 /* 2062 2061 * All the return valued will stop the operation except the S_OK … … 2071 2070 2072 2071 /* 2073 * Release the mouse in case the drop target decides to show a popup 2072 * Release the mouse in case the drop target decides to show a popup 2074 2073 * or a menu or something. 2075 2074 */ 2076 2075 ReleaseCapture(); 2077 2076 2078 2077 /* 2079 * If we end-up over a target, drop the object in the target or 2078 * If we end-up over a target, drop the object in the target or 2080 2079 * inform the target that the operation was cancelled. 2081 2080 */ … … 2084 2083 switch (trackerInfo->returnValue) 2085 2084 { 2086 2087 * If the source wants us to complete the operation, we tell 2088 2089 2085 /* 2086 * If the source wants us to complete the operation, we tell 2087 * the drop target that we just dropped the object in it. 2088 */ 2090 2089 case DRAGDROP_S_DROP: 2091 2092 2093 2094 2095 * The documentation tells me that the coordinate should be 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 * If the source told us that we should cancel, fool the drop 2111 2112 * Also set the drop effect to "NONE" in case the application 2113 2114 2090 { 2091 POINTL mousePosParam; 2092 2093 /* 2094 * The documentation tells me that the coordinate should be 2095 * in the target window's coordinate space. However, the tests 2096 * I made tell me the coordinates should be in screen coordinates. 2097 */ 2098 mousePosParam.x = mousePos.x; 2099 mousePosParam.y = mousePos.y; 2100 2101 IDropTarget_Drop(trackerInfo->curDragTarget, 2102 trackerInfo->dataObject, 2103 keyState, 2104 mousePosParam, 2105 trackerInfo->pdwEffect); 2106 break; 2107 } 2108 /* 2109 * If the source told us that we should cancel, fool the drop 2110 * target by telling it that the mouse left it's window. 2111 * Also set the drop effect to "NONE" in case the application 2112 * ignores the result of DoDragDrop. 2113 */ 2115 2114 case DRAGDROP_S_CANCEL: 2116 2117 2118 2115 IDropTarget_DragLeave(trackerInfo->curDragTarget); 2116 *trackerInfo->pdwEffect = DROPEFFECT_NONE; 2117 break; 2119 2118 } 2120 2119 } … … 2163 2162 * params: 2164 2163 * regKey - Key to read the default value from 2165 * pdwValue - Pointer to the location where the DWORD 2164 * pdwValue - Pointer to the location where the DWORD 2166 2165 * value is returned. This value is not modified 2167 2166 * if the value is not found. … … 2169 2168 2170 2169 static void OLEUTL_ReadRegistryDWORDValue( 2171 HKEY regKey, 2170 HKEY regKey, 2172 2171 DWORD* pdwValue) 2173 2172 { … … 2178 2177 2179 2178 lres = RegQueryValueExA(regKey, 2180 2181 2182 2183 2184 2179 "", 2180 NULL, 2181 &dwKeyType, 2182 (LPBYTE)buffer, 2183 &cbData); 2185 2184 2186 2185 if (lres==ERROR_SUCCESS) … … 2189 2188 { 2190 2189 case REG_DWORD: 2191 2192 2190 *pdwValue = *(DWORD*)buffer; 2191 break; 2193 2192 case REG_EXPAND_SZ: 2194 2193 case REG_MULTI_SZ: 2195 2194 case REG_SZ: 2196 2197 2195 *pdwValue = (DWORD)strtoul(buffer, NULL, 10); 2196 break; 2198 2197 } 2199 2198 } … … 2210 2209 */ 2211 2210 HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( 2212 2213 2214 2215 2211 HICON16 hIcon, 2212 LPCOLESTR16 lpszLabel, 2213 LPCOLESTR16 lpszSourceFile, 2214 UINT16 iIconIndex 2216 2215 ) { 2217 2216 METAFILEPICT16 *mf; … … 2223 2222 if (!hIcon) { 2224 2223 if (lpszSourceFile) { 2225 2226 2227 2228 2229 2230 2231 2224 HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile); 2225 2226 /* load the icon at index from lpszSourceFile */ 2227 hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex); 2228 FreeLibrary16(hInstance); 2229 } else 2230 return (HGLOBAL)NULL; 2232 2231 } 2233 2232 -
trunk/src/ole32/ole2impl.c
r6648 r6711 1 /* $Id: ole2impl.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 2 * Ole 2 Create functions implementation -
trunk/src/ole32/ole2stubs.c
r6648 r6711 1 /* $Id: ole2stubs.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 2 * Temporary place for ole2 stubs. … … 20 19 */ 21 20 HRESULT WINAPI OleCreateLinkToFile(LPCOLESTR lpszFileName, REFIID riid, 22 23 21 DWORD renderopt, LPFORMATETC lpFormatEtc, 22 LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj) 24 23 { 25 24 FIXME("(%p,%p,%li,%p,%p,%p,%p), stub!\n",lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj); … … 32 31 */ 33 32 HRESULT WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat, 34 33 UINT uiFlags) 35 34 { 36 35 FIXME("(%x,%x,%x), stub!\n", hSrc, cfFormat, uiFlags); … … 38 37 } 39 38 40 39 41 40 /*********************************************************************** 42 41 * WriteFmtUserTypeStg (OLE32.160) 43 42 */ 44 43 HRESULT WINAPI WriteFmtUserTypeStg( 45 44 LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType) 46 45 { 47 46 FIXME("(%p,%x,%s) stub!\n",pstg,cf,debugstr_w(lpszUserType)); … … 82 81 */ 83 82 HRESULT WINAPI OleCreate( 84 85 86 87 88 89 90 83 REFCLSID rclsid, 84 REFIID riid, 85 DWORD renderopt, 86 LPFORMATETC pFormatEtc, 87 LPOLECLIENTSITE pClientSite, 88 LPSTORAGE pStg, 89 LPVOID* ppvObj) 91 90 { 92 91 HRESULT hres, hres1; 93 92 IUnknown * pUnk = NULL; 94 93 95 94 FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid)); 96 95 … … 106 105 hres1 = IOleObject_SetClientSite(pOE, pClientSite); 107 106 TRACE("-- result 0x%08lx\n", hres1); 108 107 IOleObject_Release(pOE); 109 108 } 110 109 if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS)))) 111 110 { 112 111 TRACE("trying to set stg %p\n", pStg); 113 112 hres1 = IPersistStorage_InitNew(pPS, pStg); 114 113 TRACE("-- result 0x%08lx\n", hres1); 115 114 IPersistStorage_Release(pPS); 116 115 } 117 116 } … … 209 208 */ 210 209 HRESULT WINAPI OleRegEnumFormatEtc ( 211 REFCLSID clsid, 210 REFCLSID clsid, 212 211 DWORD dwDirection, 213 212 LPENUMFORMATETC* ppenumFormatetc) … … 219 218 220 219 /*********************************************************************** 221 * PropVariantClear 220 * PropVariantClear [OLE32.166] 222 221 */ 223 222 HRESULT WINAPI PropVariantClear(void *pvar) /* [in/out] FIXME: PROPVARIANT * */ 224 223 { 225 226 227 228 229 230 } 231 232 /*********************************************************************** 233 * PropVariantCopy 224 FIXME("(%p): stub:\n", pvar); 225 226 *(LPWORD)pvar = 0; 227 /* sets at least the vt field to VT_EMPTY */ 228 return S_OK; 229 } 230 231 /*********************************************************************** 232 * PropVariantCopy [OLE32.246] 234 233 */ 235 234 HRESULT WINAPI PropVariantCopy(void *pvarDest, /* [out] FIXME: PROPVARIANT * */ 236 237 { 238 239 240 241 } 242 243 /*********************************************************************** 244 * FreePropVariantArray 235 const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */ 236 { 237 FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc); 238 239 return S_OK; 240 } 241 242 /*********************************************************************** 243 * FreePropVariantArray [OLE32.195] 245 244 */ 246 245 HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */ 247 248 { 249 250 251 246 void *rgvars) /* [in/out] FIXME: PROPVARIANT * */ 247 { 248 FIXME("(%lu, %p): stub:\n", cVariants, rgvars); 249 250 return S_OK; 252 251 } 253 252 -
trunk/src/ole32/ole32_main.c
r6648 r6711 1 /* $Id: ole32_main.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 2 * OLE32 Initialization … … 17 16 18 17 /*********************************************************************** 19 * 18 * DllEntryPoint (OLE32.@) 20 19 */ 21 20 … … 27 26 case DLL_PROCESS_ATTACH: 28 27 OLE32_hInstance = hinstDLL; 29 28 break; 30 29 31 30 case DLL_PROCESS_DETACH: 32 31 OLE32_hInstance = 0; 33 32 break; 34 33 } 35 34 return TRUE; … … 37 36 38 37 /*********************************************************************** 39 * 38 * DllRegisterServer (OLE32.@) 40 39 */ 41 40 HRESULT WINAPI OLE32_DllRegisterServer() { -
trunk/src/ole32/oleobj.c
r6648 r6711 1 /* $Id: oleobj.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */2 1 /* 3 * 2 * OLE2 COM objects 4 3 * 5 * 4 * Copyright 1998 Eric Kohl 6 5 * Copyright 1999 Francis Beaudet 7 6 */ … … 13 12 #include "debugtools.h" 14 13 #include "oleidl.h" 14 15 #ifdef __WIN32OS2__ 16 #undef FIXME 17 #undef TRACE 18 #ifdef DEBUG 19 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 20 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 21 #else 22 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 23 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 24 #endif 25 #endif 15 26 16 27 DEFAULT_DEBUG_CHANNEL(ole); … … 72 83 73 84 lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(), 74 75 76 85 0, 86 sizeof(OleAdviseHolderImpl)); 87 77 88 ICOM_VTBL(lpoah) = &oahvt; 78 89 lpoah->ref = 1; 79 90 lpoah->maxSinks = INITIAL_SINKS; 80 91 lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(), 81 82 92 0, 93 lpoah->maxSinks * sizeof(IAdviseSink*)); 83 94 84 95 for (index = 0; index < lpoah->maxSinks; index++) … … 106 117 } 107 118 } 108 119 109 120 HeapFree(GetProcessHeap(), 110 111 112 121 0, 122 ptrToDestroy->arrayOfSinks); 123 113 124 114 125 HeapFree(GetProcessHeap(), 115 116 126 0, 127 ptrToDestroy); 117 128 } 118 129 … … 122 133 static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface( 123 134 LPOLEADVISEHOLDER iface, 124 REFIID riid, 135 REFIID riid, 125 136 LPVOID* ppvObj) 126 137 { 127 ICOM_THIS(OleAdviseHolderImpl, iface); 138 ICOM_THIS(OleAdviseHolderImpl, iface); 128 139 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj); 129 140 /* … … 135 146 *ppvObj = NULL; 136 147 137 if (IsEqualIID(riid, &IID_IUnknown)) 148 if (IsEqualIID(riid, &IID_IUnknown)) 138 149 { 139 150 /* IUnknown */ 140 *ppvObj = This; 141 } 142 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 151 *ppvObj = This; 152 } 153 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 143 154 { 144 155 /* IOleAdviseHolder */ … … 148 159 if(*ppvObj == NULL) 149 160 return E_NOINTERFACE; 150 161 151 162 /* 152 163 * A successful QI always increments the reference count. … … 163 174 LPOLEADVISEHOLDER iface) 164 175 { 165 ICOM_THIS(OleAdviseHolderImpl, iface); 166 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 176 ICOM_THIS(OleAdviseHolderImpl, iface); 177 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 167 178 return ++(This->ref); 168 179 } … … 174 185 LPOLEADVISEHOLDER iface) 175 186 { 176 ICOM_THIS(OleAdviseHolderImpl, iface); 177 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 187 ICOM_THIS(OleAdviseHolderImpl, iface); 188 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 178 189 This->ref--; 179 190 … … 197 208 { 198 209 DWORD index; 199 200 ICOM_THIS(OleAdviseHolderImpl, iface); 210 211 ICOM_THIS(OleAdviseHolderImpl, iface); 201 212 202 213 TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection); … … 207 218 if (pdwConnection==NULL) 208 219 return E_POINTER; 209 220 210 221 *pdwConnection = 0; 211 222 … … 228 239 This->maxSinks+=INITIAL_SINKS; 229 240 230 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 231 232 233 241 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 242 0, 243 This->arrayOfSinks, 244 This->maxSinks*sizeof(IAdviseSink*)); 234 245 235 246 for (i=index;i < This->maxSinks; i++) 236 This->arrayOfSinks[i]=0; 247 This->arrayOfSinks[i]=0; 237 248 } 238 249 … … 259 270 */ 260 271 static HRESULT WINAPI OleAdviseHolderImpl_Unadvise( 261 LPOLEADVISEHOLDER iface, 272 LPOLEADVISEHOLDER iface, 262 273 DWORD dwConnection) 263 274 { 264 ICOM_THIS(OleAdviseHolderImpl, iface); 275 ICOM_THIS(OleAdviseHolderImpl, iface); 265 276 266 277 TRACE("(%p)->(%lu)\n", This, dwConnection); 267 278 268 279 /* 269 * So we don't return 0 as a cookie, the index was 280 * So we don't return 0 as a cookie, the index was 270 281 * incremented by 1 in OleAdviseHolderImpl_Advise 271 282 * we have to compensate. 272 283 */ 273 284 dwConnection--; 274 285 275 286 /* 276 287 * Check for invalid cookies. 277 288 */ 278 if ( (dwConnection < 0) || 289 if ( (dwConnection < 0) || 279 290 (dwConnection >= This->maxSinks) ) 280 291 return OLE_E_NOCONNECTION; … … 298 309 OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise) 299 310 { 300 ICOM_THIS(OleAdviseHolderImpl, iface); 311 ICOM_THIS(OleAdviseHolderImpl, iface); 301 312 FIXME("(%p)->(%p)\n", This, ppenumAdvise); 302 313 … … 312 323 OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk) 313 324 { 314 ICOM_THIS(OleAdviseHolderImpl, iface); 325 ICOM_THIS(OleAdviseHolderImpl, iface); 315 326 FIXME("(%p)->(%p)\n", This, pmk); 316 327 … … 325 336 OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface) 326 337 { 327 ICOM_THIS(OleAdviseHolderImpl, iface); 338 ICOM_THIS(OleAdviseHolderImpl, iface); 328 339 FIXME("(%p)\n", This); 329 340 … … 337 348 OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface) 338 349 { 339 ICOM_THIS(OleAdviseHolderImpl, iface); 350 ICOM_THIS(OleAdviseHolderImpl, iface); 340 351 FIXME("(%p)\n", This); 341 352 … … 351 362 FORMATETC fmat; 352 363 DWORD advf; 353 } DataAdviseConnection; 364 } DataAdviseConnection; 354 365 355 366 typedef struct DataAdviseHolder … … 368 379 static void DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy); 369 380 static HRESULT WINAPI DataAdviseHolder_QueryInterface( 370 371 372 373 static ULONG WINAPI DataAdviseHolder_AddRef( 381 IDataAdviseHolder* iface, 382 REFIID riid, 383 void** ppvObject); 384 static ULONG WINAPI DataAdviseHolder_AddRef( 374 385 IDataAdviseHolder* iface); 375 static ULONG WINAPI DataAdviseHolder_Release( 386 static ULONG WINAPI DataAdviseHolder_Release( 376 387 IDataAdviseHolder* iface); 377 static HRESULT WINAPI DataAdviseHolder_Advise( 388 static HRESULT WINAPI DataAdviseHolder_Advise( 378 389 IDataAdviseHolder* iface, 379 IDataObject* pDataObject, 380 FORMATETC* pFetc, 381 DWORD advf, 382 IAdviseSink* pAdvise, 383 384 static HRESULT WINAPI DataAdviseHolder_Unadvise( 390 IDataObject* pDataObject, 391 FORMATETC* pFetc, 392 DWORD advf, 393 IAdviseSink* pAdvise, 394 DWORD* pdwConnection); 395 static HRESULT WINAPI DataAdviseHolder_Unadvise( 385 396 IDataAdviseHolder* iface, 386 387 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 388 IDataAdviseHolder* iface, 389 390 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 391 IDataAdviseHolder* iface, 392 IDataObject* pDataObject, 393 DWORD dwReserved, 394 397 DWORD dwConnection); 398 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 399 IDataAdviseHolder* iface, 400 IEnumSTATDATA** ppenumAdvise); 401 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 402 IDataAdviseHolder* iface, 403 IDataObject* pDataObject, 404 DWORD dwReserved, 405 DWORD advf); 395 406 396 407 /************************************************************************** … … 417 428 418 429 newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(), 419 420 421 430 0, 431 sizeof(DataAdviseHolder)); 432 422 433 ICOM_VTBL(newHolder) = &DataAdviseHolderImpl_VTable; 423 434 newHolder->ref = 1; 424 435 newHolder->maxCons = INITIAL_SINKS; 425 436 newHolder->Connections = HeapAlloc(GetProcessHeap(), 426 427 newHolder->maxCons * 428 437 HEAP_ZERO_MEMORY, 438 newHolder->maxCons * 439 sizeof(DataAdviseConnection)); 429 440 430 441 TRACE("returning %p\n", newHolder); … … 448 459 } 449 460 } 450 461 451 462 HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections); 452 463 HeapFree(GetProcessHeap(), 0, ptrToDestroy); … … 463 474 void** ppvObject) 464 475 { 465 ICOM_THIS(DataAdviseHolder, iface); 476 ICOM_THIS(DataAdviseHolder, iface); 466 477 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject); 467 478 /* … … 470 481 if ( (This==0) || (ppvObject==0) ) 471 482 return E_INVALIDARG; 472 483 473 484 /* 474 485 * Initialize the return parameter. … … 484 495 *ppvObject = iface; 485 496 } 486 497 487 498 /* 488 499 * Check that we obtained an interface. … … 492 503 return E_NOINTERFACE; 493 504 } 494 505 495 506 /* 496 507 * Query Interface always increases the reference count by one when it is 497 * successful. 508 * successful. 498 509 */ 499 510 IUnknown_AddRef((IUnknown*)*ppvObject); 500 511 501 return S_OK;; 512 return S_OK;; 502 513 } 503 514 … … 507 518 * See Windows documentation for more details on IUnknown methods. 508 519 */ 509 static ULONG WINAPI DataAdviseHolder_AddRef( 520 static ULONG WINAPI DataAdviseHolder_AddRef( 510 521 IDataAdviseHolder* iface) 511 522 { 512 ICOM_THIS(DataAdviseHolder, iface); 523 ICOM_THIS(DataAdviseHolder, iface); 513 524 TRACE("(%p) (ref=%ld)\n", This, This->ref); 514 525 This->ref++; … … 522 533 * See Windows documentation for more details on IUnknown methods. 523 534 */ 524 static ULONG WINAPI DataAdviseHolder_Release( 535 static ULONG WINAPI DataAdviseHolder_Release( 525 536 IDataAdviseHolder* iface) 526 537 { … … 542 553 return 0; 543 554 } 544 555 545 556 return This->ref; 546 557 } … … 552 563 static HRESULT WINAPI DataAdviseHolder_Advise( 553 564 IDataAdviseHolder* iface, 554 IDataObject* pDataObject, 555 FORMATETC* pFetc, 556 DWORD advf, 557 IAdviseSink* pAdvise, 565 IDataObject* pDataObject, 566 FORMATETC* pFetc, 567 DWORD advf, 568 IAdviseSink* pAdvise, 558 569 DWORD* pdwConnection) 559 570 { 560 571 DWORD index; 561 562 ICOM_THIS(DataAdviseHolder, iface); 572 573 ICOM_THIS(DataAdviseHolder, iface); 563 574 564 575 TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf, 565 576 pAdvise, pdwConnection); 566 577 /* 567 578 * Sanity check … … 569 580 if (pdwConnection==NULL) 570 581 return E_POINTER; 571 582 572 583 *pdwConnection = 0; 573 584 … … 588 599 This->maxCons+=INITIAL_SINKS; 589 600 This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 590 591 601 This->Connections, 602 This->maxCons*sizeof(DataAdviseConnection)); 592 603 } 593 604 /* … … 617 628 * DataAdviseHolder_Unadvise 618 629 */ 619 static HRESULT WINAPI DataAdviseHolder_Unadvise( 630 static HRESULT WINAPI DataAdviseHolder_Unadvise( 620 631 IDataAdviseHolder* iface, 621 632 DWORD dwConnection) 622 633 { 623 ICOM_THIS(DataAdviseHolder, iface); 634 ICOM_THIS(DataAdviseHolder, iface); 624 635 625 636 TRACE("(%p)->(%lu)\n", This, dwConnection); 626 637 627 638 /* 628 * So we don't return 0 as a cookie, the index was 639 * So we don't return 0 as a cookie, the index was 629 640 * incremented by 1 in OleAdviseHolderImpl_Advise 630 641 * we have to compensate. 631 642 */ 632 643 dwConnection--; 633 644 634 645 /* 635 646 * Check for invalid cookies. 636 647 */ 637 if ( (dwConnection < 0) || 648 if ( (dwConnection < 0) || 638 649 (dwConnection >= This->maxCons) ) 639 650 return OLE_E_NOCONNECTION; … … 650 661 } 651 662 652 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 653 IDataAdviseHolder* iface, 663 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 664 IDataAdviseHolder* iface, 654 665 IEnumSTATDATA** ppenumAdvise) 655 666 { 656 ICOM_THIS(DataAdviseHolder, iface); 667 ICOM_THIS(DataAdviseHolder, iface); 657 668 658 669 FIXME("(%p)->(%p)\n", This, ppenumAdvise); … … 663 674 * DataAdviseHolder_SendOnDataChange 664 675 */ 665 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 666 IDataAdviseHolder* iface, 667 IDataObject* pDataObject, 668 DWORD dwReserved, 676 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 677 IDataAdviseHolder* iface, 678 IDataObject* pDataObject, 679 DWORD dwReserved, 669 680 DWORD advf) 670 681 { 671 ICOM_THIS(DataAdviseHolder, iface); 682 ICOM_THIS(DataAdviseHolder, iface); 672 683 DWORD index; 673 684 STGMEDIUM stg; … … 679 690 if(This->Connections[index].sink != NULL) { 680 691 if(!(This->Connections[index].advf & ADVF_NODATA)) { 681 682 683 684 685 692 TRACE("Calling IDataObject_GetData\n"); 693 res = IDataObject_GetData(pDataObject, 694 &(This->Connections[index].fmat), 695 &stg); 696 TRACE("returns %08lx\n", res); 686 697 } 687 698 TRACE("Calling IAdviseSink_OnDataChange\n"); 688 699 IAdviseSink_OnDataChange(This->Connections[index].sink, 689 690 700 &(This->Connections[index].fmat), 701 &stg); 691 702 TRACE("Done IAdviseSink_OnDataChange\n"); 692 703 if(This->Connections[index].advf & ADVF_ONLYONCE) { 693 694 704 TRACE("Removing connection\n"); 705 DataAdviseHolder_Unadvise(iface, index+1); 695 706 } 696 707 } -
trunk/src/ole32/stg_bigblockfile.c
r6648 r6711 1 /* $Id: stg_bigblockfile.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */2 1 /****************************************************************************** 3 2 * 4 3 * BigBlockFile 5 4 * 6 * This is the implementation of a file that consists of blocks of 5 * This is the implementation of a file that consists of blocks of 7 6 * a predetermined size. 8 * This class is used in the Compound File implementation of the 9 * IStorage and IStream interfaces. It provides the functionality 10 * to read and write any blocks in the file as well as setting and 7 * This class is used in the Compound File implementation of the 8 * IStorage and IStream interfaces. It provides the functionality 9 * to read and write any blocks in the file as well as setting and 11 10 * obtaining the size of the file. 12 11 * The blocks are indexed sequentially from the start of the file 13 12 * starting with -1. 14 * 13 * 15 14 * TODO: 16 15 * - Support for a transacted mode … … 45 44 #include "debugtools.h" 46 45 46 #ifdef __WIN32OS2__ 47 #undef FIXME 48 #undef TRACE 49 #ifdef DEBUG 50 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 51 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 52 #else 53 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 54 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 55 #endif 56 #endif 57 47 58 DEFAULT_DEBUG_CHANNEL(storage); 48 59 … … 70 81 /*** 71 82 * This structure identifies the paged that are mapped 72 * from the file and their position in memory. It is 83 * from the file and their position in memory. It is 73 84 * also used to hold a reference count to those pages. 74 85 * … … 103 114 ULONG index, 104 115 DWORD desired_access); 105 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 106 116 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 117 void* pBlock); 107 118 static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This, 108 119 ULONG page_index); 109 120 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags); 110 121 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile); … … 119 130 */ 120 131 static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb, 121 132 unsigned int index) 122 133 { 123 134 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int)); … … 151 162 * BIGBLOCKFILE_Construct 152 163 * 153 * Construct a big block file. Create the file mapping object. 164 * Construct a big block file. Create the file mapping object. 154 165 * Create the read only mapped pages list, the writable mapped page list 155 166 * and the blocks in use list. … … 231 242 232 243 This->filesize.s.LowPart = GetFileSize(This->hfile, 233 244 &This->filesize.s.HighPart); 234 245 235 246 This->maplist = NULL; … … 324 335 /* 325 336 * validate the block index 326 * 337 * 327 338 */ 328 339 if (This->blocksize * (index + 1) … … 330 341 { 331 342 TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1), 332 343 This->filesize.s.LowPart); 333 344 return NULL; 334 345 } … … 380 391 381 392 if (pBlock == NULL) 382 393 return; 383 394 384 395 page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock); 385 396 386 397 if (page == NULL) 387 398 return; 388 399 389 400 BIGBLOCKFILE_ReleaseMappedPage(This, page); … … 394 405 * 395 406 * Sets the size of the file. 396 * 407 * 397 408 */ 398 409 void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) … … 406 417 */ 407 418 BIGBLOCKFILE_UnmapAllMappedPages(This); 408 419 409 420 if (This->fileBased) 410 421 { … … 424 435 * 425 436 * The problem is that the SetFilePointer-SetEndOfFile combo below 426 * doesn't always succeed. The file is not grown. It seems like the 437 * doesn't always succeed. The file is not grown. It seems like the 427 438 * operation is cached. By doing the WriteFile, the file is actually 428 439 * grown on disk. … … 433 444 WriteFile(This->hfile, buf, 10, NULL, NULL); 434 445 /* 435 * END HACK 446 * END HACK 436 447 */ 437 448 … … 441 452 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN); 442 453 SetEndOfFile(This->hfile); 443 454 444 455 /* 445 456 * re-create the file mapping object … … 448 459 NULL, 449 460 This->flProtect, 450 0, 0, 461 0, 0, 451 462 NULL); 452 463 } … … 477 488 * 478 489 * Returns the size of the file. 479 * 490 * 480 491 */ 481 492 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This) … … 490 501 */ 491 502 static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index, 492 503 DWORD desired_access) 493 504 { 494 505 assert(block_index < BLOCKS_PER_PAGE); … … 496 507 if (desired_access == FILE_MAP_READ) 497 508 { 498 499 500 501 509 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index)) 510 return FALSE; 511 512 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index); 502 513 } 503 514 else 504 515 { 505 506 507 508 509 510 516 assert(desired_access == FILE_MAP_WRITE); 517 518 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index)) 519 return FALSE; 520 521 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index); 511 522 } 512 523 … … 520 531 */ 521 532 static void* BIGBLOCKFILE_GetBigBlockPointer( 522 LPBIGBLOCKFILE This, 523 ULONG block_index, 533 LPBIGBLOCKFILE This, 534 ULONG block_index, 524 535 DWORD desired_access) 525 536 { … … 532 543 if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access)) 533 544 { 534 535 545 BIGBLOCKFILE_ReleaseMappedPage(This, page); 546 return NULL; 536 547 } 537 548 … … 548 559 */ 549 560 static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 550 561 void *pBlock) 551 562 { 552 563 MappedPage *page; … … 554 565 for (page = This->maplist; page != NULL; page = page->next) 555 566 { 556 557 558 567 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes 568 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE) 569 break; 559 570 560 571 } … … 568 579 */ 569 580 static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head, 570 581 ULONG page_index) 571 582 { 572 583 for (; head != NULL; head = head->next) 573 584 { 574 575 576 577 578 585 if (head->page_index == page_index) 586 { 587 InterlockedIncrement(&head->refcnt); 588 break; 589 } 579 590 } 580 591 … … 612 623 if (!page) 613 624 { 614 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index); 625 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index); 626 if (page) 627 { 628 This->num_victim_pages--; 629 630 BIGBLOCKFILE_Zero(&page->readable_blocks); 631 BIGBLOCKFILE_Zero(&page->writable_blocks); 632 } 633 } 634 615 635 if (page) 616 636 { 617 This->num_victim_pages--; 618 619 BIGBLOCKFILE_Zero(&page->readable_blocks); 620 BIGBLOCKFILE_Zero(&page->writable_blocks); 621 } 622 } 623 624 if (page) 625 { 626 /* If the page is not already at the head of the list, move 627 * it there. (Also moves pages from victim to main list.) */ 628 if (This->maplist != page) 629 { 630 if (This->victimhead == page) This->victimhead = page->next; 631 if (This->victimtail == page) This->victimtail = page->prev; 632 633 BIGBLOCKFILE_UnlinkPage(page); 634 635 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page); 636 } 637 638 return page; 637 /* If the page is not already at the head of the list, move 638 * it there. (Also moves pages from victim to main list.) */ 639 if (This->maplist != page) 640 { 641 if (This->victimhead == page) This->victimhead = page->next; 642 if (This->victimtail == page) This->victimtail = page->prev; 643 644 BIGBLOCKFILE_UnlinkPage(page); 645 646 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page); 647 } 648 649 return page; 639 650 } 640 651 … … 653 664 if (This->fileBased) 654 665 { 655 DWORD numBytesToMap; 656 DWORD desired_access; 657 658 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart) 659 numBytesToMap = This->filesize.s.LowPart - lowoffset; 666 DWORD numBytesToMap; 667 DWORD desired_access; 668 669 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart) 670 numBytesToMap = This->filesize.s.LowPart - lowoffset; 671 else 672 numBytesToMap = PAGE_SIZE; 673 674 if (This->flProtect == PAGE_READONLY) 675 desired_access = FILE_MAP_READ; 676 else 677 desired_access = FILE_MAP_WRITE; 678 679 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0, 680 lowoffset, numBytesToMap); 681 } 660 682 else 661 numBytesToMap = PAGE_SIZE; 662 663 if (This->flProtect == PAGE_READONLY) 664 desired_access = FILE_MAP_READ; 665 else 666 desired_access = FILE_MAP_WRITE; 667 668 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0, 669 lowoffset, numBytesToMap); 670 } 671 else 672 { 673 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset; 683 { 684 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset; 674 685 } 675 686 … … 680 691 681 692 static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This, 682 693 ULONG page_index) 683 694 { 684 695 MappedPage *page; … … 706 717 TRACE("%ld at %p\n", page->page_index, page->lpBytes); 707 718 if (page->refcnt > 0) 708 719 ERR("unmapping inuse page %p\n", page->lpBytes); 709 720 710 721 if (This->fileBased && page->lpBytes) 711 722 UnmapViewOfFile(page->lpBytes); 712 723 713 724 page->lpBytes = NULL; … … 737 748 if (!InterlockedDecrement(&page->refcnt)) 738 749 { 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 750 if (This->maplist == page) This->maplist = page->next; 751 752 BIGBLOCKFILE_UnlinkPage(page); 753 754 if (MAX_VICTIM_PAGES > 0) 755 { 756 if (This->num_victim_pages >= MAX_VICTIM_PAGES) 757 { 758 MappedPage *victim = This->victimtail; 759 if (victim) 760 { 761 This->victimtail = victim->prev; 762 if (This->victimhead == victim) 763 This->victimhead = victim->next; 764 765 BIGBLOCKFILE_UnlinkPage(victim); 766 BIGBLOCKFILE_DeletePage(This, victim); 767 } 768 } 769 else This->num_victim_pages++; 770 771 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page); 772 if (This->victimtail == NULL) This->victimtail = page; 773 } 774 else 775 BIGBLOCKFILE_DeletePage(This, page); 765 776 } 766 777 } … … 770 781 while (list != NULL) 771 782 { 772 773 774 775 776 783 MappedPage *next = list->next; 784 785 BIGBLOCKFILE_DeletePage(This, list); 786 787 list = next; 777 788 } 778 789 } … … 800 811 for (; list != NULL; list = list->next) 801 812 { 802 813 BIGBLOCKFILE_UnmapPage(This, list); 803 814 } 804 815 } … … 814 825 while (list != NULL) 815 826 { 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 827 MappedPage *next = list->next; 828 829 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart) 830 { 831 TRACE("discarding %lu\n", list->page_index); 832 833 /* page is entirely outside of the file, delete it */ 834 BIGBLOCKFILE_UnlinkPage(list); 835 BIGBLOCKFILE_DeletePage(This, list); 836 } 837 else 838 { 839 /* otherwise, remap it */ 840 BIGBLOCKFILE_MapPage(This, list); 841 } 842 843 list = next; 833 844 } 834 845 } … … 849 860 { 850 861 if (openFlags & (STGM_WRITE | STGM_READWRITE)) 851 862 return PAGE_READWRITE; 852 863 else 853 854 } 864 return PAGE_READONLY; 865 } -
trunk/src/ole32/stg_stream.c
r6648 r6711 1 /* $Id: stg_stream.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */2 1 /* 3 2 * Compound Storage (32 bit version) … … 28 27 29 28 #include "storage32.h" 29 30 #ifdef __WIN32OS2__ 31 #undef FIXME 32 #undef TRACE 33 #ifdef DEBUG 34 #define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog 35 #define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog 36 #else 37 #define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 38 #define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL) 39 #endif 40 #endif 30 41 31 42 DEFAULT_DEBUG_CHANNEL(storage); … … 66 77 */ 67 78 StgStreamImpl* StgStreamImpl_Construct( 68 79 StorageBaseImpl* parentStorage, 69 80 DWORD grfMode, 70 81 ULONG ownerProperty) … … 73 84 74 85 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl)); 75 86 76 87 if (newStream!=0) 77 88 { … … 81 92 ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl; 82 93 newStream->ref = 0; 83 94 84 95 /* 85 96 * We want to nail-down the reference to the storage in case the … … 89 100 IStorage_AddRef((IStorage*)newStream->parentStorage); 90 101 91 newStream->grfMode = grfMode; 102 newStream->grfMode = grfMode; 92 103 newStream->ownerProperty = ownerProperty; 93 104 94 105 /* 95 106 * Start the stream at the begining. … … 97 108 newStream->currentPosition.s.HighPart = 0; 98 109 newStream->currentPosition.s.LowPart = 0; 99 110 100 111 /* 101 112 * Initialize the rest of the data. … … 105 116 newStream->bigBlockChain = 0; 106 117 newStream->smallBlockChain = 0; 107 118 108 119 /* 109 120 * Read the size from the property and determine if the blocks forming … … 112 123 StgStreamImpl_OpenBlockChain(newStream); 113 124 } 114 125 115 126 return newStream; 116 127 } … … 119 130 * This is the destructor of the StgStreamImpl class. 120 131 * 121 * This method will clean-up all the resources used-up by the given StgStreamImpl 132 * This method will clean-up all the resources used-up by the given StgStreamImpl 122 133 * class. The pointer passed-in to this function will be freed and will not 123 134 * be valid anymore. … … 151 162 * Finally, free the memory used-up by the class. 152 163 */ 153 HeapFree(GetProcessHeap(), 0, This); 164 HeapFree(GetProcessHeap(), 0, This); 154 165 } 155 166 … … 159 170 */ 160 171 HRESULT WINAPI StgStreamImpl_QueryInterface( 161 162 REFIID riid, /* [in] */ 163 void** ppvObject) /* [iid_is][out] */ 172 IStream* iface, 173 REFIID riid, /* [in] */ 174 void** ppvObject) /* [iid_is][out] */ 164 175 { 165 176 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 170 181 if (ppvObject==0) 171 182 return E_INVALIDARG; 172 183 173 184 /* 174 185 * Initialize the return parameter. 175 186 */ 176 187 *ppvObject = 0; 177 188 178 189 /* 179 190 * Compare the riid with the interface IDs implemented by this object. 180 191 */ 181 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 192 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 182 193 { 183 194 *ppvObject = (IStream*)This; 184 195 } 185 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 196 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 186 197 { 187 198 *ppvObject = (IStream*)This; 188 199 } 189 200 190 201 /* 191 202 * Check that we obtained an interface. … … 193 204 if ((*ppvObject)==0) 194 205 return E_NOINTERFACE; 195 206 196 207 /* 197 208 * Query Interface always increases the reference count by one when it is … … 199 210 */ 200 211 StgStreamImpl_AddRef(iface); 201 212 202 213 return S_OK;; 203 214 } … … 208 219 */ 209 220 ULONG WINAPI StgStreamImpl_AddRef( 210 221 IStream* iface) 211 222 { 212 223 StgStreamImpl* const This=(StgStreamImpl*)iface; 213 224 214 225 This->ref++; 215 226 216 227 return This->ref; 217 228 } … … 222 233 */ 223 234 ULONG WINAPI StgStreamImpl_Release( 224 235 IStream* iface) 225 236 { 226 237 StgStreamImpl* const This=(StgStreamImpl*)iface; 227 238 228 239 ULONG newRef; 229 240 230 241 This->ref--; 231 242 232 243 newRef = This->ref; 233 244 234 245 /* 235 246 * If the reference count goes down to 0, perform suicide. … … 239 250 StgStreamImpl_Destroy(This); 240 251 } 241 252 242 253 return newRef; 243 254 } … … 273 284 */ 274 285 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 275 276 277 286 This->ownerProperty, 287 &curProperty); 288 278 289 if (readSucessful) 279 290 { 280 291 This->streamSize = curProperty.size; 281 292 282 293 /* 283 294 * This code supports only streams that are <32 bits in size. 284 295 */ 285 296 assert(This->streamSize.s.HighPart == 0); 286 297 287 298 if(curProperty.startingBlock == BLOCK_END_OF_CHAIN) 288 299 { … … 292 303 { 293 304 if ( (This->streamSize.s.HighPart == 0) && 294 305 (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) ) 295 306 { 296 297 This->parentStorage->ancestorStorage, 298 307 This->smallBlockChain = SmallBlockChainStream_Construct( 308 This->parentStorage->ancestorStorage, 309 This->ownerProperty); 299 310 } 300 311 else 301 312 { 302 303 304 305 313 This->bigBlockChain = BlockChainStream_Construct( 314 This->parentStorage->ancestorStorage, 315 NULL, 316 This->ownerProperty); 306 317 } 307 318 } … … 318 329 * See the documentation of ISequentialStream for more info. 319 330 */ 320 HRESULT WINAPI StgStreamImpl_Read( 321 322 323 ULONG cb, /* [in] */ 324 ULONG* pcbRead) /* [out] */ 331 HRESULT WINAPI StgStreamImpl_Read( 332 IStream* iface, 333 void* pv, /* [length_is][size_is][out] */ 334 ULONG cb, /* [in] */ 335 ULONG* pcbRead) /* [out] */ 325 336 { 326 337 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 330 341 331 342 TRACE("(%p, %p, %ld, %p)\n", 332 333 334 /* 343 iface, pv, cb, pcbRead); 344 345 /* 335 346 * If the caller is not interested in the nubmer of bytes read, 336 347 * we use another buffer to avoid "if" statements in the code. … … 338 349 if (pcbRead==0) 339 350 pcbRead = &bytesReadBuffer; 340 351 341 352 /* 342 353 * Using the known size of the stream, calculate the number of bytes … … 344 355 */ 345 356 bytesToReadFromBuffer = min( This->streamSize.s.LowPart - This->currentPosition.s.LowPart, cb); 346 357 347 358 /* 348 359 * Depending on the type of chain that was opened when the stream was constructed, … … 352 363 { 353 364 SmallBlockChainStream_ReadAt(This->smallBlockChain, 354 355 356 357 358 365 This->currentPosition, 366 bytesToReadFromBuffer, 367 pv, 368 pcbRead); 369 359 370 } 360 371 else if (This->bigBlockChain!=0) 361 372 { 362 373 BlockChainStream_ReadAt(This->bigBlockChain, 363 364 365 366 374 This->currentPosition, 375 bytesToReadFromBuffer, 376 pv, 377 pcbRead); 367 378 } 368 379 else … … 387 398 */ 388 399 This->currentPosition.s.LowPart += *pcbRead; 389 400 390 401 /* 391 402 * The function returns S_OK if the buffer was filled completely … … 395 406 if(*pcbRead == cb) 396 407 return S_OK; 397 408 398 409 return S_FALSE; 399 410 } 400 411 401 412 /*** 402 413 * This method is part of the ISequentialStream interface. … … 410 421 */ 411 422 HRESULT WINAPI StgStreamImpl_Write( 412 413 const void* pv, /* [size_is][in] */ 414 ULONG cb, /* [in] */ 415 ULONG* pcbWritten) /* [out] */ 423 IStream* iface, 424 const void* pv, /* [size_is][in] */ 425 ULONG cb, /* [in] */ 426 ULONG* pcbWritten) /* [out] */ 416 427 { 417 428 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 421 432 422 433 TRACE("(%p, %p, %ld, %p)\n", 423 424 434 iface, pv, cb, pcbWritten); 435 425 436 /* 426 437 * Do we have permission to write to this stream? … … 436 447 if (pcbWritten == 0) 437 448 pcbWritten = &bytesWritten; 438 449 439 450 /* 440 451 * Initialize the out parameter … … 451 462 newSize.s.LowPart = This->currentPosition.s.LowPart + cb; 452 463 } 453 464 454 465 /* 455 466 * Verify if we need to grow the stream … … 460 471 IStream_SetSize(iface, newSize); 461 472 } 462 473 463 474 /* 464 475 * Depending on the type of chain that was opened when the stream was constructed, … … 468 479 { 469 480 SmallBlockChainStream_WriteAt(This->smallBlockChain, 470 471 472 473 474 481 This->currentPosition, 482 cb, 483 pv, 484 pcbWritten); 485 475 486 } 476 487 else if (This->bigBlockChain!=0) 477 488 { 478 489 BlockChainStream_WriteAt(This->bigBlockChain, 479 480 481 482 490 This->currentPosition, 491 cb, 492 pv, 493 pcbWritten); 483 494 } 484 495 else 485 496 assert(FALSE); 486 497 487 498 /* 488 499 * Advance the position pointer for the number of positions written. 489 500 */ 490 501 This->currentPosition.s.LowPart += *pcbWritten; 491 502 492 503 return S_OK; 493 504 } … … 500 511 * 501 512 * See the documentation of IStream for more info. 502 */ 503 HRESULT WINAPI StgStreamImpl_Seek( 504 505 LARGE_INTEGER dlibMove, /* [in] */ 506 DWORD dwOrigin, /* [in] */ 507 513 */ 514 HRESULT WINAPI StgStreamImpl_Seek( 515 IStream* iface, 516 LARGE_INTEGER dlibMove, /* [in] */ 517 DWORD dwOrigin, /* [in] */ 518 ULARGE_INTEGER* plibNewPosition) /* [out] */ 508 519 { 509 520 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 512 523 513 524 TRACE("(%p, %ld, %ld, %p)\n", 514 515 516 /* 525 iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition); 526 527 /* 517 528 * The caller is allowed to pass in NULL as the new position return value. 518 529 * If it happens, we assign it to a dynamic variable to avoid special cases … … 556 567 /* ... and subtract with carry */ 557 568 if (dlibMove.s.LowPart > plibNewPosition->s.LowPart) { 558 559 plibNewPosition->s.HighPart -= 1; 569 /* carry needed, This accounts for any underflows at [1]*/ 570 plibNewPosition->s.HighPart -= 1; 560 571 } 561 572 plibNewPosition->s.LowPart -= dlibMove.s.LowPart; /* [1] */ 562 plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 573 plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 563 574 } else { 564 575 /* add directly */ … … 566 577 plibNewPosition->s.LowPart += dlibMove.s.LowPart; 567 578 if((plibNewPosition->s.LowPart < initialLowPart) || 568 569 570 579 (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) { 580 /* LowPart has rolled over => add the carry digit to HighPart */ 581 plibNewPosition->s.HighPart++; 571 582 } 572 plibNewPosition->s.HighPart += dlibMove.s.HighPart; 573 } 574 /* 575 * Check if we end-up before the beginning of the file. That should 583 plibNewPosition->s.HighPart += dlibMove.s.HighPart; 584 } 585 /* 586 * Check if we end-up before the beginning of the file. That should 576 587 * trigger an error. 577 588 */ … … 581 592 582 593 /* 583 * We currently don't support files with offsets of >32 bits. 594 * We currently don't support files with offsets of >32 bits. 584 595 * Note that we have checked for a negative offset already 585 596 */ … … 594 605 */ 595 606 This->currentPosition = *plibNewPosition; 596 607 597 608 return S_OK; 598 609 } … … 607 618 * See the documentation of IStream for more info. 608 619 */ 609 HRESULT WINAPI StgStreamImpl_SetSize( 610 611 ULARGE_INTEGER libNewSize) /* [in] */ 620 HRESULT WINAPI StgStreamImpl_SetSize( 621 IStream* iface, 622 ULARGE_INTEGER libNewSize) /* [in] */ 612 623 { 613 624 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 658 669 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 659 670 This->ownerProperty, 660 &curProperty); 671 &curProperty); 661 672 /* 662 673 * Determine if we have to switch from small to big blocks or vice versa 663 */ 664 if ( (This->smallBlockChain!=0) && 674 */ 675 if ( (This->smallBlockChain!=0) && 665 676 (curProperty.size.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) ) 666 677 { … … 694 705 curProperty.size.s.HighPart = libNewSize.s.HighPart; 695 706 curProperty.size.s.LowPart = libNewSize.s.LowPart; 696 707 697 708 if (Success) 698 709 { 699 710 StorageImpl_WriteProperty(This->parentStorage->ancestorStorage, 700 701 702 } 703 711 This->ownerProperty, 712 &curProperty); 713 } 714 704 715 This->streamSize = libNewSize; 705 716 706 717 return S_OK; 707 718 } 708 719 709 720 /*** 710 721 * This method is part of the IStream interface. … … 714 725 * See the documentation of IStream for more info. 715 726 */ 716 HRESULT WINAPI StgStreamImpl_CopyTo( 717 718 IStream* pstm, /* [unique][in] */ 719 ULARGE_INTEGER cb, /* [in] */ 720 ULARGE_INTEGER* pcbRead, /* [out] */ 721 ULARGE_INTEGER* pcbWritten) /* [out] */ 727 HRESULT WINAPI StgStreamImpl_CopyTo( 728 IStream* iface, 729 IStream* pstm, /* [unique][in] */ 730 ULARGE_INTEGER cb, /* [in] */ 731 ULARGE_INTEGER* pcbRead, /* [out] */ 732 ULARGE_INTEGER* pcbWritten) /* [out] */ 722 733 { 723 734 HRESULT hr = S_OK; … … 727 738 ULARGE_INTEGER totalBytesWritten; 728 739 729 TRACE("(%p, %p, %ld, %p, %p)\n", 730 740 TRACE("(%p, %p, %ld, %p, %p)\n", 741 iface, pstm, cb.s.LowPart, pcbRead, pcbWritten); 731 742 732 743 /* … … 750 761 else 751 762 copySize = cb.s.LowPart; 752 763 753 764 IStream_Read(iface, tmpBuffer, copySize, &bytesRead); 754 765 755 766 totalBytesRead.s.LowPart += bytesRead; 756 767 757 768 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); 758 769 … … 767 778 break; 768 779 } 769 780 770 781 if (bytesRead!=copySize) 771 782 cb.s.LowPart = 0; … … 798 809 * 799 810 * See the documentation of IStream for more info. 800 */ 801 HRESULT WINAPI StgStreamImpl_Commit( 802 803 DWORD grfCommitFlags) /* [in] */ 811 */ 812 HRESULT WINAPI StgStreamImpl_Commit( 813 IStream* iface, 814 DWORD grfCommitFlags) /* [in] */ 804 815 { 805 816 return S_OK; … … 813 824 * 814 825 * See the documentation of IStream for more info. 815 */ 816 HRESULT WINAPI StgStreamImpl_Revert( 817 826 */ 827 HRESULT WINAPI StgStreamImpl_Revert( 828 IStream* iface) 818 829 { 819 830 return S_OK; 820 831 } 821 832 822 HRESULT WINAPI StgStreamImpl_LockRegion( 823 824 ULARGE_INTEGER libOffset, /* [in] */ 825 ULARGE_INTEGER cb, /* [in] */ 826 DWORD dwLockType) /* [in] */ 833 HRESULT WINAPI StgStreamImpl_LockRegion( 834 IStream* iface, 835 ULARGE_INTEGER libOffset, /* [in] */ 836 ULARGE_INTEGER cb, /* [in] */ 837 DWORD dwLockType) /* [in] */ 827 838 { 828 839 FIXME("not implemented!\n"); … … 830 841 } 831 842 832 HRESULT WINAPI StgStreamImpl_UnlockRegion( 833 834 ULARGE_INTEGER libOffset, /* [in] */ 835 ULARGE_INTEGER cb, /* [in] */ 836 DWORD dwLockType) /* [in] */ 843 HRESULT WINAPI StgStreamImpl_UnlockRegion( 844 IStream* iface, 845 ULARGE_INTEGER libOffset, /* [in] */ 846 ULARGE_INTEGER cb, /* [in] */ 847 DWORD dwLockType) /* [in] */ 837 848 { 838 849 FIXME("not implemented!\n"); … … 847 858 * 848 859 * See the documentation of IStream for more info. 849 */ 850 HRESULT WINAPI StgStreamImpl_Stat( 851 852 853 DWORD grfStatFlag) /* [in] */ 860 */ 861 HRESULT WINAPI StgStreamImpl_Stat( 862 IStream* iface, 863 STATSTG* pstatstg, /* [out] */ 864 DWORD grfStatFlag) /* [in] */ 854 865 { 855 866 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 857 868 StgProperty curProperty; 858 869 BOOL readSucessful; 859 870 860 871 /* 861 872 * Read the information from the property. 862 873 */ 863 874 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 864 865 866 875 This->ownerProperty, 876 &curProperty); 877 867 878 if (readSucessful) 868 879 { 869 StorageUtl_CopyPropertyToSTATSTG(pstatstg, 870 &curProperty, 871 880 StorageUtl_CopyPropertyToSTATSTG(pstatstg, 881 &curProperty, 882 grfStatFlag); 872 883 873 884 pstatstg->grfMode = This->grfMode; 874 885 875 886 return S_OK; 876 887 } 877 888 878 889 return E_FAIL; 879 890 } 880 881 HRESULT WINAPI StgStreamImpl_Clone( 882 IStream* iface, 883 IStream** ppstm) /* [out] */ 884 { 885 FIXME("not implemented!\n"); 886 return E_NOTIMPL; 887 } 891 892 /*** 893 * This method is part of the IStream interface. 894 * 895 * This method returns a clone of the interface that allows for 896 * another seek pointer 897 * 898 * See the documentation of IStream for more info. 899 * 900 * I am not totally sure what I am doing here but I presume that this 901 * should be basically as simple as creating a new stream with the same 902 * parent etc and positioning its seek cursor. 903 */ 904 HRESULT WINAPI StgStreamImpl_Clone( 905 IStream* iface, 906 IStream** ppstm) /* [out] */ 907 { 908 StgStreamImpl* const This=(StgStreamImpl*)iface; 909 HRESULT hres; 910 StgStreamImpl* new_stream; 911 LARGE_INTEGER seek_pos; 912 913 /* 914 * Sanity check 915 */ 916 if ( ppstm == 0 ) 917 return STG_E_INVALIDPOINTER; 918 919 new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->ownerProperty); 920 921 if (!new_stream) 922 return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */ 923 924 *ppstm = (IStream*) new_stream; 925 seek_pos.QuadPart = This->currentPosition.QuadPart; 926 927 hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL); 928 929 assert (SUCCEEDED(hres)); 930 931 return S_OK; 932 } -
trunk/src/ole32/storage32.c
r6648 r6711 1 /* $Id: storage32.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */2 1 /* 3 2 * Compound Storage (32 bit version) … … 38 37 #define FILE_BEGIN 0 39 38 39 #ifdef __WIN32OS2__ 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 49 #endif 50 40 51 41 52 /* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */ … … 48 59 /* OLESTREAM memory structure to use for Get and Put Routines */ 49 60 /* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */ 50 typedef struct 61 typedef struct 51 62 { 52 63 DWORD dwOleID; … … 86 97 DWORD dwExtentX; 87 98 DWORD dwExtentY; 88 DWORD dwSize; 99 DWORD dwSize; 89 100 BYTE *pData; 90 101 }OLECONVERT_ISTORAGE_OLEPRES; … … 111 122 INT typeOfRelation); 112 123 113 static HRESULT adjustPropertyChain( 124 static HRESULT adjustPropertyChain( 114 125 StorageImpl *This, 115 126 StgProperty propertyToDelete, … … 138 149 * Declaration of miscellaneous functions... 139 150 */ 140 static HRESULT validateSTGM(DWORD stgmValue); 151 static HRESULT validateSTGM(DWORD stgmValue); 141 152 142 153 static DWORD GetShareModeFromSTGM(DWORD stgm); … … 224 235 * This method implements the common QueryInterface for all IStorage32 225 236 * implementations contained in this file. 226 * 237 * 227 238 * See Windows documentation for more details on IUnknown methods. 228 239 */ … … 238 249 if ( (This==0) || (ppvObject==0) ) 239 250 return E_INVALIDARG; 240 251 241 252 /* 242 253 * Initialize the return parameter. 243 254 */ 244 255 *ppvObject = 0; 245 256 246 257 /* 247 258 * Compare the riid with the interface IDs implemented by this object. 248 259 */ 249 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 260 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 250 261 { 251 262 *ppvObject = (IStorage*)This; 252 263 } 253 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 264 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 254 265 { 255 266 *ppvObject = (IStorage*)This; 256 267 } 257 268 258 269 /* 259 270 * Check that we obtained an interface. … … 261 272 if ((*ppvObject)==0) 262 273 return E_NOINTERFACE; 263 274 264 275 /* 265 276 * Query Interface always increases the reference count by one when it is … … 270 281 return S_OK; 271 282 } 272 283 273 284 /************************************************************************ 274 285 * Storage32BaseImpl_AddRef (IUnknown) … … 276 287 * This method implements the common AddRef for all IStorage32 277 288 * implementations contained in this file. 278 * 289 * 279 290 * See Windows documentation for more details on IUnknown methods. 280 291 */ 281 ULONG WINAPI StorageBaseImpl_AddRef( 292 ULONG WINAPI StorageBaseImpl_AddRef( 282 293 IStorage* iface) 283 294 { … … 287 298 return This->ref; 288 299 } 289 300 290 301 /************************************************************************ 291 302 * Storage32BaseImpl_Release (IUnknown) … … 293 304 * This method implements the common Release for all IStorage32 294 305 * implementations contained in this file. 295 * 306 * 296 307 * See Windows documentation for more details on IUnknown methods. 297 308 */ 298 ULONG WINAPI StorageBaseImpl_Release( 309 ULONG WINAPI StorageBaseImpl_Release( 299 310 IStorage* iface) 300 311 { … … 311 322 { 312 323 /* 313 * Since we are using a system of base-classes, we want to call the 314 * destructor of the appropriate derived class. To do this, we are 324 * Since we are using a system of base-classes, we want to call the 325 * destructor of the appropriate derived class. To do this, we are 315 326 * using virtual functions to implement the destructor. 316 327 */ … … 319 330 return 0; 320 331 } 321 332 322 333 return This->ref; 323 334 } … … 330 341 * See Windows documentation for more details on IStorage methods. 331 342 */ 332 HRESULT WINAPI StorageBaseImpl_OpenStream( 343 HRESULT WINAPI StorageBaseImpl_OpenStream( 333 344 IStorage* iface, 334 345 const OLECHAR* pwcsName, /* [string][in] */ 335 346 void* reserved1, /* [unique][in] */ 336 DWORD grfMode, /* [in] */ 337 DWORD reserved2, /* [in] */ 338 IStream** ppstm) /* [out] */ 347 DWORD grfMode, /* [in] */ 348 DWORD reserved2, /* [in] */ 349 IStream** ppstm) /* [out] */ 339 350 { 340 351 ICOM_THIS(StorageBaseImpl,iface); … … 344 355 ULONG foundPropertyIndex; 345 356 346 TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 347 357 TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 358 iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm); 348 359 349 360 /* … … 352 363 if ( (pwcsName==NULL) || (ppstm==0) ) 353 364 return E_INVALIDARG; 354 365 355 366 /* 356 367 * Initialize the out parameter 357 368 */ 358 369 *ppstm = 0; 359 370 360 371 /* 361 372 * Validate the STGM flags … … 376 387 */ 377 388 propertyEnumeration = IEnumSTATSTGImpl_Construct( 378 This->ancestorStorage, 389 This->ancestorStorage, 379 390 This->rootPropertySetIndex); 380 391 381 392 /* 382 393 * Search the enumeration for the property with the given name … … 386 397 pwcsName, 387 398 ¤tProperty); 388 399 389 400 /* 390 401 * Delete the property enumeration since we don't need it anymore 391 402 */ 392 403 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 393 404 394 405 /* 395 406 * If it was found, construct the stream object and return a pointer to it. 396 407 */ 397 if ( (foundPropertyIndex!=PROPERTY_NULL) && 408 if ( (foundPropertyIndex!=PROPERTY_NULL) && 398 409 (currentProperty.propertyType==PROPTYPE_STREAM) ) 399 410 { 400 411 newStream = StgStreamImpl_Construct(This, grfMode, foundPropertyIndex); 401 412 402 413 if (newStream!=0) 403 414 { … … 406 417 407 418 /* 408 * Since we are returning a pointer to the interface, we have to 419 * Since we are returning a pointer to the interface, we have to 409 420 * nail down the reference. 410 421 */ 411 422 StgStreamImpl_AddRef(*ppstm); 412 423 413 424 return S_OK; 414 425 } 415 426 416 427 return E_OUTOFMEMORY; 417 428 } 418 429 419 430 return STG_E_FILENOTFOUND; 420 431 } … … 424 435 * 425 436 * This method will open a new storage object from the current storage. 426 * 437 * 427 438 * See Windows documentation for more details on IStorage methods. 428 */ 429 HRESULT WINAPI StorageBaseImpl_OpenStorage( 439 */ 440 HRESULT WINAPI StorageBaseImpl_OpenStorage( 430 441 IStorage* iface, 431 const OLECHAR* pwcsName, /* [string][unique][in] */ 432 IStorage* pstgPriority, /* [unique][in] */ 433 DWORD grfMode, /* [in] */ 434 SNB snbExclude, /* [unique][in] */ 435 DWORD reserved, /* [in] */ 436 IStorage** ppstg) /* [out] */ 442 const OLECHAR* pwcsName, /* [string][unique][in] */ 443 IStorage* pstgPriority, /* [unique][in] */ 444 DWORD grfMode, /* [in] */ 445 SNB snbExclude, /* [unique][in] */ 446 DWORD reserved, /* [in] */ 447 IStorage** ppstg) /* [out] */ 437 448 { 438 449 ICOM_THIS(StorageBaseImpl,iface); … … 442 453 ULONG foundPropertyIndex; 443 454 444 TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 445 iface, debugstr_w(pwcsName), pstgPriority, 446 447 455 TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 456 iface, debugstr_w(pwcsName), pstgPriority, 457 grfMode, snbExclude, reserved, ppstg); 458 448 459 /* 449 460 * Perform a sanity check on the parameters. … … 451 462 if ( (This==0) || (pwcsName==NULL) || (ppstg==0) ) 452 463 return E_INVALIDARG; 453 464 454 465 /* 455 466 * Validate the STGM flags … … 461 472 * As documented. 462 473 */ 463 if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 474 if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 464 475 (grfMode & STGM_DELETEONRELEASE) || 465 476 (grfMode & STGM_PRIORITY) ) … … 470 481 */ 471 482 *ppstg = 0; 472 483 473 484 /* 474 485 * Create a property enumeration to search the properties 475 486 */ 476 487 propertyEnumeration = IEnumSTATSTGImpl_Construct( 477 This->ancestorStorage, 488 This->ancestorStorage, 478 489 This->rootPropertySetIndex); 479 490 480 491 /* 481 492 * Search the enumeration for the property with the given name … … 485 496 pwcsName, 486 497 ¤tProperty); 487 498 488 499 /* 489 500 * Delete the property enumeration since we don't need it anymore 490 501 */ 491 502 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 492 503 493 504 /* 494 505 * If it was found, construct the stream object and return a pointer to it. 495 506 */ 496 if ( (foundPropertyIndex!=PROPERTY_NULL) && 507 if ( (foundPropertyIndex!=PROPERTY_NULL) && 497 508 (currentProperty.propertyType==PROPTYPE_STORAGE) ) 498 509 { … … 503 514 This->ancestorStorage, 504 515 foundPropertyIndex); 505 516 506 517 if (newStorage != 0) 507 518 { … … 509 520 510 521 /* 511 * Since we are returning a pointer to the interface, 522 * Since we are returning a pointer to the interface, 512 523 * we have to nail down the reference. 513 524 */ 514 525 StorageBaseImpl_AddRef(*ppstg); 515 526 516 527 return S_OK; 517 528 } 518 529 519 530 return STG_E_INSUFFICIENTMEMORY; 520 531 } 521 532 522 533 return STG_E_FILENOTFOUND; 523 534 } … … 526 537 * Storage32BaseImpl_EnumElements (IStorage) 527 538 * 528 * This method will create an enumerator object that can be used to 539 * This method will create an enumerator object that can be used to 529 540 * retrieve informatino about all the properties in the storage object. 530 * 541 * 531 542 * See Windows documentation for more details on IStorage methods. 532 */ 533 HRESULT WINAPI StorageBaseImpl_EnumElements( 543 */ 544 HRESULT WINAPI StorageBaseImpl_EnumElements( 534 545 IStorage* iface, 535 DWORD reserved1, /* [in] */ 536 void* reserved2, /* [size_is][unique][in] */ 537 DWORD reserved3, /* [in] */ 538 IEnumSTATSTG** ppenum) /* [out] */ 546 DWORD reserved1, /* [in] */ 547 void* reserved2, /* [size_is][unique][in] */ 548 DWORD reserved3, /* [in] */ 549 IEnumSTATSTG** ppenum) /* [out] */ 539 550 { 540 551 ICOM_THIS(StorageBaseImpl,iface); 541 552 IEnumSTATSTGImpl* newEnum; 542 553 543 TRACE("(%p, %ld, %p, %ld, %p)\n", 544 554 TRACE("(%p, %ld, %p, %ld, %p)\n", 555 iface, reserved1, reserved2, reserved3, ppenum); 545 556 546 557 /* … … 549 560 if ( (This==0) || (ppenum==0)) 550 561 return E_INVALIDARG; 551 562 552 563 /* 553 564 * Construct the enumerator. … … 566 577 */ 567 578 IEnumSTATSTGImpl_AddRef(*ppenum); 568 579 569 580 return S_OK; 570 581 } … … 577 588 * 578 589 * This method will retrieve information about this storage object. 579 * 590 * 580 591 * See Windows documentation for more details on IStorage methods. 581 */ 582 HRESULT WINAPI StorageBaseImpl_Stat( 592 */ 593 HRESULT WINAPI StorageBaseImpl_Stat( 583 594 IStorage* iface, 584 STATSTG* pstatstg, /* [out] */ 585 DWORD grfStatFlag) /* [in] */ 595 STATSTG* pstatstg, /* [out] */ 596 DWORD grfStatFlag) /* [in] */ 586 597 { 587 598 ICOM_THIS(StorageBaseImpl,iface); … … 589 600 BOOL readSuccessful; 590 601 591 TRACE("(%p, %p, %lx)\n", 592 602 TRACE("(%p, %p, %lx)\n", 603 iface, pstatstg, grfStatFlag); 593 604 594 605 /* … … 609 620 { 610 621 StorageUtl_CopyPropertyToSTATSTG( 611 pstatstg, 612 &curProperty, 622 pstatstg, 623 &curProperty, 613 624 grfStatFlag); 614 625 615 626 return S_OK; 616 627 } 617 628 618 629 return E_FAIL; 619 630 } … … 622 633 * Storage32BaseImpl_RenameElement (IStorage) 623 634 * 624 * This method will rename the specified element. 635 * This method will rename the specified element. 625 636 * 626 637 * See Windows documentation for more details on IStorage methods. 627 * 628 * Implementation notes: The method used to rename consists of creating a clone 629 * of the deleted StgProperty object setting it with the new name and to 638 * 639 * Implementation notes: The method used to rename consists of creating a clone 640 * of the deleted StgProperty object setting it with the new name and to 630 641 * perform a DestroyElement of the old StgProperty. 631 642 */ … … 640 651 ULONG foundPropertyIndex; 641 652 642 TRACE("(%p, %s, %s)\n", 643 653 TRACE("(%p, %s, %s)\n", 654 iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName)); 644 655 645 656 /* … … 687 698 * Setup a new property for the renamed property 688 699 */ 689 renamedProperty.sizeOfNameString = 700 renamedProperty.sizeOfNameString = 690 701 ( lstrlenW(pwcsNewName)+1 ) * sizeof(WCHAR); 691 702 692 703 if (renamedProperty.sizeOfNameString > PROPERTY_NAME_BUFFER_LEN) 693 704 return STG_E_INVALIDNAME; 694 705 695 706 strcpyW(renamedProperty.name, pwcsNewName); 696 707 697 708 renamedProperty.propertyType = currentProperty.propertyType; 698 709 renamedProperty.startingBlock = currentProperty.startingBlock; 699 710 renamedProperty.size.s.LowPart = currentProperty.size.s.LowPart; 700 711 renamedProperty.size.s.HighPart = currentProperty.size.s.HighPart; 701 712 702 713 renamedProperty.previousProperty = PROPERTY_NULL; 703 714 renamedProperty.nextProperty = PROPERTY_NULL; 704 715 705 716 /* 706 717 * Bring the dirProperty link in case it is a storage and in which … … 708 719 */ 709 720 renamedProperty.dirProperty = currentProperty.dirProperty; 710 711 /* call CoFileTime to get the current time 721 722 /* call CoFileTime to get the current time 712 723 renamedProperty.timeStampS1 713 724 renamedProperty.timeStampD1 714 725 renamedProperty.timeStampS2 715 726 renamedProperty.timeStampD2 716 renamedProperty.propertyUniqueID 727 renamedProperty.propertyUniqueID 717 728 */ 718 719 /* 729 730 /* 720 731 * Obtain a free property in the property chain 721 732 */ 722 733 renamedPropertyIndex = getFreeProperty(This->ancestorStorage); 723 734 724 735 /* 725 736 * Save the new property into the new property spot 726 */ 737 */ 727 738 StorageImpl_WriteProperty( 728 739 This->ancestorStorage, 729 renamedPropertyIndex, 740 renamedPropertyIndex, 730 741 &renamedProperty); 731 732 /* 742 743 /* 733 744 * Find a spot in the property chain for our newly created property. 734 745 */ 735 746 updatePropertyChain( 736 747 (StorageImpl*)This, 737 renamedPropertyIndex, 748 renamedPropertyIndex, 738 749 renamedProperty); 739 750 740 751 /* 741 * At this point the renamed property has been inserted in the tree, 742 * now, before to Destroy the old property we must zeroed it's dirProperty 743 * otherwise the DestroyProperty below will zap it all and we do not want 752 * At this point the renamed property has been inserted in the tree, 753 * now, before to Destroy the old property we must zeroed it's dirProperty 754 * otherwise the DestroyProperty below will zap it all and we do not want 744 755 * this to happen. 745 756 * Also, we fake that the old property is a storage so the DestroyProperty 746 757 * will not do a SetSize(0) on the stream data. 747 * 758 * 748 759 * This means that we need to tweek the StgProperty if it is a stream or a 749 760 * non empty storage. … … 757 768 StorageImpl_WriteProperty( 758 769 This->ancestorStorage, 759 foundPropertyIndex, 770 foundPropertyIndex, 760 771 ¤tProperty); 761 772 762 /* 763 * Invoke Destroy to get rid of the ole property and automatically redo 764 * the linking of it's previous and next members... 765 */ 766 StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 773 /* 774 * Invoke Destroy to get rid of the ole property and automatically redo 775 * the linking of it's previous and next members... 776 */ 777 StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 767 778 768 779 } … … 781 792 * Storage32BaseImpl_CreateStream (IStorage) 782 793 * 783 * This method will create a stream object within this storage 794 * This method will create a stream object within this storage 784 795 * 785 796 * See Windows documentation for more details on IStorage methods. … … 799 810 ULONG foundPropertyIndex, newPropertyIndex; 800 811 801 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 802 iface, debugstr_w(pwcsName), grfMode, 803 812 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 813 iface, debugstr_w(pwcsName), grfMode, 814 reserved1, reserved2, ppstm); 804 815 805 816 /* … … 846 857 { 847 858 /* 848 * An element with this name already exists 859 * An element with this name already exists 849 860 */ 850 861 if (grfMode & STGM_CREATE) 851 862 { 852 IStorage_DestroyElement(iface, pwcsName); 853 } 854 else 863 IStorage_DestroyElement(iface, pwcsName); 864 } 865 else 855 866 return STG_E_FILEALREADYEXISTS; 856 867 } 857 868 858 /* 859 * memset the empty property 869 /* 870 * memset the empty property 860 871 */ 861 872 memset(&newStreamProperty, 0, sizeof(StgProperty)); … … 878 889 newStreamProperty.dirProperty = PROPERTY_NULL; 879 890 880 /* call CoFileTime to get the current time 891 /* call CoFileTime to get the current time 881 892 newStreamProperty.timeStampS1 882 893 newStreamProperty.timeStampD1 … … 888 899 889 900 /* 890 * Get a free property or create a new one 901 * Get a free property or create a new one 891 902 */ 892 903 newPropertyIndex = getFreeProperty(This->ancestorStorage); … … 894 905 /* 895 906 * Save the new property into the new property spot 896 */ 907 */ 897 908 StorageImpl_WriteProperty( 898 909 This->ancestorStorage, 899 newPropertyIndex, 910 newPropertyIndex, 900 911 &newStreamProperty); 901 912 902 /* 913 /* 903 914 * Find a spot in the property chain for our newly created property. 904 915 */ 905 916 updatePropertyChain( 906 917 (StorageImpl*)This, 907 newPropertyIndex, 918 newPropertyIndex, 908 919 newStreamProperty); 909 920 910 /* 921 /* 911 922 * Open the stream to return it. 912 923 */ … … 934 945 * Storage32BaseImpl_SetClass (IStorage) 935 946 * 936 * This method will write the specified CLSID in the property of this 947 * This method will write the specified CLSID in the property of this 937 948 * storage. 938 949 * … … 949 960 950 961 TRACE("(%p, %p)\n", iface, clsid); 951 962 952 963 success = StorageImpl_ReadProperty(This->ancestorStorage, 953 964 This->rootPropertySetIndex, … … 970 981 ** Storage32Impl implementation 971 982 */ 972 983 973 984 /************************************************************************ 974 985 * Storage32Impl_CreateStorage (IStorage) … … 978 989 * See Windows documentation for more details on IStorage methods. 979 990 */ 980 HRESULT WINAPI StorageImpl_CreateStorage( 991 HRESULT WINAPI StorageImpl_CreateStorage( 981 992 IStorage* iface, 982 const OLECHAR *pwcsName, /* [string][in] */ 983 DWORD grfMode, /* [in] */ 984 DWORD reserved1, /* [in] */ 985 DWORD reserved2, /* [in] */ 986 IStorage **ppstg) /* [out] */ 993 const OLECHAR *pwcsName, /* [string][in] */ 994 DWORD grfMode, /* [in] */ 995 DWORD reserved1, /* [in] */ 996 DWORD reserved2, /* [in] */ 997 IStorage **ppstg) /* [out] */ 987 998 { 988 999 StorageImpl* const This=(StorageImpl*)iface; … … 995 1006 HRESULT hr; 996 1007 997 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 998 iface, debugstr_w(pwcsName), grfMode, 999 1000 1008 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 1009 iface, debugstr_w(pwcsName), grfMode, 1010 reserved1, reserved2, ppstg); 1011 1001 1012 /* 1002 1013 * Validate parameters … … 1034 1045 { 1035 1046 /* 1036 * An element with this name already exists 1047 * An element with this name already exists 1037 1048 */ 1038 1049 if (grfMode & STGM_CREATE) 1039 IStorage_DestroyElement(iface, pwcsName); 1040 else 1050 IStorage_DestroyElement(iface, pwcsName); 1051 else 1041 1052 return STG_E_FILEALREADYEXISTS; 1042 1053 } 1043 1054 1044 /* 1045 * memset the empty property 1055 /* 1056 * memset the empty property 1046 1057 */ 1047 1058 memset(&newProperty, 0, sizeof(StgProperty)); … … 1063 1074 newProperty.dirProperty = PROPERTY_NULL; 1064 1075 1065 /* call CoFileTime to get the current time 1076 /* call CoFileTime to get the current time 1066 1077 newProperty.timeStampS1 1067 1078 newProperty.timeStampD1 … … 1072 1083 /* newStorageProperty.propertyUniqueID */ 1073 1084 1074 /* 1085 /* 1075 1086 * Obtain a free property in the property chain 1076 1087 */ … … 1079 1090 /* 1080 1091 * Save the new property into the new property spot 1081 */ 1092 */ 1082 1093 StorageImpl_WriteProperty( 1083 1094 This->ancestorStorage, 1084 newPropertyIndex, 1095 newPropertyIndex, 1085 1096 &newProperty); 1086 1097 1087 /* 1098 /* 1088 1099 * Find a spot in the property chain for our newly created property. 1089 1100 */ 1090 1101 updatePropertyChain( 1091 1102 This, 1092 newPropertyIndex, 1103 newPropertyIndex, 1093 1104 newProperty); 1094 1105 1095 /* 1106 /* 1096 1107 * Open it to get a pointer to return. 1097 1108 */ … … 1110 1121 } 1111 1122 1112 1123 1113 1124 return S_OK; 1114 1125 } … … 1141 1152 if (currentProperty.sizeOfNameString == 0) 1142 1153 { 1143 /* 1154 /* 1144 1155 * The property existis and is available, we found it. 1145 1156 */ … … 1158 1169 } while (newPropertyIndex == PROPERTY_NULL); 1159 1170 1160 /* 1161 * grow the property chain 1171 /* 1172 * grow the property chain 1162 1173 */ 1163 1174 if (! readSuccessful) … … 1169 1180 ULONG blockCount = 0; 1170 1181 1171 /* 1172 * obtain the new count of property blocks 1182 /* 1183 * obtain the new count of property blocks 1173 1184 */ 1174 1185 blockCount = BlockChainStream_GetCount( 1175 1186 storage->ancestorStorage->rootBlockChain)+1; 1176 1187 1177 /* 1178 * initialize the size used by the property stream 1188 /* 1189 * initialize the size used by the property stream 1179 1190 */ 1180 1191 newSize.s.HighPart = 0; 1181 1192 newSize.s.LowPart = storage->bigBlockSize * blockCount; 1182 1193 1183 /* 1184 * add a property block to the property chain 1194 /* 1195 * add a property block to the property chain 1185 1196 */ 1186 1197 BlockChainStream_SetSize(storage->ancestorStorage->rootBlockChain, newSize); 1187 1198 1188 /* 1189 * memset the empty property in order to initialize the unused newly 1199 /* 1200 * memset the empty property in order to initialize the unused newly 1190 1201 * created property 1191 1202 */ 1192 1203 memset(&emptyProperty, 0, sizeof(StgProperty)); 1193 1204 1194 /* 1205 /* 1195 1206 * initialize them 1196 1207 */ 1197 lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 1198 1208 lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 1209 1199 1210 for( 1200 1211 propertyIndex = newPropertyIndex; … … 1204 1215 StorageImpl_WriteProperty( 1205 1216 storage->ancestorStorage, 1206 propertyIndex, 1217 propertyIndex, 1207 1218 &emptyProperty); 1208 1219 } … … 1216 1227 * Internal Method 1217 1228 * 1218 * Case insensitive comparaison of StgProperty.name by first considering 1229 * Case insensitive comparaison of StgProperty.name by first considering 1219 1230 * their size. 1220 1231 * … … 1229 1240 LONG diff = lstrlenW(newProperty) - lstrlenW(currentProperty); 1230 1241 1231 if (diff == 0) 1232 { 1233 /* 1242 if (diff == 0) 1243 { 1244 /* 1234 1245 * We compare the string themselves only when they are of the same lenght 1235 1246 */ … … 1237 1248 } 1238 1249 1239 return diff; 1250 return diff; 1240 1251 } 1241 1252 … … 1249 1260 StorageImpl *storage, 1250 1261 ULONG newPropertyIndex, 1251 StgProperty newProperty) 1262 StgProperty newProperty) 1252 1263 { 1253 1264 StgProperty currentProperty; … … 1262 1273 if (currentProperty.dirProperty != PROPERTY_NULL) 1263 1274 { 1264 /* 1275 /* 1265 1276 * The root storage contains some element, therefore, start the research 1266 1277 * for the appropriate location. … … 1275 1286 1276 1287 /* 1277 * Read 1288 * Read 1278 1289 */ 1279 1290 StorageImpl_ReadProperty(storage->ancestorStorage, … … 1288 1299 { 1289 1300 LONG diff = propertyNameCmp( newProperty.name, currentProperty.name); 1290 1301 1291 1302 if (diff < 0) 1292 1303 { … … 1327 1338 else 1328 1339 { 1329 1330 1331 1332 1333 1340 /* 1341 * Trying to insert an item with the same name in the 1342 * subtree structure. 1343 */ 1344 assert(FALSE); 1334 1345 } 1335 1346 … … 1340 1351 else 1341 1352 { 1342 /* 1353 /* 1343 1354 * The root storage is empty, link the new property to it's dir property 1344 1355 */ … … 1350 1361 } 1351 1362 1352 1363 1353 1364 /************************************************************************* 1354 1365 * CopyTo (IStorage) 1355 1366 */ 1356 HRESULT WINAPI StorageImpl_CopyTo( 1367 HRESULT WINAPI StorageImpl_CopyTo( 1357 1368 IStorage* iface, 1358 DWORD ciidExclude, /* [in] */ 1359 const IID* rgiidExclude, /* [size_is][unique][in] */ 1360 SNB snbExclude, /* [unique][in] */ 1361 IStorage* pstgDest) /* [unique][in] */ 1369 DWORD ciidExclude, /* [in] */ 1370 const IID* rgiidExclude, /* [size_is][unique][in] */ 1371 SNB snbExclude, /* [unique][in] */ 1372 IStorage* pstgDest) /* [unique][in] */ 1362 1373 { 1363 1374 IEnumSTATSTG *elements = 0; … … 1370 1381 FIXME("Exclude option not implemented\n"); 1371 1382 1372 TRACE("(%p, %ld, %p, %p, %p)\n", 1373 iface, ciidExclude, rgiidExclude, 1374 1383 TRACE("(%p, %ld, %p, %p, %p)\n", 1384 iface, ciidExclude, rgiidExclude, 1385 snbExclude, pstgDest); 1375 1386 1376 1387 /* … … 1380 1391 return STG_E_INVALIDPOINTER; 1381 1392 1382 /* 1393 /* 1383 1394 * Enumerate the elements 1384 1395 */ … … 1393 1404 IStorage_Stat( iface, &curElement, STATFLAG_NONAME); 1394 1405 IStorage_SetClass( pstgDest, &curElement.clsid ); 1395 1406 1396 1407 do 1397 1408 { … … 1413 1424 */ 1414 1425 hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL, 1415 1416 1426 STGM_READ|STGM_SHARE_EXCLUSIVE, 1427 NULL, 0, &pstgChild ); 1417 1428 1418 1429 if (hr != S_OK) … … 1425 1436 if (pstgChild == pstgDest) 1426 1437 { 1427 1428 1429 1438 IEnumSTATSTG_Release(elements); 1439 1440 return STG_E_ACCESSDENIED; 1430 1441 } 1431 1442 1432 1443 /* 1433 1444 * create a new storage in destination storage … … 1435 1446 hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName, 1436 1447 STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE, 1437 1448 0, 0, 1438 1449 &pstgTmp ); 1439 1450 /* … … 1446 1457 NULL, 0, &pstgTmp ); 1447 1458 } 1448 1459 1449 1460 if (hr != S_OK) 1450 1461 break; 1451 1462 1452 1463 1453 1464 /* 1454 1465 * do the copy recursively … … 1456 1467 hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude, 1457 1468 snbExclude, pstgTmp ); 1458 1469 1459 1470 IStorage_Release( pstgTmp ); 1460 1471 IStorage_Release( pstgChild ); … … 1477 1488 */ 1478 1489 hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL, 1479 1480 1490 STGM_READ|STGM_SHARE_EXCLUSIVE, 1491 0, &pstrChild ); 1481 1492 1482 1493 if (hr != S_OK) … … 1492 1503 */ 1493 1504 IStream_SetSize(pstrTmp, strStat.cbSize); 1494 1505 1495 1506 /* 1496 1507 * do the copy … … 1498 1509 hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize, 1499 1510 NULL, NULL ); 1500 1511 1501 1512 IStream_Release( pstrTmp ); 1502 1513 IStream_Release( pstrChild ); … … 1513 1524 */ 1514 1525 IEnumSTATSTG_Release(elements); 1515 1526 1516 1527 return hr; 1517 1528 } 1518 1529 1519 1530 /************************************************************************* 1520 1531 * MoveElementTo (IStorage) 1521 1532 */ 1522 HRESULT WINAPI StorageImpl_MoveElementTo( 1533 HRESULT WINAPI StorageImpl_MoveElementTo( 1523 1534 IStorage* iface, 1524 const OLECHAR *pwcsName, /* [string][in] */ 1525 IStorage *pstgDest, /* [unique][in] */ 1526 const OLECHAR *pwcsNewName,/* [string][in] */ 1527 DWORD grfFlags) /* [in] */ 1535 const OLECHAR *pwcsName, /* [string][in] */ 1536 IStorage *pstgDest, /* [unique][in] */ 1537 const OLECHAR *pwcsNewName,/* [string][in] */ 1538 DWORD grfFlags) /* [in] */ 1528 1539 { 1529 1540 FIXME("not implemented!\n"); 1530 1541 return E_NOTIMPL; 1531 1542 } 1532 1543 1533 1544 /************************************************************************* 1534 1545 * Commit (IStorage) 1535 1546 */ 1536 HRESULT WINAPI StorageImpl_Commit( 1547 HRESULT WINAPI StorageImpl_Commit( 1537 1548 IStorage* iface, 1538 DWORD grfCommitFlags)/* [in] */ 1549 DWORD grfCommitFlags)/* [in] */ 1539 1550 { 1540 1551 FIXME("(%ld): stub!\n", grfCommitFlags); 1541 1552 return S_OK; 1542 1553 } 1543 1554 1544 1555 /************************************************************************* 1545 1556 * Revert (IStorage) 1546 1557 */ 1547 HRESULT WINAPI StorageImpl_Revert( 1558 HRESULT WINAPI StorageImpl_Revert( 1548 1559 IStorage* iface) 1549 1560 { … … 1555 1566 * DestroyElement (IStorage) 1556 1567 * 1557 * Stategy: This implementation is build this way for simplicity not for speed. 1568 * Stategy: This implementation is build this way for simplicity not for speed. 1558 1569 * I always delete the top most element of the enumeration and adjust 1559 * the deleted element pointer all the time. This takes longer to 1560 * do but allow to reinvoke DestroyElement whenever we encounter a 1570 * the deleted element pointer all the time. This takes longer to 1571 * do but allow to reinvoke DestroyElement whenever we encounter a 1561 1572 * storage object. The optimisation reside in the usage of another 1562 * enumeration stategy that would give all the leaves of a storage 1573 * enumeration stategy that would give all the leaves of a storage 1563 1574 * first. (postfix order) 1564 1575 */ 1565 HRESULT WINAPI StorageImpl_DestroyElement( 1576 HRESULT WINAPI StorageImpl_DestroyElement( 1566 1577 IStorage* iface, 1567 const OLECHAR *pwcsName)/* [string][in] */ 1578 const OLECHAR *pwcsName)/* [string][in] */ 1568 1579 { 1569 1580 StorageImpl* const This=(StorageImpl*)iface; … … 1578 1589 ULONG parentPropertyId; 1579 1590 1580 TRACE("(%p, %s)\n", 1581 1591 TRACE("(%p, %s)\n", 1592 iface, debugstr_w(pwcsName)); 1582 1593 1583 1594 /* 1584 1595 * Perform a sanity check on the parameters. 1585 1596 */ 1586 if (pwcsName==NULL) 1597 if (pwcsName==NULL) 1587 1598 return STG_E_INVALIDPOINTER; 1588 1599 1589 1600 /* 1590 1601 * Create a property enumeration to search the property with the given name 1591 1602 */ 1592 1603 propertyEnumeration = IEnumSTATSTGImpl_Construct( 1593 This->ancestorStorage, 1604 This->ancestorStorage, 1594 1605 This->rootPropertySetIndex); 1595 1606 1596 1607 foundPropertyIndexToDelete = IEnumSTATSTGImpl_FindProperty( 1597 1608 propertyEnumeration, … … 1601 1612 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 1602 1613 1603 if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 1614 if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 1604 1615 { 1605 1616 return STG_E_FILENOTFOUND; 1606 1617 } 1607 1618 1608 /* 1609 * Find the parent property of the property to delete (the one that 1610 * link to it). If This->dirProperty == foundPropertyIndexToDelete, 1619 /* 1620 * Find the parent property of the property to delete (the one that 1621 * link to it). If This->dirProperty == foundPropertyIndexToDelete, 1611 1622 * the parent is This. Otherwise, the parent is one of it's sibling... 1612 1623 */ 1613 1624 1614 /* 1625 /* 1615 1626 * First, read This's StgProperty.. 1616 1627 */ 1617 res = StorageImpl_ReadProperty( 1628 res = StorageImpl_ReadProperty( 1618 1629 This->ancestorStorage, 1619 1630 This->rootPropertySetIndex, … … 1622 1633 assert(res==TRUE); 1623 1634 1624 /* 1635 /* 1625 1636 * Second, check to see if by any chance the actual storage (This) is not 1626 1637 * the parent of the property to delete... We never know... … … 1628 1639 if ( parentProperty.dirProperty == foundPropertyIndexToDelete ) 1629 1640 { 1630 /* 1641 /* 1631 1642 * Set data as it would have been done in the else part... 1632 1643 */ … … 1634 1645 parentPropertyId = This->rootPropertySetIndex; 1635 1646 } 1636 else 1637 { 1638 /* 1639 * Create a property enumeration to search the parent properties, and 1647 else 1648 { 1649 /* 1650 * Create a property enumeration to search the parent properties, and 1640 1651 * delete it once done. 1641 1652 */ … … 1643 1654 1644 1655 propertyEnumeration2 = IEnumSTATSTGImpl_Construct( 1645 This->ancestorStorage, 1656 This->ancestorStorage, 1646 1657 This->rootPropertySetIndex); 1647 1658 1648 1659 typeOfRelation = IEnumSTATSTGImpl_FindParentProperty( 1649 1660 propertyEnumeration2, … … 1655 1666 } 1656 1667 1657 if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 1668 if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 1658 1669 { 1659 1670 hr = deleteStorageProperty( 1660 This, 1671 This, 1661 1672 foundPropertyIndexToDelete, 1662 1673 propertyToDelete); 1663 } 1674 } 1664 1675 else if ( propertyToDelete.propertyType == PROPTYPE_STREAM ) 1665 1676 { 1666 1677 hr = deleteStreamProperty( 1667 This, 1678 This, 1668 1679 foundPropertyIndexToDelete, 1669 1680 propertyToDelete); 1670 1681 } 1671 1682 1672 if (hr!=S_OK) 1683 if (hr!=S_OK) 1673 1684 return hr; 1674 1685 … … 1678 1689 hr = adjustPropertyChain( 1679 1690 This, 1680 propertyToDelete, 1691 propertyToDelete, 1681 1692 parentProperty, 1682 1693 parentPropertyId, … … 1722 1733 } 1723 1734 1724 /* 1735 /* 1725 1736 * Enumerate the elements 1726 1737 */ … … 1736 1747 { 1737 1748 destroyHr = StorageImpl_DestroyElement( 1738 (IStorage*)childStorage, 1749 (IStorage*)childStorage, 1739 1750 (OLECHAR*)currentElement.pwcsName); 1740 1751 … … 1761 1772 IStorage_Release(childStorage); 1762 1773 IEnumSTATSTG_Release(elements); 1763 1774 1764 1775 return destroyHr; 1765 1776 } … … 1791 1802 0, 1792 1803 &pis); 1793 1804 1794 1805 if (hr!=S_OK) 1795 1806 { … … 1797 1808 } 1798 1809 1799 /* 1800 * Zap the stream 1801 */ 1802 hr = IStream_SetSize(pis, size); 1810 /* 1811 * Zap the stream 1812 */ 1813 hr = IStream_SetSize(pis, size); 1803 1814 1804 1815 if(hr != S_OK) … … 1812 1823 IStream_Release(pis); 1813 1824 1814 /* 1825 /* 1815 1826 * Invalidate the property by zeroing it's name member. 1816 1827 */ 1817 1828 propertyToDelete.sizeOfNameString = 0; 1818 1829 1819 /* 1830 /* 1820 1831 * Here we should re-read the property so we get the updated pointer 1821 1832 * but since we are here to zap it, I don't do it... 1822 1833 */ 1823 1834 StorageImpl_WriteProperty( 1824 parentStorage->ancestorStorage, 1835 parentStorage->ancestorStorage, 1825 1836 indexOfPropertyToDelete, 1826 1837 &propertyToDelete); … … 1851 1862 res = StorageImpl_ReadProperty( 1852 1863 storage->ancestorStorage, 1853 storePropertyIndex, 1864 storePropertyIndex, 1854 1865 &storeProperty); 1855 1866 … … 1865 1876 return findPlaceholder( 1866 1877 storage, 1867 propertyIndexToStore, 1878 propertyIndexToStore, 1868 1879 storeProperty.previousProperty, 1869 1880 typeOfRelation); … … 1880 1891 return findPlaceholder( 1881 1892 storage, 1882 propertyIndexToStore, 1893 propertyIndexToStore, 1883 1894 storeProperty.nextProperty, 1884 1895 typeOfRelation); … … 1888 1899 storeProperty.nextProperty = propertyIndexToStore; 1889 1900 } 1890 } 1901 } 1891 1902 else if (typeOfRelation == PROPERTY_RELATION_DIR) 1892 1903 { … … 1895 1906 return findPlaceholder( 1896 1907 storage, 1897 propertyIndexToStore, 1908 propertyIndexToStore, 1898 1909 storeProperty.dirProperty, 1899 1910 typeOfRelation); … … 1907 1918 hr = StorageImpl_WriteProperty( 1908 1919 storage->ancestorStorage, 1909 storePropertyIndex, 1920 storePropertyIndex, 1910 1921 &storeProperty); 1911 1922 … … 1922 1933 * Internal Method 1923 1934 * 1924 * This method takes the previous and the next property link of a property 1935 * This method takes the previous and the next property link of a property 1925 1936 * to be deleted and find them a place in the Storage. 1926 1937 */ 1927 static HRESULT adjustPropertyChain( 1938 static HRESULT adjustPropertyChain( 1928 1939 StorageImpl *This, 1929 1940 StgProperty propertyToDelete, … … 1939 1950 HRESULT hr = S_OK; 1940 1951 BOOL res = TRUE; 1941 1942 if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 1943 { 1944 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1945 { 1946 /* 1952 1953 if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 1954 { 1955 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1956 { 1957 /* 1947 1958 * Set the parent previous to the property to delete previous 1948 1959 */ 1949 1960 newLinkProperty = propertyToDelete.previousProperty; 1950 1961 1951 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1962 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1952 1963 { 1953 1964 /* 1954 * We also need to find a storage for the other link, setup variables 1965 * We also need to find a storage for the other link, setup variables 1955 1966 * to do this at the end... 1956 */ 1967 */ 1957 1968 needToFindAPlaceholder = TRUE; 1958 1969 storeNode = propertyToDelete.previousProperty; … … 1960 1971 relationType = PROPERTY_RELATION_NEXT; 1961 1972 } 1962 } 1963 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1964 { 1965 /* 1973 } 1974 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1975 { 1976 /* 1966 1977 * Set the parent previous to the property to delete next 1967 1978 */ 1968 1979 newLinkProperty = propertyToDelete.nextProperty; 1969 1980 } 1970 1971 /* 1981 1982 /* 1972 1983 * Link it for real... 1973 */ 1984 */ 1974 1985 parentProperty.previousProperty = newLinkProperty; 1975 1976 } 1977 else if (typeOfRelation == PROPERTY_RELATION_NEXT) 1978 { 1979 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1980 { 1981 /* 1986 1987 } 1988 else if (typeOfRelation == PROPERTY_RELATION_NEXT) 1989 { 1990 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1991 { 1992 /* 1982 1993 * Set the parent next to the property to delete next previous 1983 1994 */ 1984 1995 newLinkProperty = propertyToDelete.previousProperty; 1985 1986 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1996 1997 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1987 1998 { 1988 1999 /* 1989 * We also need to find a storage for the other link, setup variables 2000 * We also need to find a storage for the other link, setup variables 1990 2001 * to do this at the end... 1991 */ 2002 */ 1992 2003 needToFindAPlaceholder = TRUE; 1993 2004 storeNode = propertyToDelete.previousProperty; … … 1995 2006 relationType = PROPERTY_RELATION_NEXT; 1996 2007 } 1997 } 1998 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1999 { 2000 /* 2008 } 2009 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 2010 { 2011 /* 2001 2012 * Set the parent next to the property to delete next 2002 2013 */ … … 2004 2015 } 2005 2016 2006 /* 2017 /* 2007 2018 * Link it for real... 2008 */ 2019 */ 2009 2020 parentProperty.nextProperty = newLinkProperty; 2010 } 2021 } 2011 2022 else /* (typeOfRelation == PROPERTY_RELATION_DIR) */ 2012 2023 { 2013 if (propertyToDelete.previousProperty != PROPERTY_NULL) 2014 { 2015 /* 2024 if (propertyToDelete.previousProperty != PROPERTY_NULL) 2025 { 2026 /* 2016 2027 * Set the parent dir to the property to delete previous 2017 2028 */ 2018 2029 newLinkProperty = propertyToDelete.previousProperty; 2019 2030 2020 if (propertyToDelete.nextProperty != PROPERTY_NULL) 2031 if (propertyToDelete.nextProperty != PROPERTY_NULL) 2021 2032 { 2022 2033 /* 2023 * We also need to find a storage for the other link, setup variables 2034 * We also need to find a storage for the other link, setup variables 2024 2035 * to do this at the end... 2025 */ 2036 */ 2026 2037 needToFindAPlaceholder = TRUE; 2027 2038 storeNode = propertyToDelete.previousProperty; … … 2029 2040 relationType = PROPERTY_RELATION_NEXT; 2030 2041 } 2031 } 2032 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 2033 { 2034 /* 2042 } 2043 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 2044 { 2045 /* 2035 2046 * Set the parent dir to the property to delete next 2036 2047 */ … … 2038 2049 } 2039 2050 2040 /* 2051 /* 2041 2052 * Link it for real... 2042 */ 2053 */ 2043 2054 parentProperty.dirProperty = newLinkProperty; 2044 2055 } 2045 2056 2046 /* 2047 * Write back the parent property 2057 /* 2058 * Write back the parent property 2048 2059 */ 2049 2060 res = StorageImpl_WriteProperty( 2050 This->ancestorStorage, 2061 This->ancestorStorage, 2051 2062 parentPropertyId, 2052 2063 &parentProperty); … … 2057 2068 2058 2069 /* 2059 * If a placeholder is required for the other link, then, find one and 2070 * If a placeholder is required for the other link, then, find one and 2060 2071 * get out of here... 2061 2072 */ 2062 if (needToFindAPlaceholder) 2073 if (needToFindAPlaceholder) 2063 2074 { 2064 2075 hr = findPlaceholder( 2065 This, 2066 toStoreNode, 2076 This, 2077 toStoreNode, 2067 2078 storeNode, 2068 2079 relationType); … … 2076 2087 * SetElementTimes (IStorage) 2077 2088 */ 2078 HRESULT WINAPI StorageImpl_SetElementTimes( 2089 HRESULT WINAPI StorageImpl_SetElementTimes( 2079 2090 IStorage* iface, 2080 const OLECHAR *pwcsName,/* [string][in] */ 2081 const FILETIME *pctime, /* [in] */ 2082 const FILETIME *patime, /* [in] */ 2083 const FILETIME *pmtime) /* [in] */ 2091 const OLECHAR *pwcsName,/* [string][in] */ 2092 const FILETIME *pctime, /* [in] */ 2093 const FILETIME *patime, /* [in] */ 2094 const FILETIME *pmtime) /* [in] */ 2084 2095 { 2085 2096 FIXME("not implemented!\n"); … … 2090 2101 * SetStateBits (IStorage) 2091 2102 */ 2092 HRESULT WINAPI StorageImpl_SetStateBits( 2103 HRESULT WINAPI StorageImpl_SetStateBits( 2093 2104 IStorage* iface, 2094 DWORD grfStateBits,/* [in] */ 2095 DWORD grfMask) /* [in] */ 2105 DWORD grfStateBits,/* [in] */ 2106 DWORD grfMask) /* [in] */ 2096 2107 { 2097 2108 FIXME("not implemented!\n"); … … 2111 2122 BOOL readSuccessful; 2112 2123 ULONG currentPropertyIndex; 2113 2124 2114 2125 if ( FAILED( validateSTGM(openFlags) )) 2115 2126 return STG_E_INVALIDFLAG; 2116 2127 2117 2128 memset(This, 0, sizeof(StorageImpl)); 2118 2129 2119 2130 /* 2120 2131 * Initialize the virtual fgunction table. … … 2122 2133 ICOM_VTBL(This) = &Storage32Impl_Vtbl; 2123 2134 This->v_destructor = &StorageImpl_Destroy; 2124 2135 2125 2136 /* 2126 2137 * This is the top-level storage so initialize the ancester pointer … … 2128 2139 */ 2129 2140 This->ancestorStorage = This; 2130 2141 2131 2142 /* 2132 2143 * Initialize the physical support of the storage. 2133 2144 */ 2134 2145 This->hFile = hFile; 2135 2146 2136 2147 /* 2137 2148 * Initialize the big block cache. … … 2147 2158 if (This->bigBlockFile == 0) 2148 2159 return E_FAIL; 2149 2160 2150 2161 if (fileCreate) 2151 2162 { … … 2159 2170 * - There is no small block depot 2160 2171 */ 2161 memset( This->bigBlockDepotStart, 2162 BLOCK_UNUSED, 2172 memset( This->bigBlockDepotStart, 2173 BLOCK_UNUSED, 2163 2174 sizeof(This->bigBlockDepotStart)); 2164 2175 … … 2214 2225 */ 2215 2226 This->prevFreeBlock = 0; 2216 2227 2217 2228 /* 2218 2229 * Create the block chain abstractions. 2219 2230 */ 2220 This->rootBlockChain = 2231 This->rootBlockChain = 2221 2232 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL); 2222 2233 2223 2234 This->smallBlockDepotChain = BlockChainStream_Construct( 2224 This, 2225 &This->smallBlockDepotStart, 2235 This, 2236 &This->smallBlockDepotStart, 2226 2237 PROPERTY_NULL); 2227 2238 2228 2239 /* 2229 * Write the root property 2240 * Write the root property 2230 2241 */ 2231 2242 if (fileCreate) … … 2254 2265 */ 2255 2266 currentPropertyIndex = 0; 2256 2267 2257 2268 do 2258 2269 { 2259 2270 readSuccessful = StorageImpl_ReadProperty( 2260 This, 2261 currentPropertyIndex, 2271 This, 2272 currentPropertyIndex, 2262 2273 ¤tProperty); 2263 2274 2264 2275 if (readSuccessful) 2265 2276 { … … 2272 2283 2273 2284 currentPropertyIndex++; 2274 2285 2275 2286 } while (readSuccessful && (This->rootPropertySetIndex == PROPERTY_NULL) ); 2276 2287 2277 2288 if (!readSuccessful) 2278 2289 { … … 2285 2296 */ 2286 2297 This->smallBlockRootChain = BlockChainStream_Construct( 2287 This, 2288 NULL, 2298 This, 2299 NULL, 2289 2300 This->rootPropertySetIndex); 2290 2301 2291 2302 return hr; 2292 2303 } … … 2821 2832 2822 2833 StorageUtl_ReadWord( 2823 headerBigBlock, 2824 OFFSET_BIGBLOCKSIZEBITS, 2834 headerBigBlock, 2835 OFFSET_BIGBLOCKSIZEBITS, 2825 2836 &This->bigBlockSizeBits); 2826 2837 2827 2838 StorageUtl_ReadWord( 2828 headerBigBlock, 2829 OFFSET_SMALLBLOCKSIZEBITS, 2839 headerBigBlock, 2840 OFFSET_SMALLBLOCKSIZEBITS, 2830 2841 &This->smallBlockSizeBits); 2831 2842 2832 2843 StorageUtl_ReadDWord( 2833 headerBigBlock, 2834 OFFSET_BBDEPOTCOUNT, 2844 headerBigBlock, 2845 OFFSET_BBDEPOTCOUNT, 2835 2846 &This->bigBlockDepotCount); 2836 2847 2837 2848 StorageUtl_ReadDWord( 2838 headerBigBlock, 2839 OFFSET_ROOTSTARTBLOCK, 2849 headerBigBlock, 2850 OFFSET_ROOTSTARTBLOCK, 2840 2851 &This->rootStartBlock); 2841 2852 2842 2853 StorageUtl_ReadDWord( 2843 headerBigBlock, 2844 OFFSET_SBDEPOTSTART, 2854 headerBigBlock, 2855 OFFSET_SBDEPOTSTART, 2845 2856 &This->smallBlockDepotStart); 2846 2857 2858 StorageUtl_ReadDWord( 2859 headerBigBlock, 2860 OFFSET_EXTBBDEPOTSTART, 2861 &This->extBigBlockDepotStart); 2862 2847 2863 StorageUtl_ReadDWord( 2848 headerBigBlock, 2849 OFFSET_EXTBBDEPOTSTART, 2850 &This->extBigBlockDepotStart); 2851 2852 StorageUtl_ReadDWord( 2853 headerBigBlock, 2854 OFFSET_EXTBBDEPOTCOUNT, 2864 headerBigBlock, 2865 OFFSET_EXTBBDEPOTCOUNT, 2855 2866 &This->extBigBlockDepotCount); 2856 2867 2857 2868 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 2858 2869 { 2859 2870 StorageUtl_ReadDWord( 2860 headerBigBlock, 2871 headerBigBlock, 2861 2872 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 2862 2873 &(This->bigBlockDepotStart[index])); 2863 2874 } 2864 2875 2865 2876 /* 2866 2877 * Make the bitwise arithmetic to get the size of the blocks in bytes. … … 2876 2887 This->smallBlockSize = 0x000000001 >> (DWORD)This->smallBlockSizeBits; 2877 2888 } 2878 2879 /* 2880 * Right now, the code is making some assumptions about the size of the 2889 2890 /* 2891 * Right now, the code is making some assumptions about the size of the 2881 2892 * blocks, just make sure they are what we're expecting. 2882 2893 */ 2883 assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 2894 assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 2884 2895 (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE)); 2885 2896 2886 2897 /* 2887 2898 * Release the block. … … 2891 2902 hr = S_OK; 2892 2903 } 2893 2904 2894 2905 return hr; 2895 2906 } … … 2911 2922 */ 2912 2923 success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock); 2913 2924 2914 2925 /* 2915 2926 * If the block read failed, the file is probably new. … … 2921 2932 */ 2922 2933 memset(headerBigBlock, 0, BIG_BLOCK_SIZE); 2923 2934 2924 2935 /* 2925 2936 * Initialize the magic number. 2926 2937 */ 2927 2938 memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic)); 2928 2939 2929 2940 /* 2930 2941 * And a bunch of things we don't know what they mean … … 2936 2947 StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001); 2937 2948 } 2938 2949 2939 2950 /* 2940 2951 * Write the information to the header. … … 2943 2954 { 2944 2955 StorageUtl_WriteWord( 2945 headerBigBlock, 2946 OFFSET_BIGBLOCKSIZEBITS, 2956 headerBigBlock, 2957 OFFSET_BIGBLOCKSIZEBITS, 2947 2958 This->bigBlockSizeBits); 2948 2959 2949 2960 StorageUtl_WriteWord( 2950 headerBigBlock, 2951 OFFSET_SMALLBLOCKSIZEBITS, 2961 headerBigBlock, 2962 OFFSET_SMALLBLOCKSIZEBITS, 2952 2963 This->smallBlockSizeBits); 2953 2964 2954 2965 StorageUtl_WriteDWord( 2955 headerBigBlock, 2956 OFFSET_BBDEPOTCOUNT, 2966 headerBigBlock, 2967 OFFSET_BBDEPOTCOUNT, 2957 2968 This->bigBlockDepotCount); 2958 2969 2959 2970 StorageUtl_WriteDWord( 2960 headerBigBlock, 2961 OFFSET_ROOTSTARTBLOCK, 2971 headerBigBlock, 2972 OFFSET_ROOTSTARTBLOCK, 2962 2973 This->rootStartBlock); 2963 2974 2964 2975 StorageUtl_WriteDWord( 2965 headerBigBlock, 2966 OFFSET_SBDEPOTSTART, 2976 headerBigBlock, 2977 OFFSET_SBDEPOTSTART, 2967 2978 This->smallBlockDepotStart); 2968 2979 2969 2980 StorageUtl_WriteDWord( 2970 headerBigBlock, 2971 OFFSET_EXTBBDEPOTSTART, 2981 headerBigBlock, 2982 OFFSET_EXTBBDEPOTSTART, 2972 2983 This->extBigBlockDepotStart); 2973 2984 2974 2985 StorageUtl_WriteDWord( 2975 headerBigBlock, 2976 OFFSET_EXTBBDEPOTCOUNT, 2986 headerBigBlock, 2987 OFFSET_EXTBBDEPOTCOUNT, 2977 2988 This->extBigBlockDepotCount); 2978 2989 … … 2980 2991 { 2981 2992 StorageUtl_WriteDWord( 2982 headerBigBlock, 2993 headerBigBlock, 2983 2994 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 2984 2995 (This->bigBlockDepotStart[index])); 2985 2996 } 2986 2997 } 2987 2998 2988 2999 /* 2989 3000 * Write the big block back to the file. … … 3009 3020 offsetInPropSet.s.HighPart = 0; 3010 3021 offsetInPropSet.s.LowPart = index * PROPSET_BLOCK_SIZE; 3011 3022 3012 3023 readSuccessful = BlockChainStream_ReadAt( 3013 3024 This->rootBlockChain, … … 3016 3027 currentProperty, 3017 3028 &bytesRead); 3018 3029 3019 3030 if (readSuccessful) 3020 3031 { 3021 3032 memset(buffer->name, 0, sizeof(buffer->name)); 3022 3033 memcpy( 3023 buffer->name, 3024 currentProperty+OFFSET_PS_NAME, 3034 buffer->name, 3035 currentProperty+OFFSET_PS_NAME, 3025 3036 PROPERTY_NAME_BUFFER_LEN ); 3026 3037 3027 3038 memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1); 3028 3039 3029 3040 StorageUtl_ReadWord( 3030 currentProperty, 3031 OFFSET_PS_NAMELENGTH, 3041 currentProperty, 3042 OFFSET_PS_NAMELENGTH, 3032 3043 &buffer->sizeOfNameString); 3033 3044 3034 3045 StorageUtl_ReadDWord( 3035 currentProperty, 3036 OFFSET_PS_PREVIOUSPROP, 3046 currentProperty, 3047 OFFSET_PS_PREVIOUSPROP, 3037 3048 &buffer->previousProperty); 3038 3049 3039 3050 StorageUtl_ReadDWord( 3040 currentProperty, 3041 OFFSET_PS_NEXTPROP, 3051 currentProperty, 3052 OFFSET_PS_NEXTPROP, 3042 3053 &buffer->nextProperty); 3043 3054 3044 3055 StorageUtl_ReadDWord( 3045 currentProperty, 3046 OFFSET_PS_DIRPROP, 3056 currentProperty, 3057 OFFSET_PS_DIRPROP, 3047 3058 &buffer->dirProperty); 3048 3059 3049 3060 StorageUtl_ReadGUID( 3050 currentProperty, 3051 OFFSET_PS_GUID, 3061 currentProperty, 3062 OFFSET_PS_GUID, 3052 3063 &buffer->propertyUniqueID); 3053 3064 3054 3065 StorageUtl_ReadDWord( 3055 currentProperty, 3056 OFFSET_PS_TSS1, 3066 currentProperty, 3067 OFFSET_PS_TSS1, 3057 3068 &buffer->timeStampS1); 3058 3069 3059 3070 StorageUtl_ReadDWord( 3060 currentProperty, 3061 OFFSET_PS_TSD1, 3071 currentProperty, 3072 OFFSET_PS_TSD1, 3062 3073 &buffer->timeStampD1); 3063 3074 3064 3075 StorageUtl_ReadDWord( 3065 currentProperty, 3066 OFFSET_PS_TSS2, 3076 currentProperty, 3077 OFFSET_PS_TSS2, 3067 3078 &buffer->timeStampS2); 3068 3079 3069 3080 StorageUtl_ReadDWord( 3070 currentProperty, 3071 OFFSET_PS_TSD2, 3081 currentProperty, 3082 OFFSET_PS_TSD2, 3072 3083 &buffer->timeStampD2); 3073 3084 3074 3085 StorageUtl_ReadDWord( 3075 currentProperty, 3076 OFFSET_PS_STARTBLOCK, 3086 currentProperty, 3087 OFFSET_PS_STARTBLOCK, 3077 3088 &buffer->startingBlock); 3078 3089 3079 3090 StorageUtl_ReadDWord( 3080 currentProperty, 3081 OFFSET_PS_SIZE, 3091 currentProperty, 3092 OFFSET_PS_SIZE, 3082 3093 &buffer->size.s.LowPart); 3083 3094 … … 3107 3118 3108 3119 memcpy( 3109 currentProperty + OFFSET_PS_NAME, 3110 buffer->name, 3120 currentProperty + OFFSET_PS_NAME, 3121 buffer->name, 3111 3122 PROPERTY_NAME_BUFFER_LEN ); 3112 3123 … … 3114 3125 3115 3126 StorageUtl_WriteWord( 3116 currentProperty, 3117 OFFSET_PS_NAMELENGTH, 3127 currentProperty, 3128 OFFSET_PS_NAMELENGTH, 3118 3129 buffer->sizeOfNameString); 3119 3130 3120 3131 StorageUtl_WriteDWord( 3121 currentProperty, 3122 OFFSET_PS_PREVIOUSPROP, 3132 currentProperty, 3133 OFFSET_PS_PREVIOUSPROP, 3123 3134 buffer->previousProperty); 3124 3135 3125 3136 StorageUtl_WriteDWord( 3126 currentProperty, 3127 OFFSET_PS_NEXTPROP, 3137 currentProperty, 3138 OFFSET_PS_NEXTPROP, 3128 3139 buffer->nextProperty); 3129 3140 3130 3141 StorageUtl_WriteDWord( 3131 currentProperty, 3132 OFFSET_PS_DIRPROP, 3142 currentProperty, 3143 OFFSET_PS_DIRPROP, 3133 3144 buffer->dirProperty); 3134 3145 3135 3146 StorageUtl_WriteGUID( 3136 currentProperty, 3137 OFFSET_PS_GUID, 3147 currentProperty, 3148 OFFSET_PS_GUID, 3138 3149 &buffer->propertyUniqueID); 3139 3150 3140 3151 StorageUtl_WriteDWord( 3141 currentProperty, 3142 OFFSET_PS_TSS1, 3152 currentProperty, 3153 OFFSET_PS_TSS1, 3143 3154 buffer->timeStampS1); 3144 3155 3145 3156 StorageUtl_WriteDWord( 3146 currentProperty, 3147 OFFSET_PS_TSD1, 3157 currentProperty, 3158 OFFSET_PS_TSD1, 3148 3159 buffer->timeStampD1); 3149 3160 3150 3161 StorageUtl_WriteDWord( 3151 currentProperty, 3152 OFFSET_PS_TSS2, 3162 currentProperty, 3163 OFFSET_PS_TSS2, 3153 3164 buffer->timeStampS2); 3154 3165 3155 3166 StorageUtl_WriteDWord( 3156 currentProperty, 3157 OFFSET_PS_TSD2, 3167 currentProperty, 3168 OFFSET_PS_TSD2, 3158 3169 buffer->timeStampD2); 3159 3170 3160 3171 StorageUtl_WriteDWord( 3161 currentProperty, 3162 OFFSET_PS_STARTBLOCK, 3172 currentProperty, 3173 OFFSET_PS_STARTBLOCK, 3163 3174 buffer->startingBlock); 3164 3175 3165 3176 StorageUtl_WriteDWord( 3166 currentProperty, 3167 OFFSET_PS_SIZE, 3177 currentProperty, 3178 OFFSET_PS_SIZE, 3168 3179 buffer->size.s.LowPart); 3169 3180 … … 3211 3222 3212 3223 StorageImpl_ReleaseBigBlock(This, bigBlockBuffer); 3213 3224 3214 3225 return TRUE; 3215 3226 } 3216 3227 3217 3228 return FALSE; 3218 3229 } … … 3344 3355 3345 3356 StorageInternalImpl* StorageInternalImpl_Construct( 3346 StorageImpl* ancestorStorage, 3357 StorageImpl* ancestorStorage, 3347 3358 ULONG rootPropertyIndex) 3348 3359 { … … 3395 3406 ** does nothing. 3396 3407 */ 3397 HRESULT WINAPI StorageInternalImpl_Commit( 3408 HRESULT WINAPI StorageInternalImpl_Commit( 3398 3409 IStorage* iface, 3399 DWORD grfCommitFlags) /* [in] */ 3410 DWORD grfCommitFlags) /* [in] */ 3400 3411 { 3401 3412 return S_OK; 3402 3413 } 3403 3414 3404 3415 /****************************************************************************** 3405 3416 ** … … 3409 3420 ** does nothing. 3410 3421 */ 3411 HRESULT WINAPI StorageInternalImpl_Revert( 3422 HRESULT WINAPI StorageInternalImpl_Revert( 3412 3423 IStorage* iface) 3413 3424 { … … 3426 3437 3427 3438 newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl)); 3428 3439 3429 3440 if (newEnumeration!=0) 3430 3441 { … … 3434 3445 ICOM_VTBL(newEnumeration) = &IEnumSTATSTGImpl_Vtbl; 3435 3446 newEnumeration->ref = 0; 3436 3447 3437 3448 /* 3438 3449 * We want to nail-down the reference to the storage in case the … … 3441 3452 newEnumeration->parentStorage = parentStorage; 3442 3453 IStorage_AddRef((IStorage*)newEnumeration->parentStorage); 3443 3454 3444 3455 newEnumeration->firstPropertyNode = firstPropertyNode; 3445 3456 3446 3457 /* 3447 3458 * Initialize the search stack … … 3449 3460 newEnumeration->stackSize = 0; 3450 3461 newEnumeration->stackMaxSize = ENUMSTATSGT_SIZE_INCREMENT; 3451 newEnumeration->stackToVisit = 3462 newEnumeration->stackToVisit = 3452 3463 HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG)*ENUMSTATSGT_SIZE_INCREMENT); 3453 3464 3454 3465 /* 3455 3466 * Make sure the current node of the iterator is the first one. … … 3457 3468 IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration); 3458 3469 } 3459 3470 3460 3471 return newEnumeration; 3461 3472 } … … 3489 3500 * Compare the riid with the interface IDs implemented by this object. 3490 3501 */ 3491 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 3502 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 3492 3503 { 3493 3504 *ppvObject = (IEnumSTATSTG*)This; 3494 3505 } 3495 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 3506 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 3496 3507 { 3497 3508 *ppvObject = (IEnumSTATSTG*)This; … … 3512 3523 return S_OK; 3513 3524 } 3514 3525 3515 3526 ULONG WINAPI IEnumSTATSTGImpl_AddRef( 3516 3527 IEnumSTATSTG* iface) … … 3521 3532 return This->ref; 3522 3533 } 3523 3534 3524 3535 ULONG WINAPI IEnumSTATSTGImpl_Release( 3525 3536 IEnumSTATSTG* iface) … … 3560 3571 */ 3561 3572 if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) ) 3562 return E_INVALIDARG; 3563 3573 return E_INVALIDARG; 3574 3564 3575 /* 3565 3576 * To avoid the special case, get another pointer to a ULONG value if … … 3568 3579 if (pceltFetched==0) 3569 3580 pceltFetched = &objectFetched; 3570 3581 3571 3582 /* 3572 3583 * Start the iteration, we will iterate until we hit the end of the … … 3580 3591 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3581 3592 3582 while ( ( *pceltFetched < celt) && 3593 while ( ( *pceltFetched < celt) && 3583 3594 ( currentSearchNode!=PROPERTY_NULL) ) 3584 3595 { 3585 /* 3596 /* 3586 3597 * Remove the top node from the stack 3587 3598 */ … … 3592 3603 */ 3593 3604 StorageImpl_ReadProperty(This->parentStorage, 3594 currentSearchNode, 3605 currentSearchNode, 3595 3606 ¤tProperty); 3596 3607 … … 3601 3612 ¤tProperty, 3602 3613 STATFLAG_DEFAULT); 3603 3614 3604 3615 /* 3605 3616 * Step to the next item in the iteration … … 3625 3636 } 3626 3637 3627 3638 3628 3639 HRESULT WINAPI IEnumSTATSTGImpl_Skip( 3629 3640 IEnumSTATSTG* iface, … … 3641 3652 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3642 3653 3643 while ( (objectFetched < celt) && 3654 while ( (objectFetched < celt) && 3644 3655 (currentSearchNode!=PROPERTY_NULL) ) 3645 3656 { 3646 /* 3657 /* 3647 3658 * Remove the top node from the stack 3648 3659 */ … … 3653 3664 */ 3654 3665 StorageImpl_ReadProperty(This->parentStorage, 3655 currentSearchNode, 3666 currentSearchNode, 3656 3667 ¤tProperty); 3657 3668 3658 3669 /* 3659 3670 * Step to the next item in the iteration … … 3677 3688 return S_FALSE; 3678 3689 } 3679 3690 3680 3691 HRESULT WINAPI IEnumSTATSTGImpl_Reset( 3681 3692 IEnumSTATSTG* iface) … … 3696 3707 readSuccessful = StorageImpl_ReadProperty( 3697 3708 This->parentStorage, 3698 This->firstPropertyNode, 3709 This->firstPropertyNode, 3699 3710 &rootProperty); 3700 3711 … … 3711 3722 return S_OK; 3712 3723 } 3713 3724 3714 3725 HRESULT WINAPI IEnumSTATSTGImpl_Clone( 3715 3726 IEnumSTATSTG* iface, … … 3725 3736 if (ppenum==0) 3726 3737 return E_INVALIDARG; 3727 3738 3728 3739 newClone = IEnumSTATSTGImpl_Construct(This->parentStorage, 3729 3740 This->firstPropertyNode); 3730 3741 3731 3742 3732 3743 /* 3733 3744 * The new clone enumeration must point to the same current node as … … 3736 3747 newClone->stackSize = This->stackSize ; 3737 3748 newClone->stackMaxSize = This->stackMaxSize ; 3738 newClone->stackToVisit = 3749 newClone->stackToVisit = 3739 3750 HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * newClone->stackMaxSize); 3740 3751 3741 3752 memcpy( 3742 newClone->stackToVisit, 3743 This->stackToVisit, 3753 newClone->stackToVisit, 3754 This->stackToVisit, 3744 3755 sizeof(ULONG) * newClone->stackSize); 3745 3756 … … 3757 3768 INT IEnumSTATSTGImpl_FindParentProperty( 3758 3769 IEnumSTATSTGImpl *This, 3759 ULONG childProperty, 3770 ULONG childProperty, 3760 3771 StgProperty *currentProperty, 3761 3772 ULONG *thisNodeId) … … 3775 3786 */ 3776 3787 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3777 3788 3778 3789 3779 3790 while (currentSearchNode!=PROPERTY_NULL) … … 3784 3795 *thisNodeId = currentSearchNode; 3785 3796 3786 /* 3797 /* 3787 3798 * Remove the top node from the stack 3788 3799 */ … … 3794 3805 StorageImpl_ReadProperty( 3795 3806 This->parentStorage, 3796 currentSearchNode, 3807 currentSearchNode, 3797 3808 currentProperty); 3798 3809 3799 3810 if (currentProperty->previousProperty == childProperty) 3800 3811 return PROPERTY_RELATION_PREVIOUS; 3801 3812 3802 else if (currentProperty->nextProperty == childProperty) 3813 else if (currentProperty->nextProperty == childProperty) 3803 3814 return PROPERTY_RELATION_NEXT; 3804 3815 3805 3816 else if (currentProperty->dirProperty == childProperty) 3806 3817 return PROPERTY_RELATION_DIR; 3807 3818 3808 3819 /* 3809 3820 * Push the next search node in the search stack. … … 3834 3845 while (currentSearchNode!=PROPERTY_NULL) 3835 3846 { 3836 /* 3847 /* 3837 3848 * Remove the top node from the stack 3838 3849 */ … … 3843 3854 */ 3844 3855 StorageImpl_ReadProperty(This->parentStorage, 3845 currentSearchNode, 3856 currentSearchNode, 3846 3857 currentProperty); 3847 3858 3848 3859 if ( propertyNameCmp( 3849 (OLECHAR*)currentProperty->name, 3860 (OLECHAR*)currentProperty->name, 3850 3861 (OLECHAR*)lpszPropName) == 0) 3851 3862 return currentSearchNode; … … 3886 3897 3887 3898 This->stackToVisit = HeapReAlloc( 3888 GetProcessHeap(), 3899 GetProcessHeap(), 3889 3900 0, 3890 3901 This->stackToVisit, … … 3900 3911 readSuccessful = StorageImpl_ReadProperty( 3901 3912 This->parentStorage, 3902 nodeToPush, 3913 nodeToPush, 3903 3914 &rootProperty); 3904 3915 … … 3987 3998 else 3988 3999 { 3989 destination->pwcsName = 4000 destination->pwcsName = 3990 4001 CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR)); 3991 4002 3992 4003 strcpyW((LPWSTR)destination->pwcsName, source->name); 3993 4004 } 3994 4005 3995 4006 switch (source->propertyType) 3996 4007 { … … 4004 4015 default: 4005 4016 destination->type = STGTY_STREAM; 4006 break; 4017 break; 4007 4018 } 4008 4019 4009 4020 destination->cbSize = source->size; 4010 /* 4021 /* 4011 4022 currentReturnStruct->mtime = {0}; TODO 4012 4023 currentReturnStruct->ctime = {0}; 4013 currentReturnStruct->atime = {0}; 4024 currentReturnStruct->atime = {0}; 4014 4025 */ 4015 4026 destination->grfMode = 0; 4016 destination->grfLocksSupported = 0; 4027 destination->grfLocksSupported = 0; 4017 4028 destination->clsid = source->propertyUniqueID; 4018 destination->grfStateBits = 0; 4019 destination->reserved = 0; 4029 destination->grfStateBits = 0; 4030 destination->reserved = 0; 4020 4031 } 4021 4032 … … 4025 4036 4026 4037 BlockChainStream* BlockChainStream_Construct( 4027 StorageImpl* parentStorage, 4038 StorageImpl* parentStorage, 4028 4039 ULONG* headOfStreamPlaceHolder, 4029 4040 ULONG propertyIndex) … … 4098 4109 * Returns the number of blocks that comprises this chain. 4099 4110 * This is not the size of the stream as the last block may not be full! 4100 * 4111 * 4101 4112 */ 4102 4113 ULONG BlockChainStream_GetCount(BlockChainStream* This) … … 4112 4123 4113 4124 blockIndex = StorageImpl_GetNextBlockInChain( 4114 This->parentStorage, 4125 This->parentStorage, 4115 4126 blockIndex); 4116 4127 } … … 4120 4131 4121 4132 /****************************************************************************** 4122 * BlockChainStream_ReadAt 4133 * BlockChainStream_ReadAt 4123 4134 * 4124 4135 * Reads a specified number of bytes from this chain at the specified offset. … … 4160 4171 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4161 4172 { 4162 blockIndex = 4173 blockIndex = 4163 4174 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4164 4175 4165 4176 blockNoInSequence--; 4166 4177 } … … 4173 4184 *bytesRead = 0; 4174 4185 bufferWalker = buffer; 4175 4186 4176 4187 while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) ) 4177 4188 { … … 4179 4190 * Calculate how many bytes we can copy from this big block. 4180 4191 */ 4181 bytesToReadInBuffer = 4192 bytesToReadInBuffer = 4182 4193 min(This->parentStorage->bigBlockSize - offsetInBlock, size); 4183 4194 4184 4195 /* 4185 4196 * Copy those bytes to the buffer 4186 4197 */ 4187 bigBlockBuffer = 4198 bigBlockBuffer = 4188 4199 StorageImpl_GetROBigBlock(This->parentStorage, blockIndex); 4189 4200 4190 4201 memcpy(bufferWalker, bigBlockBuffer + offsetInBlock, bytesToReadInBuffer); 4191 4202 4192 4203 StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer); 4193 4204 4194 4205 /* 4195 4206 * Step to the next big block. 4196 4207 */ 4197 blockIndex = 4208 blockIndex = 4198 4209 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4199 4210 … … 4204 4215 4205 4216 } 4206 4217 4207 4218 return (size == 0); 4208 4219 } … … 4249 4260 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4250 4261 { 4251 blockIndex = 4262 blockIndex = 4252 4263 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4253 4264 4254 4265 blockNoInSequence--; 4255 4266 } … … 4269 4280 * Calculate how many bytes we can copy from this big block. 4270 4281 */ 4271 bytesToWrite = 4282 bytesToWrite = 4272 4283 min(This->parentStorage->bigBlockSize - offsetInBlock, size); 4273 4284 4274 4285 /* 4275 4286 * Copy those bytes to the buffer 4276 4287 */ 4277 4288 bigBlockBuffer = StorageImpl_GetBigBlock(This->parentStorage, blockIndex); 4278 4289 4279 4290 memcpy(bigBlockBuffer + offsetInBlock, bufferWalker, bytesToWrite); 4280 4291 4281 4292 StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer); 4282 4293 4283 4294 /* 4284 4295 * Step to the next big block. 4285 4296 */ 4286 blockIndex = 4297 blockIndex = 4287 4298 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4288 4299 … … 4292 4303 offsetInBlock = 0; /* There is no offset on the next block */ 4293 4304 } 4294 4305 4295 4306 return (size == 0); 4296 4307 } … … 4329 4340 while (count < numBlocks) 4330 4341 { 4331 blockIndex = 4342 blockIndex = 4332 4343 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4333 4344 … … 4336 4347 4337 4348 /* Get the next block before marking the new end */ 4338 extraBlock = 4349 extraBlock = 4339 4350 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4340 4351 4341 4352 /* Mark the new end of chain */ 4342 4353 StorageImpl_SetNextBlockInChain( 4343 This->parentStorage, 4344 blockIndex, 4354 This->parentStorage, 4355 blockIndex, 4345 4356 BLOCK_END_OF_CHAIN); 4346 4357 … … 4353 4364 while (extraBlock != BLOCK_END_OF_CHAIN) 4354 4365 { 4355 blockIndex = 4366 blockIndex = 4356 4367 StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock); 4357 4368 … … 4397 4408 4398 4409 StorageImpl_ReadProperty( 4399 This->parentStorage, 4410 This->parentStorage, 4400 4411 This->ownerPropertyIndex, 4401 4412 &chainProp); 4402 4413 4403 chainProp.startingBlock = blockIndex; 4414 chainProp.startingBlock = blockIndex; 4404 4415 4405 4416 StorageImpl_WriteProperty( 4406 This->parentStorage, 4417 This->parentStorage, 4407 4418 This->ownerPropertyIndex, 4408 4419 &chainProp); … … 4453 4464 4454 4465 StorageImpl_SetNextBlockInChain( 4455 This->parentStorage, 4456 currentBlock, 4457 4466 This->parentStorage, 4467 currentBlock, 4468 blockIndex); 4458 4469 4459 4470 StorageImpl_SetNextBlockInChain( 4460 This->parentStorage, 4461 blockIndex, 4462 4471 This->parentStorage, 4472 blockIndex, 4473 BLOCK_END_OF_CHAIN); 4463 4474 4464 4475 currentBlock = blockIndex; … … 4481 4492 * TODO: Free the actual blocks in the file when we shrink the chain. 4482 4493 * Currently, the blocks are still in the file. So the file size 4483 * doesn't shrink even if we shrink streams. 4494 * doesn't shrink even if we shrink streams. 4484 4495 */ 4485 4496 BOOL BlockChainStream_SetSize( … … 4498 4509 else 4499 4510 { 4500 ULARGE_INTEGER fileSize = 4511 ULARGE_INTEGER fileSize = 4501 4512 BIGBLOCKFILE_GetSize(This->parentStorage->bigBlockFile); 4502 4513 … … 4507 4518 */ 4508 4519 if ((diff % This->parentStorage->bigBlockSize) != 0) 4509 diff += (This->parentStorage->bigBlockSize - 4520 diff += (This->parentStorage->bigBlockSize - 4510 4521 (diff % This->parentStorage->bigBlockSize) ); 4511 4522 … … 4531 4542 if(This->headOfStreamPlaceHolder == NULL) 4532 4543 { 4533 /* 4534 * This chain is a data stream read the property and return 4544 /* 4545 * This chain is a data stream read the property and return 4535 4546 * the appropriate size 4536 4547 */ … … 4545 4556 { 4546 4557 /* 4547 * this chain is a chain that does not have a property, figure out the 4548 * size by making the product number of used blocks times the 4558 * this chain is a chain that does not have a property, figure out the 4559 * size by making the product number of used blocks times the 4549 4560 * size of them 4550 4561 */ … … 4552 4563 result.s.HighPart = 0; 4553 4564 4554 result.s.LowPart = 4555 BlockChainStream_GetCount(This) * 4565 result.s.LowPart = 4566 BlockChainStream_GetCount(This) * 4556 4567 This->parentStorage->bigBlockSize; 4557 4568 … … 4565 4576 4566 4577 SmallBlockChainStream* SmallBlockChainStream_Construct( 4567 StorageImpl* parentStorage, 4578 StorageImpl* parentStorage, 4568 4579 ULONG propertyIndex) 4569 4580 { … … 4616 4627 * 4617 4628 * Returns the index of the next small block in this chain. 4618 * 4629 * 4619 4630 * Return Values: 4620 4631 * - BLOCK_END_OF_CHAIN: end of this chain … … 4743 4754 else 4744 4755 { 4745 ULONG count = 4756 ULONG count = 4746 4757 BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain); 4747 4758 … … 4754 4765 { 4755 4766 sbdIndex = nextBlock; 4756 nextBlock = 4767 nextBlock = 4757 4768 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex); 4758 4769 } … … 4761 4772 if (sbdIndex != BLOCK_END_OF_CHAIN) 4762 4773 StorageImpl_SetNextBlockInChain( 4763 This->parentStorage, 4764 sbdIndex, 4774 This->parentStorage, 4775 sbdIndex, 4765 4776 newsbdIndex); 4766 4777 4767 4778 StorageImpl_SetNextBlockInChain( 4768 This->parentStorage, 4769 newsbdIndex, 4779 This->parentStorage, 4780 newsbdIndex, 4770 4781 BLOCK_END_OF_CHAIN); 4771 4782 … … 4773 4784 * Initialize all the small blocks to free 4774 4785 */ 4775 smallBlockDepot = 4786 smallBlockDepot = 4776 4787 StorageImpl_GetBigBlock(This->parentStorage, newsbdIndex); 4777 4788 … … 4785 4796 */ 4786 4797 StgProperty rootProp; 4787 ULONG sbStartIndex; 4798 ULONG sbStartIndex; 4788 4799 4789 4800 /* … … 4794 4805 4795 4806 /* 4796 * And allocate the first big block that will contain small blocks 4807 * And allocate the first big block that will contain small blocks 4797 4808 */ 4798 sbStartIndex = 4809 sbStartIndex = 4799 4810 StorageImpl_GetNextFreeBigBlock(This->parentStorage); 4800 4811 4801 4812 StorageImpl_SetNextBlockInChain( 4802 This->parentStorage, 4803 sbStartIndex, 4813 This->parentStorage, 4814 sbStartIndex, 4804 4815 BLOCK_END_OF_CHAIN); 4805 4816 4806 4817 StorageImpl_ReadProperty( 4807 This->parentStorage, 4808 This->parentStorage->rootPropertySetIndex, 4818 This->parentStorage, 4819 This->parentStorage->rootPropertySetIndex, 4809 4820 &rootProp); 4810 4821 … … 4814 4825 4815 4826 StorageImpl_WriteProperty( 4816 This->parentStorage, 4817 This->parentStorage->rootPropertySetIndex, 4827 This->parentStorage, 4828 This->parentStorage->rootPropertySetIndex, 4818 4829 &rootProp); 4819 4830 } … … 4821 4832 } 4822 4833 4823 smallBlocksPerBigBlock = 4834 smallBlocksPerBigBlock = 4824 4835 This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize; 4825 4836 … … 4833 4844 4834 4845 StorageImpl_ReadProperty( 4835 This->parentStorage, 4836 This->parentStorage->rootPropertySetIndex, 4846 This->parentStorage, 4847 This->parentStorage->rootPropertySetIndex, 4837 4848 &rootProp); 4838 4849 4839 if (rootProp.size.s.LowPart < 4850 if (rootProp.size.s.LowPart < 4840 4851 (blocksRequired * This->parentStorage->bigBlockSize)) 4841 4852 { … … 4843 4854 4844 4855 BlockChainStream_SetSize( 4845 This->parentStorage->smallBlockRootChain, 4856 This->parentStorage->smallBlockRootChain, 4846 4857 rootProp.size); 4847 4858 4848 4859 StorageImpl_WriteProperty( 4849 This->parentStorage, 4850 This->parentStorage->rootPropertySetIndex, 4860 This->parentStorage, 4861 This->parentStorage->rootPropertySetIndex, 4851 4862 &rootProp); 4852 4863 } … … 4861 4872 * Reads a specified number of bytes from this chain at the specified offset. 4862 4873 * bytesRead may be NULL. 4863 * Failure will be returned if the specified number of bytes has not been read. 4874 * Failure will be returned if the specified number of bytes has not been read. 4864 4875 */ 4865 4876 BOOL SmallBlockChainStream_ReadAt( … … 4871 4882 { 4872 4883 ULARGE_INTEGER offsetInBigBlockFile; 4873 ULONG blockNoInSequence = 4884 ULONG blockNoInSequence = 4874 4885 offset.s.LowPart / This->parentStorage->smallBlockSize; 4875 4886 … … 4908 4919 * Calculate how many bytes we can copy from this small block. 4909 4920 */ 4910 bytesToReadInBuffer = 4921 bytesToReadInBuffer = 4911 4922 min(This->parentStorage->smallBlockSize - offsetInBlock, size); 4912 4923 … … 4915 4926 */ 4916 4927 offsetInBigBlockFile.s.HighPart = 0; 4917 offsetInBigBlockFile.s.LowPart = 4928 offsetInBigBlockFile.s.LowPart = 4918 4929 blockIndex * This->parentStorage->smallBlockSize; 4919 4930 … … 4959 4970 { 4960 4971 ULARGE_INTEGER offsetInBigBlockFile; 4961 ULONG blockNoInSequence = 4972 ULONG blockNoInSequence = 4962 4973 offset.s.LowPart / This->parentStorage->smallBlockSize; 4963 4974 … … 4967 4978 ULONG bytesWrittenFromBigBlockFile; 4968 4979 BYTE* bufferWalker; 4969 4980 4970 4981 /* 4971 4982 * This should never happen on a small block file. 4972 4983 */ 4973 4984 assert(offset.s.HighPart==0); 4974 4985 4975 4986 /* 4976 4987 * Find the first block in the stream that contains part of the buffer. 4977 4988 */ 4978 4989 blockIndex = SmallBlockChainStream_GetHeadOfChain(This); 4979 4990 4980 4991 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4981 4992 { 4982 4993 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 4983 4994 4984 4995 blockNoInSequence--; 4985 4996 } 4986 4997 4987 4998 /* 4988 4999 * Start writing the buffer. … … 4998 5009 * Calculate how many bytes we can copy to this small block. 4999 5010 */ 5000 bytesToWriteInBuffer = 5011 bytesToWriteInBuffer = 5001 5012 min(This->parentStorage->smallBlockSize - offsetInBlock, size); 5002 5013 5003 5014 /* 5004 5015 * Calculate the offset of the small block in the small block file. 5005 5016 */ 5006 5017 offsetInBigBlockFile.s.HighPart = 0; 5007 offsetInBigBlockFile.s.LowPart = 5018 offsetInBigBlockFile.s.LowPart = 5008 5019 blockIndex * This->parentStorage->smallBlockSize; 5009 5020 5010 5021 offsetInBigBlockFile.s.LowPart += offsetInBlock; 5011 5022 5012 5023 /* 5013 5024 * Write those bytes in the buffer to the small block file. … … 5018 5029 bufferWalker, 5019 5030 &bytesWrittenFromBigBlockFile); 5020 5031 5021 5032 assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer); 5022 5033 5023 5034 /* 5024 5035 * Step to the next big block. … … 5030 5041 offsetInBlock = 0; /* There is no offset on the next block */ 5031 5042 } 5032 5043 5033 5044 return (size == 0); 5034 5045 } … … 5037 5048 * SmallBlockChainStream_Shrink 5038 5049 * 5039 * Shrinks this chain in the small block depot. 5050 * Shrinks this chain in the small block depot. 5040 5051 */ 5041 5052 BOOL SmallBlockChainStream_Shrink( … … 5065 5076 /* 5066 5077 * If the count is 0, we have a special case, the head of the chain was 5067 * just freed. 5078 * just freed. 5068 5079 */ 5069 5080 if (count == 0) … … 5071 5082 StgProperty chainProp; 5072 5083 5073 StorageImpl_ReadProperty(This->parentStorage, 5074 5075 5084 StorageImpl_ReadProperty(This->parentStorage, 5085 This->ownerPropertyIndex, 5086 &chainProp); 5076 5087 5077 5088 chainProp.startingBlock = BLOCK_END_OF_CHAIN; 5078 5089 5079 5090 StorageImpl_WriteProperty(This->parentStorage, 5080 5081 5091 This->ownerPropertyIndex, 5092 &chainProp); 5082 5093 5083 5094 /* … … 5093 5104 /* Mark the new end of chain */ 5094 5105 SmallBlockChainStream_SetNextBlockInChain( 5095 This, 5096 blockIndex, 5106 This, 5107 blockIndex, 5097 5108 BLOCK_END_OF_CHAIN); 5098 5109 } … … 5108 5119 } 5109 5120 5110 return TRUE; 5121 return TRUE; 5111 5122 } 5112 5123 … … 5144 5155 blockIndex = chainProp.startingBlock; 5145 5156 SmallBlockChainStream_SetNextBlockInChain( 5146 This, 5147 blockIndex, 5157 This, 5158 blockIndex, 5148 5159 BLOCK_END_OF_CHAIN); 5149 5160 } … … 5178 5189 5179 5190 SmallBlockChainStream_SetNextBlockInChain( 5180 This, 5181 blockIndex, 5191 This, 5192 blockIndex, 5182 5193 BLOCK_END_OF_CHAIN); 5183 5194 … … 5220 5231 * TODO: Free the actual blocks in the file when we shrink the chain. 5221 5232 * Currently, the blocks are still in the file. So the file size 5222 * doesn't shrink even if we shrink streams. 5233 * doesn't shrink even if we shrink streams. 5223 5234 */ 5224 5235 BOOL SmallBlockChainStream_SetSize( … … 5278 5289 WCHAR tempFileName[MAX_PATH]; 5279 5290 5280 TRACE("(%s, %lx, %ld, %p)\n", 5281 debugstr_w(pwcsName), grfMode, 5282 5291 TRACE("(%s, %lx, %ld, %p)\n", 5292 debugstr_w(pwcsName), grfMode, 5293 reserved, ppstgOpen); 5283 5294 5284 5295 /* … … 5326 5337 5327 5338 /* 5328 * Interpret the STGM value grfMode 5339 * Interpret the STGM value grfMode 5329 5340 */ 5330 5341 shareMode = GetShareModeFromSTGM(grfMode); … … 5351 5362 fileAttributes, 5352 5363 0); 5353 5364 5354 5365 if (hFile == INVALID_HANDLE_VALUE) 5355 5366 { … … 5361 5372 */ 5362 5373 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5363 5374 5364 5375 if (newStorage == 0) 5365 5376 return STG_E_INSUFFICIENTMEMORY; … … 5372 5383 TRUE, 5373 5384 TRUE); 5374 5385 5375 5386 if (FAILED(hr)) 5376 5387 { … … 5398 5409 DWORD grfMode, 5399 5410 SNB snbExclude, 5400 DWORD reserved, 5411 DWORD reserved, 5401 5412 IStorage **ppstgOpen) 5402 5413 { … … 5407 5418 DWORD accessMode; 5408 5419 5409 TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 5410 5411 5420 TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 5421 debugstr_w(pwcsName), pstgPriority, grfMode, 5422 snbExclude, reserved, ppstgOpen); 5412 5423 5413 5424 /* … … 5433 5444 */ 5434 5445 *ppstgOpen = 0; 5435 5436 hFile = CreateFileW( pwcsName, 5446 5447 hFile = CreateFileW( pwcsName, 5437 5448 accessMode, 5438 5449 shareMode, … … 5441 5452 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, 5442 5453 0); 5443 5444 5454 5455 5445 5456 if (hFile==INVALID_HANDLE_VALUE) 5446 5457 { … … 5478 5489 */ 5479 5490 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5480 5491 5481 5492 if (newStorage == 0) 5482 5493 return STG_E_INSUFFICIENTMEMORY; … … 5489 5500 TRUE, 5490 5501 FALSE); 5491 5502 5492 5503 if (FAILED(hr)) 5493 5504 { … … 5497 5508 */ 5498 5509 if(hr == STG_E_INVALIDHEADER) 5499 5510 return STG_E_FILEALREADYEXISTS; 5500 5511 return hr; 5501 5512 } 5502 5513 5503 5514 /* 5504 5515 * Get an "out" pointer for the caller. … … 5508 5519 (REFIID)&IID_IStorage, 5509 5520 (void**)ppstgOpen); 5510 5521 5511 5522 return hr; 5512 5523 } … … 5560 5571 (void**)ppstgOpen); 5561 5572 5562 return hr; 5573 return hr; 5563 5574 } 5564 5575 … … 5598 5609 */ 5599 5610 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5600 5611 5601 5612 if (newStorage == 0) 5602 5613 return STG_E_INSUFFICIENTMEMORY; … … 5634 5645 HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c ) 5635 5646 { 5636 5647 5637 5648 FIXME("(%p, %p, %p, %p),stub!\n", str, a, b, c); 5638 5649 return FALSE; … … 5685 5696 STATSTG pstatstg; 5686 5697 HRESULT hRes; 5687 5698 5688 5699 TRACE("()\n"); 5689 5700 … … 5708 5719 HRESULT WINAPI OleLoadFromStream(IStream *pStm,REFIID iidInterface,void** ppvObj) 5709 5720 { 5710 CLSID 5711 HRESULT 5712 LPPERSISTSTREAM 5721 CLSID clsid; 5722 HRESULT res; 5723 LPPERSISTSTREAM xstm; 5713 5724 5714 5725 TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj); … … 5716 5727 res=ReadClassStm(pStm,&clsid); 5717 5728 if (!SUCCEEDED(res)) 5718 5729 return res; 5719 5730 res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj); 5720 5731 if (!SUCCEEDED(res)) 5721 5732 return res; 5722 5733 res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm); 5723 5734 if (!SUCCEEDED(res)) { 5724 5725 5735 IUnknown_Release((IUnknown*)*ppvObj); 5736 return res; 5726 5737 } 5727 5738 res=IPersistStream_Load(xstm,pStm); 5728 5739 IPersistStream_Release(xstm); 5729 5740 /* FIXME: all refcounts ok at this point? I think they should be: 5730 * pStm: unchanged5731 * ppvObj: 15732 * xstm: 0 (released)5741 * pStm : unchanged 5742 * ppvObj : 1 5743 * xstm : 0 (released) 5733 5744 */ 5734 5745 return res; … … 5746 5757 CLSID clsid; 5747 5758 HRESULT res; 5748 5759 5749 5760 TRACE("(%p,%p)\n",pPStm,pStm); 5750 5761 … … 5752 5763 5753 5764 if (SUCCEEDED(res)){ 5754 5765 5755 5766 res=WriteClassStm(pStm,&clsid); 5756 5767 … … 5770 5781 * STGM_TRANSACTED 0x00010000 5771 5782 * STGM_SIMPLE 0x08000000 5772 * 5783 * 5773 5784 * STGM_READ 0x00000000 5774 5785 * STGM_WRITE 0x00000001 5775 5786 * STGM_READWRITE 0x00000002 5776 * 5787 * 5777 5788 * STGM_SHARE_DENY_NONE 0x00000040 5778 5789 * STGM_SHARE_DENY_READ 0x00000030 5779 5790 * STGM_SHARE_DENY_WRITE 0x00000020 5780 5791 * STGM_SHARE_EXCLUSIVE 0x00000010 5781 * 5792 * 5782 5793 * STGM_PRIORITY 0x00040000 5783 5794 * STGM_DELETEONRELEASE 0x04000000 … … 5795 5806 BOOL bSTGM_SIMPLE = ((stgm & STGM_SIMPLE) == STGM_SIMPLE); 5796 5807 BOOL bSTGM_DIRECT = ! (bSTGM_TRANSACTED || bSTGM_SIMPLE); 5797 5808 5798 5809 BOOL bSTGM_WRITE = ((stgm & STGM_WRITE) == STGM_WRITE); 5799 5810 BOOL bSTGM_READWRITE = ((stgm & STGM_READWRITE) == STGM_READWRITE); 5800 5811 BOOL bSTGM_READ = ! (bSTGM_WRITE || bSTGM_READWRITE); 5801 5812 5802 5813 BOOL bSTGM_SHARE_DENY_NONE = 5803 5814 ((stgm & STGM_SHARE_DENY_NONE) == STGM_SHARE_DENY_NONE); … … 5814 5825 BOOL bSTGM_CREATE = ((stgm & STGM_CREATE) == STGM_CREATE); 5815 5826 BOOL bSTGM_CONVERT = ((stgm & STGM_CONVERT) == STGM_CONVERT); 5816 5827 5817 5828 BOOL bSTGM_NOSCRATCH = ((stgm & STGM_NOSCRATCH) == STGM_NOSCRATCH); 5818 5829 BOOL bSTGM_NOSNAPSHOT = ((stgm & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT); 5819 5830 5820 /* 5831 /* 5821 5832 * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE 5822 5833 */ … … 5825 5836 return E_FAIL; 5826 5837 5827 /* 5838 /* 5828 5839 * STGM_WRITE | STGM_READWRITE | STGM_READ 5829 5840 */ … … 5833 5844 5834 5845 /* 5835 * STGM_SHARE_DENY_NONE | others 5846 * STGM_SHARE_DENY_NONE | others 5836 5847 * (I assume here that DENY_READ implies DENY_WRITE) 5837 5848 */ 5838 5849 if ( bSTGM_SHARE_DENY_NONE ) 5839 5850 if ( bSTGM_SHARE_DENY_READ || 5840 bSTGM_SHARE_DENY_WRITE || 5841 bSTGM_SHARE_EXCLUSIVE) 5851 bSTGM_SHARE_DENY_WRITE || 5852 bSTGM_SHARE_EXCLUSIVE) 5842 5853 return E_FAIL; 5843 5854 … … 5854 5865 if ( bSTGM_NOSCRATCH && ! bSTGM_TRANSACTED ) 5855 5866 return E_FAIL; 5856 5857 /* 5858 * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 5867 5868 /* 5869 * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 5859 5870 * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE` 5860 5871 */ 5861 5872 if (bSTGM_NOSNAPSHOT) 5862 5873 { 5863 if ( ! ( bSTGM_TRANSACTED && 5874 if ( ! ( bSTGM_TRANSACTED && 5864 5875 !(bSTGM_SHARE_EXCLUSIVE || bSTGM_SHARE_DENY_WRITE)) ) 5865 5876 return E_FAIL; … … 5873 5884 * 5874 5885 * This method will return a share mode flag from a STGM value. 5875 * The STGM value is assumed valid. 5886 * The STGM value is assumed valid. 5876 5887 */ 5877 5888 static DWORD GetShareModeFromSTGM(DWORD stgm) … … 5943 5954 /* All other cases */ 5944 5955 if (stgm & ~ (STGM_CREATE|STGM_CONVERT)) 5945 5956 FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT)); 5946 5957 return CREATE_NEW; 5947 5958 } … … 5949 5960 5950 5961 /************************************************************************* 5951 * OLECONVERT_LoadOLE10 [Internal] 5952 * 5953 * Loads the OLE10 STREAM to memory 5962 * OLECONVERT_LoadOLE10 [Internal] 5963 * 5964 * Loads the OLE10 STREAM to memory 5954 5965 * 5955 5966 * PARAMS … … 5964 5975 * NOTES 5965 5976 * This function is used by OleConvertOLESTREAMToIStorage only. 5966 * 5977 * 5967 5978 * Memory allocated for pData must be freed by the caller 5968 5979 */ 5969 5980 HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1) 5970 5981 { 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 5982 DWORD dwSize; 5983 HRESULT hRes = S_OK; 5984 int nTryCnt=0; 5985 int max_try = 6; 5986 5987 pData->pData = NULL; 5988 pData->pstrOleObjFileName = (CHAR *) NULL; 5989 5990 for( nTryCnt=0;nTryCnt < max_try; nTryCnt++) 5991 { 5992 /* Get the OleID */ 5993 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID)); 5994 if(dwSize != sizeof(pData->dwOleID)) 5995 { 5996 hRes = CONVERT10_E_OLESTREAM_GET; 5997 } 5998 else if(pData->dwOleID != OLESTREAM_ID) 5999 { 6000 hRes = CONVERT10_E_OLESTREAM_FMT; 6001 } 6002 else 6003 { 6004 hRes = S_OK; 6005 break; 6006 } 6007 } 6008 6009 if(hRes == S_OK) 6010 { 6011 /* Get the TypeID...more info needed for this field */ 6012 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID)); 6013 if(dwSize != sizeof(pData->dwTypeID)) 6014 { 6015 hRes = CONVERT10_E_OLESTREAM_GET; 6016 } 6017 } 6018 if(hRes == S_OK) 6019 { 6020 if(pData->dwTypeID != 0) 6021 { 6022 /* Get the lenght of the OleTypeName */ 6023 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength)); 6024 if(dwSize != sizeof(pData->dwOleTypeNameLength)) 6025 { 6026 hRes = CONVERT10_E_OLESTREAM_GET; 6027 } 6028 6029 if(hRes == S_OK) 6030 { 6031 if(pData->dwOleTypeNameLength > 0) 6032 { 6033 /* Get the OleTypeName */ 6034 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength); 6035 if(dwSize != pData->dwOleTypeNameLength) 6036 { 6037 hRes = CONVERT10_E_OLESTREAM_GET; 6038 } 6039 } 6040 } 6041 if(bStrem1) 6042 { 6043 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength)); 6044 if(dwSize != sizeof(pData->dwOleObjFileNameLength)) 6045 { 6046 hRes = CONVERT10_E_OLESTREAM_GET; 6047 } 6048 if(hRes == S_OK) 6049 { 6050 if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */ 6051 pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength); 6052 pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength); 6053 if(pData->pstrOleObjFileName) 6054 { 6055 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength); 6056 if(dwSize != pData->dwOleObjFileNameLength) 6057 { 6058 hRes = CONVERT10_E_OLESTREAM_GET; 6059 } 6060 } 6061 else 6062 hRes = CONVERT10_E_OLESTREAM_GET; 6063 } 6064 } 6065 else 6066 { 6067 /* Get the Width of the Metafile */ 6068 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth)); 6069 if(dwSize != sizeof(pData->dwMetaFileWidth)) 6070 { 6071 hRes = CONVERT10_E_OLESTREAM_GET; 6072 } 6073 if(hRes == S_OK) 6074 { 6075 /* Get the Height of the Metafile */ 6076 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight)); 6077 if(dwSize != sizeof(pData->dwMetaFileHeight)) 6078 { 6079 hRes = CONVERT10_E_OLESTREAM_GET; 6080 } 6081 } 6082 } 6083 if(hRes == S_OK) 6084 { 6085 /* Get the Lenght of the Data */ 6086 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength)); 6087 if(dwSize != sizeof(pData->dwDataLength)) 6088 { 6089 hRes = CONVERT10_E_OLESTREAM_GET; 6090 } 6091 } 6092 6093 if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */ 6094 { 6095 if(!bStrem1) /* if it is a second OLE stream data */ 6096 { 6097 pData->dwDataLength -= 8; 6098 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown)); 6099 if(dwSize != sizeof(pData->strUnknown)) 6100 { 6101 hRes = CONVERT10_E_OLESTREAM_GET; 6102 } 6103 } 6104 } 6105 if(hRes == S_OK) 6106 { 6107 if(pData->dwDataLength > 0) 6108 { 6109 pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength); 6110 6111 /* Get Data (ex. IStorage, Metafile, or BMP) */ 6112 if(pData->pData) 6113 { 6114 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength); 6115 if(dwSize != pData->dwDataLength) 6116 { 6117 hRes = CONVERT10_E_OLESTREAM_GET; 6118 } 6119 } 6120 else 6121 { 6122 hRes = CONVERT10_E_OLESTREAM_GET; 6123 } 6124 } 6125 } 6126 } 6127 } 6128 return hRes; 6118 6129 } 6119 6130 6120 6131 /************************************************************************* 6121 * OLECONVERT_SaveOLE10 [Internal] 6122 * 6123 * Saves the OLE10 STREAM From memory 6132 * OLECONVERT_SaveOLE10 [Internal] 6133 * 6134 * Saves the OLE10 STREAM From memory 6124 6135 * 6125 6136 * PARAMS … … 6133 6144 * NOTES 6134 6145 * This function is used by OleConvertIStorageToOLESTREAM only. 6135 * 6146 * 6136 6147 */ 6137 6148 HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream) … … 6227 6238 6228 6239 /************************************************************************* 6229 * OLECONVERT_GetOLE20FromOLE10[Internal] 6240 * OLECONVERT_GetOLE20FromOLE10[Internal] 6230 6241 * 6231 6242 * This function copies OLE10 Data (the IStorage in the OLESTREAM) to disk, 6232 * opens it, and copies the content to the dest IStorage for 6243 * opens it, and copies the content to the dest IStorage for 6233 6244 * OleConvertOLESTREAMToIStorage 6234 * 6245 * 6235 6246 * 6236 6247 * PARAMS … … 6243 6254 * 6244 6255 * NOTES 6245 * 6246 * 6256 * 6257 * 6247 6258 */ 6248 6259 void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, BYTE *pBuffer, DWORD nBufferLength) … … 6279 6290 6280 6291 /************************************************************************* 6281 * OLECONVERT_WriteOLE20ToBuffer [Internal] 6282 * 6283 * Saves the OLE10 STREAM From memory 6292 * OLECONVERT_WriteOLE20ToBuffer [Internal] 6293 * 6294 * Saves the OLE10 STREAM From memory 6284 6295 * 6285 6296 * PARAMS … … 6294 6305 * 6295 6306 * Used by OleConvertIStorageToOLESTREAM only. 6296 * 6307 * 6297 6308 */ 6298 6309 DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData) … … 6306 6317 6307 6318 *pData = NULL; 6308 6319 6309 6320 /* Create temp Storage */ 6310 6321 GetTempPathW(MAX_PATH, wstrTempDir); … … 6333 6344 6334 6345 /************************************************************************* 6335 * OLECONVERT_CreateOleStream [Internal] 6346 * OLECONVERT_CreateOleStream [Internal] 6336 6347 * 6337 6348 * Creates the "\001OLE" stream in the IStorage if neccessary. … … 6348 6359 * This stream is still unknown, MS Word seems to have extra data 6349 6360 * but since the data is stored in the OLESTREAM there should be 6350 * no need to recreate the stream. If the stream is manually 6361 * no need to recreate the stream. If the stream is manually 6351 6362 * deleted it will create it with this default data. 6352 * 6363 * 6353 6364 */ 6354 6365 void OLECONVERT_CreateOleStream(LPSTORAGE pStorage) … … 6357 6368 IStream *pStream; 6358 6369 WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0}; 6359 BYTE pOleStreamHeader [] = 6360 { 6361 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 6362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6363 0x00, 0x00, 0x00, 0x00 6370 BYTE pOleStreamHeader [] = 6371 { 6372 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 6373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6374 0x00, 0x00, 0x00, 0x00 6364 6375 }; 6365 6376 6366 6377 /* Create stream if not present */ 6367 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6378 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6368 6379 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6369 6380 … … 6378 6389 6379 6390 /************************************************************************* 6380 * OLECONVERT_CreateCompObjStream [Internal] 6391 * OLECONVERT_CreateCompObjStream [Internal] 6381 6392 * 6382 6393 * Creates a "\001CompObj" is the destination IStorage if necessary. 6383 6394 * 6384 6395 * PARAMS 6385 * pStorage [I] The dest IStorage to create the CompObj Stream 6396 * pStorage [I] The dest IStorage to create the CompObj Stream 6386 6397 * if necessary. 6387 6398 * strOleTypeName [I] The ProgID … … 6395 6406 * 6396 6407 * The stream data is stored in the OLESTREAM and there should be 6397 * no need to recreate the stream. If the stream is manually 6408 * no need to recreate the stream. If the stream is manually 6398 6409 * deleted it will attempt to create it by querying the registry. 6399 6410 * 6400 * 6411 * 6401 6412 */ 6402 6413 HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) … … 6417 6428 6418 6429 /* Create a CompObj stream if it doesn't exist */ 6419 hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 6430 hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 6420 6431 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6421 6432 if(hStorageRes == S_OK) … … 6438 6449 LONG hErr; 6439 6450 /* Get the CLSID Default Name from the Registry */ 6440 hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 6451 hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 6441 6452 if(hErr == ERROR_SUCCESS) 6442 6453 { … … 6480 6491 6481 6492 /************************************************************************* 6482 * OLECONVERT_CreateOlePresStream[Internal] 6493 * OLECONVERT_CreateOlePresStream[Internal] 6483 6494 * 6484 6495 * Creates the "\002OlePres000" Stream with the Metafile data … … 6487 6498 * pStorage [I] The dest IStorage to create \002OLEPres000 stream in. 6488 6499 * dwExtentX [I] Width of the Metafile 6489 * dwExtentY [I] Height of the Metafile 6500 * dwExtentY [I] Height of the Metafile 6490 6501 * pData [I] Metafile data 6491 6502 * dwDataLength [I] Size of the Metafile data … … 6497 6508 * NOTES 6498 6509 * This function is used by OleConvertOLESTREAMToIStorage only. 6499 * 6510 * 6500 6511 */ 6501 6512 void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY , BYTE *pData, DWORD dwDataLength) … … 6504 6515 IStream *pStream; 6505 6516 WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0}; 6506 BYTE pOlePresStreamHeader [] = 6507 { 6508 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 6509 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6517 BYTE pOlePresStreamHeader [] = 6518 { 6519 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 6520 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6510 6521 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 6511 6522 0x00, 0x00, 0x00, 0x00 6512 6523 }; 6513 6524 6514 BYTE pOlePresStreamHeaderEmpty [] = 6515 { 6516 0x00, 0x00, 0x00, 0x00, 6517 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6525 BYTE pOlePresStreamHeaderEmpty [] = 6526 { 6527 0x00, 0x00, 0x00, 0x00, 6528 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6518 6529 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 6519 6530 0x00, 0x00, 0x00, 0x00 6520 6531 }; 6521 6532 6522 6533 /* Create the OlePres000 Stream */ 6523 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6534 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6524 6535 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6525 6536 … … 6565 6576 6566 6577 /************************************************************************* 6567 * OLECONVERT_CreateOle10NativeStream [Internal] 6578 * OLECONVERT_CreateOle10NativeStream [Internal] 6568 6579 * 6569 6580 * Creates the "\001Ole10Native" Stream (should contain a BMP) … … 6581 6592 * 6582 6593 * Might need to verify the data and return appropriate error message 6583 * 6594 * 6584 6595 */ 6585 6596 void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, BYTE *pData, DWORD dwDataLength) … … 6588 6599 IStream *pStream; 6589 6600 WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0}; 6590 6601 6591 6602 /* Create the Ole10Native Stream */ 6592 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6603 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6593 6604 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6594 6605 … … 6604 6615 6605 6616 /************************************************************************* 6606 * OLECONVERT_GetOLE10ProgID [Internal] 6617 * OLECONVERT_GetOLE10ProgID [Internal] 6607 6618 * 6608 6619 * Finds the ProgID (or OleTypeID) from the IStorage … … 6620 6631 * This function is used by OleConvertIStorageToOLESTREAM only. 6621 6632 * 6622 * 6633 * 6623 6634 */ 6624 6635 HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize) … … 6631 6642 6632 6643 /* Open the CompObj Stream */ 6633 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6644 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6634 6645 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6635 6646 if(hRes == S_OK) … … 6668 6679 *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE); 6669 6680 } 6670 6681 6671 6682 } 6672 6683 return hRes; … … 6674 6685 6675 6686 /************************************************************************* 6676 * OLECONVERT_GetOle10PresData [Internal] 6687 * OLECONVERT_GetOle10PresData [Internal] 6677 6688 * 6678 6689 * Converts IStorage "/001Ole10Native" stream to a OLE10 Stream … … 6689 6700 * 6690 6701 * Memory allocated for pData must be freed by the caller 6691 * 6692 * 6702 * 6703 * 6693 6704 */ 6694 6705 void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData) … … 6710 6721 6711 6722 /* Open Ole10Native Stream */ 6712 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6723 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6713 6724 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6714 6725 if(hRes == S_OK) … … 6729 6740 6730 6741 /************************************************************************* 6731 * OLECONVERT_GetOle20PresData[Internal] 6742 * OLECONVERT_GetOle20PresData[Internal] 6732 6743 * 6733 6744 * Converts IStorage "/002OlePres000" stream to a OLE10 Stream … … 6742 6753 * NOTES 6743 6754 * This function is used by OleConvertIStorageToOLESTREAM only. 6744 * 6755 * 6745 6756 * Memory allocated for pData must be freed by the caller 6746 6757 */ … … 6769 6780 6770 6781 /* Open OlePress000 stream */ 6771 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6782 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6772 6783 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6773 6784 if(hRes == S_OK) … … 6817 6828 6818 6829 /************************************************************************* 6819 * OleConvertOLESTREAMToIStorage [OLE32.87] 6830 * OleConvertOLESTREAMToIStorage [OLE32.87] 6820 6831 * 6821 6832 * Read info on MSDN … … 6826 6837 * Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj", 6827 6838 * and "\001OLE" streams 6828 * 6839 * 6829 6840 */ 6830 6841 HRESULT WINAPI OleConvertOLESTREAMToIStorage ( 6831 LPOLESTREAM pOleStream, 6832 LPSTORAGE pstg, 6842 LPOLESTREAM pOleStream, 6843 LPSTORAGE pstg, 6833 6844 const DVTARGETDEVICE* ptd) 6834 6845 { … … 6902 6913 } 6903 6914 if(pOleStreamData[i].pstrOleObjFileName != NULL) 6904 6905 6906 6907 6915 { 6916 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName); 6917 pOleStreamData[i].pstrOleObjFileName = NULL; 6918 } 6908 6919 } 6909 6920 return hRes; … … 6921 6932 * Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj", 6922 6933 * and "\001OLE" streams. 6923 * 6934 * 6924 6935 */ 6925 6936 HRESULT WINAPI OleConvertIStorageToOLESTREAM ( 6926 LPSTORAGE pstg, 6937 LPSTORAGE pstg, 6927 6938 LPOLESTREAM pOleStream) 6928 6939 { … … 6949 6960 { 6950 6961 /*Was it originaly Ole10 */ 6951 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream); 6962 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream); 6952 6963 if(hRes == S_OK) 6953 6964 { … … 6984 6995 6985 6996 /*********************************************************************** 6986 * 6997 * GetConvertStg (OLE32.68) 6987 6998 */ 6988 6999 HRESULT WINAPI GetConvertStg(LPGUID guid) { … … 6998 7009 */ 6999 7010 HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) { 7000 HFILEhf;7001 OFSTRUCTofs;7002 BYTEmagic[24];7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7011 HFILE hf; 7012 OFSTRUCT ofs; 7013 BYTE magic[24]; 7014 7015 TRACE("(\'%s\')\n",fn); 7016 hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE); 7017 if (hf==HFILE_ERROR) 7018 return STG_E_FILENOTFOUND; 7019 if (24!=_lread(hf,magic,24)) { 7020 WARN(" too short\n"); 7021 _lclose(hf); 7022 return S_FALSE; 7023 } 7024 if (!memcmp(magic,STORAGE_magic,8)) { 7025 WARN(" -> YES\n"); 7026 _lclose(hf); 7027 return S_OK; 7028 } 7029 if (!memcmp(magic,STORAGE_notmagic,8)) { 7030 WARN(" -> NO\n"); 7031 _lclose(hf); 7032 return S_FALSE; 7033 } 7034 if (!memcmp(magic,STORAGE_oldmagic,8)) { 7035 WARN(" -> old format\n"); 7036 _lclose(hf); 7037 return STG_E_OLDFORMAT; 7038 } 7039 WARN(" -> Invalid header.\n"); 7040 _lclose(hf); 7041 return STG_E_INVALIDHEADER; 7031 7042 } 7032 7043 … … 7034 7045 * StgIsStorageFile [OLE32.146] 7035 7046 */ 7036 HRESULT WINAPI 7037 StgIsStorageFile(LPCOLESTR fn) 7038 { 7039 LPOLESTR16xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);7040 HRESULTret = StgIsStorageFile16(xfn);7041 7042 7043 7047 HRESULT WINAPI 7048 StgIsStorageFile(LPCOLESTR fn) 7049 { 7050 LPOLESTR16 xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn); 7051 HRESULT ret = StgIsStorageFile16(xfn); 7052 7053 HeapFree(GetProcessHeap(),0,xfn); 7054 return ret; 7044 7055 } 7045 7056 #endif
Note:
See TracChangeset
for help on using the changeset viewer.