[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: 16 bit vararg functions
From:       Ulrich Weigand <weigand () informatik ! uni-erlangen ! de>
Date:       1999-12-29 0:42:35
[Download RAW message or body]


> Currently I'm just returning ICSendMessage(hic,msg,&cb,cb). I'm not sure
> how portable (or accurate) this is though. 

No, this doesn't work.  Wine switches to a completely different stack
during the transition from 16-bit to 32-bit code, so everything that is
not explicitly copied (due do being specified in the .spec file), is
simply not present on the 32-bit stack.

To implement 16-bit variable-argument routines, you'll have to use the
VA_START16 / VA_ARG16 macros (which are implemented by directly accessing
the 16-bit stack of the caller).  For usage examples, check out e.g.
WIN16_wsprintf16 (misc/wsprintf.c) or WOW_CallProc32W16 (relay32/wowthunk.c).

Basically, you'll need a spec entry of
  207 pascal _ICMESSAGE() ICMessage16
a function declaration of
  LRESULT WINAPIV ICMessage16( void )

and retrieve the parameters using

  VA_LIST16 va_list;
  VA_START16( va_list );

  hic = VA_ARG16( va_list, HIC16 );
  msg = VA_ARG16( va_list, UINT16 );
  cb  = VA_ARG16( va_list, UINT16 );

... and then continue fetching parameters using VA_ARG16
(if you don't know the types, get them WORD by WORD until
the total size is reached).

[ Actually, va_list is in fact a pointer to the 16-bit stack,
  so you might as well use a  'memcpy( buffer, va_list, cb )'
  or so; this does rely somewhat more on implementation details,
  but I'm not sure that matters ... ]

Bye,
Ulrich

-- 
  Ulrich Weigand,
  IMMD 1, Universitaet Erlangen-Nuernberg,
  Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-7688

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic