Index: trunk/src/user32/Makefile
===================================================================
--- trunk/src/user32/Makefile	(revision 193)
+++ trunk/src/user32/Makefile	(revision 196)
@@ -1,3 +1,3 @@
-# $Id: Makefile,v 1.7 1999-06-23 22:39:01 phaller Exp $
+# $Id: Makefile,v 1.8 1999-06-25 21:35:27 sandervl Exp $
 
 #
@@ -25,5 +25,5 @@
         dlgconvert.obj icon.obj hook.obj hooks.obj menu.obj \
         usrcall.obj defwndproc.obj syscolor.obj char.obj initterm.obj \
-        uitools.obj unknown.obj
+        uitools.obj unknown.obj spy.obj
 
 
@@ -68,7 +68,9 @@
 wndclass.obj: wndclass.cpp \
               $(PDWIN32_INCLUDE)\wndproc.h $(PDWIN32_INCLUDE)\wndclass.h
-initterm.obj: initterm.cpp
+initterm.obj: initterm.cpp $(PDWIN32_INCLUDE)\spy.h
 uitools.obj: uitools.cpp
 unknown.obj: unknown.cpp
+
+spy.obj: spy.cpp $(PDWIN32_INCLUDE)\spy.h
 
 
Index: trunk/src/user32/spy.cpp
===================================================================
--- trunk/src/user32/spy.cpp	(revision 196)
+++ trunk/src/user32/spy.cpp	(revision 196)
@@ -0,0 +1,100 @@
+/* $Id: spy.cpp,v 1.1 1999-06-25 21:35:27 sandervl Exp $ */
+
+/*
+ * Queue procedures to send messages to the spy server
+ *
+ * Copyright 1999 Sander van Leeuwen
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#define INCL_DOSPROCESS
+#define INCL_DOSQUEUES
+#define INCL_DOSMEMMGR
+#define INCL_WINMESSAGEMGR
+#define INCL_DOSERRORS
+#define INCL_DOSSEMAPHORES
+#include <os2.h>
+#include <os2wrap.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <misc.h>
+#include <spy.h>
+
+
+#define  Q_BUFFER_SIZE  4096
+#define  MAX_MESSAGES   (Q_BUFFER_SIZE/sizeof(Q_SPYMSG))
+
+PID       pidServer  = 0;
+HQUEUE    hqQueue    = 0;
+Q_SPYMSG *pvdQMemory = 0;
+int       msgIndex   = 0;
+
+BOOL InitSpyQueue()
+{
+ APIRET rc;
+
+   if (rc = DosOpenQueue(&pidServer, &hqQueue, "\\queues\\"Q_NAME))
+   {
+	dprintf(("InitSpyQueue: couldn't open spy queue rc=%d!", rc));
+	return FALSE;
+   }
+   if (rc = DosAllocSharedMem((VOID **)&pvdQMemory,
+                         NULL,
+                         Q_BUFFER_SIZE,
+                         fALLOCSHR))
+   {
+	dprintf(("InitSpyQueue: DosAllocSharedMem failed rc=%d", rc));
+	DosCloseQueue(hqQueue);
+	return FALSE;
+   }
+
+   /* give memory to server */
+   if (DosGiveSharedMem(pvdQMemory, pidServer, PAG_READ | PAG_WRITE))
+   {
+	dprintf(("InitSpyQueue: DosGiveSharedMem failed"));
+	DosCloseQueue(hqQueue);
+	return FALSE;
+   }
+   return (TRUE);
+}
+
+void CloseSpyQueue()
+{
+   if(hqQueue)
+   	DosCloseQueue(hqQueue);
+   if(pvdQMemory)
+   	DosFreeMem(pvdQMemory);
+}
+
+VOID PostSpyMessage(HWND hwnd, ULONG Msg, ULONG wParam, ULONG lParam)
+{
+ APIRET rc;
+
+   if (hqQueue == 0)
+	return;
+   
+   pvdQMemory[msgIndex].hwnd   = hwnd;
+   pvdQMemory[msgIndex].Msg    = Msg;
+   pvdQMemory[msgIndex].wParam = wParam;
+   pvdQMemory[msgIndex].lParam = lParam;
+
+   if (rc = DosWriteQueue(hqQueue,
+                     Q_SPYMSG_WNDMSG,
+                     sizeof(Q_SPYMSG),
+                     &pvdQMemory[msgIndex],
+                     0))
+   {
+	hqQueue = 0; //give up, server probably died
+	dprintf(("PostSpyMessage: DosWriteQueue returned %d", rc));
+	return;
+   }
+   if(++msgIndex >= MAX_MESSAGES) 
+   {
+	msgIndex = 0;
+   }
+}
+
Index: trunk/src/user32/wndclass.cpp
===================================================================
--- trunk/src/user32/wndclass.cpp	(revision 193)
+++ trunk/src/user32/wndclass.cpp	(revision 196)
@@ -1,3 +1,3 @@
-/* $Id: wndclass.cpp,v 1.6 1999-06-21 00:21:26 buerkle Exp $ */
+/* $Id: wndclass.cpp,v 1.7 1999-06-25 21:35:27 sandervl Exp $ */
 
 /*
@@ -22,4 +22,5 @@
 #include "wndclass.h"
 #include "hooks.h"
+#include <spy.h>
 
 //default window handlers that are registered by RegisterClass are called
@@ -801,5 +802,6 @@
 
 #ifdef DEBUG
-  dprintf(("OS2ToWinCallback for message %s", GetMsgText(Msg)));
+  dprintf(("OS2ToWinCallback %s for %x %x %x", GetMsgText(Msg), hwnd, wParam, lParam));
+  PostSpyMessage(hwnd, Msg, wParam, lParam);
 #endif
 
Index: trunk/src/user32/wndproc.cpp
===================================================================
--- trunk/src/user32/wndproc.cpp	(revision 193)
+++ trunk/src/user32/wndproc.cpp	(revision 196)
@@ -1,3 +1,3 @@
-/* $Id: wndproc.cpp,v 1.6 1999-06-20 16:47:39 sandervl Exp $ */
+/* $Id: wndproc.cpp,v 1.7 1999-06-25 21:35:27 sandervl Exp $ */
 
 /*
@@ -23,4 +23,5 @@
 #include "dlgconvert.h"
 #include "hooks.h"
+#include <spy.h>
 
 #ifdef DEBUG
@@ -288,5 +289,6 @@
   if(curwnd != NULL) {
 #ifdef DEBUG
-        WriteLog("***************Message %s for window/dialog %X\n", GetMsgText(Msg), hwnd);
+        WriteLog("Message %s for %X %x %x\n", GetMsgText(Msg), hwnd, wParam, lParam);
+	PostSpyMessage(hwnd, Msg, wParam, lParam);
 #endif
 	switch(Msg) 
