Commit f56d029f authored by Francis Beaudet's avatar Francis Beaudet Committed by Alexandre Julliard

Implemented the startup-shutdown mechanism for the COM subsystem.

Implemented the Class object registration mechanism.
parent 18f1975a
......@@ -3,7 +3,7 @@ type win16
1 pascal CoBuildVersion() CoBuildVersion
2 pascal CoInitialize(long) CoInitialize16
3 pascal CoUninitialize() CoUninitialize
3 pascal CoUninitialize() CoUninitialize16
4 pascal CoGetMalloc(long ptr) CoGetMalloc16
5 pascal CoRegisterClassObject(ptr ptr long long ptr) CoRegisterClassObject16
6 stub COREVOKECLASSOBJECT
......
......@@ -41,8 +41,9 @@ HRESULT WINAPI CoInitialize32(LPVOID lpReserved);
HRESULT WINAPI CoInitializeEx32(LPVOID lpReserved, DWORD dwCoInit);
#define CoInitializeEx WINELIB_NAME(CoInitializeEx)
void WINAPI CoUninitialize(void);
void WINAPI CoUninitialize16(void);
void WINAPI CoUninitialize32(void);
#define CoUninitialize WINELIB_NAME(CoUninitialize)
HRESULT WINAPI CoCreateGuid(GUID *pguid);
......@@ -59,7 +60,9 @@ HRESULT WINAPI CoRegisterClassObject16(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dw
HRESULT WINAPI CoRegisterClassObject32(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
#define CoRegisterClassObject WINELIB_NAME(CoRegisterClassObject)
HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
HRESULT WINAPI CoRevokeClassObject32(DWORD dwRegister);
#define CoRevokeClassObject WINELIB_NAME(CoRevokeClassObject)
HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext,LPVOID pvReserved, const REFIID iid, LPVOID *ppv);
......
......@@ -184,6 +184,7 @@ extern int WIN32_LastError;
#define CO_E_INIT_SCM_EXEC_FAILURE 0x80004011
#define CO_E_INIT_ONLY_SINGLE_THREADED 0x80004012 */
#define CO_E_OBJISREG 0x800401FB
#define OLE_E_ENUM_NOMORE 0x80040002
#define CLASS_E_NOAGGREGATION 0x80040110
#define CLASS_E_CLASSNOTAVAILABLE 0x80040111
......
......@@ -9,6 +9,7 @@
#include "ole2.h"
#include "process.h"
#include "debug.h"
#include "objbase.h"
#include "objidl.h"
#include "wine/obj_base.h"
#include "wine/obj_clientserver.h"
......@@ -16,6 +17,17 @@
#include "wine/obj_moniker.h"
/******************************************************************************
* These are static/global variables that the OLE module uses to maintain
* it's state.
*/
/*
* This is the lock count on the OLE library. It is controlled by the
* OLEInitialize/OLEUninitialize methods.
*/
static ULONG s_OLEModuleLockCount = 0;
/******************************************************************************
* OleBuildVersion [OLE2.1]
*/
DWORD WINAPI OleBuildVersion(void)
......@@ -29,8 +41,44 @@ DWORD WINAPI OleBuildVersion(void)
*/
HRESULT WINAPI OleInitialize(LPVOID reserved)
{
FIXME(ole,"OleInitialize - stub\n");
return S_OK;
HRESULT hr;
TRACE(ole, "(%p)\n", reserved);
/*
* The first duty of the OleInitialize is to initialize the COM libraries.
*/
hr = CoInitializeEx32(NULL, COINIT_APARTMENTTHREADED);
/*
* If the CoInitializeEx call failed, the OLE libraries can't be
* initialized.
*/
if (FAILED(hr))
return hr;
/*
* Then, it has to initialize the OLE specific modules.
* This includes:
* Clipboard
* Drag and Drop
* Object linking and Embedding
* In-place activation
*/
if (s_OLEModuleLockCount==0)
{
/*
* Initialize the libraries.
*/
TRACE(ole, "() - Initializing the OLE libraries\n");
}
/*
* Then, we increase the lock count on the OLE module.
*/
s_OLEModuleLockCount++;
return hr;
}
/******************************************************************************
......@@ -48,7 +96,28 @@ DWORD WINAPI CoGetCurrentProcess(void) {
*/
void WINAPI OleUninitialize(void)
{
FIXME(ole,"stub\n");
TRACE(ole, "()\n");
/*
* Decrease the lock count on the OLE module.
*/
s_OLEModuleLockCount--;
/*
* If we hit the bottom of the lock stack, free the libraries.
*/
if (s_OLEModuleLockCount==0)
{
/*
* Actually free the libraries.
*/
TRACE(ole, "() - Freeing the last reference count\n");
}
/*
* Then, uninitialize the COM libraries.
*/
CoUninitialize32();
}
/***********************************************************************
......
......@@ -40,14 +40,14 @@ type win32
37 stub CoRegisterMallocSpy
38 stdcall CoRegisterMessageFilter(ptr ptr) CoRegisterMessageFilter32
39 stub CoReleaseMarshalData
40 stdcall CoRevokeClassObject(long) CoRevokeClassObject
40 stdcall CoRevokeClassObject(long) CoRevokeClassObject32
41 stub CoRevokeMallocSpy
42 stdcall CoSetState(ptr) CoSetState32
43 stdcall CoTaskMemAlloc(long) CoTaskMemAlloc
44 stdcall CoTaskMemFree(ptr) CoTaskMemFree
45 stub CoTaskMemRealloc
46 stub CoTreatAsClass
47 stdcall CoUninitialize() CoUninitialize
47 stdcall CoUninitialize() CoUninitialize32
48 stub CoUnloadingWOW
49 stub CoUnmarshalHresult
50 stub CoUnmarshalInterface
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment