https://git.reactos.org/?p=reactos.git;a=commitdiff;h=49fbaa758e2bbd42572dc…
commit 49fbaa758e2bbd42572dc4b85d922527f65a12f8
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Feb 2 15:52:13 2019 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Tue Mar 19 21:19:20 2019 +0100
[RICHED20] Simplify MSVC thiscall & stdcall wrappers.
Imports Wine commit b64511c00a5.
---
dll/win32/riched20/CMakeLists.txt | 4 --
dll/win32/riched20/msvc-thiscall.c | 121 -------------------------------
dll/win32/riched20/msvc.h | 143 -------------------------------------
dll/win32/riched20/txthost.c | 23 ++++++
dll/win32/riched20/txtsrv.c | 12 ++++
5 files changed, 35 insertions(+), 268 deletions(-)
diff --git a/dll/win32/riched20/CMakeLists.txt b/dll/win32/riched20/CMakeLists.txt
index 36f96fe924..d7ed37de70 100644
--- a/dll/win32/riched20/CMakeLists.txt
+++ b/dll/win32/riched20/CMakeLists.txt
@@ -25,10 +25,6 @@ list(APPEND SOURCE
writer.c
precomp.h)
-if(MSVC AND (ARCH STREQUAL "i386"))
- list(APPEND SOURCE msvc-thiscall.c)
-endif()
-
list(APPEND riched20_rc_deps
${CMAKE_CURRENT_SOURCE_DIR}/riched_tom.rgs
${CMAKE_CURRENT_BINARY_DIR}/riched_tom.tlb)
diff --git a/dll/win32/riched20/msvc-thiscall.c b/dll/win32/riched20/msvc-thiscall.c
deleted file mode 100644
index 21669a604b..0000000000
--- a/dll/win32/riched20/msvc-thiscall.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "editor.h"
-
-#define DEFINE_THISCALL_WRAPPER(func,args) \
- typedef struct {int x[args/4];} _tag_##func; \
- void __stdcall func(_tag_##func p1); \
- __declspec(naked) void __thiscall_##func(_tag_##func p1) \
- { \
- __asm pop eax \
- __asm push ecx \
- __asm push eax \
- __asm jmp func \
- }
-
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetCharFormat,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxCharFormatChange,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_OnTxParaFormatChange,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
-DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
-
-#define DEFINE_STDCALL_WRAPPER(num,func,args) \
- __declspec(naked) void __stdcall_##func(_tag_##func p1) \
- { \
- __asm pop eax \
- __asm pop ecx \
- __asm push eax \
- __asm mov eax, [ecx] \
- __asm jmp dword ptr [eax + 4*num] \
- }
-
-DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4)
-DEFINE_STDCALL_WRAPPER(4,ITextHostImpl_TxReleaseDC,8)
-DEFINE_STDCALL_WRAPPER(5,ITextHostImpl_TxShowScrollBar,12)
-DEFINE_STDCALL_WRAPPER(6,ITextHostImpl_TxEnableScrollBar,12)
-DEFINE_STDCALL_WRAPPER(7,ITextHostImpl_TxSetScrollRange,20)
-DEFINE_STDCALL_WRAPPER(8,ITextHostImpl_TxSetScrollPos,16)
-DEFINE_STDCALL_WRAPPER(9,ITextHostImpl_TxInvalidateRect,12)
-DEFINE_STDCALL_WRAPPER(10,ITextHostImpl_TxViewChange,8)
-DEFINE_STDCALL_WRAPPER(11,ITextHostImpl_TxCreateCaret,16)
-DEFINE_STDCALL_WRAPPER(12,ITextHostImpl_TxShowCaret,8)
-DEFINE_STDCALL_WRAPPER(13,ITextHostImpl_TxSetCaretPos,12)
-DEFINE_STDCALL_WRAPPER(14,ITextHostImpl_TxSetTimer,12)
-DEFINE_STDCALL_WRAPPER(15,ITextHostImpl_TxKillTimer,8)
-DEFINE_STDCALL_WRAPPER(16,ITextHostImpl_TxScrollWindowEx,32)
-DEFINE_STDCALL_WRAPPER(17,ITextHostImpl_TxSetCapture,8)
-DEFINE_STDCALL_WRAPPER(18,ITextHostImpl_TxSetFocus,4)
-DEFINE_STDCALL_WRAPPER(19,ITextHostImpl_TxSetCursor,12)
-DEFINE_STDCALL_WRAPPER(20,ITextHostImpl_TxScreenToClient,8)
-DEFINE_STDCALL_WRAPPER(21,ITextHostImpl_TxClientToScreen,8)
-DEFINE_STDCALL_WRAPPER(22,ITextHostImpl_TxActivate,8)
-DEFINE_STDCALL_WRAPPER(23,ITextHostImpl_TxDeactivate,8)
-DEFINE_STDCALL_WRAPPER(24,ITextHostImpl_TxGetClientRect,8)
-DEFINE_STDCALL_WRAPPER(25,ITextHostImpl_TxGetViewInset,8)
-DEFINE_STDCALL_WRAPPER(26,ITextHostImpl_TxGetCharFormat,8)
-DEFINE_STDCALL_WRAPPER(27,ITextHostImpl_TxGetParaFormat,8)
-DEFINE_STDCALL_WRAPPER(28,ITextHostImpl_TxGetSysColor,8)
-DEFINE_STDCALL_WRAPPER(29,ITextHostImpl_TxGetBackStyle,8)
-DEFINE_STDCALL_WRAPPER(30,ITextHostImpl_TxGetMaxLength,8)
-DEFINE_STDCALL_WRAPPER(31,ITextHostImpl_TxGetScrollBars,8)
-DEFINE_STDCALL_WRAPPER(32,ITextHostImpl_TxGetPasswordChar,8)
-DEFINE_STDCALL_WRAPPER(33,ITextHostImpl_TxGetAcceleratorPos,8)
-DEFINE_STDCALL_WRAPPER(34,ITextHostImpl_TxGetExtent,8)
-DEFINE_STDCALL_WRAPPER(35,ITextHostImpl_OnTxCharFormatChange,8)
-DEFINE_STDCALL_WRAPPER(36,ITextHostImpl_OnTxParaFormatChange,8)
-DEFINE_STDCALL_WRAPPER(37,ITextHostImpl_TxGetPropertyBits,12)
-DEFINE_STDCALL_WRAPPER(38,ITextHostImpl_TxNotify,12)
-DEFINE_STDCALL_WRAPPER(39,ITextHostImpl_TxImmGetContext,4)
-DEFINE_STDCALL_WRAPPER(40,ITextHostImpl_TxImmReleaseContext,8)
-DEFINE_STDCALL_WRAPPER(41,ITextHostImpl_TxGetSelectionBarWidth,8)
-
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw,52)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceActivate,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceDeactivate,4)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurTargetX,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
-DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
diff --git a/dll/win32/riched20/msvc.h b/dll/win32/riched20/msvc.h
deleted file mode 100644
index bcc603b103..0000000000
--- a/dll/win32/riched20/msvc.h
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-#define __ASM_STDCALL_FUNC(name,args,code)
-
-#define typeof(X_) __typeof_ ## X_
-
-struct HDC__;
-struct ITextHost;
-struct tagRECT;
-struct _RECTL;
-struct _charformatw;
-struct _paraformat;
-struct tagPOINT;
-enum _TXTBACKSTYLE;
-struct tagSIZE;
-struct ITextServices;
-struct tagDVTARGETDEVICE;
-struct IDropTarget;
-
-#define WINAPI __stdcall
-#define HRESULT int
-#define HDC struct HDC__*
-#define BOOL int
-#define HIMC void*
-#define ITextHost struct ITextHost
-#define INT int
-#define UINT unsigned int
-#define HBITMAP void*
-#define LPCRECT const struct tagRECT *
-#define LPRECT struct tagRECT *
-#define LPCRECTL const struct _RECTL*
-#define CHARFORMATW struct _charformatw
-#define PARAFORMAT struct _paraformat
-#define DWORD unsigned int /* HACK */
-#define COLORREF DWORD
-#define LONG int /* HACK */
-#define WPARAM unsigned long
-#define LPARAM long
-#define HRGN void*
-#define HCURSOR void*
-#define LPPOINT struct tagPOINT*
-#define TXTBACKSTYLE enum _TXTBACKSTYLE
-#define WCHAR unsigned short
-#define BSTR WCHAR*
-#define LPCWSTR const WCHAR *
-#define SIZEL struct tagSIZE
-#define LPSIZEL struct tagSIZE*
-#define ITextServices struct ITextServices
-#define LRESULT long
-#define DVTARGETDEVICE struct tagDVTARGETDEVICE
-
-typedef HDC (WINAPI typeof(ITextHostImpl_TxGetDC))(ITextHost * iface);
-typedef int (WINAPI typeof(ITextHostImpl_TxReleaseDC))(ITextHost *iface,HDC hdc);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxShowScrollBar))(ITextHost *iface,INT
fnBar,BOOL fShow);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxEnableScrollBar))(ITextHost *iface,INT
fuSBFlags,INT fuArrowflags);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxSetScrollRange))(ITextHost *iface,INT
fnBar,LONG nMinPos,INT nMaxPos,BOOL fRedraw);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxSetScrollPos))(ITextHost *iface,INT fnBar,INT
nPos,BOOL fRedraw);
-typedef void (WINAPI typeof(ITextHostImpl_TxInvalidateRect))(ITextHost *iface,LPCRECT
prc,BOOL fMode);
-typedef void (WINAPI typeof(ITextHostImpl_TxViewChange))(ITextHost *iface,BOOL fUpdate);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxCreateCaret))(ITextHost *iface,HBITMAP
hbmp,INT xWidth, INT yHeight);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxShowCaret))(ITextHost *iface, BOOL fShow);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxSetCaretPos))(ITextHost *iface,INT x, INT
y);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxSetTimer))(ITextHost *iface,UINT idTimer,
UINT uTimeout);
-typedef void (WINAPI typeof(ITextHostImpl_TxKillTimer))(ITextHost *iface,UINT idTimer);
-typedef void (WINAPI typeof(ITextHostImpl_TxScrollWindowEx))(ITextHost *iface,INT dx, INT
dy,LPCRECT lprcScroll,LPCRECT lprcClip,HRGN hRgnUpdate,LPRECT lprcUpdate,UINT fuScroll);
-typedef void (WINAPI typeof(ITextHostImpl_TxSetCapture))(ITextHost *iface,BOOL
fCapture);
-typedef void (WINAPI typeof(ITextHostImpl_TxSetFocus))(ITextHost *iface);
-typedef void (WINAPI typeof(ITextHostImpl_TxSetCursor))(ITextHost *iface,HCURSOR
hcur,BOOL fText);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxScreenToClient))(ITextHost *iface,LPPOINT
lppt);
-typedef BOOL (WINAPI typeof(ITextHostImpl_TxClientToScreen))(ITextHost *iface,LPPOINT
lppt);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxActivate))(ITextHost *iface,LONG
*plOldState);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxDeactivate))(ITextHost *iface,LONG
lNewState);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetClientRect))(ITextHost *iface,LPRECT
prc);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetViewInset))(ITextHost *iface,LPRECT
prc);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetCharFormat))(ITextHost *iface,const
CHARFORMATW **ppCF);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetParaFormat))(ITextHost *iface,const
PARAFORMAT **ppPF);
-typedef COLORREF (WINAPI typeof(ITextHostImpl_TxGetSysColor))(ITextHost *iface,int
nIndex);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetBackStyle))(ITextHost
*iface,TXTBACKSTYLE *pStyle);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetMaxLength))(ITextHost *iface,DWORD
*pLength);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetScrollBars))(ITextHost *iface,DWORD
*pdwScrollBar);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetPasswordChar))(ITextHost *iface,WCHAR
*pch);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetAcceleratorPos))(ITextHost *iface,LONG
*pch);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetExtent))(ITextHost *iface,LPSIZEL
lpExtent);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_OnTxCharFormatChange))(ITextHost
*iface,const CHARFORMATW *pcf);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_OnTxParaFormatChange))(ITextHost
*iface,const PARAFORMAT *ppf);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetPropertyBits))(ITextHost *iface,DWORD
dwMask,DWORD *pdwBits);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxNotify))(ITextHost *iface,DWORD
iNotify,void *pv);
-typedef HIMC (WINAPI typeof(ITextHostImpl_TxImmGetContext))(ITextHost *iface);
-typedef void (WINAPI typeof(ITextHostImpl_TxImmReleaseContext))(ITextHost *iface,HIMC
himc);
-typedef HRESULT (WINAPI typeof(ITextHostImpl_TxGetSelectionBarWidth))(ITextHost
*iface,LONG *lSelBarWidth);
-
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxSendMessage))(ITextServices *iface,UINT
msg,WPARAM wparam,LPARAM lparam,LRESULT* plresult);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxDraw))(ITextServices *iface,DWORD
dwDrawAspect,LONG lindex,void* pvAspect,DVTARGETDEVICE* ptd,HDC hdcDraw,HDC
hdcTargetDev,LPCRECTL lprcBounds,LPCRECTL lprcWBounds,LPRECT lprcUpdate,BOOL (__stdcall *
pfnContinue)(DWORD),DWORD dwContinue,LONG lViewId);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetHScroll))(ITextServices *iface,LONG*
plMin,LONG* plMax,LONG* plPos,LONG* plPage,BOOL* pfEnabled);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetVScroll))(ITextServices *iface,LONG*
plMin,LONG* plMax,LONG* plPos,LONG* plPage,BOOL* pfEnabled);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxSetCursor))(ITextServices *iface,DWORD
dwDrawAspect,LONG lindex,void* pvAspect,DVTARGETDEVICE* ptd,HDC hdcDraw,HDC
hicTargetDev,LPCRECT lprcClient,INT x, INT y);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxQueryHitPoint))(ITextServices *iface,DWORD
dwDrawAspect,LONG lindex,void* pvAspect,DVTARGETDEVICE* ptd,HDC hdcDraw,HDC
hicTargetDev,LPCRECT lprcClient,INT x, INT y,DWORD* pHitResult);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxInplaceActivate))(ITextServices
*iface,LPCRECT prcClient);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxInplaceDeactivate))(ITextServices *iface);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxUIActivate))(ITextServices *iface);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxUIDeactivate))(ITextServices *iface);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetText))(ITextServices *iface,BSTR*
pbstrText);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxSetText))(ITextServices *iface,LPCWSTR
pszText);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetCurTargetX))(ITextServices *iface,LONG*
x);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetBaseLinePos))(ITextServices *iface,LONG*
x);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetNaturalSize))(ITextServices *iface,DWORD
dwAspect,HDC hdcDraw,HDC hicTargetDev,DVTARGETDEVICE* ptd,DWORD dwMode,const SIZEL*
psizelExtent,LONG* pwidth,LONG* pheight);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetDropTarget))(ITextServices *iface,struct
IDropTarget** ppDropTarget);
-typedef HRESULT (WINAPI typeof(fnTextSrv_OnTxPropertyBitsChange))(ITextServices
*iface,DWORD dwMask,DWORD dwBits);
-typedef HRESULT (WINAPI typeof(fnTextSrv_TxGetCachedSize))(ITextServices *iface,DWORD*
pdwWidth,DWORD* pdwHeight);
-
-#undef WINAPI
-#undef HRESULT
-#undef HDC
-#undef BOOL
-#undef COLORREF
-#undef HIMC
-#undef ITextHost
-#undef INT
-#undef UINT
-#undef HBITMAP
-#undef LPCRECT
-#undef LPRECT
-#undef LPCRECTL
-#undef CHARFORMATW
-#undef PARAFORMAT
-#undef DWORD
-#undef LONG
-#undef WPARAM
-#undef LPARAM
-#undef HRGN
-#undef HCURSOR
-#undef LPPOINT
-#undef TXTBACKSTYLE
-#undef WCHAR
-#undef BSTR
-#undef LPCWSTR
-#undef SIZEL
-#undef LPSIZEL
-#undef ITextServices
-#undef LRESULT
-#undef DVTARGETDEVICE
-
-//#undef typeof
diff --git a/dll/win32/riched20/txthost.c b/dll/win32/riched20/txthost.c
index eaa6aaef06..d709502a1e 100644
--- a/dll/win32/riched20/txthost.c
+++ b/dll/win32/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/dll/win32/riched20/txtsrv.c b/dll/win32/riched20/txtsrv.c
index 18c2ca9d69..73815fbbd1 100644
--- a/dll/win32/riched20/txtsrv.c
+++ b/dll/win32/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