PRB: Why Thunking to 16-bit MAPI Will Fail Under Win32sLast reviewed: April 11, 1996Article ID: Q149710 |
The information in this article applies to:
SUMMARYThis article discusses the details on why a Win32s client (a 32-bit thunk DLL) cannot thunk to the 16-bit MAPI DLL. It also suggests several workarounds for this situation.
SYMPTOMSThe MAPI interface is not supported under any version of Win32s. In addition, a Win32s client (a 32-bit application or a DLL) cannot directly thunk down to 16-bit MAPI APIs in Windows 3.x. There are several resolutions for this scenario.
CAUSEWhen the 16-bit MAPI DLL allocates a buffer on behalf of a call from the 32- bit thunk DLL, your 16-bit code will have to call UTSelectorOffsetToLinear() on the returned 16:16 address. The result is a flat 32-bit address that can then be passed back to the 32-bit DLL. But when the 32-bit code is ready to call the 16-bit MAPIFreeBuffer() function by way of the thunk, the flat 32-bit address needs to be converted back to the original 16:16 address that the 16-bit code can use. The normal solution is that the 16-bit code would call UTLinearToSelectorOffset() on the 32-bit address passed from the 32-bit client before making a call to MAPIFreeBuffer(). But the problem is that in the following nested function call where x is a segmented (16:16) address, Win32s does not guarantee to return the original value of x (16:16 address) back. Hence, when MAPIFreeBuffer is called with this bogus 16:16 address, it fails.
UTLinearToSelectorOffset( UTSelectorOffsetToLinear(x) )Note that this address translation problem described here is not specific to the MAPI allocation and de-allocation routines. It applies to all 16-bit MAPI functions that use 16:16 segmented addresses.
RESOLUTIONHere are three approaches you can use to resolve this situation:
These three approaches are only suggestions; Microsoft cannot provide support if you decide to implement them in your Win32s-based application.
STATUSThis behavior is by design.
|
Additional reference words: 1.30 1.30c kbinf ipc mapi thunk win16 win32
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |