Inter-thread SendMessage() bugfixes:
- Insert new message to be received at the *end* of the SM_PENDING_LIST.
- Do *not* process received messages in ReplyMessage().
- Clear the QS_SMRESULT flag only immediatedly before waiting.

diff --git a/windows/queue.c b/windows/queue.c
index 5ed0024..adf918b 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -750,15 +750,22 @@
             break;
             
         case SM_PENDING_LIST:
+        {
             /* make it thread safe, could be accessed by the sender and
              receiver thread */
+            SMSG **prev;
 
             EnterCriticalSection( &queue->cSection );
-            smsg->nextPending = queue->smPending;
-            queue->smPending = smsg;
-            QUEUE_SetWakeBit( queue, QS_SENDMESSAGE );
+            smsg->nextPending = NULL;
+            prev = &queue->smPending;
+            while ( *prev )
+                prev = &(*prev)->nextPending;
+            *prev = smsg;
             LeaveCriticalSection( &queue->cSection );
+
+            QUEUE_SetWakeBit( queue, QS_SENDMESSAGE );
             break;
+        }
 
         default:
             WARN(sendmsg, "Invalid list: %d", list);