TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Dan Larson
from: Jonathan de Boyne Pollard
date: 1994-11-01 05:03:40
subject: 16-Bit To 32-Bit Callbac

DL>
  > the stack for the function call. I am assuming that the problem is that the
  > stack pointer handed to me by the 16-bit NSFSearch function calling my 32-b
  > "action_routine" needs to be thunked before I can use it.
I haven't the
  > slightest idea how to make sure my stack pointer gets thunked when the 16-b
  > code calls my 32-bit routine... Would anyone who knows how
  > please help me out?
DL>

  There are basically two directions for thunking.

  The first is 32->16, where 32-bit code is calling 16-bit libraries,
  such as your Lotus Notes stuff.  This is done by declaring the 16-bit
  API using _Far16 and so forth, and CSet++ will insert pointer and
  stack conversion code in the 32-bit code that calls the function for
  you. As you said, you seem to have this down pat.

  The second is 16->32, and is usually encountered where you need to
  pass a callback function to a 16-bit library.  This is more complex,
  because obviously the 16-bit code will be expecting to call a 16-bit
  function on a 16-bit stack using 16-bit pointers.  Functions written
  for the 32-bit world won't work.

  What you need to do is define your callback function as a 16-bit
  *callable* function.  You do this in the same way as you declare a
  16-bit *called* function, by using _Far16 and friends.  The only
  difference is where the thunking code goes.  This time it goes in the
  callee, not the caller.

  For example, this function is callable by 16-bit code

      void _Far16 _Cdecl callback ( short a, short b ) {}

  What happens now is that CSet++ at the start of the body of the
  function generates all of the code to convert from a 16-bit stack to a
  32-bit stack, and at the end of the function generates the code to go
  back again.  To the 16-bit world, this looks just like a 16-bit
  function, but the body of the function runs in the normal 32-bit
  world.

  This is all covered in the CSet++ manual, by the way.

  > JdeBP <
___
 X MegaMail 2.10 #0:
--- Maximus/2 2.01wb

* Origin: DoNoR/2,Woking UK (0483-725167) (2:440/4)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413
SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1
@PATH: 440/4 141/209 270/101 396/1 3615/50 229/2 12/2442 711/409 54/54
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.