NetSurf
windbg.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <windows.h>
20#include <stdio.h>
21
22#include "windbg.h"
23
24const char *msg_num_to_name(int msg)
25{
26 static char str[256];
27
28 switch (msg) {
29 case 32768:
30 return "WM_APP";
31
32 case 6:
33 return "WM_ACTIVATE ";
34
35 case 28:
36 return "WM_ACTIVATEAPP ";
37
38 case 864:
39 return "WM_AFXFIRST ";
40
41 case 895:
42 return "WM_AFXLAST ";
43
44 case 780:
45 return "WM_ASKCBFORMATNAME ";
46
47 case 75:
48 return "WM_CANCELJOURNAL ";
49
50 case 31:
51 return "WM_CANCELMODE ";
52
53 case 533:
54 return "WM_CAPTURECHANGED ";
55
56 case 781:
57 return "WM_CHANGECBCHAIN ";
58
59 case 258:
60 return "WM_CHAR ";
61
62 case 47:
63 return "WM_CHARTOITEM ";
64
65 case 34:
66 return "WM_CHILDACTIVATE ";
67
68 case 771:
69 return "WM_CLEAR ";
70
71 case 16:
72 return "WM_CLOSE ";
73
74 case 273:
75 return "WM_COMMAND ";
76
77 case 68:
78 return "WM_COMMNOTIFY ";
79
80 case 65:
81 return "WM_COMPACTING ";
82
83 case 57:
84 return "WM_COMPAREITEM ";
85
86 case 123:
87 return "WM_CONTEXTMENU ";
88
89 case 769:
90 return "WM_COPY ";
91
92 case 74:
93 return "WM_COPYDATA ";
94
95 case 1:
96 return "WM_CREATE ";
97
98 case 309:
99 return "WM_CTLCOLORBTN ";
100
101 case 310:
102 return "WM_CTLCOLORDLG ";
103
104 case 307:
105 return "WM_CTLCOLOREDIT ";
106
107 case 308:
108 return "WM_CTLCOLORLISTBOX ";
109
110 case 306:
111 return "WM_CTLCOLORMSGBOX ";
112
113 case 311:
114 return "WM_CTLCOLORSCROLLBAR ";
115
116 case 312:
117 return "WM_CTLCOLORSTATIC ";
118
119 case 768:
120 return "WM_CUT ";
121
122 case 259:
123 return "WM_DEADCHAR ";
124
125 case 45:
126 return "WM_DELETEITEM ";
127
128 case 2:
129 return "WM_DESTROY ";
130
131 case 775:
132 return "WM_DESTROYCLIPBOARD ";
133
134 case 537:
135 return "WM_DEVICECHANGE ";
136
137 case 27:
138 return "WM_DEVMODECHANGE ";
139
140 case 126:
141 return "WM_DISPLAYCHANGE ";
142
143 case 776:
144 return "WM_DRAWCLIPBOARD ";
145
146 case 43:
147 return "WM_DRAWITEM ";
148
149 case 563:
150 return "WM_DROPFILES ";
151
152 case 10:
153 return "WM_ENABLE ";
154
155 case 22:
156 return "WM_ENDSESSION ";
157
158 case 289:
159 return "WM_ENTERIDLE ";
160
161 case 529:
162 return "WM_ENTERMENULOOP ";
163
164 case 561:
165 return "WM_ENTERSIZEMOVE ";
166
167 case 20:
168 return "WM_ERASEBKGND ";
169
170 case 530:
171 return "WM_EXITMENULOOP ";
172
173 case 562:
174 return "WM_EXITSIZEMOVE ";
175
176 case 29:
177 return "WM_FONTCHANGE ";
178
179 case 135:
180 return "WM_GETDLGCODE ";
181
182 case 49:
183 return "WM_GETFONT ";
184
185 case 51:
186 return "WM_GETHOTKEY ";
187
188 case 127:
189 return "WM_GETICON ";
190
191 case 36:
192 return "WM_GETMINMAXINFO ";
193
194 case 13:
195 return "WM_GETTEXT ";
196
197 case 14:
198 return "WM_GETTEXTLENGTH ";
199
200 case 856:
201 return "WM_HANDHELDFIRST ";
202
203 case 863:
204 return "WM_HANDHELDLAST ";
205
206 case 83:
207 return "WM_HELP ";
208
209 case 786:
210 return "WM_HOTKEY ";
211
212 case 276:
213 return "WM_HSCROLL ";
214
215 case 782:
216 return "WM_HSCROLLCLIPBOARD ";
217
218 case 39:
219 return "WM_ICONERASEBKGND ";
220
221 case 272:
222 return "WM_INITDIALOG ";
223
224 case 278:
225 return "WM_INITMENU ";
226
227 case 279:
228 return "WM_INITMENUPOPUP ";
229
230 case 0x00FF:
231 return "WM_INPUT ";
232
233 case 81:
234 return "WM_INPUTLANGCHANGE ";
235
236 case 80:
237 return "WM_INPUTLANGCHANGEREQUEST ";
238
239 case 256:
240 return "WM_KEYDOWN ";
241
242 case 257:
243 return "WM_KEYUP ";
244
245 case 8:
246 return "WM_KILLFOCUS ";
247
248 case 546:
249 return "WM_MDIACTIVATE ";
250
251 case 551:
252 return "WM_MDICASCADE ";
253
254 case 544:
255 return "WM_MDICREATE ";
256
257 case 545:
258 return "WM_MDIDESTROY ";
259
260 case 553:
261 return "WM_MDIGETACTIVE ";
262
263 case 552:
264 return "WM_MDIICONARRANGE ";
265
266 case 549:
267 return "WM_MDIMAXIMIZE ";
268
269 case 548:
270 return "WM_MDINEXT ";
271
272 case 564:
273 return "WM_MDIREFRESHMENU ";
274
275 case 547:
276 return "WM_MDIRESTORE ";
277
278 case 560:
279 return "WM_MDISETMENU ";
280
281 case 550:
282 return "WM_MDITILE ";
283
284 case 44:
285 return "WM_MEASUREITEM ";
286
287 case 0x003D:
288 return "WM_GETOBJECT ";
289
290 case 0x0127:
291 return "WM_CHANGEUISTATE ";
292
293 case 0x0128:
294 return "WM_UPDATEUISTATE ";
295
296 case 0x0129:
297 return "WM_QUERYUISTATE ";
298
299 case 0x0125:
300 return "WM_UNINITMENUPOPUP ";
301
302 case 290:
303 return "WM_MENURBUTTONUP ";
304
305 case 0x0126:
306 return "WM_MENUCOMMAND ";
307
308 case 0x0124:
309 return "WM_MENUGETOBJECT ";
310
311 case 0x0123:
312 return "WM_MENUDRAG ";
313
314 case 0x0319:
315 return "WM_APPCOMMAND ";
316
317 case 288:
318 return "WM_MENUCHAR ";
319
320 case 287:
321 return "WM_MENUSELECT ";
322
323 case 531:
324 return "WM_NEXTMENU ";
325
326 case 3:
327 return "WM_MOVE ";
328
329 case 534:
330 return "WM_MOVING ";
331
332 case 134:
333 return "WM_NCACTIVATE ";
334
335 case 131:
336 return "WM_NCCALCSIZE ";
337
338 case 129:
339 return "WM_NCCREATE ";
340
341 case 130:
342 return "WM_NCDESTROY ";
343
344 case 132:
345 return "WM_NCHITTEST ";
346
347 case 163:
348 return "WM_NCLBUTTONDBLCLK ";
349
350 case 161:
351 return "WM_NCLBUTTONDOWN ";
352
353 case 162:
354 return "WM_NCLBUTTONUP ";
355
356 case 169:
357 return "WM_NCMBUTTONDBLCLK ";
358
359 case 167:
360 return "WM_NCMBUTTONDOWN ";
361
362 case 168:
363 return "WM_NCMBUTTONUP ";
364
365 case 171:
366 return "WM_NCXBUTTONDOWN ";
367
368 case 172:
369 return "WM_NCXBUTTONUP ";
370
371 case 173:
372 return "WM_NCXBUTTONDBLCLK ";
373
374 case 0x02A0:
375 return "WM_NCMOUSEHOVER ";
376
377 case 0x02A2:
378 return "WM_NCMOUSELEAVE ";
379
380 case 160:
381 return "WM_NCMOUSEMOVE ";
382
383 case 133:
384 return "WM_NCPAINT ";
385
386 case 166:
387 return "WM_NCRBUTTONDBLCLK ";
388
389 case 164:
390 return "WM_NCRBUTTONDOWN ";
391
392 case 165:
393 return "WM_NCRBUTTONUP ";
394
395 case 40:
396 return "WM_NEXTDLGCTL ";
397
398 case 78:
399 return "WM_NOTIFY ";
400
401 case 85:
402 return "WM_NOTIFYFORMAT ";
403
404 case 0:
405 return "WM_NULL ";
406
407 case 15:
408 return "WM_PAINT ";
409
410 case 777:
411 return "WM_PAINTCLIPBOARD ";
412
413 case 38:
414 return "WM_PAINTICON ";
415
416 case 785:
417 return "WM_PALETTECHANGED ";
418
419 case 784:
420 return "WM_PALETTEISCHANGING ";
421
422 case 528:
423 return "WM_PARENTNOTIFY ";
424
425 case 770:
426 return "WM_PASTE ";
427
428 case 896:
429 return "WM_PENWINFIRST ";
430
431 case 911:
432 return "WM_PENWINLAST ";
433
434 case 72:
435 return "WM_POWER ";
436
437 case 536:
438 return "WM_POWERBROADCAST ";
439
440 case 791:
441 return "WM_PRINT ";
442
443 case 792:
444 return "WM_PRINTCLIENT ";
445
446 case 55:
447 return "WM_QUERYDRAGICON ";
448
449 case 17:
450 return "WM_QUERYENDSESSION ";
451
452 case 783:
453 return "WM_QUERYNEWPALETTE ";
454
455 case 19:
456 return "WM_QUERYOPEN ";
457
458 case 35:
459 return "WM_QUEUESYNC ";
460
461 case 18:
462 return "WM_QUIT ";
463
464 case 774:
465 return "WM_RENDERALLFORMATS ";
466
467 case 773:
468 return "WM_RENDERFORMAT ";
469
470 case 32:
471 return "WM_SETCURSOR ";
472
473 case 7:
474 return "WM_SETFOCUS ";
475
476 case 48:
477 return "WM_SETFONT ";
478
479 case 50:
480 return "WM_SETHOTKEY ";
481
482 case 128:
483 return "WM_SETICON ";
484
485 case 11:
486 return "WM_SETREDRAW ";
487
488 case 12:
489 return "WM_SETTEXT ";
490
491 case 26:
492 return "WM_SETTINGCHANGE ";
493
494 case 24:
495 return "WM_SHOWWINDOW ";
496
497 case 5:
498 return "WM_SIZE ";
499
500 case 779:
501 return "WM_SIZECLIPBOARD ";
502
503 case 532:
504 return "WM_SIZING ";
505
506 case 42:
507 return "WM_SPOOLERSTATUS ";
508
509 case 125:
510 return "WM_STYLECHANGED ";
511
512 case 124:
513 return "WM_STYLECHANGING ";
514
515 case 262:
516 return "WM_SYSCHAR ";
517
518 case 21:
519 return "WM_SYSCOLORCHANGE ";
520
521 case 274:
522 return "WM_SYSCOMMAND ";
523
524 case 263:
525 return "WM_SYSDEADCHAR ";
526
527 case 260:
528 return "WM_SYSKEYDOWN ";
529
530 case 261:
531 return "WM_SYSKEYUP ";
532
533 case 82:
534 return "WM_TCARD ";
535
536 case 794:
537 return "WM_THEMECHANGED ";
538
539 case 30:
540 return "WM_TIMECHANGE ";
541
542 case 275:
543 return "WM_TIMER ";
544
545 case 772:
546 return "WM_UNDO ";
547
548 case 1024:
549 return "WM_USER ";
550
551 case 84:
552 return "WM_USERCHANGED ";
553
554 case 46:
555 return "WM_VKEYTOITEM ";
556
557 case 277:
558 return "WM_VSCROLL ";
559
560 case 778:
561 return "WM_VSCROLLCLIPBOARD ";
562
563 case 71:
564 return "WM_WINDOWPOSCHANGED ";
565
566 case 70:
567 return "WM_WINDOWPOSCHANGING ";
568
569 case 264:
570 return "WM_KEYLAST ";
571
572 case 136:
573 return "WM_SYNCPAINT ";
574
575 case 33:
576 return "WM_MOUSEACTIVATE ";
577
578 case 512:
579 return "WM_MOUSEMOVE ";
580
581 case 513:
582 return "WM_LBUTTONDOWN ";
583
584 case 514:
585 return "WM_LBUTTONUP ";
586
587 case 515:
588 return "WM_LBUTTONDBLCLK ";
589
590 case 516:
591 return "WM_RBUTTONDOWN ";
592
593 case 517:
594 return "WM_RBUTTONUP ";
595
596 case 518:
597 return "WM_RBUTTONDBLCLK ";
598
599 case 519:
600 return "WM_MBUTTONDOWN ";
601
602 case 520:
603 return "WM_MBUTTONUP ";
604
605 case 521:
606 return "WM_MBUTTONDBLCLK ";
607
608 case 522:
609 return "WM_MOUSEWHEEL ";
610
611 case 523:
612 return "WM_XBUTTONDOWN ";
613
614 case 524:
615 return "WM_XBUTTONUP ";
616
617 case 525:
618 return "WM_XBUTTONDBLCLK ";
619
620 case 0x2A1:
621 return "WM_MOUSEHOVER ";
622
623 case 0x2A3:
624 return "WM_MOUSELEAVE ";
625
626 }
627
628 sprintf(str,"%d",msg);
629
630 return str;
631}
632
633void win_perror(const char * lpszFunction)
634{
635 /* Retrieve the system error message for the last-error code */
636
637 LPVOID lpMsgBuf;
638 LPVOID lpDisplayBuf;
639 DWORD dw = GetLastError();
640
641 FormatMessage(
642 FORMAT_MESSAGE_ALLOCATE_BUFFER |
643 FORMAT_MESSAGE_FROM_SYSTEM |
644 FORMAT_MESSAGE_IGNORE_INSERTS,
645 NULL,
646 dw,
647 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
648 (LPTSTR) &lpMsgBuf,
649 0, NULL );
650
651 /* Display the error message and exit the process */
652
653 lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR));
654
655 snprintf((LPTSTR)lpDisplayBuf,
656 LocalSize(lpDisplayBuf) / sizeof(TCHAR),
657 TEXT("%s failed with error %ld: %s"),
658 lpszFunction, dw, (char *)lpMsgBuf);
659 MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
660
661 LocalFree(lpMsgBuf);
662 LocalFree(lpDisplayBuf);
663}
const char * msg_num_to_name(int msg)
Definition: windbg.c:24
void win_perror(const char *lpszFunction)
Definition: windbg.c:633