Moved a few remaining 16-bit definitions out of the standard headers.
[wine] / windows / spy.c
1 /*
2  * Message spying routines
3  *
4  * Copyright 1994, Bob Amstadt
5  *           1995, Alex Korobka
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winreg.h"
30 #include "wownt32.h"
31 #include "wine/unicode.h"
32 #include "win.h"
33 #include "wine/debug.h"
34 #include "message.h"
35 #include "winnls.h"
36 #include "commctrl.h"
37 #include "commdlg.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(message);
40
41 #define SPY_MAX_MSGNUM   WM_USER
42 #define SPY_INDENT_UNIT  4  /* 4 spaces */
43
44 #define DEBUG_SPY 0
45
46 static const char * const MessageTypeNames[SPY_MAX_MSGNUM + 1] =
47 {
48     "WM_NULL",                  /* 0x00 */
49     "WM_CREATE",
50     "WM_DESTROY",
51     "WM_MOVE",
52     "wm_sizewait",
53     "WM_SIZE",
54     "WM_ACTIVATE",
55     "WM_SETFOCUS",
56     "WM_KILLFOCUS",
57     "WM_SETVISIBLE",
58     "WM_ENABLE",
59     "WM_SETREDRAW",
60     "WM_SETTEXT",
61     "WM_GETTEXT",
62     "WM_GETTEXTLENGTH",
63     "WM_PAINT",
64     "WM_CLOSE",                 /* 0x10 */
65     "WM_QUERYENDSESSION",
66     "WM_QUIT",
67     "WM_QUERYOPEN",
68     "WM_ERASEBKGND",
69     "WM_SYSCOLORCHANGE",
70     "WM_ENDSESSION",
71     "wm_systemerror",
72     "WM_SHOWWINDOW",
73     "WM_CTLCOLOR",
74     "WM_WININICHANGE",
75     "WM_DEVMODECHANGE",
76     "WM_ACTIVATEAPP",
77     "WM_FONTCHANGE",
78     "WM_TIMECHANGE",
79     "WM_CANCELMODE",
80     "WM_SETCURSOR",             /* 0x20 */
81     "WM_MOUSEACTIVATE",
82     "WM_CHILDACTIVATE",
83     "WM_QUEUESYNC",
84     "WM_GETMINMAXINFO",
85     "wm_unused3",
86     "wm_painticon",
87     "WM_ICONERASEBKGND",
88     "WM_NEXTDLGCTL",
89     "wm_alttabactive",
90     "WM_SPOOLERSTATUS",
91     "WM_DRAWITEM",
92     "WM_MEASUREITEM",
93     "WM_DELETEITEM",
94     "WM_VKEYTOITEM",
95     "WM_CHARTOITEM",
96     "WM_SETFONT",               /* 0x30 */
97     "WM_GETFONT",
98     "WM_SETHOTKEY",
99     "WM_GETHOTKEY",
100     "wm_filesyschange",
101     "wm_isactiveicon",
102     "wm_queryparkicon",
103     "WM_QUERYDRAGICON",
104     "wm_querysavestate",
105     "WM_COMPAREITEM",
106     "wm_testing",
107     NULL,
108     "wm_otherwindowcreated",
109     "wm_otherwindowdestroyed",
110     "wm_activateshellwindow",
111     NULL,
112
113     NULL,                       /* 0x40 */
114     "wm_compacting", NULL, NULL,
115     "WM_COMMNOTIFY", NULL,
116     "WM_WINDOWPOSCHANGING",     /* 0x0046 */
117     "WM_WINDOWPOSCHANGED",      /* 0x0047 */
118     "WM_POWER", NULL,
119     "WM_COPYDATA",
120     "WM_CANCELJOURNAL", NULL, NULL,
121     "WM_NOTIFY", NULL,
122
123     /* 0x0050 */
124     "WM_INPUTLANGCHANGEREQUEST",
125     "WM_INPUTLANGCHANGE",
126     "WM_TCARD",
127     "WM_HELP",
128     "WM_USERCHANGED",
129     "WM_NOTIFYFORMAT", NULL, NULL,
130     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
131
132     /* 0x0060 */
133     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
134     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
135
136     /* 0x0070 */
137     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
138     NULL, NULL, NULL,
139     "WM_CONTEXTMENU",
140     "WM_STYLECHANGING",
141     "WM_STYLECHANGED",
142     "WM_DISPLAYCHANGE",
143     "WM_GETICON",
144
145     "WM_SETICON",               /* 0x0080 */
146     "WM_NCCREATE",              /* 0x0081 */
147     "WM_NCDESTROY",             /* 0x0082 */
148     "WM_NCCALCSIZE",            /* 0x0083 */
149     "WM_NCHITTEST",             /* 0x0084 */
150     "WM_NCPAINT",               /* 0x0085 */
151     "WM_NCACTIVATE",            /* 0x0086 */
152     "WM_GETDLGCODE",            /* 0x0087 */
153     "WM_SYNCPAINT",
154     "WM_SYNCTASK", NULL, NULL, NULL, NULL, NULL, NULL,
155
156     /* 0x0090 */
157     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
158     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
159
160     /* 0x00A0 */
161     "WM_NCMOUSEMOVE",           /* 0x00A0 */
162     "WM_NCLBUTTONDOWN",         /* 0x00A1 */
163     "WM_NCLBUTTONUP",           /* 0x00A2 */
164     "WM_NCLBUTTONDBLCLK",       /* 0x00A3 */
165     "WM_NCRBUTTONDOWN",         /* 0x00A4 */
166     "WM_NCRBUTTONUP",           /* 0x00A5 */
167     "WM_NCRBUTTONDBLCLK",       /* 0x00A6 */
168     "WM_NCMBUTTONDOWN",         /* 0x00A7 */
169     "WM_NCMBUTTONUP",           /* 0x00A8 */
170     "WM_NCMBUTTONDBLCLK",       /* 0x00A9 */
171     NULL, NULL, NULL, NULL, NULL, NULL,
172
173     /* 0x00B0 - Win32 Edit controls */
174     "EM_GETSEL",                /* 0x00b0 */
175     "EM_SETSEL",                /* 0x00b1 */
176     "EM_GETRECT",               /* 0x00b2 */
177     "EM_SETRECT",               /* 0x00b3 */
178     "EM_SETRECTNP",             /* 0x00b4 */
179     "EM_SCROLL",                /* 0x00b5 */
180     "EM_LINESCROLL",            /* 0x00b6 */
181     "EM_SCROLLCARET",           /* 0x00b7 */
182     "EM_GETMODIFY",             /* 0x00b8 */
183     "EM_SETMODIFY",             /* 0x00b9 */
184     "EM_GETLINECOUNT",          /* 0x00ba */
185     "EM_LINEINDEX",             /* 0x00bb */
186     "EM_SETHANDLE",             /* 0x00bc */
187     "EM_GETHANDLE",             /* 0x00bd */
188     "EM_GETTHUMB",              /* 0x00be */
189     NULL,                       /* 0x00bf */
190
191     NULL,                       /* 0x00c0 */
192     "EM_LINELENGTH",            /* 0x00c1 */
193     "EM_REPLACESEL",            /* 0x00c2 */
194     NULL,                       /* 0x00c3 */
195     "EM_GETLINE",               /* 0x00c4 */
196     "EM_LIMITTEXT",             /* 0x00c5 */
197     "EM_CANUNDO",               /* 0x00c6 */
198     "EM_UNDO",                  /* 0x00c7 */
199     "EM_FMTLINES",              /* 0x00c8 */
200     "EM_LINEFROMCHAR",          /* 0x00c9 */
201     NULL,                       /* 0x00ca */
202     "EM_SETTABSTOPS",           /* 0x00cb */
203     "EM_SETPASSWORDCHAR",       /* 0x00cc */
204     "EM_EMPTYUNDOBUFFER",       /* 0x00cd */
205     "EM_GETFIRSTVISIBLELINE",   /* 0x00ce */
206     "EM_SETREADONLY",           /* 0x00cf */
207
208     "EM_SETWORDBREAKPROC",      /* 0x00d0 */
209     "EM_GETWORDBREAKPROC",      /* 0x00d1 */
210     "EM_GETPASSWORDCHAR",       /* 0x00d2 */
211     "EM_SETMARGINS",            /* 0x00d3 */
212     "EM_GETMARGINS",            /* 0x00d4 */
213     "EM_GETLIMITTEXT",          /* 0x00d5 */
214     "EM_POSFROMCHAR",           /* 0x00d6 */
215     "EM_CHARFROMPOS",           /* 0x00d7 */
216     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
217
218     /* 0x00E0 - Win32 Scrollbars */
219     "SBM_SETPOS",               /* 0x00e0 */
220     "SBM_GETPOS",               /* 0x00e1 */
221     "SBM_SETRANGE",             /* 0x00e2 */
222     "SBM_GETRANGE",             /* 0x00e3 */
223     "SBM_ENABLE_ARROWS",        /* 0x00e4 */
224     NULL,
225     "SBM_SETRANGEREDRAW",       /* 0x00e6 */
226     NULL, NULL,
227     "SBM_SETSCROLLINFO",        /* 0x00e9 */
228     "SBM_GETSCROLLINFO",        /* 0x00ea */
229     NULL, NULL, NULL, NULL, NULL,
230
231     /* 0x00F0 - Win32 Buttons */
232     "BM_GETCHECK",              /* 0x00f0 */
233     "BM_SETCHECK",              /* 0x00f1 */
234     "BM_GETSTATE",              /* 0x00f2 */
235     "BM_SETSTATE",              /* 0x00f3 */
236     "BM_SETSTYLE",              /* 0x00f4 */
237     "BM_CLICK",                 /* 0x00f5 */
238     "BM_GETIMAGE",              /* 0x00f6 */
239     "BM_SETIMAGE",              /* 0x00f7 */
240     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
241
242     "WM_KEYDOWN",               /* 0x0100 */
243     "WM_KEYUP",                 /* 0x0101 */
244     "WM_CHAR",                  /* 0x0102 */
245     "WM_DEADCHAR",              /* 0x0103 */
246     "WM_SYSKEYDOWN",            /* 0x0104 */
247     "WM_SYSKEYUP",              /* 0x0105 */
248     "WM_SYSCHAR",               /* 0x0106 */
249     "WM_SYSDEADCHAR",           /* 0x0107 */
250     "WM_KEYLAST",               /* 0x0108 */
251     NULL,
252     "WM_CONVERTREQUEST",
253     "WM_CONVERTRESULT",
254     "WM_INTERIM",
255     "WM_IME_STARTCOMPOSITION",  /* 0x010d */
256     "WM_IME_ENDCOMPOSITION",    /* 0x010e */
257     "WM_IME_COMPOSITION",       /* 0x010f */
258
259     "WM_INITDIALOG",            /* 0x0110 */
260     "WM_COMMAND",               /* 0x0111 */
261     "WM_SYSCOMMAND",            /* 0x0112 */
262     "WM_TIMER",                 /* 0x0113 */
263     "WM_HSCROLL",               /* 0x0114 */
264     "WM_VSCROLL",               /* 0x0115 */
265     "WM_INITMENU",              /* 0x0116 */
266     "WM_INITMENUPOPUP",         /* 0x0117 */
267     "WM_SYSTIMER",              /* 0x0118 */
268     NULL, NULL, NULL, NULL, NULL, NULL,
269     "WM_MENUSELECT",            /* 0x011f */
270
271     "WM_MENUCHAR",              /* 0x0120 */
272     "WM_ENTERIDLE",             /* 0x0121 */
273
274     "WM_MENURBUTTONUP",         /* 0x0122 */
275     "WM_MENUDRAG",              /* 0x0123 */
276     "WM_MENUGETOBJECT",         /* 0x0124 */
277     "WM_UNINITMENUPOPUP",       /* 0x0125 */
278     "WM_MENUCOMMAND",           /* 0x0126 */
279     "WM_CHANGEUISTATE",         /* 0x0127 */
280     "WM_UPDATEUISTATE",         /* 0x0128 */
281     "WM_QUERYUISTATE",          /* 0x0129 */
282
283     NULL, NULL, NULL, NULL, NULL, NULL,
284
285     /* 0x0130 */
286     NULL,
287     "WM_LBTRACKPOINT",          /* 0x0131 */
288     "WM_CTLCOLORMSGBOX",        /* 0x0132 */
289     "WM_CTLCOLOREDIT",          /* 0x0133 */
290     "WM_CTLCOLORLISTBOX",       /* 0x0134 */
291     "WM_CTLCOLORBTN",           /* 0x0135 */
292     "WM_CTLCOLORDLG",           /* 0x0136 */
293     "WM_CTLCOLORSCROLLBAR",     /* 0x0137 */
294     "WM_CTLCOLORSTATIC",        /* 0x0138 */
295     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
296
297     /* 0x0140 - Win32 Comboboxes */
298     "CB_GETEDITSEL",            /* 0x0140 */
299     "CB_LIMITTEXT",             /* 0x0141 */
300     "CB_SETEDITSEL",            /* 0x0142 */
301     "CB_ADDSTRING",             /* 0x0143 */
302     "CB_DELETESTRING",          /* 0x0144 */
303     "CB_DIR",                   /* 0x0145 */
304     "CB_GETCOUNT",              /* 0x0146 */
305     "CB_GETCURSEL",             /* 0x0147 */
306     "CB_GETLBTEXT",             /* 0x0148 */
307     "CB_GETLBTEXTLEN",          /* 0x0149 */
308     "CB_INSERTSTRING",          /* 0x014a */
309     "CB_RESETCONTENT",          /* 0x014b */
310     "CB_FINDSTRING",            /* 0x014c */
311     "CB_SELECTSTRING",          /* 0x014d */
312     "CB_SETCURSEL",             /* 0x014e */
313     "CB_SHOWDROPDOWN",          /* 0x014f */
314
315     "CB_GETITEMDATA",           /* 0x0150 */
316     "CB_SETITEMDATA",           /* 0x0151 */
317     "CB_GETDROPPEDCONTROLRECT", /* 0x0152 */
318     "CB_SETITEMHEIGHT",         /* 0x0153 */
319     "CB_GETITEMHEIGHT",         /* 0x0154 */
320     "CB_SETEXTENDEDUI",         /* 0x0155 */
321     "CB_GETEXTENDEDUI",         /* 0x0156 */
322     "CB_GETDROPPEDSTATE",       /* 0x0157 */
323     "CB_FINDSTRINGEXACT",       /* 0x0158 */
324     "CB_SETLOCALE",             /* 0x0159 */
325     "CB_GETLOCALE",             /* 0x015a */
326     "CB_GETTOPINDEX",           /* 0x015b */
327     "CB_SETTOPINDEX",           /* 0x015c */
328     "CB_GETHORIZONTALEXTENT",   /* 0x015d */
329     "CB_SETHORIZONTALEXTENT",   /* 0x015e */
330     "CB_GETDROPPEDWIDTH",       /* 0x015f */
331
332     "CB_SETDROPPEDWIDTH",       /* 0x0160 */
333     "CB_INITSTORAGE",           /* 0x0161 */
334     NULL, NULL, NULL, NULL, NULL, NULL,
335     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
336
337     /* 0x0170 - Win32 Static controls */
338     "STM_SETICON",              /* 0x0170 */
339     "STM_GETICON",              /* 0x0171 */
340     "STM_SETIMAGE",             /* 0x0172 */
341     "STM_GETIMAGE",             /* 0x0173 */
342     NULL, NULL, NULL, NULL,
343     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
344
345     /* 0x0180 - Win32 Listboxes */
346     "LB_ADDSTRING",             /* 0x0180 */
347     "LB_INSERTSTRING",          /* 0x0181 */
348     "LB_DELETESTRING",          /* 0x0182 */
349     "LB_SELITEMRANGEEX",        /* 0x0183 */
350     "LB_RESETCONTENT",          /* 0x0184 */
351     "LB_SETSEL",                /* 0x0185 */
352     "LB_SETCURSEL",             /* 0x0186 */
353     "LB_GETSEL",                /* 0x0187 */
354     "LB_GETCURSEL",             /* 0x0188 */
355     "LB_GETTEXT",               /* 0x0189 */
356     "LB_GETTEXTLEN",            /* 0x018a */
357     "LB_GETCOUNT",              /* 0x018b */
358     "LB_SELECTSTRING",          /* 0x018c */
359     "LB_DIR",                   /* 0x018d */
360     "LB_GETTOPINDEX",           /* 0x018e */
361     "LB_FINDSTRING",            /* 0x018f */
362
363     "LB_GETSELCOUNT",           /* 0x0190 */
364     "LB_GETSELITEMS",           /* 0x0191 */
365     "LB_SETTABSTOPS",           /* 0x0192 */
366     "LB_GETHORIZONTALEXTENT",   /* 0x0193 */
367     "LB_SETHORIZONTALEXTENT",   /* 0x0194 */
368     "LB_SETCOLUMNWIDTH",        /* 0x0195 */
369     "LB_ADDFILE",               /* 0x0196 */
370     "LB_SETTOPINDEX",           /* 0x0197 */
371     "LB_GETITEMRECT",           /* 0x0198 */
372     "LB_GETITEMDATA",           /* 0x0199 */
373     "LB_SETITEMDATA",           /* 0x019a */
374     "LB_SELITEMRANGE",          /* 0x019b */
375     "LB_SETANCHORINDEX",        /* 0x019c */
376     "LB_GETANCHORINDEX",        /* 0x019d */
377     "LB_SETCARETINDEX",         /* 0x019e */
378     "LB_GETCARETINDEX",         /* 0x019f */
379
380     "LB_SETITEMHEIGHT",         /* 0x01a0 */
381     "LB_GETITEMHEIGHT",         /* 0x01a1 */
382     "LB_FINDSTRINGEXACT",       /* 0x01a2 */
383     "LB_CARETON",               /* 0x01a3 */
384     "LB_CARETOFF",              /* 0x01a4 */
385     "LB_SETLOCALE",             /* 0x01a5 */
386     "LB_GETLOCALE",             /* 0x01a6 */
387     "LB_SETCOUNT",              /* 0x01a7 */
388     "LB_INITSTORAGE",           /* 0x01a8 */
389     "LB_ITEMFROMPOINT",         /* 0x01a9 */
390     NULL, NULL, NULL, NULL, NULL, NULL,
391
392     /* 0x01B0 */
393     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
394     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
395
396     /* 0x01C0 */
397     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
398     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
399
400     /* 0x01D0 */
401     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
402     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
403
404     /* 0x01E0 */
405     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
406     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
407
408     /* 0x01F0 */
409     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
410     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
411
412     "WM_MOUSEMOVE",             /* 0x0200 */
413     "WM_LBUTTONDOWN",           /* 0x0201 */
414     "WM_LBUTTONUP",             /* 0x0202 */
415     "WM_LBUTTONDBLCLK",         /* 0x0203 */
416     "WM_RBUTTONDOWN",           /* 0x0204 */
417     "WM_RBUTTONUP",             /* 0x0205 */
418     "WM_RBUTTONDBLCLK",         /* 0x0206 */
419     "WM_MBUTTONDOWN",           /* 0x0207 */
420     "WM_MBUTTONUP",             /* 0x0208 */
421     "WM_MBUTTONDBLCLK",         /* 0x0209 */
422     "WM_MOUSEWHEEL",            /* 0x020A */
423     NULL, NULL, NULL, NULL, NULL,
424
425     "WM_PARENTNOTIFY",          /* 0x0210 */
426     "WM_ENTERMENULOOP",         /* 0x0211 */
427     "WM_EXITMENULOOP",          /* 0x0212 */
428     "WM_NEXTMENU",              /* 0x0213 */
429     "WM_SIZING",
430     "WM_CAPTURECHANGED",
431     "WM_MOVING", NULL,
432     "WM_POWERBROADCAST",
433     "WM_DEVICECHANGE", NULL, NULL, NULL, NULL, NULL, NULL,
434
435     "WM_MDICREATE",             /* 0x0220 */
436     "WM_MDIDESTROY",            /* 0x0221 */
437     "WM_MDIACTIVATE",           /* 0x0222 */
438     "WM_MDIRESTORE",            /* 0x0223 */
439     "WM_MDINEXT",               /* 0x0224 */
440     "WM_MDIMAXIMIZE",           /* 0x0225 */
441     "WM_MDITILE",               /* 0x0226 */
442     "WM_MDICASCADE",            /* 0x0227 */
443     "WM_MDIICONARRANGE",        /* 0x0228 */
444     "WM_MDIGETACTIVE",          /* 0x0229 */
445
446     "WM_DROPOBJECT",
447     "WM_QUERYDROPOBJECT",
448     "WM_BEGINDRAG",
449     "WM_DRAGLOOP",
450     "WM_DRAGSELECT",
451     "WM_DRAGMOVE",
452
453     /* 0x0230*/
454     "WM_MDISETMENU",            /* 0x0230 */
455     "WM_ENTERSIZEMOVE",         /* 0x0231 */
456     "WM_EXITSIZEMOVE",          /* 0x0232 */
457     "WM_DROPFILES",             /* 0x0233 */
458     "WM_MDIREFRESHMENU", NULL, NULL, NULL,
459     /* 0x0238*/
460     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
461
462     /* 0x0240 */
463     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
464     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
465
466     /* 0x0250 */
467     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
468     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
469
470     /* 0x0260 */
471     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
472     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
473     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
474     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
475
476     /* 0x0280 */
477     NULL, "WM_IME_SETCONTEXT", "WM_IME_NOTIFY", "WM_IME_CONTROL", "WM_IME_COMPOSITIONFULL", "WM_IME_SELECT", "WM_IME_CHAR", NULL,
478     "WM_IME_REQUEST", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
479     "WM_IME_KEYDOWN", "WM_IME_KEYUP", NULL, NULL, NULL, NULL, NULL, NULL,
480     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
481
482     /* 0x02a0 */
483     NULL, "WM_MOUSEHOVER", NULL, "WM_MOUSELEAVE", NULL, NULL, NULL, NULL,
484     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
485     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
486     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
487
488     /* 0x02c0 */
489     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
490     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
491     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
492     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
493
494     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
495     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
496     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
497     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
498
499     "WM_CUT",                   /* 0x0300 */
500     "WM_COPY",
501     "WM_PASTE",
502     "WM_CLEAR",
503     "WM_UNDO",
504     "WM_RENDERFORMAT",
505     "WM_RENDERALLFORMATS",
506     "WM_DESTROYCLIPBOARD",
507     "WM_DRAWCLIPBOARD",
508     "WM_PAINTCLIPBOARD",
509     "WM_VSCROLLCLIPBOARD",
510     "WM_SIZECLIPBOARD",
511     "WM_ASKCBFORMATNAME",
512     "WM_CHANGECBCHAIN",
513     "WM_HSCROLLCLIPBOARD",
514     "WM_QUERYNEWPALETTE",       /* 0x030f*/
515
516     "WM_PALETTEISCHANGING",
517     "WM_PALETTECHANGED",
518     "WM_HOTKEY",                /* 0x0312 */
519           NULL, NULL, NULL, NULL,
520     "WM_PRINT",
521     "WM_PRINTCLIENT",
522     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
523
524     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
525     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
526     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
527     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
528
529     /* 0x0340 */
530     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
531     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
532     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
533     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
534
535     "WM_QUERYAFXWNDPROC",   /*  0x0360 */
536     "WM_SIZEPARENT",        /*  0x0361 */
537     "WM_SETMESSAGESTRING",  /*  0x0362 */
538     "WM_IDLEUPDATECMDUI",   /*  0x0363 */
539     "WM_INITIALUPDATE",     /*  0x0364 */
540     "WM_COMMANDHELP",       /*  0x0365 */
541     "WM_HELPHITTEST",       /*  0x0366 */
542     "WM_EXITHELPMODE",      /*  0x0367 */
543     "WM_RECALCPARENT",      /*  0x0368 */
544     "WM_SIZECHILD",         /*  0x0369 */
545     "WM_KICKIDLE",          /*  0x036A */
546     "WM_QUERYCENTERWND",    /*  0x036B */
547     "WM_DISABLEMODAL",      /*  0x036C */
548     "WM_FLOATSTATUS",       /*  0x036D */
549     "WM_ACTIVATETOPLEVEL",  /*  0x036E */
550     "WM_QUERY3DCONTROLS",   /*  0x036F */
551     NULL,NULL,NULL,
552     "WM_SOCKET_NOTIFY",     /*  0x0373 */
553     "WM_SOCKET_DEAD",       /*  0x0374 */
554     "WM_POPMESSAGESTRING",  /*  0x0375 */
555     "WM_OCC_LOADFROMSTREAM",     /* 0x0376 */
556     "WM_OCC_LOADFROMSTORAGE",    /* 0x0377 */
557     "WM_OCC_INITNEW",            /* 0x0378 */
558     "WM_QUEUE_SENTINEL",         /* 0x0379 */
559     "WM_OCC_LOADFROMSTREAM_EX",  /* 0x037A */
560     "WM_OCC_LOADFROMSTORAGE_EX", /* 0x037B */
561
562     NULL,NULL,NULL,NULL,
563
564     "WM_PENWINFIRST",           /* 0x0380 */
565     "WM_RCRESULT",              /* 0x0381 */
566     "WM_HOOKRCRESULT",          /* 0x0382 */
567     "WM_GLOBALRCCHANGE",        /* 0x0383 */
568     "WM_SKB",                   /* 0x0384 */
569     "WM_HEDITCTL",              /* 0x0385 */
570     NULL, NULL,
571     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
572     "WM_PENWINLAST",            /* 0x038F */
573
574     "WM_COALESCE_FIRST",        /* 0x0390 */
575     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
576     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
577     "WM_COALESCE_LAST",         /* 0x039F */
578
579     /* 0x03a0 */
580     "MM_JOY1MOVE",
581     "MM_JOY2MOVE",
582     "MM_JOY1ZMOVE",
583     "MM_JOY2ZMOVE",
584                             NULL, NULL, NULL, NULL,
585     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
586
587     /* 0x03b0 */
588     NULL, NULL, NULL, NULL, NULL,
589     "MM_JOY1BUTTONDOWN",
590     "MM_JOY2BUTTONDOWN",
591     "MM_JOY1BUTTONUP",
592     "MM_JOY2BUTTONUP",
593     "MM_MCINOTIFY",
594                 NULL,
595     "MM_WOM_OPEN",
596     "MM_WOM_CLOSE",
597     "MM_WOM_DONE",
598     "MM_WIM_OPEN",
599     "MM_WIM_CLOSE",
600
601     /* 0x03c0 */
602     "MM_WIM_DATA",
603     "MM_MIM_OPEN",
604     "MM_MIM_CLOSE",
605     "MM_MIM_DATA",
606     "MM_MIM_LONGDATA",
607     "MM_MIM_ERROR",
608     "MM_MIM_LONGERROR",
609     "MM_MOM_OPEN",
610     "MM_MOM_CLOSE",
611     "MM_MOM_DONE",
612                 NULL, NULL, NULL, NULL, NULL, NULL,
613     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
614     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
615
616     /* 0x03e0 */
617     "WM_DDE_INITIATE",  /* 0x3E0 */
618     "WM_DDE_TERMINATE", /* 0x3E1 */
619     "WM_DDE_ADVISE",    /* 0x3E2 */
620     "WM_DDE_UNADVISE",  /* 0x3E3 */
621     "WM_DDE_ACK",       /* 0x3E4 */
622     "WM_DDE_DATA",      /* 0x3E5 */
623     "WM_DDE_REQUEST",   /* 0x3E6 */
624     "WM_DDE_POKE",      /* 0x3E7 */
625     "WM_DDE_EXECUTE",   /* 0x3E8 */
626     NULL, NULL, NULL, NULL, NULL, NULL, NULL,
627
628
629     /* 0x03f0 */
630     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
631     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
632
633     "WM_USER"                   /* 0x0400 */
634 };
635
636
637 #define SPY_MAX_LVMMSGNUM   140
638 static const char * const LVMMessageTypeNames[SPY_MAX_LVMMSGNUM + 1] =
639 {
640     "LVM_GETBKCOLOR",           /* 1000 */
641     "LVM_SETBKCOLOR",
642     "LVM_GETIMAGELIST",
643     "LVM_SETIMAGELIST",
644     "LVM_GETITEMCOUNT",
645     "LVM_GETITEMA",
646     "LVM_SETITEMA",
647     "LVM_INSERTITEMA",
648     "LVM_DELETEITEM",
649     "LVM_DELETEALLITEMS",
650     "LVM_GETCALLBACKMASK",
651     "LVM_SETCALLBACKMASK",
652     "LVM_GETNEXTITEM",
653     "LVM_FINDITEMA",
654     "LVM_GETITEMRECT",
655     "LVM_SETITEMPOSITION",
656     "LVM_GETITEMPOSITION",
657     "LVM_GETSTRINGWIDTHA",
658     "LVM_HITTEST",
659     "LVM_ENSUREVISIBLE",
660     "LVM_SCROLL",
661     "LVM_REDRAWITEMS",
662     "LVM_ARRANGE",
663     "LVM_EDITLABELA",
664     "LVM_GETEDITCONTROL",
665     "LVM_GETCOLUMNA",
666     "LVM_SETCOLUMNA",
667     "LVM_INSERTCOLUMNA",
668     "LVM_DELETECOLUMN",
669     "LVM_GETCOLUMNWIDTH",
670     "LVM_SETCOLUMNWIDTH",
671     "LVM_GETHEADER",
672     NULL,
673     "LVM_CREATEDRAGIMAGE",
674     "LVM_GETVIEWRECT",
675     "LVM_GETTEXTCOLOR",
676     "LVM_SETTEXTCOLOR",
677     "LVM_GETTEXTBKCOLOR",
678     "LVM_SETTEXTBKCOLOR",
679     "LVM_GETTOPINDEX",
680     "LVM_GETCOUNTPERPAGE",
681     "LVM_GETORIGIN",
682     "LVM_UPDATE",
683     "LVM_SETITEMSTATE",
684     "LVM_GETITEMSTATE",
685     "LVM_GETITEMTEXTA",
686     "LVM_SETITEMTEXTA",
687     "LVM_SETITEMCOUNT",
688     "LVM_SORTITEMS",
689     "LVM_SETITEMPOSITION32",
690     "LVM_GETSELECTEDCOUNT",
691     "LVM_GETITEMSPACING",
692     "LVM_GETISEARCHSTRINGA",
693     "LVM_SETICONSPACING",
694     "LVM_SETEXTENDEDLISTVIEWSTYLE",
695     "LVM_GETEXTENDEDLISTVIEWSTYLE",
696     "LVM_GETSUBITEMRECT",
697     "LVM_SUBITEMHITTEST",
698     "LVM_SETCOLUMNORDERARRAY",
699     "LVM_GETCOLUMNORDERARRAY",
700     "LVM_SETHOTITEM",
701     "LVM_GETHOTITEM",
702     "LVM_SETHOTCURSOR",
703     "LVM_GETHOTCURSOR",
704     "LVM_APPROXIMATEVIEWRECT",
705     "LVM_SETWORKAREAS",
706     "LVM_GETSELECTIONMARK",
707     "LVM_SETSELECTIONMARK",
708     "LVM_SETBKIMAGEA",
709     "LVM_GETBKIMAGEA",
710     "LVM_GETWORKAREAS",
711     "LVM_SETHOVERTIME",
712     "LVM_GETHOVERTIME",
713     "LVM_GETNUMBEROFWORKAREAS",
714     "LVM_SETTOOLTIPS",
715     "LVM_GETITEMW",
716     "LVM_SETITEMW",
717     "LVM_INSERTITEMW",
718     "LVM_GETTOOLTIPS",
719     NULL,
720     NULL,
721     NULL,
722     NULL,
723     "LVM_FINDITEMW",
724     NULL,
725     NULL,
726     NULL,
727     "LVM_GETSTRINGWIDTHW",
728     NULL,
729     NULL,
730     NULL,
731     NULL,
732     NULL,
733     NULL,
734     NULL,
735     "LVM_GETCOLUMNW",
736     "LVM_SETCOLUMNW",
737     "LVM_INSERTCOLUMNW",
738     NULL,
739     NULL,
740     NULL,
741     NULL,
742     NULL,
743     NULL,
744     NULL,
745     NULL,
746     NULL,
747     NULL,
748     NULL,
749     NULL,
750     NULL,
751     NULL,
752     NULL,
753     NULL,
754     NULL,
755     "LVM_GETITEMTEXTW",
756     "LVM_SETITEMTEXTW",
757     "LVM_GETISEARCHSTRINGW",
758     "LVM_EDITLABELW",
759     NULL,
760     NULL,
761     NULL,
762     NULL,
763     NULL,
764     NULL,
765     NULL,
766     NULL,
767     NULL,
768     NULL,
769     NULL,
770     NULL,
771     NULL,
772     NULL,
773     NULL,
774     NULL,
775     NULL,
776     NULL,
777     NULL,
778     NULL,
779     "LVM_SETBKIMAGEW",
780     "LVM_GETBKIMAGEW"   /* 0x108B */
781 };
782
783
784 #define SPY_MAX_TVMSGNUM   65
785 static const char * const TVMessageTypeNames[SPY_MAX_TVMSGNUM + 1] =
786 {
787     "TVM_INSERTITEMA",          /* 1100 */
788     "TVM_DELETEITEM",
789     "TVM_EXPAND",
790     NULL,
791     "TVM_GETITEMRECT",
792     "TVM_GETCOUNT",
793     "TVM_GETINDENT",
794     "TVM_SETINDENT",
795     "TVM_GETIMAGELIST",
796     "TVM_SETIMAGELIST",
797     "TVM_GETNEXTITEM",
798     "TVM_SELECTITEM",
799     "TVM_GETITEMA",
800     "TVM_SETITEMA",
801     "TVM_EDITLABELA",
802     "TVM_GETEDITCONTROL",
803     "TVM_GETVISIBLECOUNT",
804     "TVM_HITTEST",
805     "TVM_CREATEDRAGIMAGE",
806     "TVM_SORTCHILDREN",
807     "TVM_ENSUREVISIBLE",
808     "TVM_SORTCHILDRENCB",
809     "TVM_ENDEDITLABELNOW",
810     "TVM_GETISEARCHSTRINGA",
811     "TVM_SETTOOLTIPS",
812     "TVM_GETTOOLTIPS",
813     "TVM_SETINSERTMARK",
814     "TVM_SETITEMHEIGHT",
815     "TVM_GETITEMHEIGHT",
816     "TVM_SETBKCOLOR",
817     "TVM_SETTEXTCOLOR",
818     "TVM_GETBKCOLOR",
819     "TVM_GETTEXTCOLOR",
820     "TVM_SETSCROLLTIME",
821     "TVM_GETSCROLLTIME",
822     "TVM_UNKNOWN35",
823     "TVM_UNKNOWN36",
824     "TVM_SETINSERTMARKCOLOR",
825     "TVM_GETINSERTMARKCOLOR",
826     "TVM_GETITEMSTATE",
827     "TVM_SETLINECOLOR",
828     "TVM_GETLINECOLOR",
829     NULL,
830     NULL,
831     NULL,
832     NULL,
833     NULL,
834     NULL,
835     NULL,
836     NULL,
837     "TVM_INSERTITEMW",
838     NULL,
839     NULL,
840     NULL,
841     NULL,
842     NULL,
843     NULL,
844     NULL,
845     NULL,
846     NULL,
847     NULL,
848     NULL,
849     "TVM_GETITEMW",
850     "TVM_SETITEMW",
851     "TVM_GETISEARCHSTRINGW",
852     "TVM_EDITLABELW"
853 };
854
855
856 #define SPY_MAX_HDMMSGNUM   19
857 static const char * const HDMMessageTypeNames[SPY_MAX_HDMMSGNUM + 1] =
858 {
859     "HDM_GETITEMCOUNT",         /* 1200 */
860     "HDM_INSERTITEMA",
861     "HDM_DELETEITEM",
862     "HDM_GETITEMA",
863     "HDM_SETITEMA",
864     "HDM_LAYOUT",
865     "HDM_HITTEST",
866     "HDM_GETITEMRECT",
867     "HDM_SETIMAGELIST",
868     "HDM_GETIMAGELIST",
869     "HDM_INSERTITEMW",
870     "HDM_GETITEMW",
871     "HDM_SETITEMW",
872     NULL,
873     NULL,
874     "HDM_ORDERTOINDEX",
875     "HDM_CREATEDRAGIMAGE",
876     "GETORDERARRAYINDEX",
877     "SETORDERARRAYINDEX",
878     "SETHOTDIVIDER"
879 };
880
881
882 #define SPY_MAX_TCMMSGNUM   62
883 static const char * const TCMMessageTypeNames[SPY_MAX_TCMMSGNUM + 1] =
884 {
885     NULL,               /* 1300 */
886     NULL,
887     "TCM_SETIMAGELIST",
888     "TCM_GETIMAGELIST",
889     "TCM_GETITEMCOUNT",
890     "TCM_GETITEMA",
891     "TCM_SETITEMA",
892     "TCM_INSERTITEMA",
893     "TCM_DELETEITEM",
894     "TCM_DELETEALLITEMS",
895     "TCM_GETITEMRECT",
896     "TCM_GETCURSEL",
897     "TCM_SETCURSEL",
898     "TCM_HITTEST",
899     "TCM_SETITEMEXTRA",
900     NULL,
901     NULL,
902     NULL,
903     NULL,
904     NULL,
905     NULL,
906     NULL,
907     NULL,
908     NULL,
909     NULL,
910     NULL,
911     NULL,
912     NULL,
913     NULL,
914     NULL,
915     NULL,
916     NULL,
917     NULL,
918     NULL,
919     NULL,
920     NULL,
921     NULL,
922     NULL,
923     NULL,
924     NULL,
925     "TCM_ADJUSTRECT",
926     "TCM_SETITEMSIZE",
927     "TCM_REMOVEIMAGE",
928     "TCM_SETPADDING",
929     "TCM_GETROWCOUNT",
930     "TCM_GETTOOLTIPS",
931     "TCM_SETTOOLTIPS",
932     "TCM_GETCURFOCUS",
933     "TCM_SETCURFOCUS",
934     "TCM_SETMINTABWIDTH",
935     "TCM_DESELECTALL",
936     "TCM_HIGHLIGHTITEM",
937     "TCM_SETEXTENDEDSTYLE",
938     "TCM_GETEXTENDEDSTYLE",
939     NULL,
940     NULL,
941     NULL,
942     NULL,
943     NULL,
944     NULL,
945     "TCM_GETITEMW",
946     "TCM_SETITEMW",
947     "TCM_INSERTITEMW"
948 };
949
950 #define SPY_MAX_PGMMSGNUM   13
951 static const char * const PGMMessageTypeNames[SPY_MAX_PGMMSGNUM + 1] =
952 {
953     NULL,               /* 1400 */
954     "PGM_SETCHILD",
955     "PGM_RECALCSIZE",
956     "PGM_FORWARDMOUSE",
957     "PGM_SETBKCOLOR",
958     "PGM_GETBKCOLOR",
959     "PGM_SETBORDER",
960     "PGM_GETBORDER",
961     "PGM_SETPOS",
962     "PGM_GETPOS",
963     "PGM_SETBUTTONSIZE",
964     "PGM_GETBUTTONSIZE",
965     "PGM_GETBUTTONSTATE",
966     "PGM_GETDROPTARGET"
967 };
968
969
970 #define SPY_MAX_CCMMSGNUM   9
971 static const char * const CCMMessageTypeNames[SPY_MAX_CCMMSGNUM + 1] =
972 {
973     NULL,               /* 0x2000 */
974     "CCM_SETBKCOLOR",
975     "CCM_SETCOLORSCHEME",
976     "CCM_GETCOLORSCHEME",
977     "CCM_GETDROPTARGET",
978     "CCM_SETUNICODEFORMAT",
979     "CCM_GETUNICODEFORMAT",
980     "CCM_SETVERSION",
981     "CCM_GETVERSION",
982     "CCM_SETNOTIFYWINDOW"
983 };
984
985 #define SPY_MAX_WINEMSGNUM   6
986 static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
987 {
988     "WM_WINE_DESTROYWINDOW",
989     "WM_WINE_SETWINDOWPOS",
990     "WM_WINE_SHOWWINDOW",
991     "WM_WINE_SETPARENT",
992     "WM_WINE_SETWINDOWLONG",
993     "WM_WINE_ENABLEWINDOW"
994 };
995
996 /* Virtual key names */
997 #define SPY_MAX_VKKEYSNUM 255
998 static const char * const VK_KeyNames[SPY_MAX_VKKEYSNUM + 1] =
999 {
1000     NULL,               /* 0x00 */
1001     "VK_LBUTTON",       /* 0x01 */
1002     "VK_RBUTTON",       /* 0x02 */
1003     "VK_CANCEL",        /* 0x03 */
1004     "VK_MBUTTON",       /* 0x04 */
1005     NULL,               /* 0x05 */
1006     NULL,               /* 0x06 */
1007     NULL,               /* 0x07 */
1008     "VK_BACK",          /* 0x08 */
1009     "VK_TAB",           /* 0x09 */
1010     NULL,               /* 0x0A */
1011     NULL,               /* 0x0B */
1012     "VK_CLEAR",         /* 0x0C */
1013     "VK_RETURN",        /* 0x0D */
1014     NULL,               /* 0x0E */
1015     NULL,               /* 0x0F */
1016     "VK_SHIFT",         /* 0x10 */
1017     "VK_CONTROL",       /* 0x11 */
1018     "VK_MENU",          /* 0x12 */
1019     "VK_PAUSE",         /* 0x13 */
1020     "VK_CAPITAL",       /* 0x14 */
1021     NULL,               /* 0x15 */
1022     NULL,               /* 0x16 */
1023     NULL,               /* 0x17 */
1024     NULL,               /* 0x18 */
1025     NULL,               /* 0x19 */
1026     NULL,               /* 0x1A */
1027     "VK_ESCAPE",        /* 0x1B */
1028     NULL,               /* 0x1C */
1029     NULL,               /* 0x1D */
1030     NULL,               /* 0x1E */
1031     NULL,               /* 0x1F */
1032     "VK_SPACE",         /* 0x20 */
1033     "VK_PRIOR",         /* 0x21 */
1034     "VK_NEXT",          /* 0x22 */
1035     "VK_END",           /* 0x23 */
1036     "VK_HOME",          /* 0x24 */
1037     "VK_LEFT",          /* 0x25 */
1038     "VK_UP",            /* 0x26 */
1039     "VK_RIGHT",         /* 0x27 */
1040     "VK_DOWN",          /* 0x28 */
1041     "VK_SELECT",        /* 0x29 */
1042     "VK_PRINT",         /* 0x2A */
1043     "VK_EXECUTE",       /* 0x2B */
1044     "VK_SNAPSHOT",      /* 0x2C */
1045     "VK_INSERT",        /* 0x2D */
1046     "VK_DELETE",        /* 0x2E */
1047     "VK_HELP",          /* 0x2F */
1048     "VK_0",             /* 0x30 */
1049     "VK_1",             /* 0x31 */
1050     "VK_2",             /* 0x32 */
1051     "VK_3",             /* 0x33 */
1052     "VK_4",             /* 0x34 */
1053     "VK_5",             /* 0x35 */
1054     "VK_6",             /* 0x36 */
1055     "VK_7",             /* 0x37 */
1056     "VK_8",             /* 0x38 */
1057     "VK_9",             /* 0x39 */
1058     NULL,               /* 0x3A */
1059     NULL,               /* 0x3B */
1060     NULL,               /* 0x3C */
1061     NULL,               /* 0x3D */
1062     NULL,               /* 0x3E */
1063     NULL,               /* 0x3F */
1064     NULL,               /* 0x40 */
1065     "VK_A",             /* 0x41 */
1066     "VK_B",             /* 0x42 */
1067     "VK_C",             /* 0x43 */
1068     "VK_D",             /* 0x44 */
1069     "VK_E",             /* 0x45 */
1070     "VK_F",             /* 0x46 */
1071     "VK_G",             /* 0x47 */
1072     "VK_H",             /* 0x48 */
1073     "VK_I",             /* 0x49 */
1074     "VK_J",             /* 0x4A */
1075     "VK_K",             /* 0x4B */
1076     "VK_L",             /* 0x4C */
1077     "VK_M",             /* 0x4D */
1078     "VK_N",             /* 0x4E */
1079     "VK_O",             /* 0x4F */
1080     "VK_P",             /* 0x50 */
1081     "VK_Q",             /* 0x51 */
1082     "VK_R",             /* 0x52 */
1083     "VK_S",             /* 0x53 */
1084     "VK_T",             /* 0x54 */
1085     "VK_U",             /* 0x55 */
1086     "VK_V",             /* 0x56 */
1087     "VK_W",             /* 0x57 */
1088     "VK_X",             /* 0x58 */
1089     "VK_Y",             /* 0x59 */
1090     "VK_Z",             /* 0x5A */
1091     "VK_LWIN",          /* 0x5B */
1092     "VK_RWIN",          /* 0x5C */
1093     "VK_APPS",          /* 0x5D */
1094     NULL,               /* 0x5E */
1095     NULL,               /* 0x5F */
1096     "VK_NUMPAD0",       /* 0x60 */
1097     "VK_NUMPAD1",       /* 0x61 */
1098     "VK_NUMPAD2",       /* 0x62 */
1099     "VK_NUMPAD3",       /* 0x63 */
1100     "VK_NUMPAD4",       /* 0x64 */
1101     "VK_NUMPAD5",       /* 0x65 */
1102     "VK_NUMPAD6",       /* 0x66 */
1103     "VK_NUMPAD7",       /* 0x67 */
1104     "VK_NUMPAD8",       /* 0x68 */
1105     "VK_NUMPAD9",       /* 0x69 */
1106     "VK_MULTIPLY",      /* 0x6A */
1107     "VK_ADD",           /* 0x6B */
1108     "VK_SEPARATOR",     /* 0x6C */
1109     "VK_SUBTRACT",      /* 0x6D */
1110     "VK_DECIMAL",       /* 0x6E */
1111     "VK_DIVIDE",        /* 0x6F */
1112     "VK_F1",            /* 0x70 */
1113     "VK_F2",            /* 0x71 */
1114     "VK_F3",            /* 0x72 */
1115     "VK_F4",            /* 0x73 */
1116     "VK_F5",            /* 0x74 */
1117     "VK_F6",            /* 0x75 */
1118     "VK_F7",            /* 0x76 */
1119     "VK_F8",            /* 0x77 */
1120     "VK_F9",            /* 0x78 */
1121     "VK_F10",           /* 0x79 */
1122     "VK_F11",           /* 0x7A */
1123     "VK_F12",           /* 0x7B */
1124     "VK_F13",           /* 0x7C */
1125     "VK_F14",           /* 0x7D */
1126     "VK_F15",           /* 0x7E */
1127     "VK_F16",           /* 0x7F */
1128     "VK_F17",           /* 0x80 */
1129     "VK_F18",           /* 0x81 */
1130     "VK_F19",           /* 0x82 */
1131     "VK_F20",           /* 0x83 */
1132     "VK_F21",           /* 0x84 */
1133     "VK_F22",           /* 0x85 */
1134     "VK_F23",           /* 0x86 */
1135     "VK_F24",           /* 0x87 */
1136     NULL,               /* 0x88 */
1137     NULL,               /* 0x89 */
1138     NULL,               /* 0x8A */
1139     NULL,               /* 0x8B */
1140     NULL,               /* 0x8C */
1141     NULL,               /* 0x8D */
1142     NULL,               /* 0x8E */
1143     NULL,               /* 0x8F */
1144     "VK_NUMLOCK",       /* 0x90 */
1145     "VK_SCROLL",        /* 0x91 */
1146     NULL,               /* 0x92 */
1147     NULL,               /* 0x93 */
1148     NULL,               /* 0x94 */
1149     NULL,               /* 0x95 */
1150     NULL,               /* 0x96 */
1151     NULL,               /* 0x97 */
1152     NULL,               /* 0x98 */
1153     NULL,               /* 0x99 */
1154     NULL,               /* 0x9A */
1155     NULL,               /* 0x9B */
1156     NULL,               /* 0x9C */
1157     NULL,               /* 0x9D */
1158     NULL,               /* 0x9E */
1159     NULL,               /* 0x9F */
1160     "VK_LSHIFT",        /* 0xA0 */
1161     "VK_RSHIFT",        /* 0xA1 */
1162     "VK_LCONTROL",      /* 0xA2 */
1163     "VK_RCONTROL",      /* 0xA3 */
1164     "VK_LMENU",         /* 0xA4 */
1165     "VK_RMENU",         /* 0xA5 */
1166     NULL,               /* 0xA6 */
1167     NULL,               /* 0xA7 */
1168     NULL,               /* 0xA8 */
1169     NULL,               /* 0xA9 */
1170     NULL,               /* 0xAA */
1171     NULL,               /* 0xAB */
1172     NULL,               /* 0xAC */
1173     NULL,               /* 0xAD */
1174     NULL,               /* 0xAE */
1175     NULL,               /* 0xAF */
1176     NULL,               /* 0xB0 */
1177     NULL,               /* 0xB1 */
1178     NULL,               /* 0xB2 */
1179     NULL,               /* 0xB3 */
1180     NULL,               /* 0xB4 */
1181     NULL,               /* 0xB5 */
1182     NULL,               /* 0xB6 */
1183     NULL,               /* 0xB7 */
1184     NULL,               /* 0xB8 */
1185     NULL,               /* 0xB9 */
1186     "VK_OEM_1",         /* 0xBA */
1187     "VK_OEM_PLUS",      /* 0xBB */
1188     "VK_OEM_COMMA",     /* 0xBC */
1189     "VK_OEM_MINUS",     /* 0xBD */
1190     "VK_OEM_PERIOD",    /* 0xBE */
1191     "VK_OEM_2",         /* 0xBF */
1192     "VK_OEM_3",         /* 0xC0 */
1193     NULL,               /* 0xC1 */
1194     NULL,               /* 0xC2 */
1195     NULL,               /* 0xC3 */
1196     NULL,               /* 0xC4 */
1197     NULL,               /* 0xC5 */
1198     NULL,               /* 0xC6 */
1199     NULL,               /* 0xC7 */
1200     NULL,               /* 0xC8 */
1201     NULL,               /* 0xC9 */
1202     NULL,               /* 0xCA */
1203     NULL,               /* 0xCB */
1204     NULL,               /* 0xCC */
1205     NULL,               /* 0xCD */
1206     NULL,               /* 0xCE */
1207     NULL,               /* 0xCF */
1208     NULL,               /* 0xD0 */
1209     NULL,               /* 0xD1 */
1210     NULL,               /* 0xD2 */
1211     NULL,               /* 0xD3 */
1212     NULL,               /* 0xD4 */
1213     NULL,               /* 0xD5 */
1214     NULL,               /* 0xD6 */
1215     NULL,               /* 0xD7 */
1216     NULL,               /* 0xD8 */
1217     NULL,               /* 0xD9 */
1218     NULL,               /* 0xDA */
1219     "VK_OEM_4",         /* 0xDB */
1220     "VK_OEM_5",         /* 0xDC */
1221     "VK_OEM_6",         /* 0xDD */
1222     "VK_OEM_7",         /* 0xDE */
1223     "VK_OEM_8",         /* 0xDF */
1224     NULL,               /* 0xE0 */
1225     "VK_OEM_AX",        /* 0xE1 */
1226     "VK_OEM_102",       /* 0xE2 */
1227     "VK_ICO_HELP",      /* 0xE3 */
1228     "VK_ICO_00",        /* 0xE4 */
1229     "VK_PROCESSKEY",    /* 0xE5 */
1230     NULL,               /* 0xE6 */
1231     NULL,               /* 0xE7 */
1232     NULL,               /* 0xE8 */
1233     NULL,               /* 0xE9 */
1234     NULL,               /* 0xEA */
1235     NULL,               /* 0xEB */
1236     NULL,               /* 0xEC */
1237     NULL,               /* 0xED */
1238     NULL,               /* 0xEE */
1239     NULL,               /* 0xEF */
1240     NULL,               /* 0xF0 */
1241     NULL,               /* 0xF1 */
1242     NULL,               /* 0xF2 */
1243     NULL,               /* 0xF3 */
1244     NULL,               /* 0xF4 */
1245     NULL,               /* 0xF5 */
1246     "VK_ATTN",          /* 0xF6 */
1247     "VK_CRSEL",         /* 0xF7 */
1248     "VK_EXSEL",         /* 0xF8 */
1249     "VK_EREOF",         /* 0xF9 */
1250     "VK_PLAY",          /* 0xFA */
1251     "VK_ZOOM",          /* 0xFB */
1252     "VK_NONAME",        /* 0xFC */
1253     "VK_PA1",           /* 0xFD */
1254     "VK_OEM_CLEAR",     /* 0xFE */
1255     NULL                /* 0xFF */
1256 };
1257
1258
1259 /************************************************************************/
1260
1261
1262 /* WM_USER+n message values for "common controls" */
1263
1264 typedef struct
1265 {
1266     const char *name;      /* name of control message           */
1267     UINT        value;     /* message number (0x0401-0x0fff     */
1268     UINT        len;       /* length of space at lParam to dump */
1269 } USER_MSG;
1270
1271
1272 typedef struct
1273 {
1274 const WCHAR      *classname;  /* class name to match                  */
1275 const USER_MSG   *classmsg;   /* pointer to first USER_MSG for class  */
1276       USER_MSG   *lastmsg;    /* pointer to last USER_MSG for class   */
1277 } CONTROL_CLASS;
1278
1279 #define USM(a,b) { #a ,a,b}
1280 #define SZOF(a)  sizeof(a)
1281
1282 /* To dump memory at the lParam for any of these messages,  */
1283 /* replace the "0" with a "SZOF(structure)", or with a      */
1284 /* number. (First method prefered.)                         */
1285
1286 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
1287
1288 static const USER_MSG rebar_array[] = {
1289           USM(RB_INSERTBANDA,          0),
1290           USM(RB_DELETEBAND,           0),
1291           USM(RB_GETBARINFO,           0),
1292           USM(RB_SETBARINFO,           0),
1293           USM(RB_GETBANDINFO_OLD,      0),
1294           USM(RB_SETBANDINFOA,         0),
1295           USM(RB_SETPARENT,            0),
1296           USM(RB_HITTEST,              0),
1297           USM(RB_GETRECT,              0),
1298           USM(RB_INSERTBANDW,          0),
1299           USM(RB_SETBANDINFOW,         0),
1300           USM(RB_GETBANDCOUNT,         0),
1301           USM(RB_GETROWCOUNT,          0),
1302           USM(RB_GETROWHEIGHT,         0),
1303           USM(RB_IDTOINDEX,            0),
1304           USM(RB_GETTOOLTIPS,          0),
1305           USM(RB_SETTOOLTIPS,          0),
1306           USM(RB_SETBKCOLOR,           0),
1307           USM(RB_GETBKCOLOR,           0),
1308           USM(RB_SETTEXTCOLOR,         0),
1309           USM(RB_GETTEXTCOLOR,         0),
1310           USM(RB_SIZETORECT,           0),
1311           USM(RB_BEGINDRAG,            0),
1312           USM(RB_ENDDRAG,              0),
1313           USM(RB_DRAGMOVE,             0),
1314           USM(RB_GETBARHEIGHT,         0),
1315           USM(RB_GETBANDINFOW,         0),
1316           USM(RB_GETBANDINFOA,         0),
1317           USM(RB_MINIMIZEBAND,         0),
1318           USM(RB_MAXIMIZEBAND,         0),
1319           USM(RB_GETBANDBORDERS,       0),
1320           USM(RB_SHOWBAND,             0),
1321           USM(RB_SETPALETTE,           0),
1322           USM(RB_GETPALETTE,           0),
1323           USM(RB_MOVEBAND,             0),
1324           {0,0,0} };
1325
1326 static const USER_MSG toolbar_array[] = {
1327           USM(TB_ENABLEBUTTON          ,0),
1328           USM(TB_CHECKBUTTON           ,0),
1329           USM(TB_PRESSBUTTON           ,0),
1330           USM(TB_HIDEBUTTON            ,0),
1331           USM(TB_INDETERMINATE         ,0),
1332           USM(TB_MARKBUTTON            ,0),
1333           USM(TB_ISBUTTONENABLED       ,0),
1334           USM(TB_ISBUTTONCHECKED       ,0),
1335           USM(TB_ISBUTTONPRESSED       ,0),
1336           USM(TB_ISBUTTONHIDDEN        ,0),
1337           USM(TB_ISBUTTONINDETERMINATE ,0),
1338           USM(TB_ISBUTTONHIGHLIGHTED   ,0),
1339           USM(TB_SETSTATE              ,0),
1340           USM(TB_GETSTATE              ,0),
1341           USM(TB_ADDBITMAP             ,0),
1342           USM(TB_ADDBUTTONSA           ,0),
1343           USM(TB_INSERTBUTTONA         ,0),
1344           USM(TB_DELETEBUTTON          ,0),
1345           USM(TB_GETBUTTON             ,0),
1346           USM(TB_BUTTONCOUNT           ,0),
1347           USM(TB_COMMANDTOINDEX        ,0),
1348           USM(TB_SAVERESTOREA          ,0),
1349           USM(TB_CUSTOMIZE             ,0),
1350           USM(TB_ADDSTRINGA            ,0),
1351           USM(TB_GETITEMRECT           ,0),
1352           USM(TB_BUTTONSTRUCTSIZE      ,0),
1353           USM(TB_SETBUTTONSIZE         ,0),
1354           USM(TB_SETBITMAPSIZE         ,0),
1355           USM(TB_AUTOSIZE              ,0),
1356           USM(TB_GETTOOLTIPS           ,0),
1357           USM(TB_SETTOOLTIPS           ,0),
1358           USM(TB_SETPARENT             ,0),
1359           USM(TB_SETROWS               ,0),
1360           USM(TB_GETROWS               ,0),
1361           USM(TB_GETBITMAPFLAGS        ,0),
1362           USM(TB_SETCMDID              ,0),
1363           USM(TB_CHANGEBITMAP          ,0),
1364           USM(TB_GETBITMAP             ,0),
1365           USM(TB_GETBUTTONTEXTA        ,0),
1366           USM(TB_REPLACEBITMAP         ,0),
1367           USM(TB_SETINDENT             ,0),
1368           USM(TB_SETIMAGELIST          ,0),
1369           USM(TB_GETIMAGELIST          ,0),
1370           USM(TB_LOADIMAGES            ,0),
1371           USM(TB_GETRECT               ,0),
1372           USM(TB_SETHOTIMAGELIST       ,0),
1373           USM(TB_GETHOTIMAGELIST       ,0),
1374           USM(TB_SETDISABLEDIMAGELIST  ,0),
1375           USM(TB_GETDISABLEDIMAGELIST  ,0),
1376           USM(TB_SETSTYLE              ,0),
1377           USM(TB_GETSTYLE              ,0),
1378           USM(TB_GETBUTTONSIZE         ,0),
1379           USM(TB_SETBUTTONWIDTH        ,0),
1380           USM(TB_SETMAXTEXTROWS        ,0),
1381           USM(TB_GETTEXTROWS           ,0),
1382           USM(TB_GETOBJECT             ,0),
1383           USM(TB_GETBUTTONINFOW        ,0),
1384           USM(TB_SETBUTTONINFOW        ,0),
1385           USM(TB_GETBUTTONINFOA        ,0),
1386           USM(TB_SETBUTTONINFOA        ,0),
1387           USM(TB_INSERTBUTTONW         ,0),
1388           USM(TB_ADDBUTTONSW           ,0),
1389           USM(TB_HITTEST               ,0),
1390           USM(TB_SETDRAWTEXTFLAGS      ,0),
1391           USM(TB_GETHOTITEM            ,0),
1392           USM(TB_SETHOTITEM            ,0),
1393           USM(TB_SETANCHORHIGHLIGHT    ,0),
1394           USM(TB_GETANCHORHIGHLIGHT    ,0),
1395           USM(TB_GETBUTTONTEXTW        ,0),
1396           USM(TB_SAVERESTOREW          ,0),
1397           USM(TB_ADDSTRINGW            ,0),
1398           USM(TB_MAPACCELERATORA       ,0),
1399           USM(TB_GETINSERTMARK         ,0),
1400           USM(TB_SETINSERTMARK         ,0),
1401           USM(TB_INSERTMARKHITTEST     ,0),
1402           USM(TB_MOVEBUTTON            ,0),
1403           USM(TB_GETMAXSIZE            ,0),
1404           USM(TB_SETEXTENDEDSTYLE      ,0),
1405           USM(TB_GETEXTENDEDSTYLE      ,0),
1406           USM(TB_GETPADDING            ,0),
1407           USM(TB_SETPADDING            ,0),
1408           USM(TB_SETINSERTMARKCOLOR    ,0),
1409           USM(TB_GETINSERTMARKCOLOR    ,0),
1410           USM(TB_MAPACCELERATORW       ,0),
1411           USM(TB_GETSTRINGW            ,0),
1412           USM(TB_GETSTRINGA            ,0),
1413           USM(TB_UNKWN45D              ,8),
1414           USM(TB_UNKWN45E              ,0),
1415           USM(TB_UNKWN460              ,0),
1416           USM(TB_UNKWN463              ,8),
1417           USM(TB_UNKWN464              ,0),
1418           {0,0,0} };
1419
1420 static const USER_MSG tooltips_array[] = {
1421           USM(TTM_ACTIVATE             ,0),
1422           USM(TTM_SETDELAYTIME         ,0),
1423           USM(TTM_ADDTOOLA             ,0),
1424           USM(TTM_DELTOOLA             ,0),
1425           USM(TTM_NEWTOOLRECTA         ,0),
1426           USM(TTM_RELAYEVENT           ,0),
1427           USM(TTM_GETTOOLINFOA         ,0),
1428           USM(TTM_HITTESTA             ,0),
1429           USM(TTM_GETTEXTA             ,0),
1430           USM(TTM_UPDATETIPTEXTA       ,0),
1431           USM(TTM_GETTOOLCOUNT         ,0),
1432           USM(TTM_ENUMTOOLSA           ,0),
1433           USM(TTM_GETCURRENTTOOLA      ,0),
1434           USM(TTM_WINDOWFROMPOINT      ,0),
1435           USM(TTM_TRACKACTIVATE        ,0),
1436           USM(TTM_TRACKPOSITION        ,0),
1437           USM(TTM_SETTIPBKCOLOR        ,0),
1438           USM(TTM_SETTIPTEXTCOLOR      ,0),
1439           USM(TTM_GETDELAYTIME         ,0),
1440           USM(TTM_GETTIPBKCOLOR        ,0),
1441           USM(TTM_GETTIPTEXTCOLOR      ,0),
1442           USM(TTM_SETMAXTIPWIDTH       ,0),
1443           USM(TTM_GETMAXTIPWIDTH       ,0),
1444           USM(TTM_SETMARGIN            ,0),
1445           USM(TTM_GETMARGIN            ,0),
1446           USM(TTM_POP                  ,0),
1447           USM(TTM_UPDATE               ,0),
1448           USM(TTM_GETBUBBLESIZE        ,0),
1449           USM(TTM_ADDTOOLW             ,0),
1450           USM(TTM_DELTOOLW             ,0),
1451           USM(TTM_NEWTOOLRECTW         ,0),
1452           USM(TTM_GETTOOLINFOW         ,0),
1453           USM(TTM_SETTOOLINFOW         ,0),
1454           USM(TTM_HITTESTW             ,0),
1455           USM(TTM_GETTEXTW             ,0),
1456           USM(TTM_UPDATETIPTEXTW       ,0),
1457           USM(TTM_ENUMTOOLSW           ,0),
1458           USM(TTM_GETCURRENTTOOLW      ,0),
1459           {0,0,0} };
1460
1461 static const USER_MSG comboex_array[] = {
1462           USM(CBEM_INSERTITEMA        ,0),
1463           USM(CBEM_SETIMAGELIST       ,0),
1464           USM(CBEM_GETIMAGELIST       ,0),
1465           USM(CBEM_GETITEMA           ,0),
1466           USM(CBEM_SETITEMA           ,0),
1467           USM(CBEM_GETCOMBOCONTROL    ,0),
1468           USM(CBEM_GETEDITCONTROL     ,0),
1469           USM(CBEM_SETEXSTYLE         ,0),
1470           USM(CBEM_GETEXTENDEDSTYLE   ,0),
1471           USM(CBEM_HASEDITCHANGED     ,0),
1472           USM(CBEM_INSERTITEMW        ,0),
1473           USM(CBEM_SETITEMW           ,0),
1474           USM(CBEM_GETITEMW           ,0),
1475           USM(CBEM_SETEXTENDEDSTYLE   ,0),
1476           {0,0,0} };
1477
1478 static const USER_MSG propsht_array[] = {
1479           USM(PSM_SETCURSEL           ,0),
1480           USM(PSM_REMOVEPAGE          ,0),
1481           USM(PSM_ADDPAGE             ,0),
1482           USM(PSM_CHANGED             ,0),
1483           USM(PSM_RESTARTWINDOWS      ,0),
1484           USM(PSM_REBOOTSYSTEM        ,0),
1485           USM(PSM_CANCELTOCLOSE       ,0),
1486           USM(PSM_QUERYSIBLINGS       ,0),
1487           USM(PSM_UNCHANGED           ,0),
1488           USM(PSM_APPLY               ,0),
1489           USM(PSM_SETTITLEA           ,0),
1490           USM(PSM_SETWIZBUTTONS       ,0),
1491           USM(PSM_PRESSBUTTON         ,0),
1492           USM(PSM_SETCURSELID         ,0),
1493           USM(PSM_SETFINISHTEXTA      ,0),
1494           USM(PSM_GETTABCONTROL       ,0),
1495           USM(PSM_ISDIALOGMESSAGE     ,0),
1496           USM(PSM_GETCURRENTPAGEHWND  ,0),
1497           USM(PSM_SETTITLEW           ,0),
1498           USM(PSM_SETFINISHTEXTW      ,0),
1499           {0,0,0} };
1500 const WCHAR PropSheetInfoStr[] =
1501     {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
1502
1503 static const USER_MSG updown_array[] = {
1504           USM(UDM_SETRANGE            ,0),
1505           USM(UDM_GETRANGE            ,0),
1506           USM(UDM_SETPOS              ,0),
1507           USM(UDM_GETPOS              ,0),
1508           USM(UDM_SETBUDDY            ,0),
1509           USM(UDM_GETBUDDY            ,0),
1510           USM(UDM_SETACCEL            ,0),
1511           USM(UDM_GETACCEL            ,0),
1512           USM(UDM_SETBASE             ,0),
1513           USM(UDM_GETBASE             ,0),
1514           USM(UDM_SETRANGE32          ,0),
1515           USM(UDM_GETRANGE32          ,0),
1516           USM(UDM_SETPOS32            ,0),
1517           USM(UDM_GETPOS32            ,0),
1518           {0,0,0} };
1519
1520 #undef SZOF
1521 #undef USM
1522
1523 static CONTROL_CLASS  cc_array[] = {
1524     {WC_COMBOBOXEXW,    comboex_array,  0},
1525     {WC_PROPSHEETW,     propsht_array,  0},
1526     {REBARCLASSNAMEW,   rebar_array,    0},
1527     {TOOLBARCLASSNAMEW, toolbar_array,  0},
1528     {TOOLTIPS_CLASSW,   tooltips_array, 0},
1529     {UPDOWN_CLASSW,     updown_array,   0},
1530     {0, 0, 0} };
1531
1532
1533 /************************************************************************/
1534
1535
1536 /* WM_NOTIFY function codes display */
1537
1538 typedef struct
1539 {
1540     const char *name;     /* name of notify message        */
1541     UINT        value;     /* notify code value             */
1542     UINT        len;       /* length of extra space to dump */
1543 } SPY_NOTIFY;
1544
1545 #define SPNFY(a,b) { #a ,a,sizeof(b)-sizeof(NMHDR)}
1546
1547 /* Array MUST be in descending order by the 'value' field  */
1548 /* (since value is UNSIGNED, 0xffffffff is largest and     */
1549 /*  0xfffffffe is smaller). A binary search is used to     */
1550 /* locate the correct 'value'.                             */
1551 static const SPY_NOTIFY spnfy_array[] = {
1552     /*  common        0U       to  0U-99U  */
1553     SPNFY(NM_OUTOFMEMORY,        NMHDR),
1554     SPNFY(NM_CLICK,              NMHDR),
1555     SPNFY(NM_DBLCLK,             NMHDR),
1556     SPNFY(NM_RETURN,             NMHDR),
1557     SPNFY(NM_RCLICK,             NMHDR),
1558     SPNFY(NM_RDBLCLK,            NMHDR),
1559     SPNFY(NM_SETFOCUS,           NMHDR),
1560     SPNFY(NM_KILLFOCUS,          NMHDR),
1561     SPNFY(NM_CUSTOMDRAW,         NMCUSTOMDRAW),
1562     SPNFY(NM_HOVER,              NMHDR),
1563     SPNFY(NM_NCHITTEST,          NMMOUSE),
1564     SPNFY(NM_KEYDOWN,            NMKEY),
1565     SPNFY(NM_RELEASEDCAPTURE,    NMHDR),
1566     SPNFY(NM_SETCURSOR,          NMMOUSE),
1567     SPNFY(NM_CHAR,               NMCHAR),
1568     SPNFY(NM_TOOLTIPSCREATED,    NMTOOLTIPSCREATED),
1569     /* Listview       0U-100U  to  0U-199U  */
1570     SPNFY(LVN_ITEMCHANGING,      NMLISTVIEW),
1571     SPNFY(LVN_ITEMCHANGED,       NMLISTVIEW),
1572     SPNFY(LVN_INSERTITEM,        NMLISTVIEW),
1573     SPNFY(LVN_DELETEITEM,        NMLISTVIEW),
1574     SPNFY(LVN_DELETEALLITEMS,    NMLISTVIEW),
1575     SPNFY(LVN_BEGINLABELEDITA,   NMLVDISPINFOA),
1576     SPNFY(LVN_ENDLABELEDITA,     NMLVDISPINFOA),
1577     SPNFY(LVN_COLUMNCLICK,       NMLISTVIEW),
1578     SPNFY(LVN_BEGINDRAG,         NMLISTVIEW),
1579     SPNFY(LVN_BEGINRDRAG,        NMLISTVIEW),
1580     SPNFY(LVN_ODCACHEHINT,       NMLVCACHEHINT),
1581     SPNFY(LVN_ITEMACTIVATE,      NMITEMACTIVATE),
1582     SPNFY(LVN_ODSTATECHANGED,    NMLVODSTATECHANGE),
1583     SPNFY(LVN_HOTTRACK,          NMLISTVIEW),
1584     SPNFY(LVN_GETDISPINFOA,      NMLVDISPINFOA),
1585     SPNFY(LVN_SETDISPINFOA,      NMLVDISPINFOA),
1586     SPNFY(LVN_ODFINDITEMA,       NMLVFINDITEMA),
1587     SPNFY(LVN_KEYDOWN,           NMLVKEYDOWN),
1588     SPNFY(LVN_MARQUEEBEGIN,      NMLISTVIEW),
1589     SPNFY(LVN_GETINFOTIPA,       NMLVGETINFOTIPA),
1590     SPNFY(LVN_GETINFOTIPW,       NMLVGETINFOTIPW),
1591     SPNFY(LVN_BEGINLABELEDITW,   NMLVDISPINFOW),
1592     SPNFY(LVN_ENDLABELEDITW,     NMLVDISPINFOW),
1593     SPNFY(LVN_GETDISPINFOW,      NMLVDISPINFOW),
1594     SPNFY(LVN_SETDISPINFOW,      NMLVDISPINFOW),
1595     SPNFY(LVN_ODFINDITEMW,       NMLVFINDITEMW),
1596     /* PropertySheet  0U-200U  to  0U-299U  */
1597     SPNFY(PSN_SETACTIVE,         PSHNOTIFY),
1598     SPNFY(PSN_KILLACTIVE,        PSHNOTIFY),
1599     SPNFY(PSN_APPLY,             PSHNOTIFY),
1600     SPNFY(PSN_RESET,             PSHNOTIFY),
1601     SPNFY(PSN_HELP,              PSHNOTIFY),
1602     SPNFY(PSN_WIZBACK,           PSHNOTIFY),
1603     SPNFY(PSN_WIZNEXT,           PSHNOTIFY),
1604     SPNFY(PSN_WIZFINISH,         PSHNOTIFY),
1605     SPNFY(PSN_QUERYCANCEL,       PSHNOTIFY),
1606     SPNFY(PSN_GETOBJECT,         NMOBJECTNOTIFY),
1607     /*    SPNFY(PSN_QUERYINITIALFOCUS, .PSHNOTIFY),         NIY      */
1608     /*    SPNFY(PSN_TRANSLATEACCELERATOR, .PSHNOTIFY),      NIY      */
1609     /* Header         0U-300U  to  0U-399U  */
1610     SPNFY(HDN_ITEMCHANGINGA,     NMHDR),
1611     SPNFY(HDN_ITEMCHANGEDA,      NMHDR),
1612     SPNFY(HDN_ITEMCLICKA,        NMHDR),
1613     SPNFY(HDN_ITEMDBLCLICKA,     NMHDR),
1614     SPNFY(HDN_DIVIDERDBLCLICKA,  NMHDR),
1615     SPNFY(HDN_BEGINTRACKA,       NMHDR),
1616     SPNFY(HDN_ENDTRACKA,         NMHDR),
1617     SPNFY(HDN_GETDISPINFOA,      NMHDR),
1618     SPNFY(HDN_BEGINDRAG,         NMHDR),
1619     SPNFY(HDN_ENDDRAG,           NMHDR),
1620     SPNFY(HDN_ITEMCHANGINGW,     NMHDR),
1621     SPNFY(HDN_ITEMCHANGEDW,      NMHDR),
1622     SPNFY(HDN_ITEMCLICKW,        NMHDR),
1623     SPNFY(HDN_ITEMDBLCLICKW,     NMHDR),
1624     SPNFY(HDN_DIVIDERDBLCLICKW,  NMHDR),
1625     SPNFY(HDN_BEGINTRACKW,       NMHDR),
1626     SPNFY(HDN_ENDTRACKW,         NMHDR),
1627     SPNFY(HDN_GETDISPINFOW,      NMHDR),
1628     /* Treeview       0U-400U  to  0U-499U  */
1629     SPNFY(TVN_SELCHANGINGA,      NMTREEVIEWA),
1630     SPNFY(TVN_SELCHANGEDA,       NMTREEVIEWA),
1631     SPNFY(TVN_GETDISPINFOA,      NMTVDISPINFOA),
1632     SPNFY(TVN_SETDISPINFOA,      NMTVDISPINFOA),
1633     SPNFY(TVN_ITEMEXPANDINGA,    NMTREEVIEWA),
1634     SPNFY(TVN_ITEMEXPANDEDA,     NMTREEVIEWA),
1635     SPNFY(TVN_BEGINDRAGA,        NMTREEVIEWA),
1636     SPNFY(TVN_BEGINRDRAGA,       NMTREEVIEWA),
1637     SPNFY(TVN_DELETEITEMA,       NMTREEVIEWA),
1638     SPNFY(TVN_BEGINLABELEDITA,   NMTVDISPINFOA),
1639     SPNFY(TVN_ENDLABELEDITA,     NMTVDISPINFOA),
1640     SPNFY(TVN_KEYDOWN,           NMTVKEYDOWN),
1641     SPNFY(TVN_SELCHANGINGW,      NMTREEVIEWW),
1642     SPNFY(TVN_SELCHANGEDW,       NMTREEVIEWW),
1643     SPNFY(TVN_GETDISPINFOW,      NMTVDISPINFOW),
1644     SPNFY(TVN_SETDISPINFOW,      NMTVDISPINFOW),
1645     SPNFY(TVN_ITEMEXPANDINGW,    NMTREEVIEWW),
1646     SPNFY(TVN_ITEMEXPANDEDW,     NMTREEVIEWW),
1647     SPNFY(TVN_BEGINDRAGW,        NMTREEVIEWW),
1648     SPNFY(TVN_BEGINRDRAGW,       NMTREEVIEWW),
1649     SPNFY(TVN_DELETEITEMW,       NMTREEVIEWW),
1650     SPNFY(TVN_BEGINLABELEDITW,   NMTVDISPINFOW),
1651     SPNFY(TVN_ENDLABELEDITW,     NMTVDISPINFOW),
1652     /* Tooltips       0U-520U  to  0U-549U  */
1653     SPNFY(TTN_GETDISPINFOA,      NMHDR),
1654     SPNFY(TTN_SHOW,              NMHDR),
1655     SPNFY(TTN_POP,               NMHDR),
1656     SPNFY(TTN_GETDISPINFOW,      NMHDR),
1657     /* Tab            0U-550U  to  0U-580U  */
1658     SPNFY(TCN_KEYDOWN,           NMHDR),
1659     SPNFY(TCN_SELCHANGE,         NMHDR),
1660     SPNFY(TCN_SELCHANGING,       NMHDR),
1661     SPNFY(TCN_GETOBJECT,         NMHDR),
1662     /* Common Dialog  0U-601U  to  0U-699U  */
1663     SPNFY(CDN_INITDONE,          OFNOTIFYA),
1664     SPNFY(CDN_SELCHANGE,         OFNOTIFYA),
1665     SPNFY(CDN_FOLDERCHANGE,      OFNOTIFYA),
1666     SPNFY(CDN_SHAREVIOLATION,    OFNOTIFYA),
1667     SPNFY(CDN_HELP,              OFNOTIFYA),
1668     SPNFY(CDN_FILEOK,            OFNOTIFYA),
1669     SPNFY(CDN_TYPECHANGE,        OFNOTIFYA),
1670     /* Toolbar        0U-700U  to  0U-720U  */
1671     SPNFY(TBN_GETBUTTONINFOA,    NMTOOLBARA),
1672     SPNFY(TBN_BEGINDRAG,         NMTOOLBARA),
1673     SPNFY(TBN_ENDDRAG,           NMTOOLBARA),
1674     SPNFY(TBN_BEGINADJUST,       NMHDR),
1675     SPNFY(TBN_ENDADJUST,         NMHDR),
1676     SPNFY(TBN_RESET,             NMHDR),
1677     SPNFY(TBN_QUERYINSERT,       NMTOOLBARA),
1678     SPNFY(TBN_QUERYDELETE,       NMTOOLBARA),
1679     SPNFY(TBN_TOOLBARCHANGE,     NMHDR),
1680     SPNFY(TBN_CUSTHELP,          NMHDR),
1681     SPNFY(TBN_DROPDOWN,          NMTOOLBARA),
1682     SPNFY(TBN_GETOBJECT,         NMOBJECTNOTIFY),
1683     SPNFY(TBN_HOTITEMCHANGE,     NMTBHOTITEM),
1684     SPNFY(TBN_DRAGOUT,           NMTOOLBARA),
1685     SPNFY(TBN_DELETINGBUTTON,    NMTOOLBARA),
1686     SPNFY(TBN_GETDISPINFOA,      NMTBDISPINFOA),
1687     SPNFY(TBN_GETDISPINFOW,      NMTBDISPINFOW),
1688     SPNFY(TBN_GETINFOTIPA,       NMTBGETINFOTIPA),
1689     SPNFY(TBN_GETINFOTIPW,       NMTBGETINFOTIPW),
1690     SPNFY(TBN_GETBUTTONINFOW,    NMTOOLBARW),
1691     /* Up/Down        0U-721U  to  0U-740U  */
1692     SPNFY(UDN_DELTAPOS,          NMHDR),
1693     /* Month Calendar 0U-750U  to  0U-759U  */
1694     /* ******************* WARNING ***************************** */
1695     /* The following appear backwards but needs to be this way.  */
1696     /* The reason is that MS (and us) define the MCNs as         */
1697     /*         MCN_FIRST + n                                     */
1698     /* instead of the way ALL other notifications are            */
1699     /*         TBN_FIRST - n                                     */
1700     /* The only place that this is important is in this list     */
1701     /*                                                           */
1702     /* Also since the same error was made with the DTN_ items,   */
1703     /* they overlay the MCN_ and need to be inserted in the      */
1704     /* other section of the table so that it is in order for     */
1705     /* the binary search.                                        */
1706     /*                                                           */
1707     /* Thank you MS for your obvious quality control!!           */
1708     /* ******************* WARNING ***************************** */
1709     /* Date/Time      0U-760U  to  0U-799U  */
1710     /* SPNFY(MCN_SELECT,            NMHDR), */
1711     /* SPNFY(MCN_GETDAYSTATE,       NMHDR), */
1712     /* SPNFY(MCN_SELCHANGE,         NMHDR), */
1713     /* ******************* WARNING ***************************** */
1714     /* The following appear backwards but needs to be this way.  */
1715     /* The reason is that MS (and us) define the MCNs as         */
1716     /*         DTN_FIRST + n                                     */
1717     /* instead of the way ALL other notifications are            */
1718     /*         TBN_FIRST - n                                     */
1719     /* The only place that this is important is in this list     */
1720     /* ******************* WARNING ***************************** */
1721     SPNFY(DTN_FORMATQUERYW,      NMHDR),
1722     SPNFY(DTN_FORMATW,           NMHDR),
1723     SPNFY(DTN_WMKEYDOWNW,        NMHDR),
1724     SPNFY(DTN_USERSTRINGW,       NMHDR),
1725     SPNFY(MCN_SELECT,            NMHDR),
1726     SPNFY(MCN_GETDAYSTATE,       NMHDR),
1727     SPNFY(MCN_SELCHANGE,         NMHDR),
1728     SPNFY(DTN_CLOSEUP,           NMHDR),
1729     SPNFY(DTN_DROPDOWN,          NMHDR),
1730     SPNFY(DTN_FORMATQUERYA,      NMHDR),
1731     SPNFY(DTN_FORMATA,           NMHDR),
1732     SPNFY(DTN_WMKEYDOWNA,        NMHDR),
1733     SPNFY(DTN_USERSTRINGA,       NMHDR),
1734     SPNFY(DTN_DATETIMECHANGE,    NMHDR),
1735     /* ComboBoxEx     0U-800U  to  0U-830U  */
1736     SPNFY(CBEN_GETDISPINFOA,     NMCOMBOBOXEXA),
1737     SPNFY(CBEN_INSERTITEM,       NMCOMBOBOXEXA),
1738     SPNFY(CBEN_DELETEITEM,       NMCOMBOBOXEXA),
1739     SPNFY(CBEN_BEGINEDIT,        NMHDR),
1740     SPNFY(CBEN_ENDEDITA,         NMCBEENDEDITA),
1741     SPNFY(CBEN_ENDEDITW,         NMCBEENDEDITW),
1742     SPNFY(CBEN_GETDISPINFOW,     NMCOMBOBOXEXW),
1743     SPNFY(CBEN_DRAGBEGINA,       NMCBEDRAGBEGINA),
1744     SPNFY(CBEN_DRAGBEGINW,       NMCBEDRAGBEGINW),
1745     /* Rebar          0U-831U  to  0U-859U  */
1746     SPNFY(RBN_HEIGHTCHANGE,      NMHDR),
1747     SPNFY(RBN_GETOBJECT,         NMOBJECTNOTIFY),
1748     SPNFY(RBN_LAYOUTCHANGED,     NMHDR),
1749     SPNFY(RBN_AUTOSIZE,          NMRBAUTOSIZE),
1750     SPNFY(RBN_BEGINDRAG,         NMREBAR),
1751     SPNFY(RBN_ENDDRAG,           NMREBAR),
1752     SPNFY(RBN_DELETINGBAND,      NMREBAR),
1753     SPNFY(RBN_DELETEDBAND,       NMREBAR),
1754     SPNFY(RBN_CHILDSIZE,         NMREBARCHILDSIZE),
1755     /* IP Adderss     0U-860U  to  0U-879U  */
1756     SPNFY(IPN_FIELDCHANGED,      NMHDR),
1757     /* Status bar     0U-880U  to  0U-899U  */
1758     SPNFY(SBN_SIMPLEMODECHANGE,  NMHDR),
1759     /* Pager          0U-900U  to  0U-950U  */
1760     SPNFY(PGN_SCROLL,            NMPGSCROLL),
1761     SPNFY(PGN_CALCSIZE,          NMPGCALCSIZE),
1762     {0,0,0}};
1763 static const SPY_NOTIFY *end_spnfy_array;     /* ptr to last good entry in array */
1764 #undef SPNFY
1765
1766
1767 static BOOL16 SPY_Exclude[SPY_MAX_MSGNUM+1];
1768 static BOOL16 SPY_ExcludeDWP = 0;
1769
1770 #define SPY_EXCLUDE(msg) \
1771     (SPY_Exclude[(msg) > SPY_MAX_MSGNUM ? SPY_MAX_MSGNUM : (msg)])
1772
1773
1774 typedef struct
1775 {
1776     UINT       msgnum;           /* message number */
1777     HWND       msg_hwnd;         /* window handle for message          */
1778     WPARAM     wParam;           /* message parameter                  */
1779     LPARAM     lParam;           /* message parameter                  */
1780     INT        data_len;         /* length of data to dump             */
1781     char       msg_name[60];     /* message name (see SPY_GetMsgName)  */
1782     WCHAR      wnd_class[60];    /* window class name (full)           */
1783     WCHAR      wnd_name[16];     /* window name for message            */
1784 } SPY_INSTANCE;
1785
1786 /* This is defined so that the external entry point can return the addr */
1787 static SPY_INSTANCE ext_sp_e;
1788
1789 static int indent_tls_index;
1790
1791 /***********************************************************************
1792  *           get_indent_level
1793  */
1794 inline static int get_indent_level(void)
1795 {
1796     return (int)TlsGetValue( indent_tls_index );
1797 }
1798
1799
1800 /***********************************************************************
1801  *           set_indent_level
1802  */
1803 inline static void set_indent_level( int level )
1804 {
1805     TlsSetValue( indent_tls_index, (void *)level );
1806 }
1807
1808
1809 /***********************************************************************
1810  *           SPY_GetMsgInternal
1811  */
1812 static const char *SPY_GetMsgInternal( UINT msg )
1813 {
1814     if (msg <= SPY_MAX_MSGNUM)
1815     {
1816         if (!MessageTypeNames[msg]) return "???";
1817         return MessageTypeNames[msg];
1818     }
1819
1820     if (msg >= LVM_FIRST && msg <= LVM_FIRST + SPY_MAX_LVMMSGNUM)
1821     {
1822         if (!LVMMessageTypeNames[msg-LVM_FIRST]) return "LVM_?";
1823         return LVMMessageTypeNames[msg-LVM_FIRST];
1824     }
1825
1826     if (msg >= TV_FIRST && msg <= TV_FIRST + SPY_MAX_TVMSGNUM)
1827     {
1828         if (!TVMessageTypeNames[msg-TV_FIRST]) return "TV_?";
1829         return TVMessageTypeNames[msg-TV_FIRST];
1830     }
1831
1832     if (msg >= HDM_FIRST && msg <= HDM_FIRST + SPY_MAX_HDMMSGNUM)
1833     {
1834         if (!HDMMessageTypeNames[msg-HDM_FIRST]) return "HDM_?";
1835         return HDMMessageTypeNames[msg-HDM_FIRST];
1836     }
1837
1838     if (msg >= TCM_FIRST && msg <= TCM_FIRST + SPY_MAX_TCMMSGNUM)
1839     {
1840         if (!TCMMessageTypeNames[msg-TCM_FIRST]) return "TCM_?";
1841         return TCMMessageTypeNames[msg-TCM_FIRST];
1842     }
1843
1844     if (msg >= PGM_FIRST && msg <= PGM_FIRST + SPY_MAX_PGMMSGNUM)
1845     {
1846         if (!PGMMessageTypeNames[msg-PGM_FIRST]) return "PGM_?";
1847         return PGMMessageTypeNames[msg-PGM_FIRST];
1848     }
1849
1850     if (msg >= CCM_FIRST && msg <= CCM_FIRST + SPY_MAX_CCMMSGNUM)
1851     {
1852         if (!CCMMessageTypeNames[msg-CCM_FIRST]) return "???";
1853         return CCMMessageTypeNames[msg-CCM_FIRST];
1854     }
1855
1856     if (msg >= WM_WINE_DESTROYWINDOW && msg <= WM_WINE_DESTROYWINDOW + SPY_MAX_WINEMSGNUM)
1857     {
1858         if (!WINEMessageTypeNames[msg-WM_WINE_DESTROYWINDOW]) return "???";
1859         return WINEMessageTypeNames[msg-WM_WINE_DESTROYWINDOW];
1860     }
1861     return "";
1862 }
1863
1864 /***********************************************************************
1865  *           SPY_Bsearch_Msg
1866  */
1867 const USER_MSG *SPY_Bsearch_Msg( const USER_MSG *first, const USER_MSG *last, UINT code)
1868 {
1869     INT count;
1870     const USER_MSG *test;
1871
1872     while (last >= first) {
1873         count = 1 + last - first;
1874         if (count < 3) {
1875 #if DEBUG_SPY
1876             TRACE("code=%d, f-value=%d, f-name=%s, l-value=%d, l-name=%s, l-len=%d,\n",
1877                code, first->value, first->name, last->value, last->name, last->len);
1878 #endif
1879             if (first->value == code) return first;
1880             if (last->value == code) return last;
1881             return NULL;
1882         }
1883         count = count / 2;
1884         test = first + count;
1885 #if DEBUG_SPY
1886         TRACE("first=%p, last=%p, test=%p, t-value=%d, code=%d, count=%d\n",
1887            first, last, test, test->value, code, count);
1888 #endif
1889         if (test->value == code) return test;
1890         if (test->value > code)
1891             last = test - 1;
1892         else
1893             first = test + 1;
1894     }
1895     return NULL;
1896 }
1897
1898 /***********************************************************************
1899  *           SPY_GetMsgStuff
1900  *
1901  *  Get message name and other information for dumping
1902  */
1903 static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
1904 {
1905     const USER_MSG *p;
1906
1907     sp_e->msg_name[sizeof(sp_e->msg_name)-1] = 0;
1908     strncpy (sp_e->msg_name, SPY_GetMsgInternal( sp_e->msgnum ),
1909              sizeof(sp_e->msg_name)-1);
1910
1911     sp_e->data_len = 0;
1912     if (!sp_e->msg_name[0])
1913     {
1914         INT i = 0;
1915
1916         if (sp_e->msgnum >= 0xc000)
1917         {
1918             if (GlobalGetAtomNameA( sp_e->msgnum, sp_e->msg_name+1, sizeof(sp_e->msg_name)-2 ))
1919             {
1920                 sp_e->msg_name[0] = '\"';
1921                 strcat( sp_e->msg_name, "\"" );
1922                 return;
1923             }
1924         }
1925 #if DEBUG_SPY
1926         TRACE("looking class %s\n", sp_e->wnd_class);
1927 #endif
1928
1929         while (cc_array[i].classname &&
1930                strcmpW(cc_array[i].classname, sp_e->wnd_class) !=0) i++;
1931
1932         if (cc_array[i].classname)
1933         {
1934 #if DEBUG_SPY
1935             TRACE("process class %s, first %p, last %p\n",
1936                   debugstr_w(cc_array[i].classname), cc_array[i].classmsg,
1937                   cc_array[i].lastmsg);
1938 #endif
1939             p = SPY_Bsearch_Msg (cc_array[i].classmsg, cc_array[i].lastmsg,
1940                                  sp_e->msgnum);
1941             if (p) {
1942                 strncpy (sp_e->msg_name, p->name, sizeof(sp_e->msg_name)-1);
1943                 sp_e->data_len = p->len;
1944                 return;
1945             }
1946         }
1947         sprintf( sp_e->msg_name, "WM_USER+%04x", sp_e->msgnum - WM_USER );
1948     }
1949 }
1950
1951 /***********************************************************************
1952  *           SPY_GetWndName
1953  *
1954  *  Sets the value of "wnd_name" and "wnd_class" members of the
1955  *  instance structure.
1956  *
1957  */
1958 void SPY_GetWndName( SPY_INSTANCE *sp_e )
1959 {
1960     DWORD save_error;
1961     INT len;
1962
1963     /* save and restore error code over the next call */
1964     save_error = GetLastError();
1965     /* special code to detect a property sheet dialog   */
1966     if ((GetClassLongW(sp_e->msg_hwnd, GCW_ATOM) == (LONG)WC_DIALOGW) &&
1967         (GetPropW(sp_e->msg_hwnd, PropSheetInfoStr))) {
1968         strcpyW(sp_e->wnd_class, WC_PROPSHEETW);
1969     }
1970     else {
1971         GetClassNameW(sp_e->msg_hwnd, sp_e->wnd_class, sizeof(sp_e->wnd_class)/sizeof(WCHAR));
1972     }
1973     SetLastError(save_error);
1974
1975     len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, sizeof(sp_e->wnd_name)/sizeof(WCHAR));
1976     if(!len) /* get class name */
1977     {
1978         LPWSTR dst = sp_e->wnd_name;
1979         LPWSTR src = sp_e->wnd_class;
1980         int n = sizeof(sp_e->wnd_name)/sizeof(WCHAR) - 3;
1981         *dst++ = '{';
1982         while ((n-- > 0) && *src) *dst++ = *src++;
1983         *dst++ = '}';
1984         *dst = 0;
1985     }
1986 }
1987
1988 /***********************************************************************
1989  *           SPY_GetMsgName
1990  *
1991  *  ****  External function  ****
1992  *
1993  *  Get message name
1994  */
1995 const char *SPY_GetMsgName( UINT msg, HWND hWnd )
1996 {
1997     ext_sp_e.msgnum = msg;
1998     ext_sp_e.msg_hwnd   = hWnd;
1999     ext_sp_e.lParam = 0;
2000     ext_sp_e.wParam = 0;
2001     SPY_GetWndName(&ext_sp_e);
2002     SPY_GetMsgStuff(&ext_sp_e);
2003     return ext_sp_e.msg_name;
2004 }
2005
2006 /***********************************************************************
2007  *           SPY_GetVKeyName
2008  */
2009 const char *SPY_GetVKeyName(WPARAM wParam)
2010 {
2011     const char *vk_key_name;
2012
2013     if(wParam <= SPY_MAX_VKKEYSNUM && VK_KeyNames[wParam])
2014         vk_key_name = VK_KeyNames[wParam];
2015     else
2016         vk_key_name = "VK_???";
2017
2018     return vk_key_name;
2019 }
2020
2021 /***********************************************************************
2022  *           SPY_Bsearch_Notify
2023  */
2024 const SPY_NOTIFY *SPY_Bsearch_Notify( const SPY_NOTIFY *first, const SPY_NOTIFY *last, UINT code)
2025 {
2026     INT count;
2027     const SPY_NOTIFY *test;
2028
2029     while (last >= first) {
2030         count = 1 + last - first;
2031         if (count < 3) {
2032 #if DEBUG_SPY
2033             TRACE("code=%d, f-value=%d, f-name=%s, l-value=%d, l-name=%s, l-len=%d,\n",
2034                code, first->value, first->name, last->value, last->name, last->len);
2035 #endif
2036             if (first->value == code) return first;
2037             if (last->value == code) return last;
2038             return NULL;
2039         }
2040         count = count / 2;
2041         test = first + count;
2042 #if DEBUG_SPY
2043         TRACE("first=%p, last=%p, test=%p, t-value=%d, code=%d, count=%d\n",
2044            first, last, test, test->value, code, count);
2045 #endif
2046         if (test->value == code) return test;
2047         if (test->value < code)
2048             last = test - 1;
2049         else
2050             first = test + 1;
2051     }
2052     return NULL;
2053 }
2054
2055 /***********************************************************************
2056  *           SPY_DumpMem
2057  */
2058 void SPY_DumpMem (LPCSTR header, UINT *q, INT len)
2059 {
2060     int i;
2061
2062     for(i=0; i<len-12; i+=16) {
2063         TRACE("%s [%04x] %08x %08x %08x %08x\n",
2064               header, i, *q, *(q+1), *(q+2), *(q+3));
2065         q += 4;
2066     }
2067     switch ((len - i + 3) & (~3)) {
2068     case 16:
2069         TRACE("%s [%04x] %08x %08x %08x %08x\n",
2070               header, i, *q, *(q+1), *(q+2), *(q+3));
2071         break;
2072     case 12:
2073         TRACE("%s [%04x] %08x %08x %08x\n",
2074               header, i, *q, *(q+1), *(q+2));
2075         break;
2076     case 8:
2077         TRACE("%s [%04x] %08x %08x\n",
2078               header, i, *q, *(q+1));
2079         break;
2080     case 4:
2081         TRACE("%s [%04x] %08x\n",
2082               header, i, *q);
2083         break;
2084     default:
2085         break;
2086     }
2087 }
2088
2089 /***********************************************************************
2090  *           SPY_DumpStructure
2091  */
2092 void SPY_DumpStructure (SPY_INSTANCE *sp_e, BOOL enter)
2093 {
2094     switch (sp_e->msgnum)
2095         {
2096         case LVM_INSERTITEMW:
2097         case LVM_INSERTITEMA:
2098         case LVM_SETITEMW:
2099         case LVM_SETITEMA:
2100             if (!enter) break;
2101             /* fall through */
2102         case LVM_GETITEMW:
2103         case LVM_GETITEMA:
2104             {
2105                 LPLVITEMA item = (LPLVITEMA) sp_e->lParam;
2106                 if (item) {
2107                     SPY_DumpMem ("LVITEM", (UINT*)item, sizeof(LVITEMA));
2108                 }
2109                 break;
2110             }
2111         case TCM_INSERTITEMW:
2112         case TCM_INSERTITEMA:
2113         case TCM_SETITEMW:
2114         case TCM_SETITEMA:
2115             if (!enter) break;
2116             /* fall through */
2117         case TCM_GETITEMW:
2118         case TCM_GETITEMA:
2119             {
2120                 TCITEMA *item = (TCITEMA *) sp_e->lParam;
2121                 if (item) {
2122                     SPY_DumpMem ("TCITEM", (UINT*)item, sizeof(TCITEMA));
2123                 }
2124                 break;
2125             }
2126         case TCM_ADJUSTRECT:
2127         case LVM_GETITEMRECT:
2128         case LVM_GETSUBITEMRECT:
2129             {
2130                 LPRECT rc = (LPRECT) sp_e->lParam;
2131                 if (rc) {
2132                     TRACE("lParam rect (%ld,%ld)-(%ld,%ld)\n",
2133                           rc->left, rc->top, rc->right, rc->bottom);
2134                 }
2135                 break;
2136             }
2137         case LVM_SETITEMPOSITION32:
2138             if (!enter) break;
2139             /* fall through */
2140         case LVM_GETITEMPOSITION:
2141         case LVM_GETORIGIN:
2142             {
2143                 LPPOINT point = (LPPOINT) sp_e->lParam;
2144                 if (point) {
2145                     TRACE("lParam point x=%ld, y=%ld\n", point->x, point->y);
2146                 }
2147                 break;
2148             }
2149         case SBM_SETRANGE:
2150             if (!enter && (sp_e->msgnum == SBM_SETRANGE)) break;
2151             TRACE("min=%d max=%d\n", (INT)sp_e->wParam, (INT)sp_e->lParam);
2152             break;
2153         case SBM_GETRANGE:
2154             if ((enter && (sp_e->msgnum == SBM_GETRANGE)) ||
2155                 (!enter && (sp_e->msgnum == SBM_SETRANGE))) break;
2156             {
2157                 LPINT ptmin = (LPINT) sp_e->wParam;
2158                 LPINT ptmax = (LPINT) sp_e->lParam;
2159                 if (ptmin && ptmax)
2160                     TRACE("min=%d max=%d\n", *ptmin, *ptmax);
2161                 else if (ptmin)
2162                     TRACE("min=%d max=n/a\n", *ptmin);
2163                 else if (ptmax)
2164                     TRACE("min=n/a max=%d\n", *ptmax);
2165                 break;
2166             }
2167         case WM_DRAWITEM:
2168             if (!enter) break;
2169             {
2170                 DRAWITEMSTRUCT *lpdis = (DRAWITEMSTRUCT*) sp_e->lParam;
2171                 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
2172                       lpdis->CtlType, lpdis->CtlID);
2173                 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
2174                       lpdis->itemID, lpdis->itemAction, lpdis->itemState);
2175                 TRACE("hWnd=%p hDC=%p (%ld,%ld)-(%ld,%ld) itemData=0x%08lx\n",
2176                       lpdis->hwndItem, lpdis->hDC, lpdis->rcItem.left,
2177                       lpdis->rcItem.top, lpdis->rcItem.right,
2178                       lpdis->rcItem.bottom, lpdis->itemData);
2179             }
2180             break;
2181         case WM_MEASUREITEM:
2182             {
2183                 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*) sp_e->lParam;
2184                 TRACE("MEASUREITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
2185                       lpmis->CtlType, lpmis->CtlID);
2186                 TRACE("itemID=0x%08x itemWidth=0x%08x itemHeight=0x%08x\n",
2187                       lpmis->itemID, lpmis->itemWidth, lpmis->itemHeight);
2188                 TRACE("itemData=0x%08lx\n", lpmis->itemData);
2189             }
2190             break;
2191         case WM_SIZE:
2192             if (!enter) break;
2193             TRACE("cx=%d cy=%d\n", LOWORD(sp_e->lParam), HIWORD(sp_e->lParam));
2194             break;
2195         case WM_WINDOWPOSCHANGED:
2196             if (!enter) break;
2197         case WM_WINDOWPOSCHANGING:
2198             {
2199                 WINDOWPOS *lpwp = (WINDOWPOS *)sp_e->lParam;
2200                 TRACE("WINDOWPOS hwnd=%p, after=%p, at (%d,%d) w=%d h=%d, flags=0x%08x\n",
2201                       lpwp->hwnd, lpwp->hwndInsertAfter, lpwp->x, lpwp->y,
2202                       lpwp->cx, lpwp->cy, lpwp->flags);
2203             }
2204             break;
2205         case WM_STYLECHANGED:
2206             if (!enter) break;
2207         case WM_STYLECHANGING:
2208             {
2209                 LPSTYLESTRUCT ss = (LPSTYLESTRUCT) sp_e->lParam;
2210                 TRACE("STYLESTRUCT: StyleOld=0x%08lx, StyleNew=0x%08lx\n",
2211                       ss->styleOld, ss->styleNew);
2212             }
2213             break;
2214         case WM_NCCALCSIZE:
2215             {
2216                 RECT *rc = (RECT *)sp_e->lParam;
2217                 TRACE("Rect (%ld,%ld)-(%ld,%ld)\n",
2218                       rc->left, rc->top, rc->right, rc->bottom);
2219             }
2220             break;
2221         case WM_NOTIFY:
2222             /* if (!enter) break; */
2223             {
2224                 NMHDR * pnmh = (NMHDR*) sp_e->lParam;
2225                 UINT *q, dumplen;
2226                 const SPY_NOTIFY *p;
2227                 WCHAR from_class[60];
2228                 DWORD save_error;
2229
2230                 p = SPY_Bsearch_Notify (&spnfy_array[0], end_spnfy_array,
2231                                         pnmh->code);
2232                 if (p) {
2233                     TRACE("NMHDR hwndFrom=%p idFrom=0x%08x code=%s<0x%08x>, extra=0x%x\n",
2234                           pnmh->hwndFrom, pnmh->idFrom, p->name, pnmh->code, p->len);
2235                     dumplen = p->len;
2236
2237                     /* for CUSTOMDRAW, dump all the data for TOOLBARs */
2238                     if (pnmh->code == NM_CUSTOMDRAW) {
2239                         /* save and restore error code over the next call */
2240                         save_error = GetLastError();
2241                         GetClassNameW(pnmh->hwndFrom, from_class,
2242                                       sizeof(from_class)/sizeof(WCHAR));
2243                         SetLastError(save_error);
2244                         if (strcmpW(TOOLBARCLASSNAMEW, from_class) == 0)
2245                             dumplen = sizeof(NMTBCUSTOMDRAW)-sizeof(NMHDR);
2246                     }
2247                     if (dumplen > 0) {
2248                         q = (UINT *)(pnmh + 1);
2249                         SPY_DumpMem ("NM extra", q, (INT)dumplen);
2250                     }
2251                 }
2252                 else
2253                     TRACE("NMHDR hwndFrom=%p idFrom=0x%08x code=0x%08x\n",
2254                           pnmh->hwndFrom, pnmh->idFrom, pnmh->code);
2255             }
2256         default:
2257             if (sp_e->data_len > 0)
2258                 SPY_DumpMem ("MSG lParam", (UINT *)sp_e->lParam, sp_e->data_len);
2259             break;
2260         }
2261
2262 }
2263 /***********************************************************************
2264  *           SPY_EnterMessage
2265  */
2266 void SPY_EnterMessage( INT iFlag, HWND hWnd, UINT msg,
2267                        WPARAM wParam, LPARAM lParam )
2268 {
2269     SPY_INSTANCE sp_e;
2270     int indent;
2271
2272     if (!TRACE_ON(message) || SPY_EXCLUDE(msg)) return;
2273
2274     sp_e.msgnum = msg;
2275     sp_e.msg_hwnd   = hWnd;
2276     sp_e.lParam = lParam;
2277     sp_e.wParam = wParam;
2278     SPY_GetWndName(&sp_e);
2279     SPY_GetMsgStuff(&sp_e);
2280     indent = get_indent_level();
2281
2282     /* each SPY_SENDMESSAGE must be complemented by call to SPY_ExitMessage */
2283     switch(iFlag)
2284     {
2285     case SPY_DISPATCHMESSAGE16:
2286         TRACE("%*s(%04x) %-16s message [%04x] %s dispatched  wp=%04x lp=%08lx\n",
2287               indent, "", HWND_16(hWnd),
2288               debugstr_w(sp_e.wnd_name), msg, sp_e.msg_name, wParam, lParam);
2289         break;
2290
2291     case SPY_DISPATCHMESSAGE:
2292         TRACE("%*s(%p) %-16s message [%04x] %s dispatched  wp=%08x lp=%08lx\n",
2293                         indent, "", hWnd, debugstr_w(sp_e.wnd_name), msg,
2294                         sp_e.msg_name, wParam, lParam);
2295         break;
2296
2297     case SPY_SENDMESSAGE16:
2298     case SPY_SENDMESSAGE:
2299         {
2300             char taskName[20];
2301             DWORD tid = GetWindowThreadProcessId( hWnd, NULL );
2302
2303             if (tid == GetCurrentThreadId()) strcpy( taskName, "self" );
2304             else sprintf( taskName, "tid %04lx", GetCurrentThreadId() );
2305
2306             if (iFlag == SPY_SENDMESSAGE16)
2307                 TRACE("%*s(%04x) %-16s message [%04x] %s sent from %s wp=%04x lp=%08lx\n",
2308                       indent, "", HWND_16(hWnd), debugstr_w(sp_e.wnd_name), msg,
2309                       sp_e.msg_name, taskName, wParam, lParam );
2310             else
2311             {   TRACE("%*s(%p) %-16s message [%04x] %s sent from %s wp=%08x lp=%08lx\n",
2312                              indent, "", hWnd, debugstr_w(sp_e.wnd_name), msg,
2313                              sp_e.msg_name, taskName, wParam, lParam );
2314                 SPY_DumpStructure(&sp_e, TRUE);
2315             }
2316         }
2317         break;
2318
2319     case SPY_DEFWNDPROC16:
2320         if( SPY_ExcludeDWP ) return;
2321         TRACE("%*s(%04x)  DefWindowProc16: %s [%04x]  wp=%04x lp=%08lx\n",
2322               indent, "", HWND_16(hWnd), sp_e.msg_name, msg, wParam, lParam );
2323         break;
2324
2325     case SPY_DEFWNDPROC:
2326         if( SPY_ExcludeDWP ) return;
2327         TRACE("%*s(%p)  DefWindowProc32: %s [%04x]  wp=%08x lp=%08lx\n",
2328                         indent, "", hWnd, sp_e.msg_name,
2329                         msg, wParam, lParam );
2330         break;
2331     }
2332     set_indent_level( indent + SPY_INDENT_UNIT );
2333 }
2334
2335
2336 /***********************************************************************
2337  *           SPY_ExitMessage
2338  */
2339 void SPY_ExitMessage( INT iFlag, HWND hWnd, UINT msg, LRESULT lReturn,
2340                        WPARAM wParam, LPARAM lParam )
2341 {
2342     SPY_INSTANCE sp_e;
2343     int indent;
2344
2345     if (!TRACE_ON(message) || SPY_EXCLUDE(msg) ||
2346         (SPY_ExcludeDWP && (iFlag == SPY_RESULT_DEFWND16 || iFlag == SPY_RESULT_DEFWND)) )
2347         return;
2348
2349     sp_e.msgnum = msg;
2350     sp_e.msg_hwnd   = hWnd;
2351     sp_e.lParam = lParam;
2352     sp_e.wParam = wParam;
2353     SPY_GetWndName(&sp_e);
2354     SPY_GetMsgStuff(&sp_e);
2355
2356     if ((indent = get_indent_level()))
2357     {
2358         indent -= SPY_INDENT_UNIT;
2359         set_indent_level( indent );
2360     }
2361
2362     switch(iFlag)
2363     {
2364     case SPY_RESULT_DEFWND16:
2365         TRACE(" %*s(%04x)  DefWindowProc16: %s [%04x] returned %08lx\n",
2366               indent, "", HWND_16(hWnd), sp_e.msg_name, msg, lReturn );
2367         break;
2368
2369     case SPY_RESULT_DEFWND:
2370         TRACE(" %*s(%p)  DefWindowProc32: %s [%04x] returned %08lx\n",
2371                         indent, "", hWnd, sp_e.msg_name, msg, lReturn );
2372         break;
2373
2374     case SPY_RESULT_OK16:
2375         TRACE(" %*s(%04x) %-16s message [%04x] %s returned %08lx\n",
2376               indent, "", HWND_16(hWnd), debugstr_w(sp_e.wnd_name), msg,
2377               sp_e.msg_name, lReturn );
2378         break;
2379
2380     case SPY_RESULT_OK:
2381         TRACE(" %*s(%p) %-16s message [%04x] %s returned %08lx\n",
2382                         indent, "", hWnd, debugstr_w(sp_e.wnd_name), msg,
2383                         sp_e.msg_name, lReturn );
2384         SPY_DumpStructure(&sp_e, FALSE);
2385         break;
2386
2387     case SPY_RESULT_INVALIDHWND16:
2388         WARN(" %*s(%04x) %-16s message [%04x] %s HAS INVALID HWND\n",
2389              indent, "", HWND_16(hWnd), debugstr_w(sp_e.wnd_name), msg, sp_e.msg_name );
2390         break;
2391
2392     case SPY_RESULT_INVALIDHWND:
2393         WARN(" %*s(%p) %-16s message [%04x] %s HAS INVALID HWND\n",
2394                         indent, "", hWnd, debugstr_w(sp_e.wnd_name), msg,
2395                         sp_e.msg_name );
2396         break;
2397    }
2398 }
2399
2400
2401 /***********************************************************************
2402  *           SPY_Init
2403  */
2404 int SPY_Init(void)
2405 {
2406     int i, j;
2407     char buffer[1024];
2408     const SPY_NOTIFY *p;
2409     const USER_MSG *q;
2410     HKEY hkey;
2411
2412     if (!TRACE_ON(message)) return TRUE;
2413
2414     indent_tls_index = TlsAlloc();
2415     if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Debug", &hkey))
2416     {
2417         DWORD type, count = sizeof(buffer);
2418
2419         buffer[0] = 0;
2420         if (!RegQueryValueExA(hkey, "SpyInclude", 0, &type, buffer, &count) &&
2421             strcmp( buffer, "INCLUDEALL" ))
2422         {
2423             TRACE("Include=%s\n", buffer );
2424             for (i = 0; i <= SPY_MAX_MSGNUM; i++)
2425                 SPY_Exclude[i] = (MessageTypeNames[i] && !strstr(buffer,MessageTypeNames[i]));
2426         }
2427
2428         count = sizeof(buffer);
2429         buffer[0] = 0;
2430         if (!RegQueryValueExA(hkey, "SpyExclude", 0, &type, buffer, &count))
2431         {
2432             TRACE("Exclude=%s\n", buffer );
2433             if (!strcmp( buffer, "EXCLUDEALL" ))
2434                 for (i = 0; i <= SPY_MAX_MSGNUM; i++) SPY_Exclude[i] = TRUE;
2435             else
2436                 for (i = 0; i <= SPY_MAX_MSGNUM; i++)
2437                     SPY_Exclude[i] = (MessageTypeNames[i] && strstr(buffer,MessageTypeNames[i]));
2438         }
2439
2440         SPY_ExcludeDWP = 0;
2441         count = sizeof(buffer);
2442         if(!RegQueryValueExA(hkey, "SpyExcludeDWP", 0, &type, buffer, &count))
2443             SPY_ExcludeDWP = atoi(buffer);
2444
2445         RegCloseKey(hkey);
2446     }
2447
2448     /* find last good entry in spy notify array and save addr for b-search */
2449     p = &spnfy_array[0];
2450     j = 0xffffffff;
2451     while (p->name) {
2452         if ((UINT)p->value > (UINT)j) {
2453             ERR("Notify message array out of order\n");
2454             ERR("  between values [%08x] %s and [%08x] %s\n",
2455                 j, (p-1)->name, p->value, p->name);
2456             break;
2457         }
2458         j = p->value;
2459         p++;
2460     }
2461     p--;
2462     end_spnfy_array = p;
2463
2464     /* find last good entry in each common control message array
2465      *  and save addr for b-search.
2466      */
2467     i = 0;
2468     while (cc_array[i].classname) {
2469
2470         j = 0x0400; /* minimum entry in array */
2471         q = cc_array[i].classmsg;
2472         while(q->name) {
2473             if (q->value <= j) {
2474                 ERR("Class message array out of order for class %s\n",
2475                     debugstr_w(cc_array[i].classname));
2476                 ERR("  between values [%04x] %s and [%04x] %s\n",
2477                     j, (q-1)->name, q->value, q->name);
2478                 break;
2479             }
2480             j = q->value;
2481             q++;
2482         }
2483         q--;
2484         cc_array[i].lastmsg = (USER_MSG *)q;
2485
2486         i++;
2487     }
2488
2489     return 1;
2490 }