Creating a Thunk Script

The thunk compiler takes an input file called a thunk script. Thunk scripts contain C-style type definitions and prototypes of the functions that are to be called through the thunk. Thunk scripts usually have a .THK filename extension.

To create 32-bit to 16-bit thunks, place the following line at the beginning of the thunk script:

enablemapdirect3216 = true;     // Creates 32->16 thunks. 

Alternatively, to create 16-bit to 32-bit thunks, place the following line at the beginning of the thunk script:

enablemapdirect1632 = true;     // Creates 16->32 thunks. 

If you need to create both types of thunks, you must create two thunk scripts, one for 32-bit to16-bit thunks and the other for 16-bit to 32-bit thunks.

The remainder of the thunk script contains type definitions, followed by prototypes of the thunk functions. For an example of a simple thunk script, suppose we are calling the following 32-bit function from a 16-bit application:

BOOL WINAPI Sample(int n)
{
    // ...
}
 

The corresponding thunk script would look like this:

enablemapdirect1632=true;

typedef bool BOOL; 
 
BOOL Sample(int n) 
{ 
}