Mixing 16-Bit and 32-Bit Application Modules

Under OS/2 Version 2.0, 32-bit applications may make use of existing 16-bit application code and resources; this practice is known as mixed model programming. For example, a 32-bit Presentation Manager application may access an object window procedure contained in a 16-bit DLL created for OS/2 Version 1.3. This capability allows 32-bit applications to make use of existing application objects, avoiding the necessity to rewrite existing object libraries to accommodate the 32-bit programming environment.

Applications that make use of 16-bit modules and resources must be aware of the particular characteristics of the 16-bit environment, which affect the way that application modules interface with one another and pass parameters or messages. Such characteristics include:

  • Pointers in the 16-bit environment are made up of a segment selector and an offset; this addressing scheme is therefore known as 16. Pointers in the 32-bit environment are composed of a linear offset only; hence the addressing scheme is known as 0:32. Note that this difference in representation applies not only to memory pointers, but also to window and resource handles under Presentation Manager.

  • Memory objects passed as parameters between 16-bit and 32-bit routines must not be greater than 64KB in size, in order to avoid problems with the 16-bit segmented memory model.

  • Memory objects passed as parameters from 32-bit applications to 16-bit routines must not lie across a segment boundary.

    Obviously, conversion of pointers and possible realignment of memory objects is required when passing control between 16-bit and 32-bit modules. This conversion between addressing schemes is known under OS/2 Version 2.0 as thunking. Thunking is performed using a simple algorithm known as the Compatibility Region Mapping Algorithm (CRMA). This algorithm, along with sample code, is described in OS/2 Version 2.0 - Volume 1: Control Program.


    [Back: Summary]
    [Next: Function Calls to 16-Bit Modules]