Retrofitting the WM_COPY­DATA message onto Windows 3.1

ibobev2 pts0 comments

Retrofitting the WM_COPY­DATA message onto Windows 3.1 - The Old New Thing

Skip to main content

Search<br>Search

No results

Cancel

Raymond Chen

Some time ago, I talked about how to return results back from the WM_COPY­DATA message. Which reminded me of a clever bit of history.

The WM_COPY­DATA message was introduced in 32-bit Windows. There was no need for it in 16-bit Windows because all 16-bit programs ran in the same address space. A far pointer in one process was good in any process. You could put it in the lParam of a window message and send it to any other window, same process or different process, doesn’t matter. But 32-bit programs ran in separate address spaces, so this trick didn’t work. Hence the need for WM_COPY­DATA to pass data not only between 32-bit programs, but also between 32-bit programs and 16-bit programs.

How did this message get retrofitted into 16-bit Windows so that Win32s could support it?

Easy: It was already implemented, unwittingly.

If the source and destination windows are both 16-bit windows, then the pointer to the COPY­DATA­STRUCT is already valid in both processes, as is the pointer inside the COPY­DATA­STRUCT. And the window handle in the wParam is also the same for both processes. Therefore, doing absolutely nothing with the wParam and lParam and simply allowing it to pass from a 16-bit program to another 16-bit program will still behave as expected.

And it so happens that Windows 3.1 already did that: Windows 3.1 always passed the wParam and lParam unmodified, even when the message sender and receiver are in different processes, because all programs shared the same address space.

It was just a sneaky trick to design the WM_COPY­DATA message in such a way that the null marshaler is the correct behavior when it is sent between 16-bit programs.

Category<br>Old New Thing

Topics<br>Other

Share

WM_COPY&shy;DATA message onto Windows 3.1" data-bi-id="post_page_body_share post" data-post-id=112430 data-bi-name="Share on X" aria-label="Share on X" target="_blank" rel="noreferrer noopener" class="d-flex share-post">

Author

Raymond Chen

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

1 comment

Join the discussion.

Leave a commentCancel reply<br>Sign in

Code of Conduct

Sort by :

Newest

Newest<br>Popular<br>Oldest

Ah, but what concurrency "fun" if either 16-bit sender or receiver decided to modify the data or the sender deallocated it after sending. The joys of a 16-bit OS.

Read next

June 5, 2026

C++: The Programming Language also raises questions not answered by the front cover" href="https://devblogs.microsoft.com/oldnewthing/20260605-01/?p=112391">The back cover of C++: The Programming Language also raises questions not answered by the front cover

Raymond Chen

April 27, 2026

Looking at consequences of passing too few register parameters to a C function on various architectures

Raymond Chen

Stay informed

Get notified when new posts are published.

Email *

Country/Region *<br>Select...United StatesAfghanistanÅland IslandsAlbaniaAlgeriaAmerican SamoaAndorraAngolaAnguillaAntarcticaAntigua and BarbudaArgentinaArmeniaArubaAustraliaAustriaAzerbaijanBahamasBahrainBangladeshBarbadosBelarusBelgiumBelizeBeninBermudaBhutanBoliviaBonaireBosnia and HerzegovinaBotswanaBouvet IslandBrazilBritish Indian Ocean TerritoryBritish Virgin IslandsBruneiBulgariaBurkina FasoBurundiCabo VerdeCambodiaCameroonCanadaCayman IslandsCentral African RepublicChadChileChinaChristmas IslandCocos (Keeling) IslandsColombiaComorosCongoCongo (DRC)Cook IslandsCosta RicaCôte dIvoireCroatiaCuraçaoCyprusCzechiaDenmarkDjiboutiDominicaDominican RepublicEcuadorEgyptEl SalvadorEquatorial GuineaEritreaEstoniaEswatiniEthiopiaFalkland IslandsFaroe IslandsFijiFinlandFranceFrench GuianaFrench PolynesiaFrench Southern TerritoriesGabonGambiaGeorgiaGermanyGhanaGibraltarGreeceGreenlandGrenadaGuadeloupeGuamGuatemalaGuernseyGuineaGuinea-BissauGuyanaHaitiHeard Island and McDonald IslandsHondurasHong Kong SARHungaryIcelandIndiaIndonesiaIraqIrelandIsle of ManIsraelItalyJamaicaJan MayenJapanJerseyJordanKazakhstanKenyaKiribatiKoreaKosovoKuwaitKyrgyzstanLaosLatviaLebanonLesothoLiberiaLibyaLiechtensteinLithuaniaLuxembourgMacau SARMadagascarMalawiMalaysiaMaldivesMaliMaltaMarshall IslandsMartiniqueMauritaniaMauritiusMayotteMexicoMicronesiaMoldovaMonacoMongoliaMontenegroMontserratMoroccoMozambiqueMyanmarNamibiaNauruNepalNetherlandsNew CaledoniaNew ZealandNicaraguaNigerNigeriaNiueNorfolk IslandNorth MacedoniaNorthern Mariana IslandsNorwayOmanPakistanPalauPalestinian AuthorityPanamaPapua New...

data windows message wm_copy programs raymond

Related Articles