A technical answer to the question "What Isa Thunk?" is that it is a change of address space (or memory addressing method).
In the Microsoft world, a "thunk" is a switch to another kind of address space, like to call 32-bit library functions from a 16-bit program.
Anyone with examples of how to do this? Last time I checked, this required particularly gross things like opening a socket connection between the 32-bit DLL and the 16-bit DLL. -- Sunir Shah
This (the socket-opening thing) is curiously reminiscent of some of the tricks apparently used by split-brain patients (who've had their cerebral commissure severed as a treatment for severe epilepsy) use to re-establish communication between the two halves of the brain. I always thought Microsoft products were brain-damaged... :-) -- Gareth Mc Caughan
OS/2 also needed to switch between 16-bit and 32-bit address spaces, and the little stubs that did it were also called thunks. As I recall, it has to do with call gates and other arcane things, but doesn't require sockets.
See Microsoft Knowledge Base Article ID Q154093, "HOWTO: Call 32-bit Code from 16-bit Code Under Windows 95" support.microsoft.com
I believe this loads the 32-bit DLL into the 16-bit process. -- Jeff Grigg
See Microsoft Knowledge Base Article ID Q155763, "HOWTO: Call 16-bit Code from 32-bit Code Under Windows 95" support.microsoft.com
I've also seen Win32 API functions to do this, but I've misplaced the reference...
Originally the 80286 didn't have any way to switch from "large address space" back to "16 bit 8086 compatible" mode. It wasn't designed to; as who would want to switch back to 16 bit after upgrading? Well, lots of people wanted to switch back and forth, to access memory over the 1MB barrier and yet to still run the old 16-bit programs and OS. So clever hardware designers gave the software a way to trigger the reset pin of the CPU, causing it to restart -- redoing the power on reset process. So, every time you wanted to fetch or write a page of RAM to your RAM DISK, the system would switch "up" to 32 bit, fetch the data, and then "power on reset" the CPU. Quite a "thunk" just to switch address spaces, eh?
Well, it wasn't 32-bit; the size of a segment was still limited to 64k, and memory objects larger than that had to be split across multiple segments. What the 80286 offered was a way to have the segment registers map through a lookup table that contained base address and length, rather than treating them directly as (base address * 16). The addressing range was also extended somewhat; the '286 had 24 bits of physical address instead of 20. None of this changes the fact that the reset pin thing was a hack though.
See original on c2.com