Changeset 784 for trunk/src/ole32/ole32.cpp
- Timestamp:
- Sep 2, 1999, 2:43:42 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/ole32.cpp
r633 r784 82 82 83 83 /* 84 * This open DLL table belongs in a per process table, but my guess is that85 * it shouldn't live in the kernel, so I'll put them out here in DLL86 * space assuming that there is one OLE32 per process.87 */88 typedef struct tagOpenDll89 {90 char * DllName; /* really only needed for debugging */91 HINSTANCE hLibrary;92 struct tagOpenDll * next;93 } OpenDll;94 95 static OpenDll * openDllList = NULL; /* linked list of open dlls */96 97 /*98 84 * Com Library reference count... 99 85 * … … 465 451 } 466 452 return hres; 453 } 454 455 // ---------------------------------------------------------------------- 456 // CoLockObjectExternal 457 // ---------------------------------------------------------------------- 458 HRESULT WIN32API CoLockObjectExternal(IUnknown *pUnk, BOOL fLock, BOOL fLastUnlockReleases) 459 { 460 dprintf(("OLE32: CoLockObjectExternal")); 461 462 if (fLock) 463 { 464 /* 465 * Increment the external lock coutner, COM_ExternalLockAddRef also 466 * increment the object's internal lock counter. 467 */ 468 COM_ExternalLockAddRef( pUnk); 469 } 470 else 471 { 472 /* 473 * Decrement the external lock coutner, COM_ExternalLockRelease also 474 * decrement the object's internal lock counter. 475 */ 476 COM_ExternalLockRelease( pUnk, fLastUnlockReleases); 477 } 478 479 return S_OK; 480 } 481 482 // ---------------------------------------------------------------------- 483 // CoRegisterClassObject 484 // ---------------------------------------------------------------------- 485 HRESULT WINAPI CoRegisterClassObject( 486 REFCLSID rclsid, 487 LPUNKNOWN pUnk, 488 DWORD dwClsContext, // Context in which to run the executable 489 DWORD flags, // how connections are made 490 LPDWORD lpdwRegister) 491 { 492 RegisteredClass * newClass; 493 LPUNKNOWN foundObject; 494 HRESULT hr; 495 oStringA tClsid(rclsid); 496 497 dprintf(("OLE32: CoRegisterClassObject(%s)", (char *)tClsid)); 498 499 // Perform a sanity check on the parameters 500 if ((lpdwRegister == 0) || (pUnk == 0)) 501 return E_INVALIDARG; 502 503 // Initialize the cookie (out parameter) 504 *lpdwRegister = 0; 505 506 // First, check if the class is already registered. 507 // If it is, this should cause an error. 508 hr = COM_GetRegisteredClassObject(rclsid, dwClsContext, &foundObject); 509 if (hr == S_OK) 510 { 511 // The COM_GetRegisteredClassObject increased the reference count on the 512 // object so it has to be released. 513 IUnknown_Release(foundObject); 514 515 return CO_E_OBJISREG; 516 } 517 518 // If it is not registered, we must create a new entry for this class and 519 // append it to the registered class list. 520 // We use the address of the chain node as the cookie since we are sure it's 521 // unique. 522 newClass = (RegisteredClass *)HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass)); 523 524 // Initialize the node. 525 newClass->classIdentifier = *rclsid; 526 newClass->runContext = dwClsContext; 527 newClass->connectFlags = flags; 528 newClass->dwCookie = (DWORD)newClass; 529 newClass->nextClass = firstRegisteredClass; 530 531 // Since we're making a copy of the object pointer, we have to increase it's 532 // reference count. 533 newClass->classObject = pUnk; 534 IUnknown_AddRef(newClass->classObject); 535 536 firstRegisteredClass = newClass; 537 538 // Assign the out parameter (cookie) 539 *lpdwRegister = newClass->dwCookie; 540 541 return S_OK; 542 } 543 544 // ---------------------------------------------------------------------- 545 // CoRegisterClassObject 546 // ---------------------------------------------------------------------- 547 // This method will remove a class object from the class registry 548 HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister) 549 { 550 RegisteredClass * * prevClassLink; 551 RegisteredClass * curClass; 552 553 dprintf(("OLE32: CoRegisterClassObject")); 554 555 // Iterate through the whole list and try to match the cookie. 556 curClass = firstRegisteredClass; 557 prevClassLink = &firstRegisteredClass; 558 559 while (curClass != 0) 560 { 561 // Check if we have a match on the cookie. 562 if (curClass->dwCookie == dwRegister) 563 { 564 // Remove the class from the chain. 565 *prevClassLink = curClass->nextClass; 566 567 // Release the reference to the class object. 568 IUnknown_Release(curClass->classObject); 569 570 // Free the memory used by the chain node. 571 HeapFree(GetProcessHeap(), 0, curClass); 572 573 return S_OK; 574 } 575 576 // Step to the next class in the list. 577 prevClassLink = &(curClass->nextClass); 578 curClass = curClass->nextClass; 579 } 580 581 return E_INVALIDARG; 467 582 } 468 583
Note:
See TracChangeset
for help on using the changeset viewer.