Changeset 6648 for trunk/src/ole32
- Timestamp:
- Sep 5, 2001, 3:19:02 PM (24 years ago)
- Location:
- trunk/src/ole32
- Files:
-
- 24 edited
-
antimoniker.c (modified) (19 diffs)
-
bindctx.c (modified) (14 diffs)
-
clipboard.c (modified) (88 diffs)
-
compobj.c (modified) (98 diffs)
-
compositemoniker.c (modified) (48 diffs)
-
datacache.c (modified) (97 diffs)
-
defaulthandler.c (modified) (92 diffs)
-
errorinfo.c (modified) (9 diffs)
-
filemoniker.c (modified) (47 diffs)
-
hglobalstream.c (modified) (47 diffs)
-
ifs.c (modified) (22 diffs)
-
initole32.cpp (modified) (4 diffs)
-
initterm.cpp (modified) (1 diff)
-
itemmoniker.c (modified) (29 diffs)
-
memlockbytes.c (modified) (7 diffs)
-
moniker.c (modified) (17 diffs)
-
ole2.c (modified) (95 diffs)
-
ole2impl.c (modified) (1 diff)
-
ole2stubs.c (modified) (8 diffs)
-
ole32_main.c (modified) (4 diffs)
-
oleobj.c (modified) (34 diffs)
-
stg_bigblockfile.c (modified) (32 diffs)
-
stg_stream.c (modified) (50 diffs)
-
storage32.c (modified) (288 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/antimoniker.c
r5602 r6648 1 /* $Id: antimoniker.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */ 1 2 /*************************************************************************************** 2 * AntiMonikers implementation3 * AntiMonikers implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 22 23 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 23 24 24 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 25 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 25 26 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 26 27 */ … … 128 129 { 129 130 ICOM_THIS(AntiMonikerImpl,iface); 130 131 131 132 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 132 133 133 134 /* Perform a sanity check on the parameters.*/ 134 135 if ( (This==0) || (ppvObject==0) ) 135 return E_INVALIDARG;136 136 return E_INVALIDARG; 137 137 138 /* Initialize the return parameter */ 138 139 *ppvObject = 0; … … 151 152 if ((*ppvObject)==0) 152 153 return E_NOINTERFACE; 153 154 154 155 /* Query Interface always increases the reference count by one when it is successful */ 155 156 AntiMonikerImpl_AddRef(iface); … … 200 201 if (pClassID==NULL) 201 202 return E_POINTER; 202 203 203 204 *pClassID = CLSID_AntiMoniker; 204 205 205 206 return S_OK; 206 207 } … … 244 245 DWORD constant=1; 245 246 HRESULT res; 246 247 247 248 /* data writen by this function is only a DWORD constant seted to 1 ! */ 248 249 res=IStream_Write(pStm,&constant,sizeof(constant),NULL); … … 263 264 264 265 /* for more details see AntiMonikerImpl_Save coments */ 265 266 266 267 /* Normaly the sizemax must be the size of DWORD ! but I tested this function it ususlly return 16 bytes */ 267 268 /* more than the number of bytes used by AntiMoniker::Save function */ … … 342 343 343 344 *ppmkReduced=iface; 344 345 345 346 return MK_S_REDUCED_TO_SELF; 346 347 } … … 357 358 358 359 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 359 return E_POINTER;360 return E_POINTER; 360 361 361 362 *ppmkComposite=0; 362 363 363 364 if (fOnlyIfNotGeneric) 364 365 return MK_E_NEEDGENERIC; … … 376 377 if (ppenumMoniker == NULL) 377 378 return E_POINTER; 378 379 379 380 *ppenumMoniker = NULL; 380 381 … … 388 389 { 389 390 DWORD mkSys; 390 391 391 392 TRACE("(%p,%p)\n",iface,pmkOtherMoniker); 392 393 393 394 if (pmkOtherMoniker==NULL) 394 395 return S_FALSE; 395 396 396 397 IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); 397 398 … … 476 477 { 477 478 DWORD mkSys; 478 479 479 480 IMoniker_IsSystemMoniker(pmkOther,&mkSys); 480 481 … … 486 487 487 488 IMoniker_AddRef(iface); 488 489 489 490 return MK_S_US; 490 491 } … … 519 520 { 520 521 WCHAR back[]={'\\','.','.',0}; 521 522 522 523 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName); 523 524 … … 536 537 537 538 strcpyW(*ppszDisplayName,back); 538 539 539 540 return S_OK; 540 541 } … … 563 564 if (!pwdMksys) 564 565 return E_POINTER; 565 566 566 567 (*pwdMksys)=MKSYS_ANTIMONIKER; 567 568 … … 600 601 { 601 602 ICOM_THIS_From_IROTData(IMoniker, iface); 602 603 603 604 TRACE("(%p)\n",iface); 604 605 … … 619 620 620 621 /****************************************************************************** 621 * CreateAntiMoniker [OLE.55]622 * CreateAntiMoniker [OLE.55] 622 623 ******************************************************************************/ 623 624 HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk) … … 626 627 HRESULT hr = S_OK; 627 628 IID riid=IID_IMoniker; 628 629 629 630 TRACE("(%p)\n",ppmk); 630 631 -
trunk/src/ole32/bindctx.c
r5602 r6648 1 /* $Id: bindctx.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */ 1 2 /*************************************************************************************** 2 * BindCtx implementation3 * BindCtx implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 20 21 21 22 /* represent the first size table and it's increment block size */ 22 #define BLOCK_TAB_SIZE 10 23 #define BLOCK_TAB_SIZE 10 23 24 #define MAX_TAB_SIZE 0xFFFFFFFF 24 25 … … 38 39 39 40 ICOM_VFIELD(IBindCtx); /* VTable relative to the IBindCtx interface.*/ 40 41 41 42 ULONG ref; /* reference counter for this object */ 42 43 … … 102 103 if ( (This==0) || (ppvObject==0) ) 103 104 return E_INVALIDARG; 104 105 105 106 /* Initialize the return parameter.*/ 106 107 *ppvObject = 0; … … 116 117 if ((*ppvObject)==0) 117 118 return E_NOINTERFACE; 118 119 119 120 /* Query Interface always increases the reference count by one when it is successful */ 120 121 BindCtxImpl_AddRef(iface); … … 223 224 if (punk==NULL) 224 225 return E_POINTER; 225 226 226 227 IUnknown_AddRef(punk); 227 228 228 229 /* put the object in the first free element in the table */ 229 230 This->bindCtxTable[lastIndex].pObj = punk; … … 263 264 /* check if the object was registred or not */ 264 265 if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE) 265 266 266 267 return MK_E_NOTBOUND; 267 268 268 269 IUnknown_Release(This->bindCtxTable[index].pObj); 269 270 270 271 /* left-shift all elements in the right side of the current revoked object */ 271 272 for(j=index; j<This->bindCtxTableLastIndex-1; j++) 272 273 This->bindCtxTable[j]= This->bindCtxTable[j+1]; 273 274 274 275 This->bindCtxTableLastIndex--; 275 276 … … 307 308 if (pbindopts==NULL) 308 309 return E_POINTER; 309 310 310 311 if (pbindopts->cbStruct > sizeof(BIND_OPTS2)) 311 312 { … … 351 352 if (pprot==NULL) 352 353 return E_POINTER; 353 354 354 355 res=GetRunningObjectTable(0, pprot); 355 356 … … 368 369 if (punk==NULL) 369 370 return E_INVALIDARG; 370 371 371 372 IUnknown_AddRef(punk); 372 373 … … 389 390 390 391 This->bindCtxTableLastIndex++; 391 392 392 393 if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */ 393 394 … … 419 420 420 421 *punk=0; 421 422 422 423 if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE) 423 424 return E_FAIL; 424 425 425 426 IUnknown_AddRef(This->bindCtxTable[index].pObj); 426 427 427 428 *punk = This->bindCtxTable[index].pObj; 428 429 … … 446 447 /* release the object if it's found */ 447 448 IUnknown_Release(This->bindCtxTable[index].pObj); 448 449 449 450 /* remove the object from the table with a left-shifting of all objects in the right side */ 450 451 for(j=index; j<This->bindCtxTableLastIndex-1; j++) 451 452 This->bindCtxTable[j]= This->bindCtxTable[j+1]; 452 453 453 454 This->bindCtxTableLastIndex--; 454 455 … … 476 477 DWORD i; 477 478 BYTE found=0; 478 479 479 480 TRACE("(%p,%p,%p,%p)\n",This,punk,pszkey,index); 480 481 -
trunk/src/ole32/clipboard.c
r5602 r6648 1 /* $Id: clipboard.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */ 1 2 /* 2 3 * OLE 2 clipboard support … … 81 82 82 83 /* 83 * The hidden OLE clipboard window. This window is used as the bridge between the 84 * The hidden OLE clipboard window. This window is used as the bridge between the 84 85 * the OLE and windows clipboard API. (Windows creates one such window per process) 85 86 */ … … 114 115 * DO NOT add any members before the VTables declaration! 115 116 */ 116 typedef struct 117 typedef struct 117 118 { 118 119 /* IEnumFORMATETC VTable */ 119 120 ICOM_VFIELD(IEnumFORMATETC); 120 121 121 122 /* IEnumFORMATETC fields */ 122 123 UINT posFmt; /* current enumerator position */ … … 133 134 */ 134 135 IUnknown* pUnkDataObj; 135 136 136 137 } IEnumFORMATETCImpl; 137 138 … … 172 173 REFIID riid, 173 174 void** ppvObject); 174 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 175 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 175 176 IDataObject* iface); 176 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 177 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 177 178 IDataObject* iface); 178 179 static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( 179 IDataObject* iface,180 LPFORMATETC pformatetcIn, 181 STGMEDIUM* pmedium);180 IDataObject* iface, 181 LPFORMATETC pformatetcIn, 182 STGMEDIUM* pmedium); 182 183 static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere( 183 IDataObject* iface, 184 LPFORMATETC pformatetc,185 STGMEDIUM* pmedium);184 IDataObject* iface, 185 LPFORMATETC pformatetc, 186 STGMEDIUM* pmedium); 186 187 static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData( 187 IDataObject* iface,188 LPFORMATETC pformatetc);188 IDataObject* iface, 189 LPFORMATETC pformatetc); 189 190 static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc( 190 IDataObject* iface, 191 LPFORMATETC pformatectIn, 192 LPFORMATETC pformatetcOut);191 IDataObject* iface, 192 LPFORMATETC pformatectIn, 193 LPFORMATETC pformatetcOut); 193 194 static HRESULT WINAPI OLEClipbrd_IDataObject_SetData( 194 IDataObject* iface,195 LPFORMATETC pformatetc, 196 STGMEDIUM* pmedium, 197 BOOL fRelease);195 IDataObject* iface, 196 LPFORMATETC pformatetc, 197 STGMEDIUM* pmedium, 198 BOOL fRelease); 198 199 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( 199 IDataObject* iface, 200 DWORD dwDirection,201 IEnumFORMATETC** ppenumFormatEtc);200 IDataObject* iface, 201 DWORD dwDirection, 202 IEnumFORMATETC** ppenumFormatEtc); 202 203 static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise( 203 IDataObject* iface, 204 FORMATETC* pformatetc, 205 DWORD advf, 206 IAdviseSink* pAdvSink, 207 DWORD* pdwConnection);204 IDataObject* iface, 205 FORMATETC* pformatetc, 206 DWORD advf, 207 IAdviseSink* pAdvSink, 208 DWORD* pdwConnection); 208 209 static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise( 209 IDataObject* iface,210 DWORD dwConnection);210 IDataObject* iface, 211 DWORD dwConnection); 211 212 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise( 212 IDataObject* iface,213 IEnumSTATDATA** ppenumAdvise);213 IDataObject* iface, 214 IEnumSTATDATA** ppenumAdvise); 214 215 215 216 /* … … 265 266 266 267 /* 267 * Name of our registered OLE clipboard window class 268 * Name of our registered OLE clipboard window class 268 269 */ 269 270 CHAR OLEClipbrd_WNDCLASS[] = "CLIPBRDWNDCLASS"; … … 279 280 280 281 /*---------------------------------------------------------------------* 281 * Win32 OLE clipboard API 282 * Win32 OLE clipboard API 282 283 *---------------------------------------------------------------------*/ 283 284 … … 290 291 * 291 292 * S_OK IDataObject pointer placed on the clipboard 292 * CLIPBRD_E_CANT_OPEN OpenClipboard failed 293 * CLIPBRD_E_CANT_EMPTY EmptyClipboard failed 293 * CLIPBRD_E_CANT_OPEN OpenClipboard failed 294 * CLIPBRD_E_CANT_EMPTY EmptyClipboard failed 294 295 * CLIPBRD_E_CANT_CLOSE CloseClipboard failed 295 296 * CLIPBRD_E_CANT_SET SetClipboard failed … … 306 307 OLEClipbrd **ppDataObject; 307 308 */ 308 309 309 310 TRACE("(%p)\n", pDataObj); 310 311 311 312 /* 312 313 * Make sure we have a clipboard object … … 331 332 /* 332 333 * Empty the current clipboard and make our window the clipboard owner 333 * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 334 * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 334 335 */ 335 336 if ( !EmptyClipboard() ) … … 356 357 357 358 /* 358 * Enumerate all HGLOBAL formats supported by the source and make 359 * Enumerate all HGLOBAL formats supported by the source and make 359 360 * those formats available using delayed rendering using SetClipboardData. 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 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 362 363 * mediums(non TYMED_HGLOBAL) can only be accessed via the Ole Clipboard API. 363 364 * … … 373 374 HANDLE_ERROR( hr ); 374 375 } 375 376 376 377 while ( S_OK == IEnumFORMATETC_Next(penumFormatetc, 1, &rgelt, NULL) ) 377 378 { … … 382 383 GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1) 383 384 ? szFmtName : ""); 384 385 385 386 SetClipboardData( rgelt.cfFormat, (HANDLE)NULL); 386 387 } … … 391 392 /* 392 393 * Windows additionally creates a new "DataObject" clipboard format 393 * and stores in on the clipboard. We could possibly store a pointer 394 * and stores in on the clipboard. We could possibly store a pointer 394 395 * to our internal IDataObject interface on the clipboard. I'm not 395 396 * sure what the use of this is though. … … 402 403 if (hDataObject==0) 403 404 HANDLE_ERROR( E_OUTOFMEMORY ); 404 405 405 406 ppDataObject = (OLEClipbrd**)GlobalLock(hDataObject); 406 407 *ppDataObject = theOleClipboard; … … 410 411 HANDLE_ERROR( CLIPBRD_E_CANT_SET ); 411 412 */ 412 413 413 414 hr = S_OK; 414 415 … … 439 440 /*********************************************************************** 440 441 * OleGetClipboard [OLE32.105] 441 * Returns a pointer to our internal IDataObject which represents the conceptual 442 * state of the Windows clipboard. If the current clipboard already contains 442 * Returns a pointer to our internal IDataObject which represents the conceptual 443 * state of the Windows clipboard. If the current clipboard already contains 443 444 * an IDataObject, our internal IDataObject will delegate to this object. 444 445 */ … … 447 448 HRESULT hr = S_OK; 448 449 TRACE("()\n"); 449 450 450 451 /* 451 452 * Make sure we have a clipboard object … … 488 489 BOOL bClipboardOpen = FALSE; 489 490 IDataObject* pIDataObjectSrc = NULL; 490 491 491 492 TRACE("()\n"); 492 493 … … 508 509 pIDataObjectSrc = theOleClipboard->pIDataObjectSrc; 509 510 IDataObject_AddRef(pIDataObjectSrc); 510 511 511 512 /* 512 513 * Open the Windows clipboard … … 548 549 } 549 550 } 550 551 551 552 IEnumFORMATETC_Release(penumFormatetc); 552 553 553 554 /* 554 555 * Release the source data object we are holding on to … … 571 572 * OleIsCurrentClipboard [OLE32.110] 572 573 */ 573 HRESULT WINAPI OleIsCurrentClipboard ( IDataObject *pDataObject) 574 HRESULT WINAPI OleIsCurrentClipboard ( IDataObject *pDataObject) 574 575 { 575 576 TRACE("()\n"); … … 587 588 588 589 /*---------------------------------------------------------------------* 589 * Internal implementation methods for the OLE clipboard 590 * Internal implementation methods for the OLE clipboard 590 591 *---------------------------------------------------------------------*/ 591 592 592 593 /*********************************************************************** 593 594 * OLEClipbrd_Initialize() 594 * Initializes the OLE clipboard. 595 * Initializes the OLE clipboard. 595 596 */ 596 597 void OLEClipbrd_Initialize() 597 598 { 598 599 /* 599 * Create the clipboard if necessary 600 * Create the clipboard if necessary 600 601 */ 601 602 if ( !theOleClipboard ) … … 609 610 /*********************************************************************** 610 611 * OLEClipbrd_UnInitialize() 611 * Un-Initializes the OLE clipboard 612 * Un-Initializes the OLE clipboard 612 613 */ 613 614 void OLEClipbrd_UnInitialize() … … 636 637 OLEClipbrd* newObject = NULL; 637 638 HGLOBAL hNewObject = 0; 638 639 639 640 /* 640 641 * Allocate space for the object. We use GlobalAlloc since we need … … 650 651 */ 651 652 newObject = GlobalLock(hNewObject); 652 653 653 654 /* 654 655 * Initialize the virtual function table. … … 657 658 658 659 /* 659 * Start with one reference count. The caller of this function 660 * Start with one reference count. The caller of this function 660 661 * must release the interface pointer when it is done. 661 662 */ … … 663 664 664 665 newObject->hSelf = hNewObject; 665 666 666 667 /* 667 668 * The Ole clipboard is a singleton - save the global handle and pointer … … 676 677 { 677 678 TRACE("()\n"); 678 679 679 680 if ( !ptrToDestroy ) 680 681 return; 681 682 682 683 /* 683 * Destroy the Ole clipboard window 684 * Destroy the Ole clipboard window 684 685 */ 685 686 if ( ptrToDestroy->hWndClipboard ) … … 703 704 /*********************************************************************** 704 705 * OLEClipbrd_CreateWindow() 705 * Create the clipboard window 706 * Create the clipboard window 706 707 */ 707 708 static HWND OLEClipbrd_CreateWindow() … … 710 711 WNDCLASSEXA wcex; 711 712 712 /* 713 * Register the clipboard window class if necessary 713 /* 714 * Register the clipboard window class if necessary 714 715 */ 715 716 ZeroMemory( &wcex, sizeof(WNDCLASSEXA)); … … 727 728 728 729 /* 729 * Create a hidden window to receive OLE clipboard messages 730 * Create a hidden window to receive OLE clipboard messages 730 731 */ 731 732 … … 737 738 */ 738 739 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 */);740 hwnd = CreateWindowA(OLEClipbrd_WNDCLASS, 741 "ClipboardWindow", 742 WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED, 743 CW_USEDEFAULT, CW_USEDEFAULT, 744 CW_USEDEFAULT, CW_USEDEFAULT, 745 0, 746 0, 747 0, 748 0 /*(LPVOID)&clipboardInfo */); 748 749 749 750 return hwnd; … … 756 757 static void OLEClipbrd_DestroyWindow(HWND hwnd) 757 758 { 758 /* 759 * Destroy clipboard window and unregister its WNDCLASS 759 /* 760 * Destroy clipboard window and unregister its WNDCLASS 760 761 */ 761 762 DestroyWindow(hwnd); … … 765 766 /*********************************************************************** 766 767 * OLEClipbrd_WndProc(HWND, unsigned, WORD, LONG) 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(). 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(). 770 771 * i.e. Only when OLE owns the windows clipboard. 771 772 */ … … 773 774 (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 774 775 { 775 switch (message) 776 switch (message) 776 777 { 777 778 /* 778 * WM_RENDERFORMAT 779 * WM_RENDERFORMAT 779 780 * We receive this message to allow us to handle delayed rendering of 780 * a specific clipboard format when an application requests data in 781 * a specific clipboard format when an application requests data in 781 782 * that format by calling GetClipboardData. 782 * (Recall that in OleSetClipboard, we used SetClipboardData to 783 * (Recall that in OleSetClipboard, we used SetClipboardData to 783 784 * make all HGLOBAL formats supported by the source IDataObject 784 785 * available using delayed rendering) 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. 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. 788 789 */ 789 790 case WM_RENDERFORMAT: 790 791 { 791 792 FORMATETC rgelt; 792 793 793 794 ZeroMemory( &rgelt, sizeof(FORMATETC)); 794 795 … … 802 803 803 804 TRACE("(): WM_RENDERFORMAT(cfFormat=%d)\n", rgelt.cfFormat); 804 805 805 806 /* 806 807 * Render the clipboard data. … … 826 827 IEnumFORMATETC* penumFormatetc = NULL; 827 828 FORMATETC rgelt; 828 829 829 830 TRACE("(): WM_RENDERALLFORMATS\n"); 830 831 831 832 /* 832 833 * Render all HGLOBAL formats supported by the source into … … 845 846 { 846 847 /* 847 * Render the clipboard data. 848 * Render the clipboard data. 848 849 */ 849 850 if ( FAILED(OLEClipbrd_RenderFormat( (IDataObject*)&(theOleClipboard->lpvtbl1), &rgelt )) ) 850 851 continue; 851 852 852 853 TRACE("(): WM_RENDERALLFORMATS(cfFormat=%d)\n", rgelt.cfFormat); 853 854 } 854 855 } 855 856 856 857 IEnumFORMATETC_Release(penumFormatetc); 857 858 … … 992 993 993 994 HeapFree(GetProcessHeap(), 0, mfBits); 994 995 995 996 GlobalUnlock(std2.u.hMetaFilePict); 996 997 … … 1020 1021 * Put a copy of the rendered data back on the clipboard 1021 1022 */ 1022 1023 1023 1024 if ( !(hDup = OLEClipbrd_GlobalDupMem(hStorage)) ) 1024 1025 HANDLE_ERROR( E_OUTOFMEMORY ); 1025 1026 1026 1027 if ( !SetClipboardData( pFormatetc->cfFormat, hDup ) ) 1027 1028 { … … 1031 1032 1032 1033 CLEANUP: 1033 1034 1034 1035 ReleaseStgMedium(&std); 1035 1036 1036 1037 return hr; 1037 1038 } … … 1047 1048 PVOID pGlobalSrc, pGlobalDest; 1048 1049 DWORD cBytes; 1049 1050 1050 1051 if ( !hGlobalSrc ) 1051 1052 return 0; … … 1054 1055 if ( 0 == cBytes ) 1055 1056 return 0; 1056 1057 1057 1058 hGlobalDest = GlobalAlloc( GMEM_DDESHARE|GMEM_MOVEABLE, 1058 1059 cBytes ); 1059 1060 if ( !hGlobalDest ) 1060 1061 return 0; 1061 1062 1062 1063 pGlobalSrc = GlobalLock(hGlobalSrc); 1063 1064 pGlobalDest = GlobalLock(hGlobalDest); … … 1066 1067 1067 1068 memcpy(pGlobalDest, pGlobalSrc, cBytes); 1068 1069 1069 1070 GlobalUnlock(hGlobalSrc); 1070 1071 GlobalUnlock(hGlobalDest); … … 1075 1076 1076 1077 /*---------------------------------------------------------------------* 1077 * Implementation of the internal IDataObject interface exposed by 1078 * Implementation of the internal IDataObject interface exposed by 1078 1079 * the OLE clipboard. 1079 1080 *---------------------------------------------------------------------*/ … … 1090 1091 void** ppvObject) 1091 1092 { 1092 /* 1093 * Declare "This" pointer 1093 /* 1094 * Declare "This" pointer 1094 1095 */ 1095 1096 ICOM_THIS(OLEClipbrd, iface); 1096 1097 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObject); 1097 1098 1098 1099 /* 1099 1100 * Perform a sanity check on the parameters. … … 1101 1102 if ( (This==0) || (ppvObject==0) ) 1102 1103 return E_INVALIDARG; 1103 1104 1104 1105 /* 1105 1106 * Initialize the return parameter. … … 1110 1111 * Compare the riid with the interface IDs implemented by this object. 1111 1112 */ 1112 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 1113 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 1113 1114 { 1114 1115 *ppvObject = iface; 1115 1116 } 1116 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 1117 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 1117 1118 { 1118 1119 *ppvObject = (IDataObject*)&(This->lpvtbl1); … … 1123 1124 return E_NOINTERFACE; 1124 1125 } 1125 1126 1126 1127 /* 1127 1128 * Query Interface always increases the reference count by one when it is 1128 * successful. 1129 * successful. 1129 1130 */ 1130 1131 IUnknown_AddRef((IUnknown*)*ppvObject); … … 1138 1139 * See Windows documentation for more details on IUnknown methods. 1139 1140 */ 1140 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 1141 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 1141 1142 IDataObject* iface) 1142 1143 { 1143 /* 1144 * Declare "This" pointer 1144 /* 1145 * Declare "This" pointer 1145 1146 */ 1146 1147 ICOM_THIS(OLEClipbrd, iface); 1147 1148 1148 1149 TRACE("(%p)->(count=%lu)\n",This, This->ref); 1149 1150 1150 1151 This->ref++; 1151 1152 … … 1158 1159 * See Windows documentation for more details on IUnknown methods. 1159 1160 */ 1160 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 1161 static ULONG WINAPI OLEClipbrd_IDataObject_Release( 1161 1162 IDataObject* iface) 1162 1163 { 1163 /* 1164 * Declare "This" pointer 1164 /* 1165 * Declare "This" pointer 1165 1166 */ 1166 1167 ICOM_THIS(OLEClipbrd, iface); 1167 1168 1168 1169 TRACE("(%p)->(count=%lu)\n",This, This->ref); 1169 1170 1170 1171 /* 1171 1172 * Decrease the reference count on this object. … … 1180 1181 OLEClipbrd_Destroy(This); 1181 1182 } 1182 1183 1183 1184 return This->ref; 1184 1185 } 1185 1186 1186 1187 1187 1188 /************************************************************************ 1188 1189 * OLEClipbrd_IDataObject_GetData (IDataObject) 1189 1190 * 1190 * The OLE Clipboard's implementation of this method delegates to 1191 * The OLE Clipboard's implementation of this method delegates to 1191 1192 * a data source if there is one or wraps around the windows clipboard 1192 1193 * … … 1194 1195 */ 1195 1196 static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( 1196 IDataObject* iface,1197 LPFORMATETC pformatetcIn, 1198 STGMEDIUM* pmedium)1197 IDataObject* iface, 1198 LPFORMATETC pformatetcIn, 1199 STGMEDIUM* pmedium) 1199 1200 { 1200 1201 HANDLE hData = 0; … … 1203 1204 1204 1205 /* 1205 * Declare "This" pointer 1206 * Declare "This" pointer 1206 1207 */ 1207 1208 ICOM_THIS(OLEClipbrd, iface); 1208 1209 1209 1210 TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium); 1210 1211 … … 1232 1233 */ 1233 1234 1234 /* 1235 /* 1235 1236 * Otherwise, get the data from the windows clipboard using GetClipboardData 1236 1237 */ … … 1240 1241 hData = GetClipboardData(pformatetcIn->cfFormat); 1241 1242 1242 /* 1243 /* 1243 1244 * Return the clipboard data in the storage medium structure 1244 1245 */ … … 1246 1247 pmedium->u.hGlobal = (HGLOBAL)hData; 1247 1248 pmedium->pUnkForRelease = NULL; 1248 1249 1249 1250 hr = S_OK; 1250 1251 1251 1252 CLEANUP: 1252 1253 /* … … 1262 1263 1263 1264 static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere( 1264 IDataObject* iface, 1265 LPFORMATETC pformatetc,1266 STGMEDIUM* pmedium)1265 IDataObject* iface, 1266 LPFORMATETC pformatetc, 1267 STGMEDIUM* pmedium) 1267 1268 { 1268 1269 FIXME(": Stub\n"); … … 1273 1274 * OLEClipbrd_IDataObject_QueryGetData (IDataObject) 1274 1275 * 1275 * The OLE Clipboard's implementation of this method delegates to 1276 * The OLE Clipboard's implementation of this method delegates to 1276 1277 * a data source if there is one or wraps around the windows clipboard 1277 1278 * function IsClipboardFormatAvailable() otherwise. … … 1280 1281 */ 1281 1282 static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData( 1282 IDataObject* iface,1283 LPFORMATETC pformatetc)1284 { 1285 /* 1286 * Declare "This" pointer 1283 IDataObject* iface, 1284 LPFORMATETC pformatetc) 1285 { 1286 /* 1287 * Declare "This" pointer 1287 1288 */ 1288 1289 ICOM_THIS(OLEClipbrd, iface); … … 1314 1315 if ( pformatetc->tymed != TYMED_HGLOBAL ) 1315 1316 return DV_E_TYMED; 1316 1317 1317 1318 /* 1318 1319 * Delegate to the Windows clipboard function IsClipboardFormatAvailable … … 1327 1328 */ 1328 1329 static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc( 1329 IDataObject* iface, 1330 LPFORMATETC pformatectIn, 1331 LPFORMATETC pformatetcOut)1330 IDataObject* iface, 1331 LPFORMATETC pformatectIn, 1332 LPFORMATETC pformatetcOut) 1332 1333 { 1333 1334 TRACE("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut); … … 1343 1344 * OLEClipbrd_IDataObject_SetData (IDataObject) 1344 1345 * 1345 * The OLE Clipboard's does not implement this method 1346 * The OLE Clipboard's does not implement this method 1346 1347 * 1347 1348 * See Windows documentation for more details on IDataObject methods. 1348 1349 */ 1349 1350 static HRESULT WINAPI OLEClipbrd_IDataObject_SetData( 1350 IDataObject* iface,1351 LPFORMATETC pformatetc, 1352 STGMEDIUM* pmedium, 1353 BOOL fRelease)1351 IDataObject* iface, 1352 LPFORMATETC pformatetc, 1353 STGMEDIUM* pmedium, 1354 BOOL fRelease) 1354 1355 { 1355 1356 TRACE("\n"); … … 1363 1364 */ 1364 1365 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc( 1365 IDataObject* iface,1366 DWORD dwDirection,1367 IEnumFORMATETC** ppenumFormatEtc)1366 IDataObject* iface, 1367 DWORD dwDirection, 1368 IEnumFORMATETC** ppenumFormatEtc) 1368 1369 { 1369 1370 HRESULT hr = S_OK; … … 1372 1373 UINT format; 1373 1374 BOOL bClipboardOpen; 1374 1375 /* 1376 * Declare "This" pointer 1375 1376 /* 1377 * Declare "This" pointer 1377 1378 */ 1378 1379 ICOM_THIS(OLEClipbrd, iface); … … 1427 1428 HANDLE_ERROR( E_FAIL ); 1428 1429 } 1429 1430 1430 1431 /* Init the FORMATETC struct */ 1431 1432 afmt[i].cfFormat = format; … … 1446 1447 if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc))) 1447 1448 HANDLE_ERROR( hr ); 1448 1449 1449 1450 hr = S_OK; 1450 1451 1451 1452 CLEANUP: 1452 1453 /* … … 1455 1456 if (afmt) 1456 1457 HeapFree(GetProcessHeap(), 0, afmt); 1457 1458 1458 1459 /* 1459 1460 * Close Windows clipboard … … 1468 1469 * OLEClipbrd_IDataObject_DAdvise (IDataObject) 1469 1470 * 1470 * The OLE Clipboard's does not implement this method 1471 * The OLE Clipboard's does not implement this method 1471 1472 * 1472 1473 * See Windows documentation for more details on IDataObject methods. 1473 1474 */ 1474 1475 static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise( 1475 IDataObject* iface, 1476 FORMATETC* pformatetc, 1477 DWORD advf, 1478 IAdviseSink* pAdvSink, 1479 DWORD* pdwConnection)1476 IDataObject* iface, 1477 FORMATETC* pformatetc, 1478 DWORD advf, 1479 IAdviseSink* pAdvSink, 1480 DWORD* pdwConnection) 1480 1481 { 1481 1482 TRACE("\n"); … … 1486 1487 * OLEClipbrd_IDataObject_DUnadvise (IDataObject) 1487 1488 * 1488 * The OLE Clipboard's does not implement this method 1489 * The OLE Clipboard's does not implement this method 1489 1490 * 1490 1491 * See Windows documentation for more details on IDataObject methods. 1491 1492 */ 1492 1493 static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise( 1493 IDataObject* iface,1494 DWORD dwConnection)1494 IDataObject* iface, 1495 DWORD dwConnection) 1495 1496 { 1496 1497 TRACE("\n"); … … 1506 1507 */ 1507 1508 static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise( 1508 IDataObject* iface,1509 IEnumSTATDATA** ppenumAdvise)1509 IDataObject* iface, 1510 IEnumSTATDATA** ppenumAdvise) 1510 1511 { 1511 1512 TRACE("\n"); … … 1533 1534 DWORD size=cfmt * sizeof(FORMATETC); 1534 1535 LPMALLOC pIMalloc; 1535 1536 1536 1537 ef = (IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(), 1537 1538 HEAP_ZERO_MEMORY, … … 1539 1540 if (!ef) 1540 1541 return NULL; 1541 1542 1542 1543 ef->ref = 0; 1543 1544 ICOM_VTBL(ef) = &efvt; 1544 1545 ef->pUnkDataObj = pUnkDataObj; 1545 1546 1546 1547 ef->posFmt = 0; 1547 1548 ef->countFmt = cfmt; … … 1550 1551 ef->pFmt = (LPFORMATETC)IMalloc_Alloc(pIMalloc, size); 1551 1552 IMalloc_Release(pIMalloc); 1552 1553 1553 1554 if (ef->pFmt) 1554 1555 memcpy(ef->pFmt, afmt, size); 1555 1556 1556 1557 TRACE("(%p)->()\n",ef); 1557 1558 return (LPENUMFORMATETC)ef; … … 1575 1576 * we only need to support the IUnknown and IEnumFORMATETC interfaces 1576 1577 */ 1577 1578 1578 1579 *ppvObj = NULL; 1579 1580 1580 1581 if(IsEqualIID(riid, &IID_IUnknown)) 1581 1582 { … … 1585 1586 { 1586 1587 *ppvObj = (IDataObject*)This; 1587 } 1588 1588 } 1589 1589 1590 if(*ppvObj) 1590 1591 { … … 1593 1594 return S_OK; 1594 1595 } 1595 1596 1596 1597 TRACE("-- Interface: E_NOINTERFACE\n"); 1597 1598 return E_NOINTERFACE; … … 1614 1615 if (This->pUnkDataObj) 1615 1616 IUnknown_AddRef(This->pUnkDataObj); 1616 1617 1617 1618 return ++(This->ref); 1618 1619 } … … 1632 1633 if (This->pUnkDataObj) 1633 1634 IUnknown_Release(This->pUnkDataObj); /* Release parent data object */ 1634 1635 if (!--(This->ref)) 1635 1636 if (!--(This->ref)) 1636 1637 { 1637 1638 TRACE("() - destroying IEnumFORMATETC(%p)\n",This); … … 1641 1642 IMalloc_Release(pIMalloc); 1642 1643 } 1643 1644 1644 1645 HeapFree(GetProcessHeap(),0,This); 1645 1646 return 0; … … 1660 1661 UINT cfetch; 1661 1662 HRESULT hres = S_FALSE; 1662 1663 1663 1664 TRACE("(%p)->(pos=%u)\n", This, This->posFmt); 1664 1665 1665 1666 if (This->posFmt < This->countFmt) 1666 1667 { … … 1671 1672 hres = S_OK; 1672 1673 } 1673 1674 1674 1675 memcpy(rgelt, &This->pFmt[This->posFmt], cfetch * sizeof(FORMATETC)); 1675 1676 This->posFmt += cfetch; … … 1679 1680 cfetch = 0; 1680 1681 } 1681 1682 1682 1683 if (pceltFethed) 1683 1684 { 1684 1685 *pceltFethed = cfetch; 1685 1686 } 1686 1687 1687 1688 return hres; 1688 1689 } … … 1697 1698 ICOM_THIS(IEnumFORMATETCImpl,iface); 1698 1699 TRACE("(%p)->(num=%lu)\n", This, celt); 1699 1700 1700 1701 This->posFmt += celt; 1701 1702 if (This->posFmt > This->countFmt) … … 1716 1717 ICOM_THIS(IEnumFORMATETCImpl,iface); 1717 1718 TRACE("(%p)->()\n", This); 1718 1719 1719 1720 This->posFmt = 0; 1720 1721 return S_OK; … … 1731 1732 ICOM_THIS(IEnumFORMATETCImpl,iface); 1732 1733 HRESULT hr = S_OK; 1733 1734 1734 1735 TRACE("(%p)->(ppenum=%p)\n", This, ppenum); 1735 1736 … … 1743 1744 if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum))) 1744 1745 return ( hr ); 1745 1746 1746 1747 return (*ppenum) ? S_OK : E_OUTOFMEMORY; 1747 1748 } -
trunk/src/ole32/compobj.c
r5602 r6648 1 /* $Id: compobj.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */ 1 2 /* 2 * COMPOBJ library3 * 4 * Copyright 1995Martin von Loewis5 * Copyright 1998Justin Bradford3 * COMPOBJ library 4 * 5 * Copyright 1995 Martin von Loewis 6 * Copyright 1998 Justin Bradford 6 7 * Copyright 1999 Francis Beaudet 7 8 * Copyright 1999 Sylvain St-Germain … … 44 45 * COM External Lock structures and methods declaration 45 46 * 46 * This api provides a linked list to managed external references to 47 * COM objects. 48 * 49 * The public interface consists of three calls: 47 * This api provides a linked list to managed external references to 48 * COM objects. 49 * 50 * The public interface consists of three calls: 50 51 * COM_ExternalLockAddRef 51 52 * COM_ExternalLockRelease … … 57 58 58 59 /* 59 * Declaration of the static structure that manage the 60 * Declaration of the static structure that manage the 60 61 * external lock to COM objects. 61 62 */ … … 82 83 83 84 /* 84 * Public Interface to the external lock list 85 * Public Interface to the external lock list 85 86 */ 86 87 static void COM_ExternalLockFreeList(); … … 90 91 91 92 /* 92 * Private methods used to managed the linked list 93 * Private methods used to managed the linked list 93 94 */ 94 95 static BOOL COM_ExternalLockInsert( … … 152 153 */ 153 154 typedef struct tagOpenDll { 154 HINSTANCE hLibrary; 155 HINSTANCE hLibrary; 155 156 struct tagOpenDll *next; 156 157 } OpenDll; … … 163 164 */ 164 165 static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, 165 DWORD dwClsContext,166 LPUNKNOWN* ppUnk);166 DWORD dwClsContext, 167 LPUNKNOWN* ppUnk); 167 168 168 169 static void COM_RevokeAllClasses(); … … 173 174 * 174 175 * RETURNS 175 * Current build version, hiword is majornumber, loword is minornumber176 * Current build version, hiword is majornumber, loword is minornumber 176 177 */ 177 178 DWORD WINAPI CoBuildVersion(void) … … 183 184 #ifndef __WIN32OS2__ 184 185 /****************************************************************************** 185 * CoInitialize16[COMPOBJ.2]186 * CoInitialize16 [COMPOBJ.2] 186 187 * Set the win16 IMalloc used for memory management 187 188 */ 188 189 HRESULT WINAPI CoInitialize16( 189 LPVOID lpReserved/* [in] pointer to win16 malloc interface */190 LPVOID lpReserved /* [in] pointer to win16 malloc interface */ 190 191 ) { 191 192 currentMalloc16 = (LPMALLOC16)lpReserved; … … 195 196 196 197 /****************************************************************************** 197 * CoInitialize[OLE32.26]198 * CoInitialize [OLE32.26] 198 199 * 199 200 * Initializes the COM libraries. … … 202 203 */ 203 204 HRESULT WINAPI CoInitialize( 204 LPVOID lpReserved/* [in] pointer to win32 malloc interface205 LPVOID lpReserved /* [in] pointer to win32 malloc interface 205 206 (obsolete, should be NULL) */ 206 ) 207 ) 207 208 { 208 209 /* … … 213 214 214 215 /****************************************************************************** 215 * CoInitializeEx[OLE32.163]216 * CoInitializeEx [OLE32.163] 216 217 * 217 218 * Initializes the COM libraries. The behavior used to set the win32 IMalloc … … 225 226 * 226 227 * BUGS 227 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 228 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 228 229 * is never returned. 229 230 * … … 231 232 */ 232 233 HRESULT WINAPI CoInitializeEx( 233 LPVOID lpReserved,/* [in] pointer to win32 malloc interface234 LPVOID lpReserved, /* [in] pointer to win32 malloc interface 234 235 (obsolete, should be NULL) */ 235 DWORD dwCoInit/* [in] A value from COINIT specifies the threading model */236 ) 236 DWORD dwCoInit /* [in] A value from COINIT specifies the threading model */ 237 ) 237 238 { 238 239 HRESULT hr; … … 248 249 * Check for unsupported features. 249 250 */ 250 if (dwCoInit!=COINIT_APARTMENTTHREADED) 251 if (dwCoInit!=COINIT_APARTMENTTHREADED) 251 252 { 252 253 FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit); … … 283 284 /*********************************************************************** 284 285 * CoUninitialize16 [COMPOBJ.3] 285 * Don't know what it does. 286 * Don't know what it does. 286 287 * 3-Nov-98 -- this was originally misspelled, I changed it to what I 287 288 * believe is the correct spelling … … 304 305 { 305 306 TRACE("()\n"); 306 307 307 308 /* 308 309 * Decrease the reference count. 309 310 */ 310 311 s_COMLockCount--; 311 312 312 313 /* 313 314 * If we are back to 0 locks on the COM library, make sure we free … … 343 344 * CoGetMalloc16 [COMPOBJ.4] 344 345 * RETURNS 345 * The current win16 IMalloc346 * The current win16 IMalloc 346 347 */ 347 348 HRESULT WINAPI CoGetMalloc16( 348 DWORD dwMemContext,/* [in] unknown */349 LPMALLOC16 * lpMalloc/* [out] current win16 malloc interface */349 DWORD dwMemContext, /* [in] unknown */ 350 LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */ 350 351 ) { 351 352 if(!currentMalloc16) 352 currentMalloc16 = IMalloc16_Constructor();353 currentMalloc16 = IMalloc16_Constructor(); 353 354 *lpMalloc = currentMalloc16; 354 355 return S_OK; … … 357 358 358 359 /****************************************************************************** 359 * CoGetMalloc[OLE32.20]360 * CoGetMalloc [OLE32.20] 360 361 * 361 362 * RETURNS 362 * The current win32 IMalloc363 * The current win32 IMalloc 363 364 */ 364 365 HRESULT WINAPI CoGetMalloc( 365 DWORD dwMemContext,/* [in] unknown */366 LPMALLOC *lpMalloc/* [out] current win32 malloc interface */366 DWORD dwMemContext, /* [in] unknown */ 367 LPMALLOC *lpMalloc /* [out] current win32 malloc interface */ 367 368 ) { 368 369 if(!currentMalloc32) 369 currentMalloc32 = IMalloc_Constructor();370 currentMalloc32 = IMalloc_Constructor(); 370 371 *lpMalloc = currentMalloc32; 371 372 return S_OK; … … 377 378 */ 378 379 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, 379 LPMALLOC16 *lpMalloc)380 LPMALLOC16 *lpMalloc) 380 381 { 381 382 /* FIXME: docu says we shouldn't return the same allocator as in … … 386 387 387 388 /****************************************************************************** 388 * CoDisconnectObject[COMPOBJ.15]389 * CoDisconnectObject [COMPOBJ.15] 389 390 */ 390 391 HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) … … 400 401 * 401 402 * RETURNS 402 * TRUE if equal403 * TRUE if equal 403 404 */ 404 405 BOOL16 WINAPI IsEqualGUID16( 405 GUID* g1,/* [in] unique id 1 */406 GUID* g2/* [in] unique id 2 */406 GUID* g1, /* [in] unique id 1 */ 407 GUID* g2 /* [in] unique id 2 */ 407 408 ) { 408 409 return !memcmp( g1, g2, sizeof(GUID) ); … … 411 412 412 413 /****************************************************************************** 413 * CLSIDFromString16[COMPOBJ.20]414 * Converts a unique identifier from its string representation into 414 * CLSIDFromString16 [COMPOBJ.20] 415 * Converts a unique identifier from its string representation into 415 416 * the GUID struct. 416 417 * 417 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 418 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 418 419 * 419 420 * RETURNS 420 * the converted GUID421 * the converted GUID 421 422 */ 422 423 HRESULT WINAPI CLSIDFromString16( 423 LPCOLESTR16 idstr,/* [in] string representation of guid */424 CLSID *id/* [out] GUID converted from string */424 LPCOLESTR16 idstr, /* [in] string representation of guid */ 425 CLSID *id /* [out] GUID converted from string */ 425 426 ) { 426 427 BYTE *s = (BYTE *) idstr; 427 428 BYTE *p; 428 int i;429 int i; 429 430 BYTE table[256]; 430 431 431 432 if (!s) 432 s = "{00000000-0000-0000-0000-000000000000}";433 s = "{00000000-0000-0000-0000-000000000000}"; 433 434 else { /* validate the CLSID string */ 434 435 … … 467 468 p = (BYTE *) id; 468 469 469 s++; /* skip leading brace */470 s++; /* skip leading brace */ 470 471 for (i = 0; i < 4; i++) { 471 472 p[3 - i] = table[*s]<<4 | table[*(s+1)]; … … 473 474 } 474 475 p += 4; 475 s++; /* skip - */476 s++; /* skip - */ 476 477 477 478 for (i = 0; i < 2; i++) { … … 480 481 } 481 482 p += 2; 482 s++; /* skip - */483 s++; /* skip - */ 483 484 484 485 for (i = 0; i < 2; i++) { … … 487 488 } 488 489 p += 2; 489 s++; /* skip - */490 s++; /* skip - */ 490 491 491 492 /* these are just sequential bytes */ … … 494 495 s += 2; 495 496 } 496 s++; /* skip - */497 s++; /* skip - */ 497 498 498 499 for (i = 0; i < 6; i++) { … … 505 506 506 507 /****************************************************************************** 507 * CoCreateGuid[OLE32.6]508 * CoCreateGuid[OLE32.6] 508 509 * 509 510 */ 510 511 HRESULT WINAPI CoCreateGuid( 511 GUID *pguid /* [out] points to the GUID to initialize */512 GUID *pguid /* [out] points to the GUID to initialize */ 512 513 ) { 513 514 return UuidCreate(pguid); … … 515 516 516 517 /****************************************************************************** 517 * CLSIDFromString[OLE32.3]518 * Converts a unique identifier from its string representation into 518 * CLSIDFromString [OLE32.3] 519 * Converts a unique identifier from its string representation into 519 520 * the GUID struct. 520 521 * … … 523 524 * 524 525 * RETURNS 525 * the converted GUID526 * the converted GUID 526 527 */ 527 528 HRESULT WINAPI CLSIDFromString( 528 LPCOLESTR idstr,/* [in] string representation of GUID */529 CLSID *id/* [out] GUID represented by above string */529 LPCOLESTR idstr, /* [in] string representation of GUID */ 530 CLSID *id /* [out] GUID represented by above string */ 530 531 ) { 531 532 LPOLESTR16 xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr); … … 540 541 541 542 /****************************************************************************** 542 * WINE_StringFromCLSID[Internal]543 * WINE_StringFromCLSID [Internal] 543 544 * Converts a GUID into the respective string representation. 544 545 * … … 546 547 * 547 548 * RETURNS 548 * the string representation and HRESULT549 * the string representation and HRESULT 549 550 */ 550 551 #ifdef __WIN32OS2__ 551 552 HRESULT WINAPI WINE_StringFromCLSID( 552 const CLSID *id,/* [in] GUID to be converted */553 LPSTR idstr/* [out] pointer to buffer to contain converted guid */553 const CLSID *id, /* [in] GUID to be converted */ 554 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 554 555 #else 555 556 static HRESULT WINE_StringFromCLSID( 556 const CLSID *id,/* [in] GUID to be converted */557 LPSTR idstr/* [out] pointer to buffer to contain converted guid */557 const CLSID *id, /* [in] GUID to be converted */ 558 LPSTR idstr /* [out] pointer to buffer to contain converted guid */ 558 559 #endif 559 560 ) { 560 561 static const char *hex = "0123456789ABCDEF"; 561 562 char *s; 562 int i;563 int i; 563 564 564 565 if (!id) 565 { ERR("called with id=Null\n");566 *idstr = 0x00;567 return E_FAIL;568 }569 566 { ERR("called with id=Null\n"); 567 *idstr = 0x00; 568 return E_FAIL; 569 } 570 570 571 sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-", 571 id->Data1, id->Data2, id->Data3,572 id->Data4[0], id->Data4[1]);572 id->Data1, id->Data2, id->Data3, 573 id->Data4[0], id->Data4[1]); 573 574 s = &idstr[25]; 574 575 … … 588 589 #ifndef __WIN32OS2__ 589 590 /****************************************************************************** 590 * StringFromCLSID16[COMPOBJ.19]591 * StringFromCLSID16 [COMPOBJ.19] 591 592 * Converts a GUID into the respective string representation. 592 593 * The target string is allocated using the OLE IMalloc. 593 594 * RETURNS 594 * the string representation and HRESULT595 * the string representation and HRESULT 595 596 */ 596 597 HRESULT WINAPI StringFromCLSID16( 597 598 REFCLSID id, /* [in] the GUID to be converted */ 598 LPOLESTR16 *idstr/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */599 LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */ 599 600 600 601 ) { 601 602 extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, 602 603 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode ); 603 LPMALLOC16 mllc;604 HRESULT ret;605 DWORD args[2];604 LPMALLOC16 mllc; 605 HRESULT ret; 606 DWORD args[2]; 606 607 607 608 ret = CoGetMalloc16(0,&mllc); … … 615 616 */ 616 617 if (!K32WOWCallback16Ex( 617 (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL(618 (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL( 618 619 (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc)))) 619 )->Alloc,620 WCB16_CDECL,621 2*sizeof(DWORD),622 (LPVOID)args,623 (LPDWORD)idstr620 )->Alloc, 621 WCB16_CDECL, 622 2*sizeof(DWORD), 623 (LPVOID)args, 624 (LPDWORD)idstr 624 625 )) { 625 WARN("CallTo16 IMalloc16 failed\n");626 return E_FAIL;626 WARN("CallTo16 IMalloc16 failed\n"); 627 return E_FAIL; 627 628 } 628 629 return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr)); … … 630 631 #endif 631 632 /****************************************************************************** 632 * StringFromCLSID[OLE32.151]633 * StringFromCLSID [OLE32.151] 633 634 * Converts a GUID into the respective string representation. 634 635 * The target string is allocated using the OLE IMalloc. 635 636 * RETURNS 636 * the string representation and HRESULT637 * the string representation and HRESULT 637 638 */ 638 639 HRESULT WINAPI StringFromCLSID( 639 640 REFCLSID id, /* [in] the GUID to be converted */ 640 LPOLESTR *idstr/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */641 LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */ 641 642 ) { 642 char buf[80];643 HRESULT ret;644 LPMALLOCmllc;645 646 if ((ret=CoGetMalloc(0,&mllc)))647 return ret;648 649 ret=WINE_StringFromCLSID(id,buf);650 if (!ret) {643 char buf[80]; 644 HRESULT ret; 645 LPMALLOC mllc; 646 647 if ((ret=CoGetMalloc(0,&mllc))) 648 return ret; 649 650 ret=WINE_StringFromCLSID(id,buf); 651 if (!ret) { 651 652 DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); 652 653 *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) ); 653 654 MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len ); 654 }655 return ret;656 } 657 658 /****************************************************************************** 659 * StringFromGUID2[COMPOBJ.76] [OLE32.152]655 } 656 return ret; 657 } 658 659 /****************************************************************************** 660 * StringFromGUID2 [COMPOBJ.76] [OLE32.152] 660 661 * 661 662 * Converts a global unique identifier into a string of an API- … … 663 664 * 664 665 * RETURNS 665 * The (UNICODE) string representation of the GUID in 'str'666 * The length of the resulting string, 0 if there was any problem.666 * The (UNICODE) string representation of the GUID in 'str' 667 * The length of the resulting string, 0 if there was any problem. 667 668 */ 668 669 INT WINAPI 669 670 StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) 670 671 { 671 char xguid[80];672 char xguid[80]; 672 673 673 674 if (WINE_StringFromCLSID(id,xguid)) 674 return 0;675 return 0; 675 676 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax ); 676 677 } … … 729 730 730 731 /****************************************************************************** 731 * CLSIDFromProgID16[COMPOBJ.61]732 * CLSIDFromProgID16 [COMPOBJ.61] 732 733 * Converts a program id into the respective GUID. (By using a registry lookup) 733 734 * RETURNS 734 * riid associated with the progid735 * riid associated with the progid 735 736 */ 736 737 HRESULT WINAPI CLSIDFromProgID16( 737 LPCOLESTR16 progid,/* [in] program id as found in registry */738 LPCLSID riid/* [out] associated CLSID */738 LPCOLESTR16 progid, /* [in] program id as found in registry */ 739 LPCLSID riid /* [out] associated CLSID */ 739 740 ) { 740 char*buf,buf2[80];741 DWORDbuf2len;742 HRESULTerr;743 HKEYxhkey;744 745 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);746 sprintf(buf,"%s\\CLSID",progid);747 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {748 HeapFree(GetProcessHeap(),0,buf);741 char *buf,buf2[80]; 742 DWORD buf2len; 743 HRESULT err; 744 HKEY xhkey; 745 746 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8); 747 sprintf(buf,"%s\\CLSID",progid); 748 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) { 749 HeapFree(GetProcessHeap(),0,buf); 749 750 return CO_E_CLASSSTRING; 750 }751 HeapFree(GetProcessHeap(),0,buf);752 buf2len = sizeof(buf2);753 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {754 RegCloseKey(xhkey);751 } 752 HeapFree(GetProcessHeap(),0,buf); 753 buf2len = sizeof(buf2); 754 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) { 755 RegCloseKey(xhkey); 755 756 return CO_E_CLASSSTRING; 756 }757 RegCloseKey(xhkey);758 return CLSIDFromString16(buf2,riid);759 } 760 761 /****************************************************************************** 762 * CLSIDFromProgID[OLE32.2]757 } 758 RegCloseKey(xhkey); 759 return CLSIDFromString16(buf2,riid); 760 } 761 762 /****************************************************************************** 763 * CLSIDFromProgID [OLE32.2] 763 764 * Converts a program id into the respective GUID. (By using a registry lookup) 764 765 * RETURNS 765 * riid associated with the progid766 * riid associated with the progid 766 767 */ 767 768 HRESULT WINAPI CLSIDFromProgID( 768 LPCOLESTR progid,/* [in] program id as found in registry */769 LPCLSID riid/* [out] associated CLSID */769 LPCOLESTR progid, /* [in] program id as found in registry */ 770 LPCLSID riid /* [out] associated CLSID */ 770 771 ) { 771 LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);772 HRESULT ret = CLSIDFromProgID16(pid,riid);773 774 HeapFree(GetProcessHeap(),0,pid);775 return ret;772 LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid); 773 HRESULT ret = CLSIDFromProgID16(pid,riid); 774 775 HeapFree(GetProcessHeap(),0,pid); 776 return ret; 776 777 } 777 778 … … 782 783 * 783 784 * This function returns the CLSID of the DLL that implements the proxy and stub 784 * for the specified interface. 785 * 786 * It determines this by searching the 785 * for the specified interface. 786 * 787 * It determines this by searching the 787 788 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry 788 789 * and any interface id registered by CoRegisterPSClsid within the current process. 789 * 790 * 790 791 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid. 791 792 */ … … 822 823 823 824 /* ... Once we have the key, query the registry to get the 824 value of CLSID as a string, and convert it into a 825 value of CLSID as a string, and convert it into a 825 826 proper CLSID structure to be passed back to the app */ 826 827 buf2len = sizeof(buf2); … … 846 847 847 848 /*********************************************************************** 848 * WriteClassStm849 * WriteClassStm 849 850 * 850 851 * This function write a CLSID on stream … … 861 862 862 863 /*********************************************************************** 863 * ReadClassStm864 * ReadClassStm 864 865 * 865 866 * This function read a CLSID from a stream … … 869 870 ULONG nbByte; 870 871 HRESULT res; 871 872 872 873 TRACE("(%p,%p)\n",pStm,rclsid); 873 874 874 875 if (rclsid==NULL) 875 876 return E_INVALIDARG; 876 877 877 878 res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte); 878 879 879 880 if (FAILED(res)) 880 881 return res; 881 882 882 883 if (nbByte != sizeof(CLSID)) 883 884 return S_FALSE; … … 892 893 */ 893 894 HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) { 894 FIXME("(%p,%p),stub!\n",hTask,p);895 if ((*hTask = GetCurrentTask()) == hETask) {896 memcpy(p, Table_ETask, sizeof(Table_ETask));897 }898 return 0;895 FIXME("(%p,%p),stub!\n",hTask,p); 896 if ((*hTask = GetCurrentTask()) == hETask) { 897 memcpy(p, Table_ETask, sizeof(Table_ETask)); 898 } 899 return 0; 899 900 } 900 901 … … 905 906 HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) { 906 907 FIXME("(%04x,%p),stub!\n",hTask,p); 907 hETask = hTask;908 return 0;908 hETask = hTask; 909 return 0; 909 910 } 910 911 … … 914 915 */ 915 916 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) { 916 FIXME("(%p,%p),stub!\n",p1,p2);917 return 0;918 } 919 920 /****************************************************************************** 921 * CoRegisterClassObject16[COMPOBJ.5]917 FIXME("(%p,%p),stub!\n",p1,p2); 918 return 0; 919 } 920 921 /****************************************************************************** 922 * CoRegisterClassObject16 [COMPOBJ.5] 922 923 * 923 924 * Don't know where it registers it ... 924 925 */ 925 926 HRESULT WINAPI CoRegisterClassObject16( 926 REFCLSID rclsid,927 LPUNKNOWN pUnk,928 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */929 DWORD flags, /* [in] REGCLS flags indicating how connections are made */930 LPDWORD lpdwRegister927 REFCLSID rclsid, 928 LPUNKNOWN pUnk, 929 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 930 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 931 LPDWORD lpdwRegister 931 932 ) { 932 charbuf[80];933 934 WINE_StringFromCLSID(rclsid,buf);935 936 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",937 buf,pUnk,dwClsContext,flags,lpdwRegister938 );939 return 0;933 char buf[80]; 934 935 WINE_StringFromCLSID(rclsid,buf); 936 937 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n", 938 buf,pUnk,dwClsContext,flags,lpdwRegister 939 ); 940 return 0; 940 941 } 941 942 … … 956 957 * COM_GetRegisteredClassObject 957 958 * 958 * This internal method is used to scan the registered class list to 959 * This internal method is used to scan the registered class list to 959 960 * find a class object. 960 961 * 961 * Params: 962 * Params: 962 963 * rclsid Class ID of the class to find. 963 964 * dwClsContext Class context to match. … … 967 968 */ 968 969 static HRESULT COM_GetRegisteredClassObject( 969 REFCLSID rclsid,970 DWORD dwClsContext,971 LPUNKNOWN* ppUnk)970 REFCLSID rclsid, 971 DWORD dwClsContext, 972 LPUNKNOWN* ppUnk) 972 973 { 973 974 RegisteredClass* curClass; … … 1018 1019 1019 1020 /****************************************************************************** 1020 * CoRegisterClassObject[OLE32.36]1021 * CoRegisterClassObject [OLE32.36] 1021 1022 * 1022 1023 * This method will register the class object for a given class ID. … … 1025 1026 */ 1026 1027 HRESULT WINAPI CoRegisterClassObject( 1027 REFCLSID rclsid,1028 LPUNKNOWN pUnk,1029 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */1030 DWORD flags, /* [in] REGCLS flags indicating how connections are made */1031 LPDWORD lpdwRegister1032 ) 1028 REFCLSID rclsid, 1029 LPUNKNOWN pUnk, 1030 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 1031 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 1032 LPDWORD lpdwRegister 1033 ) 1033 1034 { 1034 1035 RegisteredClass* newClass; … … 1040 1041 1041 1042 TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n", 1042 buf,pUnk,dwClsContext,flags,lpdwRegister);1043 buf,pUnk,dwClsContext,flags,lpdwRegister); 1043 1044 1044 1045 /* … … 1071 1072 return CO_E_OBJISREG; 1072 1073 } 1073 1074 1074 1075 /* 1075 1076 * If it is not registered, we must create a new entry for this class and … … 1102 1103 */ 1103 1104 *lpdwRegister = newClass->dwCookie; 1104 1105 1105 1106 /* 1106 1107 * We're successful Yippee! … … 1117 1118 */ 1118 1119 HRESULT WINAPI CoRevokeClassObject( 1119 DWORD dwRegister) 1120 DWORD dwRegister) 1120 1121 { 1121 1122 RegisteredClass** prevClassLink; … … 1175 1176 REFIID iid, LPVOID *ppv 1176 1177 ) { 1177 LPUNKNOWN regClassObject;1178 HRESULT hres = E_UNEXPECTED;1179 char xclsid[80];1178 LPUNKNOWN regClassObject; 1179 HRESULT hres = E_UNEXPECTED; 1180 char xclsid[80]; 1180 1181 WCHAR dllName[MAX_PATH+1]; 1181 1182 DWORD dllNameLen = sizeof(dllName); 1182 1183 HINSTANCE hLibrary; 1183 1184 #ifdef __WIN32OS2__ 1184 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1185 REFIID iid, LPVOID *ppv);1185 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1186 REFIID iid, LPVOID *ppv); 1186 1187 #else 1187 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1188 REFIID iid, LPVOID *ppv);1188 typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 1189 REFIID iid, LPVOID *ppv); 1189 1190 #endif 1190 1191 DllGetClassObjectFunc DllGetClassObject; … … 1193 1194 1194 1195 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", 1195 debugstr_guid(rclsid),1196 debugstr_guid(iid)1196 debugstr_guid(rclsid), 1197 debugstr_guid(iid) 1197 1198 ); 1198 1199 1199 1200 if (pServerInfo) { 1200 FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));1201 FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);1201 FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName)); 1202 FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo); 1202 1203 } 1203 1204 1204 1205 /* 1205 * First, try and see if we can't match the class ID with one of the 1206 * First, try and see if we can't match the class ID with one of the 1206 1207 * registered classes. 1207 1208 */ … … 1228 1229 ){ 1229 1230 FIXME("%s %s not supported!\n", 1230 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",1231 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""1232 );1233 return E_ACCESSDENIED;1231 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"", 1232 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":"" 1233 ); 1234 return E_ACCESSDENIED; 1234 1235 } 1235 1236 1236 1237 if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) { 1237 1238 HKEY key; 1238 char buf[200];1239 1240 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);1239 char buf[200]; 1240 1241 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); 1241 1242 hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); 1242 1243 1243 if (hres != ERROR_SUCCESS) {1244 return REGDB_E_CLASSNOTREG;1245 }1246 1247 memset(dllName,0,sizeof(dllName));1248 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);1249 if (hres)1250 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */1251 RegCloseKey(key);1252 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));1253 1254 /* open dll, call DllGetClassObject */1255 hLibrary = CoLoadLibrary(dllName, TRUE);1256 if (hLibrary == 0) {1257 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));1258 return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */1259 }1260 DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");1261 if (!DllGetClassObject) {1262 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/1263 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));1264 return E_ACCESSDENIED;1265 }1266 1267 /*1268 * Ask the DLL for its class object. (there was a note here about class1269 * factories but this is good.1270 */1271 return DllGetClassObject(rclsid, iid, ppv);1244 if (hres != ERROR_SUCCESS) { 1245 return REGDB_E_CLASSNOTREG; 1246 } 1247 1248 memset(dllName,0,sizeof(dllName)); 1249 hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen); 1250 if (hres) 1251 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */ 1252 RegCloseKey(key); 1253 TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName)); 1254 1255 /* open dll, call DllGetClassObject */ 1256 hLibrary = CoLoadLibrary(dllName, TRUE); 1257 if (hLibrary == 0) { 1258 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName)); 1259 return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1260 } 1261 DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"); 1262 if (!DllGetClassObject) { 1263 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1264 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName)); 1265 return E_ACCESSDENIED; 1266 } 1267 1268 /* 1269 * Ask the DLL for its class object. (there was a note here about class 1270 * factories but this is good. 1271 */ 1272 return DllGetClassObject(rclsid, iid, ppv); 1272 1273 } 1273 1274 return hres; … … 1281 1282 HRESULT WINAPI CoResumeClassObjects(void) 1282 1283 { 1283 FIXME("\n");1284 return S_OK;1284 FIXME("\n"); 1285 return S_OK; 1285 1286 } 1286 1287 … … 1316 1317 pattern in the registry. this case is not frequently used ! so I present only the psodocode for 1317 1318 this case 1318 1319 1319 1320 for(i=0;i<nFileTypes;i++) 1320 1321 … … 1349 1350 length=lstrlenW(absFile); 1350 1351 for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); 1351 1352 1352 1353 /* get the progId associated to the extension */ 1353 1354 progId=CoTaskMemAlloc(sizeProgId); … … 1377 1378 #ifndef __WIN32OS2__ 1378 1379 /****************************************************************************** 1379 * CoRegisterMessageFilter16[COMPOBJ.27]1380 * CoRegisterMessageFilter16 [COMPOBJ.27] 1380 1381 */ 1381 1382 HRESULT WINAPI CoRegisterMessageFilter16( 1382 LPMESSAGEFILTER lpMessageFilter,1383 LPMESSAGEFILTER *lplpMessageFilter1383 LPMESSAGEFILTER lpMessageFilter, 1384 LPMESSAGEFILTER *lplpMessageFilter 1384 1385 ) { 1385 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);1386 return 0;1386 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter); 1387 return 0; 1387 1388 } 1388 1389 #endif … … 1392 1393 */ 1393 1394 HRESULT WINAPI CoCreateInstance( 1394 REFCLSID rclsid,1395 LPUNKNOWN pUnkOuter,1396 DWORD dwClsContext,1397 REFIID iid,1398 LPVOID *ppv) 1399 { 1400 HRESULT hres;1401 LPCLASSFACTORY lpclf = 0;1395 REFCLSID rclsid, 1396 LPUNKNOWN pUnkOuter, 1397 DWORD dwClsContext, 1398 REFIID iid, 1399 LPVOID *ppv) 1400 { 1401 HRESULT hres; 1402 LPCLASSFACTORY lpclf = 0; 1402 1403 1403 1404 /* … … 1411 1412 */ 1412 1413 *ppv = 0; 1413 1414 1414 1415 /* 1415 1416 * Get a class factory to construct the object we want. 1416 1417 */ 1417 1418 hres = CoGetClassObject(rclsid, 1418 dwClsContext,1419 NULL,1420 &IID_IClassFactory,1421 (LPVOID)&lpclf);1419 dwClsContext, 1420 NULL, 1421 &IID_IClassFactory, 1422 (LPVOID)&lpclf); 1422 1423 1423 1424 if (FAILED(hres)) { … … 1429 1430 * Create the object and don't forget to release the factory 1430 1431 */ 1431 hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);1432 IClassFactory_Release(lpclf);1433 1434 return hres;1432 hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv); 1433 IClassFactory_Release(lpclf); 1434 1435 return hres; 1435 1436 } 1436 1437 … … 1439 1440 */ 1440 1441 HRESULT WINAPI CoCreateInstanceEx( 1441 REFCLSID rclsid, 1442 REFCLSID rclsid, 1442 1443 LPUNKNOWN pUnkOuter, 1443 DWORD dwClsContext, 1444 DWORD dwClsContext, 1444 1445 COSERVERINFO* pServerInfo, 1445 1446 ULONG cmq, … … 1472 1473 * Get the object and get its IUnknown pointer. 1473 1474 */ 1474 hr = CoCreateInstance(rclsid, 1475 pUnkOuter,1476 dwClsContext,1477 &IID_IUnknown,1478 (VOID**)&pUnk);1475 hr = CoCreateInstance(rclsid, 1476 pUnkOuter, 1477 dwClsContext, 1478 &IID_IUnknown, 1479 (VOID**)&pUnk); 1479 1480 1480 1481 if (hr) … … 1487 1488 { 1488 1489 pResults[index].hr = IUnknown_QueryInterface(pUnk, 1489 pResults[index].pIID,1490 (VOID**)&(pResults[index].pItf));1490 pResults[index].pIID, 1491 (VOID**)&(pResults[index].pItf)); 1491 1492 1492 1493 if (pResults[index].hr == S_OK) … … 1519 1520 prev = NULL; 1520 1521 for (ptr = openDllList; ptr != NULL; ptr=ptr->next) { 1521 if (ptr->hLibrary == hLibrary) {1522 break;1523 }1524 prev = ptr;1522 if (ptr->hLibrary == hLibrary) { 1523 break; 1524 } 1525 prev = ptr; 1525 1526 } 1526 1527 1527 1528 if (ptr == NULL) { 1528 /* shouldn't happen if user passed in a valid hLibrary */1529 return;1529 /* shouldn't happen if user passed in a valid hLibrary */ 1530 return; 1530 1531 } 1531 1532 /* assert: ptr points to the library entry to free */ … … 1534 1535 FreeLibrary(hLibrary); 1535 1536 if (ptr == openDllList) { 1536 tmp = openDllList->next;1537 HeapFree(GetProcessHeap(), 0, openDllList);1538 openDllList = tmp;1537 tmp = openDllList->next; 1538 HeapFree(GetProcessHeap(), 0, openDllList); 1539 openDllList = tmp; 1539 1540 } else { 1540 tmp = ptr->next;1541 HeapFree(GetProcessHeap(), 0, ptr);1542 prev->next = tmp;1541 tmp = ptr->next; 1542 HeapFree(GetProcessHeap(), 0, ptr); 1543 prev->next = tmp; 1543 1544 } 1544 1545 … … 1554 1555 1555 1556 for (ptr = openDllList; ptr != NULL; ) { 1556 tmp=ptr->next;1557 CoFreeLibrary(ptr->hLibrary);1558 ptr = tmp;1557 tmp=ptr->next; 1558 CoFreeLibrary(ptr->hLibrary); 1559 ptr = tmp; 1559 1560 } 1560 1561 } … … 1572 1573 1573 1574 for (ptr = openDllList; ptr != NULL; ) { 1574 DllCanUnloadNow = (DllCanUnloadNowFunc)1575 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");1576 1577 if ( (DllCanUnloadNow != NULL) &&1578 (DllCanUnloadNow() == S_OK) ) {1579 tmp=ptr->next;1580 CoFreeLibrary(ptr->hLibrary);1581 ptr = tmp;1582 } else {1583 ptr=ptr->next;1584 }1575 DllCanUnloadNow = (DllCanUnloadNowFunc) 1576 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow"); 1577 1578 if ( (DllCanUnloadNow != NULL) && 1579 (DllCanUnloadNow() == S_OK) ) { 1580 tmp=ptr->next; 1581 CoFreeLibrary(ptr->hLibrary); 1582 ptr = tmp; 1583 } else { 1584 ptr=ptr->next; 1585 } 1585 1586 } 1586 1587 } … … 1589 1590 * CoFileTimeNow [COMPOBJ.82, OLE32.10] 1590 1591 * RETURNS 1591 * the current system time in lpFileTime1592 * the current system time in lpFileTime 1592 1593 */ 1593 1594 HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */ … … 1600 1601 * CoTaskMemAlloc (OLE32.43) 1601 1602 * RETURNS 1602 * pointer to newly allocated block1603 * pointer to newly allocated block 1603 1604 */ 1604 1605 LPVOID WINAPI CoTaskMemAlloc( 1605 ULONG size/* [in] size of memoryblock to be allocated */1606 ULONG size /* [in] size of memoryblock to be allocated */ 1606 1607 ) { 1607 LPMALLOC lpmalloc;1608 HRESULT ret = CoGetMalloc(0,&lpmalloc);1609 1610 if (FAILED(ret)) 1611 return NULL;1608 LPMALLOC lpmalloc; 1609 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1610 1611 if (FAILED(ret)) 1612 return NULL; 1612 1613 1613 1614 return IMalloc_Alloc(lpmalloc,size); … … 1617 1618 */ 1618 1619 VOID WINAPI CoTaskMemFree( 1619 LPVOID ptr/* [in] pointer to be freed */1620 LPVOID ptr /* [in] pointer to be freed */ 1620 1621 ) { 1621 LPMALLOC lpmalloc;1622 HRESULT ret = CoGetMalloc(0,&lpmalloc);1623 1624 if (FAILED(ret)) 1622 LPMALLOC lpmalloc; 1623 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1624 1625 if (FAILED(ret)) 1625 1626 return; 1626 1627 … … 1631 1632 * CoTaskMemRealloc (OLE32.45) 1632 1633 * RETURNS 1633 * pointer to newly allocated block1634 * pointer to newly allocated block 1634 1635 */ 1635 1636 LPVOID WINAPI CoTaskMemRealloc( 1636 1637 LPVOID pvOld, 1637 ULONG size) /* [in] size of memoryblock to be allocated */1638 ULONG size) /* [in] size of memoryblock to be allocated */ 1638 1639 { 1639 1640 LPMALLOC lpmalloc; 1640 1641 HRESULT ret = CoGetMalloc(0,&lpmalloc); 1641 1642 if (FAILED(ret)) 1642 1643 if (FAILED(ret)) 1643 1644 return NULL; 1644 1645 … … 1654 1655 OpenDll *ptr; 1655 1656 OpenDll *tmp; 1656 1657 1657 1658 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1658 1659 … … 1660 1661 1661 1662 if (!bAutoFree) 1662 return hLibrary;1663 return hLibrary; 1663 1664 1664 1665 if (openDllList == NULL) { 1665 1666 /* empty list -- add first node */ 1666 1667 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1667 openDllList->hLibrary=hLibrary;1668 openDllList->next = NULL;1668 openDllList->hLibrary=hLibrary; 1669 openDllList->next = NULL; 1669 1670 } else { 1670 1671 /* search for this dll */ 1671 1672 int found = FALSE; 1672 1673 for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) { 1673 if (ptr->hLibrary == hLibrary) { 1674 found = TRUE; 1675 break; 1676 } 1674 if (ptr->hLibrary == hLibrary) { 1675 found = TRUE; 1676 break; 1677 1677 } 1678 if (!found) { 1679 /* dll not found, add it */ 1680 tmp = openDllList; 1681 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1682 openDllList->hLibrary = hLibrary; 1683 openDllList->next = tmp; 1684 } 1685 } 1686 1678 } 1679 if (!found) { 1680 /* dll not found, add it */ 1681 tmp = openDllList; 1682 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1683 openDllList->hLibrary = hLibrary; 1684 openDllList->next = tmp; 1685 } 1686 } 1687 1687 1688 return hLibrary; 1688 1689 } … … 1698 1699 #ifndef __WIN32OS2__ 1699 1700 /****************************************************************************** 1700 * CoLockObjectExternal16[COMPOBJ.63]1701 * CoLockObjectExternal16 [COMPOBJ.63] 1701 1702 */ 1702 1703 HRESULT WINAPI CoLockObjectExternal16( 1703 LPUNKNOWN pUnk, /* [in] object to be locked */1704 BOOL16 fLock, /* [in] do lock */1705 BOOL16 fLastUnlockReleases /* [in] ? */1704 LPUNKNOWN pUnk, /* [in] object to be locked */ 1705 BOOL16 fLock, /* [in] do lock */ 1706 BOOL16 fLastUnlockReleases /* [in] ? */ 1706 1707 ) { 1707 1708 FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases); … … 1711 1712 1712 1713 /****************************************************************************** 1713 * CoLockObjectExternal[OLE32.31]1714 * CoLockObjectExternal [OLE32.31] 1714 1715 */ 1715 1716 HRESULT WINAPI CoLockObjectExternal( 1716 LPUNKNOWN pUnk, /* [in] object to be locked */1717 BOOL fLock, /* [in] do lock */1717 LPUNKNOWN pUnk, /* [in] object to be locked */ 1718 BOOL fLock, /* [in] do lock */ 1718 1719 BOOL fLastUnlockReleases) /* [in] unlock all */ 1719 1720 { 1720 1721 1721 if (fLock) 1722 if (fLock) 1722 1723 { 1723 /* 1724 /* 1724 1725 * Increment the external lock coutner, COM_ExternalLockAddRef also 1725 1726 * increment the object's internal lock counter. 1726 1727 */ 1727 COM_ExternalLockAddRef( pUnk); 1728 COM_ExternalLockAddRef( pUnk); 1728 1729 } 1729 1730 else 1730 1731 { 1731 /* 1732 /* 1732 1733 * Decrement the external lock coutner, COM_ExternalLockRelease also 1733 1734 * decrement the object's internal lock counter. … … 1765 1766 { 1766 1767 FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal); 1767 1768 1768 1769 return S_OK; 1769 1770 } … … 1774 1775 */ 1775 1776 HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) 1776 { 1777 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));1778 *ppv = NULL;1779 return CLASS_E_CLASSNOTAVAILABLE;1777 { 1778 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); 1779 *ppv = NULL; 1780 return CLASS_E_CLASSNOTAVAILABLE; 1780 1781 } 1781 1782 … … 1784 1785 * COM_RevokeAllClasses 1785 1786 * 1786 * This method is called when the COM libraries are uninitialized to 1787 * This method is called when the COM libraries are uninitialized to 1787 1788 * release all the references to the class objects registered with 1788 1789 * the library … … 1801 1802 1802 1803 /**************************************************************************** 1803 * Public - Method that increments the count for a IUnknown* in the linked 1804 * Public - Method that increments the count for a IUnknown* in the linked 1804 1805 * list. The item is inserted if not already in the list. 1805 1806 */ … … 1822 1823 * Add an internal lock to the object 1823 1824 */ 1824 IUnknown_AddRef(pUnk); 1825 IUnknown_AddRef(pUnk); 1825 1826 } 1826 1827 1827 1828 /**************************************************************************** 1828 * Public - Method that decrements the count for a IUnknown* in the linked 1829 * Public - Method that decrements the count for a IUnknown* in the linked 1829 1830 * list. The item is removed from the list if its count end up at zero or if 1830 1831 * bRelAll is TRUE. … … 1843 1844 IUnknown_Release(pUnk); /* release local locks as well */ 1844 1845 1845 if ( bRelAll == FALSE ) 1846 if ( bRelAll == FALSE ) 1846 1847 break; /* perform single release */ 1847 1848 1848 } while ( externalLock->uRefCount > 0 ); 1849 } while ( externalLock->uRefCount > 0 ); 1849 1850 1850 1851 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ … … 1864 1865 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 1865 1866 1866 head = elList.head; /* get the new head... */ 1867 head = elList.head; /* get the new head... */ 1867 1868 } 1868 1869 } … … 1880 1881 { 1881 1882 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 1882 1883 /* Skip to the next item */ 1883 1884 /* Skip to the next item */ 1884 1885 current = current->next; 1885 } 1886 } 1886 1887 1887 1888 } … … 1903 1904 IUnknown *pUnk) 1904 1905 { 1905 if ( element == EL_END_OF_LIST ) 1906 if ( element == EL_END_OF_LIST ) 1906 1907 return EL_NOT_FOUND; 1907 1908 … … 1909 1910 return element; 1910 1911 1911 else /* Not the right guy, keep on looking */ 1912 else /* Not the right guy, keep on looking */ 1912 1913 return COM_ExternalLockLocate( element->next, pUnk); 1913 1914 } … … 1929 1930 if (newLock!=NULL) 1930 1931 { 1931 if ( elList.head == EL_END_OF_LIST ) 1932 if ( elList.head == EL_END_OF_LIST ) 1932 1933 { 1933 1934 elList.head = newLock; /* The list is empty */ 1934 1935 } 1935 else 1936 else 1936 1937 { 1937 /* 1938 /* 1938 1939 * insert does it at the head 1939 1940 */ … … 1943 1944 1944 1945 /* 1945 * Set new list item data member 1946 * Set new list item data member 1946 1947 */ 1947 1948 newLock->pUnk = pUnk; 1948 1949 newLock->uRefCount = 1; 1949 1950 newLock->next = previousHead; 1950 1951 1951 1952 return TRUE; 1952 1953 } … … 1965 1966 if ( current == itemList ) 1966 1967 { 1967 /* 1968 * this section handles the deletion of the first node 1968 /* 1969 * this section handles the deletion of the first node 1969 1970 */ 1970 1971 elList.head = itemList->next; 1971 HeapFree( GetProcessHeap(), 0, itemList); 1972 HeapFree( GetProcessHeap(), 0, itemList); 1972 1973 } 1973 1974 else 1974 1975 { 1975 do 1976 do 1976 1977 { 1977 1978 if ( current->next == itemList ) /* We found the item to free */ 1978 1979 { 1979 1980 current->next = itemList->next; /* readjust the list pointers */ 1980 1981 HeapFree( GetProcessHeap(), 0, itemList); 1982 break; 1981 1982 HeapFree( GetProcessHeap(), 0, itemList); 1983 break; 1983 1984 } 1984 1985 /* Skip to the next item */ 1985 1986 /* Skip to the next item */ 1986 1987 current = current->next; 1987 1988 1988 1989 } while ( current != EL_END_OF_LIST ); 1989 1990 } … … 2031 2032 { 2032 2033 res = REGDB_E_CLASSNOTREG; 2033 goto done;2034 goto done; 2034 2035 } 2035 2036 len = 200; … … 2039 2040 { 2040 2041 res = REGDB_E_KEYMISSING; 2041 goto done;2042 goto done; 2042 2043 } 2043 2044 MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) ); … … 2064 2065 { 2065 2066 res = REGDB_E_CLASSNOTREG; 2066 goto done;2067 goto done; 2067 2068 } 2068 2069 if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert)) 2069 2070 { 2070 2071 res = REGDB_E_WRITEREGDB; 2071 goto done;2072 goto done; 2072 2073 } 2073 2074 if (RegSetValueExA(hkeyConvert, NULL, 0, … … 2075 2076 { 2076 2077 res = REGDB_E_WRITEREGDB; 2077 goto done;2078 goto done; 2078 2079 } 2079 2080 … … 2091 2092 * 2092 2093 * RETURNS 2093 * TRUE if equal2094 * TRUE if equal 2094 2095 */ 2095 2096 #undef IsEqualGUID … … 2110 2111 2111 2112 HRESULT WIN32API CLSIDFromStringA( 2112 LPCSTR lpsz,// [in] - ASCII string CLSID2113 LPCLSID pclsid)// [out] - Binary CLSID2113 LPCSTR lpsz, // [in] - ASCII string CLSID 2114 LPCLSID pclsid) // [out] - Binary CLSID 2114 2115 { 2115 2116 return CLSIDFromString16(lpsz, pclsid); -
trunk/src/ole32/compositemoniker.c
r5602 r6648 1 /* $Id: compositemoniker.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */ 1 2 /*************************************************************************************** 2 * CompositeMonikers implementation3 * CompositeMonikers implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 26 27 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 27 28 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 30 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 30 31 */ … … 186 187 { 187 188 ICOM_THIS(CompositeMonikerImpl,iface); 188 189 189 190 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 190 191 191 192 /* Perform a sanity check on the parameters.*/ 192 193 if ( (This==0) || (ppvObject==0) ) 193 return E_INVALIDARG;194 194 return E_INVALIDARG; 195 195 196 /* Initialize the return parameter */ 196 197 *ppvObject = 0; … … 235 236 ICOM_THIS(CompositeMonikerImpl,iface); 236 237 ULONG i; 237 238 238 239 TRACE("(%p)\n",This); 239 240 … … 246 247 for (i=0;i<This->tabLastIndex;i++) 247 248 IMoniker_Release(This->tabMoniker[i]); 248 249 249 250 CompositeMonikerImpl_Destroy(This); 250 251 … … 263 264 if (pClassID==NULL) 264 265 return E_POINTER; 265 266 266 267 *pClassID = CLSID_CompositeMoniker; 267 268 268 269 return S_OK; 269 270 } … … 292 293 CLSID clsid; 293 294 WCHAR string[1]={0}; 294 295 ICOM_THIS(CompositeMonikerImpl,iface); 295 296 ICOM_THIS(CompositeMonikerImpl,iface); 296 297 297 298 TRACE("(%p,%p)\n",iface,pStm); … … 349 350 /* resize the table if needed */ 350 351 if (++This->tabLastIndex==This->tabSize){ 351 352 352 353 This->tabSize+=BLOCK_TAB_SIZE; 353 354 This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); … … 370 371 IMoniker *pmk; 371 372 DWORD constant=3; 372 373 373 374 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty); 374 375 … … 445 446 IMoniker *tempMk; 446 447 HRESULT res; 447 448 448 449 TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest); 449 450 … … 471 472 472 473 IMoniker_Enum(pmkFirst,TRUE,&enumMoniker); 473 474 474 475 while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){ 475 476 476 477 477 478 if (++This->tabLastIndex==This->tabSize){ 478 479 479 480 This->tabSize+=BLOCK_TAB_SIZE; 480 481 This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker)); … … 491 492 492 493 IMoniker_IsSystemMoniker(pmkRest,&mkSys); 493 494 494 495 if (mkSys!=MKSYS_GENERICCOMPOSITE){ 495 496 … … 498 499 res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],pmkRest,TRUE,&tempMk); 499 500 500 if (res==MK_E_NEEDGENERIC){ 501 if (res==MK_E_NEEDGENERIC){ 501 502 502 503 /* there's no simplification in this case */ … … 507 508 IMoniker_AddRef(pmkRest); 508 509 } 509 else if (tempMk==NULL){ 510 else if (tempMk==NULL){ 510 511 511 512 /* we have an antimoniker after a simple moniker so we can make a simplification in this case */ … … 525 526 /* resize tabMoniker if needed */ 526 527 if (This->tabLastIndex==This->tabSize){ 527 528 528 529 This->tabSize+=BLOCK_TAB_SIZE; 529 530 … … 562 563 563 564 if (This->tabLastIndex==This->tabSize){ 564 565 565 566 This->tabSize+=BLOCK_TAB_SIZE; 566 567 … … 605 606 IMoniker *tempMk,*antiMk,*mostRigthMk; 606 607 IEnumMoniker *enumMoniker; 607 608 608 609 TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult); 609 610 610 611 if (ppvResult==NULL) 611 612 return E_POINTER; 612 613 613 614 *ppvResult=0; 614 615 /* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */ … … 634 635 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 635 636 IEnumMoniker_Release(enumMoniker); 636 637 637 638 res=CreateAntiMoniker(&antiMk); 638 639 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); 639 640 IMoniker_Release(antiMk); 640 641 641 642 res=CompositeMonikerImpl_BindToObject(mostRigthMk,pbc,tempMk,riid,ppvResult); 642 643 … … 669 670 670 671 if (pmkToLeft!=NULL){ 671 672 672 673 IMoniker_Enum(iface,FALSE,&enumMoniker); 673 674 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 674 675 IEnumMoniker_Release(enumMoniker); 675 676 676 677 res=CreateAntiMoniker(&antiMk); 677 678 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); 678 679 IMoniker_Release(antiMk); 679 680 680 681 res=CompositeMonikerImpl_BindToStorage(mostRigthMk,pbc,tempMk,riid,ppvResult); 681 682 … … 715 716 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 716 717 IEnumMoniker_Release(enumMoniker); 717 718 718 719 res=CreateAntiMoniker(&antiMk); 719 720 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); … … 732 733 IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL); 733 734 IEnumMoniker_Release(enumMoniker); 734 735 735 736 res=CreateAntiMoniker(&antiMk); 736 737 res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk); … … 768 769 769 770 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 770 return E_POINTER;771 return E_POINTER; 771 772 772 773 *ppmkComposite=0; … … 775 776 /* otherwise, the method returns the result of combining the two monikers by calling the */ 776 777 /* CreateGenericComposite function */ 777 778 778 779 if (fOnlyIfNotGeneric) 779 780 return MK_E_NEEDGENERIC; 780 781 781 782 return CreateGenericComposite(iface,pmkRight,ppmkComposite); 782 783 } … … 793 794 if (ppenumMoniker == NULL) 794 795 return E_POINTER; 795 796 796 797 return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabLastIndex,0,fForward,ppenumMoniker); 797 798 } … … 805 806 IMoniker *tempMk1,*tempMk2; 806 807 HRESULT res1,res2,res; 807 808 808 809 TRACE("(%p,%p)\n",iface,pmkOtherMoniker); 809 810 … … 817 818 if (enumMoniker1==NULL) 818 819 return S_FALSE; 819 820 820 821 IMoniker_Enum(iface,TRUE,&enumMoniker2); 821 822 … … 824 825 res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL); 825 826 res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL); 826 827 827 828 if((res1==S_OK)&&(res2==S_OK)){ 828 829 … … 894 895 /* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */ 895 896 /* to this moniker */ 896 897 897 898 if (pmkNewlyRunning!=NULL) 898 899 … … 912 913 /* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */ 913 914 /* the composite as the pmkToLeft parameter for that call. */ 914 915 915 916 res=IBindCtx_GetRunningObjectTable(pbc,&rot); 916 917 … … 956 957 IMoniker *tempMk,*antiMk,*mostRigthMk; 957 958 IEnumMoniker *enumMoniker; 958 959 959 960 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime); 960 961 … … 1053 1054 IEnumMoniker *enumMoniker1,*enumMoniker2; 1054 1055 ULONG i,nbCommonMk=0; 1055 1056 1056 1057 /* If the other moniker is a composite, this method compares the components of each composite from left */ 1057 1058 /* to right. The returned common prefix moniker might also be a composite moniker, depending on how many */ … … 1060 1061 if (ppmkPrefix==NULL) 1061 1062 return E_POINTER; 1062 1063 1063 1064 *ppmkPrefix=0; 1064 1065 1065 1066 if (pmkOther==NULL) 1066 1067 return MK_E_NOPREFIX; 1067 1068 1068 1069 IMoniker_IsSystemMoniker(pmkOther,&mkSys); 1069 1070 … … 1129 1130 IMoniker_Release(tempMk1); 1130 1131 IMoniker_Release(tempMk2); 1131 1132 1132 1133 /* compose all common monikers in a composite moniker */ 1133 1134 for(i=0;i<nbCommonMk;i++){ … … 1140 1141 1141 1142 IMoniker_Release(tempMk1); 1142 1143 1143 1144 *ppmkPrefix=tempMk2; 1144 1145 } … … 1181 1182 DWORD mkSys; 1182 1183 HRESULT res1,res2; 1183 1184 1184 1185 *restMk=0; 1185 1186 … … 1279 1280 1280 1281 /* finds the common prefix of the two monikers */ 1281 res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk); 1282 res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk); 1282 1283 1283 1284 /* if there's no common prefix or the two moniker are equal the relative is the other moniker */ … … 1336 1337 if (ppszDisplayName==NULL) 1337 1338 return E_POINTER; 1338 1339 1339 1340 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)); 1340 1341 … … 1348 1349 1349 1350 IMoniker_Enum(iface,TRUE,&enumMoniker); 1350 1351 1351 1352 while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){ 1352 1353 … … 1408 1409 if (!pwdMksys) 1409 1410 return E_POINTER; 1410 1411 1411 1412 (*pwdMksys)=MKSYS_GENERICCOMPOSITE; 1412 1413 … … 1445 1446 { 1446 1447 ICOM_THIS_From_IROTData(IMoniker, iface); 1447 1448 1448 1449 TRACE("(%p)\n",iface); 1449 1450 … … 1469 1470 { 1470 1471 ICOM_THIS(EnumMonikerImpl,iface); 1471 1472 1472 1473 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 1473 1474 1474 1475 /* Perform a sanity check on the parameters.*/ 1475 1476 if ( (This==0) || (ppvObject==0) ) 1476 return E_INVALIDARG;1477 1477 return E_INVALIDARG; 1478 1478 1479 /* Initialize the return parameter */ 1479 1480 *ppvObject = 0; … … 1520 1521 /* destroy the object if there's no more reference on it */ 1521 1522 if (This->ref==0){ 1522 1523 1523 1524 for(i=0;i<This->tabSize;i++) 1524 1525 IMoniker_Release(This->tabMoniker[i]); … … 1547 1548 if (pceltFethed!=NULL) 1548 1549 *pceltFethed= i; 1549 1550 1550 1551 if (i==celt) 1551 1552 return S_OK; … … 1565 1566 1566 1567 This->currentPos+=celt; 1567 1568 1568 1569 return S_OK; 1569 1570 } … … 1611 1612 if (currentPos > tabSize) 1612 1613 return E_INVALIDARG; 1613 1614 1614 1615 /* Initialize the virtual function table. */ 1615 1616 ICOM_VTBL(newEnumMoniker) = &VT_EnumMonikerImpl; … … 1643 1644 1644 1645 /****************************************************************************** 1645 * CreateGenericComposite [OLE.55]1646 * CreateGenericComposite [OLE.55] 1646 1647 ******************************************************************************/ 1647 1648 HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite) … … 1654 1655 if (ppmkComposite==NULL) 1655 1656 return E_POINTER; 1656 1657 1657 1658 *ppmkComposite=0; 1658 1659 … … 1692 1693 1693 1694 /****************************************************************************** 1694 * MonikerCommonPrefixWith [OLE.55]1695 * MonikerCommonPrefixWith [OLE.55] 1695 1696 ******************************************************************************/ 1696 1697 HRESULT WINAPI MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon) -
trunk/src/ole32/datacache.c
r5602 r6648 1 /* $Id: datacache.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */ 1 2 /* 2 * OLE 2 Data cache3 * OLE 2 Data cache 3 4 * 4 5 * Copyright 1999 Francis Beaudet … … 17 18 * - This implementation of the datacache will let your application 18 19 * load documents that have embedded OLE objects in them and it will 19 * also retrieve the metafile representation of those objects. 20 * also retrieve the metafile representation of those objects. 20 21 * - This implementation of the datacache will also allow your 21 22 * application to save new documents with OLE objects in them. 22 * - The main thing that it doesn't do is allow you to activate 23 * - The main thing that it doesn't do is allow you to activate 23 24 * or modify the OLE objects in any way. 24 25 * - I haven't found any good documentation on the real usage of … … 27 28 * "\002OlePresXXX". It appears to just be a counter. 28 29 * - Also, I don't know the real content of the presentation stream 29 * header. I was able to figure-out where the extent of the object 30 * header. I was able to figure-out where the extent of the object 30 31 * was stored and the aspect, but that's about it. 31 32 */ … … 60 61 typedef struct PresentationDataHeader 61 62 { 62 DWORD unknown1; /* -1 */63 DWORD unknown2; /* 3, possibly CF_METAFILEPICT */64 DWORD unknown3; /* 4, possibly TYMED_ISTREAM */63 DWORD unknown1; /* -1 */ 64 DWORD unknown2; /* 3, possibly CF_METAFILEPICT */ 65 DWORD unknown3; /* 4, possibly TYMED_ISTREAM */ 65 66 DVASPECT dvAspect; 66 DWORD unknown5; /* -1 */67 DWORD unknown5; /* -1 */ 67 68 68 69 DWORD unknown6; 69 DWORD unknown7; /* 0 */70 DWORD unknown7; /* 0 */ 70 71 DWORD dwObjectExtentX; 71 72 DWORD dwObjectExtentY; … … 81 82 * List all interface VTables here 82 83 */ 83 ICOM_VTABLE(IDataObject)* lpvtbl1; 84 ICOM_VTABLE(IDataObject)* lpvtbl1; 84 85 ICOM_VTABLE(IUnknown)* lpvtbl2; 85 86 ICOM_VTABLE(IPersistStorage)* lpvtbl3; 86 ICOM_VTABLE(IViewObject2)* lpvtbl4; 87 ICOM_VTABLE(IViewObject2)* lpvtbl4; 87 88 ICOM_VTABLE(IOleCache2)* lpvtbl5; 88 89 ICOM_VTABLE(IOleCacheControl)* lpvtbl6; … … 119 120 120 121 /* 121 * Here, I define utility macros to help with the casting of the 122 * Here, I define utility macros to help with the casting of the 122 123 * "this" parameter. 123 124 * There is a version to accomodate all of the VTables implemented … … 125 126 */ 126 127 #define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name; 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*)); 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*)); 132 133 133 134 /* … … 135 136 */ 136 137 static DataCache* DataCache_Construct(REFCLSID clsid, 137 LPUNKNOWN pUnkOuter);138 LPUNKNOWN pUnkOuter); 138 139 static void DataCache_Destroy(DataCache* ptrToDestroy); 139 140 static HRESULT DataCache_ReadPresentationData(DataCache* this, 140 DWORD drawAspect,141 PresentationDataHeader* header);141 DWORD drawAspect, 142 PresentationDataHeader* header); 142 143 static HRESULT DataCache_OpenPresStream(DataCache *this, 143 DWORD drawAspect,144 IStream **pStm);144 DWORD drawAspect, 145 IStream **pStm); 145 146 static HMETAFILE DataCache_ReadPresMetafile(DataCache* this, 146 DWORD drawAspect);147 DWORD drawAspect); 147 148 static void DataCache_FireOnViewChange(DataCache* this, 148 DWORD aspect,149 LONG lindex);149 DWORD aspect, 150 LONG lindex); 150 151 151 152 /* … … 157 158 REFIID riid, 158 159 void** ppvObject); 159 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 160 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 160 161 IUnknown* iface); 161 static ULONG WINAPI DataCache_NDIUnknown_Release( 162 static ULONG WINAPI DataCache_NDIUnknown_Release( 162 163 IUnknown* iface); 163 164 … … 170 171 REFIID riid, 171 172 void** ppvObject); 172 static ULONG WINAPI DataCache_IDataObject_AddRef( 173 static ULONG WINAPI DataCache_IDataObject_AddRef( 173 174 IDataObject* iface); 174 static ULONG WINAPI DataCache_IDataObject_Release( 175 static ULONG WINAPI DataCache_IDataObject_Release( 175 176 IDataObject* iface); 176 177 static HRESULT WINAPI DataCache_GetData( 177 IDataObject* iface,178 LPFORMATETC pformatetcIn, 179 STGMEDIUM* pmedium);178 IDataObject* iface, 179 LPFORMATETC pformatetcIn, 180 STGMEDIUM* pmedium); 180 181 static HRESULT WINAPI DataCache_GetDataHere( 181 IDataObject* iface, 182 LPFORMATETC pformatetc,183 STGMEDIUM* pmedium);182 IDataObject* iface, 183 LPFORMATETC pformatetc, 184 STGMEDIUM* pmedium); 184 185 static HRESULT WINAPI DataCache_QueryGetData( 185 IDataObject* iface,186 LPFORMATETC pformatetc);186 IDataObject* iface, 187 LPFORMATETC pformatetc); 187 188 static HRESULT WINAPI DataCache_GetCanonicalFormatEtc( 188 IDataObject* iface, 189 LPFORMATETC pformatectIn, 190 LPFORMATETC pformatetcOut);189 IDataObject* iface, 190 LPFORMATETC pformatectIn, 191 LPFORMATETC pformatetcOut); 191 192 static HRESULT WINAPI DataCache_IDataObject_SetData( 192 IDataObject* iface,193 LPFORMATETC pformatetc, 194 STGMEDIUM* pmedium, 195 BOOL fRelease);193 IDataObject* iface, 194 LPFORMATETC pformatetc, 195 STGMEDIUM* pmedium, 196 BOOL fRelease); 196 197 static HRESULT WINAPI DataCache_EnumFormatEtc( 197 IDataObject* iface, 198 DWORD dwDirection,199 IEnumFORMATETC** ppenumFormatEtc);198 IDataObject* iface, 199 DWORD dwDirection, 200 IEnumFORMATETC** ppenumFormatEtc); 200 201 static HRESULT WINAPI DataCache_DAdvise( 201 IDataObject* iface, 202 FORMATETC* pformatetc, 203 DWORD advf, 204 IAdviseSink* pAdvSink, 205 DWORD* pdwConnection);202 IDataObject* iface, 203 FORMATETC* pformatetc, 204 DWORD advf, 205 IAdviseSink* pAdvSink, 206 DWORD* pdwConnection); 206 207 static HRESULT WINAPI DataCache_DUnadvise( 207 IDataObject* iface,208 DWORD dwConnection);208 IDataObject* iface, 209 DWORD dwConnection); 209 210 static HRESULT WINAPI DataCache_EnumDAdvise( 210 IDataObject* iface,211 IEnumSTATDATA** ppenumAdvise);211 IDataObject* iface, 212 IEnumSTATDATA** ppenumAdvise); 212 213 213 214 /* … … 219 220 REFIID riid, 220 221 void** ppvObject); 221 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 222 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 222 223 IPersistStorage* iface); 223 static ULONG WINAPI DataCache_IPersistStorage_Release( 224 static ULONG WINAPI DataCache_IPersistStorage_Release( 224 225 IPersistStorage* iface); 225 static HRESULT WINAPI DataCache_GetClassID( 226 static HRESULT WINAPI DataCache_GetClassID( 226 227 IPersistStorage* iface, 227 CLSID* pClassID);228 static HRESULT WINAPI DataCache_IsDirty( 228 CLSID* pClassID); 229 static HRESULT WINAPI DataCache_IsDirty( 229 230 IPersistStorage* iface); 230 static HRESULT WINAPI DataCache_InitNew( 231 IPersistStorage* iface, 232 IStorage* pStg); 233 static HRESULT WINAPI DataCache_Load( 231 static HRESULT WINAPI DataCache_InitNew( 234 232 IPersistStorage* iface, 235 IStorage* pStg);236 static HRESULT WINAPI DataCache_ Save(233 IStorage* pStg); 234 static HRESULT WINAPI DataCache_Load( 237 235 IPersistStorage* iface, 238 IStorage* pStg, 239 BOOL fSameAsLoad); 240 static HRESULT WINAPI DataCache_SaveCompleted( 241 IPersistStorage* iface, 242 IStorage* pStgNew); 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); 243 244 static HRESULT WINAPI DataCache_HandsOffStorage( 244 245 IPersistStorage* iface); … … 252 253 REFIID riid, 253 254 void** ppvObject); 254 static ULONG WINAPI DataCache_IViewObject2_AddRef( 255 static ULONG WINAPI DataCache_IViewObject2_AddRef( 255 256 IViewObject2* iface); 256 static ULONG WINAPI DataCache_IViewObject2_Release( 257 static ULONG WINAPI DataCache_IViewObject2_Release( 257 258 IViewObject2* iface); 258 259 static HRESULT WINAPI DataCache_Draw( 259 260 IViewObject2* iface, 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);261 DWORD dwDrawAspect, 262 LONG lindex, 263 void* pvAspect, 264 DVTARGETDEVICE* ptd, 265 HDC hdcTargetDev, 266 HDC hdcDraw, 267 LPCRECTL lprcBounds, 268 LPCRECTL lprcWBounds, 269 IVO_ContCallback pfnContinue, 270 DWORD dwContinue); 270 271 static HRESULT WINAPI DataCache_GetColorSet( 271 IViewObject2* iface, 272 DWORD dwDrawAspect, 273 LONG lindex, 274 void* pvAspect, 275 DVTARGETDEVICE* ptd, 276 HDC hicTargetDevice, 277 LOGPALETTE** ppColorSet);272 IViewObject2* iface, 273 DWORD dwDrawAspect, 274 LONG lindex, 275 void* pvAspect, 276 DVTARGETDEVICE* ptd, 277 HDC hicTargetDevice, 278 LOGPALETTE** ppColorSet); 278 279 static HRESULT WINAPI DataCache_Freeze( 279 280 IViewObject2* iface, 280 DWORD dwDrawAspect,281 LONG lindex,282 void* pvAspect, 283 DWORD* pdwFreeze);281 DWORD dwDrawAspect, 282 LONG lindex, 283 void* pvAspect, 284 DWORD* pdwFreeze); 284 285 static HRESULT WINAPI DataCache_Unfreeze( 285 286 IViewObject2* iface, 286 DWORD dwFreeze);287 DWORD dwFreeze); 287 288 static HRESULT WINAPI DataCache_SetAdvise( 288 289 IViewObject2* iface, 289 DWORD aspects, 290 DWORD advf, 291 IAdviseSink* pAdvSink);290 DWORD aspects, 291 DWORD advf, 292 IAdviseSink* pAdvSink); 292 293 static HRESULT WINAPI DataCache_GetAdvise( 293 IViewObject2* iface, 294 DWORD* pAspects, 295 DWORD* pAdvf, 296 IAdviseSink** ppAdvSink);294 IViewObject2* iface, 295 DWORD* pAspects, 296 DWORD* pAdvf, 297 IAdviseSink** ppAdvSink); 297 298 static HRESULT WINAPI DataCache_GetExtent( 298 IViewObject2* iface, 299 DWORD dwDrawAspect, 300 LONG lindex, 301 DVTARGETDEVICE* ptd, 302 LPSIZEL lpsizel);299 IViewObject2* iface, 300 DWORD dwDrawAspect, 301 LONG lindex, 302 DVTARGETDEVICE* ptd, 303 LPSIZEL lpsizel); 303 304 304 305 /* … … 310 311 REFIID riid, 311 312 void** ppvObject); 312 static ULONG WINAPI DataCache_IOleCache2_AddRef( 313 static ULONG WINAPI DataCache_IOleCache2_AddRef( 313 314 IOleCache2* iface); 314 static ULONG WINAPI DataCache_IOleCache2_Release( 315 static ULONG WINAPI DataCache_IOleCache2_Release( 315 316 IOleCache2* iface); 316 317 static HRESULT WINAPI DataCache_Cache( 317 318 IOleCache2* iface, 318 FORMATETC* pformatetc,319 DWORD advf,320 DWORD* pdwConnection);319 FORMATETC* pformatetc, 320 DWORD advf, 321 DWORD* pdwConnection); 321 322 static HRESULT WINAPI DataCache_Uncache( 322 IOleCache2* iface,323 DWORD dwConnection);323 IOleCache2* iface, 324 DWORD dwConnection); 324 325 static HRESULT WINAPI DataCache_EnumCache( 325 326 IOleCache2* iface, 326 IEnumSTATDATA** ppenumSTATDATA);327 IEnumSTATDATA** ppenumSTATDATA); 327 328 static HRESULT WINAPI DataCache_InitCache( 328 IOleCache2* iface,329 IDataObject* pDataObject);329 IOleCache2* iface, 330 IDataObject* pDataObject); 330 331 static HRESULT WINAPI DataCache_IOleCache2_SetData( 331 332 IOleCache2* iface, 332 FORMATETC* pformatetc,333 STGMEDIUM* pmedium,334 BOOL fRelease);333 FORMATETC* pformatetc, 334 STGMEDIUM* pmedium, 335 BOOL fRelease); 335 336 static HRESULT WINAPI DataCache_UpdateCache( 336 337 IOleCache2* iface, 337 LPDATAOBJECT pDataObject, 338 DWORD grfUpdf,339 LPVOID pReserved);338 LPDATAOBJECT pDataObject, 339 DWORD grfUpdf, 340 LPVOID pReserved); 340 341 static HRESULT WINAPI DataCache_DiscardCache( 341 342 IOleCache2* iface, 342 DWORD dwDiscardOptions);343 DWORD dwDiscardOptions); 343 344 344 345 /* … … 350 351 REFIID riid, 351 352 void** ppvObject); 352 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 353 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 353 354 IOleCacheControl* iface); 354 static ULONG WINAPI DataCache_IOleCacheControl_Release( 355 static ULONG WINAPI DataCache_IOleCacheControl_Release( 355 356 IOleCacheControl* iface); 356 357 static HRESULT WINAPI DataCache_OnRun( 357 IOleCacheControl* iface,358 LPDATAOBJECT pDataObject);358 IOleCacheControl* iface, 359 LPDATAOBJECT pDataObject); 359 360 static HRESULT WINAPI DataCache_OnStop( 360 IOleCacheControl* iface);361 IOleCacheControl* iface); 361 362 362 363 /* … … 447 448 */ 448 449 HRESULT WINAPI CreateDataCache( 449 LPUNKNOWN pUnkOuter, 450 REFCLSID rclsid, 451 REFIID riid, 450 LPUNKNOWN pUnkOuter, 451 REFCLSID rclsid, 452 REFIID riid, 452 453 LPVOID* ppvObj) 453 454 { … … 471 472 * IUnknown pointer can be returned to the outside. 472 473 */ 473 if ( (pUnkOuter!=NULL) && 474 if ( (pUnkOuter!=NULL) && 474 475 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) ) 475 476 return CLASS_E_NOAGGREGATION; … … 478 479 * Try to construct a new instance of the class. 479 480 */ 480 newCache = DataCache_Construct(rclsid, 481 pUnkOuter);481 newCache = DataCache_Construct(rclsid, 482 pUnkOuter); 482 483 483 484 if (newCache == 0) … … 514 515 if (newObject==0) 515 516 return newObject; 516 517 517 518 /* 518 519 * Initialize the virtual function table. … … 524 525 newObject->lpvtbl5 = &DataCache_IOleCache2_VTable; 525 526 newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable; 526 527 /* 528 * Start with one reference count. The caller of this function 527 528 /* 529 * Start with one reference count. The caller of this function 529 530 * must release the interface pointer when it is done. 530 531 */ … … 533 534 /* 534 535 * Initialize the outer unknown 535 * We don't keep a reference on the outer unknown since, the way 536 * We don't keep a reference on the outer unknown since, the way 536 537 * aggregation works, our lifetime is at least as large as it's 537 538 * lifetime. … … 579 580 * DataCache_ReadPresentationData 580 581 * 581 * This method will read information for the requested presentation 582 * This method will read information for the requested presentation 582 583 * into the given structure. 583 584 * … … 601 602 hres = DataCache_OpenPresStream( 602 603 this, 603 drawAspect,604 &presStream);604 drawAspect, 605 &presStream); 605 606 606 607 if (FAILED(hres)) … … 613 614 hres = IStream_Read( 614 615 presStream, 615 header,616 sizeof(PresentationDataHeader),617 NULL);616 header, 617 sizeof(PresentationDataHeader), 618 NULL); 618 619 619 620 /* … … 657 658 { 658 659 IAdviseSink_OnViewChange(this->sinkInterface, 659 aspect,660 lindex);660 aspect, 661 lindex); 661 662 662 663 /* … … 666 667 if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0) 667 668 { 668 IAdviseSink_Release(this->sinkInterface);669 670 this->sinkInterface = NULL;671 this->sinkAspects = 0;672 this->sinkAdviseFlag = 0;669 IAdviseSink_Release(this->sinkInterface); 670 671 this->sinkInterface = NULL; 672 this->sinkAspects = 0; 673 this->sinkAdviseFlag = 0; 673 674 } 674 675 } … … 686 687 687 688 return (elem->type == STGTY_STREAM) 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');689 && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader)) 690 && (strlenW(name) == 11) 691 && (strncmpW(name, OlePres, 8) == 0) 692 && (name[8] >= '0') && (name[8] <= '9') 693 && (name[9] >= '0') && (name[9] <= '9') 694 && (name[10] >= '0') && (name[10] <= '9'); 694 695 } 695 696 … … 707 708 * 708 709 * Errors: 709 * S_OK The requested stream has been opened.710 * OLE_E_BLANK The requested stream could not be found.710 * S_OK The requested stream has been opened. 711 * OLE_E_BLANK The requested stream could not be found. 711 712 * Quite a few others I'm too lazy to map correctly. 712 713 * 713 714 * Notes: 714 * Algorithm: Scan the elements of the presentation storage, looking715 * for presentation streams. For each presentation stream,716 * load the header and check to see if the aspect maches.715 * Algorithm: Scan the elements of the presentation storage, looking 716 * for presentation streams. For each presentation stream, 717 * load the header and check to see if the aspect maches. 717 718 * 718 719 * If a fallback is desired, just opening the first presentation stream … … 735 736 while ((hr = IEnumSTATSTG_Next(pEnum, 1, &elem, NULL)) == S_OK) 736 737 { 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); 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 } 774 772 } 775 773 774 CoTaskMemFree(elem.pwcsName); 775 } 776 776 777 IEnumSTATSTG_Release(pEnum); 777 778 … … 782 783 * DataCache_ReadPresentationData 783 784 * 784 * This method will read information for the requested presentation 785 * This method will read information for the requested presentation 785 786 * into the given structure. 786 787 * … … 808 809 */ 809 810 hres = DataCache_OpenPresStream( 810 this, 811 drawAspect,812 &presStream);811 this, 812 drawAspect, 813 &presStream); 813 814 814 815 if (FAILED(hres)) … … 819 820 */ 820 821 hres = IStream_Stat(presStream, 821 &streamInfo,822 STATFLAG_NONAME);822 &streamInfo, 823 STATFLAG_NONAME); 823 824 824 825 /* … … 830 831 hres = IStream_Seek( 831 832 presStream, 832 offset,833 STREAM_SEEK_SET,834 NULL);833 offset, 834 STREAM_SEEK_SET, 835 NULL); 835 836 836 837 streamInfo.cbSize.s.LowPart -= offset.s.LowPart; … … 839 840 * Allocate a buffer for the metafile bits. 840 841 */ 841 metafileBits = HeapAlloc(GetProcessHeap(), 842 0, 843 streamInfo.cbSize.s.LowPart);842 metafileBits = HeapAlloc(GetProcessHeap(), 843 0, 844 streamInfo.cbSize.s.LowPart); 844 845 845 846 /* … … 847 848 */ 848 849 hres = IStream_Read( 849 presStream,850 metafileBits,851 streamInfo.cbSize.s.LowPart,852 NULL);850 presStream, 851 metafileBits, 852 streamInfo.cbSize.s.LowPart, 853 NULL); 853 854 854 855 /* … … 897 898 if ( (this==0) || (ppvObject==0) ) 898 899 return E_INVALIDARG; 899 900 900 901 /* 901 902 * Initialize the return parameter. … … 906 907 * Compare the riid with the interface IDs implemented by this object. 907 908 */ 908 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 909 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 909 910 { 910 911 *ppvObject = iface; 911 912 } 912 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 913 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 913 914 { 914 915 *ppvObject = (IDataObject*)&(this->lpvtbl1); 915 916 } 916 917 else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0) || 917 (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )918 (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) ) 918 919 { 919 920 *ppvObject = (IPersistStorage*)&(this->lpvtbl3); 920 921 } 921 922 else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) || 922 (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )923 (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) ) 923 924 { 924 925 *ppvObject = (IViewObject2*)&(this->lpvtbl4); 925 926 } 926 927 else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) || 927 (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )928 (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) ) 928 929 { 929 930 *ppvObject = (IOleCache2*)&(this->lpvtbl5); 930 931 } 931 else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 932 else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 932 933 { 933 934 *ppvObject = (IOleCacheControl*)&(this->lpvtbl6); … … 942 943 return E_NOINTERFACE; 943 944 } 944 945 945 946 /* 946 947 * Query Interface always increases the reference count by one when it is 947 * successful. 948 * successful. 948 949 */ 949 950 IUnknown_AddRef((IUnknown*)*ppvObject); 950 951 951 return S_OK;; 952 return S_OK;; 952 953 } 953 954 … … 960 961 * to the outer unknown. 961 962 */ 962 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 963 static ULONG WINAPI DataCache_NDIUnknown_AddRef( 963 964 IUnknown* iface) 964 965 { … … 978 979 * to the outer unknown. 979 980 */ 980 static ULONG WINAPI DataCache_NDIUnknown_Release( 981 static ULONG WINAPI DataCache_NDIUnknown_Release( 981 982 IUnknown* iface) 982 983 { … … 997 998 return 0; 998 999 } 999 1000 1000 1001 return this->ref; 1001 1002 } … … 1018 1019 _ICOM_THIS_From_IDataObject(DataCache, iface); 1019 1020 1020 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1021 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1021 1022 } 1022 1023 … … 1026 1027 * See Windows documentation for more details on IUnknown methods. 1027 1028 */ 1028 static ULONG WINAPI DataCache_IDataObject_AddRef( 1029 static ULONG WINAPI DataCache_IDataObject_AddRef( 1029 1030 IDataObject* iface) 1030 1031 { 1031 1032 _ICOM_THIS_From_IDataObject(DataCache, iface); 1032 1033 1033 return IUnknown_AddRef(this->outerUnknown); 1034 return IUnknown_AddRef(this->outerUnknown); 1034 1035 } 1035 1036 … … 1039 1040 * See Windows documentation for more details on IUnknown methods. 1040 1041 */ 1041 static ULONG WINAPI DataCache_IDataObject_Release( 1042 static ULONG WINAPI DataCache_IDataObject_Release( 1042 1043 IDataObject* iface) 1043 1044 { 1044 1045 _ICOM_THIS_From_IDataObject(DataCache, iface); 1045 1046 1046 return IUnknown_Release(this->outerUnknown); 1047 return IUnknown_Release(this->outerUnknown); 1047 1048 } 1048 1049 … … 1055 1056 */ 1056 1057 static HRESULT WINAPI DataCache_GetData( 1057 IDataObject* iface,1058 LPFORMATETC pformatetcIn, 1059 STGMEDIUM* pmedium)1058 IDataObject* iface, 1059 LPFORMATETC pformatetcIn, 1060 STGMEDIUM* pmedium) 1060 1061 { 1061 1062 HRESULT hr = 0; … … 1154 1155 1155 1156 static HRESULT WINAPI DataCache_GetDataHere( 1156 IDataObject* iface, 1157 LPFORMATETC pformatetc,1158 STGMEDIUM* pmedium)1157 IDataObject* iface, 1158 LPFORMATETC pformatetc, 1159 STGMEDIUM* pmedium) 1159 1160 { 1160 1161 FIXME("stub\n"); … … 1163 1164 1164 1165 static HRESULT WINAPI DataCache_QueryGetData( 1165 IDataObject* iface,1166 LPFORMATETC pformatetc)1166 IDataObject* iface, 1167 LPFORMATETC pformatetc) 1167 1168 { 1168 1169 FIXME("stub\n"); … … 1178 1179 */ 1179 1180 static HRESULT WINAPI DataCache_GetCanonicalFormatEtc( 1180 IDataObject* iface, 1181 LPFORMATETC pformatectIn, 1182 LPFORMATETC pformatetcOut)1181 IDataObject* iface, 1182 LPFORMATETC pformatectIn, 1183 LPFORMATETC pformatetcOut) 1183 1184 { 1184 1185 TRACE("()\n"); … … 1194 1195 */ 1195 1196 static HRESULT WINAPI DataCache_IDataObject_SetData( 1196 IDataObject* iface,1197 LPFORMATETC pformatetc, 1198 STGMEDIUM* pmedium, 1199 BOOL fRelease)1197 IDataObject* iface, 1198 LPFORMATETC pformatetc, 1199 STGMEDIUM* pmedium, 1200 BOOL fRelease) 1200 1201 { 1201 1202 IOleCache2* oleCache = NULL; … … 1224 1225 */ 1225 1226 static HRESULT WINAPI DataCache_EnumFormatEtc( 1226 IDataObject* iface, 1227 DWORD dwDirection,1228 IEnumFORMATETC** ppenumFormatEtc)1227 IDataObject* iface, 1228 DWORD dwDirection, 1229 IEnumFORMATETC** ppenumFormatEtc) 1229 1230 { 1230 1231 TRACE("()\n"); … … 1240 1241 */ 1241 1242 static HRESULT WINAPI DataCache_DAdvise( 1242 IDataObject* iface, 1243 FORMATETC* pformatetc, 1244 DWORD advf, 1245 IAdviseSink* pAdvSink, 1246 DWORD* pdwConnection)1243 IDataObject* iface, 1244 FORMATETC* pformatetc, 1245 DWORD advf, 1246 IAdviseSink* pAdvSink, 1247 DWORD* pdwConnection) 1247 1248 { 1248 1249 TRACE("()\n"); … … 1258 1259 */ 1259 1260 static HRESULT WINAPI DataCache_DUnadvise( 1260 IDataObject* iface,1261 DWORD dwConnection)1261 IDataObject* iface, 1262 DWORD dwConnection) 1262 1263 { 1263 1264 TRACE("()\n"); … … 1273 1274 */ 1274 1275 static HRESULT WINAPI DataCache_EnumDAdvise( 1275 IDataObject* iface,1276 IEnumSTATDATA** ppenumAdvise)1276 IDataObject* iface, 1277 IEnumSTATDATA** ppenumAdvise) 1277 1278 { 1278 1279 TRACE("()\n"); … … 1297 1298 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1298 1299 1299 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1300 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1300 1301 } 1301 1302 … … 1305 1306 * See Windows documentation for more details on IUnknown methods. 1306 1307 */ 1307 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 1308 static ULONG WINAPI DataCache_IPersistStorage_AddRef( 1308 1309 IPersistStorage* iface) 1309 1310 { 1310 1311 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1311 1312 1312 return IUnknown_AddRef(this->outerUnknown); 1313 return IUnknown_AddRef(this->outerUnknown); 1313 1314 } 1314 1315 … … 1318 1319 * See Windows documentation for more details on IUnknown methods. 1319 1320 */ 1320 static ULONG WINAPI DataCache_IPersistStorage_Release( 1321 static ULONG WINAPI DataCache_IPersistStorage_Release( 1321 1322 IPersistStorage* iface) 1322 1323 { 1323 1324 _ICOM_THIS_From_IPersistStorage(DataCache, iface); 1324 1325 1325 return IUnknown_Release(this->outerUnknown); 1326 return IUnknown_Release(this->outerUnknown); 1326 1327 } 1327 1328 … … 1333 1334 * See Windows documentation for more details on IPersistStorage methods. 1334 1335 */ 1335 static HRESULT WINAPI DataCache_GetClassID( 1336 static HRESULT WINAPI DataCache_GetClassID( 1336 1337 IPersistStorage* iface, 1337 CLSID* pClassID)1338 CLSID* pClassID) 1338 1339 { 1339 1340 TRACE("(%p, %p)\n", iface, pClassID); … … 1344 1345 * DataCache_IsDirty (IPersistStorage) 1345 1346 * 1346 * Until we actully connect to a running object and retrieve new 1347 * Until we actully connect to a running object and retrieve new 1347 1348 * information to it, we never get dirty. 1348 1349 * 1349 1350 * See Windows documentation for more details on IPersistStorage methods. 1350 1351 */ 1351 static HRESULT WINAPI DataCache_IsDirty( 1352 static HRESULT WINAPI DataCache_IsDirty( 1352 1353 IPersistStorage* iface) 1353 1354 { … … 1365 1366 * See Windows documentation for more details on IPersistStorage methods. 1366 1367 */ 1367 static HRESULT WINAPI DataCache_InitNew( 1368 IPersistStorage* iface, 1369 IStorage* pStg)1368 static HRESULT WINAPI DataCache_InitNew( 1369 IPersistStorage* iface, 1370 IStorage* pStg) 1370 1371 { 1371 1372 TRACE("(%p, %p)\n", iface, pStg); … … 1377 1378 * DataCache_Load (IPersistStorage) 1378 1379 * 1379 * The data cache implementation of IPersistStorage_Load doesn't 1380 * The data cache implementation of IPersistStorage_Load doesn't 1380 1381 * actually load anything. Instead, it holds on to the storage pointer 1381 * and it will load the presentation information when the 1382 * and it will load the presentation information when the 1382 1383 * IDataObject_GetData or IViewObject2_Draw methods are called. 1383 1384 * 1384 1385 * See Windows documentation for more details on IPersistStorage methods. 1385 1386 */ 1386 static HRESULT WINAPI DataCache_Load( 1387 static HRESULT WINAPI DataCache_Load( 1387 1388 IPersistStorage* iface, 1388 IStorage* pStg)1389 IStorage* pStg) 1389 1390 { 1390 1391 _ICOM_THIS_From_IPersistStorage(DataCache, iface); … … 1409 1410 * DataCache_Save (IPersistStorage) 1410 1411 * 1411 * Until we actully connect to a running object and retrieve new 1412 * Until we actully connect to a running object and retrieve new 1412 1413 * information to it, we never have to save anything. However, it is 1413 1414 * our responsability to copy the information when saving to a new … … 1416 1417 * See Windows documentation for more details on IPersistStorage methods. 1417 1418 */ 1418 static HRESULT WINAPI DataCache_Save( 1419 static HRESULT WINAPI DataCache_Save( 1419 1420 IPersistStorage* iface, 1420 IStorage* pStg, 1421 BOOL fSameAsLoad)1421 IStorage* pStg, 1422 BOOL fSameAsLoad) 1422 1423 { 1423 1424 _ICOM_THIS_From_IPersistStorage(DataCache, iface); … … 1425 1426 TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad); 1426 1427 1427 if ( (!fSameAsLoad) && 1428 if ( (!fSameAsLoad) && 1428 1429 (this->presentationStorage!=NULL) ) 1429 1430 { 1430 1431 return IStorage_CopyTo(this->presentationStorage, 1431 0,1432 NULL,1433 NULL,1434 pStg);1432 0, 1433 NULL, 1434 NULL, 1435 pStg); 1435 1436 } 1436 1437 … … 1446 1447 * See Windows documentation for more details on IPersistStorage methods. 1447 1448 */ 1448 static HRESULT WINAPI DataCache_SaveCompleted( 1449 IPersistStorage* iface, 1450 IStorage* pStgNew)1449 static HRESULT WINAPI DataCache_SaveCompleted( 1450 IPersistStorage* iface, 1451 IStorage* pStgNew) 1451 1452 { 1452 1453 TRACE("(%p, %p)\n", iface, pStgNew); … … 1511 1512 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1512 1513 1513 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1514 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1514 1515 } 1515 1516 … … 1519 1520 * See Windows documentation for more details on IUnknown methods. 1520 1521 */ 1521 static ULONG WINAPI DataCache_IViewObject2_AddRef( 1522 static ULONG WINAPI DataCache_IViewObject2_AddRef( 1522 1523 IViewObject2* iface) 1523 1524 { 1524 1525 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1525 1526 1526 return IUnknown_AddRef(this->outerUnknown); 1527 return IUnknown_AddRef(this->outerUnknown); 1527 1528 } 1528 1529 … … 1532 1533 * See Windows documentation for more details on IUnknown methods. 1533 1534 */ 1534 static ULONG WINAPI DataCache_IViewObject2_Release( 1535 static ULONG WINAPI DataCache_IViewObject2_Release( 1535 1536 IViewObject2* iface) 1536 1537 { 1537 1538 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1538 1539 1539 return IUnknown_Release(this->outerUnknown); 1540 return IUnknown_Release(this->outerUnknown); 1540 1541 } 1541 1542 … … 1550 1551 static HRESULT WINAPI DataCache_Draw( 1551 1552 IViewObject2* iface, 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)1553 DWORD dwDrawAspect, 1554 LONG lindex, 1555 void* pvAspect, 1556 DVTARGETDEVICE* ptd, 1557 HDC hdcTargetDev, 1558 HDC hdcDraw, 1559 LPCRECTL lprcBounds, 1560 LPCRECTL lprcWBounds, 1561 IVO_ContCallback pfnContinue, 1562 DWORD dwContinue) 1562 1563 { 1563 1564 PresentationDataHeader presData; … … 1568 1569 1569 1570 TRACE("(%p, %lx, %ld, %p, %x, %x, %p, %p, %p, %lx)\n", 1570 iface,1571 dwDrawAspect,1572 lindex,1573 pvAspect,1574 hdcTargetDev, 1575 hdcDraw,1576 lprcBounds,1577 lprcWBounds,1578 pfnContinue,1579 dwContinue);1571 iface, 1572 dwDrawAspect, 1573 lindex, 1574 pvAspect, 1575 hdcTargetDev, 1576 hdcDraw, 1577 lprcBounds, 1578 lprcWBounds, 1579 pfnContinue, 1580 dwContinue); 1580 1581 1581 1582 /* … … 1590 1591 */ 1591 1592 hres = DataCache_ReadPresentationData(this, 1592 dwDrawAspect,1593 &presData);1593 dwDrawAspect, 1594 &presData); 1594 1595 1595 1596 if (FAILED(hres)) … … 1604 1605 */ 1605 1606 presMetafile = DataCache_ReadPresMetafile(this, 1606 dwDrawAspect);1607 dwDrawAspect); 1607 1608 1608 1609 /* … … 1619 1620 1620 1621 SetWindowExtEx(hdcDraw, 1621 presData.dwObjectExtentX,1622 presData.dwObjectExtentY,1623 &oldWindowExt);1624 1625 SetViewportExtEx(hdcDraw, 1626 lprcBounds->right - lprcBounds->left,1627 lprcBounds->bottom - lprcBounds->top,1628 &oldViewportExt);1622 presData.dwObjectExtentX, 1623 presData.dwObjectExtentY, 1624 &oldWindowExt); 1625 1626 SetViewportExtEx(hdcDraw, 1627 lprcBounds->right - lprcBounds->left, 1628 lprcBounds->bottom - lprcBounds->top, 1629 &oldViewportExt); 1629 1630 1630 1631 SetViewportOrgEx(hdcDraw, 1631 lprcBounds->left,1632 lprcBounds->top,1633 &oldViewportOrg);1632 lprcBounds->left, 1633 lprcBounds->top, 1634 &oldViewportOrg); 1634 1635 1635 1636 PlayMetaFile(hdcDraw, presMetafile); 1636 1637 1637 1638 SetWindowExtEx(hdcDraw, 1638 oldWindowExt.cx,1639 oldWindowExt.cy,1640 NULL);1641 1642 SetViewportExtEx(hdcDraw, 1643 oldViewportExt.cx,1644 oldViewportExt.cy,1645 NULL);1639 oldWindowExt.cx, 1640 oldWindowExt.cy, 1641 NULL); 1642 1643 SetViewportExtEx(hdcDraw, 1644 oldViewportExt.cx, 1645 oldViewportExt.cy, 1646 NULL); 1646 1647 1647 1648 SetViewportOrgEx(hdcDraw, 1648 oldViewportOrg.x,1649 oldViewportOrg.y,1650 NULL);1649 oldViewportOrg.x, 1650 oldViewportOrg.y, 1651 NULL); 1651 1652 1652 1653 SetMapMode(hdcDraw, prevMapMode); … … 1659 1660 1660 1661 static HRESULT WINAPI DataCache_GetColorSet( 1661 IViewObject2* iface, 1662 DWORD dwDrawAspect, 1663 LONG lindex, 1664 void* pvAspect, 1665 DVTARGETDEVICE* ptd, 1666 HDC hicTargetDevice, 1667 LOGPALETTE** ppColorSet)1662 IViewObject2* iface, 1663 DWORD dwDrawAspect, 1664 LONG lindex, 1665 void* pvAspect, 1666 DVTARGETDEVICE* ptd, 1667 HDC hicTargetDevice, 1668 LOGPALETTE** ppColorSet) 1668 1669 { 1669 1670 FIXME("stub\n"); … … 1673 1674 static HRESULT WINAPI DataCache_Freeze( 1674 1675 IViewObject2* iface, 1675 DWORD dwDrawAspect,1676 LONG lindex,1677 void* pvAspect, 1678 DWORD* pdwFreeze)1676 DWORD dwDrawAspect, 1677 LONG lindex, 1678 void* pvAspect, 1679 DWORD* pdwFreeze) 1679 1680 { 1680 1681 FIXME("stub\n"); … … 1684 1685 static HRESULT WINAPI DataCache_Unfreeze( 1685 1686 IViewObject2* iface, 1686 DWORD dwFreeze)1687 DWORD dwFreeze) 1687 1688 { 1688 1689 FIXME("stub\n"); … … 1700 1701 static HRESULT WINAPI DataCache_SetAdvise( 1701 1702 IViewObject2* iface, 1702 DWORD aspects, 1703 DWORD advf, 1704 IAdviseSink* pAdvSink)1703 DWORD aspects, 1704 DWORD advf, 1705 IAdviseSink* pAdvSink) 1705 1706 { 1706 1707 _ICOM_THIS_From_IViewObject2(DataCache, iface); … … 1715 1716 IAdviseSink_Release(this->sinkInterface); 1716 1717 this->sinkInterface = NULL; 1717 this->sinkAspects = 0; 1718 this->sinkAspects = 0; 1718 1719 this->sinkAdviseFlag = 0; 1719 1720 } … … 1725 1726 { 1726 1727 this->sinkInterface = pAdvSink; 1727 this->sinkAspects = aspects; 1728 this->sinkAdviseFlag = advf; 1728 this->sinkAspects = aspects; 1729 this->sinkAdviseFlag = advf; 1729 1730 1730 1731 IAdviseSink_AddRef(this->sinkInterface); … … 1738 1739 { 1739 1740 DataCache_FireOnViewChange(this, 1740 DVASPECT_CONTENT,1741 -1);1741 DVASPECT_CONTENT, 1742 -1); 1742 1743 } 1743 1744 … … 1748 1749 * DataCache_GetAdvise (IViewObject2) 1749 1750 * 1750 * This method queries the current state of the advise sink 1751 * This method queries the current state of the advise sink 1751 1752 * installed on the data cache. 1752 1753 * … … 1754 1755 */ 1755 1756 static HRESULT WINAPI DataCache_GetAdvise( 1756 IViewObject2* iface, 1757 DWORD* pAspects, 1758 DWORD* pAdvf, 1759 IAdviseSink** ppAdvSink)1757 IViewObject2* iface, 1758 DWORD* pAspects, 1759 DWORD* pAdvf, 1760 IAdviseSink** ppAdvSink) 1760 1761 { 1761 1762 _ICOM_THIS_From_IViewObject2(DataCache, iface); … … 1774 1775 if (ppAdvSink!=NULL) 1775 1776 { 1776 IAdviseSink_QueryInterface(this->sinkInterface, 1777 &IID_IAdviseSink, 1778 (void**)ppAdvSink);1777 IAdviseSink_QueryInterface(this->sinkInterface, 1778 &IID_IAdviseSink, 1779 (void**)ppAdvSink); 1779 1780 } 1780 1781 … … 1790 1791 */ 1791 1792 static HRESULT WINAPI DataCache_GetExtent( 1792 IViewObject2* iface, 1793 DWORD dwDrawAspect, 1794 LONG lindex, 1795 DVTARGETDEVICE* ptd, 1796 LPSIZEL lpsizel)1793 IViewObject2* iface, 1794 DWORD dwDrawAspect, 1795 LONG lindex, 1796 DVTARGETDEVICE* ptd, 1797 LPSIZEL lpsizel) 1797 1798 { 1798 1799 PresentationDataHeader presData; … … 1801 1802 _ICOM_THIS_From_IViewObject2(DataCache, iface); 1802 1803 1803 TRACE("(%p, %lx, %ld, %p, %p)\n", 1804 iface, dwDrawAspect, lindex, ptd, lpsizel);1804 TRACE("(%p, %lx, %ld, %p, %p)\n", 1805 iface, dwDrawAspect, lindex, ptd, lpsizel); 1805 1806 1806 1807 /* … … 1828 1829 if (ptd!=NULL) 1829 1830 FIXME("Unimplemented ptd = %p\n", ptd); 1830 1831 /* 1832 * Get the presentation information from the 1831 1832 /* 1833 * Get the presentation information from the 1833 1834 * cache. 1834 1835 */ 1835 1836 hres = DataCache_ReadPresentationData(this, 1836 dwDrawAspect,1837 &presData);1837 dwDrawAspect, 1838 &presData); 1838 1839 1839 1840 if (SUCCEEDED(hres)) … … 1870 1871 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1871 1872 1872 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1873 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1873 1874 } 1874 1875 … … 1878 1879 * See Windows documentation for more details on IUnknown methods. 1879 1880 */ 1880 static ULONG WINAPI DataCache_IOleCache2_AddRef( 1881 static ULONG WINAPI DataCache_IOleCache2_AddRef( 1881 1882 IOleCache2* iface) 1882 1883 { 1883 1884 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1884 1885 1885 return IUnknown_AddRef(this->outerUnknown); 1886 return IUnknown_AddRef(this->outerUnknown); 1886 1887 } 1887 1888 … … 1891 1892 * See Windows documentation for more details on IUnknown methods. 1892 1893 */ 1893 static ULONG WINAPI DataCache_IOleCache2_Release( 1894 static ULONG WINAPI DataCache_IOleCache2_Release( 1894 1895 IOleCache2* iface) 1895 1896 { 1896 1897 _ICOM_THIS_From_IOleCache2(DataCache, iface); 1897 1898 1898 return IUnknown_Release(this->outerUnknown); 1899 return IUnknown_Release(this->outerUnknown); 1899 1900 } 1900 1901 1901 1902 static HRESULT WINAPI DataCache_Cache( 1902 1903 IOleCache2* iface, 1903 FORMATETC* pformatetc,1904 DWORD advf,1905 DWORD* pdwConnection)1904 FORMATETC* pformatetc, 1905 DWORD advf, 1906 DWORD* pdwConnection) 1906 1907 { 1907 1908 FIXME("stub\n"); … … 1910 1911 1911 1912 static HRESULT WINAPI DataCache_Uncache( 1912 IOleCache2* iface,1913 DWORD dwConnection)1913 IOleCache2* iface, 1914 DWORD dwConnection) 1914 1915 { 1915 1916 FIXME("stub\n"); … … 1919 1920 static HRESULT WINAPI DataCache_EnumCache( 1920 1921 IOleCache2* iface, 1921 IEnumSTATDATA** ppenumSTATDATA)1922 IEnumSTATDATA** ppenumSTATDATA) 1922 1923 { 1923 1924 FIXME("stub\n"); … … 1926 1927 1927 1928 static HRESULT WINAPI DataCache_InitCache( 1928 IOleCache2* iface,1929 IDataObject* pDataObject)1929 IOleCache2* iface, 1930 IDataObject* pDataObject) 1930 1931 { 1931 1932 FIXME("stub\n"); … … 1935 1936 static HRESULT WINAPI DataCache_IOleCache2_SetData( 1936 1937 IOleCache2* iface, 1937 FORMATETC* pformatetc,1938 STGMEDIUM* pmedium,1939 BOOL fRelease)1938 FORMATETC* pformatetc, 1939 STGMEDIUM* pmedium, 1940 BOOL fRelease) 1940 1941 { 1941 1942 FIXME("stub\n"); … … 1945 1946 static HRESULT WINAPI DataCache_UpdateCache( 1946 1947 IOleCache2* iface, 1947 LPDATAOBJECT pDataObject, 1948 DWORD grfUpdf,1949 LPVOID pReserved)1948 LPDATAOBJECT pDataObject, 1949 DWORD grfUpdf, 1950 LPVOID pReserved) 1950 1951 { 1951 1952 FIXME("stub\n"); … … 1955 1956 static HRESULT WINAPI DataCache_DiscardCache( 1956 1957 IOleCache2* iface, 1957 DWORD dwDiscardOptions)1958 DWORD dwDiscardOptions) 1958 1959 { 1959 1960 FIXME("stub\n"); … … 1979 1980 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 1980 1981 1981 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1982 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1982 1983 } 1983 1984 … … 1987 1988 * See Windows documentation for more details on IUnknown methods. 1988 1989 */ 1989 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 1990 static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 1990 1991 IOleCacheControl* iface) 1991 1992 { 1992 1993 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 1993 1994 1994 return IUnknown_AddRef(this->outerUnknown); 1995 return IUnknown_AddRef(this->outerUnknown); 1995 1996 } 1996 1997 … … 2000 2001 * See Windows documentation for more details on IUnknown methods. 2001 2002 */ 2002 static ULONG WINAPI DataCache_IOleCacheControl_Release( 2003 static ULONG WINAPI DataCache_IOleCacheControl_Release( 2003 2004 IOleCacheControl* iface) 2004 2005 { 2005 2006 _ICOM_THIS_From_IOleCacheControl(DataCache, iface); 2006 2007 2007 return IUnknown_Release(this->outerUnknown); 2008 return IUnknown_Release(this->outerUnknown); 2008 2009 } 2009 2010 2010 2011 static HRESULT WINAPI DataCache_OnRun( 2011 IOleCacheControl* iface,2012 LPDATAOBJECT pDataObject)2012 IOleCacheControl* iface, 2013 LPDATAOBJECT pDataObject) 2013 2014 { 2014 2015 FIXME("stub\n"); … … 2017 2018 2018 2019 static HRESULT WINAPI DataCache_OnStop( 2019 IOleCacheControl* iface)2020 IOleCacheControl* iface) 2020 2021 { 2021 2022 FIXME("stub\n"); -
trunk/src/ole32/defaulthandler.c
r5602 r6648 1 /* $Id: defaulthandler.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */ 1 2 /* 2 * OLE 2 default object handler3 * OLE 2 default object handler 3 4 * 4 5 * Copyright 1999 Francis Beaudet … … 25 26 * done in this area. 26 27 * 27 * - Some functions still return E_NOTIMPL they have to be 28 * - Some functions still return E_NOTIMPL they have to be 28 29 * implemented. Most of those are related to the running of the 29 30 * actual server. … … 53 54 * List all interface VTables here 54 55 */ 55 ICOM_VTABLE(IOleObject)* lpvtbl1; 56 ICOM_VTABLE(IOleObject)* lpvtbl1; 56 57 ICOM_VTABLE(IUnknown)* lpvtbl2; 57 58 ICOM_VTABLE(IDataObject)* lpvtbl3; … … 90 91 91 92 /* 92 * The IDataAdviseHolder maintains the data 93 * The IDataAdviseHolder maintains the data 93 94 * connections on behalf of the default handler. 94 95 */ … … 98 99 * Name of the container and object contained 99 100 */ 100 LPWSTR containerApp; 101 LPWSTR containerApp; 101 102 LPWSTR containerObj; 102 103 … … 106 107 107 108 /* 108 * Here, I define utility macros to help with the casting of the 109 * Here, I define utility macros to help with the casting of the 109 110 * "this" parameter. 110 111 * There is a version to accomodate all of the VTables implemented … … 112 113 */ 113 114 #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name; 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*)); 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*)); 117 118 118 119 /* … … 120 121 */ 121 122 static DefaultHandler* DefaultHandler_Construct(REFCLSID clsid, 122 LPUNKNOWN pUnkOuter);123 LPUNKNOWN pUnkOuter); 123 124 static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy); 124 125 … … 131 132 REFIID riid, 132 133 void** ppvObject); 133 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 134 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 134 135 IUnknown* iface); 135 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 136 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 136 137 IUnknown* iface); 137 138 … … 144 145 REFIID riid, 145 146 void** ppvObject); 146 static ULONG WINAPI DefaultHandler_AddRef( 147 static ULONG WINAPI DefaultHandler_AddRef( 147 148 IOleObject* iface); 148 static ULONG WINAPI DefaultHandler_Release( 149 static ULONG WINAPI DefaultHandler_Release( 149 150 IOleObject* iface); 150 151 static HRESULT WINAPI DefaultHandler_SetClientSite( 151 IOleObject* iface,152 IOleClientSite* pClientSite);152 IOleObject* iface, 153 IOleClientSite* pClientSite); 153 154 static HRESULT WINAPI DefaultHandler_GetClientSite( 154 IOleObject* iface,155 IOleClientSite** ppClientSite);155 IOleObject* iface, 156 IOleClientSite** ppClientSite); 156 157 static HRESULT WINAPI DefaultHandler_SetHostNames( 157 IOleObject* iface,158 LPCOLESTR szContainerApp, 159 LPCOLESTR szContainerObj);158 IOleObject* iface, 159 LPCOLESTR szContainerApp, 160 LPCOLESTR szContainerObj); 160 161 static HRESULT WINAPI DefaultHandler_Close( 161 IOleObject* iface, 162 DWORD dwSaveOption);162 IOleObject* iface, 163 DWORD dwSaveOption); 163 164 static HRESULT WINAPI DefaultHandler_SetMoniker( 164 IOleObject* iface, 165 DWORD dwWhichMoniker,166 IMoniker* pmk);165 IOleObject* iface, 166 DWORD dwWhichMoniker, 167 IMoniker* pmk); 167 168 static HRESULT WINAPI DefaultHandler_GetMoniker( 168 IOleObject* iface,169 DWORD dwAssign,170 DWORD dwWhichMoniker,171 IMoniker** ppmk);169 IOleObject* iface, 170 DWORD dwAssign, 171 DWORD dwWhichMoniker, 172 IMoniker** ppmk); 172 173 static HRESULT WINAPI DefaultHandler_InitFromData( 173 IOleObject* iface, 174 IDataObject* pDataObject, 175 BOOL fCreation,176 DWORD dwReserved);174 IOleObject* iface, 175 IDataObject* pDataObject, 176 BOOL fCreation, 177 DWORD dwReserved); 177 178 static HRESULT WINAPI DefaultHandler_GetClipboardData( 178 IOleObject* iface, 179 DWORD dwReserved, 180 IDataObject** ppDataObject);179 IOleObject* iface, 180 DWORD dwReserved, 181 IDataObject** ppDataObject); 181 182 static HRESULT WINAPI DefaultHandler_DoVerb( 182 IOleObject* iface, 183 LONG iVerb, 183 IOleObject* iface, 184 LONG iVerb, 184 185 #ifdef __WIN32OS2__ 185 LPMSG lpmsg, 186 LPMSG lpmsg, 186 187 #else 187 struct tagMSG* lpmsg, 188 struct tagMSG* lpmsg, 188 189 #endif 189 IOleClientSite* pActiveSite, 190 LONG lindex, 191 HWND hwndParent, 192 LPCRECT lprcPosRect);190 IOleClientSite* pActiveSite, 191 LONG lindex, 192 HWND hwndParent, 193 LPCRECT lprcPosRect); 193 194 static HRESULT WINAPI DefaultHandler_EnumVerbs( 194 IOleObject* iface, 195 IEnumOLEVERB** ppEnumOleVerb);195 IOleObject* iface, 196 IEnumOLEVERB** ppEnumOleVerb); 196 197 static HRESULT WINAPI DefaultHandler_Update( 197 IOleObject* iface);198 IOleObject* iface); 198 199 static HRESULT WINAPI DefaultHandler_IsUpToDate( 199 IOleObject* iface);200 IOleObject* iface); 200 201 static HRESULT WINAPI DefaultHandler_GetUserClassID( 201 IOleObject* iface, 202 CLSID* pClsid);202 IOleObject* iface, 203 CLSID* pClsid); 203 204 static HRESULT WINAPI DefaultHandler_GetUserType( 204 IOleObject* iface, 205 DWORD dwFormOfType, 206 LPOLESTR* pszUserType);205 IOleObject* iface, 206 DWORD dwFormOfType, 207 LPOLESTR* pszUserType); 207 208 static HRESULT WINAPI DefaultHandler_SetExtent( 208 IOleObject* iface, 209 DWORD dwDrawAspect, 210 SIZEL* psizel);209 IOleObject* iface, 210 DWORD dwDrawAspect, 211 SIZEL* psizel); 211 212 static HRESULT WINAPI DefaultHandler_GetExtent( 212 IOleObject* iface, 213 DWORD dwDrawAspect, 214 SIZEL* psizel);213 IOleObject* iface, 214 DWORD dwDrawAspect, 215 SIZEL* psizel); 215 216 static HRESULT WINAPI DefaultHandler_Advise( 216 IOleObject* iface, 217 IAdviseSink* pAdvSink, 218 DWORD* pdwConnection);217 IOleObject* iface, 218 IAdviseSink* pAdvSink, 219 DWORD* pdwConnection); 219 220 static HRESULT WINAPI DefaultHandler_Unadvise( 220 IOleObject* iface, 221 DWORD dwConnection);221 IOleObject* iface, 222 DWORD dwConnection); 222 223 static HRESULT WINAPI DefaultHandler_EnumAdvise( 223 IOleObject* iface, 224 IEnumSTATDATA** ppenumAdvise);224 IOleObject* iface, 225 IEnumSTATDATA** ppenumAdvise); 225 226 static HRESULT WINAPI DefaultHandler_GetMiscStatus( 226 IOleObject* iface, 227 DWORD dwAspect, 228 DWORD* pdwStatus);227 IOleObject* iface, 228 DWORD dwAspect, 229 DWORD* pdwStatus); 229 230 static HRESULT WINAPI DefaultHandler_SetColorScheme( 230 IOleObject* iface,231 struct tagLOGPALETTE* pLogpal);231 IOleObject* iface, 232 struct tagLOGPALETTE* pLogpal); 232 233 233 234 /* … … 239 240 REFIID riid, 240 241 void** ppvObject); 241 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 242 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 242 243 IDataObject* iface); 243 static ULONG WINAPI DefaultHandler_IDataObject_Release( 244 static ULONG WINAPI DefaultHandler_IDataObject_Release( 244 245 IDataObject* iface); 245 246 static HRESULT WINAPI DefaultHandler_GetData( 246 IDataObject* iface,247 LPFORMATETC pformatetcIn, 248 STGMEDIUM* pmedium);247 IDataObject* iface, 248 LPFORMATETC pformatetcIn, 249 STGMEDIUM* pmedium); 249 250 static HRESULT WINAPI DefaultHandler_GetDataHere( 250 IDataObject* iface, 251 LPFORMATETC pformatetc,252 STGMEDIUM* pmedium);251 IDataObject* iface, 252 LPFORMATETC pformatetc, 253 STGMEDIUM* pmedium); 253 254 static HRESULT WINAPI DefaultHandler_QueryGetData( 254 IDataObject* iface,255 LPFORMATETC pformatetc);255 IDataObject* iface, 256 LPFORMATETC pformatetc); 256 257 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc( 257 IDataObject* iface, 258 LPFORMATETC pformatectIn, 259 LPFORMATETC pformatetcOut);258 IDataObject* iface, 259 LPFORMATETC pformatectIn, 260 LPFORMATETC pformatetcOut); 260 261 static HRESULT WINAPI DefaultHandler_SetData( 261 IDataObject* iface,262 LPFORMATETC pformatetc, 263 STGMEDIUM* pmedium, 264 BOOL fRelease);262 IDataObject* iface, 263 LPFORMATETC pformatetc, 264 STGMEDIUM* pmedium, 265 BOOL fRelease); 265 266 static HRESULT WINAPI DefaultHandler_EnumFormatEtc( 266 IDataObject* iface, 267 DWORD dwDirection,268 IEnumFORMATETC** ppenumFormatEtc);267 IDataObject* iface, 268 DWORD dwDirection, 269 IEnumFORMATETC** ppenumFormatEtc); 269 270 static HRESULT WINAPI DefaultHandler_DAdvise( 270 IDataObject* iface, 271 FORMATETC* pformatetc, 272 DWORD advf, 273 IAdviseSink* pAdvSink, 274 DWORD* pdwConnection);271 IDataObject* iface, 272 FORMATETC* pformatetc, 273 DWORD advf, 274 IAdviseSink* pAdvSink, 275 DWORD* pdwConnection); 275 276 static HRESULT WINAPI DefaultHandler_DUnadvise( 276 IDataObject* iface,277 DWORD dwConnection);277 IDataObject* iface, 278 DWORD dwConnection); 278 279 static HRESULT WINAPI DefaultHandler_EnumDAdvise( 279 IDataObject* iface,280 IEnumSTATDATA** ppenumAdvise);280 IDataObject* iface, 281 IEnumSTATDATA** ppenumAdvise); 281 282 282 283 /* … … 288 289 REFIID riid, 289 290 void** ppvObject); 290 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 291 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 291 292 IRunnableObject* iface); 292 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 293 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 293 294 IRunnableObject* iface); 294 static HRESULT WINAPI DefaultHandler_GetRunningClass( 295 IRunnableObject* iface, 296 LPCLSID lpClsid); 297 static HRESULT WINAPI DefaultHandler_Run( 295 static HRESULT WINAPI DefaultHandler_GetRunningClass( 298 296 IRunnableObject* iface, 299 IBindCtx* pbc); 300 static BOOL WINAPI DefaultHandler_IsRunning( 297 LPCLSID lpClsid); 298 static HRESULT WINAPI DefaultHandler_Run( 299 IRunnableObject* iface, 300 IBindCtx* pbc); 301 static BOOL WINAPI DefaultHandler_IsRunning( 301 302 IRunnableObject* iface); 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);303 static HRESULT WINAPI DefaultHandler_LockRunning( 304 IRunnableObject* iface, 305 BOOL fLock, 306 BOOL fLastUnlockCloses); 307 static HRESULT WINAPI DefaultHandler_SetContainedObject( 308 IRunnableObject* iface, 309 BOOL fContained); 309 310 310 311 … … 407 408 * IUnknown pointer can be returned to the outside. 408 409 */ 409 if ( (pUnkOuter!=NULL) && 410 if ( (pUnkOuter!=NULL) && 410 411 (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) ) 411 412 return CLASS_E_NOAGGREGATION; … … 414 415 * Try to construct a new instance of the class. 415 416 */ 416 newHandler = DefaultHandler_Construct(clsid, 417 pUnkOuter);417 newHandler = DefaultHandler_Construct(clsid, 418 pUnkOuter); 418 419 419 420 if (newHandler == 0) … … 450 451 if (newObject==0) 451 452 return newObject; 452 453 453 454 /* 454 455 * Initialize the virtual function table. … … 460 461 461 462 /* 462 * Start with one reference count. The caller of this function 463 * Start with one reference count. The caller of this function 463 464 * must release the interface pointer when it is done. 464 465 */ … … 467 468 /* 468 469 * Initialize the outer unknown 469 * We don't keep a reference on the outer unknown since, the way 470 * We don't keep a reference on the outer unknown since, the way 470 471 * aggregation works, our lifetime is at least as large as it's 471 472 * lifetime. … … 479 480 * Create a datacache object. 480 481 * We aggregate with the datacache. Make sure we pass our outer 481 * unknown as the datacache's outer unknown. 482 * unknown as the datacache's outer unknown. 482 483 */ 483 484 CreateDataCache(newObject->outerUnknown, 484 clsid,485 &IID_IUnknown,486 (void**)&newObject->dataCache);485 clsid, 486 &IID_IUnknown, 487 (void**)&newObject->dataCache); 487 488 488 489 /* … … 516 517 ptrToDestroy->containerObj = NULL; 517 518 } 518 519 519 520 /* 520 521 * Release our reference to the data cache. … … 585 586 if ( (this==0) || (ppvObject==0) ) 586 587 return E_INVALIDARG; 587 588 588 589 /* 589 590 * Initialize the return parameter. … … 594 595 * Compare the riid with the interface IDs implemented by this object. 595 596 */ 596 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 597 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 597 598 { 598 599 *ppvObject = iface; 599 600 } 600 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 601 else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 601 602 { 602 603 *ppvObject = (IOleObject*)&(this->lpvtbl1); 603 604 } 604 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 605 else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 605 606 { 606 607 *ppvObject = (IDataObject*)&(this->lpvtbl3); 607 608 } 608 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 609 else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 609 610 { 610 611 *ppvObject = (IRunnableObject*)&(this->lpvtbl4); … … 616 617 */ 617 618 if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK) 618 return S_OK;619 } 620 619 return S_OK; 620 } 621 621 622 /* 622 623 * Check that we obtained an interface. … … 627 628 return E_NOINTERFACE; 628 629 } 629 630 630 631 /* 631 632 * Query Interface always increases the reference count by one when it is 632 * successful. 633 * successful. 633 634 */ 634 635 IUnknown_AddRef((IUnknown*)*ppvObject); 635 636 636 return S_OK;; 637 return S_OK;; 637 638 } 638 639 … … 645 646 * to the outer unknown. 646 647 */ 647 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 648 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 648 649 IUnknown* iface) 649 650 { … … 663 664 * to the outer unknown. 664 665 */ 665 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 666 static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 666 667 IUnknown* iface) 667 668 { … … 682 683 return 0; 683 684 } 684 685 685 686 return this->ref; 686 687 } … … 703 704 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 704 705 705 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 706 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 706 707 } 707 708 … … 711 712 * See Windows documentation for more details on IUnknown methods. 712 713 */ 713 static ULONG WINAPI DefaultHandler_AddRef( 714 static ULONG WINAPI DefaultHandler_AddRef( 714 715 IOleObject* iface) 715 716 { … … 724 725 * See Windows documentation for more details on IUnknown methods. 725 726 */ 726 static ULONG WINAPI DefaultHandler_Release( 727 static ULONG WINAPI DefaultHandler_Release( 727 728 IOleObject* iface) 728 729 { … … 741 742 */ 742 743 static HRESULT WINAPI DefaultHandler_SetClientSite( 743 IOleObject* iface,744 IOleClientSite* pClientSite)744 IOleObject* iface, 745 IOleClientSite* pClientSite) 745 746 { 746 747 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 776 777 */ 777 778 static HRESULT WINAPI DefaultHandler_GetClientSite( 778 IOleObject* iface,779 IOleClientSite** ppClientSite)779 IOleObject* iface, 780 IOleClientSite** ppClientSite) 780 781 { 781 782 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 806 807 */ 807 808 static HRESULT WINAPI DefaultHandler_SetHostNames( 808 IOleObject* iface,809 LPCOLESTR szContainerApp, 810 LPCOLESTR szContainerObj)809 IOleObject* iface, 810 LPCOLESTR szContainerApp, 811 LPCOLESTR szContainerObj) 811 812 { 812 813 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 813 814 814 815 TRACE("(%p, %s, %s)\n", 815 iface,816 debugstr_w(szContainerApp), 817 debugstr_w(szContainerObj));816 iface, 817 debugstr_w(szContainerApp), 818 debugstr_w(szContainerObj)); 818 819 819 820 /* 820 821 * Be sure to cleanup before re-assinging the strings. 821 */ 822 */ 822 823 if (this->containerApp!=NULL) 823 824 { … … 860 861 */ 861 862 static HRESULT WINAPI DefaultHandler_Close( 862 IOleObject* iface, 863 DWORD dwSaveOption)863 IOleObject* iface, 864 DWORD dwSaveOption) 864 865 { 865 866 TRACE("()\n"); … … 875 876 */ 876 877 static HRESULT WINAPI DefaultHandler_SetMoniker( 877 IOleObject* iface, 878 DWORD dwWhichMoniker,879 IMoniker* pmk)878 IOleObject* iface, 879 DWORD dwWhichMoniker, 880 IMoniker* pmk) 880 881 { 881 882 TRACE("(%p, %ld, %p)\n", 882 iface, 883 dwWhichMoniker, 884 pmk);883 iface, 884 dwWhichMoniker, 885 pmk); 885 886 886 887 return S_OK; … … 895 896 */ 896 897 static HRESULT WINAPI DefaultHandler_GetMoniker( 897 IOleObject* iface,898 DWORD dwAssign,899 DWORD dwWhichMoniker,900 IMoniker** ppmk)898 IOleObject* iface, 899 DWORD dwAssign, 900 DWORD dwWhichMoniker, 901 IMoniker** ppmk) 901 902 { 902 903 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 903 904 904 905 TRACE("(%p, %ld, %ld, %p)\n", 905 iface, dwAssign, dwWhichMoniker, ppmk);906 iface, dwAssign, dwWhichMoniker, ppmk); 906 907 907 908 if (this->clientSite) 908 909 { 909 910 return IOleClientSite_GetMoniker(this->clientSite, 910 dwAssign,911 dwWhichMoniker,912 ppmk);913 911 dwAssign, 912 dwWhichMoniker, 913 ppmk); 914 914 915 } 915 916 … … 921 922 * 922 923 * This method is meaningless if the server is not running 923 * 924 * 924 925 * See Windows documentation for more details on IOleObject methods. 925 926 */ 926 927 static HRESULT WINAPI DefaultHandler_InitFromData( 927 IOleObject* iface, 928 IDataObject* pDataObject, 929 BOOL fCreation,930 DWORD dwReserved)928 IOleObject* iface, 929 IDataObject* pDataObject, 930 BOOL fCreation, 931 DWORD dwReserved) 931 932 { 932 933 TRACE("(%p, %p, %d, %ld)\n", 933 iface, pDataObject, fCreation, dwReserved);934 iface, pDataObject, fCreation, dwReserved); 934 935 935 936 return OLE_E_NOTRUNNING; … … 940 941 * 941 942 * This method is meaningless if the server is not running 942 * 943 * 943 944 * See Windows documentation for more details on IOleObject methods. 944 945 */ 945 946 static HRESULT WINAPI DefaultHandler_GetClipboardData( 946 IOleObject* iface, 947 DWORD dwReserved, 948 IDataObject** ppDataObject)947 IOleObject* iface, 948 DWORD dwReserved, 949 IDataObject** ppDataObject) 949 950 { 950 951 TRACE("(%p, %ld, %p)\n", 951 iface, dwReserved, ppDataObject);952 iface, dwReserved, ppDataObject); 952 953 953 954 return OLE_E_NOTRUNNING; … … 955 956 956 957 static HRESULT WINAPI DefaultHandler_DoVerb( 957 IOleObject* iface, 958 LONG iVerb, 958 IOleObject* iface, 959 LONG iVerb, 959 960 #ifdef __WIN32OS2__ 960 LPMSG lpmsg, 961 LPMSG lpmsg, 961 962 #else 962 struct tagMSG* lpmsg, 963 struct tagMSG* lpmsg, 963 964 #endif 964 IOleClientSite* pActiveSite, 965 LONG lindex, 966 HWND hwndParent, 967 LPCRECT lprcPosRect)965 IOleClientSite* pActiveSite, 966 LONG lindex, 967 HWND hwndParent, 968 LPCRECT lprcPosRect) 968 969 { 969 970 FIXME(": Stub\n"); … … 976 977 * The default handler implementation of this method simply delegates 977 978 * to OleRegEnumVerbs 978 * 979 * 979 980 * See Windows documentation for more details on IOleObject methods. 980 981 */ 981 982 static HRESULT WINAPI DefaultHandler_EnumVerbs( 982 IOleObject* iface, 983 IEnumOLEVERB** ppEnumOleVerb)983 IOleObject* iface, 984 IEnumOLEVERB** ppEnumOleVerb) 984 985 { 985 986 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 991 992 992 993 static HRESULT WINAPI DefaultHandler_Update( 993 IOleObject* iface)994 IOleObject* iface) 994 995 { 995 996 FIXME(": Stub\n"); … … 1001 1002 * 1002 1003 * This method is meaningless if the server is not running 1003 * 1004 * 1004 1005 * See Windows documentation for more details on IOleObject methods. 1005 1006 */ 1006 1007 static HRESULT WINAPI DefaultHandler_IsUpToDate( 1007 IOleObject* iface)1008 IOleObject* iface) 1008 1009 { 1009 1010 TRACE("(%p)\n", iface); … … 1016 1017 * 1017 1018 * TODO: Map to a new class ID if emulation is active. 1018 * 1019 * 1019 1020 * See Windows documentation for more details on IOleObject methods. 1020 1021 */ 1021 1022 static HRESULT WINAPI DefaultHandler_GetUserClassID( 1022 IOleObject* iface, 1023 CLSID* pClsid)1023 IOleObject* iface, 1024 CLSID* pClsid) 1024 1025 { 1025 1026 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 1043 1044 * The default handler implementation of this method simply delegates 1044 1045 * to OleRegGetUserType 1045 * 1046 * 1046 1047 * See Windows documentation for more details on IOleObject methods. 1047 1048 */ 1048 1049 static HRESULT WINAPI DefaultHandler_GetUserType( 1049 IOleObject* iface, 1050 DWORD dwFormOfType, 1051 LPOLESTR* pszUserType)1050 IOleObject* iface, 1051 DWORD dwFormOfType, 1052 LPOLESTR* pszUserType) 1052 1053 { 1053 1054 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); … … 1066 1067 */ 1067 1068 static HRESULT WINAPI DefaultHandler_SetExtent( 1068 IOleObject* iface, 1069 DWORD dwDrawAspect, 1070 SIZEL* psizel)1069 IOleObject* iface, 1070 DWORD dwDrawAspect, 1071 SIZEL* psizel) 1071 1072 { 1072 1073 TRACE("(%p, %lx, (%ld x %ld))\n", iface, … … 1084 1085 */ 1085 1086 static HRESULT WINAPI DefaultHandler_GetExtent( 1086 IOleObject* iface, 1087 DWORD dwDrawAspect, 1088 SIZEL* psizel)1087 IOleObject* iface, 1088 DWORD dwDrawAspect, 1089 SIZEL* psizel) 1089 1090 { 1090 1091 DVTARGETDEVICE* targetDevice; … … 1092 1093 HRESULT hres; 1093 1094 1094 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1095 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1095 1096 1096 1097 TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel); … … 1105 1106 * 1106 1107 * Here we would build a valid DVTARGETDEVICE structure 1107 * but, since we are calling into the data cache, we 1108 * know it's implementation and we'll skip this 1108 * but, since we are calling into the data cache, we 1109 * know it's implementation and we'll skip this 1109 1110 * extra work until later. 1110 1111 */ … … 1112 1113 1113 1114 hres = IViewObject2_GetExtent(cacheView, 1114 dwDrawAspect,1115 -1,1116 targetDevice,1117 psizel);1115 dwDrawAspect, 1116 -1, 1117 targetDevice, 1118 psizel); 1118 1119 1119 1120 /* … … 1134 1135 */ 1135 1136 static HRESULT WINAPI DefaultHandler_Advise( 1136 IOleObject* iface, 1137 IAdviseSink* pAdvSink, 1138 DWORD* pdwConnection)1137 IOleObject* iface, 1138 IAdviseSink* pAdvSink, 1139 DWORD* pdwConnection) 1139 1140 { 1140 1141 HRESULT hres = S_OK; 1141 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1142 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1142 1143 1143 1144 TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection); … … 1153 1154 if (SUCCEEDED(hres)) 1154 1155 { 1155 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 1156 pAdvSink, 1157 pdwConnection);1156 hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 1157 pAdvSink, 1158 pdwConnection); 1158 1159 } 1159 1160 … … 1170 1171 */ 1171 1172 static HRESULT WINAPI DefaultHandler_Unadvise( 1172 IOleObject* iface, 1173 DWORD dwConnection)1174 { 1175 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1173 IOleObject* iface, 1174 DWORD dwConnection) 1175 { 1176 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1176 1177 1177 1178 TRACE("(%p, %ld)\n", iface, dwConnection); … … 1185 1186 1186 1187 return IOleAdviseHolder_Unadvise(this->oleAdviseHolder, 1187 dwConnection);1188 dwConnection); 1188 1189 } 1189 1190 … … 1197 1198 */ 1198 1199 static HRESULT WINAPI DefaultHandler_EnumAdvise( 1199 IOleObject* iface, 1200 IEnumSTATDATA** ppenumAdvise)1201 { 1202 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1200 IOleObject* iface, 1201 IEnumSTATDATA** ppenumAdvise) 1202 { 1203 _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 1203 1204 1204 1205 TRACE("(%p, %p)\n", iface, ppenumAdvise); … … 1217 1218 if (this->oleAdviseHolder==NULL) 1218 1219 return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder, 1219 ppenumAdvise);1220 ppenumAdvise); 1220 1221 1221 1222 return S_OK; … … 1231 1232 */ 1232 1233 static HRESULT WINAPI DefaultHandler_GetMiscStatus( 1233 IOleObject* iface, 1234 DWORD dwAspect, 1235 DWORD* pdwStatus)1234 IOleObject* iface, 1235 DWORD dwAspect, 1236 DWORD* pdwStatus) 1236 1237 { 1237 1238 HRESULT hres; … … 1256 1257 */ 1257 1258 static HRESULT WINAPI DefaultHandler_SetColorScheme( 1258 IOleObject* iface,1259 struct tagLOGPALETTE* pLogpal)1259 IOleObject* iface, 1260 struct tagLOGPALETTE* pLogpal) 1260 1261 { 1261 1262 TRACE("(%p, %p))\n", iface, pLogpal); … … 1274 1275 */ 1275 1276 static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface( 1276 IDataObject* iface, 1277 IDataObject* iface, 1277 1278 REFIID riid, 1278 1279 void** ppvObject) … … 1280 1281 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1281 1282 1282 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1283 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1283 1284 } 1284 1285 … … 1288 1289 * See Windows documentation for more details on IUnknown methods. 1289 1290 */ 1290 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 1291 static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 1291 1292 IDataObject* iface) 1292 1293 { 1293 1294 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1294 1295 1295 return IUnknown_AddRef(this->outerUnknown); 1296 return IUnknown_AddRef(this->outerUnknown); 1296 1297 } 1297 1298 … … 1301 1302 * See Windows documentation for more details on IUnknown methods. 1302 1303 */ 1303 static ULONG WINAPI DefaultHandler_IDataObject_Release( 1304 static ULONG WINAPI DefaultHandler_IDataObject_Release( 1304 1305 IDataObject* iface) 1305 1306 { 1306 1307 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1307 1308 1308 return IUnknown_Release(this->outerUnknown); 1309 return IUnknown_Release(this->outerUnknown); 1309 1310 } 1310 1311 … … 1317 1318 */ 1318 1319 static HRESULT WINAPI DefaultHandler_GetData( 1319 IDataObject* iface,1320 LPFORMATETC pformatetcIn, 1321 STGMEDIUM* pmedium)1320 IDataObject* iface, 1321 LPFORMATETC pformatetcIn, 1322 STGMEDIUM* pmedium) 1322 1323 { 1323 1324 IDataObject* cacheDataObject = NULL; … … 1328 1329 TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium); 1329 1330 1330 hres = IUnknown_QueryInterface(this->dataCache, 1331 &IID_IDataObject,1332 (void**)&cacheDataObject);1331 hres = IUnknown_QueryInterface(this->dataCache, 1332 &IID_IDataObject, 1333 (void**)&cacheDataObject); 1333 1334 1334 1335 if (FAILED(hres)) … … 1336 1337 1337 1338 hres = IDataObject_GetData(cacheDataObject, 1338 pformatetcIn,1339 pmedium);1340 1339 pformatetcIn, 1340 pmedium); 1341 1341 1342 IDataObject_Release(cacheDataObject); 1342 1343 1343 1344 return hres; 1344 1345 } 1345 1346 1346 1347 static HRESULT WINAPI DefaultHandler_GetDataHere( 1347 IDataObject* iface, 1348 LPFORMATETC pformatetc,1349 STGMEDIUM* pmedium)1348 IDataObject* iface, 1349 LPFORMATETC pformatetc, 1350 STGMEDIUM* pmedium) 1350 1351 { 1351 1352 FIXME(": Stub\n"); … … 1356 1357 * DefaultHandler_QueryGetData (IDataObject) 1357 1358 * 1358 * The default handler's implementation of this method delegates to 1359 * The default handler's implementation of this method delegates to 1359 1360 * the cache. 1360 1361 * … … 1362 1363 */ 1363 1364 static HRESULT WINAPI DefaultHandler_QueryGetData( 1364 IDataObject* iface,1365 LPFORMATETC pformatetc)1365 IDataObject* iface, 1366 LPFORMATETC pformatetc) 1366 1367 { 1367 1368 IDataObject* cacheDataObject = NULL; … … 1372 1373 TRACE("(%p, %p)\n", iface, pformatetc); 1373 1374 1374 hres = IUnknown_QueryInterface(this->dataCache, 1375 &IID_IDataObject,1376 (void**)&cacheDataObject);1375 hres = IUnknown_QueryInterface(this->dataCache, 1376 &IID_IDataObject, 1377 (void**)&cacheDataObject); 1377 1378 1378 1379 if (FAILED(hres)) … … 1380 1381 1381 1382 hres = IDataObject_QueryGetData(cacheDataObject, 1382 pformatetc);1383 pformatetc); 1383 1384 1384 1385 IDataObject_Release(cacheDataObject); 1385 1386 1386 1387 return hres; 1387 1388 } … … 1395 1396 */ 1396 1397 static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc( 1397 IDataObject* iface, 1398 LPFORMATETC pformatectIn, 1399 LPFORMATETC pformatetcOut)1398 IDataObject* iface, 1399 LPFORMATETC pformatectIn, 1400 LPFORMATETC pformatetcOut) 1400 1401 { 1401 1402 FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut); … … 1407 1408 * DefaultHandler_SetData (IDataObject) 1408 1409 * 1409 * The default handler's implementation of this method delegates to 1410 * The default handler's implementation of this method delegates to 1410 1411 * the cache. 1411 1412 * … … 1413 1414 */ 1414 1415 static HRESULT WINAPI DefaultHandler_SetData( 1415 IDataObject* iface,1416 LPFORMATETC pformatetc, 1417 STGMEDIUM* pmedium, 1418 BOOL fRelease)1416 IDataObject* iface, 1417 LPFORMATETC pformatetc, 1418 STGMEDIUM* pmedium, 1419 BOOL fRelease) 1419 1420 { 1420 1421 IDataObject* cacheDataObject = NULL; … … 1425 1426 TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease); 1426 1427 1427 hres = IUnknown_QueryInterface(this->dataCache, 1428 &IID_IDataObject,1429 (void**)&cacheDataObject);1428 hres = IUnknown_QueryInterface(this->dataCache, 1429 &IID_IDataObject, 1430 (void**)&cacheDataObject); 1430 1431 1431 1432 if (FAILED(hres)) … … 1433 1434 1434 1435 hres = IDataObject_SetData(cacheDataObject, 1435 pformatetc,1436 pmedium,1437 fRelease);1438 1436 pformatetc, 1437 pmedium, 1438 fRelease); 1439 1439 1440 IDataObject_Release(cacheDataObject); 1440 1441 1441 1442 return hres; 1442 1443 } … … 1451 1452 */ 1452 1453 static HRESULT WINAPI DefaultHandler_EnumFormatEtc( 1453 IDataObject* iface, 1454 DWORD dwDirection,1455 IEnumFORMATETC** ppenumFormatEtc)1454 IDataObject* iface, 1455 DWORD dwDirection, 1456 IEnumFORMATETC** ppenumFormatEtc) 1456 1457 { 1457 1458 HRESULT hres; … … 1474 1475 */ 1475 1476 static HRESULT WINAPI DefaultHandler_DAdvise( 1476 IDataObject* iface, 1477 FORMATETC* pformatetc, 1478 DWORD advf, 1479 IAdviseSink* pAdvSink, 1480 DWORD* pdwConnection)1477 IDataObject* iface, 1478 FORMATETC* pformatetc, 1479 DWORD advf, 1480 IAdviseSink* pAdvSink, 1481 DWORD* pdwConnection) 1481 1482 { 1482 1483 HRESULT hres = S_OK; 1483 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1484 1485 TRACE("(%p, %p, %ld, %p, %p)\n", 1486 iface, pformatetc, advf, pAdvSink, pdwConnection);1484 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1485 1486 TRACE("(%p, %p, %ld, %p, %p)\n", 1487 iface, pformatetc, advf, pAdvSink, pdwConnection); 1487 1488 1488 1489 /* … … 1496 1497 if (SUCCEEDED(hres)) 1497 1498 { 1498 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 1499 iface,1500 pformatetc, 1501 advf, 1502 pAdvSink, 1503 pdwConnection);1499 hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 1500 iface, 1501 pformatetc, 1502 advf, 1503 pAdvSink, 1504 pdwConnection); 1504 1505 } 1505 1506 … … 1516 1517 */ 1517 1518 static HRESULT WINAPI DefaultHandler_DUnadvise( 1518 IDataObject* iface,1519 DWORD dwConnection)1520 { 1521 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1519 IDataObject* iface, 1520 DWORD dwConnection) 1521 { 1522 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1522 1523 1523 1524 TRACE("(%p, %ld)\n", iface, dwConnection); … … 1532 1533 } 1533 1534 1534 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 1535 dwConnection);1535 return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 1536 dwConnection); 1536 1537 } 1537 1538 … … 1545 1546 */ 1546 1547 static HRESULT WINAPI DefaultHandler_EnumDAdvise( 1547 IDataObject* iface,1548 IEnumSTATDATA** ppenumAdvise)1549 { 1550 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1548 IDataObject* iface, 1549 IEnumSTATDATA** ppenumAdvise) 1550 { 1551 _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 1551 1552 1552 1553 TRACE("(%p, %p)\n", iface, ppenumAdvise); … … 1568 1569 if (this->dataAdviseHolder!=NULL) 1569 1570 { 1570 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 1571 ppenumAdvise);1571 return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 1572 ppenumAdvise); 1572 1573 } 1573 1574 … … 1576 1577 1577 1578 /********************************************************* 1578 * Methods implementation for the IRunnableObject part 1579 * Methods implementation for the IRunnableObject part 1579 1580 * of the DefaultHandler class. 1580 1581 */ … … 1592 1593 _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface); 1593 1594 1594 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1595 return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 1595 1596 } 1596 1597 … … 1600 1601 * See Windows documentation for more details on IUnknown methods. 1601 1602 */ 1602 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 1603 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 1603 1604 IRunnableObject* iface) 1604 1605 { … … 1613 1614 * See Windows documentation for more details on IUnknown methods. 1614 1615 */ 1615 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 1616 static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 1616 1617 IRunnableObject* iface) 1617 1618 { … … 1624 1625 * DefaultHandler_GetRunningClass (IRunnableObject) 1625 1626 * 1626 * According to Brockscmidt, Chapter 19, the default handler's 1627 * According to Brockscmidt, Chapter 19, the default handler's 1627 1628 * implementation of IRunnableobject does nothing until the object 1628 1629 * is actually running. … … 1630 1631 * See Windows documentation for more details on IRunnableObject methods. 1631 1632 */ 1632 static HRESULT WINAPI DefaultHandler_GetRunningClass( 1633 IRunnableObject* iface, 1634 LPCLSID lpClsid)1633 static HRESULT WINAPI DefaultHandler_GetRunningClass( 1634 IRunnableObject* iface, 1635 LPCLSID lpClsid) 1635 1636 { 1636 1637 TRACE("()\n"); … … 1638 1639 } 1639 1640 1640 static HRESULT WINAPI DefaultHandler_Run( 1641 static HRESULT WINAPI DefaultHandler_Run( 1641 1642 IRunnableObject* iface, 1642 IBindCtx* pbc)1643 IBindCtx* pbc) 1643 1644 { 1644 1645 FIXME(": Stub\n"); … … 1649 1650 * DefaultHandler_IsRunning (IRunnableObject) 1650 1651 * 1651 * According to Brockscmidt, Chapter 19, the default handler's 1652 * According to Brockscmidt, Chapter 19, the default handler's 1652 1653 * implementation of IRunnableobject does nothing until the object 1653 1654 * is actually running. … … 1655 1656 * See Windows documentation for more details on IRunnableObject methods. 1656 1657 */ 1657 static BOOL WINAPI DefaultHandler_IsRunning( 1658 static BOOL WINAPI DefaultHandler_IsRunning( 1658 1659 IRunnableObject* iface) 1659 1660 { … … 1665 1666 * DefaultHandler_LockRunning (IRunnableObject) 1666 1667 * 1667 * According to Brockscmidt, Chapter 19, the default handler's 1668 * According to Brockscmidt, Chapter 19, the default handler's 1668 1669 * implementation of IRunnableobject does nothing until the object 1669 1670 * is actually running. … … 1671 1672 * See Windows documentation for more details on IRunnableObject methods. 1672 1673 */ 1673 static HRESULT WINAPI DefaultHandler_LockRunning( 1674 IRunnableObject* iface, 1675 BOOL fLock, 1676 BOOL fLastUnlockCloses)1674 static HRESULT WINAPI DefaultHandler_LockRunning( 1675 IRunnableObject* iface, 1676 BOOL fLock, 1677 BOOL fLastUnlockCloses) 1677 1678 { 1678 1679 TRACE("()\n"); … … 1683 1684 * DefaultHandler_SetContainedObject (IRunnableObject) 1684 1685 * 1685 * According to Brockscmidt, Chapter 19, the default handler's 1686 * According to Brockscmidt, Chapter 19, the default handler's 1686 1687 * implementation of IRunnableobject does nothing until the object 1687 1688 * is actually running. … … 1689 1690 * See Windows documentation for more details on IRunnableObject methods. 1690 1691 */ 1691 static HRESULT WINAPI DefaultHandler_SetContainedObject( 1692 IRunnableObject* iface, 1693 BOOL fContained)1692 static HRESULT WINAPI DefaultHandler_SetContainedObject( 1693 IRunnableObject* iface, 1694 BOOL fContained) 1694 1695 { 1695 1696 TRACE("()\n"); -
trunk/src/ole32/errorinfo.c
r5602 r6648 1 /* $Id: errorinfo.c,v 1.3 2001-09-05 13:17:09 bird Exp $ */ 1 2 /* 2 3 * ErrorInfo API … … 5 6 * 6 7 * 7 * The errorinfo is a per-thread object. The reference is stored in the 8 * The errorinfo is a per-thread object. The reference is stored in the 8 9 * TEB at offset 0xf80 9 10 */ … … 30 31 WCHAR* stringBuffer; 31 32 DWORD len; 32 33 33 34 if (in == NULL) 34 return NULL;35 return NULL; 35 36 /* 36 37 * Find the lenth of the buffer passed-in in bytes. … … 89 90 { 90 91 DWORD* bufferPointer; 91 92 92 93 /* NULL is a valid parameter */ 93 94 if(!in) return; … … 111 112 typedef struct ErrorInfoImpl 112 113 { 113 ICOM_VTABLE(IErrorInfo)*lpvtei;114 ICOM_VTABLE(ICreateErrorInfo)*lpvtcei;115 ICOM_VTABLE(ISupportErrorInfo)*lpvtsei;116 DWORDref;117 118 GUID m_Guid;119 BSTR bstrSource;120 BSTR bstrDescription;121 BSTR bstrHelpFile;122 DWORD m_dwHelpContext;114 ICOM_VTABLE(IErrorInfo) *lpvtei; 115 ICOM_VTABLE(ICreateErrorInfo) *lpvtcei; 116 ICOM_VTABLE(ISupportErrorInfo) *lpvtsei; 117 DWORD ref; 118 119 GUID m_Guid; 120 BSTR bstrSource; 121 BSTR bstrDescription; 122 BSTR bstrHelpFile; 123 DWORD m_dwHelpContext; 123 124 } ErrorInfoImpl; 124 125 125 static ICOM_VTABLE(IErrorInfo) IErrorInfoImpl_VTable;126 static ICOM_VTABLE(ICreateErrorInfo) ICreateErrorInfoImpl_VTable;127 static ICOM_VTABLE(ISupportErrorInfo) ISupportErrorInfoImpl_VTable;126 static ICOM_VTABLE(IErrorInfo) IErrorInfoImpl_VTable; 127 static ICOM_VTABLE(ICreateErrorInfo) ICreateErrorInfoImpl_VTable; 128 static ICOM_VTABLE(ISupportErrorInfo) ISupportErrorInfoImpl_VTable; 128 129 129 130 /* 130 131 converts a objectpointer to This 131 132 */ 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); 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); 140 141 141 142 /* 142 143 converts This to a objectpointer 143 144 */ 144 #define _IErrorInfo_(This) (IErrorInfo*)&(This->lpvtei)145 #define _ICreateErrorInfo_(This) (ICreateErrorInfo*)&(This->lpvtcei)146 #define _ISupportErrorInfo_(This) (ISupportErrorInfo*)&(This->lpvtsei)145 #define _IErrorInfo_(This) (IErrorInfo*)&(This->lpvtei) 146 #define _ICreateErrorInfo_(This) (ICreateErrorInfo*)&(This->lpvtcei) 147 #define _ISupportErrorInfo_(This) (ISupportErrorInfo*)&(This->lpvtsei) 147 148 148 149 IErrorInfo * IErrorInfoImpl_Constructor() 149 150 { 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;151 ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl)); 152 if (ei) 153 { 154 ei->lpvtei = &IErrorInfoImpl_VTable; 155 ei->lpvtcei = &ICreateErrorInfoImpl_VTable; 156 ei->lpvtsei = &ISupportErrorInfoImpl_VTable; 157 ei->ref = 1; 158 ei->bstrSource = NULL; 159 ei->bstrDescription = NULL; 160 ei->bstrHelpFile = NULL; 161 ei->m_dwHelpContext = 0; 162 } 163 return (IErrorInfo *)ei; 163 164 } 164 165 165 166 166 167 static HRESULT WINAPI IErrorInfoImpl_QueryInterface( 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;168 IErrorInfo* iface, 169 REFIID riid, 170 VOID** ppvoid) 171 { 172 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 173 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid); 174 175 *ppvoid = NULL; 176 177 if(IsEqualIID(riid, &IID_IErrorInfo)) 178 { 179 *ppvoid = _IErrorInfo_(This); 180 } 181 else if(IsEqualIID(riid, &IID_ICreateErrorInfo)) 182 { 183 *ppvoid = _ICreateErrorInfo_(This); 184 } 185 else if(IsEqualIID(riid, &IID_ISupportErrorInfo)) 186 { 187 *ppvoid = _ISupportErrorInfo_(This); 188 } 189 190 if(*ppvoid) 191 { 192 IUnknown_AddRef( (IUnknown*)*ppvoid ); 193 TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid); 194 return S_OK; 195 } 196 TRACE("-- Interface: E_NOINTERFACE\n"); 197 return E_NOINTERFACE; 197 198 } 198 199 199 200 static ULONG WINAPI IErrorInfoImpl_AddRef( 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);201 IErrorInfo* iface) 202 { 203 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 204 TRACE("(%p)->(count=%lu)\n",This,This->ref); 205 return InterlockedIncrement(&This->ref); 205 206 } 206 207 207 208 static ULONG WINAPI IErrorInfoImpl_Release( 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;209 IErrorInfo* iface) 210 { 211 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 212 TRACE("(%p)->(count=%lu)\n",This,This->ref); 213 214 if (!InterlockedDecrement(&This->ref)) 215 { 216 TRACE("-- destroying IErrorInfo(%p)\n",This); 217 HeapFree(GetProcessHeap(),0,This); 218 return 0; 219 } 220 return This->ref; 220 221 } 221 222 222 223 static HRESULT WINAPI IErrorInfoImpl_GetGUID( 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;224 IErrorInfo* iface, 225 GUID * pGUID) 226 { 227 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 228 TRACE("(%p)->(count=%lu)\n",This,This->ref); 229 if(!pGUID )return E_INVALIDARG; 230 memcpy(pGUID, &This->m_Guid, sizeof(GUID)); 231 return S_OK; 231 232 } 232 233 233 234 static HRESULT WINAPI IErrorInfoImpl_GetSource( 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;235 IErrorInfo* iface, 236 BSTR *pBstrSource) 237 { 238 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 239 TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource); 240 if (pBstrSource == NULL) 241 return E_INVALIDARG; 242 *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource); 243 return S_OK; 243 244 } 244 245 245 246 static HRESULT WINAPI IErrorInfoImpl_GetDescription( 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;247 IErrorInfo* iface, 248 BSTR *pBstrDescription) 249 { 250 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 251 252 TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription); 253 if (pBstrDescription == NULL) 254 return E_INVALIDARG; 255 *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription); 256 257 return S_OK; 257 258 } 258 259 259 260 static HRESULT WINAPI IErrorInfoImpl_GetHelpFile( 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;261 IErrorInfo* iface, 262 BSTR *pBstrHelpFile) 263 { 264 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 265 266 TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile); 267 if (pBstrHelpFile == NULL) 268 return E_INVALIDARG; 269 *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile); 270 271 return S_OK; 271 272 } 272 273 273 274 static HRESULT WINAPI IErrorInfoImpl_GetHelpContext( 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;275 IErrorInfo* iface, 276 DWORD *pdwHelpContext) 277 { 278 _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface); 279 TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext); 280 if (pdwHelpContext == NULL) 281 return E_INVALIDARG; 282 *pdwHelpContext = This->m_dwHelpContext; 283 284 return S_OK; 284 285 } 285 286 … … 290 291 IErrorInfoImpl_AddRef, 291 292 IErrorInfoImpl_Release, 292 293 293 294 IErrorInfoImpl_GetGUID, 294 295 IErrorInfoImpl_GetSource, … … 300 301 301 302 static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface( 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);303 ICreateErrorInfo* iface, 304 REFIID riid, 305 VOID** ppvoid) 306 { 307 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 308 TRACE("(%p)\n", This); 309 return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid); 309 310 } 310 311 311 312 static ULONG WINAPI ICreateErrorInfoImpl_AddRef( 312 ICreateErrorInfo* iface)313 { 314 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);315 TRACE("(%p)\n", This);316 return IErrorInfo_AddRef(_IErrorInfo_(This));313 ICreateErrorInfo* iface) 314 { 315 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 316 TRACE("(%p)\n", This); 317 return IErrorInfo_AddRef(_IErrorInfo_(This)); 317 318 } 318 319 319 320 static ULONG WINAPI ICreateErrorInfoImpl_Release( 320 ICreateErrorInfo* iface)321 { 322 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);323 TRACE("(%p)\n", This);324 return IErrorInfo_Release(_IErrorInfo_(This));321 ICreateErrorInfo* iface) 322 { 323 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 324 TRACE("(%p)\n", This); 325 return IErrorInfo_Release(_IErrorInfo_(This)); 325 326 } 326 327 327 328 328 329 static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID( 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;330 ICreateErrorInfo* iface, 331 REFGUID rguid) 332 { 333 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 334 TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid)); 335 memcpy(&This->m_Guid, rguid, sizeof(GUID)); 336 return S_OK; 336 337 } 337 338 338 339 static HRESULT WINAPI ICreateErrorInfoImpl_SetSource( 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;340 ICreateErrorInfo* iface, 341 LPOLESTR szSource) 342 { 343 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 344 TRACE("(%p)\n",This); 345 if (This->bstrSource != NULL) 346 ERRORINFO_SysFreeString(This->bstrSource); 347 This->bstrSource = ERRORINFO_SysAllocString(szSource); 348 349 return S_OK; 349 350 } 350 351 351 352 static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription( 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;353 ICreateErrorInfo* iface, 354 LPOLESTR szDescription) 355 { 356 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 357 TRACE("(%p)\n",This); 358 if (This->bstrDescription != NULL) 359 ERRORINFO_SysFreeString(This->bstrDescription); 360 This->bstrDescription = ERRORINFO_SysAllocString(szDescription); 361 362 return S_OK; 362 363 } 363 364 364 365 static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile( 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;366 ICreateErrorInfo* iface, 367 LPOLESTR szHelpFile) 368 { 369 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 370 TRACE("(%p)\n",This); 371 if (This->bstrHelpFile != NULL) 372 ERRORINFO_SysFreeString(This->bstrHelpFile); 373 This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile); 374 375 return S_OK; 375 376 } 376 377 377 378 static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext( 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;379 ICreateErrorInfo* iface, 380 DWORD dwHelpContext) 381 { 382 _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface); 383 TRACE("(%p)\n",This); 384 This->m_dwHelpContext = dwHelpContext; 385 386 return S_OK; 386 387 } 387 388 … … 401 402 402 403 static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface( 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);404 ISupportErrorInfo* iface, 405 REFIID riid, 406 VOID** ppvoid) 407 { 408 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 409 TRACE("(%p)\n", This); 410 411 return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid); 411 412 } 412 413 413 414 static ULONG WINAPI ISupportErrorInfoImpl_AddRef( 414 ISupportErrorInfo* iface)415 { 416 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);417 TRACE("(%p)\n", This);418 return IErrorInfo_AddRef(_IErrorInfo_(This));415 ISupportErrorInfo* iface) 416 { 417 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 418 TRACE("(%p)\n", This); 419 return IErrorInfo_AddRef(_IErrorInfo_(This)); 419 420 } 420 421 421 422 static ULONG WINAPI ISupportErrorInfoImpl_Release( 422 ISupportErrorInfo* iface)423 { 424 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);425 TRACE("(%p)\n", This);426 return IErrorInfo_Release(_IErrorInfo_(This));423 ISupportErrorInfo* iface) 424 { 425 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 426 TRACE("(%p)\n", This); 427 return IErrorInfo_Release(_IErrorInfo_(This)); 427 428 } 428 429 429 430 430 431 static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo( 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;432 ISupportErrorInfo* iface, 433 REFIID riid) 434 { 435 _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface); 436 TRACE("(%p)->(%s)\n", This, debugstr_guid(riid)); 437 return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE; 437 438 } 438 439 … … 448 449 }; 449 450 /*********************************************************************** 450 * CreateErrorInfo451 * CreateErrorInfo 451 452 */ 452 453 HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo) 453 454 { 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;455 IErrorInfo * pei; 456 HRESULT res; 457 TRACE("(%p): stub:\n", pperrinfo); 458 if(! pperrinfo ) return E_INVALIDARG; 459 if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY; 460 461 res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo); 462 IErrorInfo_Release(pei); 463 return res; 463 464 } 464 465 465 466 /*********************************************************************** 466 * GetErrorInfo467 * GetErrorInfo 467 468 */ 468 469 HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo) 469 470 { 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;471 TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo); 472 473 if(! pperrinfo ) return E_INVALIDARG; 474 if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE; 475 476 /* clear thread error state */ 477 NtCurrentTeb()->ErrorInfo = NULL; 478 return S_OK; 478 479 } 479 480 480 481 /*********************************************************************** 481 * SetErrorInfo482 * SetErrorInfo 482 483 */ 483 484 HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo) 484 485 { 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 } 486 IErrorInfo * pei; 487 TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo); 488 489 /* release old errorinfo */ 490 pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo; 491 if(pei) IErrorInfo_Release(pei); 492 493 /* set to new value */ 494 NtCurrentTeb()->ErrorInfo = perrinfo; 495 if(perrinfo) IErrorInfo_AddRef(perrinfo); 496 return S_OK; 497 } -
trunk/src/ole32/filemoniker.c
r5602 r6648 1 /* $Id: filemoniker.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */ 1 2 /*************************************************************************************** 2 * FileMonikers implementation3 * FileMonikers implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 26 27 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 27 28 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 30 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 30 31 */ … … 136 137 { 137 138 ICOM_THIS(FileMonikerImpl,iface); 138 139 139 140 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 140 141 141 142 /* Perform a sanity check on the parameters.*/ 142 143 if ( (This==0) || (ppvObject==0) ) 143 return E_INVALIDARG;144 144 return E_INVALIDARG; 145 145 146 /* Initialize the return parameter */ 146 147 *ppvObject = 0; … … 153 154 ) 154 155 *ppvObject = iface; 155 156 156 157 else if (IsEqualIID(&IID_IROTData, riid)) 157 158 *ppvObject = (IROTData*)&(This->lpvtbl2); … … 160 161 if ((*ppvObject)==0) 161 162 return E_NOINTERFACE; 162 163 163 164 /* Query Interface always increases the reference count by one when it is successful */ 164 165 FileMonikerImpl_AddRef(iface); … … 212 213 213 214 *pClassID = CLSID_FileMoniker; 214 215 215 216 return S_OK; 216 217 } … … 252 253 if (bread!=sizeof(WORD) || wbuffer!=0) 253 254 return E_FAIL; 254 255 255 256 /* read filePath string length (plus one) */ 256 257 res=IStream_Read(pStm,&length,sizeof(DWORD),&bread); … … 268 269 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF) 269 270 return E_FAIL; 270 271 271 272 length--; 272 273 273 274 for(i=0;i<10;i++){ 274 275 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread); … … 276 277 return E_FAIL; 277 278 } 278 279 279 280 if (length>8) 280 281 length=0; 281 282 282 283 doubleLenHex=doubleLenDec=2*length; 283 284 if (length > 5) … … 290 291 if (length==0) 291 292 return res; 292 293 293 294 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread); 294 295 if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex) … … 311 312 312 313 HeapFree(GetProcessHeap(),0,filePathA); 313 314 314 315 return res; 315 316 } … … 324 325 /* this function saves data of this object. In the begining I thougth that I have just to write 325 326 * the filePath string on Stream. But, when I tested this function whith windows programs samples ! 326 * I noted that it was not the case. So I analysed data written by this function on Windows system and 327 * I noted that it was not the case. So I analysed data written by this function on Windows system and 327 328 * what did this function do exactly ! but I have no idear a bout its logic ! 328 329 * I guessed data who must be written on stream wich is: … … 333 334 */ 334 335 335 ICOM_THIS(FileMonikerImpl,iface); 336 ICOM_THIS(FileMonikerImpl,iface); 336 337 337 338 HRESULT res; … … 368 369 /* write a DWORD set to 0xDEADFFFF: constant */ 369 370 res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL); 370 371 371 372 len--; 372 373 /* write 10 times a DWORD set to 0 : constants */ 373 374 for(i=0;i<10;i++) 374 375 res=IStream_Write(pStm,&zero,sizeof(WORD),NULL); 375 376 376 377 if (len>8) 377 378 len=0; 378 379 379 380 doubleLenHex=doubleLenDec=2*len; 380 381 if (len > 5) … … 415 416 416 417 /* for more details see FileMonikerImpl_Save coments */ 417 418 418 419 sizeMAx = sizeof(WORD) + /* first WORD is 0 */ 419 420 sizeof(DWORD)+ /* length of filePath including "\0" in the end of the string */ … … 425 426 if (len==0 || len > 8) 426 427 return S_OK; 427 428 428 429 sizeMAx += sizeof(DWORD)+ /* size of the unicode filePath: "\0" not included */ 429 430 sizeof(WORD)+ /* constant : 0x3 */ 430 431 len*sizeof(WCHAR); /* unicde filePath string */ 431 432 432 433 pcbSize->s.LowPart=sizeMAx; 433 434 pcbSize->s.HighPart=0; … … 447 448 WCHAR bkSlash[]={'\\',0}; 448 449 BYTE addBkSlash; 449 450 450 451 TRACE("(%p,%p)\n",This,lpszPathName); 451 452 … … 492 493 493 494 *This->filePathName=0; 494 495 495 496 for(i=0;tabStr[i]!=NULL;i++) 496 497 strcatW(This->filePathName,tabStr[i]); 497 498 498 499 if (addBkSlash) 499 500 strcatW(This->filePathName,bkSlash); … … 538 539 IClassFactory *pcf=0; 539 540 IClassActivator *pca=0; 540 541 ICOM_THIS(FileMonikerImpl,iface); 541 542 ICOM_THIS(FileMonikerImpl,iface); 542 543 543 544 *ppvResult=0; … … 546 547 547 548 if(pmkToLeft==NULL){ 548 549 549 550 res=IBindCtx_GetRunningObjectTable(pbc,&prot); 550 551 … … 578 579 579 580 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca); 580 581 581 582 if (res==E_NOINTERFACE) 582 583 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED; … … 597 598 598 599 FIXME("()"); 599 600 600 601 /*res=GetClassFile(This->filePathName,&clsID); 601 602 … … 633 634 if (pcf!=NULL) 634 635 IClassFactory_Release(pcf); 635 636 636 637 return res; 637 638 } … … 736 737 737 738 if (pmkRight==NULL) 738 return E_INVALIDARG;739 return E_INVALIDARG; 739 740 740 741 *ppmkComposite=0; 741 742 742 743 IMoniker_IsSystemMoniker(pmkRight,&mkSys); 743 744 … … 768 769 /* the length of the composed path string is raised by the sum of the two paths lengths */ 769 770 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); 770 771 if (newStr==NULL)772 return E_OUTOFMEMORY;771 772 if (newStr==NULL) 773 return E_OUTOFMEMORY; 773 774 774 775 /* new path is the concatenation of the rest of str1 and str2 */ … … 778 779 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) 779 780 strcatW(newStr,bkSlash); 780 781 781 782 for(j=i;j<=lastIdx2;j++) 782 783 strcatW(newStr,strDec2[j]); 783 784 784 785 /* create a new moniker with the new string */ 785 786 res=CreateFileMoniker(newStr,ppmkComposite); … … 857 858 858 859 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath); 859 860 860 861 if (lstrcmpiW(filePath, 861 862 This->filePathName)!=0) 862 863 863 864 return S_FALSE; 864 865 865 866 return S_OK; 866 867 } … … 879 880 if (pdwHash==NULL) 880 881 return E_POINTER; 881 882 882 883 val = This->filePathName; 883 884 len = lstrlenW(val); … … 886 887 for (i = len ; i > 0; i--) { 887 888 h = (h * 37) + val[off++]; 888 }889 } 889 890 } else { 890 891 /* only sample some characters */ 891 skip = len / 8;892 for (i = len ; i > 0; i -= skip, off += skip) {892 skip = len / 8; 893 for (i = len ; i > 0; i -= skip, off += skip) { 893 894 h = (h * 39) + val[off]; 894 }895 } 895 896 } 896 897 … … 963 964 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info)) 964 965 return MK_E_NOOBJECT; 965 966 966 967 *pFileTime=info.ftLastWriteTime; 967 968 } … … 998 999 if (pmkOther==NULL) 999 1000 return E_INVALIDARG; 1000 1001 1001 1002 *ppmkPrefix=0; 1002 1003 1003 1004 /* check if we have the same type of moniker */ 1004 1005 IMoniker_IsSystemMoniker(pmkOther,&mkSys); … … 1022 1023 1023 1024 *commonPath=0; 1024 1025 1025 1026 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) && 1026 1027 (stringTable2[sameIdx]!=NULL) && … … 1041 1042 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\') 1042 1043 sameIdx--; 1043 1044 1044 1045 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) ) 1045 1046 return MK_E_NOPREFIX; … … 1047 1048 for(i=0;i<sameIdx;i++) 1048 1049 strcatW(commonPath,stringTable1[i]); 1049 1050 1050 1051 for(i=0;i<nb1;i++) 1051 1052 CoTaskMemFree(stringTable1[i]); … … 1059 1060 1060 1061 HeapFree(GetProcessHeap(),0,commonPath); 1061 1062 1062 1063 return CreateFileMoniker(commonPath,ppmkPrefix); 1063 1064 } … … 1079 1080 1080 1081 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR)); 1081 1082 1082 1083 if (strgtable==NULL) 1083 return E_OUTOFMEMORY;1084 1084 return E_OUTOFMEMORY; 1085 1085 1086 while(str[i]!=0){ 1086 1087 … … 1090 1091 1091 1092 if (strgtable[tabIndex]==NULL) 1092 return E_OUTOFMEMORY;1093 return E_OUTOFMEMORY; 1093 1094 1094 1095 strcpyW(strgtable[tabIndex++],bSlash); … … 1113 1114 } 1114 1115 strgtable[tabIndex]=NULL; 1115 1116 1116 1117 *stringTable=strgtable; 1117 1118 1118 1119 return tabIndex; 1119 1120 } … … 1129 1130 DWORD len1=0,len2=0,sameIdx=0,j=0; 1130 1131 WCHAR back[] ={'.','.','\\',0}; 1131 1132 1132 1133 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); 1133 1134 … … 1137 1138 if (pmOther==NULL) 1138 1139 return E_INVALIDARG; 1139 1140 1140 1141 res=CreateBindCtx(0,&bind); 1141 1142 if (FAILED(res)) 1142 return res;1143 return res; 1143 1144 1144 1145 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1); 1145 1146 if (FAILED(res)) 1146 return res;1147 return res; 1147 1148 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2); 1148 1149 if (FAILED(res)) 1149 return res;1150 return res; 1150 1151 1151 1152 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1); … … 1153 1154 1154 1155 if (FAILED(len1) || FAILED(len2)) 1155 return E_OUTOFMEMORY;1156 1156 return E_OUTOFMEMORY; 1157 1157 1158 /* count the number of similar items from the begin of the two paths */ 1158 1159 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) && 1159 (tabStr2[sameIdx]!=NULL) &&1160 (tabStr2[sameIdx]!=NULL) && 1160 1161 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++); 1161 1162 … … 1175 1176 for(j=sameIdx;tabStr2[j]!=NULL;j++) 1176 1177 strcatW(relPath,tabStr2[j]); 1177 1178 1178 1179 res=CreateFileMoniker(relPath,ppmkRelPath); 1179 1180 1180 1181 for(j=0; tabStr1[j]!=NULL;j++) 1181 1182 CoTaskMemFree(tabStr1[j]); … … 1219 1220 1220 1221 strcpyW(*ppszDisplayName,This->filePathName); 1221 1222 1222 1223 return S_OK; 1223 1224 } … … 1246 1247 if (!pwdMksys) 1247 1248 return E_POINTER; 1248 1249 1249 1250 (*pwdMksys)=MKSYS_FILEMONIKER; 1250 1251 … … 1283 1284 { 1284 1285 ICOM_THIS_From_IROTData(IMoniker, iface); 1285 1286 1286 1287 TRACE("(%p)\n",This); 1287 1288 … … 1327 1328 if(lpszPathName==NULL) 1328 1329 return MK_E_SYNTAX; 1329 1330 1330 1331 *ppmk=0; 1331 1332 1332 1333 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl)); 1333 1334 … … 1338 1339 1339 1340 if (SUCCEEDED(hr)) 1340 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);1341 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk); 1341 1342 else 1342 1343 HeapFree(GetProcessHeap(),0,newFileMoniker); -
trunk/src/ole32/hglobalstream.c
r5602 r6648 1 /* $Id: hglobalstream.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */ 1 2 /* 2 3 * HGLOBAL Stream implementation … … 29 30 { 30 31 ICOM_VFIELD(IStream); /* Needs to be the first item in the stuct 31 * since we want to cast this in a IStream pointer */32 32 * since we want to cast this in a IStream pointer */ 33 33 34 /* 34 35 * Reference count 35 36 */ 36 ULONG ref;37 ULONG ref; 37 38 38 39 /* … … 64 65 */ 65 66 HGLOBALStreamImpl* HGLOBALStreamImpl_Construct( 66 HGLOBAL hGlobal,67 BOOL fDeleteOnRelease);67 HGLOBAL hGlobal, 68 BOOL fDeleteOnRelease); 68 69 69 70 void HGLOBALStreamImpl_Destroy( … … 74 75 75 76 HRESULT WINAPI HGLOBALStreamImpl_QueryInterface( 76 IStream* iface,77 REFIID riid, /* [in] */ 78 void** ppvObject); /* [iid_is][out] */ 79 77 IStream* iface, 78 REFIID riid, /* [in] */ 79 void** ppvObject); /* [iid_is][out] */ 80 80 81 ULONG WINAPI HGLOBALStreamImpl_AddRef( 81 IStream* iface);82 82 IStream* iface); 83 83 84 ULONG WINAPI HGLOBALStreamImpl_Release( 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 85 IStream* iface); 86 87 HRESULT WINAPI HGLOBALStreamImpl_Read( 88 IStream* iface, 89 void* pv, /* [length_is][size_is][out] */ 90 ULONG cb, /* [in] */ 91 ULONG* pcbRead); /* [out] */ 92 92 93 HRESULT WINAPI HGLOBALStreamImpl_Write( 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] */ 94 IStream* iface, 95 const void* pv, /* [size_is][in] */ 96 ULONG cb, /* [in] */ 97 ULONG* pcbWritten); /* [out] */ 98 99 HRESULT WINAPI HGLOBALStreamImpl_Seek( 100 IStream* iface, 101 LARGE_INTEGER dlibMove, /* [in] */ 102 DWORD dwOrigin, /* [in] */ 103 ULARGE_INTEGER* plibNewPosition); /* [out] */ 104 105 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 106 IStream* iface, 107 ULARGE_INTEGER libNewSize); /* [in] */ 108 109 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 110 IStream* iface, 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 IStream* iface, 118 DWORD grfCommitFlags); /* [in] */ 119 120 HRESULT WINAPI HGLOBALStreamImpl_Revert( 121 IStream* iface); 122 123 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 124 IStream* iface, 125 ULARGE_INTEGER libOffset, /* [in] */ 126 ULARGE_INTEGER cb, /* [in] */ 127 DWORD dwLockType); /* [in] */ 128 129 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 130 IStream* iface, 131 ULARGE_INTEGER libOffset, /* [in] */ 132 ULARGE_INTEGER cb, /* [in] */ 133 DWORD dwLockType); /* [in] */ 134 135 HRESULT WINAPI HGLOBALStreamImpl_Stat( 136 IStream* iface, 137 STATSTG* pstatstg, /* [out] */ 138 DWORD grfStatFlag); /* [in] */ 139 140 HRESULT WINAPI HGLOBALStreamImpl_Clone( 141 IStream* iface, 142 IStream** ppstm); /* [out] */ 142 143 143 144 … … 168 169 */ 169 170 HRESULT WINAPI CreateStreamOnHGlobal( 170 HGLOBAL hGlobal, 171 BOOL fDeleteOnRelease, 172 LPSTREAM* ppstm)171 HGLOBAL hGlobal, 172 BOOL fDeleteOnRelease, 173 LPSTREAM* ppstm) 173 174 { 174 175 HGLOBALStreamImpl* newStream; 175 176 176 177 newStream = HGLOBALStreamImpl_Construct(hGlobal, 177 fDeleteOnRelease);178 fDeleteOnRelease); 178 179 179 180 if (newStream!=NULL) 180 181 { 181 return IUnknown_QueryInterface((IUnknown*)newStream, 182 &IID_IStream,183 (void**)ppstm);182 return IUnknown_QueryInterface((IUnknown*)newStream, 183 &IID_IStream, 184 (void**)ppstm); 184 185 } 185 186 … … 222 223 * Params: 223 224 * hGlobal - Handle that will support the stream. can be NULL. 224 * fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 225 * fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 225 226 * when the IStream object is destroyed. 226 227 */ 227 228 HGLOBALStreamImpl* HGLOBALStreamImpl_Construct( 228 HGLOBAL hGlobal,229 BOOL fDeleteOnRelease)229 HGLOBAL hGlobal, 230 BOOL fDeleteOnRelease) 230 231 { 231 232 HGLOBALStreamImpl* newStream; 232 233 233 234 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl)); 234 235 235 236 if (newStream!=0) 236 237 { … … 240 241 ICOM_VTBL(newStream) = &HGLOBALStreamImpl_Vtbl; 241 242 newStream->ref = 0; 242 243 243 244 /* 244 245 * Initialize the support. … … 253 254 { 254 255 newStream->supportHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD | 255 GMEM_SHARE, 0);256 GMEM_SHARE, 0); 256 257 } 257 258 258 259 /* 259 260 * Start the stream at the begining. … … 261 262 newStream->currentPosition.s.HighPart = 0; 262 263 newStream->currentPosition.s.LowPart = 0; 263 264 264 265 /* 265 266 * Initialize the size of the stream to the size of the handle. … … 268 269 newStream->streamSize.s.LowPart = GlobalSize(newStream->supportHandle); 269 270 } 270 271 271 272 return newStream; 272 273 } … … 275 276 * This is the destructor of the HGLOBALStreamImpl class. 276 277 * 277 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 278 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 278 279 * class. The pointer passed-in to this function will be freed and will not 279 280 * be valid anymore. … … 295 296 * Finally, free the memory used-up by the class. 296 297 */ 297 HeapFree(GetProcessHeap(), 0, This); 298 HeapFree(GetProcessHeap(), 0, This); 298 299 } 299 300 … … 303 304 */ 304 305 HRESULT WINAPI HGLOBALStreamImpl_QueryInterface( 305 IStream* iface,306 REFIID riid, /* [in] */ 307 void** ppvObject) /* [iid_is][out] */ 306 IStream* iface, 307 REFIID riid, /* [in] */ 308 void** ppvObject) /* [iid_is][out] */ 308 309 { 309 310 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 314 315 if (ppvObject==0) 315 316 return E_INVALIDARG; 316 317 317 318 /* 318 319 * Initialize the return parameter. 319 320 */ 320 321 *ppvObject = 0; 321 322 322 323 /* 323 324 * Compare the riid with the interface IDs implemented by this object. 324 325 */ 325 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 326 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 326 327 { 327 328 *ppvObject = (IStream*)This; 328 329 } 329 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 330 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 330 331 { 331 332 *ppvObject = (IStream*)This; 332 333 } 333 334 334 335 /* 335 336 * Check that we obtained an interface. … … 337 338 if ((*ppvObject)==0) 338 339 return E_NOINTERFACE; 339 340 340 341 /* 341 342 * Query Interface always increases the reference count by one when it is … … 343 344 */ 344 345 HGLOBALStreamImpl_AddRef(iface); 345 346 346 347 return S_OK;; 347 348 } … … 352 353 */ 353 354 ULONG WINAPI HGLOBALStreamImpl_AddRef( 354 IStream* iface)355 IStream* iface) 355 356 { 356 357 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; 357 358 358 359 This->ref++; 359 360 360 361 return This->ref; 361 362 } … … 366 367 */ 367 368 ULONG WINAPI HGLOBALStreamImpl_Release( 368 IStream* iface)369 IStream* iface) 369 370 { 370 371 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; 371 372 372 373 ULONG newRef; 373 374 374 375 This->ref--; 375 376 376 377 newRef = This->ref; 377 378 378 379 /* 379 380 * If the reference count goes down to 0, perform suicide. … … 383 384 HGLOBALStreamImpl_Destroy(This); 384 385 } 385 386 386 387 return newRef; 387 388 } … … 396 397 * See the documentation of ISequentialStream for more info. 397 398 */ 398 HRESULT WINAPI HGLOBALStreamImpl_Read( 399 IStream* iface,400 void* pv, /* [length_is][size_is][out] */401 ULONG cb, /* [in] */ 402 ULONG* pcbRead) /* [out] */ 399 HRESULT WINAPI HGLOBALStreamImpl_Read( 400 IStream* iface, 401 void* pv, /* [length_is][size_is][out] */ 402 ULONG cb, /* [in] */ 403 ULONG* pcbRead) /* [out] */ 403 404 { 404 405 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 409 410 410 411 TRACE("(%p, %p, %ld, %p)\n", iface, 411 pv, cb, pcbRead);412 413 /* 412 pv, cb, pcbRead); 413 414 /* 414 415 * If the caller is not interested in the nubmer of bytes read, 415 416 * we use another buffer to avoid "if" statements in the code. … … 417 418 if (pcbRead==0) 418 419 pcbRead = &bytesReadBuffer; 419 420 420 421 /* 421 422 * Using the known size of the stream, calculate the number of bytes … … 445 446 */ 446 447 GlobalUnlock(This->supportHandle); 447 448 448 449 /* 449 450 * The function returns S_OK if the buffer was filled completely … … 453 454 if(*pcbRead == cb) 454 455 return S_OK; 455 456 456 457 return S_FALSE; 457 458 } 458 459 459 460 /*** 460 461 * This method is part of the ISequentialStream interface. … … 468 469 */ 469 470 HRESULT WINAPI HGLOBALStreamImpl_Write( 470 IStream* iface,471 const void* pv, /* [size_is][in] */ 472 ULONG cb, /* [in] */ 473 ULONG* pcbWritten) /* [out] */ 471 IStream* iface, 472 const void* pv, /* [size_is][in] */ 473 ULONG cb, /* [in] */ 474 ULONG* pcbWritten) /* [out] */ 474 475 { 475 476 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 480 481 481 482 TRACE("(%p, %p, %ld, %p)\n", iface, 482 pv, cb, pcbWritten);483 483 pv, cb, pcbWritten); 484 484 485 /* 485 486 * If the caller is not interested in the number of bytes written, … … 488 489 if (pcbWritten == 0) 489 490 pcbWritten = &bytesWritten; 490 491 491 492 if (cb == 0) 492 493 { … … 498 499 newSize.s.LowPart = This->currentPosition.s.LowPart + cb; 499 500 } 500 501 501 502 /* 502 503 * Verify if we need to grow the stream … … 507 508 IStream_SetSize(iface, newSize); 508 509 } 509 510 510 511 /* 511 512 * Lock the buffer in position and copy the data. … … 513 514 supportBuffer = GlobalLock(This->supportHandle); 514 515 515 memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 516 memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 516 517 517 518 /* … … 529 530 */ 530 531 GlobalUnlock(This->supportHandle); 531 532 532 533 return S_OK; 533 534 } … … 540 541 * 541 542 * See the documentation of IStream for more info. 542 */ 543 HRESULT WINAPI HGLOBALStreamImpl_Seek( 544 IStream* iface,545 LARGE_INTEGER dlibMove, /* [in] */ 546 DWORD dwOrigin, /* [in] */ 547 ULARGE_INTEGER* plibNewPosition) /* [out] */543 */ 544 HRESULT WINAPI HGLOBALStreamImpl_Seek( 545 IStream* iface, 546 LARGE_INTEGER dlibMove, /* [in] */ 547 DWORD dwOrigin, /* [in] */ 548 ULARGE_INTEGER* plibNewPosition) /* [out] */ 548 549 { 549 550 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 552 553 553 554 TRACE("(%p, %ld, %ld, %p)\n", iface, 554 dlibMove.s.LowPart, dwOrigin, plibNewPosition);555 556 /* 555 dlibMove.s.LowPart, dwOrigin, plibNewPosition); 556 557 /* 557 558 * The caller is allowed to pass in NULL as the new position return value. 558 559 * If it happens, we assign it to a dynamic variable to avoid special cases … … 608 609 plibNewPosition->s.LowPart += dlibMove.s.LowPart; 609 610 This->currentPosition = *plibNewPosition; 610 611 611 612 return S_OK; 612 613 } … … 621 622 * See the documentation of IStream for more info. 622 623 */ 623 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 624 IStream* iface,625 ULARGE_INTEGER libNewSize) /* [in] */ 624 HRESULT WINAPI HGLOBALStreamImpl_SetSize( 625 IStream* iface, 626 ULARGE_INTEGER libNewSize) /* [in] */ 626 627 { 627 628 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 634 635 if (libNewSize.s.HighPart != 0) 635 636 return STG_E_INVALIDFUNCTION; 636 637 637 638 if (This->streamSize.s.LowPart == libNewSize.s.LowPart) 638 639 return S_OK; … … 641 642 * Re allocate the HGlobal to fit the new size of the stream. 642 643 */ 643 This->supportHandle = GlobalReAlloc(This->supportHandle, 644 libNewSize.s.LowPart,645 0);644 This->supportHandle = GlobalReAlloc(This->supportHandle, 645 libNewSize.s.LowPart, 646 0); 646 647 647 648 This->streamSize.s.LowPart = libNewSize.s.LowPart; 648 649 649 650 return S_OK; 650 651 } 651 652 652 653 /*** 653 654 * This method is part of the IStream interface. … … 657 658 * See the documentation of IStream for more info. 658 659 */ 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] */ 660 HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 661 IStream* iface, 662 IStream* pstm, /* [unique][in] */ 663 ULARGE_INTEGER cb, /* [in] */ 664 ULARGE_INTEGER* pcbRead, /* [out] */ 665 ULARGE_INTEGER* pcbWritten) /* [out] */ 665 666 { 666 667 HRESULT hr = S_OK; … … 670 671 ULARGE_INTEGER totalBytesWritten; 671 672 672 TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 673 cb.s.LowPart, pcbRead, pcbWritten);673 TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 674 cb.s.LowPart, pcbRead, pcbWritten); 674 675 675 676 /* … … 693 694 else 694 695 copySize = cb.s.LowPart; 695 696 696 697 IStream_Read(iface, tmpBuffer, copySize, &bytesRead); 697 698 698 699 totalBytesRead.s.LowPart += bytesRead; 699 700 700 701 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); 701 702 … … 710 711 break; 711 712 } 712 713 713 714 if (bytesRead!=copySize) 714 715 cb.s.LowPart = 0; … … 737 738 * This method is part of the IStream interface. 738 739 * 739 * For streams supported by HGLOBALS, this function does nothing. 740 * For streams supported by HGLOBALS, this function does nothing. 740 741 * This is what the documentation tells us. 741 742 * 742 743 * See the documentation of IStream for more info. 743 */ 744 HRESULT WINAPI HGLOBALStreamImpl_Commit( 745 IStream* iface,746 DWORD grfCommitFlags) /* [in] */ 744 */ 745 HRESULT WINAPI HGLOBALStreamImpl_Commit( 746 IStream* iface, 747 DWORD grfCommitFlags) /* [in] */ 747 748 { 748 749 return S_OK; … … 752 753 * This method is part of the IStream interface. 753 754 * 754 * For streams supported by HGLOBALS, this function does nothing. 755 * For streams supported by HGLOBALS, this function does nothing. 755 756 * This is what the documentation tells us. 756 757 * 757 758 * See the documentation of IStream for more info. 758 */ 759 HRESULT WINAPI HGLOBALStreamImpl_Revert( 760 IStream* iface)759 */ 760 HRESULT WINAPI HGLOBALStreamImpl_Revert( 761 IStream* iface) 761 762 { 762 763 return S_OK; … … 766 767 * This method is part of the IStream interface. 767 768 * 768 * For streams supported by HGLOBALS, this function does nothing. 769 * For streams supported by HGLOBALS, this function does nothing. 769 770 * This is what the documentation tells us. 770 771 * 771 772 * See the documentation of IStream for more info. 772 */ 773 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 774 IStream* iface,775 ULARGE_INTEGER libOffset, /* [in] */ 776 ULARGE_INTEGER cb, /* [in] */ 777 DWORD dwLockType) /* [in] */ 773 */ 774 HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 775 IStream* iface, 776 ULARGE_INTEGER libOffset, /* [in] */ 777 ULARGE_INTEGER cb, /* [in] */ 778 DWORD dwLockType) /* [in] */ 778 779 { 779 780 return S_OK; … … 783 784 * This method is part of the IStream interface. 784 785 * 785 * For streams supported by HGLOBALS, this function does nothing. 786 * For streams supported by HGLOBALS, this function does nothing. 786 787 * This is what the documentation tells us. 787 788 * 788 789 * See the documentation of IStream for more info. 789 */ 790 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 791 IStream* iface,792 ULARGE_INTEGER libOffset, /* [in] */ 793 ULARGE_INTEGER cb, /* [in] */ 794 DWORD dwLockType) /* [in] */ 790 */ 791 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 792 IStream* iface, 793 ULARGE_INTEGER libOffset, /* [in] */ 794 ULARGE_INTEGER cb, /* [in] */ 795 DWORD dwLockType) /* [in] */ 795 796 { 796 797 return S_OK; … … 804 805 * 805 806 * See the documentation of IStream for more info. 806 */ 807 HRESULT WINAPI HGLOBALStreamImpl_Stat( 808 IStream* iface,809 STATSTG* pstatstg, /* [out] */810 DWORD grfStatFlag) /* [in] */ 807 */ 808 HRESULT WINAPI HGLOBALStreamImpl_Stat( 809 IStream* iface, 810 STATSTG* pstatstg, /* [out] */ 811 DWORD grfStatFlag) /* [in] */ 811 812 { 812 813 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; … … 820 821 return S_OK; 821 822 } 822 823 HRESULT WINAPI HGLOBALStreamImpl_Clone( 824 IStream* iface,825 IStream** ppstm) /* [out] */ 823 824 HRESULT WINAPI HGLOBALStreamImpl_Clone( 825 IStream* iface, 826 IStream** ppstm) /* [out] */ 826 827 { 827 828 FIXME("not implemented!\n"); -
trunk/src/ole32/ifs.c
r5602 r6648 1 /* $Id: ifs.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */ 1 2 /* 2 * basic interfaces3 * basic interfaces 3 4 * 4 * Copyright 1997Marcus Meissner5 * Copyright 1997 Marcus Meissner 5 6 */ 6 7 … … 30 31 31 32 /****************************************************************************** 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);33 * IUnknown_AddRef [VTABLE:IUNKNOWN.1] 34 */ 35 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 36 ICOM_THIS(IUnknownImpl,iface); 37 TRACE("(%p)->AddRef()\n",This); 38 return ++(This->ref); 38 39 } 39 40 … … 42 43 */ 43 44 static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) { 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;45 ICOM_THIS(IUnknownImpl,iface); 46 TRACE("(%p)->Release()\n",This); 47 if (!--(This->ref)) { 48 HeapFree(GetProcessHeap(),0,This); 49 return 0; 50 } 51 return This->ref; 51 52 } 52 53 … … 55 56 */ 56 57 static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) { 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_DummyRTTIVALUE71 IUnknown_fnQueryInterface,72 IUnknown_fnAddRef,73 IUnknown_fnRelease58 ICOM_THIS(IUnknownImpl,iface); 59 60 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 61 62 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) { 63 *obj = This; 64 return 0; 65 } 66 return OLE_E_ENUM_NOMORE; 67 } 68 69 static ICOM_VTABLE(IUnknown) uvt = 70 { 71 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 72 IUnknown_fnQueryInterface, 73 IUnknown_fnAddRef, 74 IUnknown_fnRelease 74 75 }; 75 76 … … 79 80 LPUNKNOWN 80 81 IUnknown_Constructor() { 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;82 IUnknownImpl* unk; 83 84 unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl)); 85 ICOM_VTBL(unk) = &uvt; 86 unk->ref = 1; 87 return (LPUNKNOWN)unk; 87 88 } 88 89 … … 100 101 101 102 /****************************************************************************** 102 * IMalloc16_QueryInterface[COMPOBJ.500]103 * IMalloc16_QueryInterface [COMPOBJ.500] 103 104 */ 104 105 HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) { 105 106 ICOM_THIS(IMalloc16Impl,iface); 106 107 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]108 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 109 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 110 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 111 ) { 112 *obj = This; 113 return 0; 114 } 115 return OLE_E_ENUM_NOMORE; 116 } 117 118 /****************************************************************************** 119 * IMalloc16_AddRef [COMPOBJ.501] 119 120 */ 120 121 ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) { 121 122 ICOM_THIS(IMalloc16Impl,iface); 122 TRACE("(%p)->AddRef()\n",This);123 return 1; /* cannot be freed */124 } 125 126 /****************************************************************************** 127 * IMalloc16_Release[COMPOBJ.502]123 TRACE("(%p)->AddRef()\n",This); 124 return 1; /* cannot be freed */ 125 } 126 127 /****************************************************************************** 128 * IMalloc16_Release [COMPOBJ.502] 128 129 */ 129 130 ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) { 130 131 ICOM_THIS(IMalloc16Impl,iface); 131 TRACE("(%p)->Release()\n",This);132 return 1; /* cannot be freed */132 TRACE("(%p)->Release()\n",This); 133 return 1; /* cannot be freed */ 133 134 } 134 135 … … 138 139 SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) { 139 140 ICOM_THIS(IMalloc16Impl,iface); 140 TRACE("(%p)->Alloc(%ld)\n",This,cb);141 TRACE("(%p)->Alloc(%ld)\n",This,cb); 141 142 return MapLS( HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, cb ) ); 142 143 } … … 165 166 DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,SEGPTR pv) 166 167 { 167 ICOM_CTHIS(IMalloc16Impl,iface);168 ICOM_CTHIS(IMalloc16Impl,iface); 168 169 TRACE("(%p)->GetSize(%08lx)\n",This,pv); 169 170 return HeapSize( GetProcessHeap(), HEAP_WINE_SEGPTR, MapSL(pv) ); … … 175 176 INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) { 176 177 ICOM_CTHIS(IMalloc16,iface); 177 TRACE("(%p)->DidAlloc(%p)\n",This,pv);178 return (INT16)-1;178 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 179 return (INT16)-1; 179 180 } 180 181 … … 184 185 LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) { 185 186 ICOM_THIS(IMalloc16Impl,iface); 186 TRACE("(%p)->HeapMinimize()\n",This);187 return NULL;187 TRACE("(%p)->HeapMinimize()\n",This); 188 return NULL; 188 189 } 189 190 … … 195 196 LPMALLOC16 196 197 IMalloc16_Constructor() { 197 IMalloc16Impl*This;198 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ");199 200 This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);198 IMalloc16Impl* This; 199 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ"); 200 201 This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl); 201 202 if (!msegvt16) { 202 203 msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16)); … … 213 214 VTENT(HeapMinimize); 214 215 #undef VTENT 215 }216 } 216 217 ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16); 217 This->ref = 1;218 return (LPMALLOC16)SEGPTR_GET(This);218 This->ref = 1; 219 return (LPMALLOC16)SEGPTR_GET(This); 219 220 } 220 221 #endif … … 230 231 231 232 /****************************************************************************** 232 * IMalloc32_QueryInterface[VTABLE]233 * IMalloc32_QueryInterface [VTABLE] 233 234 */ 234 235 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) { 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]236 ICOM_THIS(IMalloc32Impl,iface); 237 238 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 239 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 240 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 241 ) { 242 *obj = This; 243 return S_OK; 244 } 245 return OLE_E_ENUM_NOMORE; 246 } 247 248 /****************************************************************************** 249 * IMalloc32_AddRef [VTABLE] 249 250 */ 250 251 static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) { 251 ICOM_THIS(IMalloc32Impl,iface);252 TRACE("(%p)->AddRef()\n",This);253 return 1; /* cannot be freed */254 } 255 256 /****************************************************************************** 257 * IMalloc32_Release[VTABLE]252 ICOM_THIS(IMalloc32Impl,iface); 253 TRACE("(%p)->AddRef()\n",This); 254 return 1; /* cannot be freed */ 255 } 256 257 /****************************************************************************** 258 * IMalloc32_Release [VTABLE] 258 259 */ 259 260 static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) { 260 ICOM_THIS(IMalloc32Impl,iface);261 TRACE("(%p)->Release()\n",This);262 return 1; /* cannot be freed */261 ICOM_THIS(IMalloc32Impl,iface); 262 TRACE("(%p)->Release()\n",This); 263 return 1; /* cannot be freed */ 263 264 } 264 265 … … 267 268 */ 268 269 static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) { 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;270 LPVOID addr; 271 ICOM_THIS(IMalloc32Impl,iface); 272 addr = HeapAlloc(GetProcessHeap(),0,cb); 273 TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr); 274 return addr; 274 275 } 275 276 … … 278 279 */ 279 280 static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) { 280 ICOM_THIS(IMalloc32Impl,iface);281 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);282 return HeapReAlloc(GetProcessHeap(),0,pv,cb);281 ICOM_THIS(IMalloc32Impl,iface); 282 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb); 283 return HeapReAlloc(GetProcessHeap(),0,pv,cb); 283 284 } 284 285 … … 287 288 */ 288 289 static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) { 289 ICOM_THIS(IMalloc32Impl,iface);290 TRACE("(%p)->Free(%p)\n",This,pv);291 HeapFree(GetProcessHeap(),0,pv);290 ICOM_THIS(IMalloc32Impl,iface); 291 TRACE("(%p)->Free(%p)\n",This,pv); 292 HeapFree(GetProcessHeap(),0,pv); 292 293 } 293 294 … … 296 297 */ 297 298 static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) { 298 ICOM_CTHIS(IMalloc,iface);299 TRACE("(%p)->GetSize(%p)\n",This,pv);300 return HeapSize(GetProcessHeap(),0,pv);299 ICOM_CTHIS(IMalloc,iface); 300 TRACE("(%p)->GetSize(%p)\n",This,pv); 301 return HeapSize(GetProcessHeap(),0,pv); 301 302 } 302 303 … … 305 306 */ 306 307 static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) { 307 ICOM_CTHIS(IMalloc32Impl,iface);308 TRACE("(%p)->DidAlloc(%p)\n",This,pv);309 return -1;308 ICOM_CTHIS(IMalloc32Impl,iface); 309 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 310 return -1; 310 311 } 311 312 … … 314 315 */ 315 316 static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) { 316 ICOM_THIS(IMalloc32Impl,iface);317 TRACE("(%p)->HeapMinimize()\n",This);318 } 319 320 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 317 ICOM_THIS(IMalloc32Impl,iface); 318 TRACE("(%p)->HeapMinimize()\n",This); 319 } 320 321 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 321 322 { 322 323 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE … … 337 338 LPMALLOC 338 339 IMalloc_Constructor() { 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;340 IMalloc32Impl* This; 341 342 This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl)); 343 ICOM_VTBL(This) = &VT_IMalloc32; 344 This->ref = 1; 345 return (LPMALLOC)This; 345 346 } 346 347 … … 350 351 351 352 /****************************************************************************** 352 * IsValidInterface[OLE32.78]353 * IsValidInterface [OLE32.78] 353 354 * 354 355 * RETURNS … … 356 357 */ 357 358 BOOL WINAPI IsValidInterface( 358 LPUNKNOWN punk/* [in] interface to be tested */359 LPUNKNOWN punk /* [in] interface to be tested */ 359 360 ) { 360 return !(361 IsBadReadPtr(punk,4)||362 IsBadReadPtr(ICOM_VTBL(punk),4)||361 return !( 362 IsBadReadPtr(punk,4) || 363 IsBadReadPtr(ICOM_VTBL(punk),4) || 363 364 #ifdef __WIN32OS2__ 364 IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)||365 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface)365 IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9) || 366 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface) 366 367 #else 367 IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9)||368 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)368 IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) || 369 IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface) 369 370 #endif 370 );371 } 371 ); 372 } -
trunk/src/ole32/initole32.cpp
r6401 r6648 1 /* 1 /* $Id: initole32.cpp,v 1.3 2001-09-05 13:17:10 bird Exp $ 2 2 * DLL entry point 3 3 * … … 52 52 case DLL_THREAD_ATTACH: 53 53 case DLL_THREAD_DETACH: 54 return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);54 return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 55 55 56 56 case DLL_PROCESS_DETACH: 57 57 OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad); 58 return TRUE;58 return TRUE; 59 59 } 60 60 return FALSE; … … 82 82 case 0 : 83 83 { 84 dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab);85 if(dllHandle == 0) 86 return 0UL;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 UnregisterLxDll(dllHandle);92 UnregisterLxDll(dllHandle); 93 93 } 94 94 break; -
trunk/src/ole32/initterm.cpp
r6375 r6648 1 /* 1 /* $Id: initterm.cpp,v 1.11 2001-09-05 13:17:10 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * -
trunk/src/ole32/itemmoniker.c
r5602 r6648 1 /* $Id: itemmoniker.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */ 1 2 /*************************************************************************************** 2 * ItemMonikers implementation3 * ItemMonikers implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 25 26 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 26 27 27 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 28 29 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 29 30 */ … … 35 36 36 37 LPOLESTR itemDelimiter; /* Delimiter string */ 37 38 38 39 } ItemMonikerImpl; 39 40 … … 140 141 /* Perform a sanity check on the parameters.*/ 141 142 if ( (This==0) || (ppvObject==0) ) 142 return E_INVALIDARG;143 143 return E_INVALIDARG; 144 144 145 /* Initialize the return parameter */ 145 146 *ppvObject = 0; … … 152 153 ) 153 154 *ppvObject = iface; 154 155 155 156 else if (IsEqualIID(&IID_IROTData, riid)) 156 157 *ppvObject = (IROTData*)&(This->lpvtbl2); … … 159 160 if ((*ppvObject)==0) 160 161 return E_NOINTERFACE; 161 162 162 163 /* Query Interface always increases the reference count by one when it is successful */ 163 164 ItemMonikerImpl_AddRef(iface); … … 208 209 if (pClassID==NULL) 209 210 return E_POINTER; 210 211 211 212 *pClassID = CLSID_ItemMoniker; 212 213 213 214 return S_OK; 214 215 } … … 342 343 343 344 /* for more details see ItemMonikerImpl_Save coments */ 344 345 345 346 pcbSize->s.LowPart = sizeof(DWORD) + /* DWORD which contains delimiter length */ 346 347 delimiterLength + /* item delimiter string */ … … 362 363 int sizeStr1=lstrlenW(lpszItem), sizeStr2; 363 364 static const OLECHAR emptystr[1]; 364 LPCOLESTR delim;365 LPCOLESTR delim; 365 366 366 367 TRACE("(%p,%p)\n",This,lpszItem); … … 373 374 This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1)); 374 375 if (!This->itemName) 375 return E_OUTOFMEMORY;376 return E_OUTOFMEMORY; 376 377 strcpyW(This->itemName,lpszItem); 377 378 378 379 if (!lpszDelim) 379 FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");380 FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n"); 380 381 381 382 delim = lpszDelim ? lpszDelim : emptystr; … … 384 385 This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); 385 386 if (!This->itemDelimiter) { 386 HeapFree(GetProcessHeap(),0,This->itemName);387 return E_OUTOFMEMORY;387 HeapFree(GetProcessHeap(),0,This->itemName); 388 return E_OUTOFMEMORY; 388 389 } 389 390 strcpyW(This->itemDelimiter,delim); … … 419 420 { 420 421 ICOM_THIS(ItemMonikerImpl,iface); 421 422 422 423 HRESULT res; 423 424 IID refid=IID_IOleItemContainer; … … 466 467 if(pmkToLeft==NULL) 467 468 return E_INVALIDARG; 468 469 469 470 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); 470 471 … … 496 497 497 498 *ppmkReduced=iface; 498 499 499 500 return MK_S_REDUCED_TO_SELF; 500 501 } … … 516 517 517 518 if ((ppmkComposite==NULL)||(pmkRight==NULL)) 518 return E_POINTER;519 return E_POINTER; 519 520 520 521 *ppmkComposite=0; 521 522 522 523 IMoniker_IsSystemMoniker(pmkRight,&mkSys); 523 524 … … 529 530 /* if pmkRight is a composite whose leftmost component is an anti-moniker, */ 530 531 /* the returned moniker is the composite after the leftmost anti-moniker is removed. */ 531 532 532 533 if(mkSys==MKSYS_GENERICCOMPOSITE){ 533 534 … … 547 548 tempMkComposite=iface; 548 549 IMoniker_AddRef(iface); 549 550 550 551 while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){ 551 552 … … 604 605 if (pmkOtherMoniker==NULL) 605 606 return S_FALSE; 606 607 607 608 /* This method returns S_OK if both monikers are item monikers and their display names are */ 608 609 /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */ … … 619 620 IMoniker_GetDisplayName(iface,bind,NULL,&dispName1); 620 621 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2); 621 622 622 623 if (lstrcmpW(dispName1,dispName2)!=0) 623 624 return S_FALSE; 624 625 625 626 return S_OK; 626 627 } … … 639 640 if (pdwHash==NULL) 640 641 return E_POINTER; 641 642 642 643 val = This->itemName; 643 644 len = lstrlenW(val); … … 649 650 } else { 650 651 /* only sample some characters */ 651 skip = len / 8;652 for (i = len ; i > 0; i -= skip, off += skip) {652 skip = len / 8; 653 for (i = len ; i > 0; i -= skip, off += skip) { 653 654 h = (h * 39) + val[off]; 654 }655 } 655 656 } 656 657 … … 698 699 /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/ 699 700 /* passing the string contained within this moniker. */ 700 701 701 702 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); 702 703 … … 779 780 780 781 *ppmkPrefix=iface; 781 782 782 783 IMoniker_AddRef(iface); 783 784 784 785 return MK_S_US; 785 786 } … … 801 802 802 803 *ppmkRelPath=0; 803 804 804 805 return MK_E_NOTBINDABLE; 805 806 } … … 831 832 strcpyW(*ppszDisplayName,This->itemDelimiter); 832 833 strcatW(*ppszDisplayName,This->itemName); 833 834 834 835 return S_OK; 835 836 } … … 885 886 if (!pwdMksys) 886 887 return E_POINTER; 887 888 888 889 (*pwdMksys)=MKSYS_ITEMMONIKER; 889 890 … … 922 923 { 923 924 ICOM_THIS_From_IROTData(IMoniker, iface); 924 925 925 926 TRACE("(%p)\n",iface); 926 927 … … 941 942 942 943 /****************************************************************************** 943 * CreateItemMoniker16 [OLE2.28]944 * CreateItemMoniker16 [OLE2.28] 944 945 ******************************************************************************/ 945 946 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR lpszItem,LPMONIKER* ppmk) … … 952 953 953 954 /****************************************************************************** 954 * CreateItemMoniker [OLE.55]955 * CreateItemMoniker [OLE.55] 955 956 ******************************************************************************/ 956 957 HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk) -
trunk/src/ole32/memlockbytes.c
r5602 r6648 1 /* $Id: memlockbytes.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */ 1 2 /****************************************************************************** 2 3 * … … 25 26 { 26 27 /* 27 * Needs to be the first item in the stuct 28 * Needs to be the first item in the stuct 28 29 * since we want to cast this in an ILockBytes pointer 29 30 */ … … 188 189 HGLOBALLockBytesImpl* newLockBytes; 189 190 newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl)); 190 191 191 192 if (newLockBytes!=0) 192 193 { … … 196 197 ICOM_VTBL(newLockBytes) = &HGLOBALLockBytesImpl_Vtbl; 197 198 newLockBytes->ref = 0; 198 199 199 200 /* 200 201 * Initialize the support. … … 398 399 * The function returns S_OK if the specified number of bytes were read 399 400 * or the end of the array was reached. 400 * It returns STG_E_READFAULT if the number of bytes to read does not equal 401 * It returns STG_E_READFAULT if the number of bytes to read does not equal 401 402 * the number of bytes actually read. 402 403 */ … … 503 504 if (libNewSize.s.HighPart != 0) 504 505 return STG_E_INVALIDFUNCTION; 505 506 506 507 if (This->byteArraySize.s.LowPart == libNewSize.s.LowPart) 507 508 return S_OK; … … 518 519 519 520 This->byteArraySize.s.LowPart = libNewSize.s.LowPart; 520 521 521 522 return S_OK; 522 523 } -
trunk/src/ole32/moniker.c
r5843 r6648 1 /* $Id: moniker.c,v 1.3 2001-09-05 13:17:10 bird Exp $ */ 1 2 /* 2 * Monikers3 * Monikers 3 4 * 4 * Copyright 1998Marcus Meissner5 * Copyright 1998 Marcus Meissner 5 6 * Copyright 1999 Noomen Hamza 6 7 */ … … 46 47 DWORD runObjTabLastIndx; /* first free index element in the table. */ 47 48 DWORD runObjTabRegister; /* registration key of the next registered object */ 48 49 49 50 } RunningObjectTableImpl; 50 51 … … 136 137 { 137 138 TRACE("()\n"); 138 139 139 140 if (runningObjectTableInstance==NULL) 140 141 return E_INVALIDARG; … … 169 170 if (( This->runObjTab[i].regTypeObj & ROTFLAGS_REGISTRATIONKEEPSALIVE) != 0) 170 171 IUnknown_Release(This->runObjTab[i].pObj); 171 172 172 173 IMoniker_Release(This->runObjTab[i].pmkObj); 173 174 } … … 229 230 if (runningObjectTableInstance==NULL) 230 231 return E_POINTER; 231 232 232 233 RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance); 233 234 … … 270 271 This->runObjTab[This->runObjTabLastIndx].identRegObj = This->runObjTabRegister; 271 272 CoFileTimeNow(&(This->runObjTab[This->runObjTabLastIndx].lastModifObj)); 272 273 273 274 /* gives a registration identifier to the registered object*/ 274 275 (*pdwRegister)= This->runObjTabRegister; … … 277 278 278 279 FIXME("runObjTabRegister: %ld is out of data limite \n",This->runObjTabRegister); 279 return E_FAIL;280 return E_FAIL; 280 281 } 281 282 This->runObjTabRegister++; 282 283 This->runObjTabLastIndx++; 283 284 284 285 if (This->runObjTabLastIndx == This->runObjTabSize){ /* table is full ! so it must be resized */ 285 286 … … 295 296 296 297 IMoniker_AddRef(pmkObjectName); 297 298 298 299 return res; 299 300 } … … 321 322 322 323 IMoniker_Release(This->runObjTab[index].pmkObj); 323 324 324 325 /* remove the object from the table */ 325 326 for(j=index; j<This->runObjTabLastIndx-1; j++) 326 327 This->runObjTab[j]= This->runObjTab[j+1]; 327 328 328 329 This->runObjTabLastIndx--; 329 330 … … 336 337 HRESULT WINAPI RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, 337 338 IMoniker *pmkObjectName) /* Pointer to the moniker of the object whose status is desired */ 338 { 339 { 339 340 ICOM_THIS(RunningObjectTableImpl,iface); 340 341 … … 358 359 if (ppunkObject==NULL) 359 360 return E_POINTER; 360 361 361 362 *ppunkObject=0; 362 363 … … 393 394 return S_OK; 394 395 } 395 396 396 397 /*********************************************************************** 397 398 * RunningObjectTable_GetTimeOfLastChange … … 447 448 /* search object identified by a register identifier */ 448 449 for(i=0;((i<This->runObjTabLastIndx)&&(This->runObjTab[i].identRegObj!=identReg));i++); 449 450 450 451 if (i==This->runObjTabLastIndx) return S_FALSE; 451 452 … … 456 457 457 458 /****************************************************************************** 458 * GetRunningObjectTable16[OLE2.30]459 * GetRunningObjectTable16 [OLE2.30] 459 460 */ 460 461 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot) 461 462 { 462 FIXME("(%ld,%p),stub!\n",reserved,pprot);463 FIXME("(%ld,%p),stub!\n",reserved,pprot); 463 464 return E_NOTIMPL; 464 465 } … … 490 491 HRESULT WINAPI OleRun(LPUNKNOWN pUnknown) 491 492 { 492 IRunnableObject *runable;493 IRunnableObject *runable; 493 494 ICOM_THIS(IRunnableObject,pUnknown); 494 LRESULT ret;495 LRESULT ret; 495 496 496 497 #ifdef __WIN32OS2__ … … 501 502 502 503 ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,(LPVOID*)&runable); 503 if (ret) 504 return 0; /* Appears to return no error. */504 if (ret) 505 return 0; /* Appears to return no error. */ 505 506 ret = IRunnableObject_Run(runable,NULL); 506 507 IRunnableObject_Release(runable); … … 512 513 */ 513 514 HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName, 514 LPDWORD pchEaten, LPMONIKER *ppmk)515 LPDWORD pchEaten, LPMONIKER *ppmk) 515 516 { 516 517 FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk); 517 518 if (!(IsValidInterface((LPUNKNOWN) pbc))) 518 return E_INVALIDARG;519 return E_INVALIDARG; 519 520 520 521 return MK_E_SYNTAX; -
trunk/src/ole32/ole2.c
r5602 r6648 1 /* $Id: ole2.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */ 1 2 /* 2 * OLE2 library3 * 4 * Copyright 1995Martin von Loewis3 * OLE2 library 4 * 5 * Copyright 1995 Martin von Loewis 5 6 * Copyright 1999 Francis Beaudet 6 * Copyright 1999 Noel Borthwick 7 * Copyright 1999 Noel Borthwick 7 8 */ 8 9 … … 32 33 33 34 /****************************************************************************** 34 * These are static/global variables and internal data structures that the 35 * These are static/global variables and internal data structures that the 35 36 * OLE module uses to maintain it's state. 36 37 */ … … 94 95 95 96 /****************************************************************************** 96 * These are the prototypes of miscelaneous utility methods 97 * These are the prototypes of miscelaneous utility methods 97 98 */ 98 99 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue); … … 123 124 static void OLEDD_UnInitialize(); 124 125 static void OLEDD_InsertDropTarget( 125 DropTargetNode* nodeToAdd);126 DropTargetNode* nodeToAdd); 126 127 static DropTargetNode* OLEDD_ExtractDropTarget( 127 128 HWND hwndOfTarget); … … 129 130 HWND hwndOfTarget); 130 131 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 131 HWND hwnd, 132 UINT uMsg,133 WPARAM wParam, 134 LPARAM lParam);132 HWND hwnd, 133 UINT uMsg, 134 WPARAM wParam, 135 LPARAM lParam); 135 136 static void OLEDD_TrackMouseMove( 136 137 TrackerWindowInfo* trackerInfo, 137 POINT mousePos,138 DWORD keyState);138 POINT mousePos, 139 DWORD keyState); 139 140 static void OLEDD_TrackStateChange( 140 141 TrackerWindowInfo* trackerInfo, 141 POINT mousePos,142 DWORD keyState);142 POINT mousePos, 143 DWORD keyState); 143 144 static DWORD OLEDD_GetButtonState(); 144 145 145 146 146 147 /****************************************************************************** 147 * OleBuildVersion[OLE2.1]148 * OleBuildVersion [OLE2.1] 148 149 */ 149 150 DWORD WINAPI OleBuildVersion(void) … … 168 169 169 170 /* 170 * If the CoInitializeEx call failed, the OLE libraries can't be 171 * If the CoInitializeEx call failed, the OLE libraries can't be 171 172 * initialized. 172 173 */ 173 174 if (FAILED(hr)) 174 return hr; 175 return hr; 175 176 176 177 /* … … 184 185 if (OLE_moduleLockCount==0) 185 186 { 186 /* 187 /* 187 188 * Initialize the libraries. 188 189 */ … … 208 209 * Then, we increase the lock count on the OLE module. 209 210 */ 210 OLE_moduleLockCount++; 211 OLE_moduleLockCount++; 211 212 212 213 return hr; … … 214 215 215 216 /****************************************************************************** 216 * CoGetCurrentProcess[COMPOBJ.34] [OLE2.2][OLE32.108]217 * CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108] 217 218 * 218 219 * NOTES … … 221 222 DWORD WINAPI CoGetCurrentProcess(void) 222 223 { 223 return GetCurrentProcessId();224 return GetCurrentProcessId(); 224 225 } 225 226 226 227 /****************************************************************************** 227 * OleUninitialize[OLE2.3] [OLE32.131]228 * OleUninitialize [OLE2.3] [OLE32.131] 228 229 */ 229 230 void WINAPI OleUninitialize(void) … … 255 256 */ 256 257 OLEDD_UnInitialize(); 257 258 258 259 /* 259 260 * OLE shared menu … … 261 262 OLEMenu_UnInitialize(); 262 263 } 263 264 264 265 /* 265 266 * Then, uninitialize the COM libraries. … … 271 272 //imessagefilter.cpp 272 273 /****************************************************************************** 273 * CoRegisterMessageFilter[OLE32.38]274 * CoRegisterMessageFilter [OLE32.38] 274 275 */ 275 276 HRESULT WINAPI CoRegisterMessageFilter( 276 LPMESSAGEFILTER lpMessageFilter, /* [in] Pointer to interface */277 LPMESSAGEFILTER *lplpMessageFilter /* [out] Indirect pointer to prior instance if non-NULL */277 LPMESSAGEFILTER lpMessageFilter, /* [in] Pointer to interface */ 278 LPMESSAGEFILTER *lplpMessageFilter /* [out] Indirect pointer to prior instance if non-NULL */ 278 279 ) { 279 280 FIXME("stub\n"); 280 281 if (lplpMessageFilter) { 281 *lplpMessageFilter = NULL;282 *lplpMessageFilter = NULL; 282 283 } 283 284 return S_OK; … … 286 287 287 288 /****************************************************************************** 288 * OleInitializeWOW[OLE32.109]289 * OleInitializeWOW [OLE32.109] 289 290 */ 290 291 HRESULT WINAPI OleInitializeWOW(DWORD x) { … … 297 298 */ 298 299 HRESULT WINAPI RegisterDragDrop16( 299 HWND16 hwnd,300 LPDROPTARGET pDropTarget300 HWND16 hwnd, 301 LPDROPTARGET pDropTarget 301 302 ) { 302 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);303 return S_OK;303 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget); 304 return S_OK; 304 305 } 305 306 … … 308 309 */ 309 310 HRESULT WINAPI RegisterDragDrop( 310 HWND hwnd,311 LPDROPTARGET pDropTarget) 311 HWND hwnd, 312 LPDROPTARGET pDropTarget) 312 313 { 313 314 DropTargetNode* dropTargetInfo; … … 341 342 dropTargetInfo->dropTarget = pDropTarget; 342 343 IDropTarget_AddRef(dropTargetInfo->dropTarget); 343 344 344 345 OLEDD_InsertDropTarget(dropTargetInfo); 345 346 346 return S_OK;347 return S_OK; 347 348 } 348 349 … … 351 352 */ 352 353 HRESULT WINAPI RevokeDragDrop16( 353 HWND16 hwnd354 HWND16 hwnd 354 355 ) { 355 FIXME("(0x%04x),stub!\n",hwnd);356 return S_OK;356 FIXME("(0x%04x),stub!\n",hwnd); 357 return S_OK; 357 358 } 358 359 … … 361 362 */ 362 363 HRESULT WINAPI RevokeDragDrop( 363 HWND hwnd)364 HWND hwnd) 364 365 { 365 366 DropTargetNode* dropTargetInfo; … … 383 384 */ 384 385 IDropTarget_Release(dropTargetInfo->dropTarget); 385 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 386 387 return S_OK;386 HeapFree(GetProcessHeap(), 0, dropTargetInfo); 387 388 return S_OK; 388 389 } 389 390 … … 396 397 * way they are registered. 397 398 */ 398 HRESULT WINAPI OleRegGetUserType( 399 REFCLSID clsid, 400 DWORD dwFormOfType,401 LPOLESTR* pszUserType)399 HRESULT WINAPI OleRegGetUserType( 400 REFCLSID clsid, 401 DWORD dwFormOfType, 402 LPOLESTR* pszUserType) 402 403 { 403 404 char keyName[60]; … … 427 428 */ 428 429 hres = RegOpenKeyA(HKEY_CLASSES_ROOT, 429 keyName,430 &clsidKey);430 keyName, 431 &clsidKey); 431 432 432 433 if (hres != ERROR_SUCCESS) … … 439 440 440 441 hres = RegQueryValueExA(clsidKey, 441 "",442 NULL,443 &dwKeyType,444 NULL,445 &cbData);442 "", 443 NULL, 444 &dwKeyType, 445 NULL, 446 &cbData); 446 447 447 448 if (hres!=ERROR_SUCCESS) … … 473 474 474 475 hres = RegQueryValueExA(clsidKey, 475 "",476 NULL,477 &dwKeyType,478 buffer,479 &cbData);476 "", 477 NULL, 478 &dwKeyType, 479 buffer, 480 &cbData); 480 481 481 482 RegCloseKey(clsidKey); 482 483 483 484 484 485 if (hres!=ERROR_SUCCESS) 485 486 { … … 527 528 528 529 hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS, 529 "TrackerWindow",530 WS_POPUP,531 CW_USEDEFAULT, CW_USEDEFAULT,532 CW_USEDEFAULT, CW_USEDEFAULT,533 0,534 0,535 0,536 (LPVOID)&trackerInfo);530 "TrackerWindow", 531 WS_POPUP, 532 CW_USEDEFAULT, CW_USEDEFAULT, 533 CW_USEDEFAULT, CW_USEDEFAULT, 534 0, 535 0, 536 0, 537 (LPVOID)&trackerInfo); 537 538 538 539 if (hwndTrackWindow!=0) … … 548 549 while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) ) 549 550 { 550 if ( (msg.message >= WM_KEYFIRST) && 551 (msg.message <= WM_KEYLAST) )551 if ( (msg.message >= WM_KEYFIRST) && 552 (msg.message <= WM_KEYLAST) ) 552 553 { 553 /*554 * When keyboard messages are sent to windows on this thread, we555 * want to ignore notify the drop source that the state changed.556 * in the case of the Escape key, we also notify the drop source557 * 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());554 /* 555 * When keyboard messages are sent to windows on this thread, we 556 * want to ignore notify the drop source that the state changed. 557 * in the case of the Escape key, we also notify the drop source 558 * we give it a special meaning. 559 */ 560 if ( (msg.message==WM_KEYDOWN) && 561 (msg.wParam==VK_ESCAPE) ) 562 { 563 trackerInfo.escPressed = TRUE; 564 } 565 566 /* 567 * Notify the drop source. 568 */ 569 OLEDD_TrackStateChange(&trackerInfo, 570 msg.pt, 571 OLEDD_GetButtonState()); 571 572 } 572 573 else 573 574 { 574 /*575 * Dispatch the messages only when it's not a keyboard message.576 */577 DispatchMessageA(&msg);575 /* 576 * Dispatch the messages only when it's not a keyboard message. 577 */ 578 DispatchMessageA(&msg); 578 579 } 579 580 } … … 633 634 */ 634 635 result = RegOpenKeyA(HKEY_CLASSES_ROOT, 635 keyName,636 &clsidKey);636 keyName, 637 &clsidKey); 637 638 638 639 if (result != ERROR_SUCCESS) … … 643 644 */ 644 645 result = RegOpenKeyA(clsidKey, 645 "MiscStatus",646 &miscStatusKey);647 648 646 "MiscStatus", 647 &miscStatusKey); 648 649 649 650 if (result != ERROR_SUCCESS) 650 651 { … … 664 665 665 666 result = RegOpenKeyA(miscStatusKey, 666 keyName,667 &aspectKey);668 667 keyName, 668 &aspectKey); 669 669 670 if (result == ERROR_SUCCESS) 670 671 { … … 686 687 */ 687 688 HRESULT WINAPI OleSetContainedObject( 688 LPUNKNOWN pUnknown, 689 LPUNKNOWN pUnknown, 689 690 BOOL fContained) 690 691 { … … 695 696 696 697 hres = IUnknown_QueryInterface(pUnknown, 697 &IID_IRunnableObject,698 (void**)&runnable);698 &IID_IRunnableObject, 699 (void**)&runnable); 699 700 700 701 if (SUCCEEDED(hres)) … … 714 715 */ 715 716 HRESULT WINAPI OleLoad( 716 LPSTORAGE pStg, 717 REFIID riid, 718 LPOLECLIENTSITE pClientSite, 717 LPSTORAGE pStg, 718 REFIID riid, 719 LPOLECLIENTSITE pClientSite, 719 720 LPVOID* ppvObj) 720 721 { … … 725 726 726 727 TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj); 727 728 728 729 /* 729 730 * TODO, Conversion ... OleDoAutoConvert … … 739 740 */ 740 741 hres = CoCreateInstance(&storageInfo.clsid, 741 NULL,742 CLSCTX_INPROC_HANDLER,743 &IID_IOleObject,744 (void**)&oleObject);742 NULL, 743 CLSCTX_INPROC_HANDLER, 744 &IID_IOleObject, 745 (void**)&oleObject); 745 746 746 747 /* … … 751 752 { 752 753 hres = OleCreateDefaultHandler(&storageInfo.clsid, 753 NULL,754 &IID_IOleObject,755 (void**)&oleObject);754 NULL, 755 &IID_IOleObject, 756 (void**)&oleObject); 756 757 } 757 758 … … 771 772 */ 772 773 hres = IOleObject_QueryInterface(oleObject, 773 &IID_IPersistStorage,774 (void**)&persistStorage);775 776 if (SUCCEEDED(hres)) 774 &IID_IPersistStorage, 775 (void**)&persistStorage); 776 777 if (SUCCEEDED(hres)) 777 778 { 778 779 IPersistStorage_Load(persistStorage, pStg); … … 827 828 { 828 829 IStorage_Commit(pStg, 829 STGC_DEFAULT);830 } 831 830 STGC_DEFAULT); 831 } 832 832 833 return hres; 833 834 } … … 837 838 * OleLockRunning [OLE32.114] 838 839 */ 839 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 840 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 840 841 { 841 842 IRunnableObject* runnable = NULL; … … 845 846 846 847 hres = IUnknown_QueryInterface(pUnknown, 847 &IID_IRunnableObject,848 (void**)&runnable);848 &IID_IRunnableObject, 849 (void**)&runnable); 849 850 850 851 if (SUCCEEDED(hres)) … … 902 903 pHookItem->tid = tid; 903 904 pHookItem->hHeap = GetProcessHeap(); 904 905 905 906 /* Install a thread scope message hook for WH_GETMESSAGE */ 906 907 pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc, … … 918 919 pHookItem->next = hook_list; 919 920 hook_list = pHookItem; 920 921 921 922 return TRUE; 922 923 923 924 CLEANUP: 924 925 /* Unhook any hooks */ … … 929 930 /* Release the hook table entry */ 930 931 HeapFree(pHookItem->hHeap, 0, pHookItem ); 931 932 932 933 return FALSE; 933 934 } … … 994 995 return pHookItem; 995 996 } 996 997 997 998 return NULL; 998 999 } … … 1015 1016 { 1016 1017 HMENU hsubmenu; 1017 1018 1018 1019 /* Is the current item a submenu? */ 1019 1020 if ( (hsubmenu = GetSubMenu(hMainMenu, i)) ) … … 1062 1063 if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu, &nPos ) ) 1063 1064 return FALSE; 1064 1065 1065 1066 /* The group widths array has counts for the number of elements 1066 1067 * in the groups File, Edit, Container, Object, Window, Help. … … 1095 1096 OleMenuHookItem *pHookItem = NULL; 1096 1097 WORD fuFlags; 1097 1098 1098 1099 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1099 1100 … … 1101 1102 if ( HC_ACTION != code ) 1102 1103 goto NEXTHOOK; 1103 1104 1104 1105 /* Retrieve the current message being dispatched from lParam */ 1105 1106 pMsg = (LPCWPSTRUCT)lParam; … … 1131 1132 goto NEXTHOOK; 1132 1133 } 1133 1134 1134 1135 case WM_INITMENUPOPUP: 1135 1136 { … … 1138 1139 break; 1139 1140 } 1140 1141 1141 1142 case WM_MENUSELECT: 1142 1143 { … … 1151 1152 break; 1152 1153 } 1153 1154 1154 1155 case WM_DRAWITEM: 1155 1156 { … … 1171 1172 pMsg->message, pMsg->wParam, pMsg->lParam ); 1172 1173 } 1173 1174 1174 1175 NEXTHOOK: 1175 1176 if ( pOleMenuDescriptor ) 1176 1177 GlobalUnlock( hOleMenu ); 1177 1178 1178 1179 /* Lookup the hook item for the current thread */ 1179 1180 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1183 1184 return 0; 1184 1185 } 1185 1186 1186 1187 /* Pass on the message to the next hooker */ 1187 1188 return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam ); … … 1200 1201 OleMenuHookItem *pHookItem = NULL; 1201 1202 WORD wCode; 1202 1203 1203 1204 TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam ); 1204 1205 … … 1206 1207 if ( HC_ACTION != code ) 1207 1208 goto NEXTHOOK; 1208 1209 1209 1210 /* Retrieve the current message being dispatched from lParam */ 1210 1211 pMsg = (LPMSG)lParam; … … 1245 1246 pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject; 1246 1247 } 1247 1248 1248 1249 NEXTHOOK: 1249 1250 if ( pOleMenuDescriptor ) 1250 1251 GlobalUnlock( hOleMenu ); 1251 1252 1252 1253 /* Lookup the hook item for the current thread */ 1253 1254 if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) ) … … 1257 1258 return FALSE; 1258 1259 } 1259 1260 1260 1261 /* Pass on the message to the next hooker */ 1261 1262 return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam ); … … 1295 1296 for ( i = 0; i < 6; i++ ) 1296 1297 pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i]; 1297 1298 1298 1299 pOleMenuDescriptor->hmenuCombined = hmenuCombined; 1299 1300 pOleMenuDescriptor->bIsServerItem = FALSE; 1300 1301 GlobalUnlock( hOleMenu ); 1301 1302 1302 1303 return hOleMenu; 1303 1304 } … … 1312 1313 if ( hmenuDescriptor ) 1313 1314 GlobalFree( hmenuDescriptor ); 1314 return S_OK;1315 return S_OK; 1315 1316 } 1316 1317 … … 1321 1322 * OLE should install context sensitive help F1 filtering for the app when 1322 1323 * these are non null. 1323 * 1324 * 1324 1325 * PARAMS: 1325 1326 * hOleMenu Handle to composite menu descriptor … … 1349 1350 { 1350 1351 FIXME("(%x, %x, %x, %p, %p), Context sensitive help filtering not implemented!\n", 1351 (unsigned int)hOleMenu,1352 hwndFrame,1353 hwndActiveObject,1354 lpFrame,1355 lpActiveObject);1352 (unsigned int)hOleMenu, 1353 hwndFrame, 1354 hwndActiveObject, 1355 lpFrame, 1356 lpActiveObject); 1356 1357 } 1357 1358 … … 1369 1370 if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) 1370 1371 return E_FAIL; 1371 1372 1372 1373 /* Get the menu descriptor */ 1373 1374 pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); … … 1381 1382 GlobalUnlock( hOleMenu ); 1382 1383 pOleMenuDescriptor = NULL; 1383 1384 1384 1385 /* Add a menu descriptor windows property to the frame window */ 1385 1386 SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu ); … … 1394 1395 if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) ) 1395 1396 return E_FAIL; 1396 1397 1397 1398 /* Remove the menu descriptor property from the frame window */ 1398 1399 RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" ); 1399 1400 } 1400 1401 1401 1402 return S_OK; 1402 1403 } … … 1419 1420 #endif 1420 1421 { 1421 WARN_(accel)("invalid accel handle=%04x\n", hAccel);1422 return FALSE;1422 WARN_(accel)("invalid accel handle=%04x\n", hAccel); 1423 return FALSE; 1423 1424 } 1424 1425 if((lpMsg->message != WM_KEYDOWN && 1425 lpMsg->message != WM_KEYUP &&1426 lpMsg->message != WM_SYSKEYDOWN &&1427 lpMsg->message != WM_SYSKEYUP &&1428 lpMsg->message != WM_CHAR)) return FALSE;1426 lpMsg->message != WM_KEYUP && 1427 lpMsg->message != WM_SYSKEYDOWN && 1428 lpMsg->message != WM_SYSKEYUP && 1429 lpMsg->message != WM_CHAR)) return FALSE; 1429 1430 1430 1431 TRACE_(accel)("hAccel=%04x, cAccelEntries=%d," 1431 "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n",1432 hAccel, cAccelEntries,1433 lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);1432 "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n", 1433 hAccel, cAccelEntries, 1434 lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); 1434 1435 for(i = 0; i < cAccelEntries; i++) 1435 1436 { 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 else1448 {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 else1461 {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 } 1437 if(lpAccelTbl[i].key != lpMsg->wParam) 1438 continue; 1439 1440 if(lpMsg->message == WM_CHAR) 1441 { 1442 if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY)) 1443 { 1444 TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff); 1445 goto found; 1446 } 1447 } 1448 else 1449 { 1450 if(lpAccelTbl[i].fVirt & FVIRTKEY) 1451 { 1452 INT mask = 0; 1453 TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n", 1454 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff); 1455 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; 1456 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; 1457 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT; 1458 if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found; 1459 TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n"); 1460 } 1461 else 1462 { 1463 if(!(lpMsg->lParam & 0x01000000)) /* no special_key */ 1464 { 1465 if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000)) 1466 { /* ^^ ALT pressed */ 1467 TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff); 1468 goto found; 1469 } 1470 } 1471 } 1472 } 1473 } 1473 1474 1474 1475 WARN_(accel)("couldn't translate accelerator key\n"); … … 1490 1491 case TYMED_HGLOBAL: 1491 1492 { 1492 if ( (pmedium->pUnkForRelease==0) && 1493 (pmedium->u.hGlobal!=0) )1494 GlobalFree(pmedium->u.hGlobal);1493 if ( (pmedium->pUnkForRelease==0) && 1494 (pmedium->u.hGlobal!=0) ) 1495 GlobalFree(pmedium->u.hGlobal); 1495 1496 1496 1497 pmedium->u.hGlobal = 0; … … 1501 1502 if (pmedium->u.lpszFileName!=0) 1502 1503 { 1503 if (pmedium->pUnkForRelease==0)1504 {1505 DeleteFileW(pmedium->u.lpszFileName);1506 }1507 1508 CoTaskMemFree(pmedium->u.lpszFileName);1504 if (pmedium->pUnkForRelease==0) 1505 { 1506 DeleteFileW(pmedium->u.lpszFileName); 1507 } 1508 1509 CoTaskMemFree(pmedium->u.lpszFileName); 1509 1510 } 1510 1511 … … 1516 1517 if (pmedium->u.pstm!=0) 1517 1518 { 1518 IStream_Release(pmedium->u.pstm);1519 IStream_Release(pmedium->u.pstm); 1519 1520 } 1520 1521 … … 1526 1527 if (pmedium->u.pstg!=0) 1527 1528 { 1528 IStorage_Release(pmedium->u.pstg);1529 IStorage_Release(pmedium->u.pstg); 1529 1530 } 1530 1531 … … 1534 1535 case TYMED_GDI: 1535 1536 { 1536 if ( (pmedium->pUnkForRelease==0) && 1537 (pmedium->u.hGlobal!=0) )1538 DeleteObject(pmedium->u.hGlobal);1537 if ( (pmedium->pUnkForRelease==0) && 1538 (pmedium->u.hGlobal!=0) ) 1539 DeleteObject(pmedium->u.hGlobal); 1539 1540 1540 1541 pmedium->u.hGlobal = 0; … … 1543 1544 case TYMED_MFPICT: 1544 1545 { 1545 if ( (pmedium->pUnkForRelease==0) && 1546 (pmedium->u.hMetaFilePict!=0) )1546 if ( (pmedium->pUnkForRelease==0) && 1547 (pmedium->u.hMetaFilePict!=0) ) 1547 1548 { 1548 LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);1549 DeleteMetaFile(pMP->hMF);1550 GlobalUnlock(pmedium->u.hMetaFilePict);1551 GlobalFree(pmedium->u.hMetaFilePict);1549 LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict); 1550 DeleteMetaFile(pMP->hMF); 1551 GlobalUnlock(pmedium->u.hMetaFilePict); 1552 GlobalFree(pmedium->u.hMetaFilePict); 1552 1553 } 1553 1554 … … 1557 1558 case TYMED_ENHMF: 1558 1559 { 1559 if ( (pmedium->pUnkForRelease==0) && 1560 (pmedium->u.hEnhMetaFile!=0) )1560 if ( (pmedium->pUnkForRelease==0) && 1561 (pmedium->u.hEnhMetaFile!=0) ) 1561 1562 { 1562 DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);1563 DeleteEnhMetaFile(pmedium->u.hEnhMetaFile); 1563 1564 } 1564 1565 … … 1598 1599 wndClass.hbrBackground = 0; 1599 1600 wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS; 1600 1601 1601 1602 RegisterClassA (&wndClass); 1602 1603 } … … 1664 1665 /* 1665 1666 * If we get here, we have found a spot for our item. The parentNodeLink 1666 * pointer points to the pointer that we have to modify. 1667 * pointer points to the pointer that we have to modify. 1667 1668 * The curNode should be NULL. We just have to establish the link and Voila! 1668 1669 */ … … 1711 1712 { 1712 1713 /* 1713 * The item was found in the list. Detach it from it's parent and 1714 * The item was found in the list. Detach it from it's parent and 1714 1715 * re-insert it's kids in the tree. 1715 1716 */ … … 1727 1728 if (curNode->nextDropTarget!=NULL) 1728 1729 { 1729 OLEDD_InsertDropTarget(curNode->nextDropTarget);1730 OLEDD_InsertDropTarget(curNode->nextDropTarget); 1730 1731 } 1731 1732 … … 1801 1802 */ 1802 1803 static LRESULT WINAPI OLEDD_DragTrackerWindowProc( 1803 HWND hwnd, 1804 UINT uMsg,1805 WPARAM wParam, 1806 LPARAM lParam)1804 HWND hwnd, 1805 UINT uMsg, 1806 WPARAM wParam, 1807 LPARAM lParam) 1807 1808 { 1808 1809 switch (uMsg) … … 1812 1813 LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam; 1813 1814 1814 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1815 1816 1815 SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 1816 1817 1817 1818 break; 1818 1819 } … … 1909 1910 * DragOver notification 1910 1911 */ 1911 if ( (trackerInfo->curDragTarget != 0) && 1912 if ( (trackerInfo->curDragTarget != 0) && 1912 1913 (trackerInfo->curDragTargetHWND==hwndNewTarget) ) 1913 1914 { 1914 1915 POINTL mousePosParam; 1915 1916 1916 1917 /* 1917 1918 * The documentation tells me that the coordinate should be in the target … … 1921 1922 mousePosParam.x = mousePos.x; 1922 1923 mousePosParam.y = mousePos.y; 1923 1924 1924 1925 IDropTarget_DragOver(trackerInfo->curDragTarget, 1925 keyState,1926 mousePosParam,1927 trackerInfo->pdwEffect);1926 keyState, 1927 mousePosParam, 1928 trackerInfo->pdwEffect); 1928 1929 } 1929 1930 else 1930 1931 { 1931 1932 DropTargetNode* newDropTargetNode = 0; 1932 1933 1933 1934 /* 1934 1935 * If we changed window, we have to notify our old target and check for … … 1939 1940 IDropTarget_DragLeave(trackerInfo->curDragTarget); 1940 1941 } 1941 1942 1942 1943 /* 1943 1944 * Make sure we're hovering over a window. … … 1950 1951 HWND nexttar = hwndNewTarget; 1951 1952 do { 1952 newDropTargetNode = OLEDD_FindDropTarget(nexttar);1953 newDropTargetNode = OLEDD_FindDropTarget(nexttar); 1953 1954 } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0); 1954 1955 if(nexttar) hwndNewTarget = nexttar; … … 1956 1957 trackerInfo->curDragTargetHWND = hwndNewTarget; 1957 1958 trackerInfo->curDragTarget = newDropTargetNode ? newDropTargetNode->dropTarget : 0; 1958 1959 1959 1960 /* 1960 1961 * If there is, notify it that we just dragged-in … … 1962 1963 if (trackerInfo->curDragTarget!=0) 1963 1964 { 1964 POINTL mousePosParam;1965 1966 /*1967 * The documentation tells me that the coordinate should be in the target1968 * window's coordinate space. However, the tests I made tell me the1969 * 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);1965 POINTL mousePosParam; 1966 1967 /* 1968 * The documentation tells me that the coordinate should be in the target 1969 * window's coordinate space. However, the tests I made tell me the 1970 * coordinates should be in screen coordinates. 1971 */ 1972 mousePosParam.x = mousePos.x; 1973 mousePosParam.y = mousePos.y; 1974 1975 IDropTarget_DragEnter(trackerInfo->curDragTarget, 1976 trackerInfo->dataObject, 1977 keyState, 1978 mousePosParam, 1979 trackerInfo->pdwEffect); 1979 1980 } 1980 1981 } … … 1990 1991 1991 1992 /* 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 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 1994 1995 * have a target, simulate no effect. 1995 1996 */ … … 2000 2001 2001 2002 hr = IDropSource_GiveFeedback(trackerInfo->dropSource, 2002 *trackerInfo->pdwEffect);2003 *trackerInfo->pdwEffect); 2003 2004 2004 2005 /* … … 2026 2027 SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0))); 2027 2028 } 2028 } 2029 } 2029 2030 } 2030 2031 … … 2054 2055 */ 2055 2056 trackerInfo->returnValue = IDropSource_QueryContinueDrag( 2056 trackerInfo->dropSource,2057 trackerInfo->escPressed, 2058 keyState);2059 2057 trackerInfo->dropSource, 2058 trackerInfo->escPressed, 2059 keyState); 2060 2060 2061 /* 2061 2062 * All the return valued will stop the operation except the S_OK … … 2070 2071 2071 2072 /* 2072 * Release the mouse in case the drop target decides to show a popup 2073 * Release the mouse in case the drop target decides to show a popup 2073 2074 * or a menu or something. 2074 2075 */ 2075 2076 ReleaseCapture(); 2076 2077 2077 2078 /* 2078 * If we end-up over a target, drop the object in the target or 2079 * If we end-up over a target, drop the object in the target or 2079 2080 * inform the target that the operation was cancelled. 2080 2081 */ … … 2083 2084 switch (trackerInfo->returnValue) 2084 2085 { 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 */2086 /* 2087 * If the source wants us to complete the operation, we tell 2088 * the drop target that we just dropped the object in it. 2089 */ 2089 2090 case DRAGDROP_S_DROP: 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 tests2096 * 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 */2091 { 2092 POINTL mousePosParam; 2093 2094 /* 2095 * The documentation tells me that the coordinate should be 2096 * in the target window's coordinate space. However, the tests 2097 * I made tell me the coordinates should be in screen coordinates. 2098 */ 2099 mousePosParam.x = mousePos.x; 2100 mousePosParam.y = mousePos.y; 2101 2102 IDropTarget_Drop(trackerInfo->curDragTarget, 2103 trackerInfo->dataObject, 2104 keyState, 2105 mousePosParam, 2106 trackerInfo->pdwEffect); 2107 break; 2108 } 2109 /* 2110 * If the source told us that we should cancel, fool the drop 2111 * target by telling it that the mouse left it's window. 2112 * Also set the drop effect to "NONE" in case the application 2113 * ignores the result of DoDragDrop. 2114 */ 2114 2115 case DRAGDROP_S_CANCEL: 2115 IDropTarget_DragLeave(trackerInfo->curDragTarget);2116 *trackerInfo->pdwEffect = DROPEFFECT_NONE;2117 break;2116 IDropTarget_DragLeave(trackerInfo->curDragTarget); 2117 *trackerInfo->pdwEffect = DROPEFFECT_NONE; 2118 break; 2118 2119 } 2119 2120 } … … 2162 2163 * params: 2163 2164 * regKey - Key to read the default value from 2164 * pdwValue - Pointer to the location where the DWORD 2165 * pdwValue - Pointer to the location where the DWORD 2165 2166 * value is returned. This value is not modified 2166 2167 * if the value is not found. … … 2168 2169 2169 2170 static void OLEUTL_ReadRegistryDWORDValue( 2170 HKEY regKey, 2171 HKEY regKey, 2171 2172 DWORD* pdwValue) 2172 2173 { … … 2177 2178 2178 2179 lres = RegQueryValueExA(regKey, 2179 "",2180 NULL,2181 &dwKeyType,2182 (LPBYTE)buffer,2183 &cbData);2180 "", 2181 NULL, 2182 &dwKeyType, 2183 (LPBYTE)buffer, 2184 &cbData); 2184 2185 2185 2186 if (lres==ERROR_SUCCESS) … … 2188 2189 { 2189 2190 case REG_DWORD: 2190 *pdwValue = *(DWORD*)buffer;2191 break;2191 *pdwValue = *(DWORD*)buffer; 2192 break; 2192 2193 case REG_EXPAND_SZ: 2193 2194 case REG_MULTI_SZ: 2194 2195 case REG_SZ: 2195 *pdwValue = (DWORD)strtoul(buffer, NULL, 10);2196 break;2196 *pdwValue = (DWORD)strtoul(buffer, NULL, 10); 2197 break; 2197 2198 } 2198 2199 } … … 2209 2210 */ 2210 2211 HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( 2211 HICON16 hIcon,2212 LPCOLESTR16 lpszLabel,2213 LPCOLESTR16 lpszSourceFile,2214 UINT16 iIconIndex2212 HICON16 hIcon, 2213 LPCOLESTR16 lpszLabel, 2214 LPCOLESTR16 lpszSourceFile, 2215 UINT16 iIconIndex 2215 2216 ) { 2216 2217 METAFILEPICT16 *mf; … … 2222 2223 if (!hIcon) { 2223 2224 if (lpszSourceFile) { 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 } else2230 return (HGLOBAL)NULL;2225 HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile); 2226 2227 /* load the icon at index from lpszSourceFile */ 2228 hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex); 2229 FreeLibrary16(hInstance); 2230 } else 2231 return (HGLOBAL)NULL; 2231 2232 } 2232 2233 -
trunk/src/ole32/ole2impl.c
r5602 r6648 1 /* $Id: ole2impl.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */ 1 2 /* 2 3 * Ole 2 Create functions implementation -
trunk/src/ole32/ole2stubs.c
r5602 r6648 1 /* $Id: ole2stubs.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */ 1 2 /* 2 3 * Temporary place for ole2 stubs. … … 19 20 */ 20 21 HRESULT WINAPI OleCreateLinkToFile(LPCOLESTR lpszFileName, REFIID riid, 21 DWORD renderopt, LPFORMATETC lpFormatEtc,22 LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj)22 DWORD renderopt, LPFORMATETC lpFormatEtc, 23 LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj) 23 24 { 24 25 FIXME("(%p,%p,%li,%p,%p,%p,%p), stub!\n",lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj); … … 31 32 */ 32 33 HRESULT WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat, 33 UINT uiFlags)34 UINT uiFlags) 34 35 { 35 36 FIXME("(%x,%x,%x), stub!\n", hSrc, cfFormat, uiFlags); … … 37 38 } 38 39 39 40 40 41 /*********************************************************************** 41 42 * WriteFmtUserTypeStg (OLE32.160) 42 43 */ 43 44 HRESULT WINAPI WriteFmtUserTypeStg( 44 LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)45 LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType) 45 46 { 46 47 FIXME("(%p,%x,%s) stub!\n",pstg,cf,debugstr_w(lpszUserType)); … … 81 82 */ 82 83 HRESULT WINAPI OleCreate( 83 REFCLSID rclsid,84 REFIID riid,85 DWORD renderopt,86 LPFORMATETC pFormatEtc,87 LPOLECLIENTSITE pClientSite,88 LPSTORAGE pStg,89 LPVOID* ppvObj)84 REFCLSID rclsid, 85 REFIID riid, 86 DWORD renderopt, 87 LPFORMATETC pFormatEtc, 88 LPOLECLIENTSITE pClientSite, 89 LPSTORAGE pStg, 90 LPVOID* ppvObj) 90 91 { 91 92 HRESULT hres, hres1; 92 93 IUnknown * pUnk = NULL; 93 94 94 95 FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid)); 95 96 … … 105 106 hres1 = IOleObject_SetClientSite(pOE, pClientSite); 106 107 TRACE("-- result 0x%08lx\n", hres1); 107 IOleObject_Release(pOE);108 IOleObject_Release(pOE); 108 109 } 109 110 if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS)))) 110 111 { 111 112 TRACE("trying to set stg %p\n", pStg); 112 hres1 = IPersistStorage_InitNew(pPS, pStg);113 hres1 = IPersistStorage_InitNew(pPS, pStg); 113 114 TRACE("-- result 0x%08lx\n", hres1); 114 IPersistStorage_Release(pPS);115 IPersistStorage_Release(pPS); 115 116 } 116 117 } … … 208 209 */ 209 210 HRESULT WINAPI OleRegEnumFormatEtc ( 210 REFCLSID clsid, 211 REFCLSID clsid, 211 212 DWORD dwDirection, 212 213 LPENUMFORMATETC* ppenumFormatetc) … … 218 219 219 220 /*********************************************************************** 220 * PropVariantClear [OLE32.166]221 * PropVariantClear [OLE32.166] 221 222 */ 222 223 HRESULT WINAPI PropVariantClear(void *pvar) /* [in/out] FIXME: PROPVARIANT * */ 223 224 { 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]225 FIXME("(%p): stub:\n", pvar); 226 227 *(LPWORD)pvar = 0; 228 /* sets at least the vt field to VT_EMPTY */ 229 return S_OK; 230 } 231 232 /*********************************************************************** 233 * PropVariantCopy [OLE32.246] 233 234 */ 234 235 HRESULT WINAPI PropVariantCopy(void *pvarDest, /* [out] FIXME: PROPVARIANT * */ 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]236 const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */ 237 { 238 FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc); 239 240 return S_OK; 241 } 242 243 /*********************************************************************** 244 * FreePropVariantArray [OLE32.195] 244 245 */ 245 246 HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */ 246 void *rgvars) /* [in/out] FIXME: PROPVARIANT * */247 { 248 FIXME("(%lu, %p): stub:\n", cVariants, rgvars);249 250 return S_OK;247 void *rgvars) /* [in/out] FIXME: PROPVARIANT * */ 248 { 249 FIXME("(%lu, %p): stub:\n", cVariants, rgvars); 250 251 return S_OK; 251 252 } 252 253 -
trunk/src/ole32/ole32_main.c
r5602 r6648 1 /* $Id: ole32_main.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */ 1 2 /* 2 3 * OLE32 Initialization … … 16 17 17 18 /*********************************************************************** 18 * DllEntryPoint (OLE32.@)19 * DllEntryPoint (OLE32.@) 19 20 */ 20 21 … … 26 27 case DLL_PROCESS_ATTACH: 27 28 OLE32_hInstance = hinstDLL; 28 break;29 break; 29 30 30 31 case DLL_PROCESS_DETACH: 31 32 OLE32_hInstance = 0; 32 break;33 break; 33 34 } 34 35 return TRUE; … … 36 37 37 38 /*********************************************************************** 38 * DllRegisterServer (OLE32.@)39 * DllRegisterServer (OLE32.@) 39 40 */ 40 41 HRESULT WINAPI OLE32_DllRegisterServer() { -
trunk/src/ole32/oleobj.c
r5602 r6648 1 /* $Id: oleobj.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */ 1 2 /* 2 * OLE2 COM objects3 * OLE2 COM objects 3 4 * 4 * Copyright 1998 Eric Kohl5 * Copyright 1998 Eric Kohl 5 6 * Copyright 1999 Francis Beaudet 6 7 */ … … 71 72 72 73 lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(), 73 0,74 sizeof(OleAdviseHolderImpl));75 74 0, 75 sizeof(OleAdviseHolderImpl)); 76 76 77 ICOM_VTBL(lpoah) = &oahvt; 77 78 lpoah->ref = 1; 78 79 lpoah->maxSinks = INITIAL_SINKS; 79 80 lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(), 80 0,81 lpoah->maxSinks * sizeof(IAdviseSink*));81 0, 82 lpoah->maxSinks * sizeof(IAdviseSink*)); 82 83 83 84 for (index = 0; index < lpoah->maxSinks; index++) … … 105 106 } 106 107 } 107 108 108 109 HeapFree(GetProcessHeap(), 109 0,110 ptrToDestroy->arrayOfSinks);111 110 0, 111 ptrToDestroy->arrayOfSinks); 112 112 113 113 114 HeapFree(GetProcessHeap(), 114 0,115 ptrToDestroy);115 0, 116 ptrToDestroy); 116 117 } 117 118 … … 121 122 static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface( 122 123 LPOLEADVISEHOLDER iface, 123 REFIID riid, 124 REFIID riid, 124 125 LPVOID* ppvObj) 125 126 { 126 ICOM_THIS(OleAdviseHolderImpl, iface); 127 ICOM_THIS(OleAdviseHolderImpl, iface); 127 128 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj); 128 129 /* … … 134 135 *ppvObj = NULL; 135 136 136 if (IsEqualIID(riid, &IID_IUnknown)) 137 if (IsEqualIID(riid, &IID_IUnknown)) 137 138 { 138 139 /* IUnknown */ 139 *ppvObj = This; 140 } 141 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 140 *ppvObj = This; 141 } 142 else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 142 143 { 143 144 /* IOleAdviseHolder */ … … 147 148 if(*ppvObj == NULL) 148 149 return E_NOINTERFACE; 149 150 150 151 /* 151 152 * A successful QI always increments the reference count. … … 162 163 LPOLEADVISEHOLDER iface) 163 164 { 164 ICOM_THIS(OleAdviseHolderImpl, iface); 165 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 165 ICOM_THIS(OleAdviseHolderImpl, iface); 166 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 166 167 return ++(This->ref); 167 168 } … … 173 174 LPOLEADVISEHOLDER iface) 174 175 { 175 ICOM_THIS(OleAdviseHolderImpl, iface); 176 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 176 ICOM_THIS(OleAdviseHolderImpl, iface); 177 TRACE("(%p)->(ref=%ld)\n", This, This->ref); 177 178 This->ref--; 178 179 … … 196 197 { 197 198 DWORD index; 198 199 ICOM_THIS(OleAdviseHolderImpl, iface); 199 200 ICOM_THIS(OleAdviseHolderImpl, iface); 200 201 201 202 TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection); … … 206 207 if (pdwConnection==NULL) 207 208 return E_POINTER; 208 209 209 210 *pdwConnection = 0; 210 211 … … 227 228 This->maxSinks+=INITIAL_SINKS; 228 229 229 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 230 0,231 This->arrayOfSinks,232 This->maxSinks*sizeof(IAdviseSink*));230 This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 231 0, 232 This->arrayOfSinks, 233 This->maxSinks*sizeof(IAdviseSink*)); 233 234 234 235 for (i=index;i < This->maxSinks; i++) 235 This->arrayOfSinks[i]=0; 236 This->arrayOfSinks[i]=0; 236 237 } 237 238 … … 258 259 */ 259 260 static HRESULT WINAPI OleAdviseHolderImpl_Unadvise( 260 LPOLEADVISEHOLDER iface, 261 LPOLEADVISEHOLDER iface, 261 262 DWORD dwConnection) 262 263 { 263 ICOM_THIS(OleAdviseHolderImpl, iface); 264 ICOM_THIS(OleAdviseHolderImpl, iface); 264 265 265 266 TRACE("(%p)->(%lu)\n", This, dwConnection); 266 267 267 268 /* 268 * So we don't return 0 as a cookie, the index was 269 * So we don't return 0 as a cookie, the index was 269 270 * incremented by 1 in OleAdviseHolderImpl_Advise 270 271 * we have to compensate. 271 272 */ 272 273 dwConnection--; 273 274 274 275 /* 275 276 * Check for invalid cookies. 276 277 */ 277 if ( (dwConnection < 0) || 278 if ( (dwConnection < 0) || 278 279 (dwConnection >= This->maxSinks) ) 279 280 return OLE_E_NOCONNECTION; … … 297 298 OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise) 298 299 { 299 ICOM_THIS(OleAdviseHolderImpl, iface); 300 ICOM_THIS(OleAdviseHolderImpl, iface); 300 301 FIXME("(%p)->(%p)\n", This, ppenumAdvise); 301 302 … … 311 312 OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk) 312 313 { 313 ICOM_THIS(OleAdviseHolderImpl, iface); 314 ICOM_THIS(OleAdviseHolderImpl, iface); 314 315 FIXME("(%p)->(%p)\n", This, pmk); 315 316 … … 324 325 OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface) 325 326 { 326 ICOM_THIS(OleAdviseHolderImpl, iface); 327 ICOM_THIS(OleAdviseHolderImpl, iface); 327 328 FIXME("(%p)\n", This); 328 329 … … 336 337 OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface) 337 338 { 338 ICOM_THIS(OleAdviseHolderImpl, iface); 339 ICOM_THIS(OleAdviseHolderImpl, iface); 339 340 FIXME("(%p)\n", This); 340 341 … … 350 351 FORMATETC fmat; 351 352 DWORD advf; 352 } DataAdviseConnection; 353 } DataAdviseConnection; 353 354 354 355 typedef struct DataAdviseHolder … … 367 368 static void DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy); 368 369 static HRESULT WINAPI DataAdviseHolder_QueryInterface( 369 IDataAdviseHolder* iface,370 REFIID riid,371 void** ppvObject);372 static ULONG WINAPI DataAdviseHolder_AddRef( 370 IDataAdviseHolder* iface, 371 REFIID riid, 372 void** ppvObject); 373 static ULONG WINAPI DataAdviseHolder_AddRef( 373 374 IDataAdviseHolder* iface); 374 static ULONG WINAPI DataAdviseHolder_Release( 375 static ULONG WINAPI DataAdviseHolder_Release( 375 376 IDataAdviseHolder* iface); 376 static HRESULT WINAPI DataAdviseHolder_Advise( 377 static HRESULT WINAPI DataAdviseHolder_Advise( 377 378 IDataAdviseHolder* iface, 378 IDataObject* pDataObject, 379 FORMATETC* pFetc, 380 DWORD advf, 381 IAdviseSink* pAdvise, 382 DWORD* pdwConnection);383 static HRESULT WINAPI DataAdviseHolder_Unadvise( 379 IDataObject* pDataObject, 380 FORMATETC* pFetc, 381 DWORD advf, 382 IAdviseSink* pAdvise, 383 DWORD* pdwConnection); 384 static HRESULT WINAPI DataAdviseHolder_Unadvise( 384 385 IDataAdviseHolder* iface, 385 DWORD dwConnection);386 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 387 IDataAdviseHolder* iface, 388 IEnumSTATDATA** ppenumAdvise);389 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 390 IDataAdviseHolder* iface, 391 IDataObject* pDataObject, 392 DWORD dwReserved, 393 DWORD advf);386 DWORD dwConnection); 387 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 388 IDataAdviseHolder* iface, 389 IEnumSTATDATA** ppenumAdvise); 390 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 391 IDataAdviseHolder* iface, 392 IDataObject* pDataObject, 393 DWORD dwReserved, 394 DWORD advf); 394 395 395 396 /************************************************************************** … … 416 417 417 418 newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(), 418 0,419 sizeof(DataAdviseHolder));420 419 0, 420 sizeof(DataAdviseHolder)); 421 421 422 ICOM_VTBL(newHolder) = &DataAdviseHolderImpl_VTable; 422 423 newHolder->ref = 1; 423 424 newHolder->maxCons = INITIAL_SINKS; 424 425 newHolder->Connections = HeapAlloc(GetProcessHeap(), 425 HEAP_ZERO_MEMORY,426 newHolder->maxCons * 427 sizeof(DataAdviseConnection));426 HEAP_ZERO_MEMORY, 427 newHolder->maxCons * 428 sizeof(DataAdviseConnection)); 428 429 429 430 TRACE("returning %p\n", newHolder); … … 447 448 } 448 449 } 449 450 450 451 HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections); 451 452 HeapFree(GetProcessHeap(), 0, ptrToDestroy); … … 462 463 void** ppvObject) 463 464 { 464 ICOM_THIS(DataAdviseHolder, iface); 465 ICOM_THIS(DataAdviseHolder, iface); 465 466 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject); 466 467 /* … … 469 470 if ( (This==0) || (ppvObject==0) ) 470 471 return E_INVALIDARG; 471 472 472 473 /* 473 474 * Initialize the return parameter. … … 483 484 *ppvObject = iface; 484 485 } 485 486 486 487 /* 487 488 * Check that we obtained an interface. … … 491 492 return E_NOINTERFACE; 492 493 } 493 494 494 495 /* 495 496 * Query Interface always increases the reference count by one when it is 496 * successful. 497 * successful. 497 498 */ 498 499 IUnknown_AddRef((IUnknown*)*ppvObject); 499 500 500 return S_OK;; 501 return S_OK;; 501 502 } 502 503 … … 506 507 * See Windows documentation for more details on IUnknown methods. 507 508 */ 508 static ULONG WINAPI DataAdviseHolder_AddRef( 509 static ULONG WINAPI DataAdviseHolder_AddRef( 509 510 IDataAdviseHolder* iface) 510 511 { 511 ICOM_THIS(DataAdviseHolder, iface); 512 ICOM_THIS(DataAdviseHolder, iface); 512 513 TRACE("(%p) (ref=%ld)\n", This, This->ref); 513 514 This->ref++; … … 521 522 * See Windows documentation for more details on IUnknown methods. 522 523 */ 523 static ULONG WINAPI DataAdviseHolder_Release( 524 static ULONG WINAPI DataAdviseHolder_Release( 524 525 IDataAdviseHolder* iface) 525 526 { … … 541 542 return 0; 542 543 } 543 544 544 545 return This->ref; 545 546 } … … 551 552 static HRESULT WINAPI DataAdviseHolder_Advise( 552 553 IDataAdviseHolder* iface, 553 IDataObject* pDataObject, 554 FORMATETC* pFetc, 555 DWORD advf, 556 IAdviseSink* pAdvise, 554 IDataObject* pDataObject, 555 FORMATETC* pFetc, 556 DWORD advf, 557 IAdviseSink* pAdvise, 557 558 DWORD* pdwConnection) 558 559 { 559 560 DWORD index; 560 561 ICOM_THIS(DataAdviseHolder, iface); 561 562 ICOM_THIS(DataAdviseHolder, iface); 562 563 563 564 TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf, 564 pAdvise, pdwConnection);565 pAdvise, pdwConnection); 565 566 /* 566 567 * Sanity check … … 568 569 if (pdwConnection==NULL) 569 570 return E_POINTER; 570 571 571 572 *pdwConnection = 0; 572 573 … … 587 588 This->maxCons+=INITIAL_SINKS; 588 589 This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 589 This->Connections,590 This->maxCons*sizeof(DataAdviseConnection));590 This->Connections, 591 This->maxCons*sizeof(DataAdviseConnection)); 591 592 } 592 593 /* … … 616 617 * DataAdviseHolder_Unadvise 617 618 */ 618 static HRESULT WINAPI DataAdviseHolder_Unadvise( 619 static HRESULT WINAPI DataAdviseHolder_Unadvise( 619 620 IDataAdviseHolder* iface, 620 621 DWORD dwConnection) 621 622 { 622 ICOM_THIS(DataAdviseHolder, iface); 623 ICOM_THIS(DataAdviseHolder, iface); 623 624 624 625 TRACE("(%p)->(%lu)\n", This, dwConnection); 625 626 626 627 /* 627 * So we don't return 0 as a cookie, the index was 628 * So we don't return 0 as a cookie, the index was 628 629 * incremented by 1 in OleAdviseHolderImpl_Advise 629 630 * we have to compensate. 630 631 */ 631 632 dwConnection--; 632 633 633 634 /* 634 635 * Check for invalid cookies. 635 636 */ 636 if ( (dwConnection < 0) || 637 if ( (dwConnection < 0) || 637 638 (dwConnection >= This->maxCons) ) 638 639 return OLE_E_NOCONNECTION; … … 649 650 } 650 651 651 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 652 IDataAdviseHolder* iface, 652 static HRESULT WINAPI DataAdviseHolder_EnumAdvise( 653 IDataAdviseHolder* iface, 653 654 IEnumSTATDATA** ppenumAdvise) 654 655 { 655 ICOM_THIS(DataAdviseHolder, iface); 656 ICOM_THIS(DataAdviseHolder, iface); 656 657 657 658 FIXME("(%p)->(%p)\n", This, ppenumAdvise); … … 662 663 * DataAdviseHolder_SendOnDataChange 663 664 */ 664 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 665 IDataAdviseHolder* iface, 666 IDataObject* pDataObject, 667 DWORD dwReserved, 665 static HRESULT WINAPI DataAdviseHolder_SendOnDataChange( 666 IDataAdviseHolder* iface, 667 IDataObject* pDataObject, 668 DWORD dwReserved, 668 669 DWORD advf) 669 670 { 670 ICOM_THIS(DataAdviseHolder, iface); 671 ICOM_THIS(DataAdviseHolder, iface); 671 672 DWORD index; 672 673 STGMEDIUM stg; … … 678 679 if(This->Connections[index].sink != NULL) { 679 680 if(!(This->Connections[index].advf & ADVF_NODATA)) { 680 TRACE("Calling IDataObject_GetData\n");681 res = IDataObject_GetData(pDataObject,682 &(This->Connections[index].fmat),683 &stg);684 TRACE("returns %08lx\n", res);681 TRACE("Calling IDataObject_GetData\n"); 682 res = IDataObject_GetData(pDataObject, 683 &(This->Connections[index].fmat), 684 &stg); 685 TRACE("returns %08lx\n", res); 685 686 } 686 687 TRACE("Calling IAdviseSink_OnDataChange\n"); 687 688 IAdviseSink_OnDataChange(This->Connections[index].sink, 688 &(This->Connections[index].fmat),689 &stg);689 &(This->Connections[index].fmat), 690 &stg); 690 691 TRACE("Done IAdviseSink_OnDataChange\n"); 691 692 if(This->Connections[index].advf & ADVF_ONLYONCE) { 692 TRACE("Removing connection\n");693 DataAdviseHolder_Unadvise(iface, index+1);693 TRACE("Removing connection\n"); 694 DataAdviseHolder_Unadvise(iface, index+1); 694 695 } 695 696 } -
trunk/src/ole32/stg_bigblockfile.c
r5602 r6648 1 /* $Id: stg_bigblockfile.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */ 1 2 /****************************************************************************** 2 3 * 3 4 * BigBlockFile 4 5 * 5 * This is the implementation of a file that consists of blocks of 6 * This is the implementation of a file that consists of blocks of 6 7 * a predetermined size. 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 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 10 11 * obtaining the size of the file. 11 12 * The blocks are indexed sequentially from the start of the file 12 13 * starting with -1. 13 * 14 * 14 15 * TODO: 15 16 * - Support for a transacted mode … … 69 70 /*** 70 71 * This structure identifies the paged that are mapped 71 * from the file and their position in memory. It is 72 * from the file and their position in memory. It is 72 73 * also used to hold a reference count to those pages. 73 74 * … … 102 103 ULONG index, 103 104 DWORD desired_access); 104 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 105 void* pBlock);105 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 106 void* pBlock); 106 107 static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This, 107 ULONG page_index);108 ULONG page_index); 108 109 static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags); 109 110 static BOOL BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile); … … 118 119 */ 119 120 static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb, 120 unsigned int index)121 unsigned int index) 121 122 { 122 123 unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int)); … … 150 151 * BIGBLOCKFILE_Construct 151 152 * 152 * Construct a big block file. Create the file mapping object. 153 * Construct a big block file. Create the file mapping object. 153 154 * Create the read only mapped pages list, the writable mapped page list 154 155 * and the blocks in use list. … … 230 231 231 232 This->filesize.s.LowPart = GetFileSize(This->hfile, 232 &This->filesize.s.HighPart);233 &This->filesize.s.HighPart); 233 234 234 235 This->maplist = NULL; … … 323 324 /* 324 325 * validate the block index 325 * 326 * 326 327 */ 327 328 if (This->blocksize * (index + 1) … … 329 330 { 330 331 TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1), 331 This->filesize.s.LowPart);332 This->filesize.s.LowPart); 332 333 return NULL; 333 334 } … … 379 380 380 381 if (pBlock == NULL) 381 return;382 return; 382 383 383 384 page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock); 384 385 385 386 if (page == NULL) 386 return;387 return; 387 388 388 389 BIGBLOCKFILE_ReleaseMappedPage(This, page); … … 393 394 * 394 395 * Sets the size of the file. 395 * 396 * 396 397 */ 397 398 void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) … … 405 406 */ 406 407 BIGBLOCKFILE_UnmapAllMappedPages(This); 407 408 408 409 if (This->fileBased) 409 410 { … … 423 424 * 424 425 * The problem is that the SetFilePointer-SetEndOfFile combo below 425 * doesn't always succeed. The file is not grown. It seems like the 426 * doesn't always succeed. The file is not grown. It seems like the 426 427 * operation is cached. By doing the WriteFile, the file is actually 427 428 * grown on disk. … … 432 433 WriteFile(This->hfile, buf, 10, NULL, NULL); 433 434 /* 434 * END HACK 435 * END HACK 435 436 */ 436 437 … … 440 441 SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN); 441 442 SetEndOfFile(This->hfile); 442 443 443 444 /* 444 445 * re-create the file mapping object … … 447 448 NULL, 448 449 This->flProtect, 449 0, 0, 450 0, 0, 450 451 NULL); 451 452 } … … 476 477 * 477 478 * Returns the size of the file. 478 * 479 * 479 480 */ 480 481 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This) … … 489 490 */ 490 491 static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index, 491 DWORD desired_access)492 DWORD desired_access) 492 493 { 493 494 assert(block_index < BLOCKS_PER_PAGE); … … 495 496 if (desired_access == FILE_MAP_READ) 496 497 { 497 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))498 return FALSE;499 500 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);498 if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index)) 499 return FALSE; 500 501 BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index); 501 502 } 502 503 else 503 504 { 504 assert(desired_access == FILE_MAP_WRITE);505 506 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))507 return FALSE;508 509 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);505 assert(desired_access == FILE_MAP_WRITE); 506 507 if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index)) 508 return FALSE; 509 510 BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index); 510 511 } 511 512 … … 519 520 */ 520 521 static void* BIGBLOCKFILE_GetBigBlockPointer( 521 LPBIGBLOCKFILE This, 522 ULONG block_index, 522 LPBIGBLOCKFILE This, 523 ULONG block_index, 523 524 DWORD desired_access) 524 525 { … … 531 532 if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access)) 532 533 { 533 BIGBLOCKFILE_ReleaseMappedPage(This, page);534 return NULL;534 BIGBLOCKFILE_ReleaseMappedPage(This, page); 535 return NULL; 535 536 } 536 537 … … 547 548 */ 548 549 static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 549 void *pBlock)550 void *pBlock) 550 551 { 551 552 MappedPage *page; … … 553 554 for (page = This->maplist; page != NULL; page = page->next) 554 555 { 555 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes556 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)557 break;556 if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes 557 && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE) 558 break; 558 559 559 560 } … … 567 568 */ 568 569 static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head, 569 ULONG page_index)570 ULONG page_index) 570 571 { 571 572 for (; head != NULL; head = head->next) 572 573 { 573 if (head->page_index == page_index)574 {575 InterlockedIncrement(&head->refcnt);576 break;577 }574 if (head->page_index == page_index) 575 { 576 InterlockedIncrement(&head->refcnt); 577 break; 578 } 578 579 } 579 580 … … 611 612 if (!page) 612 613 { 613 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index); 614 if (page) 615 { 616 This->num_victim_pages--; 617 618 BIGBLOCKFILE_Zero(&page->readable_blocks); 619 BIGBLOCKFILE_Zero(&page->writable_blocks); 620 } 621 } 622 614 page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index); 623 615 if (page) 624 616 { 625 /* If the page is not already at the head of the list, move 626 * it there. (Also moves pages from victim to main list.) */ 627 if (This->maplist != page) 628 { 629 if (This->victimhead == page) This->victimhead = page->next; 630 if (This->victimtail == page) This->victimtail = page->prev; 631 632 BIGBLOCKFILE_UnlinkPage(page); 633 634 BIGBLOCKFILE_LinkHeadPage(&This->maplist, page); 635 } 636 637 return page; 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; 638 639 } 639 640 … … 652 653 if (This->fileBased) 653 654 { 654 DWORD numBytesToMap; 655 DWORD desired_access; 656 657 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart) 658 numBytesToMap = This->filesize.s.LowPart - lowoffset; 659 else 660 numBytesToMap = PAGE_SIZE; 661 662 if (This->flProtect == PAGE_READONLY) 663 desired_access = FILE_MAP_READ; 664 else 665 desired_access = FILE_MAP_WRITE; 666 667 page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0, 668 lowoffset, numBytesToMap); 669 } 655 DWORD numBytesToMap; 656 DWORD desired_access; 657 658 if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart) 659 numBytesToMap = This->filesize.s.LowPart - lowoffset; 670 660 else 671 { 672 page->lpBytes = (LPBYTE)This->pbytearray + lowoffset; 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; 673 674 } 674 675 … … 679 680 680 681 static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This, 681 ULONG page_index)682 ULONG page_index) 682 683 { 683 684 MappedPage *page; … … 705 706 TRACE("%ld at %p\n", page->page_index, page->lpBytes); 706 707 if (page->refcnt > 0) 707 ERR("unmapping inuse page %p\n", page->lpBytes);708 ERR("unmapping inuse page %p\n", page->lpBytes); 708 709 709 710 if (This->fileBased && page->lpBytes) 710 UnmapViewOfFile(page->lpBytes);711 UnmapViewOfFile(page->lpBytes); 711 712 712 713 page->lpBytes = NULL; … … 736 737 if (!InterlockedDecrement(&page->refcnt)) 737 738 { 738 if (This->maplist == page) This->maplist = page->next;739 740 BIGBLOCKFILE_UnlinkPage(page);741 742 if (MAX_VICTIM_PAGES > 0)743 {744 if (This->num_victim_pages >= MAX_VICTIM_PAGES)745 {746 MappedPage *victim = This->victimtail;747 if (victim)748 {749 This->victimtail = victim->prev;750 if (This->victimhead == victim)751 This->victimhead = victim->next;752 753 BIGBLOCKFILE_UnlinkPage(victim);754 BIGBLOCKFILE_DeletePage(This, victim);755 }756 }757 else This->num_victim_pages++;758 759 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);760 if (This->victimtail == NULL) This->victimtail = page;761 }762 else763 BIGBLOCKFILE_DeletePage(This, page);739 if (This->maplist == page) This->maplist = page->next; 740 741 BIGBLOCKFILE_UnlinkPage(page); 742 743 if (MAX_VICTIM_PAGES > 0) 744 { 745 if (This->num_victim_pages >= MAX_VICTIM_PAGES) 746 { 747 MappedPage *victim = This->victimtail; 748 if (victim) 749 { 750 This->victimtail = victim->prev; 751 if (This->victimhead == victim) 752 This->victimhead = victim->next; 753 754 BIGBLOCKFILE_UnlinkPage(victim); 755 BIGBLOCKFILE_DeletePage(This, victim); 756 } 757 } 758 else This->num_victim_pages++; 759 760 BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page); 761 if (This->victimtail == NULL) This->victimtail = page; 762 } 763 else 764 BIGBLOCKFILE_DeletePage(This, page); 764 765 } 765 766 } … … 769 770 while (list != NULL) 770 771 { 771 MappedPage *next = list->next;772 773 BIGBLOCKFILE_DeletePage(This, list);774 775 list = next;772 MappedPage *next = list->next; 773 774 BIGBLOCKFILE_DeletePage(This, list); 775 776 list = next; 776 777 } 777 778 } … … 799 800 for (; list != NULL; list = list->next) 800 801 { 801 BIGBLOCKFILE_UnmapPage(This, list);802 BIGBLOCKFILE_UnmapPage(This, list); 802 803 } 803 804 } … … 813 814 while (list != NULL) 814 815 { 815 MappedPage *next = list->next;816 817 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)818 {819 TRACE("discarding %lu\n", list->page_index);820 821 /* page is entirely outside of the file, delete it */822 BIGBLOCKFILE_UnlinkPage(list);823 BIGBLOCKFILE_DeletePage(This, list);824 }825 else826 {827 /* otherwise, remap it */828 BIGBLOCKFILE_MapPage(This, list);829 }830 831 list = next;816 MappedPage *next = list->next; 817 818 if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart) 819 { 820 TRACE("discarding %lu\n", list->page_index); 821 822 /* page is entirely outside of the file, delete it */ 823 BIGBLOCKFILE_UnlinkPage(list); 824 BIGBLOCKFILE_DeletePage(This, list); 825 } 826 else 827 { 828 /* otherwise, remap it */ 829 BIGBLOCKFILE_MapPage(This, list); 830 } 831 832 list = next; 832 833 } 833 834 } … … 848 849 { 849 850 if (openFlags & (STGM_WRITE | STGM_READWRITE)) 850 return PAGE_READWRITE;851 return PAGE_READWRITE; 851 852 else 852 return PAGE_READONLY;853 } 853 return PAGE_READONLY; 854 } -
trunk/src/ole32/stg_stream.c
r5602 r6648 1 /* $Id: stg_stream.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */ 1 2 /* 2 3 * Compound Storage (32 bit version) … … 65 66 */ 66 67 StgStreamImpl* StgStreamImpl_Construct( 67 StorageBaseImpl* parentStorage,68 StorageBaseImpl* parentStorage, 68 69 DWORD grfMode, 69 70 ULONG ownerProperty) … … 72 73 73 74 newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl)); 74 75 75 76 if (newStream!=0) 76 77 { … … 80 81 ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl; 81 82 newStream->ref = 0; 82 83 83 84 /* 84 85 * We want to nail-down the reference to the storage in case the … … 88 89 IStorage_AddRef((IStorage*)newStream->parentStorage); 89 90 90 newStream->grfMode = grfMode; 91 newStream->grfMode = grfMode; 91 92 newStream->ownerProperty = ownerProperty; 92 93 93 94 /* 94 95 * Start the stream at the begining. … … 96 97 newStream->currentPosition.s.HighPart = 0; 97 98 newStream->currentPosition.s.LowPart = 0; 98 99 99 100 /* 100 101 * Initialize the rest of the data. … … 104 105 newStream->bigBlockChain = 0; 105 106 newStream->smallBlockChain = 0; 106 107 107 108 /* 108 109 * Read the size from the property and determine if the blocks forming … … 111 112 StgStreamImpl_OpenBlockChain(newStream); 112 113 } 113 114 114 115 return newStream; 115 116 } … … 118 119 * This is the destructor of the StgStreamImpl class. 119 120 * 120 * This method will clean-up all the resources used-up by the given StgStreamImpl 121 * This method will clean-up all the resources used-up by the given StgStreamImpl 121 122 * class. The pointer passed-in to this function will be freed and will not 122 123 * be valid anymore. … … 150 151 * Finally, free the memory used-up by the class. 151 152 */ 152 HeapFree(GetProcessHeap(), 0, This); 153 HeapFree(GetProcessHeap(), 0, This); 153 154 } 154 155 … … 158 159 */ 159 160 HRESULT WINAPI StgStreamImpl_QueryInterface( 160 IStream* iface,161 REFIID riid, /* [in] */ 162 void** ppvObject) /* [iid_is][out] */ 161 IStream* iface, 162 REFIID riid, /* [in] */ 163 void** ppvObject) /* [iid_is][out] */ 163 164 { 164 165 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 169 170 if (ppvObject==0) 170 171 return E_INVALIDARG; 171 172 172 173 /* 173 174 * Initialize the return parameter. 174 175 */ 175 176 *ppvObject = 0; 176 177 177 178 /* 178 179 * Compare the riid with the interface IDs implemented by this object. 179 180 */ 180 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 181 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 181 182 { 182 183 *ppvObject = (IStream*)This; 183 184 } 184 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 185 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 185 186 { 186 187 *ppvObject = (IStream*)This; 187 188 } 188 189 189 190 /* 190 191 * Check that we obtained an interface. … … 192 193 if ((*ppvObject)==0) 193 194 return E_NOINTERFACE; 194 195 195 196 /* 196 197 * Query Interface always increases the reference count by one when it is … … 198 199 */ 199 200 StgStreamImpl_AddRef(iface); 200 201 201 202 return S_OK;; 202 203 } … … 207 208 */ 208 209 ULONG WINAPI StgStreamImpl_AddRef( 209 IStream* iface)210 IStream* iface) 210 211 { 211 212 StgStreamImpl* const This=(StgStreamImpl*)iface; 212 213 213 214 This->ref++; 214 215 215 216 return This->ref; 216 217 } … … 221 222 */ 222 223 ULONG WINAPI StgStreamImpl_Release( 223 IStream* iface)224 IStream* iface) 224 225 { 225 226 StgStreamImpl* const This=(StgStreamImpl*)iface; 226 227 227 228 ULONG newRef; 228 229 229 230 This->ref--; 230 231 231 232 newRef = This->ref; 232 233 233 234 /* 234 235 * If the reference count goes down to 0, perform suicide. … … 238 239 StgStreamImpl_Destroy(This); 239 240 } 240 241 241 242 return newRef; 242 243 } … … 272 273 */ 273 274 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 274 This->ownerProperty,275 &curProperty);276 275 This->ownerProperty, 276 &curProperty); 277 277 278 if (readSucessful) 278 279 { 279 280 This->streamSize = curProperty.size; 280 281 281 282 /* 282 283 * This code supports only streams that are <32 bits in size. 283 284 */ 284 285 assert(This->streamSize.s.HighPart == 0); 285 286 286 287 if(curProperty.startingBlock == BLOCK_END_OF_CHAIN) 287 288 { … … 291 292 { 292 293 if ( (This->streamSize.s.HighPart == 0) && 293 (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )294 (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) ) 294 295 { 295 This->smallBlockChain = SmallBlockChainStream_Construct(296 This->parentStorage->ancestorStorage, 297 This->ownerProperty);296 This->smallBlockChain = SmallBlockChainStream_Construct( 297 This->parentStorage->ancestorStorage, 298 This->ownerProperty); 298 299 } 299 300 else 300 301 { 301 This->bigBlockChain = BlockChainStream_Construct(302 This->parentStorage->ancestorStorage,303 NULL,304 This->ownerProperty);302 This->bigBlockChain = BlockChainStream_Construct( 303 This->parentStorage->ancestorStorage, 304 NULL, 305 This->ownerProperty); 305 306 } 306 307 } … … 317 318 * See the documentation of ISequentialStream for more info. 318 319 */ 319 HRESULT WINAPI StgStreamImpl_Read( 320 IStream* iface,321 void* pv, /* [length_is][size_is][out] */322 ULONG cb, /* [in] */ 323 ULONG* pcbRead) /* [out] */ 320 HRESULT WINAPI StgStreamImpl_Read( 321 IStream* iface, 322 void* pv, /* [length_is][size_is][out] */ 323 ULONG cb, /* [in] */ 324 ULONG* pcbRead) /* [out] */ 324 325 { 325 326 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 329 330 330 331 TRACE("(%p, %p, %ld, %p)\n", 331 iface, pv, cb, pcbRead);332 333 /* 332 iface, pv, cb, pcbRead); 333 334 /* 334 335 * If the caller is not interested in the nubmer of bytes read, 335 336 * we use another buffer to avoid "if" statements in the code. … … 337 338 if (pcbRead==0) 338 339 pcbRead = &bytesReadBuffer; 339 340 340 341 /* 341 342 * Using the known size of the stream, calculate the number of bytes … … 343 344 */ 344 345 bytesToReadFromBuffer = min( This->streamSize.s.LowPart - This->currentPosition.s.LowPart, cb); 345 346 346 347 /* 347 348 * Depending on the type of chain that was opened when the stream was constructed, … … 351 352 { 352 353 SmallBlockChainStream_ReadAt(This->smallBlockChain, 353 This->currentPosition,354 bytesToReadFromBuffer,355 pv,356 pcbRead);357 354 This->currentPosition, 355 bytesToReadFromBuffer, 356 pv, 357 pcbRead); 358 358 359 } 359 360 else if (This->bigBlockChain!=0) 360 361 { 361 362 BlockChainStream_ReadAt(This->bigBlockChain, 362 This->currentPosition,363 bytesToReadFromBuffer,364 pv,365 pcbRead);363 This->currentPosition, 364 bytesToReadFromBuffer, 365 pv, 366 pcbRead); 366 367 } 367 368 else … … 386 387 */ 387 388 This->currentPosition.s.LowPart += *pcbRead; 388 389 389 390 /* 390 391 * The function returns S_OK if the buffer was filled completely … … 394 395 if(*pcbRead == cb) 395 396 return S_OK; 396 397 397 398 return S_FALSE; 398 399 } 399 400 400 401 /*** 401 402 * This method is part of the ISequentialStream interface. … … 409 410 */ 410 411 HRESULT WINAPI StgStreamImpl_Write( 411 IStream* iface,412 const void* pv, /* [size_is][in] */ 413 ULONG cb, /* [in] */ 414 ULONG* pcbWritten) /* [out] */ 412 IStream* iface, 413 const void* pv, /* [size_is][in] */ 414 ULONG cb, /* [in] */ 415 ULONG* pcbWritten) /* [out] */ 415 416 { 416 417 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 420 421 421 422 TRACE("(%p, %p, %ld, %p)\n", 422 iface, pv, cb, pcbWritten);423 423 iface, pv, cb, pcbWritten); 424 424 425 /* 425 426 * Do we have permission to write to this stream? … … 435 436 if (pcbWritten == 0) 436 437 pcbWritten = &bytesWritten; 437 438 438 439 /* 439 440 * Initialize the out parameter … … 450 451 newSize.s.LowPart = This->currentPosition.s.LowPart + cb; 451 452 } 452 453 453 454 /* 454 455 * Verify if we need to grow the stream … … 459 460 IStream_SetSize(iface, newSize); 460 461 } 461 462 462 463 /* 463 464 * Depending on the type of chain that was opened when the stream was constructed, … … 467 468 { 468 469 SmallBlockChainStream_WriteAt(This->smallBlockChain, 469 This->currentPosition,470 cb,471 pv,472 pcbWritten);473 470 This->currentPosition, 471 cb, 472 pv, 473 pcbWritten); 474 474 475 } 475 476 else if (This->bigBlockChain!=0) 476 477 { 477 478 BlockChainStream_WriteAt(This->bigBlockChain, 478 This->currentPosition,479 cb,480 pv,481 pcbWritten);479 This->currentPosition, 480 cb, 481 pv, 482 pcbWritten); 482 483 } 483 484 else 484 485 assert(FALSE); 485 486 486 487 /* 487 488 * Advance the position pointer for the number of positions written. 488 489 */ 489 490 This->currentPosition.s.LowPart += *pcbWritten; 490 491 491 492 return S_OK; 492 493 } … … 499 500 * 500 501 * See the documentation of IStream for more info. 501 */ 502 HRESULT WINAPI StgStreamImpl_Seek( 503 IStream* iface,504 LARGE_INTEGER dlibMove, /* [in] */ 505 DWORD dwOrigin, /* [in] */ 506 ULARGE_INTEGER* plibNewPosition) /* [out] */502 */ 503 HRESULT WINAPI StgStreamImpl_Seek( 504 IStream* iface, 505 LARGE_INTEGER dlibMove, /* [in] */ 506 DWORD dwOrigin, /* [in] */ 507 ULARGE_INTEGER* plibNewPosition) /* [out] */ 507 508 { 508 509 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 511 512 512 513 TRACE("(%p, %ld, %ld, %p)\n", 513 iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition);514 515 /* 514 iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition); 515 516 /* 516 517 * The caller is allowed to pass in NULL as the new position return value. 517 518 * If it happens, we assign it to a dynamic variable to avoid special cases … … 555 556 /* ... and subtract with carry */ 556 557 if (dlibMove.s.LowPart > plibNewPosition->s.LowPart) { 557 /* carry needed, This accounts for any underflows at [1]*/558 plibNewPosition->s.HighPart -= 1; 558 /* carry needed, This accounts for any underflows at [1]*/ 559 plibNewPosition->s.HighPart -= 1; 559 560 } 560 561 plibNewPosition->s.LowPart -= dlibMove.s.LowPart; /* [1] */ 561 plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 562 plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 562 563 } else { 563 564 /* add directly */ … … 565 566 plibNewPosition->s.LowPart += dlibMove.s.LowPart; 566 567 if((plibNewPosition->s.LowPart < initialLowPart) || 567 (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {568 /* LowPart has rolled over => add the carry digit to HighPart */569 plibNewPosition->s.HighPart++;568 (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) { 569 /* LowPart has rolled over => add the carry digit to HighPart */ 570 plibNewPosition->s.HighPart++; 570 571 } 571 plibNewPosition->s.HighPart += dlibMove.s.HighPart; 572 } 573 /* 574 * Check if we end-up before the beginning of the file. That should 572 plibNewPosition->s.HighPart += dlibMove.s.HighPart; 573 } 574 /* 575 * Check if we end-up before the beginning of the file. That should 575 576 * trigger an error. 576 577 */ … … 580 581 581 582 /* 582 * We currently don't support files with offsets of >32 bits. 583 * We currently don't support files with offsets of >32 bits. 583 584 * Note that we have checked for a negative offset already 584 585 */ … … 593 594 */ 594 595 This->currentPosition = *plibNewPosition; 595 596 596 597 return S_OK; 597 598 } … … 606 607 * See the documentation of IStream for more info. 607 608 */ 608 HRESULT WINAPI StgStreamImpl_SetSize( 609 IStream* iface,610 ULARGE_INTEGER libNewSize) /* [in] */ 609 HRESULT WINAPI StgStreamImpl_SetSize( 610 IStream* iface, 611 ULARGE_INTEGER libNewSize) /* [in] */ 611 612 { 612 613 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 657 658 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 658 659 This->ownerProperty, 659 &curProperty); 660 &curProperty); 660 661 /* 661 662 * Determine if we have to switch from small to big blocks or vice versa 662 */ 663 if ( (This->smallBlockChain!=0) && 663 */ 664 if ( (This->smallBlockChain!=0) && 664 665 (curProperty.size.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) ) 665 666 { … … 693 694 curProperty.size.s.HighPart = libNewSize.s.HighPart; 694 695 curProperty.size.s.LowPart = libNewSize.s.LowPart; 695 696 696 697 if (Success) 697 698 { 698 699 StorageImpl_WriteProperty(This->parentStorage->ancestorStorage, 699 This->ownerProperty,700 &curProperty);701 } 702 700 This->ownerProperty, 701 &curProperty); 702 } 703 703 704 This->streamSize = libNewSize; 704 705 705 706 return S_OK; 706 707 } 707 708 708 709 /*** 709 710 * This method is part of the IStream interface. … … 713 714 * See the documentation of IStream for more info. 714 715 */ 715 HRESULT WINAPI StgStreamImpl_CopyTo( 716 IStream* iface,717 IStream* pstm, /* [unique][in] */ 718 ULARGE_INTEGER cb, /* [in] */ 719 ULARGE_INTEGER* pcbRead, /* [out] */ 720 ULARGE_INTEGER* pcbWritten) /* [out] */ 716 HRESULT WINAPI StgStreamImpl_CopyTo( 717 IStream* iface, 718 IStream* pstm, /* [unique][in] */ 719 ULARGE_INTEGER cb, /* [in] */ 720 ULARGE_INTEGER* pcbRead, /* [out] */ 721 ULARGE_INTEGER* pcbWritten) /* [out] */ 721 722 { 722 723 HRESULT hr = S_OK; … … 726 727 ULARGE_INTEGER totalBytesWritten; 727 728 728 TRACE("(%p, %p, %ld, %p, %p)\n", 729 iface, pstm, cb.s.LowPart, pcbRead, pcbWritten);729 TRACE("(%p, %p, %ld, %p, %p)\n", 730 iface, pstm, cb.s.LowPart, pcbRead, pcbWritten); 730 731 731 732 /* … … 749 750 else 750 751 copySize = cb.s.LowPart; 751 752 752 753 IStream_Read(iface, tmpBuffer, copySize, &bytesRead); 753 754 754 755 totalBytesRead.s.LowPart += bytesRead; 755 756 756 757 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); 757 758 … … 766 767 break; 767 768 } 768 769 769 770 if (bytesRead!=copySize) 770 771 cb.s.LowPart = 0; … … 797 798 * 798 799 * See the documentation of IStream for more info. 799 */ 800 HRESULT WINAPI StgStreamImpl_Commit( 801 IStream* iface,802 DWORD grfCommitFlags) /* [in] */ 800 */ 801 HRESULT WINAPI StgStreamImpl_Commit( 802 IStream* iface, 803 DWORD grfCommitFlags) /* [in] */ 803 804 { 804 805 return S_OK; … … 812 813 * 813 814 * See the documentation of IStream for more info. 814 */ 815 HRESULT WINAPI StgStreamImpl_Revert( 816 IStream* iface)815 */ 816 HRESULT WINAPI StgStreamImpl_Revert( 817 IStream* iface) 817 818 { 818 819 return S_OK; 819 820 } 820 821 821 HRESULT WINAPI StgStreamImpl_LockRegion( 822 IStream* iface,823 ULARGE_INTEGER libOffset, /* [in] */ 824 ULARGE_INTEGER cb, /* [in] */ 825 DWORD dwLockType) /* [in] */ 822 HRESULT WINAPI StgStreamImpl_LockRegion( 823 IStream* iface, 824 ULARGE_INTEGER libOffset, /* [in] */ 825 ULARGE_INTEGER cb, /* [in] */ 826 DWORD dwLockType) /* [in] */ 826 827 { 827 828 FIXME("not implemented!\n"); … … 829 830 } 830 831 831 HRESULT WINAPI StgStreamImpl_UnlockRegion( 832 IStream* iface,833 ULARGE_INTEGER libOffset, /* [in] */ 834 ULARGE_INTEGER cb, /* [in] */ 835 DWORD dwLockType) /* [in] */ 832 HRESULT WINAPI StgStreamImpl_UnlockRegion( 833 IStream* iface, 834 ULARGE_INTEGER libOffset, /* [in] */ 835 ULARGE_INTEGER cb, /* [in] */ 836 DWORD dwLockType) /* [in] */ 836 837 { 837 838 FIXME("not implemented!\n"); … … 846 847 * 847 848 * See the documentation of IStream for more info. 848 */ 849 HRESULT WINAPI StgStreamImpl_Stat( 850 IStream* iface,851 STATSTG* pstatstg, /* [out] */852 DWORD grfStatFlag) /* [in] */ 849 */ 850 HRESULT WINAPI StgStreamImpl_Stat( 851 IStream* iface, 852 STATSTG* pstatstg, /* [out] */ 853 DWORD grfStatFlag) /* [in] */ 853 854 { 854 855 StgStreamImpl* const This=(StgStreamImpl*)iface; … … 856 857 StgProperty curProperty; 857 858 BOOL readSucessful; 858 859 859 860 /* 860 861 * Read the information from the property. 861 862 */ 862 863 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage, 863 This->ownerProperty,864 &curProperty);865 864 This->ownerProperty, 865 &curProperty); 866 866 867 if (readSucessful) 867 868 { 868 StorageUtl_CopyPropertyToSTATSTG(pstatstg, 869 &curProperty, 870 grfStatFlag);869 StorageUtl_CopyPropertyToSTATSTG(pstatstg, 870 &curProperty, 871 grfStatFlag); 871 872 872 873 pstatstg->grfMode = This->grfMode; 873 874 874 875 return S_OK; 875 876 } 876 877 877 878 return E_FAIL; 878 879 } 879 880 HRESULT WINAPI StgStreamImpl_Clone( 881 IStream* iface,882 IStream** ppstm) /* [out] */ 880 881 HRESULT WINAPI StgStreamImpl_Clone( 882 IStream* iface, 883 IStream** ppstm) /* [out] */ 883 884 { 884 885 FIXME("not implemented!\n"); -
trunk/src/ole32/storage32.c
r5602 r6648 1 /* $Id: storage32.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */ 1 2 /* 2 3 * Compound Storage (32 bit version) … … 47 48 /* OLESTREAM memory structure to use for Get and Put Routines */ 48 49 /* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */ 49 typedef struct 50 typedef struct 50 51 { 51 52 DWORD dwOleID; … … 85 86 DWORD dwExtentX; 86 87 DWORD dwExtentY; 87 DWORD dwSize; 88 DWORD dwSize; 88 89 BYTE *pData; 89 90 }OLECONVERT_ISTORAGE_OLEPRES; … … 110 111 INT typeOfRelation); 111 112 112 static HRESULT adjustPropertyChain( 113 static HRESULT adjustPropertyChain( 113 114 StorageImpl *This, 114 115 StgProperty propertyToDelete, … … 137 138 * Declaration of miscellaneous functions... 138 139 */ 139 static HRESULT validateSTGM(DWORD stgmValue); 140 static HRESULT validateSTGM(DWORD stgmValue); 140 141 141 142 static DWORD GetShareModeFromSTGM(DWORD stgm); … … 223 224 * This method implements the common QueryInterface for all IStorage32 224 225 * implementations contained in this file. 225 * 226 * 226 227 * See Windows documentation for more details on IUnknown methods. 227 228 */ … … 237 238 if ( (This==0) || (ppvObject==0) ) 238 239 return E_INVALIDARG; 239 240 240 241 /* 241 242 * Initialize the return parameter. 242 243 */ 243 244 *ppvObject = 0; 244 245 245 246 /* 246 247 * Compare the riid with the interface IDs implemented by this object. 247 248 */ 248 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 249 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 249 250 { 250 251 *ppvObject = (IStorage*)This; 251 252 } 252 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 253 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 253 254 { 254 255 *ppvObject = (IStorage*)This; 255 256 } 256 257 257 258 /* 258 259 * Check that we obtained an interface. … … 260 261 if ((*ppvObject)==0) 261 262 return E_NOINTERFACE; 262 263 263 264 /* 264 265 * Query Interface always increases the reference count by one when it is … … 269 270 return S_OK; 270 271 } 271 272 272 273 /************************************************************************ 273 274 * Storage32BaseImpl_AddRef (IUnknown) … … 275 276 * This method implements the common AddRef for all IStorage32 276 277 * implementations contained in this file. 277 * 278 * 278 279 * See Windows documentation for more details on IUnknown methods. 279 280 */ 280 ULONG WINAPI StorageBaseImpl_AddRef( 281 ULONG WINAPI StorageBaseImpl_AddRef( 281 282 IStorage* iface) 282 283 { … … 286 287 return This->ref; 287 288 } 288 289 289 290 /************************************************************************ 290 291 * Storage32BaseImpl_Release (IUnknown) … … 292 293 * This method implements the common Release for all IStorage32 293 294 * implementations contained in this file. 294 * 295 * 295 296 * See Windows documentation for more details on IUnknown methods. 296 297 */ 297 ULONG WINAPI StorageBaseImpl_Release( 298 ULONG WINAPI StorageBaseImpl_Release( 298 299 IStorage* iface) 299 300 { … … 310 311 { 311 312 /* 312 * Since we are using a system of base-classes, we want to call the 313 * destructor of the appropriate derived class. To do this, we are 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 314 315 * using virtual functions to implement the destructor. 315 316 */ … … 318 319 return 0; 319 320 } 320 321 321 322 return This->ref; 322 323 } … … 329 330 * See Windows documentation for more details on IStorage methods. 330 331 */ 331 HRESULT WINAPI StorageBaseImpl_OpenStream( 332 HRESULT WINAPI StorageBaseImpl_OpenStream( 332 333 IStorage* iface, 333 334 const OLECHAR* pwcsName, /* [string][in] */ 334 335 void* reserved1, /* [unique][in] */ 335 DWORD grfMode, /* [in] */ 336 DWORD reserved2, /* [in] */ 337 IStream** ppstm) /* [out] */ 336 DWORD grfMode, /* [in] */ 337 DWORD reserved2, /* [in] */ 338 IStream** ppstm) /* [out] */ 338 339 { 339 340 ICOM_THIS(StorageBaseImpl,iface); … … 343 344 ULONG foundPropertyIndex; 344 345 345 TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 346 iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);346 TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 347 iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm); 347 348 348 349 /* … … 351 352 if ( (pwcsName==NULL) || (ppstm==0) ) 352 353 return E_INVALIDARG; 353 354 354 355 /* 355 356 * Initialize the out parameter 356 357 */ 357 358 *ppstm = 0; 358 359 359 360 /* 360 361 * Validate the STGM flags … … 375 376 */ 376 377 propertyEnumeration = IEnumSTATSTGImpl_Construct( 377 This->ancestorStorage, 378 This->ancestorStorage, 378 379 This->rootPropertySetIndex); 379 380 380 381 /* 381 382 * Search the enumeration for the property with the given name … … 385 386 pwcsName, 386 387 ¤tProperty); 387 388 388 389 /* 389 390 * Delete the property enumeration since we don't need it anymore 390 391 */ 391 392 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 392 393 393 394 /* 394 395 * If it was found, construct the stream object and return a pointer to it. 395 396 */ 396 if ( (foundPropertyIndex!=PROPERTY_NULL) && 397 if ( (foundPropertyIndex!=PROPERTY_NULL) && 397 398 (currentProperty.propertyType==PROPTYPE_STREAM) ) 398 399 { 399 400 newStream = StgStreamImpl_Construct(This, grfMode, foundPropertyIndex); 400 401 401 402 if (newStream!=0) 402 403 { … … 405 406 406 407 /* 407 * Since we are returning a pointer to the interface, we have to 408 * Since we are returning a pointer to the interface, we have to 408 409 * nail down the reference. 409 410 */ 410 411 StgStreamImpl_AddRef(*ppstm); 411 412 412 413 return S_OK; 413 414 } 414 415 415 416 return E_OUTOFMEMORY; 416 417 } 417 418 418 419 return STG_E_FILENOTFOUND; 419 420 } … … 423 424 * 424 425 * This method will open a new storage object from the current storage. 425 * 426 * 426 427 * See Windows documentation for more details on IStorage methods. 427 */ 428 HRESULT WINAPI StorageBaseImpl_OpenStorage( 428 */ 429 HRESULT WINAPI StorageBaseImpl_OpenStorage( 429 430 IStorage* iface, 430 const OLECHAR* pwcsName, /* [string][unique][in] */ 431 IStorage* pstgPriority, /* [unique][in] */ 432 DWORD grfMode, /* [in] */ 433 SNB snbExclude, /* [unique][in] */ 434 DWORD reserved, /* [in] */ 435 IStorage** ppstg) /* [out] */ 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] */ 436 437 { 437 438 ICOM_THIS(StorageBaseImpl,iface); … … 441 442 ULONG foundPropertyIndex; 442 443 443 TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 444 iface, debugstr_w(pwcsName), pstgPriority, 445 grfMode, snbExclude, reserved, ppstg);446 444 TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 445 iface, debugstr_w(pwcsName), pstgPriority, 446 grfMode, snbExclude, reserved, ppstg); 447 447 448 /* 448 449 * Perform a sanity check on the parameters. … … 450 451 if ( (This==0) || (pwcsName==NULL) || (ppstg==0) ) 451 452 return E_INVALIDARG; 452 453 453 454 /* 454 455 * Validate the STGM flags … … 460 461 * As documented. 461 462 */ 462 if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 463 if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 463 464 (grfMode & STGM_DELETEONRELEASE) || 464 465 (grfMode & STGM_PRIORITY) ) … … 469 470 */ 470 471 *ppstg = 0; 471 472 472 473 /* 473 474 * Create a property enumeration to search the properties 474 475 */ 475 476 propertyEnumeration = IEnumSTATSTGImpl_Construct( 476 This->ancestorStorage, 477 This->ancestorStorage, 477 478 This->rootPropertySetIndex); 478 479 479 480 /* 480 481 * Search the enumeration for the property with the given name … … 484 485 pwcsName, 485 486 ¤tProperty); 486 487 487 488 /* 488 489 * Delete the property enumeration since we don't need it anymore 489 490 */ 490 491 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 491 492 492 493 /* 493 494 * If it was found, construct the stream object and return a pointer to it. 494 495 */ 495 if ( (foundPropertyIndex!=PROPERTY_NULL) && 496 if ( (foundPropertyIndex!=PROPERTY_NULL) && 496 497 (currentProperty.propertyType==PROPTYPE_STORAGE) ) 497 498 { … … 502 503 This->ancestorStorage, 503 504 foundPropertyIndex); 504 505 505 506 if (newStorage != 0) 506 507 { … … 508 509 509 510 /* 510 * Since we are returning a pointer to the interface, 511 * Since we are returning a pointer to the interface, 511 512 * we have to nail down the reference. 512 513 */ 513 514 StorageBaseImpl_AddRef(*ppstg); 514 515 515 516 return S_OK; 516 517 } 517 518 518 519 return STG_E_INSUFFICIENTMEMORY; 519 520 } 520 521 521 522 return STG_E_FILENOTFOUND; 522 523 } … … 525 526 * Storage32BaseImpl_EnumElements (IStorage) 526 527 * 527 * This method will create an enumerator object that can be used to 528 * This method will create an enumerator object that can be used to 528 529 * retrieve informatino about all the properties in the storage object. 529 * 530 * 530 531 * See Windows documentation for more details on IStorage methods. 531 */ 532 HRESULT WINAPI StorageBaseImpl_EnumElements( 532 */ 533 HRESULT WINAPI StorageBaseImpl_EnumElements( 533 534 IStorage* iface, 534 DWORD reserved1, /* [in] */ 535 void* reserved2, /* [size_is][unique][in] */ 536 DWORD reserved3, /* [in] */ 537 IEnumSTATSTG** ppenum) /* [out] */ 535 DWORD reserved1, /* [in] */ 536 void* reserved2, /* [size_is][unique][in] */ 537 DWORD reserved3, /* [in] */ 538 IEnumSTATSTG** ppenum) /* [out] */ 538 539 { 539 540 ICOM_THIS(StorageBaseImpl,iface); 540 541 IEnumSTATSTGImpl* newEnum; 541 542 542 TRACE("(%p, %ld, %p, %ld, %p)\n", 543 iface, reserved1, reserved2, reserved3, ppenum);543 TRACE("(%p, %ld, %p, %ld, %p)\n", 544 iface, reserved1, reserved2, reserved3, ppenum); 544 545 545 546 /* … … 548 549 if ( (This==0) || (ppenum==0)) 549 550 return E_INVALIDARG; 550 551 551 552 /* 552 553 * Construct the enumerator. … … 565 566 */ 566 567 IEnumSTATSTGImpl_AddRef(*ppenum); 567 568 568 569 return S_OK; 569 570 } … … 576 577 * 577 578 * This method will retrieve information about this storage object. 578 * 579 * 579 580 * See Windows documentation for more details on IStorage methods. 580 */ 581 HRESULT WINAPI StorageBaseImpl_Stat( 581 */ 582 HRESULT WINAPI StorageBaseImpl_Stat( 582 583 IStorage* iface, 583 STATSTG* pstatstg, /* [out] */ 584 DWORD grfStatFlag) /* [in] */ 584 STATSTG* pstatstg, /* [out] */ 585 DWORD grfStatFlag) /* [in] */ 585 586 { 586 587 ICOM_THIS(StorageBaseImpl,iface); … … 588 589 BOOL readSuccessful; 589 590 590 TRACE("(%p, %p, %lx)\n", 591 iface, pstatstg, grfStatFlag);591 TRACE("(%p, %p, %lx)\n", 592 iface, pstatstg, grfStatFlag); 592 593 593 594 /* … … 608 609 { 609 610 StorageUtl_CopyPropertyToSTATSTG( 610 pstatstg, 611 &curProperty, 611 pstatstg, 612 &curProperty, 612 613 grfStatFlag); 613 614 614 615 return S_OK; 615 616 } 616 617 617 618 return E_FAIL; 618 619 } … … 621 622 * Storage32BaseImpl_RenameElement (IStorage) 622 623 * 623 * This method will rename the specified element. 624 * This method will rename the specified element. 624 625 * 625 626 * See Windows documentation for more details on IStorage methods. 626 * 627 * Implementation notes: The method used to rename consists of creating a clone 628 * of the deleted StgProperty object setting it with the new name and to 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 629 630 * perform a DestroyElement of the old StgProperty. 630 631 */ … … 639 640 ULONG foundPropertyIndex; 640 641 641 TRACE("(%p, %s, %s)\n", 642 iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));642 TRACE("(%p, %s, %s)\n", 643 iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName)); 643 644 644 645 /* … … 686 687 * Setup a new property for the renamed property 687 688 */ 688 renamedProperty.sizeOfNameString = 689 renamedProperty.sizeOfNameString = 689 690 ( lstrlenW(pwcsNewName)+1 ) * sizeof(WCHAR); 690 691 691 692 if (renamedProperty.sizeOfNameString > PROPERTY_NAME_BUFFER_LEN) 692 693 return STG_E_INVALIDNAME; 693 694 694 695 strcpyW(renamedProperty.name, pwcsNewName); 695 696 696 697 renamedProperty.propertyType = currentProperty.propertyType; 697 698 renamedProperty.startingBlock = currentProperty.startingBlock; 698 699 renamedProperty.size.s.LowPart = currentProperty.size.s.LowPart; 699 700 renamedProperty.size.s.HighPart = currentProperty.size.s.HighPart; 700 701 701 702 renamedProperty.previousProperty = PROPERTY_NULL; 702 703 renamedProperty.nextProperty = PROPERTY_NULL; 703 704 704 705 /* 705 706 * Bring the dirProperty link in case it is a storage and in which … … 707 708 */ 708 709 renamedProperty.dirProperty = currentProperty.dirProperty; 709 710 /* call CoFileTime to get the current time 710 711 /* call CoFileTime to get the current time 711 712 renamedProperty.timeStampS1 712 713 renamedProperty.timeStampD1 713 714 renamedProperty.timeStampS2 714 715 renamedProperty.timeStampD2 715 renamedProperty.propertyUniqueID 716 renamedProperty.propertyUniqueID 716 717 */ 717 718 /* 718 719 /* 719 720 * Obtain a free property in the property chain 720 721 */ 721 722 renamedPropertyIndex = getFreeProperty(This->ancestorStorage); 722 723 723 724 /* 724 725 * Save the new property into the new property spot 725 */ 726 */ 726 727 StorageImpl_WriteProperty( 727 728 This->ancestorStorage, 728 renamedPropertyIndex, 729 renamedPropertyIndex, 729 730 &renamedProperty); 730 731 /* 731 732 /* 732 733 * Find a spot in the property chain for our newly created property. 733 734 */ 734 735 updatePropertyChain( 735 736 (StorageImpl*)This, 736 renamedPropertyIndex, 737 renamedPropertyIndex, 737 738 renamedProperty); 738 739 739 740 /* 740 * At this point the renamed property has been inserted in the tree, 741 * now, before to Destroy the old property we must zeroed it's dirProperty 742 * otherwise the DestroyProperty below will zap it all and we do not want 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 743 744 * this to happen. 744 745 * Also, we fake that the old property is a storage so the DestroyProperty 745 746 * will not do a SetSize(0) on the stream data. 746 * 747 * 747 748 * This means that we need to tweek the StgProperty if it is a stream or a 748 749 * non empty storage. … … 756 757 StorageImpl_WriteProperty( 757 758 This->ancestorStorage, 758 foundPropertyIndex, 759 foundPropertyIndex, 759 760 ¤tProperty); 760 761 761 /* 762 * Invoke Destroy to get rid of the ole property and automatically redo 763 * the linking of it's previous and next members... 764 */ 765 StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 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); 766 767 767 768 } … … 780 781 * Storage32BaseImpl_CreateStream (IStorage) 781 782 * 782 * This method will create a stream object within this storage 783 * This method will create a stream object within this storage 783 784 * 784 785 * See Windows documentation for more details on IStorage methods. … … 798 799 ULONG foundPropertyIndex, newPropertyIndex; 799 800 800 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 801 iface, debugstr_w(pwcsName), grfMode, 802 reserved1, reserved2, ppstm);801 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 802 iface, debugstr_w(pwcsName), grfMode, 803 reserved1, reserved2, ppstm); 803 804 804 805 /* … … 845 846 { 846 847 /* 847 * An element with this name already exists 848 * An element with this name already exists 848 849 */ 849 850 if (grfMode & STGM_CREATE) 850 851 { 851 IStorage_DestroyElement(iface, pwcsName); 852 } 853 else 852 IStorage_DestroyElement(iface, pwcsName); 853 } 854 else 854 855 return STG_E_FILEALREADYEXISTS; 855 856 } 856 857 857 /* 858 * memset the empty property 858 /* 859 * memset the empty property 859 860 */ 860 861 memset(&newStreamProperty, 0, sizeof(StgProperty)); … … 877 878 newStreamProperty.dirProperty = PROPERTY_NULL; 878 879 879 /* call CoFileTime to get the current time 880 /* call CoFileTime to get the current time 880 881 newStreamProperty.timeStampS1 881 882 newStreamProperty.timeStampD1 … … 887 888 888 889 /* 889 * Get a free property or create a new one 890 * Get a free property or create a new one 890 891 */ 891 892 newPropertyIndex = getFreeProperty(This->ancestorStorage); … … 893 894 /* 894 895 * Save the new property into the new property spot 895 */ 896 */ 896 897 StorageImpl_WriteProperty( 897 898 This->ancestorStorage, 898 newPropertyIndex, 899 newPropertyIndex, 899 900 &newStreamProperty); 900 901 901 /* 902 /* 902 903 * Find a spot in the property chain for our newly created property. 903 904 */ 904 905 updatePropertyChain( 905 906 (StorageImpl*)This, 906 newPropertyIndex, 907 newPropertyIndex, 907 908 newStreamProperty); 908 909 909 /* 910 /* 910 911 * Open the stream to return it. 911 912 */ … … 933 934 * Storage32BaseImpl_SetClass (IStorage) 934 935 * 935 * This method will write the specified CLSID in the property of this 936 * This method will write the specified CLSID in the property of this 936 937 * storage. 937 938 * … … 948 949 949 950 TRACE("(%p, %p)\n", iface, clsid); 950 951 951 952 success = StorageImpl_ReadProperty(This->ancestorStorage, 952 953 This->rootPropertySetIndex, … … 969 970 ** Storage32Impl implementation 970 971 */ 971 972 972 973 /************************************************************************ 973 974 * Storage32Impl_CreateStorage (IStorage) … … 977 978 * See Windows documentation for more details on IStorage methods. 978 979 */ 979 HRESULT WINAPI StorageImpl_CreateStorage( 980 HRESULT WINAPI StorageImpl_CreateStorage( 980 981 IStorage* iface, 981 const OLECHAR *pwcsName, /* [string][in] */ 982 DWORD grfMode, /* [in] */ 983 DWORD reserved1, /* [in] */ 984 DWORD reserved2, /* [in] */ 985 IStorage **ppstg) /* [out] */ 982 const OLECHAR *pwcsName, /* [string][in] */ 983 DWORD grfMode, /* [in] */ 984 DWORD reserved1, /* [in] */ 985 DWORD reserved2, /* [in] */ 986 IStorage **ppstg) /* [out] */ 986 987 { 987 988 StorageImpl* const This=(StorageImpl*)iface; … … 994 995 HRESULT hr; 995 996 996 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 997 iface, debugstr_w(pwcsName), grfMode, 998 reserved1, reserved2, ppstg);999 997 TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 998 iface, debugstr_w(pwcsName), grfMode, 999 reserved1, reserved2, ppstg); 1000 1000 1001 /* 1001 1002 * Validate parameters … … 1033 1034 { 1034 1035 /* 1035 * An element with this name already exists 1036 * An element with this name already exists 1036 1037 */ 1037 1038 if (grfMode & STGM_CREATE) 1038 IStorage_DestroyElement(iface, pwcsName); 1039 else 1039 IStorage_DestroyElement(iface, pwcsName); 1040 else 1040 1041 return STG_E_FILEALREADYEXISTS; 1041 1042 } 1042 1043 1043 /* 1044 * memset the empty property 1044 /* 1045 * memset the empty property 1045 1046 */ 1046 1047 memset(&newProperty, 0, sizeof(StgProperty)); … … 1062 1063 newProperty.dirProperty = PROPERTY_NULL; 1063 1064 1064 /* call CoFileTime to get the current time 1065 /* call CoFileTime to get the current time 1065 1066 newProperty.timeStampS1 1066 1067 newProperty.timeStampD1 … … 1071 1072 /* newStorageProperty.propertyUniqueID */ 1072 1073 1073 /* 1074 /* 1074 1075 * Obtain a free property in the property chain 1075 1076 */ … … 1078 1079 /* 1079 1080 * Save the new property into the new property spot 1080 */ 1081 */ 1081 1082 StorageImpl_WriteProperty( 1082 1083 This->ancestorStorage, 1083 newPropertyIndex, 1084 newPropertyIndex, 1084 1085 &newProperty); 1085 1086 1086 /* 1087 /* 1087 1088 * Find a spot in the property chain for our newly created property. 1088 1089 */ 1089 1090 updatePropertyChain( 1090 1091 This, 1091 newPropertyIndex, 1092 newPropertyIndex, 1092 1093 newProperty); 1093 1094 1094 /* 1095 /* 1095 1096 * Open it to get a pointer to return. 1096 1097 */ … … 1109 1110 } 1110 1111 1111 1112 1112 1113 return S_OK; 1113 1114 } … … 1140 1141 if (currentProperty.sizeOfNameString == 0) 1141 1142 { 1142 /* 1143 /* 1143 1144 * The property existis and is available, we found it. 1144 1145 */ … … 1157 1158 } while (newPropertyIndex == PROPERTY_NULL); 1158 1159 1159 /* 1160 * grow the property chain 1160 /* 1161 * grow the property chain 1161 1162 */ 1162 1163 if (! readSuccessful) … … 1168 1169 ULONG blockCount = 0; 1169 1170 1170 /* 1171 * obtain the new count of property blocks 1171 /* 1172 * obtain the new count of property blocks 1172 1173 */ 1173 1174 blockCount = BlockChainStream_GetCount( 1174 1175 storage->ancestorStorage->rootBlockChain)+1; 1175 1176 1176 /* 1177 * initialize the size used by the property stream 1177 /* 1178 * initialize the size used by the property stream 1178 1179 */ 1179 1180 newSize.s.HighPart = 0; 1180 1181 newSize.s.LowPart = storage->bigBlockSize * blockCount; 1181 1182 1182 /* 1183 * add a property block to the property chain 1183 /* 1184 * add a property block to the property chain 1184 1185 */ 1185 1186 BlockChainStream_SetSize(storage->ancestorStorage->rootBlockChain, newSize); 1186 1187 1187 /* 1188 * memset the empty property in order to initialize the unused newly 1188 /* 1189 * memset the empty property in order to initialize the unused newly 1189 1190 * created property 1190 1191 */ 1191 1192 memset(&emptyProperty, 0, sizeof(StgProperty)); 1192 1193 1193 /* 1194 /* 1194 1195 * initialize them 1195 1196 */ 1196 lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 1197 1197 lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 1198 1198 1199 for( 1199 1200 propertyIndex = newPropertyIndex; … … 1203 1204 StorageImpl_WriteProperty( 1204 1205 storage->ancestorStorage, 1205 propertyIndex, 1206 propertyIndex, 1206 1207 &emptyProperty); 1207 1208 } … … 1215 1216 * Internal Method 1216 1217 * 1217 * Case insensitive comparaison of StgProperty.name by first considering 1218 * Case insensitive comparaison of StgProperty.name by first considering 1218 1219 * their size. 1219 1220 * … … 1228 1229 LONG diff = lstrlenW(newProperty) - lstrlenW(currentProperty); 1229 1230 1230 if (diff == 0) 1231 { 1232 /* 1231 if (diff == 0) 1232 { 1233 /* 1233 1234 * We compare the string themselves only when they are of the same lenght 1234 1235 */ … … 1236 1237 } 1237 1238 1238 return diff; 1239 return diff; 1239 1240 } 1240 1241 … … 1248 1249 StorageImpl *storage, 1249 1250 ULONG newPropertyIndex, 1250 StgProperty newProperty) 1251 StgProperty newProperty) 1251 1252 { 1252 1253 StgProperty currentProperty; … … 1261 1262 if (currentProperty.dirProperty != PROPERTY_NULL) 1262 1263 { 1263 /* 1264 /* 1264 1265 * The root storage contains some element, therefore, start the research 1265 1266 * for the appropriate location. … … 1274 1275 1275 1276 /* 1276 * Read 1277 * Read 1277 1278 */ 1278 1279 StorageImpl_ReadProperty(storage->ancestorStorage, … … 1287 1288 { 1288 1289 LONG diff = propertyNameCmp( newProperty.name, currentProperty.name); 1289 1290 1290 1291 if (diff < 0) 1291 1292 { … … 1326 1327 else 1327 1328 { 1328 /*1329 * Trying to insert an item with the same name in the1330 * subtree structure.1331 */1332 assert(FALSE);1329 /* 1330 * Trying to insert an item with the same name in the 1331 * subtree structure. 1332 */ 1333 assert(FALSE); 1333 1334 } 1334 1335 … … 1339 1340 else 1340 1341 { 1341 /* 1342 /* 1342 1343 * The root storage is empty, link the new property to it's dir property 1343 1344 */ … … 1349 1350 } 1350 1351 1351 1352 1352 1353 /************************************************************************* 1353 1354 * CopyTo (IStorage) 1354 1355 */ 1355 HRESULT WINAPI StorageImpl_CopyTo( 1356 HRESULT WINAPI StorageImpl_CopyTo( 1356 1357 IStorage* iface, 1357 DWORD ciidExclude, /* [in] */ 1358 const IID* rgiidExclude, /* [size_is][unique][in] */ 1359 SNB snbExclude, /* [unique][in] */ 1360 IStorage* pstgDest) /* [unique][in] */ 1358 DWORD ciidExclude, /* [in] */ 1359 const IID* rgiidExclude, /* [size_is][unique][in] */ 1360 SNB snbExclude, /* [unique][in] */ 1361 IStorage* pstgDest) /* [unique][in] */ 1361 1362 { 1362 1363 IEnumSTATSTG *elements = 0; … … 1369 1370 FIXME("Exclude option not implemented\n"); 1370 1371 1371 TRACE("(%p, %ld, %p, %p, %p)\n", 1372 iface, ciidExclude, rgiidExclude, 1373 snbExclude, pstgDest);1372 TRACE("(%p, %ld, %p, %p, %p)\n", 1373 iface, ciidExclude, rgiidExclude, 1374 snbExclude, pstgDest); 1374 1375 1375 1376 /* … … 1379 1380 return STG_E_INVALIDPOINTER; 1380 1381 1381 /* 1382 /* 1382 1383 * Enumerate the elements 1383 1384 */ … … 1392 1393 IStorage_Stat( iface, &curElement, STATFLAG_NONAME); 1393 1394 IStorage_SetClass( pstgDest, &curElement.clsid ); 1394 1395 1395 1396 do 1396 1397 { … … 1412 1413 */ 1413 1414 hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL, 1414 STGM_READ|STGM_SHARE_EXCLUSIVE,1415 NULL, 0, &pstgChild );1415 STGM_READ|STGM_SHARE_EXCLUSIVE, 1416 NULL, 0, &pstgChild ); 1416 1417 1417 1418 if (hr != S_OK) … … 1424 1425 if (pstgChild == pstgDest) 1425 1426 { 1426 IEnumSTATSTG_Release(elements);1427 1428 return STG_E_ACCESSDENIED;1427 IEnumSTATSTG_Release(elements); 1428 1429 return STG_E_ACCESSDENIED; 1429 1430 } 1430 1431 1431 1432 /* 1432 1433 * create a new storage in destination storage … … 1434 1435 hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName, 1435 1436 STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE, 1436 0, 0,1437 0, 0, 1437 1438 &pstgTmp ); 1438 1439 /* … … 1445 1446 NULL, 0, &pstgTmp ); 1446 1447 } 1447 1448 1448 1449 if (hr != S_OK) 1449 1450 break; 1450 1451 1451 1452 1452 1453 /* 1453 1454 * do the copy recursively … … 1455 1456 hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude, 1456 1457 snbExclude, pstgTmp ); 1457 1458 1458 1459 IStorage_Release( pstgTmp ); 1459 1460 IStorage_Release( pstgChild ); … … 1476 1477 */ 1477 1478 hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL, 1478 STGM_READ|STGM_SHARE_EXCLUSIVE,1479 0, &pstrChild );1479 STGM_READ|STGM_SHARE_EXCLUSIVE, 1480 0, &pstrChild ); 1480 1481 1481 1482 if (hr != S_OK) … … 1491 1492 */ 1492 1493 IStream_SetSize(pstrTmp, strStat.cbSize); 1493 1494 1494 1495 /* 1495 1496 * do the copy … … 1497 1498 hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize, 1498 1499 NULL, NULL ); 1499 1500 1500 1501 IStream_Release( pstrTmp ); 1501 1502 IStream_Release( pstrChild ); … … 1512 1513 */ 1513 1514 IEnumSTATSTG_Release(elements); 1514 1515 1515 1516 return hr; 1516 1517 } 1517 1518 1518 1519 /************************************************************************* 1519 1520 * MoveElementTo (IStorage) 1520 1521 */ 1521 HRESULT WINAPI StorageImpl_MoveElementTo( 1522 HRESULT WINAPI StorageImpl_MoveElementTo( 1522 1523 IStorage* iface, 1523 const OLECHAR *pwcsName, /* [string][in] */ 1524 IStorage *pstgDest, /* [unique][in] */ 1525 const OLECHAR *pwcsNewName,/* [string][in] */ 1526 DWORD grfFlags) /* [in] */ 1524 const OLECHAR *pwcsName, /* [string][in] */ 1525 IStorage *pstgDest, /* [unique][in] */ 1526 const OLECHAR *pwcsNewName,/* [string][in] */ 1527 DWORD grfFlags) /* [in] */ 1527 1528 { 1528 1529 FIXME("not implemented!\n"); 1529 1530 return E_NOTIMPL; 1530 1531 } 1531 1532 1532 1533 /************************************************************************* 1533 1534 * Commit (IStorage) 1534 1535 */ 1535 HRESULT WINAPI StorageImpl_Commit( 1536 HRESULT WINAPI StorageImpl_Commit( 1536 1537 IStorage* iface, 1537 DWORD grfCommitFlags)/* [in] */ 1538 DWORD grfCommitFlags)/* [in] */ 1538 1539 { 1539 1540 FIXME("(%ld): stub!\n", grfCommitFlags); 1540 1541 return S_OK; 1541 1542 } 1542 1543 1543 1544 /************************************************************************* 1544 1545 * Revert (IStorage) 1545 1546 */ 1546 HRESULT WINAPI StorageImpl_Revert( 1547 HRESULT WINAPI StorageImpl_Revert( 1547 1548 IStorage* iface) 1548 1549 { … … 1554 1555 * DestroyElement (IStorage) 1555 1556 * 1556 * Stategy: This implementation is build this way for simplicity not for speed. 1557 * Stategy: This implementation is build this way for simplicity not for speed. 1557 1558 * I always delete the top most element of the enumeration and adjust 1558 * the deleted element pointer all the time. This takes longer to 1559 * do but allow to reinvoke DestroyElement whenever we encounter a 1559 * the deleted element pointer all the time. This takes longer to 1560 * do but allow to reinvoke DestroyElement whenever we encounter a 1560 1561 * storage object. The optimisation reside in the usage of another 1561 * enumeration stategy that would give all the leaves of a storage 1562 * enumeration stategy that would give all the leaves of a storage 1562 1563 * first. (postfix order) 1563 1564 */ 1564 HRESULT WINAPI StorageImpl_DestroyElement( 1565 HRESULT WINAPI StorageImpl_DestroyElement( 1565 1566 IStorage* iface, 1566 const OLECHAR *pwcsName)/* [string][in] */ 1567 const OLECHAR *pwcsName)/* [string][in] */ 1567 1568 { 1568 1569 StorageImpl* const This=(StorageImpl*)iface; … … 1577 1578 ULONG parentPropertyId; 1578 1579 1579 TRACE("(%p, %s)\n", 1580 iface, debugstr_w(pwcsName));1580 TRACE("(%p, %s)\n", 1581 iface, debugstr_w(pwcsName)); 1581 1582 1582 1583 /* 1583 1584 * Perform a sanity check on the parameters. 1584 1585 */ 1585 if (pwcsName==NULL) 1586 if (pwcsName==NULL) 1586 1587 return STG_E_INVALIDPOINTER; 1587 1588 1588 1589 /* 1589 1590 * Create a property enumeration to search the property with the given name 1590 1591 */ 1591 1592 propertyEnumeration = IEnumSTATSTGImpl_Construct( 1592 This->ancestorStorage, 1593 This->ancestorStorage, 1593 1594 This->rootPropertySetIndex); 1594 1595 1595 1596 foundPropertyIndexToDelete = IEnumSTATSTGImpl_FindProperty( 1596 1597 propertyEnumeration, … … 1600 1601 IEnumSTATSTGImpl_Destroy(propertyEnumeration); 1601 1602 1602 if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 1603 if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 1603 1604 { 1604 1605 return STG_E_FILENOTFOUND; 1605 1606 } 1606 1607 1607 /* 1608 * Find the parent property of the property to delete (the one that 1609 * link to it). If This->dirProperty == foundPropertyIndexToDelete, 1608 /* 1609 * Find the parent property of the property to delete (the one that 1610 * link to it). If This->dirProperty == foundPropertyIndexToDelete, 1610 1611 * the parent is This. Otherwise, the parent is one of it's sibling... 1611 1612 */ 1612 1613 1613 /* 1614 /* 1614 1615 * First, read This's StgProperty.. 1615 1616 */ 1616 res = StorageImpl_ReadProperty( 1617 res = StorageImpl_ReadProperty( 1617 1618 This->ancestorStorage, 1618 1619 This->rootPropertySetIndex, … … 1621 1622 assert(res==TRUE); 1622 1623 1623 /* 1624 /* 1624 1625 * Second, check to see if by any chance the actual storage (This) is not 1625 1626 * the parent of the property to delete... We never know... … … 1627 1628 if ( parentProperty.dirProperty == foundPropertyIndexToDelete ) 1628 1629 { 1629 /* 1630 /* 1630 1631 * Set data as it would have been done in the else part... 1631 1632 */ … … 1633 1634 parentPropertyId = This->rootPropertySetIndex; 1634 1635 } 1635 else 1636 { 1637 /* 1638 * Create a property enumeration to search the parent properties, and 1636 else 1637 { 1638 /* 1639 * Create a property enumeration to search the parent properties, and 1639 1640 * delete it once done. 1640 1641 */ … … 1642 1643 1643 1644 propertyEnumeration2 = IEnumSTATSTGImpl_Construct( 1644 This->ancestorStorage, 1645 This->ancestorStorage, 1645 1646 This->rootPropertySetIndex); 1646 1647 1647 1648 typeOfRelation = IEnumSTATSTGImpl_FindParentProperty( 1648 1649 propertyEnumeration2, … … 1654 1655 } 1655 1656 1656 if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 1657 if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 1657 1658 { 1658 1659 hr = deleteStorageProperty( 1659 This, 1660 This, 1660 1661 foundPropertyIndexToDelete, 1661 1662 propertyToDelete); 1662 } 1663 } 1663 1664 else if ( propertyToDelete.propertyType == PROPTYPE_STREAM ) 1664 1665 { 1665 1666 hr = deleteStreamProperty( 1666 This, 1667 This, 1667 1668 foundPropertyIndexToDelete, 1668 1669 propertyToDelete); 1669 1670 } 1670 1671 1671 if (hr!=S_OK) 1672 if (hr!=S_OK) 1672 1673 return hr; 1673 1674 … … 1677 1678 hr = adjustPropertyChain( 1678 1679 This, 1679 propertyToDelete, 1680 propertyToDelete, 1680 1681 parentProperty, 1681 1682 parentPropertyId, … … 1721 1722 } 1722 1723 1723 /* 1724 /* 1724 1725 * Enumerate the elements 1725 1726 */ … … 1735 1736 { 1736 1737 destroyHr = StorageImpl_DestroyElement( 1737 (IStorage*)childStorage, 1738 (IStorage*)childStorage, 1738 1739 (OLECHAR*)currentElement.pwcsName); 1739 1740 … … 1760 1761 IStorage_Release(childStorage); 1761 1762 IEnumSTATSTG_Release(elements); 1762 1763 1763 1764 return destroyHr; 1764 1765 } … … 1790 1791 0, 1791 1792 &pis); 1792 1793 1793 1794 if (hr!=S_OK) 1794 1795 { … … 1796 1797 } 1797 1798 1798 /* 1799 * Zap the stream 1800 */ 1801 hr = IStream_SetSize(pis, size); 1799 /* 1800 * Zap the stream 1801 */ 1802 hr = IStream_SetSize(pis, size); 1802 1803 1803 1804 if(hr != S_OK) … … 1811 1812 IStream_Release(pis); 1812 1813 1813 /* 1814 /* 1814 1815 * Invalidate the property by zeroing it's name member. 1815 1816 */ 1816 1817 propertyToDelete.sizeOfNameString = 0; 1817 1818 1818 /* 1819 /* 1819 1820 * Here we should re-read the property so we get the updated pointer 1820 1821 * but since we are here to zap it, I don't do it... 1821 1822 */ 1822 1823 StorageImpl_WriteProperty( 1823 parentStorage->ancestorStorage, 1824 parentStorage->ancestorStorage, 1824 1825 indexOfPropertyToDelete, 1825 1826 &propertyToDelete); … … 1850 1851 res = StorageImpl_ReadProperty( 1851 1852 storage->ancestorStorage, 1852 storePropertyIndex, 1853 storePropertyIndex, 1853 1854 &storeProperty); 1854 1855 … … 1864 1865 return findPlaceholder( 1865 1866 storage, 1866 propertyIndexToStore, 1867 propertyIndexToStore, 1867 1868 storeProperty.previousProperty, 1868 1869 typeOfRelation); … … 1879 1880 return findPlaceholder( 1880 1881 storage, 1881 propertyIndexToStore, 1882 propertyIndexToStore, 1882 1883 storeProperty.nextProperty, 1883 1884 typeOfRelation); … … 1887 1888 storeProperty.nextProperty = propertyIndexToStore; 1888 1889 } 1889 } 1890 } 1890 1891 else if (typeOfRelation == PROPERTY_RELATION_DIR) 1891 1892 { … … 1894 1895 return findPlaceholder( 1895 1896 storage, 1896 propertyIndexToStore, 1897 propertyIndexToStore, 1897 1898 storeProperty.dirProperty, 1898 1899 typeOfRelation); … … 1906 1907 hr = StorageImpl_WriteProperty( 1907 1908 storage->ancestorStorage, 1908 storePropertyIndex, 1909 storePropertyIndex, 1909 1910 &storeProperty); 1910 1911 … … 1921 1922 * Internal Method 1922 1923 * 1923 * This method takes the previous and the next property link of a property 1924 * This method takes the previous and the next property link of a property 1924 1925 * to be deleted and find them a place in the Storage. 1925 1926 */ 1926 static HRESULT adjustPropertyChain( 1927 static HRESULT adjustPropertyChain( 1927 1928 StorageImpl *This, 1928 1929 StgProperty propertyToDelete, … … 1938 1939 HRESULT hr = S_OK; 1939 1940 BOOL res = TRUE; 1940 1941 if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 1942 { 1943 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1944 { 1945 /* 1941 1942 if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 1943 { 1944 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1945 { 1946 /* 1946 1947 * Set the parent previous to the property to delete previous 1947 1948 */ 1948 1949 newLinkProperty = propertyToDelete.previousProperty; 1949 1950 1950 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1951 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1951 1952 { 1952 1953 /* 1953 * We also need to find a storage for the other link, setup variables 1954 * We also need to find a storage for the other link, setup variables 1954 1955 * to do this at the end... 1955 */ 1956 */ 1956 1957 needToFindAPlaceholder = TRUE; 1957 1958 storeNode = propertyToDelete.previousProperty; … … 1959 1960 relationType = PROPERTY_RELATION_NEXT; 1960 1961 } 1961 } 1962 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1963 { 1964 /* 1962 } 1963 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1964 { 1965 /* 1965 1966 * Set the parent previous to the property to delete next 1966 1967 */ 1967 1968 newLinkProperty = propertyToDelete.nextProperty; 1968 1969 } 1969 1970 /* 1970 1971 /* 1971 1972 * Link it for real... 1972 */ 1973 */ 1973 1974 parentProperty.previousProperty = newLinkProperty; 1974 1975 } 1976 else if (typeOfRelation == PROPERTY_RELATION_NEXT) 1977 { 1978 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1979 { 1980 /* 1975 1976 } 1977 else if (typeOfRelation == PROPERTY_RELATION_NEXT) 1978 { 1979 if (propertyToDelete.previousProperty != PROPERTY_NULL) 1980 { 1981 /* 1981 1982 * Set the parent next to the property to delete next previous 1982 1983 */ 1983 1984 newLinkProperty = propertyToDelete.previousProperty; 1984 1985 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1985 1986 if (propertyToDelete.nextProperty != PROPERTY_NULL) 1986 1987 { 1987 1988 /* 1988 * We also need to find a storage for the other link, setup variables 1989 * We also need to find a storage for the other link, setup variables 1989 1990 * to do this at the end... 1990 */ 1991 */ 1991 1992 needToFindAPlaceholder = TRUE; 1992 1993 storeNode = propertyToDelete.previousProperty; … … 1994 1995 relationType = PROPERTY_RELATION_NEXT; 1995 1996 } 1996 } 1997 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1998 { 1999 /* 1997 } 1998 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 1999 { 2000 /* 2000 2001 * Set the parent next to the property to delete next 2001 2002 */ … … 2003 2004 } 2004 2005 2005 /* 2006 /* 2006 2007 * Link it for real... 2007 */ 2008 */ 2008 2009 parentProperty.nextProperty = newLinkProperty; 2009 } 2010 } 2010 2011 else /* (typeOfRelation == PROPERTY_RELATION_DIR) */ 2011 2012 { 2012 if (propertyToDelete.previousProperty != PROPERTY_NULL) 2013 { 2014 /* 2013 if (propertyToDelete.previousProperty != PROPERTY_NULL) 2014 { 2015 /* 2015 2016 * Set the parent dir to the property to delete previous 2016 2017 */ 2017 2018 newLinkProperty = propertyToDelete.previousProperty; 2018 2019 2019 if (propertyToDelete.nextProperty != PROPERTY_NULL) 2020 if (propertyToDelete.nextProperty != PROPERTY_NULL) 2020 2021 { 2021 2022 /* 2022 * We also need to find a storage for the other link, setup variables 2023 * We also need to find a storage for the other link, setup variables 2023 2024 * to do this at the end... 2024 */ 2025 */ 2025 2026 needToFindAPlaceholder = TRUE; 2026 2027 storeNode = propertyToDelete.previousProperty; … … 2028 2029 relationType = PROPERTY_RELATION_NEXT; 2029 2030 } 2030 } 2031 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 2032 { 2033 /* 2031 } 2032 else if (propertyToDelete.nextProperty != PROPERTY_NULL) 2033 { 2034 /* 2034 2035 * Set the parent dir to the property to delete next 2035 2036 */ … … 2037 2038 } 2038 2039 2039 /* 2040 /* 2040 2041 * Link it for real... 2041 */ 2042 */ 2042 2043 parentProperty.dirProperty = newLinkProperty; 2043 2044 } 2044 2045 2045 /* 2046 * Write back the parent property 2046 /* 2047 * Write back the parent property 2047 2048 */ 2048 2049 res = StorageImpl_WriteProperty( 2049 This->ancestorStorage, 2050 This->ancestorStorage, 2050 2051 parentPropertyId, 2051 2052 &parentProperty); … … 2056 2057 2057 2058 /* 2058 * If a placeholder is required for the other link, then, find one and 2059 * If a placeholder is required for the other link, then, find one and 2059 2060 * get out of here... 2060 2061 */ 2061 if (needToFindAPlaceholder) 2062 if (needToFindAPlaceholder) 2062 2063 { 2063 2064 hr = findPlaceholder( 2064 This, 2065 toStoreNode, 2065 This, 2066 toStoreNode, 2066 2067 storeNode, 2067 2068 relationType); … … 2075 2076 * SetElementTimes (IStorage) 2076 2077 */ 2077 HRESULT WINAPI StorageImpl_SetElementTimes( 2078 HRESULT WINAPI StorageImpl_SetElementTimes( 2078 2079 IStorage* iface, 2079 const OLECHAR *pwcsName,/* [string][in] */ 2080 const FILETIME *pctime, /* [in] */ 2081 const FILETIME *patime, /* [in] */ 2082 const FILETIME *pmtime) /* [in] */ 2080 const OLECHAR *pwcsName,/* [string][in] */ 2081 const FILETIME *pctime, /* [in] */ 2082 const FILETIME *patime, /* [in] */ 2083 const FILETIME *pmtime) /* [in] */ 2083 2084 { 2084 2085 FIXME("not implemented!\n"); … … 2089 2090 * SetStateBits (IStorage) 2090 2091 */ 2091 HRESULT WINAPI StorageImpl_SetStateBits( 2092 HRESULT WINAPI StorageImpl_SetStateBits( 2092 2093 IStorage* iface, 2093 DWORD grfStateBits,/* [in] */ 2094 DWORD grfMask) /* [in] */ 2094 DWORD grfStateBits,/* [in] */ 2095 DWORD grfMask) /* [in] */ 2095 2096 { 2096 2097 FIXME("not implemented!\n"); … … 2110 2111 BOOL readSuccessful; 2111 2112 ULONG currentPropertyIndex; 2112 2113 2113 2114 if ( FAILED( validateSTGM(openFlags) )) 2114 2115 return STG_E_INVALIDFLAG; 2115 2116 2116 2117 memset(This, 0, sizeof(StorageImpl)); 2117 2118 2118 2119 /* 2119 2120 * Initialize the virtual fgunction table. … … 2121 2122 ICOM_VTBL(This) = &Storage32Impl_Vtbl; 2122 2123 This->v_destructor = &StorageImpl_Destroy; 2123 2124 2124 2125 /* 2125 2126 * This is the top-level storage so initialize the ancester pointer … … 2127 2128 */ 2128 2129 This->ancestorStorage = This; 2129 2130 2130 2131 /* 2131 2132 * Initialize the physical support of the storage. 2132 2133 */ 2133 2134 This->hFile = hFile; 2134 2135 2135 2136 /* 2136 2137 * Initialize the big block cache. … … 2146 2147 if (This->bigBlockFile == 0) 2147 2148 return E_FAIL; 2148 2149 2149 2150 if (fileCreate) 2150 2151 { … … 2158 2159 * - There is no small block depot 2159 2160 */ 2160 memset( This->bigBlockDepotStart, 2161 BLOCK_UNUSED, 2161 memset( This->bigBlockDepotStart, 2162 BLOCK_UNUSED, 2162 2163 sizeof(This->bigBlockDepotStart)); 2163 2164 … … 2213 2214 */ 2214 2215 This->prevFreeBlock = 0; 2215 2216 2216 2217 /* 2217 2218 * Create the block chain abstractions. 2218 2219 */ 2219 This->rootBlockChain = 2220 This->rootBlockChain = 2220 2221 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL); 2221 2222 2222 2223 This->smallBlockDepotChain = BlockChainStream_Construct( 2223 This, 2224 &This->smallBlockDepotStart, 2224 This, 2225 &This->smallBlockDepotStart, 2225 2226 PROPERTY_NULL); 2226 2227 2227 2228 /* 2228 * Write the root property 2229 * Write the root property 2229 2230 */ 2230 2231 if (fileCreate) … … 2253 2254 */ 2254 2255 currentPropertyIndex = 0; 2255 2256 2256 2257 do 2257 2258 { 2258 2259 readSuccessful = StorageImpl_ReadProperty( 2259 This, 2260 currentPropertyIndex, 2260 This, 2261 currentPropertyIndex, 2261 2262 ¤tProperty); 2262 2263 2263 2264 if (readSuccessful) 2264 2265 { … … 2271 2272 2272 2273 currentPropertyIndex++; 2273 2274 2274 2275 } while (readSuccessful && (This->rootPropertySetIndex == PROPERTY_NULL) ); 2275 2276 2276 2277 if (!readSuccessful) 2277 2278 { … … 2284 2285 */ 2285 2286 This->smallBlockRootChain = BlockChainStream_Construct( 2286 This, 2287 NULL, 2287 This, 2288 NULL, 2288 2289 This->rootPropertySetIndex); 2289 2290 2290 2291 return hr; 2291 2292 } … … 2820 2821 2821 2822 StorageUtl_ReadWord( 2822 headerBigBlock, 2823 OFFSET_BIGBLOCKSIZEBITS, 2823 headerBigBlock, 2824 OFFSET_BIGBLOCKSIZEBITS, 2824 2825 &This->bigBlockSizeBits); 2825 2826 2826 2827 StorageUtl_ReadWord( 2827 headerBigBlock, 2828 OFFSET_SMALLBLOCKSIZEBITS, 2828 headerBigBlock, 2829 OFFSET_SMALLBLOCKSIZEBITS, 2829 2830 &This->smallBlockSizeBits); 2830 2831 2831 2832 StorageUtl_ReadDWord( 2832 headerBigBlock, 2833 OFFSET_BBDEPOTCOUNT, 2833 headerBigBlock, 2834 OFFSET_BBDEPOTCOUNT, 2834 2835 &This->bigBlockDepotCount); 2835 2836 2836 2837 StorageUtl_ReadDWord( 2837 headerBigBlock, 2838 OFFSET_ROOTSTARTBLOCK, 2838 headerBigBlock, 2839 OFFSET_ROOTSTARTBLOCK, 2839 2840 &This->rootStartBlock); 2840 2841 2841 2842 StorageUtl_ReadDWord( 2842 headerBigBlock, 2843 OFFSET_SBDEPOTSTART, 2843 headerBigBlock, 2844 OFFSET_SBDEPOTSTART, 2844 2845 &This->smallBlockDepotStart); 2845 2846 2846 StorageUtl_ReadDWord( 2847 headerBigBlock, 2848 OFFSET_EXTBBDEPOTSTART, 2847 StorageUtl_ReadDWord( 2848 headerBigBlock, 2849 OFFSET_EXTBBDEPOTSTART, 2849 2850 &This->extBigBlockDepotStart); 2850 2851 2851 2852 StorageUtl_ReadDWord( 2852 headerBigBlock, 2853 OFFSET_EXTBBDEPOTCOUNT, 2853 headerBigBlock, 2854 OFFSET_EXTBBDEPOTCOUNT, 2854 2855 &This->extBigBlockDepotCount); 2855 2856 2856 2857 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 2857 2858 { 2858 2859 StorageUtl_ReadDWord( 2859 headerBigBlock, 2860 headerBigBlock, 2860 2861 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 2861 2862 &(This->bigBlockDepotStart[index])); 2862 2863 } 2863 2864 2864 2865 /* 2865 2866 * Make the bitwise arithmetic to get the size of the blocks in bytes. … … 2875 2876 This->smallBlockSize = 0x000000001 >> (DWORD)This->smallBlockSizeBits; 2876 2877 } 2877 2878 /* 2879 * Right now, the code is making some assumptions about the size of the 2878 2879 /* 2880 * Right now, the code is making some assumptions about the size of the 2880 2881 * blocks, just make sure they are what we're expecting. 2881 2882 */ 2882 assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 2883 assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 2883 2884 (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE)); 2884 2885 2885 2886 /* 2886 2887 * Release the block. … … 2890 2891 hr = S_OK; 2891 2892 } 2892 2893 2893 2894 return hr; 2894 2895 } … … 2910 2911 */ 2911 2912 success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock); 2912 2913 2913 2914 /* 2914 2915 * If the block read failed, the file is probably new. … … 2920 2921 */ 2921 2922 memset(headerBigBlock, 0, BIG_BLOCK_SIZE); 2922 2923 2923 2924 /* 2924 2925 * Initialize the magic number. 2925 2926 */ 2926 2927 memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic)); 2927 2928 2928 2929 /* 2929 2930 * And a bunch of things we don't know what they mean … … 2935 2936 StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001); 2936 2937 } 2937 2938 2938 2939 /* 2939 2940 * Write the information to the header. … … 2942 2943 { 2943 2944 StorageUtl_WriteWord( 2944 headerBigBlock, 2945 OFFSET_BIGBLOCKSIZEBITS, 2945 headerBigBlock, 2946 OFFSET_BIGBLOCKSIZEBITS, 2946 2947 This->bigBlockSizeBits); 2947 2948 2948 2949 StorageUtl_WriteWord( 2949 headerBigBlock, 2950 OFFSET_SMALLBLOCKSIZEBITS, 2950 headerBigBlock, 2951 OFFSET_SMALLBLOCKSIZEBITS, 2951 2952 This->smallBlockSizeBits); 2952 2953 2953 2954 StorageUtl_WriteDWord( 2954 headerBigBlock, 2955 OFFSET_BBDEPOTCOUNT, 2955 headerBigBlock, 2956 OFFSET_BBDEPOTCOUNT, 2956 2957 This->bigBlockDepotCount); 2957 2958 2958 2959 StorageUtl_WriteDWord( 2959 headerBigBlock, 2960 OFFSET_ROOTSTARTBLOCK, 2960 headerBigBlock, 2961 OFFSET_ROOTSTARTBLOCK, 2961 2962 This->rootStartBlock); 2962 2963 2963 2964 StorageUtl_WriteDWord( 2964 headerBigBlock, 2965 OFFSET_SBDEPOTSTART, 2965 headerBigBlock, 2966 OFFSET_SBDEPOTSTART, 2966 2967 This->smallBlockDepotStart); 2967 2968 2968 2969 StorageUtl_WriteDWord( 2969 headerBigBlock, 2970 OFFSET_EXTBBDEPOTSTART, 2970 headerBigBlock, 2971 OFFSET_EXTBBDEPOTSTART, 2971 2972 This->extBigBlockDepotStart); 2972 2973 2973 2974 StorageUtl_WriteDWord( 2974 headerBigBlock, 2975 OFFSET_EXTBBDEPOTCOUNT, 2975 headerBigBlock, 2976 OFFSET_EXTBBDEPOTCOUNT, 2976 2977 This->extBigBlockDepotCount); 2977 2978 … … 2979 2980 { 2980 2981 StorageUtl_WriteDWord( 2981 headerBigBlock, 2982 headerBigBlock, 2982 2983 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 2983 2984 (This->bigBlockDepotStart[index])); 2984 2985 } 2985 2986 } 2986 2987 2987 2988 /* 2988 2989 * Write the big block back to the file. … … 3008 3009 offsetInPropSet.s.HighPart = 0; 3009 3010 offsetInPropSet.s.LowPart = index * PROPSET_BLOCK_SIZE; 3010 3011 3011 3012 readSuccessful = BlockChainStream_ReadAt( 3012 3013 This->rootBlockChain, … … 3015 3016 currentProperty, 3016 3017 &bytesRead); 3017 3018 3018 3019 if (readSuccessful) 3019 3020 { 3020 3021 memset(buffer->name, 0, sizeof(buffer->name)); 3021 3022 memcpy( 3022 buffer->name, 3023 currentProperty+OFFSET_PS_NAME, 3023 buffer->name, 3024 currentProperty+OFFSET_PS_NAME, 3024 3025 PROPERTY_NAME_BUFFER_LEN ); 3025 3026 3026 3027 memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1); 3027 3028 3028 3029 StorageUtl_ReadWord( 3029 currentProperty, 3030 OFFSET_PS_NAMELENGTH, 3030 currentProperty, 3031 OFFSET_PS_NAMELENGTH, 3031 3032 &buffer->sizeOfNameString); 3032 3033 3033 3034 StorageUtl_ReadDWord( 3034 currentProperty, 3035 OFFSET_PS_PREVIOUSPROP, 3035 currentProperty, 3036 OFFSET_PS_PREVIOUSPROP, 3036 3037 &buffer->previousProperty); 3037 3038 3038 3039 StorageUtl_ReadDWord( 3039 currentProperty, 3040 OFFSET_PS_NEXTPROP, 3040 currentProperty, 3041 OFFSET_PS_NEXTPROP, 3041 3042 &buffer->nextProperty); 3042 3043 3043 3044 StorageUtl_ReadDWord( 3044 currentProperty, 3045 OFFSET_PS_DIRPROP, 3045 currentProperty, 3046 OFFSET_PS_DIRPROP, 3046 3047 &buffer->dirProperty); 3047 3048 3048 3049 StorageUtl_ReadGUID( 3049 currentProperty, 3050 OFFSET_PS_GUID, 3050 currentProperty, 3051 OFFSET_PS_GUID, 3051 3052 &buffer->propertyUniqueID); 3052 3053 3053 3054 StorageUtl_ReadDWord( 3054 currentProperty, 3055 OFFSET_PS_TSS1, 3055 currentProperty, 3056 OFFSET_PS_TSS1, 3056 3057 &buffer->timeStampS1); 3057 3058 3058 3059 StorageUtl_ReadDWord( 3059 currentProperty, 3060 OFFSET_PS_TSD1, 3060 currentProperty, 3061 OFFSET_PS_TSD1, 3061 3062 &buffer->timeStampD1); 3062 3063 3063 3064 StorageUtl_ReadDWord( 3064 currentProperty, 3065 OFFSET_PS_TSS2, 3065 currentProperty, 3066 OFFSET_PS_TSS2, 3066 3067 &buffer->timeStampS2); 3067 3068 3068 3069 StorageUtl_ReadDWord( 3069 currentProperty, 3070 OFFSET_PS_TSD2, 3070 currentProperty, 3071 OFFSET_PS_TSD2, 3071 3072 &buffer->timeStampD2); 3072 3073 3073 3074 StorageUtl_ReadDWord( 3074 currentProperty, 3075 OFFSET_PS_STARTBLOCK, 3075 currentProperty, 3076 OFFSET_PS_STARTBLOCK, 3076 3077 &buffer->startingBlock); 3077 3078 3078 3079 StorageUtl_ReadDWord( 3079 currentProperty, 3080 OFFSET_PS_SIZE, 3080 currentProperty, 3081 OFFSET_PS_SIZE, 3081 3082 &buffer->size.s.LowPart); 3082 3083 … … 3106 3107 3107 3108 memcpy( 3108 currentProperty + OFFSET_PS_NAME, 3109 buffer->name, 3109 currentProperty + OFFSET_PS_NAME, 3110 buffer->name, 3110 3111 PROPERTY_NAME_BUFFER_LEN ); 3111 3112 … … 3113 3114 3114 3115 StorageUtl_WriteWord( 3115 currentProperty, 3116 OFFSET_PS_NAMELENGTH, 3116 currentProperty, 3117 OFFSET_PS_NAMELENGTH, 3117 3118 buffer->sizeOfNameString); 3118 3119 3119 3120 StorageUtl_WriteDWord( 3120 currentProperty, 3121 OFFSET_PS_PREVIOUSPROP, 3121 currentProperty, 3122 OFFSET_PS_PREVIOUSPROP, 3122 3123 buffer->previousProperty); 3123 3124 3124 3125 StorageUtl_WriteDWord( 3125 currentProperty, 3126 OFFSET_PS_NEXTPROP, 3126 currentProperty, 3127 OFFSET_PS_NEXTPROP, 3127 3128 buffer->nextProperty); 3128 3129 3129 3130 StorageUtl_WriteDWord( 3130 currentProperty, 3131 OFFSET_PS_DIRPROP, 3131 currentProperty, 3132 OFFSET_PS_DIRPROP, 3132 3133 buffer->dirProperty); 3133 3134 3134 3135 StorageUtl_WriteGUID( 3135 currentProperty, 3136 OFFSET_PS_GUID, 3136 currentProperty, 3137 OFFSET_PS_GUID, 3137 3138 &buffer->propertyUniqueID); 3138 3139 3139 3140 StorageUtl_WriteDWord( 3140 currentProperty, 3141 OFFSET_PS_TSS1, 3141 currentProperty, 3142 OFFSET_PS_TSS1, 3142 3143 buffer->timeStampS1); 3143 3144 3144 3145 StorageUtl_WriteDWord( 3145 currentProperty, 3146 OFFSET_PS_TSD1, 3146 currentProperty, 3147 OFFSET_PS_TSD1, 3147 3148 buffer->timeStampD1); 3148 3149 3149 3150 StorageUtl_WriteDWord( 3150 currentProperty, 3151 OFFSET_PS_TSS2, 3151 currentProperty, 3152 OFFSET_PS_TSS2, 3152 3153 buffer->timeStampS2); 3153 3154 3154 3155 StorageUtl_WriteDWord( 3155 currentProperty, 3156 OFFSET_PS_TSD2, 3156 currentProperty, 3157 OFFSET_PS_TSD2, 3157 3158 buffer->timeStampD2); 3158 3159 3159 3160 StorageUtl_WriteDWord( 3160 currentProperty, 3161 OFFSET_PS_STARTBLOCK, 3161 currentProperty, 3162 OFFSET_PS_STARTBLOCK, 3162 3163 buffer->startingBlock); 3163 3164 3164 3165 StorageUtl_WriteDWord( 3165 currentProperty, 3166 OFFSET_PS_SIZE, 3166 currentProperty, 3167 OFFSET_PS_SIZE, 3167 3168 buffer->size.s.LowPart); 3168 3169 … … 3210 3211 3211 3212 StorageImpl_ReleaseBigBlock(This, bigBlockBuffer); 3212 3213 3213 3214 return TRUE; 3214 3215 } 3215 3216 3216 3217 return FALSE; 3217 3218 } … … 3343 3344 3344 3345 StorageInternalImpl* StorageInternalImpl_Construct( 3345 StorageImpl* ancestorStorage, 3346 StorageImpl* ancestorStorage, 3346 3347 ULONG rootPropertyIndex) 3347 3348 { … … 3394 3395 ** does nothing. 3395 3396 */ 3396 HRESULT WINAPI StorageInternalImpl_Commit( 3397 HRESULT WINAPI StorageInternalImpl_Commit( 3397 3398 IStorage* iface, 3398 DWORD grfCommitFlags) /* [in] */ 3399 DWORD grfCommitFlags) /* [in] */ 3399 3400 { 3400 3401 return S_OK; 3401 3402 } 3402 3403 3403 3404 /****************************************************************************** 3404 3405 ** … … 3408 3409 ** does nothing. 3409 3410 */ 3410 HRESULT WINAPI StorageInternalImpl_Revert( 3411 HRESULT WINAPI StorageInternalImpl_Revert( 3411 3412 IStorage* iface) 3412 3413 { … … 3425 3426 3426 3427 newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl)); 3427 3428 3428 3429 if (newEnumeration!=0) 3429 3430 { … … 3433 3434 ICOM_VTBL(newEnumeration) = &IEnumSTATSTGImpl_Vtbl; 3434 3435 newEnumeration->ref = 0; 3435 3436 3436 3437 /* 3437 3438 * We want to nail-down the reference to the storage in case the … … 3440 3441 newEnumeration->parentStorage = parentStorage; 3441 3442 IStorage_AddRef((IStorage*)newEnumeration->parentStorage); 3442 3443 3443 3444 newEnumeration->firstPropertyNode = firstPropertyNode; 3444 3445 3445 3446 /* 3446 3447 * Initialize the search stack … … 3448 3449 newEnumeration->stackSize = 0; 3449 3450 newEnumeration->stackMaxSize = ENUMSTATSGT_SIZE_INCREMENT; 3450 newEnumeration->stackToVisit = 3451 newEnumeration->stackToVisit = 3451 3452 HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG)*ENUMSTATSGT_SIZE_INCREMENT); 3452 3453 3453 3454 /* 3454 3455 * Make sure the current node of the iterator is the first one. … … 3456 3457 IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration); 3457 3458 } 3458 3459 3459 3460 return newEnumeration; 3460 3461 } … … 3488 3489 * Compare the riid with the interface IDs implemented by this object. 3489 3490 */ 3490 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 3491 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 3491 3492 { 3492 3493 *ppvObject = (IEnumSTATSTG*)This; 3493 3494 } 3494 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 3495 else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 3495 3496 { 3496 3497 *ppvObject = (IEnumSTATSTG*)This; … … 3511 3512 return S_OK; 3512 3513 } 3513 3514 3514 3515 ULONG WINAPI IEnumSTATSTGImpl_AddRef( 3515 3516 IEnumSTATSTG* iface) … … 3520 3521 return This->ref; 3521 3522 } 3522 3523 3523 3524 ULONG WINAPI IEnumSTATSTGImpl_Release( 3524 3525 IEnumSTATSTG* iface) … … 3559 3560 */ 3560 3561 if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) ) 3561 return E_INVALIDARG; 3562 3562 return E_INVALIDARG; 3563 3563 3564 /* 3564 3565 * To avoid the special case, get another pointer to a ULONG value if … … 3567 3568 if (pceltFetched==0) 3568 3569 pceltFetched = &objectFetched; 3569 3570 3570 3571 /* 3571 3572 * Start the iteration, we will iterate until we hit the end of the … … 3579 3580 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3580 3581 3581 while ( ( *pceltFetched < celt) && 3582 while ( ( *pceltFetched < celt) && 3582 3583 ( currentSearchNode!=PROPERTY_NULL) ) 3583 3584 { 3584 /* 3585 /* 3585 3586 * Remove the top node from the stack 3586 3587 */ … … 3591 3592 */ 3592 3593 StorageImpl_ReadProperty(This->parentStorage, 3593 currentSearchNode, 3594 currentSearchNode, 3594 3595 ¤tProperty); 3595 3596 … … 3600 3601 ¤tProperty, 3601 3602 STATFLAG_DEFAULT); 3602 3603 3603 3604 /* 3604 3605 * Step to the next item in the iteration … … 3624 3625 } 3625 3626 3626 3627 3627 3628 HRESULT WINAPI IEnumSTATSTGImpl_Skip( 3628 3629 IEnumSTATSTG* iface, … … 3640 3641 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3641 3642 3642 while ( (objectFetched < celt) && 3643 while ( (objectFetched < celt) && 3643 3644 (currentSearchNode!=PROPERTY_NULL) ) 3644 3645 { 3645 /* 3646 /* 3646 3647 * Remove the top node from the stack 3647 3648 */ … … 3652 3653 */ 3653 3654 StorageImpl_ReadProperty(This->parentStorage, 3654 currentSearchNode, 3655 currentSearchNode, 3655 3656 ¤tProperty); 3656 3657 3657 3658 /* 3658 3659 * Step to the next item in the iteration … … 3676 3677 return S_FALSE; 3677 3678 } 3678 3679 3679 3680 HRESULT WINAPI IEnumSTATSTGImpl_Reset( 3680 3681 IEnumSTATSTG* iface) … … 3695 3696 readSuccessful = StorageImpl_ReadProperty( 3696 3697 This->parentStorage, 3697 This->firstPropertyNode, 3698 This->firstPropertyNode, 3698 3699 &rootProperty); 3699 3700 … … 3710 3711 return S_OK; 3711 3712 } 3712 3713 3713 3714 HRESULT WINAPI IEnumSTATSTGImpl_Clone( 3714 3715 IEnumSTATSTG* iface, … … 3724 3725 if (ppenum==0) 3725 3726 return E_INVALIDARG; 3726 3727 3727 3728 newClone = IEnumSTATSTGImpl_Construct(This->parentStorage, 3728 3729 This->firstPropertyNode); 3729 3730 3730 3731 3731 3732 /* 3732 3733 * The new clone enumeration must point to the same current node as … … 3735 3736 newClone->stackSize = This->stackSize ; 3736 3737 newClone->stackMaxSize = This->stackMaxSize ; 3737 newClone->stackToVisit = 3738 newClone->stackToVisit = 3738 3739 HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * newClone->stackMaxSize); 3739 3740 3740 3741 memcpy( 3741 newClone->stackToVisit, 3742 This->stackToVisit, 3742 newClone->stackToVisit, 3743 This->stackToVisit, 3743 3744 sizeof(ULONG) * newClone->stackSize); 3744 3745 … … 3756 3757 INT IEnumSTATSTGImpl_FindParentProperty( 3757 3758 IEnumSTATSTGImpl *This, 3758 ULONG childProperty, 3759 ULONG childProperty, 3759 3760 StgProperty *currentProperty, 3760 3761 ULONG *thisNodeId) … … 3774 3775 */ 3775 3776 currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE); 3776 3777 3777 3778 3778 3779 while (currentSearchNode!=PROPERTY_NULL) … … 3783 3784 *thisNodeId = currentSearchNode; 3784 3785 3785 /* 3786 /* 3786 3787 * Remove the top node from the stack 3787 3788 */ … … 3793 3794 StorageImpl_ReadProperty( 3794 3795 This->parentStorage, 3795 currentSearchNode, 3796 currentSearchNode, 3796 3797 currentProperty); 3797 3798 3798 3799 if (currentProperty->previousProperty == childProperty) 3799 3800 return PROPERTY_RELATION_PREVIOUS; 3800 3801 3801 else if (currentProperty->nextProperty == childProperty) 3802 else if (currentProperty->nextProperty == childProperty) 3802 3803 return PROPERTY_RELATION_NEXT; 3803 3804 3804 3805 else if (currentProperty->dirProperty == childProperty) 3805 3806 return PROPERTY_RELATION_DIR; 3806 3807 3807 3808 /* 3808 3809 * Push the next search node in the search stack. … … 3833 3834 while (currentSearchNode!=PROPERTY_NULL) 3834 3835 { 3835 /* 3836 /* 3836 3837 * Remove the top node from the stack 3837 3838 */ … … 3842 3843 */ 3843 3844 StorageImpl_ReadProperty(This->parentStorage, 3844 currentSearchNode, 3845 currentSearchNode, 3845 3846 currentProperty); 3846 3847 3847 3848 if ( propertyNameCmp( 3848 (OLECHAR*)currentProperty->name, 3849 (OLECHAR*)currentProperty->name, 3849 3850 (OLECHAR*)lpszPropName) == 0) 3850 3851 return currentSearchNode; … … 3885 3886 3886 3887 This->stackToVisit = HeapReAlloc( 3887 GetProcessHeap(), 3888 GetProcessHeap(), 3888 3889 0, 3889 3890 This->stackToVisit, … … 3899 3900 readSuccessful = StorageImpl_ReadProperty( 3900 3901 This->parentStorage, 3901 nodeToPush, 3902 nodeToPush, 3902 3903 &rootProperty); 3903 3904 … … 3986 3987 else 3987 3988 { 3988 destination->pwcsName = 3989 destination->pwcsName = 3989 3990 CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR)); 3990 3991 3991 3992 strcpyW((LPWSTR)destination->pwcsName, source->name); 3992 3993 } 3993 3994 3994 3995 switch (source->propertyType) 3995 3996 { … … 4003 4004 default: 4004 4005 destination->type = STGTY_STREAM; 4005 break; 4006 break; 4006 4007 } 4007 4008 4008 4009 destination->cbSize = source->size; 4009 /* 4010 /* 4010 4011 currentReturnStruct->mtime = {0}; TODO 4011 4012 currentReturnStruct->ctime = {0}; 4012 currentReturnStruct->atime = {0}; 4013 currentReturnStruct->atime = {0}; 4013 4014 */ 4014 4015 destination->grfMode = 0; 4015 destination->grfLocksSupported = 0; 4016 destination->grfLocksSupported = 0; 4016 4017 destination->clsid = source->propertyUniqueID; 4017 destination->grfStateBits = 0; 4018 destination->reserved = 0; 4018 destination->grfStateBits = 0; 4019 destination->reserved = 0; 4019 4020 } 4020 4021 … … 4024 4025 4025 4026 BlockChainStream* BlockChainStream_Construct( 4026 StorageImpl* parentStorage, 4027 StorageImpl* parentStorage, 4027 4028 ULONG* headOfStreamPlaceHolder, 4028 4029 ULONG propertyIndex) … … 4097 4098 * Returns the number of blocks that comprises this chain. 4098 4099 * This is not the size of the stream as the last block may not be full! 4099 * 4100 * 4100 4101 */ 4101 4102 ULONG BlockChainStream_GetCount(BlockChainStream* This) … … 4111 4112 4112 4113 blockIndex = StorageImpl_GetNextBlockInChain( 4113 This->parentStorage, 4114 This->parentStorage, 4114 4115 blockIndex); 4115 4116 } … … 4119 4120 4120 4121 /****************************************************************************** 4121 * BlockChainStream_ReadAt 4122 * BlockChainStream_ReadAt 4122 4123 * 4123 4124 * Reads a specified number of bytes from this chain at the specified offset. … … 4159 4160 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4160 4161 { 4161 blockIndex = 4162 blockIndex = 4162 4163 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4163 4164 4164 4165 blockNoInSequence--; 4165 4166 } … … 4172 4173 *bytesRead = 0; 4173 4174 bufferWalker = buffer; 4174 4175 4175 4176 while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) ) 4176 4177 { … … 4178 4179 * Calculate how many bytes we can copy from this big block. 4179 4180 */ 4180 bytesToReadInBuffer = 4181 bytesToReadInBuffer = 4181 4182 min(This->parentStorage->bigBlockSize - offsetInBlock, size); 4182 4183 4183 4184 /* 4184 4185 * Copy those bytes to the buffer 4185 4186 */ 4186 bigBlockBuffer = 4187 bigBlockBuffer = 4187 4188 StorageImpl_GetROBigBlock(This->parentStorage, blockIndex); 4188 4189 4189 4190 memcpy(bufferWalker, bigBlockBuffer + offsetInBlock, bytesToReadInBuffer); 4190 4191 4191 4192 StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer); 4192 4193 4193 4194 /* 4194 4195 * Step to the next big block. 4195 4196 */ 4196 blockIndex = 4197 blockIndex = 4197 4198 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4198 4199 … … 4203 4204 4204 4205 } 4205 4206 4206 4207 return (size == 0); 4207 4208 } … … 4248 4249 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4249 4250 { 4250 blockIndex = 4251 blockIndex = 4251 4252 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4252 4253 4253 4254 blockNoInSequence--; 4254 4255 } … … 4268 4269 * Calculate how many bytes we can copy from this big block. 4269 4270 */ 4270 bytesToWrite = 4271 bytesToWrite = 4271 4272 min(This->parentStorage->bigBlockSize - offsetInBlock, size); 4272 4273 4273 4274 /* 4274 4275 * Copy those bytes to the buffer 4275 4276 */ 4276 4277 bigBlockBuffer = StorageImpl_GetBigBlock(This->parentStorage, blockIndex); 4277 4278 4278 4279 memcpy(bigBlockBuffer + offsetInBlock, bufferWalker, bytesToWrite); 4279 4280 4280 4281 StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer); 4281 4282 4282 4283 /* 4283 4284 * Step to the next big block. 4284 4285 */ 4285 blockIndex = 4286 blockIndex = 4286 4287 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4287 4288 … … 4291 4292 offsetInBlock = 0; /* There is no offset on the next block */ 4292 4293 } 4293 4294 4294 4295 return (size == 0); 4295 4296 } … … 4328 4329 while (count < numBlocks) 4329 4330 { 4330 blockIndex = 4331 blockIndex = 4331 4332 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4332 4333 … … 4335 4336 4336 4337 /* Get the next block before marking the new end */ 4337 extraBlock = 4338 extraBlock = 4338 4339 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4339 4340 4340 4341 /* Mark the new end of chain */ 4341 4342 StorageImpl_SetNextBlockInChain( 4342 This->parentStorage, 4343 blockIndex, 4343 This->parentStorage, 4344 blockIndex, 4344 4345 BLOCK_END_OF_CHAIN); 4345 4346 … … 4352 4353 while (extraBlock != BLOCK_END_OF_CHAIN) 4353 4354 { 4354 blockIndex = 4355 blockIndex = 4355 4356 StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock); 4356 4357 … … 4396 4397 4397 4398 StorageImpl_ReadProperty( 4398 This->parentStorage, 4399 This->parentStorage, 4399 4400 This->ownerPropertyIndex, 4400 4401 &chainProp); 4401 4402 4402 chainProp.startingBlock = blockIndex; 4403 chainProp.startingBlock = blockIndex; 4403 4404 4404 4405 StorageImpl_WriteProperty( 4405 This->parentStorage, 4406 This->parentStorage, 4406 4407 This->ownerPropertyIndex, 4407 4408 &chainProp); … … 4452 4453 4453 4454 StorageImpl_SetNextBlockInChain( 4454 This->parentStorage, 4455 currentBlock, 4456 blockIndex);4455 This->parentStorage, 4456 currentBlock, 4457 blockIndex); 4457 4458 4458 4459 StorageImpl_SetNextBlockInChain( 4459 This->parentStorage, 4460 blockIndex, 4461 BLOCK_END_OF_CHAIN);4460 This->parentStorage, 4461 blockIndex, 4462 BLOCK_END_OF_CHAIN); 4462 4463 4463 4464 currentBlock = blockIndex; … … 4480 4481 * TODO: Free the actual blocks in the file when we shrink the chain. 4481 4482 * Currently, the blocks are still in the file. So the file size 4482 * doesn't shrink even if we shrink streams. 4483 * doesn't shrink even if we shrink streams. 4483 4484 */ 4484 4485 BOOL BlockChainStream_SetSize( … … 4497 4498 else 4498 4499 { 4499 ULARGE_INTEGER fileSize = 4500 ULARGE_INTEGER fileSize = 4500 4501 BIGBLOCKFILE_GetSize(This->parentStorage->bigBlockFile); 4501 4502 … … 4506 4507 */ 4507 4508 if ((diff % This->parentStorage->bigBlockSize) != 0) 4508 diff += (This->parentStorage->bigBlockSize - 4509 diff += (This->parentStorage->bigBlockSize - 4509 4510 (diff % This->parentStorage->bigBlockSize) ); 4510 4511 … … 4530 4531 if(This->headOfStreamPlaceHolder == NULL) 4531 4532 { 4532 /* 4533 * This chain is a data stream read the property and return 4533 /* 4534 * This chain is a data stream read the property and return 4534 4535 * the appropriate size 4535 4536 */ … … 4544 4545 { 4545 4546 /* 4546 * this chain is a chain that does not have a property, figure out the 4547 * size by making the product number of used blocks times the 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 4548 4549 * size of them 4549 4550 */ … … 4551 4552 result.s.HighPart = 0; 4552 4553 4553 result.s.LowPart = 4554 BlockChainStream_GetCount(This) * 4554 result.s.LowPart = 4555 BlockChainStream_GetCount(This) * 4555 4556 This->parentStorage->bigBlockSize; 4556 4557 … … 4564 4565 4565 4566 SmallBlockChainStream* SmallBlockChainStream_Construct( 4566 StorageImpl* parentStorage, 4567 StorageImpl* parentStorage, 4567 4568 ULONG propertyIndex) 4568 4569 { … … 4615 4616 * 4616 4617 * Returns the index of the next small block in this chain. 4617 * 4618 * 4618 4619 * Return Values: 4619 4620 * - BLOCK_END_OF_CHAIN: end of this chain … … 4742 4743 else 4743 4744 { 4744 ULONG count = 4745 ULONG count = 4745 4746 BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain); 4746 4747 … … 4753 4754 { 4754 4755 sbdIndex = nextBlock; 4755 nextBlock = 4756 nextBlock = 4756 4757 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex); 4757 4758 } … … 4760 4761 if (sbdIndex != BLOCK_END_OF_CHAIN) 4761 4762 StorageImpl_SetNextBlockInChain( 4762 This->parentStorage, 4763 sbdIndex, 4763 This->parentStorage, 4764 sbdIndex, 4764 4765 newsbdIndex); 4765 4766 4766 4767 StorageImpl_SetNextBlockInChain( 4767 This->parentStorage, 4768 newsbdIndex, 4768 This->parentStorage, 4769 newsbdIndex, 4769 4770 BLOCK_END_OF_CHAIN); 4770 4771 … … 4772 4773 * Initialize all the small blocks to free 4773 4774 */ 4774 smallBlockDepot = 4775 smallBlockDepot = 4775 4776 StorageImpl_GetBigBlock(This->parentStorage, newsbdIndex); 4776 4777 … … 4784 4785 */ 4785 4786 StgProperty rootProp; 4786 ULONG sbStartIndex; 4787 ULONG sbStartIndex; 4787 4788 4788 4789 /* … … 4793 4794 4794 4795 /* 4795 * And allocate the first big block that will contain small blocks 4796 * And allocate the first big block that will contain small blocks 4796 4797 */ 4797 sbStartIndex = 4798 sbStartIndex = 4798 4799 StorageImpl_GetNextFreeBigBlock(This->parentStorage); 4799 4800 4800 4801 StorageImpl_SetNextBlockInChain( 4801 This->parentStorage, 4802 sbStartIndex, 4802 This->parentStorage, 4803 sbStartIndex, 4803 4804 BLOCK_END_OF_CHAIN); 4804 4805 4805 4806 StorageImpl_ReadProperty( 4806 This->parentStorage, 4807 This->parentStorage->rootPropertySetIndex, 4807 This->parentStorage, 4808 This->parentStorage->rootPropertySetIndex, 4808 4809 &rootProp); 4809 4810 … … 4813 4814 4814 4815 StorageImpl_WriteProperty( 4815 This->parentStorage, 4816 This->parentStorage->rootPropertySetIndex, 4816 This->parentStorage, 4817 This->parentStorage->rootPropertySetIndex, 4817 4818 &rootProp); 4818 4819 } … … 4820 4821 } 4821 4822 4822 smallBlocksPerBigBlock = 4823 smallBlocksPerBigBlock = 4823 4824 This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize; 4824 4825 … … 4832 4833 4833 4834 StorageImpl_ReadProperty( 4834 This->parentStorage, 4835 This->parentStorage->rootPropertySetIndex, 4835 This->parentStorage, 4836 This->parentStorage->rootPropertySetIndex, 4836 4837 &rootProp); 4837 4838 4838 if (rootProp.size.s.LowPart < 4839 if (rootProp.size.s.LowPart < 4839 4840 (blocksRequired * This->parentStorage->bigBlockSize)) 4840 4841 { … … 4842 4843 4843 4844 BlockChainStream_SetSize( 4844 This->parentStorage->smallBlockRootChain, 4845 This->parentStorage->smallBlockRootChain, 4845 4846 rootProp.size); 4846 4847 4847 4848 StorageImpl_WriteProperty( 4848 This->parentStorage, 4849 This->parentStorage->rootPropertySetIndex, 4849 This->parentStorage, 4850 This->parentStorage->rootPropertySetIndex, 4850 4851 &rootProp); 4851 4852 } … … 4860 4861 * Reads a specified number of bytes from this chain at the specified offset. 4861 4862 * bytesRead may be NULL. 4862 * Failure will be returned if the specified number of bytes has not been read. 4863 * Failure will be returned if the specified number of bytes has not been read. 4863 4864 */ 4864 4865 BOOL SmallBlockChainStream_ReadAt( … … 4870 4871 { 4871 4872 ULARGE_INTEGER offsetInBigBlockFile; 4872 ULONG blockNoInSequence = 4873 ULONG blockNoInSequence = 4873 4874 offset.s.LowPart / This->parentStorage->smallBlockSize; 4874 4875 … … 4907 4908 * Calculate how many bytes we can copy from this small block. 4908 4909 */ 4909 bytesToReadInBuffer = 4910 bytesToReadInBuffer = 4910 4911 min(This->parentStorage->smallBlockSize - offsetInBlock, size); 4911 4912 … … 4914 4915 */ 4915 4916 offsetInBigBlockFile.s.HighPart = 0; 4916 offsetInBigBlockFile.s.LowPart = 4917 offsetInBigBlockFile.s.LowPart = 4917 4918 blockIndex * This->parentStorage->smallBlockSize; 4918 4919 … … 4958 4959 { 4959 4960 ULARGE_INTEGER offsetInBigBlockFile; 4960 ULONG blockNoInSequence = 4961 ULONG blockNoInSequence = 4961 4962 offset.s.LowPart / This->parentStorage->smallBlockSize; 4962 4963 … … 4966 4967 ULONG bytesWrittenFromBigBlockFile; 4967 4968 BYTE* bufferWalker; 4968 4969 4969 4970 /* 4970 4971 * This should never happen on a small block file. 4971 4972 */ 4972 4973 assert(offset.s.HighPart==0); 4973 4974 4974 4975 /* 4975 4976 * Find the first block in the stream that contains part of the buffer. 4976 4977 */ 4977 4978 blockIndex = SmallBlockChainStream_GetHeadOfChain(This); 4978 4979 4979 4980 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4980 4981 { 4981 4982 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 4982 4983 4983 4984 blockNoInSequence--; 4984 4985 } 4985 4986 4986 4987 /* 4987 4988 * Start writing the buffer. … … 4997 4998 * Calculate how many bytes we can copy to this small block. 4998 4999 */ 4999 bytesToWriteInBuffer = 5000 bytesToWriteInBuffer = 5000 5001 min(This->parentStorage->smallBlockSize - offsetInBlock, size); 5001 5002 5002 5003 /* 5003 5004 * Calculate the offset of the small block in the small block file. 5004 5005 */ 5005 5006 offsetInBigBlockFile.s.HighPart = 0; 5006 offsetInBigBlockFile.s.LowPart = 5007 offsetInBigBlockFile.s.LowPart = 5007 5008 blockIndex * This->parentStorage->smallBlockSize; 5008 5009 5009 5010 offsetInBigBlockFile.s.LowPart += offsetInBlock; 5010 5011 5011 5012 /* 5012 5013 * Write those bytes in the buffer to the small block file. … … 5017 5018 bufferWalker, 5018 5019 &bytesWrittenFromBigBlockFile); 5019 5020 5020 5021 assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer); 5021 5022 5022 5023 /* 5023 5024 * Step to the next big block. … … 5029 5030 offsetInBlock = 0; /* There is no offset on the next block */ 5030 5031 } 5031 5032 5032 5033 return (size == 0); 5033 5034 } … … 5036 5037 * SmallBlockChainStream_Shrink 5037 5038 * 5038 * Shrinks this chain in the small block depot. 5039 * Shrinks this chain in the small block depot. 5039 5040 */ 5040 5041 BOOL SmallBlockChainStream_Shrink( … … 5064 5065 /* 5065 5066 * If the count is 0, we have a special case, the head of the chain was 5066 * just freed. 5067 * just freed. 5067 5068 */ 5068 5069 if (count == 0) … … 5070 5071 StgProperty chainProp; 5071 5072 5072 StorageImpl_ReadProperty(This->parentStorage, 5073 This->ownerPropertyIndex,5074 &chainProp);5073 StorageImpl_ReadProperty(This->parentStorage, 5074 This->ownerPropertyIndex, 5075 &chainProp); 5075 5076 5076 5077 chainProp.startingBlock = BLOCK_END_OF_CHAIN; 5077 5078 5078 5079 StorageImpl_WriteProperty(This->parentStorage, 5079 This->ownerPropertyIndex,5080 &chainProp);5080 This->ownerPropertyIndex, 5081 &chainProp); 5081 5082 5082 5083 /* … … 5092 5093 /* Mark the new end of chain */ 5093 5094 SmallBlockChainStream_SetNextBlockInChain( 5094 This, 5095 blockIndex, 5095 This, 5096 blockIndex, 5096 5097 BLOCK_END_OF_CHAIN); 5097 5098 } … … 5107 5108 } 5108 5109 5109 return TRUE; 5110 return TRUE; 5110 5111 } 5111 5112 … … 5143 5144 blockIndex = chainProp.startingBlock; 5144 5145 SmallBlockChainStream_SetNextBlockInChain( 5145 This, 5146 blockIndex, 5146 This, 5147 blockIndex, 5147 5148 BLOCK_END_OF_CHAIN); 5148 5149 } … … 5177 5178 5178 5179 SmallBlockChainStream_SetNextBlockInChain( 5179 This, 5180 blockIndex, 5180 This, 5181 blockIndex, 5181 5182 BLOCK_END_OF_CHAIN); 5182 5183 … … 5219 5220 * TODO: Free the actual blocks in the file when we shrink the chain. 5220 5221 * Currently, the blocks are still in the file. So the file size 5221 * doesn't shrink even if we shrink streams. 5222 * doesn't shrink even if we shrink streams. 5222 5223 */ 5223 5224 BOOL SmallBlockChainStream_SetSize( … … 5277 5278 WCHAR tempFileName[MAX_PATH]; 5278 5279 5279 TRACE("(%s, %lx, %ld, %p)\n", 5280 debugstr_w(pwcsName), grfMode, 5281 reserved, ppstgOpen);5280 TRACE("(%s, %lx, %ld, %p)\n", 5281 debugstr_w(pwcsName), grfMode, 5282 reserved, ppstgOpen); 5282 5283 5283 5284 /* … … 5325 5326 5326 5327 /* 5327 * Interpret the STGM value grfMode 5328 * Interpret the STGM value grfMode 5328 5329 */ 5329 5330 shareMode = GetShareModeFromSTGM(grfMode); … … 5350 5351 fileAttributes, 5351 5352 0); 5352 5353 5353 5354 if (hFile == INVALID_HANDLE_VALUE) 5354 5355 { … … 5360 5361 */ 5361 5362 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5362 5363 5363 5364 if (newStorage == 0) 5364 5365 return STG_E_INSUFFICIENTMEMORY; … … 5371 5372 TRUE, 5372 5373 TRUE); 5373 5374 5374 5375 if (FAILED(hr)) 5375 5376 { … … 5397 5398 DWORD grfMode, 5398 5399 SNB snbExclude, 5399 DWORD reserved, 5400 DWORD reserved, 5400 5401 IStorage **ppstgOpen) 5401 5402 { … … 5406 5407 DWORD accessMode; 5407 5408 5408 TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 5409 debugstr_w(pwcsName), pstgPriority, grfMode,5410 snbExclude, reserved, ppstgOpen);5409 TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 5410 debugstr_w(pwcsName), pstgPriority, grfMode, 5411 snbExclude, reserved, ppstgOpen); 5411 5412 5412 5413 /* … … 5432 5433 */ 5433 5434 *ppstgOpen = 0; 5434 5435 hFile = CreateFileW( pwcsName, 5435 5436 hFile = CreateFileW( pwcsName, 5436 5437 accessMode, 5437 5438 shareMode, … … 5440 5441 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, 5441 5442 0); 5442 5443 5443 5444 5444 5445 if (hFile==INVALID_HANDLE_VALUE) 5445 5446 { … … 5477 5478 */ 5478 5479 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5479 5480 5480 5481 if (newStorage == 0) 5481 5482 return STG_E_INSUFFICIENTMEMORY; … … 5488 5489 TRUE, 5489 5490 FALSE); 5490 5491 5491 5492 if (FAILED(hr)) 5492 5493 { … … 5496 5497 */ 5497 5498 if(hr == STG_E_INVALIDHEADER) 5498 return STG_E_FILEALREADYEXISTS;5499 return STG_E_FILEALREADYEXISTS; 5499 5500 return hr; 5500 5501 } 5501 5502 5502 5503 /* 5503 5504 * Get an "out" pointer for the caller. … … 5507 5508 (REFIID)&IID_IStorage, 5508 5509 (void**)ppstgOpen); 5509 5510 5510 5511 return hr; 5511 5512 } … … 5559 5560 (void**)ppstgOpen); 5560 5561 5561 return hr; 5562 return hr; 5562 5563 } 5563 5564 … … 5597 5598 */ 5598 5599 newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); 5599 5600 5600 5601 if (newStorage == 0) 5601 5602 return STG_E_INSUFFICIENTMEMORY; … … 5633 5634 HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c ) 5634 5635 { 5635 5636 5636 5637 FIXME("(%p, %p, %p, %p),stub!\n", str, a, b, c); 5637 5638 return FALSE; … … 5684 5685 STATSTG pstatstg; 5685 5686 HRESULT hRes; 5686 5687 5687 5688 TRACE("()\n"); 5688 5689 … … 5707 5708 HRESULT WINAPI OleLoadFromStream(IStream *pStm,REFIID iidInterface,void** ppvObj) 5708 5709 { 5709 CLSID clsid;5710 HRESULT res;5711 LPPERSISTSTREAM xstm;5710 CLSID clsid; 5711 HRESULT res; 5712 LPPERSISTSTREAM xstm; 5712 5713 5713 5714 TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj); … … 5715 5716 res=ReadClassStm(pStm,&clsid); 5716 5717 if (!SUCCEEDED(res)) 5717 return res;5718 return res; 5718 5719 res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj); 5719 5720 if (!SUCCEEDED(res)) 5720 return res;5721 return res; 5721 5722 res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm); 5722 5723 if (!SUCCEEDED(res)) { 5723 IUnknown_Release((IUnknown*)*ppvObj);5724 return res;5724 IUnknown_Release((IUnknown*)*ppvObj); 5725 return res; 5725 5726 } 5726 5727 res=IPersistStream_Load(xstm,pStm); 5727 5728 IPersistStream_Release(xstm); 5728 5729 /* FIXME: all refcounts ok at this point? I think they should be: 5729 * pStm: unchanged5730 * ppvObj: 15731 * xstm: 0 (released)5730 * pStm : unchanged 5731 * ppvObj : 1 5732 * xstm : 0 (released) 5732 5733 */ 5733 5734 return res; … … 5745 5746 CLSID clsid; 5746 5747 HRESULT res; 5747 5748 5748 5749 TRACE("(%p,%p)\n",pPStm,pStm); 5749 5750 … … 5751 5752 5752 5753 if (SUCCEEDED(res)){ 5753 5754 5754 5755 res=WriteClassStm(pStm,&clsid); 5755 5756 … … 5769 5770 * STGM_TRANSACTED 0x00010000 5770 5771 * STGM_SIMPLE 0x08000000 5771 * 5772 * 5772 5773 * STGM_READ 0x00000000 5773 5774 * STGM_WRITE 0x00000001 5774 5775 * STGM_READWRITE 0x00000002 5775 * 5776 * 5776 5777 * STGM_SHARE_DENY_NONE 0x00000040 5777 5778 * STGM_SHARE_DENY_READ 0x00000030 5778 5779 * STGM_SHARE_DENY_WRITE 0x00000020 5779 5780 * STGM_SHARE_EXCLUSIVE 0x00000010 5780 * 5781 * 5781 5782 * STGM_PRIORITY 0x00040000 5782 5783 * STGM_DELETEONRELEASE 0x04000000 … … 5794 5795 BOOL bSTGM_SIMPLE = ((stgm & STGM_SIMPLE) == STGM_SIMPLE); 5795 5796 BOOL bSTGM_DIRECT = ! (bSTGM_TRANSACTED || bSTGM_SIMPLE); 5796 5797 5797 5798 BOOL bSTGM_WRITE = ((stgm & STGM_WRITE) == STGM_WRITE); 5798 5799 BOOL bSTGM_READWRITE = ((stgm & STGM_READWRITE) == STGM_READWRITE); 5799 5800 BOOL bSTGM_READ = ! (bSTGM_WRITE || bSTGM_READWRITE); 5800 5801 5801 5802 BOOL bSTGM_SHARE_DENY_NONE = 5802 5803 ((stgm & STGM_SHARE_DENY_NONE) == STGM_SHARE_DENY_NONE); … … 5813 5814 BOOL bSTGM_CREATE = ((stgm & STGM_CREATE) == STGM_CREATE); 5814 5815 BOOL bSTGM_CONVERT = ((stgm & STGM_CONVERT) == STGM_CONVERT); 5815 5816 5816 5817 BOOL bSTGM_NOSCRATCH = ((stgm & STGM_NOSCRATCH) == STGM_NOSCRATCH); 5817 5818 BOOL bSTGM_NOSNAPSHOT = ((stgm & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT); 5818 5819 5819 /* 5820 /* 5820 5821 * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE 5821 5822 */ … … 5824 5825 return E_FAIL; 5825 5826 5826 /* 5827 /* 5827 5828 * STGM_WRITE | STGM_READWRITE | STGM_READ 5828 5829 */ … … 5832 5833 5833 5834 /* 5834 * STGM_SHARE_DENY_NONE | others 5835 * STGM_SHARE_DENY_NONE | others 5835 5836 * (I assume here that DENY_READ implies DENY_WRITE) 5836 5837 */ 5837 5838 if ( bSTGM_SHARE_DENY_NONE ) 5838 5839 if ( bSTGM_SHARE_DENY_READ || 5839 bSTGM_SHARE_DENY_WRITE || 5840 bSTGM_SHARE_EXCLUSIVE) 5840 bSTGM_SHARE_DENY_WRITE || 5841 bSTGM_SHARE_EXCLUSIVE) 5841 5842 return E_FAIL; 5842 5843 … … 5853 5854 if ( bSTGM_NOSCRATCH && ! bSTGM_TRANSACTED ) 5854 5855 return E_FAIL; 5855 5856 /* 5857 * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 5856 5857 /* 5858 * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 5858 5859 * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE` 5859 5860 */ 5860 5861 if (bSTGM_NOSNAPSHOT) 5861 5862 { 5862 if ( ! ( bSTGM_TRANSACTED && 5863 if ( ! ( bSTGM_TRANSACTED && 5863 5864 !(bSTGM_SHARE_EXCLUSIVE || bSTGM_SHARE_DENY_WRITE)) ) 5864 5865 return E_FAIL; … … 5872 5873 * 5873 5874 * This method will return a share mode flag from a STGM value. 5874 * The STGM value is assumed valid. 5875 * The STGM value is assumed valid. 5875 5876 */ 5876 5877 static DWORD GetShareModeFromSTGM(DWORD stgm) … … 5942 5943 /* All other cases */ 5943 5944 if (stgm & ~ (STGM_CREATE|STGM_CONVERT)) 5944 FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));5945 FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT)); 5945 5946 return CREATE_NEW; 5946 5947 } … … 5948 5949 5949 5950 /************************************************************************* 5950 * OLECONVERT_LoadOLE10 [Internal] 5951 * 5952 * Loads the OLE10 STREAM to memory 5951 * OLECONVERT_LoadOLE10 [Internal] 5952 * 5953 * Loads the OLE10 STREAM to memory 5953 5954 * 5954 5955 * PARAMS … … 5963 5964 * NOTES 5964 5965 * This function is used by OleConvertOLESTREAMToIStorage only. 5965 * 5966 * 5966 5967 * Memory allocated for pData must be freed by the caller 5967 5968 */ 5968 5969 HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1) 5969 5970 { 5970 DWORD dwSize;5971 HRESULT hRes = S_OK;5972 int nTryCnt=0;5973 int max_try = 6;5974 5975 pData->pData = NULL;5976 pData->pstrOleObjFileName = (CHAR *) NULL;5977 5978 for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)5979 {5980 /* Get the OleID */5981 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));5982 if(dwSize != sizeof(pData->dwOleID))5983 {5984 hRes = CONVERT10_E_OLESTREAM_GET;5985 }5986 else if(pData->dwOleID != OLESTREAM_ID)5987 {5988 hRes = CONVERT10_E_OLESTREAM_FMT;5989 }5990 else5991 {5992 hRes = S_OK;5993 break;5994 }5995 }5996 5997 if(hRes == S_OK)5998 {5999 /* Get the TypeID...more info needed for this field */6000 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));6001 if(dwSize != sizeof(pData->dwTypeID))6002 {6003 hRes = CONVERT10_E_OLESTREAM_GET;6004 }6005 }6006 if(hRes == S_OK)6007 {6008 if(pData->dwTypeID != 0)6009 {6010 /* Get the lenght of the OleTypeName */6011 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));6012 if(dwSize != sizeof(pData->dwOleTypeNameLength))6013 {6014 hRes = CONVERT10_E_OLESTREAM_GET;6015 }6016 6017 if(hRes == S_OK)6018 {6019 if(pData->dwOleTypeNameLength > 0)6020 {6021 /* Get the OleTypeName */6022 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);6023 if(dwSize != pData->dwOleTypeNameLength)6024 {6025 hRes = CONVERT10_E_OLESTREAM_GET;6026 }6027 }6028 }6029 if(bStrem1)6030 {6031 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));6032 if(dwSize != sizeof(pData->dwOleObjFileNameLength))6033 {6034 hRes = CONVERT10_E_OLESTREAM_GET;6035 }6036 if(hRes == S_OK)6037 {6038 if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */6039 pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);6040 pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);6041 if(pData->pstrOleObjFileName)6042 {6043 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);6044 if(dwSize != pData->dwOleObjFileNameLength)6045 {6046 hRes = CONVERT10_E_OLESTREAM_GET;6047 }6048 }6049 else6050 hRes = CONVERT10_E_OLESTREAM_GET;6051 }6052 }6053 else6054 {6055 /* Get the Width of the Metafile */6056 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));6057 if(dwSize != sizeof(pData->dwMetaFileWidth))6058 {6059 hRes = CONVERT10_E_OLESTREAM_GET;6060 }6061 if(hRes == S_OK)6062 {6063 /* Get the Height of the Metafile */6064 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));6065 if(dwSize != sizeof(pData->dwMetaFileHeight))6066 {6067 hRes = CONVERT10_E_OLESTREAM_GET;6068 }6069 }6070 }6071 if(hRes == S_OK)6072 {6073 /* Get the Lenght of the Data */6074 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));6075 if(dwSize != sizeof(pData->dwDataLength))6076 {6077 hRes = CONVERT10_E_OLESTREAM_GET;6078 }6079 }6080 6081 if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */6082 {6083 if(!bStrem1) /* if it is a second OLE stream data */6084 {6085 pData->dwDataLength -= 8;6086 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));6087 if(dwSize != sizeof(pData->strUnknown))6088 {6089 hRes = CONVERT10_E_OLESTREAM_GET;6090 }6091 }6092 }6093 if(hRes == S_OK)6094 {6095 if(pData->dwDataLength > 0)6096 {6097 pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);6098 6099 /* Get Data (ex. IStorage, Metafile, or BMP) */6100 if(pData->pData)6101 {6102 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);6103 if(dwSize != pData->dwDataLength)6104 {6105 hRes = CONVERT10_E_OLESTREAM_GET;6106 }6107 }6108 else6109 {6110 hRes = CONVERT10_E_OLESTREAM_GET;6111 }6112 }6113 }6114 }6115 }6116 return hRes;5971 DWORD dwSize; 5972 HRESULT hRes = S_OK; 5973 int nTryCnt=0; 5974 int max_try = 6; 5975 5976 pData->pData = NULL; 5977 pData->pstrOleObjFileName = (CHAR *) NULL; 5978 5979 for( nTryCnt=0;nTryCnt < max_try; nTryCnt++) 5980 { 5981 /* Get the OleID */ 5982 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID)); 5983 if(dwSize != sizeof(pData->dwOleID)) 5984 { 5985 hRes = CONVERT10_E_OLESTREAM_GET; 5986 } 5987 else if(pData->dwOleID != OLESTREAM_ID) 5988 { 5989 hRes = CONVERT10_E_OLESTREAM_FMT; 5990 } 5991 else 5992 { 5993 hRes = S_OK; 5994 break; 5995 } 5996 } 5997 5998 if(hRes == S_OK) 5999 { 6000 /* Get the TypeID...more info needed for this field */ 6001 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID)); 6002 if(dwSize != sizeof(pData->dwTypeID)) 6003 { 6004 hRes = CONVERT10_E_OLESTREAM_GET; 6005 } 6006 } 6007 if(hRes == S_OK) 6008 { 6009 if(pData->dwTypeID != 0) 6010 { 6011 /* Get the lenght of the OleTypeName */ 6012 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength)); 6013 if(dwSize != sizeof(pData->dwOleTypeNameLength)) 6014 { 6015 hRes = CONVERT10_E_OLESTREAM_GET; 6016 } 6017 6018 if(hRes == S_OK) 6019 { 6020 if(pData->dwOleTypeNameLength > 0) 6021 { 6022 /* Get the OleTypeName */ 6023 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength); 6024 if(dwSize != pData->dwOleTypeNameLength) 6025 { 6026 hRes = CONVERT10_E_OLESTREAM_GET; 6027 } 6028 } 6029 } 6030 if(bStrem1) 6031 { 6032 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength)); 6033 if(dwSize != sizeof(pData->dwOleObjFileNameLength)) 6034 { 6035 hRes = CONVERT10_E_OLESTREAM_GET; 6036 } 6037 if(hRes == S_OK) 6038 { 6039 if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */ 6040 pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength); 6041 pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength); 6042 if(pData->pstrOleObjFileName) 6043 { 6044 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength); 6045 if(dwSize != pData->dwOleObjFileNameLength) 6046 { 6047 hRes = CONVERT10_E_OLESTREAM_GET; 6048 } 6049 } 6050 else 6051 hRes = CONVERT10_E_OLESTREAM_GET; 6052 } 6053 } 6054 else 6055 { 6056 /* Get the Width of the Metafile */ 6057 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth)); 6058 if(dwSize != sizeof(pData->dwMetaFileWidth)) 6059 { 6060 hRes = CONVERT10_E_OLESTREAM_GET; 6061 } 6062 if(hRes == S_OK) 6063 { 6064 /* Get the Height of the Metafile */ 6065 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight)); 6066 if(dwSize != sizeof(pData->dwMetaFileHeight)) 6067 { 6068 hRes = CONVERT10_E_OLESTREAM_GET; 6069 } 6070 } 6071 } 6072 if(hRes == S_OK) 6073 { 6074 /* Get the Lenght of the Data */ 6075 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength)); 6076 if(dwSize != sizeof(pData->dwDataLength)) 6077 { 6078 hRes = CONVERT10_E_OLESTREAM_GET; 6079 } 6080 } 6081 6082 if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */ 6083 { 6084 if(!bStrem1) /* if it is a second OLE stream data */ 6085 { 6086 pData->dwDataLength -= 8; 6087 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown)); 6088 if(dwSize != sizeof(pData->strUnknown)) 6089 { 6090 hRes = CONVERT10_E_OLESTREAM_GET; 6091 } 6092 } 6093 } 6094 if(hRes == S_OK) 6095 { 6096 if(pData->dwDataLength > 0) 6097 { 6098 pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength); 6099 6100 /* Get Data (ex. IStorage, Metafile, or BMP) */ 6101 if(pData->pData) 6102 { 6103 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength); 6104 if(dwSize != pData->dwDataLength) 6105 { 6106 hRes = CONVERT10_E_OLESTREAM_GET; 6107 } 6108 } 6109 else 6110 { 6111 hRes = CONVERT10_E_OLESTREAM_GET; 6112 } 6113 } 6114 } 6115 } 6116 } 6117 return hRes; 6117 6118 } 6118 6119 6119 6120 /************************************************************************* 6120 * OLECONVERT_SaveOLE10 [Internal] 6121 * 6122 * Saves the OLE10 STREAM From memory 6121 * OLECONVERT_SaveOLE10 [Internal] 6122 * 6123 * Saves the OLE10 STREAM From memory 6123 6124 * 6124 6125 * PARAMS … … 6132 6133 * NOTES 6133 6134 * This function is used by OleConvertIStorageToOLESTREAM only. 6134 * 6135 * 6135 6136 */ 6136 6137 HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream) … … 6226 6227 6227 6228 /************************************************************************* 6228 * OLECONVERT_GetOLE20FromOLE10[Internal] 6229 * OLECONVERT_GetOLE20FromOLE10[Internal] 6229 6230 * 6230 6231 * This function copies OLE10 Data (the IStorage in the OLESTREAM) to disk, 6231 * opens it, and copies the content to the dest IStorage for 6232 * opens it, and copies the content to the dest IStorage for 6232 6233 * OleConvertOLESTREAMToIStorage 6233 * 6234 * 6234 6235 * 6235 6236 * PARAMS … … 6242 6243 * 6243 6244 * NOTES 6244 * 6245 * 6245 * 6246 * 6246 6247 */ 6247 6248 void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, BYTE *pBuffer, DWORD nBufferLength) … … 6278 6279 6279 6280 /************************************************************************* 6280 * OLECONVERT_WriteOLE20ToBuffer [Internal] 6281 * 6282 * Saves the OLE10 STREAM From memory 6281 * OLECONVERT_WriteOLE20ToBuffer [Internal] 6282 * 6283 * Saves the OLE10 STREAM From memory 6283 6284 * 6284 6285 * PARAMS … … 6293 6294 * 6294 6295 * Used by OleConvertIStorageToOLESTREAM only. 6295 * 6296 * 6296 6297 */ 6297 6298 DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData) … … 6305 6306 6306 6307 *pData = NULL; 6307 6308 6308 6309 /* Create temp Storage */ 6309 6310 GetTempPathW(MAX_PATH, wstrTempDir); … … 6332 6333 6333 6334 /************************************************************************* 6334 * OLECONVERT_CreateOleStream [Internal] 6335 * OLECONVERT_CreateOleStream [Internal] 6335 6336 * 6336 6337 * Creates the "\001OLE" stream in the IStorage if neccessary. … … 6347 6348 * This stream is still unknown, MS Word seems to have extra data 6348 6349 * but since the data is stored in the OLESTREAM there should be 6349 * no need to recreate the stream. If the stream is manually 6350 * no need to recreate the stream. If the stream is manually 6350 6351 * deleted it will create it with this default data. 6351 * 6352 * 6352 6353 */ 6353 6354 void OLECONVERT_CreateOleStream(LPSTORAGE pStorage) … … 6356 6357 IStream *pStream; 6357 6358 WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0}; 6358 BYTE pOleStreamHeader [] = 6359 { 6360 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 6361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6362 0x00, 0x00, 0x00, 0x00 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 6363 6364 }; 6364 6365 6365 6366 /* Create stream if not present */ 6366 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6367 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6367 6368 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6368 6369 … … 6377 6378 6378 6379 /************************************************************************* 6379 * OLECONVERT_CreateCompObjStream [Internal] 6380 * OLECONVERT_CreateCompObjStream [Internal] 6380 6381 * 6381 6382 * Creates a "\001CompObj" is the destination IStorage if necessary. 6382 6383 * 6383 6384 * PARAMS 6384 * pStorage [I] The dest IStorage to create the CompObj Stream 6385 * pStorage [I] The dest IStorage to create the CompObj Stream 6385 6386 * if necessary. 6386 6387 * strOleTypeName [I] The ProgID … … 6394 6395 * 6395 6396 * The stream data is stored in the OLESTREAM and there should be 6396 * no need to recreate the stream. If the stream is manually 6397 * no need to recreate the stream. If the stream is manually 6397 6398 * deleted it will attempt to create it by querying the registry. 6398 6399 * 6399 * 6400 * 6400 6401 */ 6401 6402 HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) … … 6416 6417 6417 6418 /* Create a CompObj stream if it doesn't exist */ 6418 hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 6419 hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 6419 6420 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6420 6421 if(hStorageRes == S_OK) … … 6437 6438 LONG hErr; 6438 6439 /* Get the CLSID Default Name from the Registry */ 6439 hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 6440 hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 6440 6441 if(hErr == ERROR_SUCCESS) 6441 6442 { … … 6479 6480 6480 6481 /************************************************************************* 6481 * OLECONVERT_CreateOlePresStream[Internal] 6482 * OLECONVERT_CreateOlePresStream[Internal] 6482 6483 * 6483 6484 * Creates the "\002OlePres000" Stream with the Metafile data … … 6486 6487 * pStorage [I] The dest IStorage to create \002OLEPres000 stream in. 6487 6488 * dwExtentX [I] Width of the Metafile 6488 * dwExtentY [I] Height of the Metafile 6489 * dwExtentY [I] Height of the Metafile 6489 6490 * pData [I] Metafile data 6490 6491 * dwDataLength [I] Size of the Metafile data … … 6496 6497 * NOTES 6497 6498 * This function is used by OleConvertOLESTREAMToIStorage only. 6498 * 6499 * 6499 6500 */ 6500 6501 void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY , BYTE *pData, DWORD dwDataLength) … … 6503 6504 IStream *pStream; 6504 6505 WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0}; 6505 BYTE pOlePresStreamHeader [] = 6506 { 6507 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 6508 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6506 BYTE pOlePresStreamHeader [] = 6507 { 6508 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 6509 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6509 6510 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 6510 6511 0x00, 0x00, 0x00, 0x00 6511 6512 }; 6512 6513 6513 BYTE pOlePresStreamHeaderEmpty [] = 6514 { 6515 0x00, 0x00, 0x00, 0x00, 6516 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6514 BYTE pOlePresStreamHeaderEmpty [] = 6515 { 6516 0x00, 0x00, 0x00, 0x00, 6517 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 6517 6518 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 6518 6519 0x00, 0x00, 0x00, 0x00 6519 6520 }; 6520 6521 6521 6522 /* Create the OlePres000 Stream */ 6522 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6523 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6523 6524 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6524 6525 … … 6564 6565 6565 6566 /************************************************************************* 6566 * OLECONVERT_CreateOle10NativeStream [Internal] 6567 * OLECONVERT_CreateOle10NativeStream [Internal] 6567 6568 * 6568 6569 * Creates the "\001Ole10Native" Stream (should contain a BMP) … … 6580 6581 * 6581 6582 * Might need to verify the data and return appropriate error message 6582 * 6583 * 6583 6584 */ 6584 6585 void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, BYTE *pData, DWORD dwDataLength) … … 6587 6588 IStream *pStream; 6588 6589 WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0}; 6589 6590 6590 6591 /* Create the Ole10Native Stream */ 6591 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6592 hRes = IStorage_CreateStream(pStorage, wstrStreamName, 6592 6593 STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream ); 6593 6594 … … 6603 6604 6604 6605 /************************************************************************* 6605 * OLECONVERT_GetOLE10ProgID [Internal] 6606 * OLECONVERT_GetOLE10ProgID [Internal] 6606 6607 * 6607 6608 * Finds the ProgID (or OleTypeID) from the IStorage … … 6619 6620 * This function is used by OleConvertIStorageToOLESTREAM only. 6620 6621 * 6621 * 6622 * 6622 6623 */ 6623 6624 HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize) … … 6630 6631 6631 6632 /* Open the CompObj Stream */ 6632 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6633 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6633 6634 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6634 6635 if(hRes == S_OK) … … 6667 6668 *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE); 6668 6669 } 6669 6670 6670 6671 } 6671 6672 return hRes; … … 6673 6674 6674 6675 /************************************************************************* 6675 * OLECONVERT_GetOle10PresData [Internal] 6676 * OLECONVERT_GetOle10PresData [Internal] 6676 6677 * 6677 6678 * Converts IStorage "/001Ole10Native" stream to a OLE10 Stream … … 6688 6689 * 6689 6690 * Memory allocated for pData must be freed by the caller 6690 * 6691 * 6691 * 6692 * 6692 6693 */ 6693 6694 void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData) … … 6709 6710 6710 6711 /* Open Ole10Native Stream */ 6711 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6712 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6712 6713 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6713 6714 if(hRes == S_OK) … … 6728 6729 6729 6730 /************************************************************************* 6730 * OLECONVERT_GetOle20PresData[Internal] 6731 * OLECONVERT_GetOle20PresData[Internal] 6731 6732 * 6732 6733 * Converts IStorage "/002OlePres000" stream to a OLE10 Stream … … 6741 6742 * NOTES 6742 6743 * This function is used by OleConvertIStorageToOLESTREAM only. 6743 * 6744 * 6744 6745 * Memory allocated for pData must be freed by the caller 6745 6746 */ … … 6768 6769 6769 6770 /* Open OlePress000 stream */ 6770 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6771 hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 6771 6772 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream ); 6772 6773 if(hRes == S_OK) … … 6816 6817 6817 6818 /************************************************************************* 6818 * OleConvertOLESTREAMToIStorage [OLE32.87] 6819 * OleConvertOLESTREAMToIStorage [OLE32.87] 6819 6820 * 6820 6821 * Read info on MSDN … … 6825 6826 * Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj", 6826 6827 * and "\001OLE" streams 6827 * 6828 * 6828 6829 */ 6829 6830 HRESULT WINAPI OleConvertOLESTREAMToIStorage ( 6830 LPOLESTREAM pOleStream, 6831 LPSTORAGE pstg, 6831 LPOLESTREAM pOleStream, 6832 LPSTORAGE pstg, 6832 6833 const DVTARGETDEVICE* ptd) 6833 6834 { … … 6901 6902 } 6902 6903 if(pOleStreamData[i].pstrOleObjFileName != NULL) 6903 {6904 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);6905 pOleStreamData[i].pstrOleObjFileName = NULL;6906 }6904 { 6905 HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName); 6906 pOleStreamData[i].pstrOleObjFileName = NULL; 6907 } 6907 6908 } 6908 6909 return hRes; … … 6920 6921 * Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj", 6921 6922 * and "\001OLE" streams. 6922 * 6923 * 6923 6924 */ 6924 6925 HRESULT WINAPI OleConvertIStorageToOLESTREAM ( 6925 LPSTORAGE pstg, 6926 LPSTORAGE pstg, 6926 6927 LPOLESTREAM pOleStream) 6927 6928 { … … 6948 6949 { 6949 6950 /*Was it originaly Ole10 */ 6950 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream); 6951 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream); 6951 6952 if(hRes == S_OK) 6952 6953 { … … 6983 6984 6984 6985 /*********************************************************************** 6985 * GetConvertStg (OLE32.68)6986 * GetConvertStg (OLE32.68) 6986 6987 */ 6987 6988 HRESULT WINAPI GetConvertStg(LPGUID guid) { … … 6997 6998 */ 6998 6999 HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) { 6999 HFILEhf;7000 OFSTRUCTofs;7001 BYTEmagic[24];7002 7003 TRACE("(\'%s\')\n",fn);7004 hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);7005 if (hf==HFILE_ERROR)7006 return STG_E_FILENOTFOUND;7007 if (24!=_lread(hf,magic,24)) {7008 WARN(" too short\n");7009 _lclose(hf);7010 return S_FALSE;7011 }7012 if (!memcmp(magic,STORAGE_magic,8)) {7013 WARN(" -> YES\n");7014 _lclose(hf);7015 return S_OK;7016 }7017 if (!memcmp(magic,STORAGE_notmagic,8)) {7018 WARN(" -> NO\n");7019 _lclose(hf);7020 return S_FALSE;7021 }7022 if (!memcmp(magic,STORAGE_oldmagic,8)) {7023 WARN(" -> old format\n");7024 _lclose(hf);7025 return STG_E_OLDFORMAT;7026 }7027 WARN(" -> Invalid header.\n");7028 _lclose(hf);7029 return STG_E_INVALIDHEADER;7000 HFILE hf; 7001 OFSTRUCT ofs; 7002 BYTE magic[24]; 7003 7004 TRACE("(\'%s\')\n",fn); 7005 hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE); 7006 if (hf==HFILE_ERROR) 7007 return STG_E_FILENOTFOUND; 7008 if (24!=_lread(hf,magic,24)) { 7009 WARN(" too short\n"); 7010 _lclose(hf); 7011 return S_FALSE; 7012 } 7013 if (!memcmp(magic,STORAGE_magic,8)) { 7014 WARN(" -> YES\n"); 7015 _lclose(hf); 7016 return S_OK; 7017 } 7018 if (!memcmp(magic,STORAGE_notmagic,8)) { 7019 WARN(" -> NO\n"); 7020 _lclose(hf); 7021 return S_FALSE; 7022 } 7023 if (!memcmp(magic,STORAGE_oldmagic,8)) { 7024 WARN(" -> old format\n"); 7025 _lclose(hf); 7026 return STG_E_OLDFORMAT; 7027 } 7028 WARN(" -> Invalid header.\n"); 7029 _lclose(hf); 7030 return STG_E_INVALIDHEADER; 7030 7031 } 7031 7032 … … 7033 7034 * StgIsStorageFile [OLE32.146] 7034 7035 */ 7035 HRESULT WINAPI 7036 StgIsStorageFile(LPCOLESTR fn) 7037 { 7038 LPOLESTR16xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);7039 HRESULTret = StgIsStorageFile16(xfn);7040 7041 HeapFree(GetProcessHeap(),0,xfn);7042 return ret;7036 HRESULT WINAPI 7037 StgIsStorageFile(LPCOLESTR fn) 7038 { 7039 LPOLESTR16 xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn); 7040 HRESULT ret = StgIsStorageFile16(xfn); 7041 7042 HeapFree(GetProcessHeap(),0,xfn); 7043 return ret; 7043 7044 } 7044 7045 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
