On Tue, Jan 02, 2001 at 08:00:36AM -0500, Francois Jacques wrote:
> If the network is not lying to me again,
> [EMAIL PROTECTED] wrote on Thu, Dec 21, 2000 at 01:37:39PM -0800:
>
> > Francois Jacques <[EMAIL PROTECTED]> writes:
> >
> > > +static HRESULT
> > > +INVOKE_InvokeStdCallFunction(IUnknown* pIUnk,
> > > + FUNCDESC* pFuncDesc,
> > > + VARIANTARG* paArgsCoerced,
> > > + VARIANT* pVarResult,
> > > + EXCEPINFO* pExcepInfo)
> > > +{
> > > + typedef DWORD (__stdcall *pDWORDRetFunc) (IUnknown*);
> > > + typedef double (__stdcall *pDoubleRetFunc)(IUnknown*);
> > > +
> > > + HRESULT hr = E_FAIL;
> > > +
> > > + /* retrieve current stack pointer, keep a copy */
> > > +#ifdef __GNUC__
> > > +#ifdef __i386__
> > > + register DWORD esp asm("esp");
> > > +#endif
> > > +#endif
> >
> > You absolutely cannot manipulate the stack behind gcc's back. There is
> > no way this can work except by pure blind luck.
>
>
> OK, now could you explain us why?
gcc knows about the values on the stack and manages them itself, sometimes
keeping them in registers over a time, sometimes not.
Modifying the stack is just an invitation to occasional unexplainable
brokenness.
> > You should build the
> > arguments into a DWORD array and then use a switch statement to pass
> > the right number of parameters, like we do in relay32/relay386.c.
>
>
> We were thinking about implementing it that way, but implementing it
> like it is (no limitation about the number of parameters) appeared at
> the time a more efficient approach. I like the relay implementation
> since it's 100% portable while this one isn't. However, and I repeat
> myself here, I'd like to know why the code can't work.
You could also implement it complete in assembler if you want to.
Ciao, Marcus