[PATCH] riched20: Implement MSVC asm wrappers.

Thomas Faber thomas.faber at reactos.org
Fri Mar 15 03:37:01 CDT 2019


Signed-off-by: Thomas Faber <thomas.faber at reactos.org>
---
 dlls/riched20/txthost.c | 23 +++++++++++++++++++++++
 dlls/riched20/txtsrv.c  | 12 ++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index eaa6aaef065..d709502a1ec 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -502,6 +502,16 @@ DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *i
 #ifdef __i386__  /* thiscall functions are i386-specific */
 
 #define THISCALL(func) (void *) __thiscall_ ## func
+#ifdef _MSC_VER
+#define DEFINE_THISCALL_WRAPPER(func,args) \
+    __declspec(naked) HRESULT __thiscall_##func(void) \
+    { \
+        __asm pop eax \
+        __asm push ecx \
+        __asm push eax \
+        __asm jmp func \
+    }
+#else /* _MSC_VER */
 #define DEFINE_THISCALL_WRAPPER(func,args) \
    extern HRESULT __thiscall_ ## func(void); \
    __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
@@ -509,6 +519,7 @@ DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *i
                    "pushl %ecx\n\t" \
                    "pushl %eax\n\t" \
                    "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
+#endif /* _MSC_VER */
 
 #else /* __i386__ */
 
@@ -560,6 +571,17 @@ DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
 #ifdef __i386__  /* thiscall functions are i386-specific */
 
 #define STDCALL(func) (void *) __stdcall_ ## func
+#ifdef _MSC_VER
+#define DEFINE_STDCALL_WRAPPER(num,func,args) \
+    __declspec(naked) HRESULT __stdcall_##func(void) \
+    { \
+        __asm pop eax \
+        __asm pop ecx \
+        __asm push eax \
+        __asm mov eax, [ecx] \
+        __asm jmp dword ptr [eax + 4*num] \
+    }
+#else /* _MSC_VER */
 #define DEFINE_STDCALL_WRAPPER(num,func,args) \
    extern HRESULT __stdcall_ ## func(void); \
    __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
@@ -568,6 +590,7 @@ DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
                    "pushl %eax\n\t" \
                    "movl (%ecx), %eax\n\t" \
                    "jmp *(4*(" #num "))(%eax)" )
+#endif /* _MSC_VER */
 
 DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
 DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 639a94fbd06..37b866a7f85 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -36,6 +36,16 @@
 #ifdef __i386__  /* thiscall functions are i386-specific */
 
 #define THISCALL(func) (void *) __thiscall_ ## func
+#ifdef _MSC_VER
+#define DEFINE_THISCALL_WRAPPER(func,args) \
+    __declspec(naked) HRESULT __thiscall_##func(void) \
+    { \
+        __asm pop eax \
+        __asm push ecx \
+        __asm push eax \
+        __asm jmp func \
+    }
+#else /* _MSC_VER */
 #define DEFINE_THISCALL_WRAPPER(func,args) \
    extern HRESULT __thiscall_ ## func(void); \
    __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
@@ -43,6 +53,8 @@
                    "pushl %ecx\n\t" \
                    "pushl %eax\n\t" \
                    "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
+#endif /* _MSC_VER */
+
 #else /* __i386__ */
 
 #define THISCALL(func) func
-- 
2.16.1.windows.2




More information about the wine-devel mailing list