Post · 4 min read· pp. 2805–2807

SMS

The SMS (formally tagSMS) structure is how WIN32K.SYS—and before it, WINSRV.DLL—packages a message that is to be sent between threads (which many programmers will think of as between windows).

Variability

The following changes of size are known.

VersionSize (x86)Size (x64)
3.100x40
3.51 to 6.30x3C0x70
10.00x480x88

Layout

Offset (x86)Offset (x64)DefinitionVersions
0x000x00SMS *psmsNext;3.10 to 6.3
unknown LIST_ENTRY10.0 and higher
0x04 (3.10)unknown SMS pointer3.10 only
0x08 (3.10)unknown SMS pointer3.10 only
0x0C (3.10); 0x04 (3.51 to 6.3); 0x080x08 (5.2 to 6.3); 0x10SMS *psmsReceiveNext;3.10 to 6.3
unknown LIST_ENTRY10.0 and higher

Each newly allocated SMS is inserted at the head of a global single-linked list, linking through the psmsNext pointer. Version 10.0 makes this a double-linked list.

Each newly allocated SMS is also inserted at the tail of the receiving thread’s pmsReceiveList, linking through the psmsReceiveNext pointer. Again, version 10.0 changes this list from single-linked to double. While a thread receives messages, it drains from the head of its psmsReceiveList.

Offset (x86)Offset (x64)DefinitionVersionsRemarks
0x10 (3.10); 0x08 (3.51 to 5.1)ULONG tSent;3.10 to 5.1next at 0x20
0x14 (3.10); 0x0C (3.51 to 5.1); 0x08 (5.2 to 6.3); 0x100x10 (5.2 to 6.3); 0x20THREADINFO *ptiSender;all
0x18 (3.10); 0x10 (3.51 to 5.1); 0x0C (5.2 to 6.3); 0x140x18 (5.2 to 6.3); 0x28THREADINFO *ptiReceiver;all
0x1C (3.10); 0x14 (3.51 to 5.1); 0x10 (5.2 to 6.3); 0x180x20 (5.2 to 6.3); 0x30SENDASYNCPROC lpResultCallBack;all
0x20 (3.10); 0x18 (3.51 to 5.1); 0x14 (5.2 to 6.3); 0x1C0x28 (5.2 to 6.3); 0x38DWORD_PTR dwData;all
0x24 (3.10); 0x1C (3.51 to 5.1); 0x18 (5.2 to 6.3); 0x200x30 (5.2 to 6.3); 0x40THREADINFO *ptiCallBackSender;all
0x28 (3.10); 0x20 (3.51 to 5.1); 0x1C (5.2 to 6.3); 0x240x38 (5.2 to 6.3); 0x48LONG_PTR lRet;all
0x20 (5.2 to 6.3); 0x280x40 (5.2 to 6.3); 0x50ULONG tSent;5.2 and higherpreviously at 0x08
0x2C (3.10); 0x24 (3.51 to 6.3); 0x2C0x44 (5.2 to 6.3); 0x54UINT flags;all
0x30 (3.10); 0x28 (3.51 to 6.3); 0x300x48 (5.2 to 6.3); 0x58WPARAM wParam;all
0x34 (3.10); 0x2C (3.51 to 6.3); 0x340x50 (5.2 to 6.3); 0x60LPARAM lParam;all
0x38 (3.10); 0x30 (3.51 to 6.3); 0x380x58 (5.2 to 6.3); 0x68UINT message;all
0x3C (3.10); 0x34 (3.51 to 6.3); 0x3C0x60 (5.2 to 6.3); 0x70WND *spwnd;alllast member in 3.10
0x38 (3.51 to 6.3); 0x400x68 (5.2 to 6.3); 0x78PVOID pvCapture;3.51 and higherlast member in 3.51 to 6.3
0x440x80unknown dword10.0 and higherlast member in 10.0

Flags

Debugger extensions from DDKs for Windows NT 3.51 through Windows 2000 helpfully have descriptive strings for the bits within the flags. It seems highly plausible that these are the macros that are used for the bits in the source code.

MaskNameVersions
0x00000001SMF_REPLYall
0x00000002SMF_RECEIVERDIEDall
0x00000004SMF_SENDERDIEDall
0x00000008SMF_RECEIVERFREEall
0x00000010SMF_RECEIVERBUSY3.10 to 3.51
SMF_RECEIVEDMESSAGE4.0 and higher
0x000000E0perhaps unused
0x00000100SMF_CB_REQUESTall
0x00000200SMF_CB_REPLYall
0x00000400SMF_CB_CLIENTall
0x00000800SMF_CB_SERVERall
0x00001000SMF_WOWRECEIVE3.51 and higher
0x00002000SMF_WOWSEND3.51 and higher
0x00004000SMF_RECEIVEDMESSAGE3.51 only
SMF_RECEIVERBUSY4.0 and higher
0x000080006.0 and higher
0x0001000010.0 and higher

There seems to have been some confusion over the SMF_RECEIVERBUSY and SMF_RECEIVEDMESSAGE flags. Version 3.10 has only whichever one of them is the 0x00000010 flag. It is set on receiving the message. Version 3.51 introduces the other flag, 0x00004000. This too is set on receiving the message, but it gets cleared before either freeing the message or replying to it.

By the way, the SMF_RECEIVERFREE flag is not named in contrast to SMF_RECEIVERBUSY. It simply means that the receiving thread is to free the SMS, notably because the sending thread wants no reply.