And build ifacewrap.c as x86-64 code on ARM64EC.
From: Jacek Caban jacek@codeweavers.com
And build ifacewrap.c as x86-64 code on ARM64EC. --- dlls/mshtml/htmlobject.c | 71 ++++++++- dlls/mshtml/ifacewrap.c | 289 +++++++++++++---------------------- dlls/mshtml/mshtml_private.h | 5 +- 3 files changed, 175 insertions(+), 190 deletions(-)
diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c index d6b1799f674..a91339331f9 100644 --- a/dlls/mshtml/htmlobject.c +++ b/dlls/mshtml/htmlobject.c @@ -632,6 +632,58 @@ static const IHTMLObjectElement2Vtbl HTMLObjectElement2Vtbl = { HTMLObjectElement2_get_data };
+/* + * This object wraps any unrecognized interface overriding its IUnknown methods, allowing + * us to return external interface from our QI implementation preserving COM rules. + * This can't be done right and it seems to be broken by design. + */ +typedef struct { + IUnknown IUnknown_iface; + IUnknown *iface; + IUnknown *ref_unk; + LONG ref; +} iface_wrapper_t; + +static inline iface_wrapper_t *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, iface_wrapper_t, IUnknown_iface); +} + +HRESULT WINAPI wrapper_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + iface_wrapper_t *This = impl_from_IUnknown(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); + + return IUnknown_QueryInterface(This->ref_unk, riid, ppv); +} + +ULONG WINAPI wrapper_AddRef(IUnknown *iface) +{ + iface_wrapper_t *This = impl_from_IUnknown(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%ld\n", This, ref); + + return ref; +} + +ULONG WINAPI wrapper_Release(IUnknown *iface) +{ + iface_wrapper_t *This = impl_from_IUnknown(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%ld\n", This, ref); + + if(!ref) { + IUnknown_Release(This->iface); + IUnknown_Release(This->ref_unk); + free(This); + } + + return ref; +} + static inline HTMLObjectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface) { return CONTAINING_RECORD(iface, HTMLObjectElement, plugin_container.element.node); @@ -665,19 +717,24 @@ static void *HTMLObjectElement_query_interface(DispatchEx *dispex, REFIID riid)
elem_iface = HTMLElement_query_interface(&This->plugin_container.element.node.event_target.dispex, riid); if(!elem_iface && This->plugin_container.plugin_host && This->plugin_container.plugin_host->plugin_unk) { - IUnknown *plugin_iface, *ret; + IUnknown *plugin_iface; HRESULT hres = IUnknown_QueryInterface(This->plugin_container.plugin_host->plugin_unk, riid, (void**)&plugin_iface);
if(hres == S_OK) { - hres = wrap_iface(plugin_iface, (IUnknown*)&This->IHTMLObjectElement_iface, &ret); - IUnknown_Release(plugin_iface); - if(FAILED(hres)) { - ERR("wrap_iface failed: %08lx\n", hres); + iface_wrapper_t *wrapper = malloc(sizeof(*wrapper)); + if(!wrapper) { + IUnknown_Release(plugin_iface); return NULL; }
- TRACE("returning plugin iface %p wrapped to %p\n", plugin_iface, ret); - return ret; + wrapper->IUnknown_iface.lpVtbl = (const IUnknownVtbl *)iface_wrapper_vtbl; + wrapper->ref = 1; + IUnknown_AddRef(wrapper->iface = plugin_iface); + wrapper->ref_unk = (IUnknown*)&This->IHTMLObjectElement_iface; + + IUnknown_Release(plugin_iface); + TRACE("returning plugin iface %p wrapped to %p\n", plugin_iface, wrapper); + return &wrapper->IUnknown_iface; } }
diff --git a/dlls/mshtml/ifacewrap.c b/dlls/mshtml/ifacewrap.c index 8b4127daa52..3093b645bca 100644 --- a/dlls/mshtml/ifacewrap.c +++ b/dlls/mshtml/ifacewrap.c @@ -16,6 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep arm64ec_x64 +#endif + #include <stdarg.h>
#define COBJMACROS @@ -30,60 +34,6 @@
#include "mshtml_private.h"
-WINE_DEFAULT_DEBUG_CHANNEL(mshtml); - -/* - * This object wraps any unrecognized interface overriding its IUnknown methods, allowing - * us to return external interface from our QI implementation preserving COM rules. - * This can't be done right and it seems to be broken by design. - */ -typedef struct { - IUnknown IUnknown_iface; - IUnknown *iface; - IUnknown *ref_unk; - LONG ref; -} iface_wrapper_t; - -static inline iface_wrapper_t *impl_from_IUnknown(IUnknown *iface) -{ - return CONTAINING_RECORD(iface, iface_wrapper_t, IUnknown_iface); -} - -static HRESULT WINAPI wrapper_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) -{ - iface_wrapper_t *This = impl_from_IUnknown(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); - - return IUnknown_QueryInterface(This->ref_unk, riid, ppv); -} - -static ULONG WINAPI wrapper_AddRef(IUnknown *iface) -{ - iface_wrapper_t *This = impl_from_IUnknown(iface); - LONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p) ref=%ld\n", This, ref); - - return ref; -} - -static ULONG WINAPI wrapper_Release(IUnknown *iface) -{ - iface_wrapper_t *This = impl_from_IUnknown(iface); - LONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p) ref=%ld\n", This, ref); - - if(!ref) { - IUnknown_Release(This->iface); - IUnknown_Release(This->ref_unk); - free(This); - } - - return ref; -} - #ifdef __i386__
#define DEFINE_WRAPPER_FUNC(n, off, x) \ @@ -106,6 +56,8 @@ static ULONG WINAPI wrapper_Release(IUnknown *iface)
#else
+WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + #define DEFINE_WRAPPER_FUNC(n, x, off) \ static HRESULT WINAPI wrapper_func_##n(IUnknown *iface) { \ ERR("Not implemented for this architecture\n"); \ @@ -214,132 +166,105 @@ DEFINE_WRAPPER_FUNC(98, 392, 784) DEFINE_WRAPPER_FUNC(99, 396, 792)
/* The size was found by testing when calls start crashing. It looks like MS wraps up to 100 functions. */ -static const struct { - IUnknownVtbl unk_vtbl; - const void *wrappers[97]; -} wrapper_vtbl = { - { - wrapper_QueryInterface, - wrapper_AddRef, - wrapper_Release - }, { - wrapper_func_3, - wrapper_func_4, - wrapper_func_5, - wrapper_func_6, - wrapper_func_7, - wrapper_func_8, - wrapper_func_9, - wrapper_func_10, - wrapper_func_11, - wrapper_func_12, - wrapper_func_13, - wrapper_func_14, - wrapper_func_15, - wrapper_func_16, - wrapper_func_17, - wrapper_func_18, - wrapper_func_19, - wrapper_func_20, - wrapper_func_21, - wrapper_func_22, - wrapper_func_23, - wrapper_func_24, - wrapper_func_25, - wrapper_func_26, - wrapper_func_27, - wrapper_func_28, - wrapper_func_29, - wrapper_func_30, - wrapper_func_31, - wrapper_func_32, - wrapper_func_33, - wrapper_func_34, - wrapper_func_35, - wrapper_func_36, - wrapper_func_37, - wrapper_func_38, - wrapper_func_39, - wrapper_func_40, - wrapper_func_41, - wrapper_func_42, - wrapper_func_43, - wrapper_func_44, - wrapper_func_45, - wrapper_func_46, - wrapper_func_47, - wrapper_func_48, - wrapper_func_49, - wrapper_func_50, - wrapper_func_51, - wrapper_func_52, - wrapper_func_53, - wrapper_func_54, - wrapper_func_55, - wrapper_func_56, - wrapper_func_57, - wrapper_func_58, - wrapper_func_59, - wrapper_func_60, - wrapper_func_61, - wrapper_func_62, - wrapper_func_63, - wrapper_func_64, - wrapper_func_65, - wrapper_func_66, - wrapper_func_67, - wrapper_func_68, - wrapper_func_69, - wrapper_func_70, - wrapper_func_71, - wrapper_func_72, - wrapper_func_73, - wrapper_func_74, - wrapper_func_75, - wrapper_func_76, - wrapper_func_77, - wrapper_func_78, - wrapper_func_79, - wrapper_func_80, - wrapper_func_81, - wrapper_func_82, - wrapper_func_83, - wrapper_func_84, - wrapper_func_85, - wrapper_func_86, - wrapper_func_87, - wrapper_func_88, - wrapper_func_89, - wrapper_func_90, - wrapper_func_91, - wrapper_func_92, - wrapper_func_93, - wrapper_func_94, - wrapper_func_95, - wrapper_func_96, - wrapper_func_97, - wrapper_func_98, - wrapper_func_99 - } +const void *iface_wrapper_vtbl[] = { + wrapper_QueryInterface, + wrapper_AddRef, + wrapper_Release, + wrapper_func_3, + wrapper_func_4, + wrapper_func_5, + wrapper_func_6, + wrapper_func_7, + wrapper_func_8, + wrapper_func_9, + wrapper_func_10, + wrapper_func_11, + wrapper_func_12, + wrapper_func_13, + wrapper_func_14, + wrapper_func_15, + wrapper_func_16, + wrapper_func_17, + wrapper_func_18, + wrapper_func_19, + wrapper_func_20, + wrapper_func_21, + wrapper_func_22, + wrapper_func_23, + wrapper_func_24, + wrapper_func_25, + wrapper_func_26, + wrapper_func_27, + wrapper_func_28, + wrapper_func_29, + wrapper_func_30, + wrapper_func_31, + wrapper_func_32, + wrapper_func_33, + wrapper_func_34, + wrapper_func_35, + wrapper_func_36, + wrapper_func_37, + wrapper_func_38, + wrapper_func_39, + wrapper_func_40, + wrapper_func_41, + wrapper_func_42, + wrapper_func_43, + wrapper_func_44, + wrapper_func_45, + wrapper_func_46, + wrapper_func_47, + wrapper_func_48, + wrapper_func_49, + wrapper_func_50, + wrapper_func_51, + wrapper_func_52, + wrapper_func_53, + wrapper_func_54, + wrapper_func_55, + wrapper_func_56, + wrapper_func_57, + wrapper_func_58, + wrapper_func_59, + wrapper_func_60, + wrapper_func_61, + wrapper_func_62, + wrapper_func_63, + wrapper_func_64, + wrapper_func_65, + wrapper_func_66, + wrapper_func_67, + wrapper_func_68, + wrapper_func_69, + wrapper_func_70, + wrapper_func_71, + wrapper_func_72, + wrapper_func_73, + wrapper_func_74, + wrapper_func_75, + wrapper_func_76, + wrapper_func_77, + wrapper_func_78, + wrapper_func_79, + wrapper_func_80, + wrapper_func_81, + wrapper_func_82, + wrapper_func_83, + wrapper_func_84, + wrapper_func_85, + wrapper_func_86, + wrapper_func_87, + wrapper_func_88, + wrapper_func_89, + wrapper_func_90, + wrapper_func_91, + wrapper_func_92, + wrapper_func_93, + wrapper_func_94, + wrapper_func_95, + wrapper_func_96, + wrapper_func_97, + wrapper_func_98, + wrapper_func_99 }; - -HRESULT wrap_iface(IUnknown *iface, IUnknown *ref_unk, IUnknown **ret) -{ - iface_wrapper_t *wrapper; - - wrapper = malloc(sizeof(*wrapper)); - if(!wrapper) - return E_OUTOFMEMORY; - - wrapper->IUnknown_iface.lpVtbl = &wrapper_vtbl.unk_vtbl; - wrapper->ref = 1; - - IUnknown_AddRef(iface); - wrapper->iface = iface; - - /* Caller AddRefs */ - wrapper->ref_unk = ref_unk; - - *ret = &wrapper->IUnknown_iface; - return S_OK; -} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 9609fb5edcb..36d6dfd646a 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -1224,7 +1224,10 @@ HRESULT get_doc_elem_by_id(HTMLDocumentNode*,const WCHAR*,HTMLElement**); HTMLOuterWindow *get_target_window(HTMLOuterWindow*,nsAString*,BOOL*); HRESULT handle_link_click_event(HTMLElement*,nsAString*,nsAString*,nsIDOMEvent*,BOOL*);
-HRESULT wrap_iface(IUnknown*,IUnknown*,IUnknown**); +HRESULT WINAPI wrapper_QueryInterface(IUnknown *iface, REFIID riid, void **ppv); +ULONG WINAPI wrapper_AddRef(IUnknown *iface); +ULONG WINAPI wrapper_Release(IUnknown *iface); +extern const void *iface_wrapper_vtbl[];
IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL); IHTMLElementCollection *create_collection_from_nodelist(nsIDOMNodeList*,compat_mode_t);