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

ole32: Do not pass around untyped context section pointers.

parent 1e6b130b
...@@ -145,19 +145,25 @@ struct progidredirect_data ...@@ -145,19 +145,25 @@ struct progidredirect_data
ULONG clsid_offset; ULONG clsid_offset;
}; };
enum class_reg_data_origin
{
CLASS_REG_ACTCTX,
CLASS_REG_REGISTRY,
};
struct class_reg_data struct class_reg_data
{ {
enum class_reg_data_origin origin;
union union
{ {
struct struct
{ {
struct comclassredirect_data *data; const WCHAR *module_name;
void *section; DWORD threading_model;
HANDLE hactctx; HANDLE hactctx;
} actctx; } actctx;
HKEY hkey; HKEY hkey;
} u; } u;
BOOL hkey;
}; };
struct registered_psclsid struct registered_psclsid
...@@ -1408,7 +1414,7 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst ...@@ -1408,7 +1414,7 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst
{ {
DWORD ret; DWORD ret;
if (regdata->hkey) if (regdata->origin == CLASS_REG_REGISTRY)
{ {
DWORD keytype; DWORD keytype;
WCHAR src[MAX_PATH]; WCHAR src[MAX_PATH];
...@@ -1437,12 +1443,10 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst ...@@ -1437,12 +1443,10 @@ static BOOL get_object_dll_path(const struct class_reg_data *regdata, WCHAR *dst
{ {
static const WCHAR dllW[] = {'.','d','l','l',0}; static const WCHAR dllW[] = {'.','d','l','l',0};
ULONG_PTR cookie; ULONG_PTR cookie;
WCHAR *nameW;
*dst = 0; *dst = 0;
nameW = (WCHAR*)((BYTE*)regdata->u.actctx.section + regdata->u.actctx.data->name_offset);
ActivateActCtx(regdata->u.actctx.hactctx, &cookie); ActivateActCtx(regdata->u.actctx.hactctx, &cookie);
ret = SearchPathW(NULL, nameW, dllW, dstlen, dst, NULL); ret = SearchPathW(NULL, regdata->u.actctx.module_name, dllW, dstlen, dst, NULL);
DeactivateActCtx(0, cookie); DeactivateActCtx(0, cookie);
return *dst != 0; return *dst != 0;
} }
...@@ -2990,7 +2994,7 @@ HRESULT WINAPI CoRegisterClassObject( ...@@ -2990,7 +2994,7 @@ HRESULT WINAPI CoRegisterClassObject(
static enum comclass_threadingmodel get_threading_model(const struct class_reg_data *data) static enum comclass_threadingmodel get_threading_model(const struct class_reg_data *data)
{ {
if (data->hkey) if (data->origin == CLASS_REG_REGISTRY)
{ {
static const WCHAR wszThreadingModel[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0}; static const WCHAR wszThreadingModel[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0};
static const WCHAR wszApartment[] = {'A','p','a','r','t','m','e','n','t',0}; static const WCHAR wszApartment[] = {'A','p','a','r','t','m','e','n','t',0};
...@@ -3014,7 +3018,7 @@ static enum comclass_threadingmodel get_threading_model(const struct class_reg_d ...@@ -3014,7 +3018,7 @@ static enum comclass_threadingmodel get_threading_model(const struct class_reg_d
return ThreadingModel_No; return ThreadingModel_No;
} }
else else
return data->u.actctx.data->model; return data->u.actctx.threading_model;
} }
static HRESULT get_inproc_class_object(APARTMENT *apt, const struct class_reg_data *regdata, static HRESULT get_inproc_class_object(APARTMENT *apt, const struct class_reg_data *regdata,
...@@ -3098,7 +3102,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( ...@@ -3098,7 +3102,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
REFIID iid, LPVOID *ppv) REFIID iid, LPVOID *ppv)
{ {
struct class_reg_data clsreg; struct class_reg_data clsreg = { 0 };
IUnknown *regClassObject; IUnknown *regClassObject;
HRESULT hres = E_UNEXPECTED; HRESULT hres = E_UNEXPECTED;
APARTMENT *apt; APARTMENT *apt;
...@@ -3144,10 +3148,10 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( ...@@ -3144,10 +3148,10 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
{ {
struct comclassredirect_data *comclass = (struct comclassredirect_data*)data.lpData; struct comclassredirect_data *comclass = (struct comclassredirect_data*)data.lpData;
clsreg.u.actctx.module_name = (WCHAR *)((BYTE *)data.lpSectionBase + comclass->name_offset);
clsreg.u.actctx.hactctx = data.hActCtx; clsreg.u.actctx.hactctx = data.hActCtx;
clsreg.u.actctx.data = data.lpData; clsreg.u.actctx.threading_model = comclass->model;
clsreg.u.actctx.section = data.lpSectionBase; clsreg.origin = CLASS_REG_ACTCTX;
clsreg.hkey = FALSE;
hres = get_inproc_class_object(apt, &clsreg, &comclass->clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); hres = get_inproc_class_object(apt, &clsreg, &comclass->clsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv);
ReleaseActCtx(data.hActCtx); ReleaseActCtx(data.hActCtx);
...@@ -3197,7 +3201,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( ...@@ -3197,7 +3201,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
clsreg.u.hkey = hkey; clsreg.u.hkey = hkey;
clsreg.hkey = TRUE; clsreg.origin = CLASS_REG_REGISTRY;
hres = get_inproc_class_object(apt, &clsreg, rclsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); hres = get_inproc_class_object(apt, &clsreg, rclsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv);
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -3233,7 +3237,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject( ...@@ -3233,7 +3237,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
clsreg.u.hkey = hkey; clsreg.u.hkey = hkey;
clsreg.hkey = TRUE; clsreg.origin = CLASS_REG_REGISTRY;
hres = get_inproc_class_object(apt, &clsreg, rclsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); hres = get_inproc_class_object(apt, &clsreg, rclsid, iid, !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv);
RegCloseKey(hkey); RegCloseKey(hkey);
...@@ -5171,7 +5175,7 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) ...@@ -5171,7 +5175,7 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
WCHAR dllpath[MAX_PATH+1]; WCHAR dllpath[MAX_PATH+1];
regdata.u.hkey = hkey; regdata.u.hkey = hkey;
regdata.hkey = TRUE; regdata.origin = CLASS_REG_REGISTRY;
if (get_object_dll_path(&regdata, dllpath, ARRAY_SIZE(dllpath))) if (get_object_dll_path(&regdata, dllpath, ARRAY_SIZE(dllpath)))
{ {
......
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