[5602] | 1 | /*
|
---|
[6711] | 2 | * COMPOBJ library
|
---|
[5602] | 3 | *
|
---|
[6711] | 4 | * Copyright 1995 Martin von Loewis
|
---|
| 5 | * Copyright 1998 Justin Bradford
|
---|
[5602] | 6 | * Copyright 1999 Francis Beaudet
|
---|
| 7 | * Copyright 1999 Sylvain St-Germain
|
---|
[7926] | 8 | * Copyright 2002 Marcus Meissner
|
---|
[8441] | 9 | *
|
---|
| 10 | * This library is free software; you can redistribute it and/or
|
---|
| 11 | * modify it under the terms of the GNU Lesser General Public
|
---|
| 12 | * License as published by the Free Software Foundation; either
|
---|
| 13 | * version 2.1 of the License, or (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This library is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 18 | * Lesser General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU Lesser General Public
|
---|
| 21 | * License along with this library; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
[5602] | 23 | */
|
---|
| 24 |
|
---|
| 25 | #include "config.h"
|
---|
| 26 |
|
---|
| 27 | #include <stdlib.h>
|
---|
| 28 | #include <stdio.h>
|
---|
| 29 | #include <string.h>
|
---|
| 30 | #include <assert.h>
|
---|
[7926] | 31 |
|
---|
[5602] | 32 | #include "windef.h"
|
---|
[7926] | 33 | #include "objbase.h"
|
---|
| 34 | #include "ole2.h"
|
---|
| 35 | #include "ole2ver.h"
|
---|
| 36 | #include "rpc.h"
|
---|
[5602] | 37 | #include "winerror.h"
|
---|
[7926] | 38 | #include "winreg.h"
|
---|
[5602] | 39 | #include "wownt32.h"
|
---|
[7926] | 40 | #include "wtypes.h"
|
---|
| 41 | #include "wine/unicode.h"
|
---|
[5602] | 42 | #include "wine/obj_base.h"
|
---|
[7926] | 43 | #include "wine/obj_clientserver.h"
|
---|
[5602] | 44 | #include "wine/obj_misc.h"
|
---|
[7926] | 45 | #include "wine/obj_marshal.h"
|
---|
[5602] | 46 | #include "wine/obj_storage.h"
|
---|
[7926] | 47 | #include "wine/obj_channel.h"
|
---|
| 48 | #include "compobj_private.h"
|
---|
[5602] | 49 |
|
---|
[8620] | 50 | #include "wine/debug.h"
|
---|
[5602] | 51 |
|
---|
[8620] | 52 | WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
---|
[5602] | 53 |
|
---|
| 54 | /****************************************************************************
|
---|
[9400] | 55 | * This section defines variables internal to the COM module.
|
---|
[5602] | 56 | *
|
---|
[9400] | 57 | * TODO: Most of these things will have to be made thread-safe.
|
---|
[5602] | 58 | */
|
---|
[9400] | 59 | HINSTANCE COMPOBJ_hInstance32 = 0;
|
---|
[5602] | 60 |
|
---|
[9400] | 61 | static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, DWORD dwClsContext, LPUNKNOWN* ppUnk);
|
---|
| 62 | static void COM_RevokeAllClasses();
|
---|
| 63 | static void COM_ExternalLockFreeList();
|
---|
[5602] | 64 |
|
---|
[9400] | 65 | /*****************************************************************************
|
---|
| 66 | * Appartment management stuff
|
---|
| 67 | *
|
---|
| 68 | * NOTE:
|
---|
| 69 | * per Thread values are stored in the TEB on offset 0xF80
|
---|
| 70 | *
|
---|
| 71 | * see www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm
|
---|
| 72 | *
|
---|
[5602] | 73 | */
|
---|
| 74 |
|
---|
[9400] | 75 | typedef struct {
|
---|
| 76 | unsigned char threadingModell; /* we use the COINIT flags */
|
---|
| 77 | unsigned long threadID;
|
---|
| 78 | long AppartmentLockCount;
|
---|
| 79 | } OleAppartmentData;
|
---|
[5602] | 80 |
|
---|
[9400] | 81 | typedef struct {
|
---|
| 82 | OleAppartmentData *AppartmentData;
|
---|
| 83 | } OleThreadData;
|
---|
[5602] | 84 |
|
---|
[9400] | 85 | /* not jet used
|
---|
| 86 | static CRITICAL_SECTION csAppartmentData = CRITICAL_SECTION_INIT("csAppartmentData");
|
---|
| 87 | */
|
---|
[5602] | 88 | /*
|
---|
[9400] | 89 | * the first STA created in a process is the main STA
|
---|
[5602] | 90 | */
|
---|
| 91 |
|
---|
[9400] | 92 | /* not jet used
|
---|
| 93 | static OleAppartmentData * mainSTA;
|
---|
| 94 | */
|
---|
[5602] | 95 |
|
---|
| 96 | /*
|
---|
[9400] | 97 | * a Process can only have one MTA
|
---|
[5602] | 98 | */
|
---|
| 99 |
|
---|
[9400] | 100 | /* not jet used
|
---|
| 101 | static OleAppartmentData * processMTA;
|
---|
| 102 | */
|
---|
[5602] | 103 |
|
---|
| 104 |
|
---|
| 105 | /*
|
---|
| 106 | * This lock count counts the number of times CoInitialize is called. It is
|
---|
| 107 | * decreased every time CoUninitialize is called. When it hits 0, the COM
|
---|
| 108 | * libraries are freed
|
---|
| 109 | */
|
---|
[7926] | 110 | static LONG s_COMLockCount = 0;
|
---|
[5602] | 111 |
|
---|
| 112 | /*
|
---|
| 113 | * This linked list contains the list of registered class objects. These
|
---|
| 114 | * are mostly used to register the factories for out-of-proc servers of OLE
|
---|
| 115 | * objects.
|
---|
| 116 | *
|
---|
| 117 | * TODO: Make this data structure aware of inter-process communication. This
|
---|
| 118 | * means that parts of this will be exported to the Wine Server.
|
---|
| 119 | */
|
---|
| 120 | typedef struct tagRegisteredClass
|
---|
| 121 | {
|
---|
| 122 | CLSID classIdentifier;
|
---|
| 123 | LPUNKNOWN classObject;
|
---|
| 124 | DWORD runContext;
|
---|
| 125 | DWORD connectFlags;
|
---|
| 126 | DWORD dwCookie;
|
---|
[7926] | 127 | HANDLE hThread; /* only for localserver */
|
---|
[5602] | 128 | struct tagRegisteredClass* nextClass;
|
---|
| 129 | } RegisteredClass;
|
---|
| 130 |
|
---|
[9400] | 131 | static CRITICAL_SECTION csRegisteredClassList = CRITICAL_SECTION_INIT("csRegisteredClassList");
|
---|
[5602] | 132 | static RegisteredClass* firstRegisteredClass = NULL;
|
---|
| 133 |
|
---|
[9400] | 134 | /*****************************************************************************
|
---|
| 135 | * This section contains OpenDllList definitions
|
---|
| 136 | *
|
---|
| 137 | * The OpenDllList contains only handles of dll loaded by CoGetClassObject or
|
---|
| 138 | * other functions what do LoadLibrary _without_ giving back a HMODULE.
|
---|
| 139 | * Without this list these handles would be freed never.
|
---|
| 140 | *
|
---|
| 141 | * FIXME: a DLL what says OK whenn asked for unloading is unloaded in the
|
---|
| 142 | * next unload-call but not before 600 sec.
|
---|
[5602] | 143 | */
|
---|
[9400] | 144 |
|
---|
[5602] | 145 | typedef struct tagOpenDll {
|
---|
[7926] | 146 | HINSTANCE hLibrary;
|
---|
[5602] | 147 | struct tagOpenDll *next;
|
---|
| 148 | } OpenDll;
|
---|
| 149 |
|
---|
[9400] | 150 | static CRITICAL_SECTION csOpenDllList = CRITICAL_SECTION_INIT("csOpenDllList");
|
---|
[5602] | 151 | static OpenDll *openDllList = NULL; /* linked list of open dlls */
|
---|
| 152 |
|
---|
[9400] | 153 | static void COMPOBJ_DLLList_Add(HANDLE hLibrary);
|
---|
| 154 | static void COMPOBJ_DllList_FreeUnused(int Timeout);
|
---|
[5602] | 155 |
|
---|
| 156 |
|
---|
| 157 | /******************************************************************************
|
---|
[7926] | 158 | * Initialize/Uninitialize critical sections.
|
---|
| 159 | */
|
---|
| 160 | void COMPOBJ_InitProcess( void )
|
---|
| 161 | {
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | void COMPOBJ_UninitProcess( void )
|
---|
| 165 | {
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[9400] | 168 | /*****************************************************************************
|
---|
| 169 | * This section contains OpenDllList implemantation
|
---|
| 170 | */
|
---|
| 171 |
|
---|
| 172 | static void COMPOBJ_DLLList_Add(HANDLE hLibrary)
|
---|
| 173 | {
|
---|
| 174 | OpenDll *ptr;
|
---|
| 175 | OpenDll *tmp;
|
---|
| 176 |
|
---|
| 177 | TRACE("\n");
|
---|
| 178 |
|
---|
| 179 | EnterCriticalSection( &csOpenDllList );
|
---|
| 180 |
|
---|
| 181 | if (openDllList == NULL) {
|
---|
| 182 | /* empty list -- add first node */
|
---|
| 183 | openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
|
---|
| 184 | openDllList->hLibrary=hLibrary;
|
---|
| 185 | openDllList->next = NULL;
|
---|
| 186 | } else {
|
---|
| 187 | /* search for this dll */
|
---|
| 188 | int found = FALSE;
|
---|
| 189 | for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) {
|
---|
| 190 | if (ptr->hLibrary == hLibrary) {
|
---|
| 191 | found = TRUE;
|
---|
| 192 | break;
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 | if (!found) {
|
---|
| 196 | /* dll not found, add it */
|
---|
| 197 | tmp = openDllList;
|
---|
| 198 | openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
|
---|
| 199 | openDllList->hLibrary = hLibrary;
|
---|
| 200 | openDllList->next = tmp;
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | LeaveCriticalSection( &csOpenDllList );
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | static void COMPOBJ_DllList_FreeUnused(int Timeout)
|
---|
| 208 | {
|
---|
| 209 | OpenDll *curr, *next, *prev = NULL;
|
---|
| 210 | typedef HRESULT(*DllCanUnloadNowFunc)(void);
|
---|
| 211 | DllCanUnloadNowFunc DllCanUnloadNow;
|
---|
| 212 |
|
---|
| 213 | TRACE("\n");
|
---|
| 214 |
|
---|
| 215 | EnterCriticalSection( &csOpenDllList );
|
---|
| 216 |
|
---|
| 217 | for (curr = openDllList; curr != NULL; ) {
|
---|
| 218 | DllCanUnloadNow = (DllCanUnloadNowFunc) GetProcAddress(curr->hLibrary, "DllCanUnloadNow");
|
---|
| 219 |
|
---|
| 220 | if ( (DllCanUnloadNow != NULL) && (DllCanUnloadNow() == S_OK) ) {
|
---|
| 221 | next = curr->next;
|
---|
| 222 |
|
---|
| 223 | TRACE("freeing 0x%08x\n", curr->hLibrary);
|
---|
| 224 | FreeLibrary(curr->hLibrary);
|
---|
| 225 |
|
---|
| 226 | HeapFree(GetProcessHeap(), 0, curr);
|
---|
| 227 | if (curr == openDllList) {
|
---|
| 228 | openDllList = next;
|
---|
| 229 | } else {
|
---|
| 230 | prev->next = next;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | curr = next;
|
---|
| 234 | } else {
|
---|
| 235 | prev = curr;
|
---|
| 236 | curr = curr->next;
|
---|
| 237 | }
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | LeaveCriticalSection( &csOpenDllList );
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[7926] | 243 | /******************************************************************************
|
---|
[5602] | 244 | * CoBuildVersion [COMPOBJ.1]
|
---|
[7926] | 245 | * CoBuildVersion [OLE32.4]
|
---|
[5602] | 246 | *
|
---|
| 247 | * RETURNS
|
---|
[6711] | 248 | * Current build version, hiword is majornumber, loword is minornumber
|
---|
[5602] | 249 | */
|
---|
| 250 | DWORD WINAPI CoBuildVersion(void)
|
---|
| 251 | {
|
---|
| 252 | TRACE("Returning version %d, build %d.\n", rmm, rup);
|
---|
| 253 | return (rmm<<16)+rup;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | /******************************************************************************
|
---|
[6711] | 257 | * CoInitialize [OLE32.26]
|
---|
[5602] | 258 | *
|
---|
| 259 | * Initializes the COM libraries.
|
---|
| 260 | *
|
---|
| 261 | * See CoInitializeEx
|
---|
| 262 | */
|
---|
| 263 | HRESULT WINAPI CoInitialize(
|
---|
[6711] | 264 | LPVOID lpReserved /* [in] pointer to win32 malloc interface
|
---|
[5602] | 265 | (obsolete, should be NULL) */
|
---|
[7926] | 266 | )
|
---|
[5602] | 267 | {
|
---|
| 268 | /*
|
---|
| 269 | * Just delegate to the newer method.
|
---|
| 270 | */
|
---|
| 271 | return CoInitializeEx(lpReserved, COINIT_APARTMENTTHREADED);
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | /******************************************************************************
|
---|
[6711] | 275 | * CoInitializeEx [OLE32.163]
|
---|
[5602] | 276 | *
|
---|
| 277 | * Initializes the COM libraries. The behavior used to set the win32 IMalloc
|
---|
| 278 | * used for memory management is obsolete.
|
---|
| 279 | *
|
---|
| 280 | * RETURNS
|
---|
| 281 | * S_OK if successful,
|
---|
| 282 | * S_FALSE if this function was called already.
|
---|
| 283 | * RPC_E_CHANGED_MODE if a previous call to CoInitialize specified another
|
---|
| 284 | * threading model.
|
---|
| 285 | *
|
---|
| 286 | * BUGS
|
---|
[7926] | 287 | * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE
|
---|
[5602] | 288 | * is never returned.
|
---|
| 289 | *
|
---|
| 290 | * See the windows documentation for more details.
|
---|
| 291 | */
|
---|
| 292 | HRESULT WINAPI CoInitializeEx(
|
---|
[6711] | 293 | LPVOID lpReserved, /* [in] pointer to win32 malloc interface
|
---|
[5602] | 294 | (obsolete, should be NULL) */
|
---|
[6711] | 295 | DWORD dwCoInit /* [in] A value from COINIT specifies the threading model */
|
---|
[7926] | 296 | )
|
---|
[5602] | 297 | {
|
---|
| 298 | HRESULT hr;
|
---|
| 299 |
|
---|
| 300 | TRACE("(%p, %x)\n", lpReserved, (int)dwCoInit);
|
---|
| 301 |
|
---|
| 302 | if (lpReserved!=NULL)
|
---|
| 303 | {
|
---|
| 304 | ERR("(%p, %x) - Bad parameter passed-in %p, must be an old Windows Application\n", lpReserved, (int)dwCoInit, lpReserved);
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | /*
|
---|
| 308 | * Check for unsupported features.
|
---|
| 309 | */
|
---|
[7926] | 310 | if (dwCoInit!=COINIT_APARTMENTTHREADED)
|
---|
[5602] | 311 | {
|
---|
| 312 | FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit);
|
---|
| 313 | /* Hope for the best and continue anyway */
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | /*
|
---|
| 317 | * Check the lock count. If this is the first time going through the initialize
|
---|
| 318 | * process, we have to initialize the libraries.
|
---|
[7926] | 319 | *
|
---|
| 320 | * And crank-up that lock count.
|
---|
[5602] | 321 | */
|
---|
[7926] | 322 | if (InterlockedExchangeAdd(&s_COMLockCount,1)==0)
|
---|
[5602] | 323 | {
|
---|
| 324 | /*
|
---|
| 325 | * Initialize the various COM libraries and data structures.
|
---|
| 326 | */
|
---|
| 327 | TRACE("() - Initializing the COM libraries\n");
|
---|
| 328 |
|
---|
[7926] | 329 |
|
---|
[5602] | 330 | RunningObjectTableImpl_Initialize();
|
---|
| 331 |
|
---|
| 332 | hr = S_OK;
|
---|
| 333 | }
|
---|
| 334 | else
|
---|
| 335 | hr = S_FALSE;
|
---|
| 336 |
|
---|
| 337 | return hr;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | /***********************************************************************
|
---|
| 341 | * CoUninitialize [OLE32.47]
|
---|
| 342 | *
|
---|
| 343 | * This method will release the COM libraries.
|
---|
| 344 | *
|
---|
| 345 | * See the windows documentation for more details.
|
---|
| 346 | */
|
---|
| 347 | void WINAPI CoUninitialize(void)
|
---|
| 348 | {
|
---|
[7926] | 349 | LONG lCOMRefCnt;
|
---|
[5602] | 350 | TRACE("()\n");
|
---|
[7926] | 351 |
|
---|
[5602] | 352 | /*
|
---|
| 353 | * Decrease the reference count.
|
---|
| 354 | * If we are back to 0 locks on the COM library, make sure we free
|
---|
| 355 | * all the associated data structures.
|
---|
| 356 | */
|
---|
[7926] | 357 | lCOMRefCnt = InterlockedExchangeAdd(&s_COMLockCount,-1);
|
---|
| 358 | if (lCOMRefCnt==1)
|
---|
[5602] | 359 | {
|
---|
| 360 | /*
|
---|
| 361 | * Release the various COM libraries and data structures.
|
---|
| 362 | */
|
---|
| 363 | TRACE("() - Releasing the COM libraries\n");
|
---|
| 364 |
|
---|
| 365 | RunningObjectTableImpl_UnInitialize();
|
---|
| 366 | /*
|
---|
| 367 | * Release the references to the registered class objects.
|
---|
| 368 | */
|
---|
| 369 | COM_RevokeAllClasses();
|
---|
| 370 |
|
---|
| 371 | /*
|
---|
| 372 | * This will free the loaded COM Dlls.
|
---|
| 373 | */
|
---|
| 374 | CoFreeAllLibraries();
|
---|
| 375 |
|
---|
| 376 | /*
|
---|
| 377 | * This will free list of external references to COM objects.
|
---|
| 378 | */
|
---|
| 379 | COM_ExternalLockFreeList();
|
---|
[7926] | 380 |
|
---|
| 381 | }
|
---|
| 382 | else if (lCOMRefCnt<1) {
|
---|
| 383 | ERR( "CoUninitialize() - not CoInitialized.\n" );
|
---|
| 384 | InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */
|
---|
| 385 | }
|
---|
[5602] | 386 | }
|
---|
| 387 |
|
---|
| 388 | /******************************************************************************
|
---|
[6711] | 389 | * CoDisconnectObject [COMPOBJ.15]
|
---|
[7926] | 390 | * CoDisconnectObject [OLE32.8]
|
---|
[5602] | 391 | */
|
---|
| 392 | HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
|
---|
| 393 | {
|
---|
| 394 | TRACE("(%p, %lx)\n",lpUnk,reserved);
|
---|
| 395 | return S_OK;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[9400] | 398 | /******************************************************************************
|
---|
| 399 | * CoCreateGuid[OLE32.6]
|
---|
[5602] | 400 | *
|
---|
| 401 | */
|
---|
[9400] | 402 | HRESULT WINAPI CoCreateGuid(
|
---|
| 403 | GUID *pguid /* [out] points to the GUID to initialize */
|
---|
[5602] | 404 | ) {
|
---|
[9400] | 405 | return UuidCreate(pguid);
|
---|
[5602] | 406 | }
|
---|
| 407 |
|
---|
| 408 | /******************************************************************************
|
---|
[9400] | 409 | * CLSIDFromString [OLE32.3]
|
---|
| 410 | * IIDFromString [OLE32.74]
|
---|
[7926] | 411 | * Converts a unique identifier from its string representation into
|
---|
[5602] | 412 | * the GUID struct.
|
---|
| 413 | *
|
---|
[9400] | 414 | * UNDOCUMENTED
|
---|
| 415 | * If idstr is not a valid CLSID string then it gets treated as a ProgID
|
---|
[5602] | 416 | *
|
---|
| 417 | * RETURNS
|
---|
[6711] | 418 | * the converted GUID
|
---|
[5602] | 419 | */
|
---|
[9400] | 420 | HRESULT WINAPI __CLSIDFromStringA(
|
---|
| 421 | LPCSTR idstr, /* [in] string representation of guid */
|
---|
| 422 | CLSID *id) /* [out] GUID converted from string */
|
---|
| 423 | {
|
---|
[5602] | 424 | BYTE *s = (BYTE *) idstr;
|
---|
[6711] | 425 | int i;
|
---|
[5602] | 426 | BYTE table[256];
|
---|
| 427 |
|
---|
| 428 | if (!s)
|
---|
[6711] | 429 | s = "{00000000-0000-0000-0000-000000000000}";
|
---|
[5602] | 430 | else { /* validate the CLSID string */
|
---|
[7508] | 431 |
|
---|
| 432 | if (strlen(s) != 38)
|
---|
[5602] | 433 | return CO_E_CLASSSTRING;
|
---|
| 434 |
|
---|
| 435 | if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
|
---|
| 436 | return CO_E_CLASSSTRING;
|
---|
| 437 |
|
---|
[9400] | 438 | for (i=1; i<37; i++) {
|
---|
[5602] | 439 | if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
|
---|
| 440 | if (!(((s[i] >= '0') && (s[i] <= '9')) ||
|
---|
| 441 | ((s[i] >= 'a') && (s[i] <= 'f')) ||
|
---|
[9400] | 442 | ((s[i] >= 'A') && (s[i] <= 'F'))))
|
---|
[5602] | 443 | return CO_E_CLASSSTRING;
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | TRACE("%s -> %p\n", s, id);
|
---|
[7508] | 448 |
|
---|
| 449 | /* quick lookup table */
|
---|
| 450 | memset(table, 0, 256);
|
---|
| 451 |
|
---|
| 452 | for (i = 0; i < 10; i++) {
|
---|
| 453 | table['0' + i] = i;
|
---|
[5602] | 454 | }
|
---|
[7508] | 455 | for (i = 0; i < 6; i++) {
|
---|
| 456 | table['A' + i] = i+10;
|
---|
| 457 | table['a' + i] = i+10;
|
---|
| 458 | }
|
---|
[5602] | 459 |
|
---|
| 460 | /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
|
---|
| 461 |
|
---|
[9400] | 462 | id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 |
|
---|
| 463 | table[s[5]] << 12 | table[s[6]] << 8 | table[s[7]] << 4 | table[s[8]]);
|
---|
| 464 | id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]];
|
---|
| 465 | id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]];
|
---|
[5602] | 466 |
|
---|
| 467 | /* these are just sequential bytes */
|
---|
[9400] | 468 | id->Data4[0] = table[s[20]] << 4 | table[s[21]];
|
---|
| 469 | id->Data4[1] = table[s[22]] << 4 | table[s[23]];
|
---|
| 470 | id->Data4[2] = table[s[25]] << 4 | table[s[26]];
|
---|
| 471 | id->Data4[3] = table[s[27]] << 4 | table[s[28]];
|
---|
| 472 | id->Data4[4] = table[s[29]] << 4 | table[s[30]];
|
---|
| 473 | id->Data4[5] = table[s[31]] << 4 | table[s[32]];
|
---|
| 474 | id->Data4[6] = table[s[33]] << 4 | table[s[34]];
|
---|
| 475 | id->Data4[7] = table[s[35]] << 4 | table[s[36]];
|
---|
[5602] | 476 |
|
---|
| 477 | return S_OK;
|
---|
| 478 | }
|
---|
| 479 |
|
---|
[9400] | 480 | /*****************************************************************************/
|
---|
[5602] | 481 |
|
---|
| 482 | HRESULT WINAPI CLSIDFromString(
|
---|
[6711] | 483 | LPCOLESTR idstr, /* [in] string representation of GUID */
|
---|
[7926] | 484 | CLSID *id ) /* [out] GUID represented by above string */
|
---|
| 485 | {
|
---|
| 486 | char xid[40];
|
---|
| 487 | HRESULT ret;
|
---|
[7343] | 488 |
|
---|
[7926] | 489 | if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL ))
|
---|
| 490 | return CO_E_CLASSSTRING;
|
---|
[9400] | 491 |
|
---|
| 492 |
|
---|
| 493 | ret = __CLSIDFromStringA(xid,id);
|
---|
[5602] | 494 | if(ret != S_OK) { /* It appears a ProgID is also valid */
|
---|
| 495 | ret = CLSIDFromProgID(idstr, id);
|
---|
| 496 | }
|
---|
| 497 | return ret;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | /******************************************************************************
|
---|
[6711] | 501 | * WINE_StringFromCLSID [Internal]
|
---|
[5602] | 502 | * Converts a GUID into the respective string representation.
|
---|
| 503 | *
|
---|
| 504 | * NOTES
|
---|
| 505 | *
|
---|
| 506 | * RETURNS
|
---|
[6711] | 507 | * the string representation and HRESULT
|
---|
[5602] | 508 | */
|
---|
[21916] | 509 | HRESULT WINAPI WINE_StringFromCLSID(
|
---|
[6711] | 510 | const CLSID *id, /* [in] GUID to be converted */
|
---|
| 511 | LPSTR idstr /* [out] pointer to buffer to contain converted guid */
|
---|
[5602] | 512 | ) {
|
---|
| 513 | static const char *hex = "0123456789ABCDEF";
|
---|
| 514 | char *s;
|
---|
[6711] | 515 | int i;
|
---|
[5602] | 516 |
|
---|
| 517 | if (!id)
|
---|
[6711] | 518 | { ERR("called with id=Null\n");
|
---|
| 519 | *idstr = 0x00;
|
---|
| 520 | return E_FAIL;
|
---|
| 521 | }
|
---|
[7926] | 522 |
|
---|
[5602] | 523 | sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-",
|
---|
[6711] | 524 | id->Data1, id->Data2, id->Data3,
|
---|
| 525 | id->Data4[0], id->Data4[1]);
|
---|
[5602] | 526 | s = &idstr[25];
|
---|
| 527 |
|
---|
| 528 | /* 6 hex bytes */
|
---|
| 529 | for (i = 2; i < 8; i++) {
|
---|
| 530 | *s++ = hex[id->Data4[i]>>4];
|
---|
| 531 | *s++ = hex[id->Data4[i] & 0xf];
|
---|
| 532 | }
|
---|
| 533 |
|
---|
| 534 | *s++ = '}';
|
---|
| 535 | *s++ = '\0';
|
---|
| 536 |
|
---|
| 537 | TRACE("%p->%s\n", id, idstr);
|
---|
| 538 |
|
---|
| 539 | return S_OK;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 |
|
---|
| 543 | /******************************************************************************
|
---|
[6711] | 544 | * StringFromCLSID [OLE32.151]
|
---|
[7926] | 545 | * StringFromIID [OLE32.153]
|
---|
[5602] | 546 | * Converts a GUID into the respective string representation.
|
---|
| 547 | * The target string is allocated using the OLE IMalloc.
|
---|
| 548 | * RETURNS
|
---|
[6711] | 549 | * the string representation and HRESULT
|
---|
[5602] | 550 | */
|
---|
| 551 | HRESULT WINAPI StringFromCLSID(
|
---|
| 552 | REFCLSID id, /* [in] the GUID to be converted */
|
---|
[6711] | 553 | LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
|
---|
[5602] | 554 | ) {
|
---|
[6711] | 555 | char buf[80];
|
---|
| 556 | HRESULT ret;
|
---|
| 557 | LPMALLOC mllc;
|
---|
[5602] | 558 |
|
---|
[6711] | 559 | if ((ret=CoGetMalloc(0,&mllc)))
|
---|
| 560 | return ret;
|
---|
[5602] | 561 |
|
---|
[6711] | 562 | ret=WINE_StringFromCLSID(id,buf);
|
---|
| 563 | if (!ret) {
|
---|
[5602] | 564 | DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 );
|
---|
| 565 | *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) );
|
---|
| 566 | MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len );
|
---|
[6711] | 567 | }
|
---|
| 568 | return ret;
|
---|
[5602] | 569 | }
|
---|
| 570 |
|
---|
| 571 | /******************************************************************************
|
---|
[7926] | 572 | * StringFromGUID2 [COMPOBJ.76]
|
---|
| 573 | * StringFromGUID2 [OLE32.152]
|
---|
[5602] | 574 | *
|
---|
| 575 | * Converts a global unique identifier into a string of an API-
|
---|
| 576 | * specified fixed format. (The usual {.....} stuff.)
|
---|
| 577 | *
|
---|
| 578 | * RETURNS
|
---|
[6711] | 579 | * The (UNICODE) string representation of the GUID in 'str'
|
---|
| 580 | * The length of the resulting string, 0 if there was any problem.
|
---|
[5602] | 581 | */
|
---|
| 582 | INT WINAPI
|
---|
| 583 | StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
|
---|
| 584 | {
|
---|
[6711] | 585 | char xguid[80];
|
---|
[5602] | 586 |
|
---|
| 587 | if (WINE_StringFromCLSID(id,xguid))
|
---|
[6711] | 588 | return 0;
|
---|
[5602] | 589 | return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
|
---|
| 590 | }
|
---|
| 591 |
|
---|
| 592 | /******************************************************************************
|
---|
| 593 | * ProgIDFromCLSID [OLE32.133]
|
---|
| 594 | * Converts a class id into the respective Program ID. (By using a registry lookup)
|
---|
| 595 | * RETURNS S_OK on success
|
---|
| 596 | * riid associated with the progid
|
---|
| 597 | */
|
---|
| 598 |
|
---|
| 599 | HRESULT WINAPI ProgIDFromCLSID(
|
---|
| 600 | REFCLSID clsid, /* [in] class id as found in registry */
|
---|
| 601 | LPOLESTR *lplpszProgID/* [out] associated Prog ID */
|
---|
| 602 | )
|
---|
| 603 | {
|
---|
| 604 | char strCLSID[50], *buf, *buf2;
|
---|
| 605 | DWORD buf2len;
|
---|
| 606 | HKEY xhkey;
|
---|
| 607 | LPMALLOC mllc;
|
---|
| 608 | HRESULT ret = S_OK;
|
---|
| 609 |
|
---|
| 610 | WINE_StringFromCLSID(clsid, strCLSID);
|
---|
| 611 |
|
---|
| 612 | buf = HeapAlloc(GetProcessHeap(), 0, strlen(strCLSID)+14);
|
---|
| 613 | sprintf(buf,"CLSID\\%s\\ProgID", strCLSID);
|
---|
| 614 | if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey))
|
---|
| 615 | ret = REGDB_E_CLASSNOTREG;
|
---|
| 616 |
|
---|
| 617 | HeapFree(GetProcessHeap(), 0, buf);
|
---|
| 618 |
|
---|
| 619 | if (ret == S_OK)
|
---|
| 620 | {
|
---|
| 621 | buf2 = HeapAlloc(GetProcessHeap(), 0, 255);
|
---|
| 622 | buf2len = 255;
|
---|
| 623 | if (RegQueryValueA(xhkey, NULL, buf2, &buf2len))
|
---|
| 624 | ret = REGDB_E_CLASSNOTREG;
|
---|
| 625 |
|
---|
| 626 | if (ret == S_OK)
|
---|
| 627 | {
|
---|
| 628 | if (CoGetMalloc(0,&mllc))
|
---|
| 629 | ret = E_OUTOFMEMORY;
|
---|
| 630 | else
|
---|
| 631 | {
|
---|
| 632 | DWORD len = MultiByteToWideChar( CP_ACP, 0, buf2, -1, NULL, 0 );
|
---|
| 633 | *lplpszProgID = IMalloc_Alloc(mllc, len * sizeof(WCHAR) );
|
---|
| 634 | MultiByteToWideChar( CP_ACP, 0, buf2, -1, *lplpszProgID, len );
|
---|
| 635 | }
|
---|
| 636 | }
|
---|
| 637 | HeapFree(GetProcessHeap(), 0, buf2);
|
---|
| 638 | }
|
---|
| 639 |
|
---|
| 640 | RegCloseKey(xhkey);
|
---|
| 641 | return ret;
|
---|
| 642 | }
|
---|
| 643 |
|
---|
| 644 | /******************************************************************************
|
---|
[6711] | 645 | * CLSIDFromProgID [OLE32.2]
|
---|
[5602] | 646 | * Converts a program id into the respective GUID. (By using a registry lookup)
|
---|
| 647 | * RETURNS
|
---|
[6711] | 648 | * riid associated with the progid
|
---|
[5602] | 649 | */
|
---|
| 650 | HRESULT WINAPI CLSIDFromProgID(
|
---|
[6711] | 651 | LPCOLESTR progid, /* [in] program id as found in registry */
|
---|
[7926] | 652 | LPCLSID riid ) /* [out] associated CLSID */
|
---|
| 653 | {
|
---|
| 654 | static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
|
---|
| 655 | char buf2[80];
|
---|
| 656 | DWORD buf2len = sizeof(buf2);
|
---|
| 657 | HKEY xhkey;
|
---|
[5602] | 658 |
|
---|
[7926] | 659 | WCHAR *buf = HeapAlloc( GetProcessHeap(),0,(strlenW(progid)+8) * sizeof(WCHAR) );
|
---|
| 660 | strcpyW( buf, progid );
|
---|
| 661 | strcatW( buf, clsidW );
|
---|
| 662 | if (RegOpenKeyW(HKEY_CLASSES_ROOT,buf,&xhkey))
|
---|
| 663 | {
|
---|
| 664 | HeapFree(GetProcessHeap(),0,buf);
|
---|
| 665 | return CO_E_CLASSSTRING;
|
---|
| 666 | }
|
---|
| 667 | HeapFree(GetProcessHeap(),0,buf);
|
---|
| 668 |
|
---|
| 669 | if (RegQueryValueA(xhkey,NULL,buf2,&buf2len))
|
---|
| 670 | {
|
---|
| 671 | RegCloseKey(xhkey);
|
---|
| 672 | return CO_E_CLASSSTRING;
|
---|
| 673 | }
|
---|
| 674 | RegCloseKey(xhkey);
|
---|
[9400] | 675 | return __CLSIDFromStringA(buf2,riid);
|
---|
[5602] | 676 | }
|
---|
| 677 |
|
---|
| 678 |
|
---|
[10625] | 679 | /******************************************************************************
|
---|
| 680 | * CLSIDFromProgIDEx [OLE32.]
|
---|
| 681 | */
|
---|
| 682 | HRESULT WINAPI CLSIDFromProgIDEx(LPCOLESTR lpszProgID, LPCLSID pclsid)
|
---|
| 683 | {
|
---|
| 684 | FIXME("%s: Not implemented! (returning E_NOTIMPL)\n", __FUNCTION__);
|
---|
| 685 | return E_NOTIMPL;
|
---|
| 686 | }
|
---|
[5602] | 687 |
|
---|
| 688 | /*****************************************************************************
|
---|
| 689 | * CoGetPSClsid [OLE32.22]
|
---|
| 690 | *
|
---|
| 691 | * This function returns the CLSID of the DLL that implements the proxy and stub
|
---|
[7926] | 692 | * for the specified interface.
|
---|
[5602] | 693 | *
|
---|
[7926] | 694 | * It determines this by searching the
|
---|
[5602] | 695 | * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry
|
---|
| 696 | * and any interface id registered by CoRegisterPSClsid within the current process.
|
---|
[7926] | 697 | *
|
---|
[5602] | 698 | * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid.
|
---|
| 699 | */
|
---|
| 700 | HRESULT WINAPI CoGetPSClsid(
|
---|
| 701 | REFIID riid, /* [in] Interface whose proxy/stub CLSID is to be returned */
|
---|
| 702 | CLSID *pclsid ) /* [out] Where to store returned proxy/stub CLSID */
|
---|
| 703 | {
|
---|
| 704 | char *buf, buf2[40];
|
---|
| 705 | DWORD buf2len;
|
---|
| 706 | HKEY xhkey;
|
---|
| 707 |
|
---|
| 708 | TRACE("() riid=%s, pclsid=%p\n", debugstr_guid(riid), pclsid);
|
---|
| 709 |
|
---|
| 710 | /* Get the input iid as a string */
|
---|
| 711 | WINE_StringFromCLSID(riid, buf2);
|
---|
| 712 | /* Allocate memory for the registry key we will construct.
|
---|
| 713 | (length of iid string plus constant length of static text */
|
---|
| 714 | buf = HeapAlloc(GetProcessHeap(), 0, strlen(buf2)+27);
|
---|
| 715 | if (buf == NULL)
|
---|
| 716 | {
|
---|
| 717 | return (E_OUTOFMEMORY);
|
---|
| 718 | }
|
---|
| 719 |
|
---|
| 720 | /* Construct the registry key we want */
|
---|
| 721 | sprintf(buf,"Interface\\%s\\ProxyStubClsid32", buf2);
|
---|
| 722 |
|
---|
| 723 | /* Open the key.. */
|
---|
| 724 | if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey))
|
---|
| 725 | {
|
---|
| 726 | HeapFree(GetProcessHeap(),0,buf);
|
---|
| 727 | return (E_INVALIDARG);
|
---|
| 728 | }
|
---|
| 729 | HeapFree(GetProcessHeap(),0,buf);
|
---|
| 730 |
|
---|
| 731 | /* ... Once we have the key, query the registry to get the
|
---|
[7926] | 732 | value of CLSID as a string, and convert it into a
|
---|
[5602] | 733 | proper CLSID structure to be passed back to the app */
|
---|
| 734 | buf2len = sizeof(buf2);
|
---|
| 735 | if ( (RegQueryValueA(xhkey,NULL,buf2,&buf2len)) )
|
---|
| 736 | {
|
---|
| 737 | RegCloseKey(xhkey);
|
---|
| 738 | return E_INVALIDARG;
|
---|
| 739 | }
|
---|
| 740 | RegCloseKey(xhkey);
|
---|
| 741 |
|
---|
| 742 | /* We have the CLSid we want back from the registry as a string, so
|
---|
| 743 | lets convert it into a CLSID structure */
|
---|
[9400] | 744 | if ( (__CLSIDFromStringA(buf2,pclsid)) != NOERROR) {
|
---|
[5602] | 745 | return E_INVALIDARG;
|
---|
| 746 | }
|
---|
| 747 |
|
---|
| 748 | TRACE ("() Returning CLSID=%s\n", debugstr_guid(pclsid));
|
---|
| 749 | return (S_OK);
|
---|
| 750 | }
|
---|
| 751 |
|
---|
| 752 |
|
---|
| 753 |
|
---|
| 754 | /***********************************************************************
|
---|
[7926] | 755 | * WriteClassStm (OLE32.159)
|
---|
[5602] | 756 | *
|
---|
| 757 | * This function write a CLSID on stream
|
---|
| 758 | */
|
---|
| 759 | HRESULT WINAPI WriteClassStm(IStream *pStm,REFCLSID rclsid)
|
---|
| 760 | {
|
---|
| 761 | TRACE("(%p,%p)\n",pStm,rclsid);
|
---|
| 762 |
|
---|
| 763 | if (rclsid==NULL)
|
---|
| 764 | return E_INVALIDARG;
|
---|
| 765 |
|
---|
| 766 | return IStream_Write(pStm,rclsid,sizeof(CLSID),NULL);
|
---|
| 767 | }
|
---|
| 768 |
|
---|
| 769 | /***********************************************************************
|
---|
[7926] | 770 | * ReadClassStm (OLE32.135)
|
---|
[5602] | 771 | *
|
---|
| 772 | * This function read a CLSID from a stream
|
---|
| 773 | */
|
---|
[7926] | 774 | HRESULT WINAPI ReadClassStm(IStream *pStm,CLSID *pclsid)
|
---|
[5602] | 775 | {
|
---|
| 776 | ULONG nbByte;
|
---|
| 777 | HRESULT res;
|
---|
| 778 |
|
---|
[7926] | 779 | TRACE("(%p,%p)\n",pStm,pclsid);
|
---|
| 780 |
|
---|
| 781 | if (pclsid==NULL)
|
---|
[5602] | 782 | return E_INVALIDARG;
|
---|
| 783 |
|
---|
[7926] | 784 | res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte);
|
---|
| 785 |
|
---|
[5602] | 786 | if (FAILED(res))
|
---|
| 787 | return res;
|
---|
[7926] | 788 |
|
---|
[5602] | 789 | if (nbByte != sizeof(CLSID))
|
---|
| 790 | return S_FALSE;
|
---|
| 791 | else
|
---|
| 792 | return S_OK;
|
---|
| 793 | }
|
---|
| 794 |
|
---|
[8620] | 795 |
|
---|
[5602] | 796 | /***
|
---|
| 797 | * COM_GetRegisteredClassObject
|
---|
| 798 | *
|
---|
[7926] | 799 | * This internal method is used to scan the registered class list to
|
---|
[5602] | 800 | * find a class object.
|
---|
| 801 | *
|
---|
[7926] | 802 | * Params:
|
---|
[5602] | 803 | * rclsid Class ID of the class to find.
|
---|
| 804 | * dwClsContext Class context to match.
|
---|
| 805 | * ppv [out] returns a pointer to the class object. Complying
|
---|
| 806 | * to normal COM usage, this method will increase the
|
---|
| 807 | * reference count on this object.
|
---|
| 808 | */
|
---|
| 809 | static HRESULT COM_GetRegisteredClassObject(
|
---|
[6711] | 810 | REFCLSID rclsid,
|
---|
| 811 | DWORD dwClsContext,
|
---|
| 812 | LPUNKNOWN* ppUnk)
|
---|
[5602] | 813 | {
|
---|
[7926] | 814 | HRESULT hr = S_FALSE;
|
---|
[5602] | 815 | RegisteredClass* curClass;
|
---|
| 816 |
|
---|
[7926] | 817 | EnterCriticalSection( &csRegisteredClassList );
|
---|
| 818 |
|
---|
[5602] | 819 | /*
|
---|
| 820 | * Sanity check
|
---|
| 821 | */
|
---|
| 822 | assert(ppUnk!=0);
|
---|
| 823 |
|
---|
| 824 | /*
|
---|
| 825 | * Iterate through the whole list and try to match the class ID.
|
---|
| 826 | */
|
---|
| 827 | curClass = firstRegisteredClass;
|
---|
| 828 |
|
---|
| 829 | while (curClass != 0)
|
---|
| 830 | {
|
---|
| 831 | /*
|
---|
| 832 | * Check if we have a match on the class ID.
|
---|
| 833 | */
|
---|
| 834 | if (IsEqualGUID(&(curClass->classIdentifier), rclsid))
|
---|
| 835 | {
|
---|
| 836 | /*
|
---|
| 837 | * Since we don't do out-of process or DCOM just right away, let's ignore the
|
---|
| 838 | * class context.
|
---|
| 839 | */
|
---|
| 840 |
|
---|
| 841 | /*
|
---|
| 842 | * We have a match, return the pointer to the class object.
|
---|
| 843 | */
|
---|
| 844 | *ppUnk = curClass->classObject;
|
---|
| 845 |
|
---|
| 846 | IUnknown_AddRef(curClass->classObject);
|
---|
| 847 |
|
---|
[7926] | 848 | hr = S_OK;
|
---|
| 849 | goto end;
|
---|
[5602] | 850 | }
|
---|
| 851 |
|
---|
| 852 | /*
|
---|
| 853 | * Step to the next class in the list.
|
---|
| 854 | */
|
---|
| 855 | curClass = curClass->nextClass;
|
---|
| 856 | }
|
---|
| 857 |
|
---|
[7926] | 858 | end:
|
---|
| 859 | LeaveCriticalSection( &csRegisteredClassList );
|
---|
[5602] | 860 | /*
|
---|
| 861 | * If we get to here, we haven't found our class.
|
---|
| 862 | */
|
---|
[7926] | 863 | return hr;
|
---|
[5602] | 864 | }
|
---|
| 865 |
|
---|
[7926] | 866 | static DWORD WINAPI
|
---|
| 867 | _LocalServerThread(LPVOID param) {
|
---|
| 868 | HANDLE hPipe;
|
---|
| 869 | char pipefn[200];
|
---|
| 870 | RegisteredClass *newClass = (RegisteredClass*)param;
|
---|
| 871 | HRESULT hres;
|
---|
| 872 | IStream *pStm;
|
---|
| 873 | STATSTG ststg;
|
---|
| 874 | unsigned char *buffer;
|
---|
| 875 | int buflen;
|
---|
| 876 | IClassFactory *classfac;
|
---|
| 877 | LARGE_INTEGER seekto;
|
---|
| 878 | ULARGE_INTEGER newpos;
|
---|
| 879 | ULONG res;
|
---|
| 880 |
|
---|
| 881 | TRACE("Starting threader for %s.\n",debugstr_guid(&newClass->classIdentifier));
|
---|
| 882 | strcpy(pipefn,PIPEPREF);
|
---|
| 883 | WINE_StringFromCLSID(&newClass->classIdentifier,pipefn+strlen(PIPEPREF));
|
---|
| 884 |
|
---|
| 885 | hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac);
|
---|
| 886 | if (hres) return hres;
|
---|
| 887 |
|
---|
| 888 | hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
|
---|
| 889 | if (hres) {
|
---|
| 890 | FIXME("Failed to create stream on hglobal.\n");
|
---|
| 891 | return hres;
|
---|
| 892 | }
|
---|
| 893 | hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0);
|
---|
| 894 | if (hres) {
|
---|
| 895 | FIXME("CoMarshalInterface failed, %lx!\n",hres);
|
---|
| 896 | return hres;
|
---|
| 897 | }
|
---|
| 898 | hres = IStream_Stat(pStm,&ststg,0);
|
---|
| 899 | if (hres) return hres;
|
---|
| 900 |
|
---|
[21916] | 901 | buflen = ststg.cbSize.DUMMYSTRUCTNAME_DOT LowPart;
|
---|
[7926] | 902 | buffer = HeapAlloc(GetProcessHeap(),0,buflen);
|
---|
[21916] | 903 | seekto.DUMMYSTRUCTNAME_DOT LowPart = 0;
|
---|
| 904 | seekto.DUMMYSTRUCTNAME_DOT HighPart = 0;
|
---|
[7926] | 905 | hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
|
---|
| 906 | if (hres) {
|
---|
| 907 | FIXME("IStream_Seek failed, %lx\n",hres);
|
---|
| 908 | return hres;
|
---|
| 909 | }
|
---|
| 910 | hres = IStream_Read(pStm,buffer,buflen,&res);
|
---|
| 911 | if (hres) {
|
---|
| 912 | FIXME("Stream Read failed, %lx\n",hres);
|
---|
| 913 | return hres;
|
---|
| 914 | }
|
---|
| 915 | IStream_Release(pStm);
|
---|
| 916 |
|
---|
| 917 | while (1) {
|
---|
| 918 | hPipe = CreateNamedPipeA(
|
---|
| 919 | pipefn,
|
---|
| 920 | PIPE_ACCESS_DUPLEX,
|
---|
| 921 | PIPE_TYPE_BYTE|PIPE_WAIT,
|
---|
| 922 | PIPE_UNLIMITED_INSTANCES,
|
---|
| 923 | 4096,
|
---|
| 924 | 4096,
|
---|
| 925 | NMPWAIT_USE_DEFAULT_WAIT,
|
---|
| 926 | NULL
|
---|
| 927 | );
|
---|
| 928 | if (hPipe == INVALID_HANDLE_VALUE) {
|
---|
| 929 | FIXME("pipe creation failed for %s, le is %lx\n",pipefn,GetLastError());
|
---|
| 930 | return 1;
|
---|
| 931 | }
|
---|
| 932 | if (!ConnectNamedPipe(hPipe,NULL)) {
|
---|
| 933 | ERR("Failure during ConnectNamedPipe %lx, ABORT!\n",GetLastError());
|
---|
| 934 | CloseHandle(hPipe);
|
---|
| 935 | continue;
|
---|
| 936 | }
|
---|
| 937 | WriteFile(hPipe,buffer,buflen,&res,NULL);
|
---|
| 938 | CloseHandle(hPipe);
|
---|
| 939 | }
|
---|
| 940 | return 0;
|
---|
| 941 | }
|
---|
| 942 |
|
---|
[5602] | 943 | /******************************************************************************
|
---|
[6711] | 944 | * CoRegisterClassObject [OLE32.36]
|
---|
[5602] | 945 | *
|
---|
| 946 | * This method will register the class object for a given class ID.
|
---|
| 947 | *
|
---|
| 948 | * See the Windows documentation for more details.
|
---|
| 949 | */
|
---|
| 950 | HRESULT WINAPI CoRegisterClassObject(
|
---|
[6711] | 951 | REFCLSID rclsid,
|
---|
| 952 | LPUNKNOWN pUnk,
|
---|
| 953 | DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
|
---|
| 954 | DWORD flags, /* [in] REGCLS flags indicating how connections are made */
|
---|
| 955 | LPDWORD lpdwRegister
|
---|
[7926] | 956 | )
|
---|
[5602] | 957 | {
|
---|
| 958 | RegisteredClass* newClass;
|
---|
| 959 | LPUNKNOWN foundObject;
|
---|
| 960 | HRESULT hr;
|
---|
| 961 |
|
---|
| 962 | TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n",
|
---|
[7926] | 963 | debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister);
|
---|
[5602] | 964 |
|
---|
| 965 | if ( (lpdwRegister==0) || (pUnk==0) )
|
---|
| 966 | return E_INVALIDARG;
|
---|
| 967 |
|
---|
| 968 | *lpdwRegister = 0;
|
---|
| 969 |
|
---|
| 970 | /*
|
---|
| 971 | * First, check if the class is already registered.
|
---|
| 972 | * If it is, this should cause an error.
|
---|
| 973 | */
|
---|
| 974 | hr = COM_GetRegisteredClassObject(rclsid, dwClsContext, &foundObject);
|
---|
[7926] | 975 | if (hr == S_OK) {
|
---|
[5602] | 976 | IUnknown_Release(foundObject);
|
---|
| 977 | return CO_E_OBJISREG;
|
---|
| 978 | }
|
---|
[7926] | 979 |
|
---|
[5602] | 980 | newClass = HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass));
|
---|
[7926] | 981 | if ( newClass == NULL )
|
---|
| 982 | return E_OUTOFMEMORY;
|
---|
[5602] | 983 |
|
---|
[7926] | 984 | EnterCriticalSection( &csRegisteredClassList );
|
---|
| 985 |
|
---|
[5602] | 986 | newClass->classIdentifier = *rclsid;
|
---|
| 987 | newClass->runContext = dwClsContext;
|
---|
| 988 | newClass->connectFlags = flags;
|
---|
[7926] | 989 | /*
|
---|
| 990 | * Use the address of the chain node as the cookie since we are sure it's
|
---|
| 991 | * unique.
|
---|
| 992 | */
|
---|
[5602] | 993 | newClass->dwCookie = (DWORD)newClass;
|
---|
| 994 | newClass->nextClass = firstRegisteredClass;
|
---|
| 995 |
|
---|
| 996 | /*
|
---|
| 997 | * Since we're making a copy of the object pointer, we have to increase its
|
---|
| 998 | * reference count.
|
---|
| 999 | */
|
---|
| 1000 | newClass->classObject = pUnk;
|
---|
| 1001 | IUnknown_AddRef(newClass->classObject);
|
---|
| 1002 |
|
---|
| 1003 | firstRegisteredClass = newClass;
|
---|
[7926] | 1004 | LeaveCriticalSection( &csRegisteredClassList );
|
---|
[5602] | 1005 |
|
---|
| 1006 | *lpdwRegister = newClass->dwCookie;
|
---|
[7926] | 1007 |
|
---|
| 1008 | if (dwClsContext & CLSCTX_LOCAL_SERVER) {
|
---|
| 1009 | DWORD tid;
|
---|
| 1010 |
|
---|
| 1011 | STUBMGR_Start();
|
---|
| 1012 | newClass->hThread=CreateThread(NULL,0,_LocalServerThread,newClass,0,&tid);
|
---|
| 1013 | }
|
---|
[5602] | 1014 | return S_OK;
|
---|
| 1015 | }
|
---|
| 1016 |
|
---|
| 1017 | /***********************************************************************
|
---|
| 1018 | * CoRevokeClassObject [OLE32.40]
|
---|
| 1019 | *
|
---|
| 1020 | * This method will remove a class object from the class registry
|
---|
| 1021 | *
|
---|
| 1022 | * See the Windows documentation for more details.
|
---|
| 1023 | */
|
---|
| 1024 | HRESULT WINAPI CoRevokeClassObject(
|
---|
[7926] | 1025 | DWORD dwRegister)
|
---|
[5602] | 1026 | {
|
---|
[7926] | 1027 | HRESULT hr = E_INVALIDARG;
|
---|
[5602] | 1028 | RegisteredClass** prevClassLink;
|
---|
| 1029 | RegisteredClass* curClass;
|
---|
| 1030 |
|
---|
| 1031 | TRACE("(%08lx)\n",dwRegister);
|
---|
| 1032 |
|
---|
[7926] | 1033 | EnterCriticalSection( &csRegisteredClassList );
|
---|
| 1034 |
|
---|
[5602] | 1035 | /*
|
---|
| 1036 | * Iterate through the whole list and try to match the cookie.
|
---|
| 1037 | */
|
---|
| 1038 | curClass = firstRegisteredClass;
|
---|
| 1039 | prevClassLink = &firstRegisteredClass;
|
---|
| 1040 |
|
---|
| 1041 | while (curClass != 0)
|
---|
| 1042 | {
|
---|
| 1043 | /*
|
---|
| 1044 | * Check if we have a match on the cookie.
|
---|
| 1045 | */
|
---|
| 1046 | if (curClass->dwCookie == dwRegister)
|
---|
| 1047 | {
|
---|
| 1048 | /*
|
---|
| 1049 | * Remove the class from the chain.
|
---|
| 1050 | */
|
---|
| 1051 | *prevClassLink = curClass->nextClass;
|
---|
| 1052 |
|
---|
| 1053 | /*
|
---|
| 1054 | * Release the reference to the class object.
|
---|
| 1055 | */
|
---|
| 1056 | IUnknown_Release(curClass->classObject);
|
---|
| 1057 |
|
---|
| 1058 | /*
|
---|
| 1059 | * Free the memory used by the chain node.
|
---|
[7926] | 1060 | */
|
---|
[5602] | 1061 | HeapFree(GetProcessHeap(), 0, curClass);
|
---|
| 1062 |
|
---|
[7926] | 1063 | hr = S_OK;
|
---|
| 1064 | goto end;
|
---|
| 1065 | }
|
---|
[5602] | 1066 |
|
---|
| 1067 | /*
|
---|
| 1068 | * Step to the next class in the list.
|
---|
| 1069 | */
|
---|
| 1070 | prevClassLink = &(curClass->nextClass);
|
---|
| 1071 | curClass = curClass->nextClass;
|
---|
| 1072 | }
|
---|
| 1073 |
|
---|
[7926] | 1074 | end:
|
---|
| 1075 | LeaveCriticalSection( &csRegisteredClassList );
|
---|
[5602] | 1076 | /*
|
---|
| 1077 | * If we get to here, we haven't found our class.
|
---|
| 1078 | */
|
---|
[7926] | 1079 | return hr;
|
---|
[5602] | 1080 | }
|
---|
| 1081 |
|
---|
| 1082 | /***********************************************************************
|
---|
[9400] | 1083 | * compobj_RegReadPath [internal]
|
---|
| 1084 | *
|
---|
| 1085 | * Reads a registry value and expands it when nessesary
|
---|
| 1086 | */
|
---|
| 1087 | HRESULT compobj_RegReadPath(char * keyname, char * valuename, char * dst, int dstlen)
|
---|
| 1088 | {
|
---|
| 1089 | HRESULT hres;
|
---|
| 1090 | HKEY key;
|
---|
| 1091 | DWORD keytype;
|
---|
| 1092 | char src[MAX_PATH];
|
---|
| 1093 | DWORD dwLength = dstlen;
|
---|
| 1094 |
|
---|
| 1095 | if((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key)) == ERROR_SUCCESS) {
|
---|
| 1096 | if( (hres = RegQueryValueExA(key, NULL, NULL, &keytype, (LPBYTE)src, &dwLength)) == ERROR_SUCCESS ) {
|
---|
| 1097 | if (keytype == REG_EXPAND_SZ) {
|
---|
| 1098 | if (dstlen <= ExpandEnvironmentStringsA(src, dst, dstlen)) hres = ERROR_MORE_DATA;
|
---|
| 1099 | } else {
|
---|
| 1100 | strncpy(dst, src, dstlen);
|
---|
| 1101 | }
|
---|
| 1102 | }
|
---|
| 1103 | RegCloseKey (key);
|
---|
| 1104 | }
|
---|
| 1105 | return hres;
|
---|
| 1106 | }
|
---|
| 1107 |
|
---|
| 1108 | /***********************************************************************
|
---|
[5602] | 1109 | * CoGetClassObject [COMPOBJ.7]
|
---|
[7926] | 1110 | * CoGetClassObject [OLE32.16]
|
---|
| 1111 | *
|
---|
[8620] | 1112 | * FIXME. If request allows of several options and there is a failure
|
---|
[7926] | 1113 | * with one (other than not being registered) do we try the
|
---|
| 1114 | * others or return failure? (E.g. inprocess is registered but
|
---|
| 1115 | * the DLL is not found but the server version works)
|
---|
[5602] | 1116 | */
|
---|
| 1117 | HRESULT WINAPI CoGetClassObject(
|
---|
| 1118 | REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
|
---|
| 1119 | REFIID iid, LPVOID *ppv
|
---|
| 1120 | ) {
|
---|
[6711] | 1121 | LPUNKNOWN regClassObject;
|
---|
| 1122 | HRESULT hres = E_UNEXPECTED;
|
---|
| 1123 | char xclsid[80];
|
---|
[5602] | 1124 | HINSTANCE hLibrary;
|
---|
| 1125 | #ifdef __WIN32OS2__
|
---|
[9400] | 1126 | typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
|
---|
[5602] | 1127 | #else
|
---|
[9400] | 1128 | typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
|
---|
[5602] | 1129 | #endif
|
---|
| 1130 | DllGetClassObjectFunc DllGetClassObject;
|
---|
| 1131 |
|
---|
| 1132 | WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
|
---|
| 1133 |
|
---|
[9400] | 1134 | TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
|
---|
[5602] | 1135 |
|
---|
| 1136 | if (pServerInfo) {
|
---|
[6711] | 1137 | FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
|
---|
| 1138 | FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
|
---|
[5602] | 1139 | }
|
---|
| 1140 |
|
---|
| 1141 | /*
|
---|
[7926] | 1142 | * First, try and see if we can't match the class ID with one of the
|
---|
[5602] | 1143 | * registered classes.
|
---|
| 1144 | */
|
---|
| 1145 | if (S_OK == COM_GetRegisteredClassObject(rclsid, dwClsContext, ®ClassObject))
|
---|
| 1146 | {
|
---|
| 1147 | /*
|
---|
| 1148 | * Get the required interface from the retrieved pointer.
|
---|
| 1149 | */
|
---|
| 1150 | hres = IUnknown_QueryInterface(regClassObject, iid, ppv);
|
---|
| 1151 |
|
---|
| 1152 | /*
|
---|
| 1153 | * Since QI got another reference on the pointer, we want to release the
|
---|
| 1154 | * one we already have. If QI was unsuccessful, this will release the object. This
|
---|
| 1155 | * is good since we are not returning it in the "out" parameter.
|
---|
| 1156 | */
|
---|
| 1157 | IUnknown_Release(regClassObject);
|
---|
| 1158 |
|
---|
| 1159 | return hres;
|
---|
| 1160 | }
|
---|
| 1161 |
|
---|
[9400] | 1162 | /* first try: in-process */
|
---|
| 1163 | if ((CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER) & dwClsContext) {
|
---|
| 1164 | char keyname[MAX_PATH];
|
---|
| 1165 | char dllpath[MAX_PATH+1];
|
---|
[5602] | 1166 |
|
---|
[9400] | 1167 | sprintf(keyname,"CLSID\\%s\\InprocServer32",xclsid);
|
---|
| 1168 |
|
---|
| 1169 | if ( compobj_RegReadPath(keyname, NULL, dllpath, sizeof(dllpath)) != ERROR_SUCCESS) {
|
---|
| 1170 | /* failure: CLSID is not found in registry */
|
---|
| 1171 | WARN("class %s not registred\n", xclsid);
|
---|
[7926] | 1172 | hres = REGDB_E_CLASSNOTREG;
|
---|
[9400] | 1173 | } else {
|
---|
| 1174 | if ((hLibrary = LoadLibraryExA(dllpath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
|
---|
| 1175 | /* failure: DLL could not be loaded */
|
---|
| 1176 | ERR("couldn't load InprocServer32 dll %s\n", dllpath);
|
---|
| 1177 | hres = E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */
|
---|
| 1178 | } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
|
---|
| 1179 | /* failure: the dll did not export DllGetClassObject */
|
---|
| 1180 | ERR("couldn't find function DllGetClassObject in %s\n", dllpath);
|
---|
| 1181 | FreeLibrary( hLibrary );
|
---|
| 1182 | hres = CO_E_DLLNOTFOUND;
|
---|
| 1183 | } else {
|
---|
| 1184 | /* OK: get the ClassObject */
|
---|
| 1185 | COMPOBJ_DLLList_Add( hLibrary );
|
---|
| 1186 | return DllGetClassObject(rclsid, iid, ppv);
|
---|
| 1187 | }
|
---|
[6711] | 1188 | }
|
---|
[7926] | 1189 | }
|
---|
[5602] | 1190 |
|
---|
[8620] | 1191 | /* Next try out of process */
|
---|
[7926] | 1192 | if (CLSCTX_LOCAL_SERVER & dwClsContext)
|
---|
| 1193 | {
|
---|
[8620] | 1194 | return create_marshalled_proxy(rclsid,iid,ppv);
|
---|
[5602] | 1195 | }
|
---|
[7926] | 1196 |
|
---|
[8620] | 1197 | /* Finally try remote */
|
---|
[7926] | 1198 | if (CLSCTX_REMOTE_SERVER & dwClsContext)
|
---|
| 1199 | {
|
---|
| 1200 | FIXME ("CLSCTX_REMOTE_SERVER not supported\n");
|
---|
[8620] | 1201 | hres = E_NOINTERFACE;
|
---|
[7926] | 1202 | }
|
---|
| 1203 |
|
---|
[5602] | 1204 | return hres;
|
---|
| 1205 | }
|
---|
| 1206 | /***********************************************************************
|
---|
[7926] | 1207 | * CoResumeClassObjects (OLE32.173)
|
---|
[5602] | 1208 | *
|
---|
| 1209 | * Resumes classobjects registered with REGCLS suspended
|
---|
| 1210 | */
|
---|
| 1211 | HRESULT WINAPI CoResumeClassObjects(void)
|
---|
| 1212 | {
|
---|
[6711] | 1213 | FIXME("\n");
|
---|
| 1214 | return S_OK;
|
---|
[5602] | 1215 | }
|
---|
| 1216 |
|
---|
| 1217 | /***********************************************************************
|
---|
[7926] | 1218 | * GetClassFile (OLE32.67)
|
---|
[5602] | 1219 | *
|
---|
| 1220 | * This function supplies the CLSID associated with the given filename.
|
---|
| 1221 | */
|
---|
[7926] | 1222 | HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
|
---|
[5602] | 1223 | {
|
---|
| 1224 | IStorage *pstg=0;
|
---|
| 1225 | HRESULT res;
|
---|
[9400] | 1226 | int nbElm, length, i;
|
---|
| 1227 | LONG sizeProgId;
|
---|
[5602] | 1228 | LPOLESTR *pathDec=0,absFile=0,progId=0;
|
---|
[9400] | 1229 | LPWSTR extension;
|
---|
| 1230 | static const WCHAR bkslashW[] = {'\\',0};
|
---|
| 1231 | static const WCHAR dotW[] = {'.',0};
|
---|
[5602] | 1232 |
|
---|
[9400] | 1233 | TRACE("%s, %p\n", debugstr_w(filePathName), pclsid);
|
---|
[5602] | 1234 |
|
---|
| 1235 | /* if the file contain a storage object the return the CLSID writen by IStorage_SetClass method*/
|
---|
| 1236 | if((StgIsStorageFile(filePathName))==S_OK){
|
---|
| 1237 |
|
---|
| 1238 | res=StgOpenStorage(filePathName,NULL,STGM_READ | STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
|
---|
| 1239 |
|
---|
| 1240 | if (SUCCEEDED(res))
|
---|
| 1241 | res=ReadClassStg(pstg,pclsid);
|
---|
| 1242 |
|
---|
| 1243 | IStorage_Release(pstg);
|
---|
| 1244 |
|
---|
| 1245 | return res;
|
---|
| 1246 | }
|
---|
| 1247 | /* if the file is not a storage object then attemps to match various bits in the file against a
|
---|
| 1248 | pattern in the registry. this case is not frequently used ! so I present only the psodocode for
|
---|
| 1249 | this case
|
---|
[7926] | 1250 |
|
---|
[5602] | 1251 | for(i=0;i<nFileTypes;i++)
|
---|
| 1252 |
|
---|
| 1253 | for(i=0;j<nPatternsForType;j++){
|
---|
| 1254 |
|
---|
| 1255 | PATTERN pat;
|
---|
| 1256 | HANDLE hFile;
|
---|
| 1257 |
|
---|
| 1258 | pat=ReadPatternFromRegistry(i,j);
|
---|
| 1259 | hFile=CreateFileW(filePathName,,,,,,hFile);
|
---|
| 1260 | SetFilePosition(hFile,pat.offset);
|
---|
| 1261 | ReadFile(hFile,buf,pat.size,NULL,NULL);
|
---|
| 1262 | if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
|
---|
| 1263 |
|
---|
| 1264 | *pclsid=ReadCLSIDFromRegistry(i);
|
---|
| 1265 | return S_OK;
|
---|
| 1266 | }
|
---|
| 1267 | }
|
---|
| 1268 | */
|
---|
| 1269 |
|
---|
| 1270 | /* if the obove strategies fail then search for the extension key in the registry */
|
---|
| 1271 |
|
---|
| 1272 | /* get the last element (absolute file) in the path name */
|
---|
| 1273 | nbElm=FileMonikerImpl_DecomposePath(filePathName,&pathDec);
|
---|
| 1274 | absFile=pathDec[nbElm-1];
|
---|
| 1275 |
|
---|
| 1276 | /* failed if the path represente a directory and not an absolute file name*/
|
---|
[9400] | 1277 | if (!lstrcmpW(absFile, bkslashW))
|
---|
[5602] | 1278 | return MK_E_INVALIDEXTENSION;
|
---|
| 1279 |
|
---|
| 1280 | /* get the extension of the file */
|
---|
[9400] | 1281 | extension = NULL;
|
---|
[5602] | 1282 | length=lstrlenW(absFile);
|
---|
[9400] | 1283 | for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--)
|
---|
| 1284 | /* nothing */;
|
---|
[7926] | 1285 |
|
---|
[9400] | 1286 | if (!extension || !lstrcmpW(extension, dotW))
|
---|
| 1287 | return MK_E_INVALIDEXTENSION;
|
---|
[5602] | 1288 |
|
---|
[9400] | 1289 | res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId);
|
---|
[5602] | 1290 |
|
---|
[9400] | 1291 | /* get the progId associated to the extension */
|
---|
| 1292 | progId = CoTaskMemAlloc(sizeProgId);
|
---|
| 1293 | res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
|
---|
[5602] | 1294 |
|
---|
| 1295 | if (res==ERROR_SUCCESS)
|
---|
| 1296 | /* return the clsid associated to the progId */
|
---|
| 1297 | res= CLSIDFromProgID(progId,pclsid);
|
---|
| 1298 |
|
---|
| 1299 | for(i=0; pathDec[i]!=NULL;i++)
|
---|
| 1300 | CoTaskMemFree(pathDec[i]);
|
---|
| 1301 | CoTaskMemFree(pathDec);
|
---|
| 1302 |
|
---|
| 1303 | CoTaskMemFree(progId);
|
---|
| 1304 |
|
---|
| 1305 | if (res==ERROR_SUCCESS)
|
---|
| 1306 | return res;
|
---|
| 1307 |
|
---|
| 1308 | return MK_E_INVALIDEXTENSION;
|
---|
| 1309 | }
|
---|
| 1310 | /***********************************************************************
|
---|
[7926] | 1311 | * CoCreateInstance [COMPOBJ.13]
|
---|
| 1312 | * CoCreateInstance [OLE32.7]
|
---|
[5602] | 1313 | */
|
---|
| 1314 | HRESULT WINAPI CoCreateInstance(
|
---|
[6711] | 1315 | REFCLSID rclsid,
|
---|
| 1316 | LPUNKNOWN pUnkOuter,
|
---|
| 1317 | DWORD dwClsContext,
|
---|
| 1318 | REFIID iid,
|
---|
[7926] | 1319 | LPVOID *ppv)
|
---|
[5602] | 1320 | {
|
---|
[6711] | 1321 | HRESULT hres;
|
---|
| 1322 | LPCLASSFACTORY lpclf = 0;
|
---|
[5602] | 1323 |
|
---|
| 1324 | /*
|
---|
| 1325 | * Sanity check
|
---|
| 1326 | */
|
---|
| 1327 | if (ppv==0)
|
---|
| 1328 | return E_POINTER;
|
---|
| 1329 |
|
---|
| 1330 | /*
|
---|
| 1331 | * Initialize the "out" parameter
|
---|
| 1332 | */
|
---|
| 1333 | *ppv = 0;
|
---|
[7926] | 1334 |
|
---|
[5602] | 1335 | /*
|
---|
| 1336 | * Get a class factory to construct the object we want.
|
---|
| 1337 | */
|
---|
| 1338 | hres = CoGetClassObject(rclsid,
|
---|
[6711] | 1339 | dwClsContext,
|
---|
| 1340 | NULL,
|
---|
| 1341 | &IID_IClassFactory,
|
---|
| 1342 | (LPVOID)&lpclf);
|
---|
[5602] | 1343 |
|
---|
| 1344 | if (FAILED(hres)) {
|
---|
[7926] | 1345 | FIXME("no classfactory created for CLSID %s, hres is 0x%08lx\n",
|
---|
| 1346 | debugstr_guid(rclsid),hres);
|
---|
[5602] | 1347 | return hres;
|
---|
| 1348 | }
|
---|
| 1349 |
|
---|
| 1350 | /*
|
---|
| 1351 | * Create the object and don't forget to release the factory
|
---|
| 1352 | */
|
---|
[6711] | 1353 | hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
|
---|
| 1354 | IClassFactory_Release(lpclf);
|
---|
[7926] | 1355 | if(FAILED(hres))
|
---|
| 1356 | FIXME("no instance created for interface %s of class %s, hres is 0x%08lx\n",
|
---|
| 1357 | debugstr_guid(iid), debugstr_guid(rclsid),hres);
|
---|
[5602] | 1358 |
|
---|
[6711] | 1359 | return hres;
|
---|
[5602] | 1360 | }
|
---|
| 1361 |
|
---|
| 1362 | /***********************************************************************
|
---|
| 1363 | * CoCreateInstanceEx [OLE32.165]
|
---|
| 1364 | */
|
---|
| 1365 | HRESULT WINAPI CoCreateInstanceEx(
|
---|
[7926] | 1366 | REFCLSID rclsid,
|
---|
[5602] | 1367 | LPUNKNOWN pUnkOuter,
|
---|
[7926] | 1368 | DWORD dwClsContext,
|
---|
[5602] | 1369 | COSERVERINFO* pServerInfo,
|
---|
| 1370 | ULONG cmq,
|
---|
| 1371 | MULTI_QI* pResults)
|
---|
| 1372 | {
|
---|
| 1373 | IUnknown* pUnk = NULL;
|
---|
| 1374 | HRESULT hr;
|
---|
| 1375 | ULONG index;
|
---|
| 1376 | int successCount = 0;
|
---|
| 1377 |
|
---|
[10625] | 1378 | TRACE("s%: (rclsid=%p, pUnkOuter=%p, dwClsContext=0x%lf, pServerInfo=%p, cmq=%p, pResults=%p)\n",
|
---|
| 1379 | __FUNCTION__, rclsid, pUnkOuter, dwClsContext, pServerInfo, cmq, pResults);
|
---|
[5602] | 1380 | /*
|
---|
| 1381 | * Sanity check
|
---|
| 1382 | */
|
---|
| 1383 | if ( (cmq==0) || (pResults==NULL))
|
---|
| 1384 | return E_INVALIDARG;
|
---|
| 1385 |
|
---|
| 1386 | if (pServerInfo!=NULL)
|
---|
| 1387 | FIXME("() non-NULL pServerInfo not supported!\n");
|
---|
| 1388 |
|
---|
| 1389 | /*
|
---|
| 1390 | * Initialize all the "out" parameters.
|
---|
| 1391 | */
|
---|
| 1392 | for (index = 0; index < cmq; index++)
|
---|
| 1393 | {
|
---|
| 1394 | pResults[index].pItf = NULL;
|
---|
| 1395 | pResults[index].hr = E_NOINTERFACE;
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | /*
|
---|
| 1399 | * Get the object and get its IUnknown pointer.
|
---|
| 1400 | */
|
---|
[7926] | 1401 | hr = CoCreateInstance(rclsid,
|
---|
[6711] | 1402 | pUnkOuter,
|
---|
| 1403 | dwClsContext,
|
---|
| 1404 | &IID_IUnknown,
|
---|
| 1405 | (VOID**)&pUnk);
|
---|
[5602] | 1406 |
|
---|
| 1407 | if (hr)
|
---|
| 1408 | return hr;
|
---|
| 1409 |
|
---|
| 1410 | /*
|
---|
| 1411 | * Then, query for all the interfaces requested.
|
---|
| 1412 | */
|
---|
| 1413 | for (index = 0; index < cmq; index++)
|
---|
| 1414 | {
|
---|
| 1415 | pResults[index].hr = IUnknown_QueryInterface(pUnk,
|
---|
[6711] | 1416 | pResults[index].pIID,
|
---|
| 1417 | (VOID**)&(pResults[index].pItf));
|
---|
[5602] | 1418 |
|
---|
| 1419 | if (pResults[index].hr == S_OK)
|
---|
| 1420 | successCount++;
|
---|
| 1421 | }
|
---|
| 1422 |
|
---|
| 1423 | /*
|
---|
| 1424 | * Release our temporary unknown pointer.
|
---|
| 1425 | */
|
---|
| 1426 | IUnknown_Release(pUnk);
|
---|
| 1427 |
|
---|
| 1428 | if (successCount == 0)
|
---|
| 1429 | return E_NOINTERFACE;
|
---|
| 1430 |
|
---|
| 1431 | if (successCount!=cmq)
|
---|
| 1432 | return CO_S_NOTALLINTERFACES;
|
---|
| 1433 |
|
---|
| 1434 | return S_OK;
|
---|
| 1435 | }
|
---|
| 1436 |
|
---|
| 1437 | /***********************************************************************
|
---|
[9400] | 1438 | * CoLoadLibrary (OLE32.30)
|
---|
| 1439 | */
|
---|
| 1440 | HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree)
|
---|
| 1441 | {
|
---|
| 1442 | TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree);
|
---|
| 1443 |
|
---|
| 1444 | return LoadLibraryExW(lpszLibName, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
|
---|
| 1445 | }
|
---|
| 1446 |
|
---|
| 1447 | /***********************************************************************
|
---|
[7926] | 1448 | * CoFreeLibrary [OLE32.13]
|
---|
[9400] | 1449 | *
|
---|
| 1450 | * NOTES: don't belive the docu
|
---|
[5602] | 1451 | */
|
---|
| 1452 | void WINAPI CoFreeLibrary(HINSTANCE hLibrary)
|
---|
| 1453 | {
|
---|
[9400] | 1454 | FreeLibrary(hLibrary);
|
---|
[5602] | 1455 | }
|
---|
| 1456 |
|
---|
| 1457 |
|
---|
| 1458 | /***********************************************************************
|
---|
[7926] | 1459 | * CoFreeAllLibraries [OLE32.12]
|
---|
[9400] | 1460 | *
|
---|
| 1461 | * NOTES: don't belive the docu
|
---|
[5602] | 1462 | */
|
---|
| 1463 | void WINAPI CoFreeAllLibraries(void)
|
---|
| 1464 | {
|
---|
[9400] | 1465 | /* NOP */
|
---|
[5602] | 1466 | }
|
---|
| 1467 |
|
---|
| 1468 |
|
---|
| 1469 | /***********************************************************************
|
---|
| 1470 | * CoFreeUnusedLibraries [COMPOBJ.17]
|
---|
[7926] | 1471 | * CoFreeUnusedLibraries [OLE32.14]
|
---|
[9400] | 1472 | *
|
---|
| 1473 | * FIXME: Calls to CoFreeUnusedLibraries from any thread always route
|
---|
| 1474 | * through the main apartment's thread to call DllCanUnloadNow
|
---|
[5602] | 1475 | */
|
---|
| 1476 | void WINAPI CoFreeUnusedLibraries(void)
|
---|
| 1477 | {
|
---|
[9400] | 1478 | COMPOBJ_DllList_FreeUnused(0);
|
---|
[5602] | 1479 | }
|
---|
| 1480 |
|
---|
| 1481 | /***********************************************************************
|
---|
[7926] | 1482 | * CoFileTimeNow [COMPOBJ.82]
|
---|
| 1483 | * CoFileTimeNow [OLE32.10]
|
---|
| 1484 | *
|
---|
[5602] | 1485 | * RETURNS
|
---|
[6711] | 1486 | * the current system time in lpFileTime
|
---|
[5602] | 1487 | */
|
---|
| 1488 | HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */
|
---|
| 1489 | {
|
---|
| 1490 | GetSystemTimeAsFileTime( lpFileTime );
|
---|
| 1491 | return S_OK;
|
---|
| 1492 | }
|
---|
| 1493 |
|
---|
| 1494 | /***********************************************************************
|
---|
[9400] | 1495 | * CoLoadLibrary (OLE32.30)
|
---|
[5602] | 1496 | */
|
---|
[9400] | 1497 | static void COM_RevokeAllClasses()
|
---|
| 1498 | {
|
---|
| 1499 | EnterCriticalSection( &csRegisteredClassList );
|
---|
[5602] | 1500 |
|
---|
[9400] | 1501 | while (firstRegisteredClass!=0)
|
---|
| 1502 | {
|
---|
| 1503 | CoRevokeClassObject(firstRegisteredClass->dwCookie);
|
---|
| 1504 | }
|
---|
[5602] | 1505 |
|
---|
[9400] | 1506 | LeaveCriticalSection( &csRegisteredClassList );
|
---|
[5602] | 1507 | }
|
---|
[9400] | 1508 |
|
---|
| 1509 | /****************************************************************************
|
---|
| 1510 | * COM External Lock methods implementation
|
---|
| 1511 | *
|
---|
| 1512 | * This api provides a linked list to managed external references to
|
---|
| 1513 | * COM objects.
|
---|
| 1514 | *
|
---|
| 1515 | * The public interface consists of three calls:
|
---|
| 1516 | * COM_ExternalLockAddRef
|
---|
| 1517 | * COM_ExternalLockRelease
|
---|
| 1518 | * COM_ExternalLockFreeList
|
---|
[5602] | 1519 | */
|
---|
| 1520 |
|
---|
[9400] | 1521 | #define EL_END_OF_LIST 0
|
---|
| 1522 | #define EL_NOT_FOUND 0
|
---|
[5602] | 1523 |
|
---|
[9400] | 1524 | /*
|
---|
| 1525 | * Declaration of the static structure that manage the
|
---|
| 1526 | * external lock to COM objects.
|
---|
| 1527 | */
|
---|
| 1528 | typedef struct COM_ExternalLock COM_ExternalLock;
|
---|
| 1529 | typedef struct COM_ExternalLockList COM_ExternalLockList;
|
---|
[5602] | 1530 |
|
---|
[9400] | 1531 | struct COM_ExternalLock
|
---|
[5602] | 1532 | {
|
---|
[9400] | 1533 | IUnknown *pUnk; /* IUnknown referenced */
|
---|
| 1534 | ULONG uRefCount; /* external lock counter to IUnknown object*/
|
---|
| 1535 | COM_ExternalLock *next; /* Pointer to next element in list */
|
---|
| 1536 | };
|
---|
[7926] | 1537 |
|
---|
[9400] | 1538 | struct COM_ExternalLockList
|
---|
| 1539 | {
|
---|
| 1540 | COM_ExternalLock *head; /* head of list */
|
---|
| 1541 | };
|
---|
[5602] | 1542 |
|
---|
[9400] | 1543 | /*
|
---|
| 1544 | * Declaration and initialization of the static structure that manages
|
---|
| 1545 | * the external lock to COM objects.
|
---|
| 1546 | */
|
---|
| 1547 | static COM_ExternalLockList elList = { EL_END_OF_LIST };
|
---|
[5602] | 1548 |
|
---|
[9400] | 1549 | /*
|
---|
| 1550 | * Private methods used to managed the linked list
|
---|
[5602] | 1551 | */
|
---|
[7926] | 1552 |
|
---|
[5602] | 1553 |
|
---|
[9400] | 1554 | static COM_ExternalLock* COM_ExternalLockLocate(
|
---|
| 1555 | COM_ExternalLock *element,
|
---|
| 1556 | IUnknown *pUnk);
|
---|
[5602] | 1557 |
|
---|
[9400] | 1558 | /****************************************************************************
|
---|
| 1559 | * Internal - Insert a new IUnknown* to the linked list
|
---|
| 1560 | */
|
---|
| 1561 | static BOOL COM_ExternalLockInsert(
|
---|
| 1562 | IUnknown *pUnk)
|
---|
| 1563 | {
|
---|
| 1564 | COM_ExternalLock *newLock = NULL;
|
---|
| 1565 | COM_ExternalLock *previousHead = NULL;
|
---|
[5602] | 1566 |
|
---|
[9400] | 1567 | /*
|
---|
| 1568 | * Allocate space for the new storage object
|
---|
| 1569 | */
|
---|
| 1570 | newLock = HeapAlloc(GetProcessHeap(), 0, sizeof(COM_ExternalLock));
|
---|
[7926] | 1571 |
|
---|
[9400] | 1572 | if (newLock!=NULL) {
|
---|
| 1573 | if ( elList.head == EL_END_OF_LIST ) {
|
---|
| 1574 | elList.head = newLock; /* The list is empty */
|
---|
[5602] | 1575 | } else {
|
---|
[9400] | 1576 | /* insert does it at the head */
|
---|
| 1577 | previousHead = elList.head;
|
---|
| 1578 | elList.head = newLock;
|
---|
[5602] | 1579 | }
|
---|
[7926] | 1580 |
|
---|
[9400] | 1581 | /* Set new list item data member */
|
---|
| 1582 | newLock->pUnk = pUnk;
|
---|
| 1583 | newLock->uRefCount = 1;
|
---|
| 1584 | newLock->next = previousHead;
|
---|
[7926] | 1585 |
|
---|
[9400] | 1586 | return TRUE;
|
---|
| 1587 | }
|
---|
| 1588 | return FALSE;
|
---|
[5602] | 1589 | }
|
---|
| 1590 |
|
---|
[9400] | 1591 | /****************************************************************************
|
---|
| 1592 | * Internal - Method that removes an item from the linked list.
|
---|
[5602] | 1593 | */
|
---|
[9400] | 1594 | static void COM_ExternalLockDelete(
|
---|
| 1595 | COM_ExternalLock *itemList)
|
---|
| 1596 | {
|
---|
| 1597 | COM_ExternalLock *current = elList.head;
|
---|
[5602] | 1598 |
|
---|
[9400] | 1599 | if ( current == itemList ) {
|
---|
| 1600 | /* this section handles the deletion of the first node */
|
---|
| 1601 | elList.head = itemList->next;
|
---|
| 1602 | HeapFree( GetProcessHeap(), 0, itemList);
|
---|
| 1603 | } else {
|
---|
| 1604 | do {
|
---|
| 1605 | if ( current->next == itemList ){ /* We found the item to free */
|
---|
| 1606 | current->next = itemList->next; /* readjust the list pointers */
|
---|
| 1607 | HeapFree( GetProcessHeap(), 0, itemList);
|
---|
| 1608 | break;
|
---|
| 1609 | }
|
---|
[5602] | 1610 |
|
---|
[9400] | 1611 | /* Skip to the next item */
|
---|
| 1612 | current = current->next;
|
---|
[5602] | 1613 |
|
---|
[9400] | 1614 | } while ( current != EL_END_OF_LIST );
|
---|
[5602] | 1615 | }
|
---|
| 1616 | }
|
---|
| 1617 |
|
---|
[9400] | 1618 | /****************************************************************************
|
---|
| 1619 | * Internal - Recursivity agent for IUnknownExternalLockList_Find
|
---|
[5602] | 1620 | *
|
---|
[9400] | 1621 | * NOTES: how long can the list be ?? (recursive!!!)
|
---|
[5602] | 1622 | */
|
---|
[9400] | 1623 | static COM_ExternalLock* COM_ExternalLockLocate( COM_ExternalLock *element, IUnknown *pUnk)
|
---|
[5602] | 1624 | {
|
---|
[9400] | 1625 | if ( element == EL_END_OF_LIST )
|
---|
| 1626 | return EL_NOT_FOUND;
|
---|
| 1627 | else if ( element->pUnk == pUnk ) /* We found it */
|
---|
| 1628 | return element;
|
---|
| 1629 | else /* Not the right guy, keep on looking */
|
---|
| 1630 | return COM_ExternalLockLocate( element->next, pUnk);
|
---|
[5602] | 1631 | }
|
---|
| 1632 |
|
---|
| 1633 | /****************************************************************************
|
---|
[7926] | 1634 | * Public - Method that increments the count for a IUnknown* in the linked
|
---|
[5602] | 1635 | * list. The item is inserted if not already in the list.
|
---|
| 1636 | */
|
---|
[9400] | 1637 | static void COM_ExternalLockAddRef(IUnknown *pUnk)
|
---|
[5602] | 1638 | {
|
---|
[9400] | 1639 | COM_ExternalLock *externalLock = COM_ExternalLockLocate(elList.head, pUnk);
|
---|
[5602] | 1640 |
|
---|
| 1641 | /*
|
---|
| 1642 | * Add an external lock to the object. If it was already externally
|
---|
| 1643 | * locked, just increase the reference count. If it was not.
|
---|
| 1644 | * add the item to the list.
|
---|
| 1645 | */
|
---|
| 1646 | if ( externalLock == EL_NOT_FOUND )
|
---|
| 1647 | COM_ExternalLockInsert(pUnk);
|
---|
| 1648 | else
|
---|
| 1649 | externalLock->uRefCount++;
|
---|
| 1650 |
|
---|
| 1651 | /*
|
---|
| 1652 | * Add an internal lock to the object
|
---|
| 1653 | */
|
---|
[7926] | 1654 | IUnknown_AddRef(pUnk);
|
---|
[5602] | 1655 | }
|
---|
| 1656 |
|
---|
| 1657 | /****************************************************************************
|
---|
[7926] | 1658 | * Public - Method that decrements the count for a IUnknown* in the linked
|
---|
[5602] | 1659 | * list. The item is removed from the list if its count end up at zero or if
|
---|
| 1660 | * bRelAll is TRUE.
|
---|
| 1661 | */
|
---|
| 1662 | static void COM_ExternalLockRelease(
|
---|
| 1663 | IUnknown *pUnk,
|
---|
| 1664 | BOOL bRelAll)
|
---|
| 1665 | {
|
---|
[9400] | 1666 | COM_ExternalLock *externalLock = COM_ExternalLockLocate(elList.head, pUnk);
|
---|
[5602] | 1667 |
|
---|
[9400] | 1668 | if ( externalLock != EL_NOT_FOUND ) {
|
---|
| 1669 | do {
|
---|
[5602] | 1670 | externalLock->uRefCount--; /* release external locks */
|
---|
| 1671 | IUnknown_Release(pUnk); /* release local locks as well */
|
---|
| 1672 |
|
---|
[9400] | 1673 | if ( bRelAll == FALSE ) break; /* perform single release */
|
---|
[5602] | 1674 |
|
---|
[7926] | 1675 | } while ( externalLock->uRefCount > 0 );
|
---|
[5602] | 1676 |
|
---|
| 1677 | if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */
|
---|
| 1678 | COM_ExternalLockDelete(externalLock);
|
---|
| 1679 | }
|
---|
| 1680 | }
|
---|
| 1681 | /****************************************************************************
|
---|
| 1682 | * Public - Method that frees the content of the list.
|
---|
| 1683 | */
|
---|
| 1684 | static void COM_ExternalLockFreeList()
|
---|
| 1685 | {
|
---|
| 1686 | COM_ExternalLock *head;
|
---|
| 1687 |
|
---|
| 1688 | head = elList.head; /* grab it by the head */
|
---|
[9400] | 1689 | while ( head != EL_END_OF_LIST ) {
|
---|
[5602] | 1690 | COM_ExternalLockDelete(head); /* get rid of the head stuff */
|
---|
[7926] | 1691 | head = elList.head; /* get the new head... */
|
---|
[5602] | 1692 | }
|
---|
| 1693 | }
|
---|
| 1694 |
|
---|
| 1695 | /****************************************************************************
|
---|
| 1696 | * Public - Method that dump the content of the list.
|
---|
| 1697 | */
|
---|
| 1698 | void COM_ExternalLockDump()
|
---|
| 1699 | {
|
---|
| 1700 | COM_ExternalLock *current = elList.head;
|
---|
| 1701 |
|
---|
| 1702 | DPRINTF("\nExternal lock list contains:\n");
|
---|
| 1703 |
|
---|
[9400] | 1704 | while ( current != EL_END_OF_LIST ) {
|
---|
| 1705 | DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount);
|
---|
[7926] | 1706 |
|
---|
| 1707 | /* Skip to the next item */
|
---|
[5602] | 1708 | current = current->next;
|
---|
[7926] | 1709 | }
|
---|
[5602] | 1710 | }
|
---|
| 1711 |
|
---|
[9400] | 1712 | /******************************************************************************
|
---|
| 1713 | * CoLockObjectExternal [OLE32.31]
|
---|
[5602] | 1714 | */
|
---|
[9400] | 1715 | HRESULT WINAPI CoLockObjectExternal(
|
---|
| 1716 | LPUNKNOWN pUnk, /* [in] object to be locked */
|
---|
| 1717 | BOOL fLock, /* [in] do lock */
|
---|
| 1718 | BOOL fLastUnlockReleases) /* [in] unlock all */
|
---|
[5602] | 1719 | {
|
---|
| 1720 |
|
---|
[9400] | 1721 | if (fLock) {
|
---|
| 1722 | /*
|
---|
| 1723 | * Increment the external lock coutner, COM_ExternalLockAddRef also
|
---|
| 1724 | * increment the object's internal lock counter.
|
---|
| 1725 | */
|
---|
| 1726 | COM_ExternalLockAddRef( pUnk);
|
---|
| 1727 | } else {
|
---|
| 1728 | /*
|
---|
| 1729 | * Decrement the external lock coutner, COM_ExternalLockRelease also
|
---|
| 1730 | * decrement the object's internal lock counter.
|
---|
| 1731 | */
|
---|
| 1732 | COM_ExternalLockRelease( pUnk, fLastUnlockReleases);
|
---|
| 1733 | }
|
---|
[5602] | 1734 |
|
---|
[9400] | 1735 | return S_OK;
|
---|
[5602] | 1736 | }
|
---|
| 1737 |
|
---|
[9400] | 1738 | /***********************************************************************
|
---|
| 1739 | * CoInitializeWOW (OLE32.27)
|
---|
[5602] | 1740 | */
|
---|
[9400] | 1741 | HRESULT WINAPI CoInitializeWOW(DWORD x,DWORD y) {
|
---|
| 1742 | FIXME("(0x%08lx,0x%08lx),stub!\n",x,y);
|
---|
| 1743 | return 0;
|
---|
| 1744 | }
|
---|
[5602] | 1745 |
|
---|
[9400] | 1746 | static IUnknown * pUnkState = 0; /* FIXME: thread local */
|
---|
| 1747 | static int nStatCounter = 0; /* global */
|
---|
| 1748 | static HMODULE hOleAut32 = 0; /* global */
|
---|
[5602] | 1749 |
|
---|
[9400] | 1750 | /***********************************************************************
|
---|
| 1751 | * CoGetState [OLE32.24]
|
---|
| 1752 | *
|
---|
| 1753 | * NOTES: might be incomplete
|
---|
[5602] | 1754 | */
|
---|
[9400] | 1755 | HRESULT WINAPI CoGetState(IUnknown ** ppv)
|
---|
[5602] | 1756 | {
|
---|
[9400] | 1757 | FIXME("\n");
|
---|
[5602] | 1758 |
|
---|
[9400] | 1759 | if(pUnkState) {
|
---|
| 1760 | IUnknown_AddRef(pUnkState);
|
---|
| 1761 | *ppv = pUnkState;
|
---|
| 1762 | FIXME("-- %p\n", *ppv);
|
---|
| 1763 | return S_OK;
|
---|
| 1764 | }
|
---|
| 1765 | *ppv = NULL;
|
---|
| 1766 | return E_FAIL;
|
---|
[7926] | 1767 |
|
---|
[5602] | 1768 | }
|
---|
| 1769 |
|
---|
| 1770 | /***********************************************************************
|
---|
[9400] | 1771 | * CoSetState [OLE32.42]
|
---|
[5602] | 1772 | *
|
---|
[9400] | 1773 | * NOTES: FIXME: protect this with a crst
|
---|
[5602] | 1774 | */
|
---|
[9400] | 1775 | HRESULT WINAPI CoSetState(IUnknown * pv)
|
---|
[5602] | 1776 | {
|
---|
[9400] | 1777 | FIXME("(%p),stub!\n", pv);
|
---|
[5602] | 1778 |
|
---|
[9400] | 1779 | if (pv) {
|
---|
| 1780 | IUnknown_AddRef(pv);
|
---|
| 1781 | nStatCounter++;
|
---|
| 1782 | if (nStatCounter == 1) LoadLibraryA("OLEAUT32.DLL");
|
---|
| 1783 | }
|
---|
| 1784 |
|
---|
| 1785 | if (pUnkState) {
|
---|
| 1786 | TRACE("-- release %p now\n", pUnkState);
|
---|
| 1787 | IUnknown_Release(pUnkState);
|
---|
| 1788 | nStatCounter--;
|
---|
| 1789 | if (!nStatCounter) FreeLibrary(hOleAut32);
|
---|
| 1790 | }
|
---|
| 1791 | pUnkState = pv;
|
---|
| 1792 | return S_OK;
|
---|
[5602] | 1793 | }
|
---|
[7926] | 1794 |
|
---|
[9400] | 1795 |
|
---|
[5602] | 1796 | /******************************************************************************
|
---|
| 1797 | * OleGetAutoConvert [OLE32.104]
|
---|
| 1798 | */
|
---|
| 1799 | HRESULT WINAPI OleGetAutoConvert(REFCLSID clsidOld, LPCLSID pClsidNew)
|
---|
| 1800 | {
|
---|
| 1801 | HKEY hkey = 0;
|
---|
| 1802 | char buf[200];
|
---|
| 1803 | WCHAR wbuf[200];
|
---|
| 1804 | DWORD len;
|
---|
| 1805 | HRESULT res = S_OK;
|
---|
| 1806 |
|
---|
| 1807 | sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
|
---|
| 1808 | if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
|
---|
| 1809 | {
|
---|
| 1810 | res = REGDB_E_CLASSNOTREG;
|
---|
[6711] | 1811 | goto done;
|
---|
[5602] | 1812 | }
|
---|
| 1813 | len = 200;
|
---|
| 1814 | /* we can just query for the default value of AutoConvertTo key like that,
|
---|
| 1815 | without opening the AutoConvertTo key and querying for NULL (default) */
|
---|
| 1816 | if (RegQueryValueA(hkey,"AutoConvertTo",buf,&len))
|
---|
| 1817 | {
|
---|
| 1818 | res = REGDB_E_KEYMISSING;
|
---|
[6711] | 1819 | goto done;
|
---|
[5602] | 1820 | }
|
---|
| 1821 | MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) );
|
---|
| 1822 | CLSIDFromString(wbuf,pClsidNew);
|
---|
| 1823 | done:
|
---|
[9400] | 1824 | if (hkey) RegCloseKey(hkey);
|
---|
| 1825 | return res;
|
---|
[5602] | 1826 | }
|
---|
| 1827 |
|
---|
| 1828 | /******************************************************************************
|
---|
| 1829 | * OleSetAutoConvert [OLE32.126]
|
---|
| 1830 | */
|
---|
| 1831 | HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
|
---|
| 1832 | {
|
---|
[7926] | 1833 | HKEY hkey = 0;
|
---|
[5602] | 1834 | char buf[200], szClsidNew[200];
|
---|
| 1835 | HRESULT res = S_OK;
|
---|
| 1836 |
|
---|
[7926] | 1837 | TRACE("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
|
---|
[5602] | 1838 | sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
|
---|
| 1839 | WINE_StringFromCLSID(clsidNew, szClsidNew);
|
---|
| 1840 | if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
|
---|
| 1841 | {
|
---|
| 1842 | res = REGDB_E_CLASSNOTREG;
|
---|
[6711] | 1843 | goto done;
|
---|
[5602] | 1844 | }
|
---|
[7926] | 1845 | if (RegSetValueA(hkey, "AutoConvertTo", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
|
---|
[5602] | 1846 | {
|
---|
| 1847 | res = REGDB_E_WRITEREGDB;
|
---|
[6711] | 1848 | goto done;
|
---|
[5602] | 1849 | }
|
---|
[7926] | 1850 |
|
---|
| 1851 | done:
|
---|
| 1852 | if (hkey) RegCloseKey(hkey);
|
---|
| 1853 | return res;
|
---|
| 1854 | }
|
---|
| 1855 |
|
---|
| 1856 | /******************************************************************************
|
---|
| 1857 | * CoTreatAsClass [OLE32.46]
|
---|
| 1858 | */
|
---|
| 1859 | HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
|
---|
| 1860 | {
|
---|
| 1861 | HKEY hkey = 0;
|
---|
| 1862 | char buf[200], szClsidNew[200];
|
---|
| 1863 | HRESULT res = S_OK;
|
---|
| 1864 |
|
---|
| 1865 | FIXME("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
|
---|
| 1866 | sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
|
---|
| 1867 | WINE_StringFromCLSID(clsidNew, szClsidNew);
|
---|
| 1868 | if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
|
---|
[5602] | 1869 | {
|
---|
[7926] | 1870 | res = REGDB_E_CLASSNOTREG;
|
---|
| 1871 | goto done;
|
---|
| 1872 | }
|
---|
| 1873 | if (RegSetValueA(hkey, "AutoTreatAs", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
|
---|
| 1874 | {
|
---|
[5602] | 1875 | res = REGDB_E_WRITEREGDB;
|
---|
[6711] | 1876 | goto done;
|
---|
[5602] | 1877 | }
|
---|
| 1878 |
|
---|
| 1879 | done:
|
---|
| 1880 | if (hkey) RegCloseKey(hkey);
|
---|
| 1881 | return res;
|
---|
| 1882 | }
|
---|
| 1883 |
|
---|
[7926] | 1884 |
|
---|
[5602] | 1885 | /***********************************************************************
|
---|
| 1886 | * IsEqualGUID [OLE32.76]
|
---|
| 1887 | *
|
---|
| 1888 | * Compares two Unique Identifiers.
|
---|
| 1889 | *
|
---|
| 1890 | * RETURNS
|
---|
[6711] | 1891 | * TRUE if equal
|
---|
[5602] | 1892 | */
|
---|
| 1893 | #undef IsEqualGUID
|
---|
| 1894 | BOOL WINAPI IsEqualGUID(
|
---|
| 1895 | REFGUID rguid1, /* [in] unique id 1 */
|
---|
| 1896 | REFGUID rguid2 /* [in] unique id 2 */
|
---|
| 1897 | )
|
---|
| 1898 | {
|
---|
| 1899 | return !memcmp(rguid1,rguid2,sizeof(GUID));
|
---|
| 1900 | }
|
---|
[9400] | 1901 |
|
---|
| 1902 | /***********************************************************************
|
---|
| 1903 | * CoInitializeSecurity [OLE32.164]
|
---|
| 1904 | */
|
---|
| 1905 | HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR pSecDesc, LONG cAuthSvc,
|
---|
| 1906 | SOLE_AUTHENTICATION_SERVICE* asAuthSvc,
|
---|
| 1907 | void* pReserved1, DWORD dwAuthnLevel,
|
---|
| 1908 | DWORD dwImpLevel, void* pReserved2,
|
---|
| 1909 | DWORD dwCapabilities, void* pReserved3)
|
---|
| 1910 | {
|
---|
| 1911 | FIXME("(%p,%ld,%p,%p,%ld,%ld,%p,%ld,%p) - stub!\n", pSecDesc, cAuthSvc,
|
---|
| 1912 | asAuthSvc, pReserved1, dwAuthnLevel, dwImpLevel, pReserved2,
|
---|
| 1913 | dwCapabilities, pReserved3);
|
---|
| 1914 | return S_OK;
|
---|
| 1915 | }
|
---|
[22048] | 1916 |
|
---|
| 1917 | /***********************************************************************
|
---|
| 1918 | * CoCopyProxy [OLE32.167]
|
---|
| 1919 | */
|
---|
| 1920 | HRESULT WINAPI CoCopyProxy(IUnknown* pProxy, IUnknown** ppCopy)
|
---|
| 1921 | {
|
---|
| 1922 | FIXME("(%p,%p) - stub!\n", pProxy, ppCopy);
|
---|
| 1923 | return E_NOTIMPL;
|
---|
| 1924 | }
|
---|
| 1925 |
|
---|
| 1926 | /***********************************************************************
|
---|
| 1927 | * CoQueryProxyBlanket [OLE32.188]
|
---|
| 1928 | */
|
---|
| 1929 | HRESULT WINAPI CoQueryProxyBlanket(IUnknown* pProxy, DWORD* pwAuthnSvc, DWORD* pAuthzSvc, OLECHAR** pServerPrincName, DWORD* pAuthnLevel, DWORD* pImpLevel, RPC_AUTH_IDENTITY_HANDLE* pAuthInfo, DWORD* pCapabilites)
|
---|
| 1930 | {
|
---|
| 1931 | FIXME("(%p,%p,%p,%p,%p,%p,%p,%p) - stub!\n", pProxy, pwAuthnSvc,
|
---|
| 1932 | pAuthzSvc, pServerPrincName, pAuthnLevel, pImpLevel, pAuthInfo,
|
---|
| 1933 | pCapabilites);
|
---|
| 1934 | return E_NOTIMPL;
|
---|
| 1935 | }
|
---|
| 1936 |
|
---|
| 1937 | /***********************************************************************
|
---|
| 1938 | * CoSetProxyBlanket [OLE32.175]
|
---|
| 1939 | */
|
---|
| 1940 | HRESULT WINAPI CoSetProxyBlanket(IUnknown* pProxy, DWORD dwAuthnSvc, DWORD dwAuthzSvc, OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities)
|
---|
| 1941 | {
|
---|
| 1942 | FIXME("(%p,%ld,%ld,%p,%ld,%ld,%p,%ld) - stub!\n", pProxy, dwAuthnSvc,
|
---|
| 1943 | dwAuthzSvc, pServerPrincName, dwAuthnLevel, dwImpLevel, pAuthInfo,
|
---|
| 1944 | dwCapabilities);
|
---|
| 1945 | return E_NOTIMPL;
|
---|
| 1946 | }
|
---|