The following entry points are probably useful for people who have to deal with thunking, i.e. translation of 0:32 pointers to 16:16 and vice versa.
Back in the old days of OS/2 2.x/3.x, this pointer conversion was a rather simple job. Some clever programmers invented a fast mechanism to convert pointers between 16 and 32 bit, by use of the local descriptor table (LDT). The LDT was initialized to contain direct translations for the first 512MB of memory, i.e. the first 64K were mapped to LDT entry 0 (invalid, though!), the second 64k to entry 1, third to 2 and so on. Since there are 8192 LDT entries, this sums up to 8192 * 64K = 512MB of addressable memory. The following formulae applied:
flataddr = ((((selector&0x1fff) << 3) | 0x0007) << 16) | offsetand
selector = (flataddr >> 3) >> 16 offset = flataddr & 0xffff
The formulae are written here for readability, in assembler they turn out to be pretty efficiently codeable.
Unfortunately, this no longer works with newer kernels which allow user processes to get more than 512MB of memory; thus some sort of compatibility to old 16 bit apps has been dropped. It is now no longer guaranteed to 32 bit apps that there is a 1:1 relation between used 32 bit and 16:16 addresses through LDT, so simple arithmetics probably will no longer apply. This is particularly difficult if some 32 bit application has to transfer data to some legacy 16 bit app. This is what the following API functions are good for.
An application for these functions is described in the DDK header
file ddkx86\inc\thkmacs.inc which explains how to
create handcoded thunks.
| Name | Ordinal | type |
| DOSFLATTOSEL | 423 | 16bit |
| DOSSELTOFLAT | 424 | 16bit |
| Dos32FlatToSel | 425 | 32bit |
| Dos32SelToFlat | 426 | 32bit |