Commit ce3c4593 authored by Alexandre Julliard's avatar Alexandre Julliard

rpcrt4: Return the stack size from the ObjectStubless function so that the…

rpcrt4: Return the stack size from the ObjectStubless function so that the thunks are independent from the number of arguments.
parent 6f490238
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
* TODO: Handle non-i386 architectures * TODO: Handle non-i386 architectures
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdarg.h> #include <stdarg.h>
#define COBJMACROS #define COBJMACROS
...@@ -65,50 +68,50 @@ static const IRpcProxyBufferVtbl StdProxy_Vtbl; ...@@ -65,50 +68,50 @@ static const IRpcProxyBufferVtbl StdProxy_Vtbl;
struct StublessThunk { struct StublessThunk {
BYTE push; BYTE push;
DWORD index; DWORD index;
BYTE call; BYTE jmp;
LONG handler; LONG handler;
BYTE ret;
WORD bytes;
BYTE pad[3];
}; };
#include "poppack.h" #include "poppack.h"
/* adjust the stack size since we don't use Windows's method */ #define FILL_STUBLESS(x,idx) \
#define STACK_ADJUST sizeof(DWORD)
#define FILL_STUBLESS(x,idx,stk) \
x->push = 0x68; /* pushl [immediate] */ \ x->push = 0x68; /* pushl [immediate] */ \
x->index = (idx); \ x->index = (idx); \
x->call = 0xe8; /* call [near] */ \ x->jmp = 0xe9; /* jmp */ \
x->handler = (char*)ObjectStubless - (char*)&x->ret; \ x->handler = (char*)call_stubless_func - (char*)(&x->handler + 1);
x->ret = 0xc2; /* ret [immediate] */ \
x->bytes = stk; \ extern void call_stubless_func(void);
x->pad[0] = 0x8d; /* leal (%esi),%esi */ \ __ASM_GLOBAL_FUNC(call_stubless_func,
x->pad[1] = 0x76; \ "pushl %esp\n\t" /* pointer to index */
x->pad[2] = 0x00; "call " __ASM_NAME("ObjectStubless") "\n\t"
"popl %edx\n\t" /* args size */
static HRESULT WINAPI ObjectStubless(DWORD index) "movl (%esp),%ecx\n\t" /* return address */
"addl %edx,%esp\n\t"
"jmp *%ecx" );
HRESULT WINAPI ObjectStubless(DWORD *args)
{ {
char *args = (char*)(&index + 2); DWORD index = args[0];
LPVOID iface = *(LPVOID*)args; LPVOID iface = (LPVOID)args[2];
ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface); ICOM_THIS_MULTI(StdProxyImpl,PVtbl,iface);
const MIDL_STUBLESS_PROXY_INFO *stubless = This->stubless;
const PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[index];
PFORMAT_STRING fs = This->stubless->ProcFormatString + This->stubless->FormatStringOffset[index]; /* store bytes to remove from stack */
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST; args[0] = *(const WORD*)(fs + 8);
TRACE("(%p)->(%d)([%d bytes]) ret=%08x\n", iface, index, bytes, *(DWORD*)(args+bytes)); TRACE("(%p)->(%d)([%d bytes]) ret=%08x\n", iface, index, args[0], args[1]);
return NdrClientCall2(This->stubless->pStubDesc, fs, args); return NdrClientCall2(stubless->pStubDesc, fs, args + 2);
} }
#else /* __i386__ */ #else /* __i386__ */
/* can't do that on this arch */ /* can't do that on this arch */
struct StublessThunk { int dummy; }; struct StublessThunk { int dummy; };
#define FILL_STUBLESS(x,idx,stk) \ #define FILL_STUBLESS(x,idx) \
ERR("stubless proxies are not supported on this architecture\n"); ERR("stubless proxies are not supported on this architecture\n");
#define STACK_ADJUST 0
#endif /* __i386__ */ #endif /* __i386__ */
...@@ -157,10 +160,7 @@ HRESULT StdProxy_Construct(REFIID riid, ...@@ -157,10 +160,7 @@ HRESULT StdProxy_Construct(REFIID riid,
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
struct StublessThunk *thunk = &This->thunks[i]; struct StublessThunk *thunk = &This->thunks[i];
if (vtbl->Vtbl[i] == (LPVOID)-1) { if (vtbl->Vtbl[i] == (LPVOID)-1) {
PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[i]; FILL_STUBLESS(thunk, i)
unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST;
TRACE("method %d: stacksize=%d\n", i, bytes);
FILL_STUBLESS(thunk, i, bytes)
This->PVtbl[i] = thunk; This->PVtbl[i] = thunk;
} }
else { else {
......
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