Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenoleaut.c
Go to the documentation of this file.
00001 /* 00002 * OLEAUT32 00003 * 00004 * Copyright 1999, 2000 Marcus Meissner 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include <stdarg.h> 00022 #include <string.h> 00023 #include <limits.h> 00024 00025 #define COBJMACROS 00026 00027 #include "windef.h" 00028 #include "winbase.h" 00029 #include "wingdi.h" 00030 #include "winuser.h" 00031 #include "winerror.h" 00032 00033 #include "ole2.h" 00034 #include "olectl.h" 00035 #include "oleauto.h" 00036 #include "typelib.h" 00037 00038 #include "wine/debug.h" 00039 00040 WINE_DEFAULT_DEBUG_CHANNEL(ole); 00041 00042 static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */ 00043 00044 /****************************************************************************** 00045 * BSTR {OLEAUT32} 00046 * 00047 * NOTES 00048 * BSTR is a simple typedef for a wide-character string used as the principle 00049 * string type in ole automation. When encapsulated in a Variant type they are 00050 * automatically copied and destroyed as the variant is processed. 00051 * 00052 * The low level BSTR Api allows manipulation of these strings and is used by 00053 * higher level Api calls to manage the strings transparently to the caller. 00054 * 00055 * Internally the BSTR type is allocated with space for a DWORD byte count before 00056 * the string data begins. This is undocumented and non-system code should not 00057 * access the count directly. Use SysStringLen() or SysStringByteLen() 00058 * instead. Note that the byte count does not include the terminating NUL. 00059 * 00060 * To create a new BSTR, use SysAllocString(), SysAllocStringLen() or 00061 * SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString() 00062 * or SysReAllocStringLen(). Finally to destroy a string use SysFreeString(). 00063 * 00064 * BSTR's are cached by Ole Automation by default. To override this behaviour 00065 * either set the environment variable 'OANOCACHE', or call SetOaNoCache(). 00066 * 00067 * SEE ALSO 00068 * 'Inside OLE, second edition' by Kraig Brockshmidt. 00069 */ 00070 00071 /****************************************************************************** 00072 * SysStringLen [OLEAUT32.7] 00073 * 00074 * Get the allocated length of a BSTR in wide characters. 00075 * 00076 * PARAMS 00077 * str [I] BSTR to find the length of 00078 * 00079 * RETURNS 00080 * The allocated length of str, or 0 if str is NULL. 00081 * 00082 * NOTES 00083 * See BSTR. 00084 * The returned length may be different from the length of the string as 00085 * calculated by lstrlenW(), since it returns the length that was used to 00086 * allocate the string by SysAllocStringLen(). 00087 */ 00088 UINT WINAPI SysStringLen(BSTR str) 00089 { 00090 DWORD* bufferPointer; 00091 00092 if (!str) return 0; 00093 /* 00094 * The length of the string (in bytes) is contained in a DWORD placed 00095 * just before the BSTR pointer 00096 */ 00097 bufferPointer = (DWORD*)str; 00098 00099 bufferPointer--; 00100 00101 return (int)(*bufferPointer/sizeof(WCHAR)); 00102 } 00103 00104 /****************************************************************************** 00105 * SysStringByteLen [OLEAUT32.149] 00106 * 00107 * Get the allocated length of a BSTR in bytes. 00108 * 00109 * PARAMS 00110 * str [I] BSTR to find the length of 00111 * 00112 * RETURNS 00113 * The allocated length of str, or 0 if str is NULL. 00114 * 00115 * NOTES 00116 * See SysStringLen(), BSTR(). 00117 */ 00118 UINT WINAPI SysStringByteLen(BSTR str) 00119 { 00120 DWORD* bufferPointer; 00121 00122 if (!str) return 0; 00123 /* 00124 * The length of the string (in bytes) is contained in a DWORD placed 00125 * just before the BSTR pointer 00126 */ 00127 bufferPointer = (DWORD*)str; 00128 00129 bufferPointer--; 00130 00131 return (int)(*bufferPointer); 00132 } 00133 00134 /****************************************************************************** 00135 * SysAllocString [OLEAUT32.2] 00136 * 00137 * Create a BSTR from an OLESTR. 00138 * 00139 * PARAMS 00140 * str [I] Source to create BSTR from 00141 * 00142 * RETURNS 00143 * Success: A BSTR allocated with SysAllocStringLen(). 00144 * Failure: NULL, if oleStr is NULL. 00145 * 00146 * NOTES 00147 * See BSTR. 00148 * MSDN (October 2001) incorrectly states that NULL is returned if oleStr has 00149 * a length of 0. Native Win32 and this implementation both return a valid 00150 * empty BSTR in this case. 00151 */ 00152 BSTR WINAPI SysAllocString(LPCOLESTR str) 00153 { 00154 if (!str) return 0; 00155 00156 /* Delegate this to the SysAllocStringLen32 method. */ 00157 return SysAllocStringLen(str, lstrlenW(str)); 00158 } 00159 00160 /****************************************************************************** 00161 * SysFreeString [OLEAUT32.6] 00162 * 00163 * Free a BSTR. 00164 * 00165 * PARAMS 00166 * str [I] BSTR to free. 00167 * 00168 * RETURNS 00169 * Nothing. 00170 * 00171 * NOTES 00172 * See BSTR. 00173 * str may be NULL, in which case this function does nothing. 00174 */ 00175 void WINAPI SysFreeString(BSTR str) 00176 { 00177 DWORD* bufferPointer; 00178 00179 /* NULL is a valid parameter */ 00180 if(!str) return; 00181 00182 /* 00183 * We have to be careful when we free a BSTR pointer, it points to 00184 * the beginning of the string but it skips the byte count contained 00185 * before the string. 00186 */ 00187 bufferPointer = (DWORD*)str; 00188 00189 bufferPointer--; 00190 00191 /* 00192 * Free the memory from its "real" origin. 00193 */ 00194 HeapFree(GetProcessHeap(), 0, bufferPointer); 00195 } 00196 00197 /****************************************************************************** 00198 * SysAllocStringLen [OLEAUT32.4] 00199 * 00200 * Create a BSTR from an OLESTR of a given wide character length. 00201 * 00202 * PARAMS 00203 * str [I] Source to create BSTR from 00204 * len [I] Length of oleStr in wide characters 00205 * 00206 * RETURNS 00207 * Success: A newly allocated BSTR from SysAllocStringByteLen() 00208 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails. 00209 * 00210 * NOTES 00211 * See BSTR(), SysAllocStringByteLen(). 00212 */ 00213 BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len) 00214 { 00215 DWORD bufferSize; 00216 DWORD* newBuffer; 00217 WCHAR* stringBuffer; 00218 00219 /* Detect integer overflow. */ 00220 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR))) 00221 return NULL; 00222 /* 00223 * Find the length of the buffer passed-in, in bytes. 00224 */ 00225 bufferSize = len * sizeof (WCHAR); 00226 00227 /* 00228 * Allocate a new buffer to hold the string. 00229 * don't forget to keep an empty spot at the beginning of the 00230 * buffer for the character count and an extra character at the 00231 * end for the NULL. 00232 */ 00233 newBuffer = HeapAlloc(GetProcessHeap(), 0, 00234 bufferSize + sizeof(WCHAR) + sizeof(DWORD)); 00235 00236 /* 00237 * If the memory allocation failed, return a null pointer. 00238 */ 00239 if (!newBuffer) 00240 return NULL; 00241 00242 /* 00243 * Copy the length of the string in the placeholder. 00244 */ 00245 *newBuffer = bufferSize; 00246 00247 /* 00248 * Skip the byte count. 00249 */ 00250 newBuffer++; 00251 00252 /* 00253 * Copy the information in the buffer. 00254 * Since it is valid to pass a NULL pointer here, we'll initialize the 00255 * buffer to nul if it is the case. 00256 */ 00257 if (str != 0) 00258 memcpy(newBuffer, str, bufferSize); 00259 else 00260 memset(newBuffer, 0, bufferSize); 00261 00262 /* 00263 * Make sure that there is a nul character at the end of the 00264 * string. 00265 */ 00266 stringBuffer = (WCHAR*)newBuffer; 00267 stringBuffer[len] = '\0'; 00268 00269 return stringBuffer; 00270 } 00271 00272 /****************************************************************************** 00273 * SysReAllocStringLen [OLEAUT32.5] 00274 * 00275 * Change the length of a previously created BSTR. 00276 * 00277 * PARAMS 00278 * old [O] BSTR to change the length of 00279 * str [I] New source for pbstr 00280 * len [I] Length of oleStr in wide characters 00281 * 00282 * RETURNS 00283 * Success: 1. The size of pbstr is updated. 00284 * Failure: 0, if len >= 0x80000000 or memory allocation fails. 00285 * 00286 * NOTES 00287 * See BSTR(), SysAllocStringByteLen(). 00288 * *old may be changed by this function. 00289 */ 00290 int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len) 00291 { 00292 /* Detect integer overflow. */ 00293 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR))) 00294 return 0; 00295 00296 if (*old!=NULL) { 00297 BSTR old_copy = *old; 00298 DWORD newbytelen = len*sizeof(WCHAR); 00299 DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD)); 00300 *old = (BSTR)(ptr+1); 00301 *ptr = newbytelen; 00302 /* Subtle hidden feature: The old string data is still there 00303 * when 'in' is NULL! 00304 * Some Microsoft program needs it. 00305 */ 00306 if (str && old_copy!=str) memmove(*old, str, newbytelen); 00307 (*old)[len] = 0; 00308 } else { 00309 /* 00310 * Allocate the new string 00311 */ 00312 *old = SysAllocStringLen(str, len); 00313 } 00314 00315 return 1; 00316 } 00317 00318 /****************************************************************************** 00319 * SysAllocStringByteLen [OLEAUT32.150] 00320 * 00321 * Create a BSTR from an OLESTR of a given byte length. 00322 * 00323 * PARAMS 00324 * str [I] Source to create BSTR from 00325 * len [I] Length of oleStr in bytes 00326 * 00327 * RETURNS 00328 * Success: A newly allocated BSTR 00329 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails. 00330 * 00331 * NOTES 00332 * -If len is 0 or oleStr is NULL the resulting string is empty (""). 00333 * -This function always NUL terminates the resulting BSTR. 00334 * -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied 00335 * without checking for a terminating NUL. 00336 * See BSTR. 00337 */ 00338 BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len) 00339 { 00340 DWORD* newBuffer; 00341 char* stringBuffer; 00342 00343 /* Detect integer overflow. */ 00344 if (len >= (UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))) 00345 return NULL; 00346 00347 /* 00348 * Allocate a new buffer to hold the string. 00349 * don't forget to keep an empty spot at the beginning of the 00350 * buffer for the character count and an extra character at the 00351 * end for the NULL. 00352 */ 00353 newBuffer = HeapAlloc(GetProcessHeap(), 0, 00354 len + sizeof(WCHAR) + sizeof(DWORD)); 00355 00356 /* 00357 * If the memory allocation failed, return a null pointer. 00358 */ 00359 if (newBuffer==0) 00360 return 0; 00361 00362 /* 00363 * Copy the length of the string in the placeholder. 00364 */ 00365 *newBuffer = len; 00366 00367 /* 00368 * Skip the byte count. 00369 */ 00370 newBuffer++; 00371 00372 /* 00373 * Copy the information in the buffer. 00374 * Since it is valid to pass a NULL pointer here, we'll initialize the 00375 * buffer to nul if it is the case. 00376 */ 00377 if (str != 0) 00378 memcpy(newBuffer, str, len); 00379 00380 /* 00381 * Make sure that there is a nul character at the end of the 00382 * string. 00383 */ 00384 stringBuffer = (char *)newBuffer; 00385 stringBuffer[len] = 0; 00386 stringBuffer[len+1] = 0; 00387 00388 return (LPWSTR)stringBuffer; 00389 } 00390 00391 /****************************************************************************** 00392 * SysReAllocString [OLEAUT32.3] 00393 * 00394 * Change the length of a previously created BSTR. 00395 * 00396 * PARAMS 00397 * old [I/O] BSTR to change the length of 00398 * str [I] New source for pbstr 00399 * 00400 * RETURNS 00401 * Success: 1 00402 * Failure: 0. 00403 * 00404 * NOTES 00405 * See BSTR(), SysAllocStringStringLen(). 00406 */ 00407 INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str) 00408 { 00409 /* 00410 * Sanity check 00411 */ 00412 if (old==NULL) 00413 return 0; 00414 00415 /* 00416 * Make sure we free the old string. 00417 */ 00418 SysFreeString(*old); 00419 00420 /* 00421 * Allocate the new string 00422 */ 00423 *old = SysAllocString(str); 00424 00425 return 1; 00426 } 00427 00428 /****************************************************************************** 00429 * SetOaNoCache (OLEAUT32.327) 00430 * 00431 * Instruct Ole Automation not to cache BSTR allocations. 00432 * 00433 * PARAMS 00434 * None. 00435 * 00436 * RETURNS 00437 * Nothing. 00438 * 00439 * NOTES 00440 * See BSTR. 00441 */ 00442 void WINAPI SetOaNoCache(void) 00443 { 00444 BSTR_bCache = FALSE; 00445 } 00446 00447 static const WCHAR _delimiter[2] = {'!',0}; /* default delimiter apparently */ 00448 static const WCHAR *pdelimiter = &_delimiter[0]; 00449 00450 /*********************************************************************** 00451 * RegisterActiveObject (OLEAUT32.33) 00452 * 00453 * Registers an object in the global item table. 00454 * 00455 * PARAMS 00456 * punk [I] Object to register. 00457 * rcid [I] CLSID of the object. 00458 * dwFlags [I] Flags. 00459 * pdwRegister [O] Address to store cookie of object registration in. 00460 * 00461 * RETURNS 00462 * Success: S_OK. 00463 * Failure: HRESULT code. 00464 */ 00465 HRESULT WINAPI RegisterActiveObject( 00466 LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister 00467 ) { 00468 WCHAR guidbuf[80]; 00469 HRESULT ret; 00470 LPRUNNINGOBJECTTABLE runobtable; 00471 LPMONIKER moniker; 00472 00473 StringFromGUID2(rcid,guidbuf,39); 00474 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker); 00475 if (FAILED(ret)) 00476 return ret; 00477 ret = GetRunningObjectTable(0,&runobtable); 00478 if (FAILED(ret)) { 00479 IMoniker_Release(moniker); 00480 return ret; 00481 } 00482 ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister); 00483 IRunningObjectTable_Release(runobtable); 00484 IMoniker_Release(moniker); 00485 return ret; 00486 } 00487 00488 /*********************************************************************** 00489 * RevokeActiveObject (OLEAUT32.34) 00490 * 00491 * Revokes an object from the global item table. 00492 * 00493 * PARAMS 00494 * xregister [I] Registration cookie. 00495 * reserved [I] Reserved. Set to NULL. 00496 * 00497 * RETURNS 00498 * Success: S_OK. 00499 * Failure: HRESULT code. 00500 */ 00501 HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved) 00502 { 00503 LPRUNNINGOBJECTTABLE runobtable; 00504 HRESULT ret; 00505 00506 ret = GetRunningObjectTable(0,&runobtable); 00507 if (FAILED(ret)) return ret; 00508 ret = IRunningObjectTable_Revoke(runobtable,xregister); 00509 if (SUCCEEDED(ret)) ret = S_OK; 00510 IRunningObjectTable_Release(runobtable); 00511 return ret; 00512 } 00513 00514 /*********************************************************************** 00515 * GetActiveObject (OLEAUT32.35) 00516 * 00517 * Gets an object from the global item table. 00518 * 00519 * PARAMS 00520 * rcid [I] CLSID of the object. 00521 * preserved [I] Reserved. Set to NULL. 00522 * ppunk [O] Address to store object into. 00523 * 00524 * RETURNS 00525 * Success: S_OK. 00526 * Failure: HRESULT code. 00527 */ 00528 HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk) 00529 { 00530 WCHAR guidbuf[80]; 00531 HRESULT ret; 00532 LPRUNNINGOBJECTTABLE runobtable; 00533 LPMONIKER moniker; 00534 00535 StringFromGUID2(rcid,guidbuf,39); 00536 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker); 00537 if (FAILED(ret)) 00538 return ret; 00539 ret = GetRunningObjectTable(0,&runobtable); 00540 if (FAILED(ret)) { 00541 IMoniker_Release(moniker); 00542 return ret; 00543 } 00544 ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk); 00545 IRunningObjectTable_Release(runobtable); 00546 IMoniker_Release(moniker); 00547 return ret; 00548 } 00549 00550 00551 /*********************************************************************** 00552 * OaBuildVersion [OLEAUT32.170] 00553 * 00554 * Get the Ole Automation build version. 00555 * 00556 * PARAMS 00557 * None 00558 * 00559 * RETURNS 00560 * The build version. 00561 * 00562 * NOTES 00563 * Known oleaut32.dll versions: 00564 *| OLE Ver. Comments Date Build Ver. 00565 *| -------- ------------------------- ---- --------- 00566 *| OLE 2.1 NT 1993-95 10 3023 00567 *| OLE 2.1 10 3027 00568 *| Win32s Ver 1.1e 20 4049 00569 *| OLE 2.20 W95/NT 1993-96 20 4112 00570 *| OLE 2.20 W95/NT 1993-96 20 4118 00571 *| OLE 2.20 W95/NT 1993-96 20 4122 00572 *| OLE 2.30 W95/NT 1993-98 30 4265 00573 *| OLE 2.40 NT?? 1993-98 40 4267 00574 *| OLE 2.40 W98 SE orig. file 1993-98 40 4275 00575 *| OLE 2.40 W2K orig. file 1993-XX 40 4514 00576 * 00577 * Currently the versions returned are 2.20 for Win3.1, 2.30 for Win95 & NT 3.51, 00578 * and 2.40 for all later versions. The build number is maximum, i.e. 0xffff. 00579 */ 00580 ULONG WINAPI OaBuildVersion(void) 00581 { 00582 switch(GetVersion() & 0x8000ffff) /* mask off build number */ 00583 { 00584 case 0x80000a03: /* WIN31 */ 00585 return MAKELONG(0xffff, 20); 00586 case 0x00003303: /* NT351 */ 00587 return MAKELONG(0xffff, 30); 00588 case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor 00589 version here (30), but as we still use w95 00590 as default winver (which is good IMHO), I better 00591 play safe and use the latest value for w95 for now. 00592 Change this as soon as default winver gets changed 00593 to something more recent */ 00594 case 0x80000a04: /* WIN98 */ 00595 case 0x00000004: /* NT40 */ 00596 case 0x00000005: /* W2K */ 00597 case 0x00000105: /* WinXP */ 00598 return MAKELONG(0xffff, 40); 00599 default: 00600 FIXME("Version value not known yet. Please investigate it !\n"); 00601 return MAKELONG(0xffff, 40); /* for now return the same value as for w2k */ 00602 } 00603 } 00604 00605 /****************************************************************************** 00606 * OleTranslateColor [OLEAUT32.421] 00607 * 00608 * Convert an OLE_COLOR to a COLORREF. 00609 * 00610 * PARAMS 00611 * clr [I] Color to convert 00612 * hpal [I] Handle to a palette for the conversion 00613 * pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok 00614 * 00615 * RETURNS 00616 * Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL. 00617 * Failure: E_INVALIDARG, if any argument is invalid. 00618 * 00619 * FIXME 00620 * Document the conversion rules. 00621 */ 00622 HRESULT WINAPI OleTranslateColor( 00623 OLE_COLOR clr, 00624 HPALETTE hpal, 00625 COLORREF* pColorRef) 00626 { 00627 COLORREF colorref; 00628 BYTE b = HIBYTE(HIWORD(clr)); 00629 00630 TRACE("(%08x, %p, %p)\n", clr, hpal, pColorRef); 00631 00632 /* 00633 * In case pColorRef is NULL, provide our own to simplify the code. 00634 */ 00635 if (pColorRef == NULL) 00636 pColorRef = &colorref; 00637 00638 switch (b) 00639 { 00640 case 0x00: 00641 { 00642 if (hpal != 0) 00643 *pColorRef = PALETTERGB(GetRValue(clr), 00644 GetGValue(clr), 00645 GetBValue(clr)); 00646 else 00647 *pColorRef = clr; 00648 00649 break; 00650 } 00651 00652 case 0x01: 00653 { 00654 if (hpal != 0) 00655 { 00656 PALETTEENTRY pe; 00657 /* 00658 * Validate the palette index. 00659 */ 00660 if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0) 00661 return E_INVALIDARG; 00662 } 00663 00664 *pColorRef = clr; 00665 00666 break; 00667 } 00668 00669 case 0x02: 00670 *pColorRef = clr; 00671 break; 00672 00673 case 0x80: 00674 { 00675 int index = LOBYTE(LOWORD(clr)); 00676 00677 /* 00678 * Validate GetSysColor index. 00679 */ 00680 if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR)) 00681 return E_INVALIDARG; 00682 00683 *pColorRef = GetSysColor(index); 00684 00685 break; 00686 } 00687 00688 default: 00689 return E_INVALIDARG; 00690 } 00691 00692 return S_OK; 00693 } 00694 00695 extern HRESULT WINAPI OLEAUTPS_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN; 00696 extern BOOL WINAPI OLEAUTPS_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN; 00697 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; 00698 00699 extern void _get_STDFONT_CF(LPVOID *); 00700 extern void _get_STDPIC_CF(LPVOID *); 00701 00702 static HRESULT WINAPI PSDispatchFacBuf_QueryInterface(IPSFactoryBuffer *iface, REFIID riid, void **ppv) 00703 { 00704 if (IsEqualIID(riid, &IID_IUnknown) || 00705 IsEqualIID(riid, &IID_IPSFactoryBuffer)) 00706 { 00707 IUnknown_AddRef(iface); 00708 *ppv = iface; 00709 return S_OK; 00710 } 00711 return E_NOINTERFACE; 00712 } 00713 00714 static ULONG WINAPI PSDispatchFacBuf_AddRef(IPSFactoryBuffer *iface) 00715 { 00716 return 2; 00717 } 00718 00719 static ULONG WINAPI PSDispatchFacBuf_Release(IPSFactoryBuffer *iface) 00720 { 00721 return 1; 00722 } 00723 00724 static HRESULT WINAPI PSDispatchFacBuf_CreateProxy(IPSFactoryBuffer *iface, IUnknown *pUnkOuter, REFIID riid, IRpcProxyBuffer **ppProxy, void **ppv) 00725 { 00726 IPSFactoryBuffer *pPSFB; 00727 HRESULT hr; 00728 00729 if (IsEqualIID(riid, &IID_IDispatch)) 00730 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB); 00731 else 00732 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB); 00733 00734 if (FAILED(hr)) return hr; 00735 00736 hr = IPSFactoryBuffer_CreateProxy(pPSFB, pUnkOuter, riid, ppProxy, ppv); 00737 00738 IPSFactoryBuffer_Release(pPSFB); 00739 return hr; 00740 } 00741 00742 static HRESULT WINAPI PSDispatchFacBuf_CreateStub(IPSFactoryBuffer *iface, REFIID riid, IUnknown *pUnkOuter, IRpcStubBuffer **ppStub) 00743 { 00744 IPSFactoryBuffer *pPSFB; 00745 HRESULT hr; 00746 00747 if (IsEqualIID(riid, &IID_IDispatch)) 00748 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB); 00749 else 00750 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB); 00751 00752 if (FAILED(hr)) return hr; 00753 00754 hr = IPSFactoryBuffer_CreateStub(pPSFB, riid, pUnkOuter, ppStub); 00755 00756 IPSFactoryBuffer_Release(pPSFB); 00757 return hr; 00758 } 00759 00760 static const IPSFactoryBufferVtbl PSDispatchFacBuf_Vtbl = 00761 { 00762 PSDispatchFacBuf_QueryInterface, 00763 PSDispatchFacBuf_AddRef, 00764 PSDispatchFacBuf_Release, 00765 PSDispatchFacBuf_CreateProxy, 00766 PSDispatchFacBuf_CreateStub 00767 }; 00768 00769 /* This is the whole PSFactoryBuffer object, just the vtableptr */ 00770 static const IPSFactoryBufferVtbl *pPSDispatchFacBuf = &PSDispatchFacBuf_Vtbl; 00771 00772 /*********************************************************************** 00773 * DllGetClassObject (OLEAUT32.@) 00774 */ 00775 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) 00776 { 00777 *ppv = NULL; 00778 if (IsEqualGUID(rclsid,&CLSID_StdFont)) { 00779 if (IsEqualGUID(iid,&IID_IClassFactory)) { 00780 _get_STDFONT_CF(ppv); 00781 IClassFactory_AddRef((IClassFactory*)*ppv); 00782 return S_OK; 00783 } 00784 } 00785 if (IsEqualGUID(rclsid,&CLSID_StdPicture)) { 00786 if (IsEqualGUID(iid,&IID_IClassFactory)) { 00787 _get_STDPIC_CF(ppv); 00788 IClassFactory_AddRef((IClassFactory*)*ppv); 00789 return S_OK; 00790 } 00791 } 00792 if (IsEqualCLSID(rclsid, &CLSID_PSDispatch) && IsEqualIID(iid, &IID_IPSFactoryBuffer)) { 00793 *ppv = &pPSDispatchFacBuf; 00794 IPSFactoryBuffer_AddRef((IPSFactoryBuffer *)*ppv); 00795 return S_OK; 00796 } 00797 if (IsEqualGUID(rclsid,&CLSID_PSOAInterface)) { 00798 if (S_OK==TMARSHAL_DllGetClassObject(rclsid,iid,ppv)) 00799 return S_OK; 00800 /*FALLTHROUGH*/ 00801 } 00802 if (IsEqualCLSID(rclsid, &CLSID_PSTypeInfo) || 00803 IsEqualCLSID(rclsid, &CLSID_PSTypeLib) || 00804 IsEqualCLSID(rclsid, &CLSID_PSDispatch) || 00805 IsEqualCLSID(rclsid, &CLSID_PSEnumVariant)) 00806 return OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, iid, ppv); 00807 00808 return OLEAUTPS_DllGetClassObject(rclsid, iid, ppv); 00809 } 00810 00811 /*********************************************************************** 00812 * DllCanUnloadNow (OLEAUT32.@) 00813 * 00814 * Determine if this dll can be unloaded from the callers address space. 00815 * 00816 * PARAMS 00817 * None. 00818 * 00819 * RETURNS 00820 * Always returns S_FALSE. This dll cannot be unloaded. 00821 */ 00822 HRESULT WINAPI DllCanUnloadNow(void) 00823 { 00824 return S_FALSE; 00825 } 00826 00827 /***************************************************************************** 00828 * DllMain [OLEAUT32.@] 00829 */ 00830 BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved) 00831 { 00832 return OLEAUTPS_DllMain( hInstDll, fdwReason, lpvReserved ); 00833 } 00834 00835 /*********************************************************************** 00836 * OleIconToCursor (OLEAUT32.415) 00837 */ 00838 HCURSOR WINAPI OleIconToCursor( HINSTANCE hinstExe, HICON hIcon) 00839 { 00840 FIXME("(%p,%p), partially implemented.\n",hinstExe,hIcon); 00841 /* FIXME: make a extended conversation from HICON to HCURSOR */ 00842 return CopyCursor(hIcon); 00843 } Generated on Mon May 28 2012 04:25:24 for ReactOS by
1.7.6.1
|