Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.0 KiB

  1. //-----------------------------------------------------------------------------
  2. #include "precomp.h"
  3. #pragma hdrstop
  4. extern "C"
  5. {
  6. #include <stdexts.h>
  7. #include <dbgeng.h>
  8. #include <commctrl.h>
  9. #include <comctrlp.h>
  10. #include "msgs.h"
  11. };
  12. //-----------------------------------------------------------------------------
  13. void PrintUser32Message(UINT uMsg)
  14. {
  15. IDebugClient* pDebugClient;
  16. IDebugControl* pDebugControl;
  17. if (SUCCEEDED(DebugCreate(__uuidof(IDebugClient), (void**)&pDebugClient)))
  18. {
  19. if (SUCCEEDED(pDebugClient->QueryInterface(__uuidof(IDebugControl), (void**)&pDebugControl)))
  20. {
  21. // Try calling the wm extension from userexts.dll
  22. ULONG64 ulExtension = 0;
  23. CHAR szMsg[64];
  24. pDebugControl->AddExtension("userexts", DEBUG_EXTENSION_AT_ENGINE, &ulExtension);
  25. pDebugControl->CallExtension(ulExtension, "wm", _itoa(uMsg, szMsg, 16));
  26. pDebugControl->Release();
  27. }
  28. pDebugClient->Release();
  29. }
  30. }
  31. //-----------------------------------------------------------------------------
  32. void PrintRegisteredMessage(UINT uMsg)
  33. {
  34. CHAR szMsg[64];
  35. if (GetClipboardFormatNameA(uMsg, szMsg, ARRAYSIZE(szMsg)))
  36. {
  37. Print(" %x %s\n", uMsg, szMsg);
  38. }
  39. else
  40. {
  41. Print(" %x ???\n", uMsg);
  42. }
  43. }
  44. //-----------------------------------------------------------------------------
  45. void PrintComctl32Message(UINT uMsg, HWND hwnd)
  46. {
  47. BOOL fMatchClass = FALSE;
  48. BOOL fFound = FALSE;
  49. CHAR szClassName[64];
  50. if (hwnd && IsWindow(hwnd))
  51. {
  52. if (GetClassNameA(hwnd, szClassName, ARRAYSIZE(szClassName)))
  53. {
  54. fMatchClass = TRUE;
  55. }
  56. }
  57. for (int i = 0; !IsCtrlCHit() && (i < ARRAYSIZE(rgMsgMap)); i++)
  58. {
  59. if ((i > 0) && // always execute first iteration, contains msgs common to all
  60. (fMatchClass && (_stricmp(szClassName, rgMsgMap[i].szClassName) != 0)))
  61. {
  62. continue;
  63. }
  64. int j;
  65. MSGNAME* pmm;
  66. for (j = 0, pmm = rgMsgMap[i].rgMsgName; !IsCtrlCHit() && (j < rgMsgMap[i].chMsgName); j++)
  67. {
  68. if (pmm[j].uMsg == uMsg)
  69. {
  70. Print(" %x %-25s%s\n", pmm[j].uMsg, pmm[j].szMsg, fMatchClass ? "" : rgMsgMap[i].szFriendlyClassName);
  71. fFound = TRUE;
  72. break;
  73. }
  74. }
  75. }
  76. if (!fFound)
  77. {
  78. Print(" %x ???\n", uMsg);
  79. }
  80. }
  81. //-----------------------------------------------------------------------------
  82. void PrintWindowMessageEx(UINT uMsg, HWND hwnd)
  83. {
  84. if (uMsg <= WM_USER)
  85. {
  86. PrintUser32Message(uMsg);
  87. }
  88. else if (uMsg >= 0xC000)
  89. {
  90. PrintRegisteredMessage(uMsg);
  91. }
  92. else
  93. {
  94. PrintComctl32Message(uMsg, hwnd);
  95. }
  96. }
  97. //-----------------------------------------------------------------------------
  98. extern "C" BOOL Iwmex(DWORD dwOpts, LPVOID pArg1, LPVOID pArg2)
  99. {
  100. PrintWindowMessageEx(PtrToUint(pArg1), (HWND)(HWND *)pArg2);
  101. return TRUE;
  102. }