Commit ae969df3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

combase: Move core apartment and activation functionality.

parent 04e11b58
......@@ -6,6 +6,7 @@ DELAYIMPORTS = oleaut32
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
apartment.c \
combase.c \
errorinfo.c \
malloc.c \
......
......@@ -36,6 +36,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
HINSTANCE hProxyDll;
#define CHARS_IN_GUID 39
struct comclassredirect_data
......@@ -2249,3 +2251,20 @@ DWORD WINAPI CoGetCurrentProcess(void)
return tlsdata->thread_seqid;
}
/***********************************************************************
* DllMain (combase.@)
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
{
TRACE("%p 0x%x %p\n", hinstDLL, reason, reserved);
switch (reason)
{
case DLL_PROCESS_ATTACH:
hProxyDll = hinstDLL;
break;
}
return TRUE;
}
......@@ -351,3 +351,19 @@
@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr)
@ stdcall WindowsTrimStringEnd(ptr ptr ptr)
@ stdcall WindowsTrimStringStart(ptr ptr ptr)
@ stdcall apartment_get_current_or_mta()
@ stdcall apartment_release(ptr)
@ stdcall enter_apartment(ptr long)
@ stdcall leave_apartment(ptr)
@ stdcall apartment_get_inproc_class_object(ptr ptr ptr ptr long ptr)
@ stdcall apartment_freeunusedlibraries(ptr long)
@ stdcall apartment_get_mta()
@ stdcall apartment_decrement_mta_usage(ptr)
@ stdcall apartment_increment_mta_usage(ptr)
@ stdcall apartment_findfromoxid(int64)
@ stdcall apartment_getwindow(ptr)
@ stdcall apartment_global_cleanup()
@ stdcall apartment_createwindowifneeded(ptr)
@ stdcall apartment_get_local_server_stream(ptr ptr)
@ stdcall apartment_findfromtid(long)
......@@ -17,8 +17,11 @@
#include "winternl.h"
#include "wine/orpc.h"
#include "wine/heap.h"
#include "wine/list.h"
extern HINSTANCE hProxyDll;
struct apartment
{
struct list entry;
......@@ -51,6 +54,10 @@ struct apartment
struct list usage_cookies; /* Used for refcount control with CoIncrementMTAUsage()/CoDecrementMTAUsage(). */
};
/* DCOM messages used by the apartment window (not compatible with native) */
#define DM_EXECUTERPC (WM_USER + 0) /* WPARAM = 0, LPARAM = (struct dispatch_params *) */
#define DM_HOSTOBJECT (WM_USER + 1) /* WPARAM = 0, LPARAM = (struct host_object_params *) */
/* this is what is stored in TEB->ReservedForOle */
struct tlsdata
{
......@@ -89,5 +96,40 @@ static inline struct apartment* com_get_current_apt(void)
return tlsdata->apt;
}
HWND WINAPI apartment_getwindow(const struct apartment *apt) DECLSPEC_HIDDEN;
HRESULT WINAPI apartment_createwindowifneeded(struct apartment *apt) DECLSPEC_HIDDEN;
/* RpcSs interface */
HRESULT rpcss_get_next_seqid(DWORD *id) DECLSPEC_HIDDEN;
/* stub managers hold refs on the object and each interface stub */
struct stub_manager
{
struct list entry; /* entry in apartment stubmgr list (CS apt->cs) */
struct list ifstubs; /* list of active ifstubs for the object (CS lock) */
CRITICAL_SECTION lock;
struct apartment *apt; /* owning apt (RO) */
ULONG extrefs; /* number of 'external' references (CS lock) */
ULONG refs; /* internal reference count (CS apt->cs) */
ULONG weakrefs; /* number of weak references (CS lock) */
OID oid; /* apartment-scoped unique identifier (RO) */
IUnknown *object; /* the object we are managing the stub for (RO) */
ULONG next_ipid; /* currently unused (LOCK) */
OXID_INFO oxid_info; /* string binding, ipid of rem unknown and other information (RO) */
IExternalConnection *extern_conn;
/* We need to keep a count of the outstanding marshals, so we can enforce the
* marshalling rules (ie, you can only unmarshal normal marshals once). Note
* that these counts do NOT include unmarshalled interfaces, once a stream is
* unmarshalled and a proxy set up, this count is decremented.
*/
ULONG norm_refs; /* refcount of normal marshals (CS lock) */
BOOL disconnected; /* CoDisconnectObject has been called (CS lock) */
};
/* Stub Manager */
ULONG stub_manager_int_release(struct stub_manager *This) DECLSPEC_HIDDEN;
......@@ -8,7 +8,6 @@ EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \
antimoniker.c \
apartment.c \
bindctx.c \
classmoniker.c \
clipboard.c \
......
......@@ -393,7 +393,7 @@ static void COM_RevokeRegisteredClassObject(RegisteredClass *curClass)
HeapFree(GetProcessHeap(), 0, curClass);
}
void COM_RevokeAllClasses(const struct apartment *apt)
void WINAPI InternalRevokeAllClasses(const struct apartment *apt)
{
RegisteredClass *curClass, *cursor;
......@@ -997,8 +997,6 @@ HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey
}
/***
* COM_GetRegisteredClassObject
*
* This internal method is used to scan the registered class list to
* find a class object.
*
......@@ -1009,7 +1007,7 @@ HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey
* to normal COM usage, this method will increase the
* reference count on this object.
*/
HRESULT COM_GetRegisteredClassObject(const struct apartment *apt, REFCLSID rclsid,
HRESULT WINAPI InternalGetRegisteredClassObject(const struct apartment *apt, REFCLSID rclsid,
DWORD dwClsContext, LPUNKNOWN* ppUnk)
{
HRESULT hr = S_FALSE;
......@@ -1110,7 +1108,7 @@ HRESULT WINAPI CoRegisterClassObject(
* First, check if the class is already registered.
* If it is, this should cause an error.
*/
hr = COM_GetRegisteredClassObject(apt, rclsid, dwClsContext, &foundObject);
hr = InternalGetRegisteredClassObject(apt, rclsid, dwClsContext, &foundObject);
if (hr == S_OK) {
if (flags & REGCLS_MULTIPLEUSE) {
if (dwClsContext & CLSCTX_LOCAL_SERVER)
......@@ -1267,7 +1265,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
* First, try and see if we can't match the class ID with one of the
* registered classes.
*/
if (S_OK == COM_GetRegisteredClassObject(apt, rclsid, dwClsContext,
if (S_OK == InternalGetRegisteredClassObject(apt, rclsid, dwClsContext,
&regClassObject))
{
/* Get the required interface from the retrieved pointer. */
......
......@@ -245,31 +245,30 @@ void OLEDD_UnInitialize(void) DECLSPEC_HIDDEN;
/* Apartment Functions */
struct apartment *apartment_findfromoxid(OXID oxid) DECLSPEC_HIDDEN;
struct apartment *apartment_findfromtid(DWORD tid) DECLSPEC_HIDDEN;
void apartment_release(struct apartment *apt) DECLSPEC_HIDDEN;
HRESULT apartment_disconnectproxies(struct apartment *apt) DECLSPEC_HIDDEN;
extern struct apartment * WINAPI apartment_findfromoxid(OXID oxid) DECLSPEC_HIDDEN;
extern struct apartment * WINAPI apartment_findfromtid(DWORD tid) DECLSPEC_HIDDEN;
extern void WINAPI apartment_release(struct apartment *apt) DECLSPEC_HIDDEN;
static inline HRESULT apartment_getoxid(const struct apartment *apt, OXID *oxid)
{
*oxid = apt->oxid;
return S_OK;
}
HRESULT apartment_createwindowifneeded(struct apartment *apt) DECLSPEC_HIDDEN;
HWND apartment_getwindow(const struct apartment *apt) DECLSPEC_HIDDEN;
HRESULT enter_apartment(struct oletls *info, DWORD model) DECLSPEC_HIDDEN;
void leave_apartment(struct oletls *info) DECLSPEC_HIDDEN;
struct apartment *apartment_get_current_or_mta(void) DECLSPEC_HIDDEN;
extern HRESULT WINAPI apartment_createwindowifneeded(struct apartment *apt) DECLSPEC_HIDDEN;
extern HWND WINAPI apartment_getwindow(const struct apartment *apt) DECLSPEC_HIDDEN;
extern HRESULT WINAPI enter_apartment(struct oletls *info, DWORD model) DECLSPEC_HIDDEN;
void WINAPI leave_apartment(struct oletls *info) DECLSPEC_HIDDEN;
extern struct apartment * WINAPI apartment_get_current_or_mta(void) DECLSPEC_HIDDEN;
struct class_reg_data;
HRESULT apartment_get_inproc_class_object(struct apartment *apt, const struct class_reg_data *regdata,
extern HRESULT WINAPI apartment_get_inproc_class_object(struct apartment *apt, const struct class_reg_data *regdata,
REFCLSID rclsid, REFIID riid, BOOL hostifnecessary, void **ppv) DECLSPEC_HIDDEN;
void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie) DECLSPEC_HIDDEN;
HRESULT apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie) DECLSPEC_HIDDEN;
struct apartment *apartment_get_mta(void) DECLSPEC_HIDDEN;
HRESULT apartment_get_local_server_stream(struct apartment *apt, IStream **ret) DECLSPEC_HIDDEN;
void apartment_freeunusedlibraries(struct apartment *apt, DWORD delay) DECLSPEC_HIDDEN;
void apartment_global_cleanup(void) DECLSPEC_HIDDEN;
extern void WINAPI apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie) DECLSPEC_HIDDEN;
extern HRESULT WINAPI apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie) DECLSPEC_HIDDEN;
extern struct apartment * WINAPI apartment_get_mta(void) DECLSPEC_HIDDEN;
extern HRESULT WINAPI apartment_get_local_server_stream(struct apartment *apt, IStream **ret) DECLSPEC_HIDDEN;
extern void WINAPI apartment_freeunusedlibraries(struct apartment *apt, DWORD delay) DECLSPEC_HIDDEN;
extern void WINAPI apartment_global_cleanup(void) DECLSPEC_HIDDEN;
HRESULT COM_GetRegisteredClassObject(const struct apartment *apt, REFCLSID rclsid,
DWORD dwClsContext, IUnknown **ppUnk) DECLSPEC_HIDDEN;
......
......@@ -1223,7 +1223,7 @@ static BOOL find_proxy_manager(struct apartment * apt, OXID oxid, OID oid, struc
return found;
}
HRESULT apartment_disconnectproxies(struct apartment *apt)
HRESULT WINAPI Internal_apartment_disconnectproxies(struct apartment *apt)
{
struct list * cursor;
......
......@@ -298,3 +298,8 @@
@ stub WriteOleStg
@ stub WriteStringStream
@ stdcall InternalIsInitialized()
@ stdcall InternalGetRegisteredClassObject(ptr ptr long ptr)
@ stdcall InternalRevokeAllClasses(ptr)
@ stdcall Internal_apartment_disconnectproxies(ptr)
@ stdcall Internal_RPC_ExecuteCall(ptr)
@ stdcall Internal_stub_manager_int_release(ptr)
......@@ -1324,7 +1324,7 @@ static HRESULT unmarshal_ORPCTHAT(RPC_MESSAGE *msg, ORPCTHAT *orpcthat,
return S_OK;
}
void RPC_ExecuteCall(struct dispatch_params *params)
void WINAPI Internal_RPC_ExecuteCall(struct dispatch_params *params)
{
struct message_state *message_state = NULL;
RPC_MESSAGE *msg = (RPC_MESSAGE *)params->msg;
......@@ -1504,7 +1504,7 @@ static void __RPC_STUB dispatch_rpc(RPC_MESSAGE *msg)
enter_apartment(info, COINIT_MULTITHREADED);
joined = TRUE;
}
RPC_ExecuteCall(params);
Internal_RPC_ExecuteCall(params);
if (joined)
{
leave_apartment(info);
......
......@@ -307,6 +307,11 @@ static ULONG stub_manager_int_addref(struct stub_manager *This)
return refs;
}
ULONG WINAPI Internal_stub_manager_int_release(struct stub_manager *m)
{
return stub_manager_int_release(m);
}
/* decrements the internal refcount */
ULONG stub_manager_int_release(struct stub_manager *This)
{
......
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