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.

328 lines
14 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. trdebug.c
  5. Abstract: This module contains all the debug functions.
  6. Environment:
  7. User mode
  8. Author:
  9. Michael Tsang (MikeTs) 13-Mar-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef TRDEBUG
  14. int giTRVerboseLevel = 0;
  15. NAMETABLE WMMsgNames[] =
  16. {
  17. WM_NULL, "Null",
  18. WM_CREATE, "Create",
  19. WM_DESTROY, "Destroy",
  20. WM_MOVE, "Move",
  21. WM_SIZE, "Size",
  22. WM_ACTIVATE, "Activate",
  23. WM_SETFOCUS, "SetFocus",
  24. WM_KILLFOCUS, "KillFocus",
  25. WM_ENABLE, "Enable",
  26. WM_SETREDRAW, "SetRedraw",
  27. WM_SETTEXT, "SetText",
  28. WM_GETTEXT, "GetText",
  29. WM_GETTEXTLENGTH, "GetTextLen",
  30. WM_PAINT, "Paint",
  31. WM_CLOSE, "Close",
  32. WM_QUERYENDSESSION, "QueryEndSession",
  33. WM_QUERYOPEN, "QueryOpen",
  34. WM_ENDSESSION, "EndSession",
  35. WM_QUIT, "Quit",
  36. WM_ERASEBKGND, "EraseBackground",
  37. WM_SYSCOLORCHANGE, "SysColorChange",
  38. WM_SHOWWINDOW, "ShowWindow",
  39. WM_WININICHANGE, "WinIniChange",
  40. WM_SETTINGCHANGE, "SettingChange",
  41. WM_DEVMODECHANGE, "DevModeChange",
  42. WM_ACTIVATEAPP, "ActivateApp",
  43. WM_FONTCHANGE, "FontChange",
  44. WM_TIMECHANGE, "TimeChange",
  45. WM_CANCELMODE, "CancelMode",
  46. WM_SETCURSOR, "SetCursor",
  47. WM_MOUSEACTIVATE, "MouseActivate",
  48. WM_CHILDACTIVATE, "ChildActivate",
  49. WM_QUEUESYNC, "QueueSync",
  50. WM_GETMINMAXINFO, "GetMinMaxInfo",
  51. WM_PAINTICON, "PaintIcon",
  52. WM_ICONERASEBKGND, "IconEraseBackground",
  53. WM_NEXTDLGCTL, "NextDialogControl",
  54. WM_SPOOLERSTATUS, "SpoolerStatus",
  55. WM_DRAWITEM, "DrawItem",
  56. WM_MEASUREITEM, "MeasureItem",
  57. WM_DELETEITEM, "DeleteItem",
  58. WM_VKEYTOITEM, "VKeyToItem",
  59. WM_CHARTOITEM, "CharToItem",
  60. WM_SETFONT, "SetFont",
  61. WM_GETFONT, "GetFont",
  62. WM_SETHOTKEY, "SetHotKey",
  63. WM_GETHOTKEY, "GetHotKey",
  64. WM_QUERYDRAGICON, "QueryDragIcon",
  65. WM_COMPAREITEM, "CompareItem",
  66. WM_GETOBJECT, "GetObject",
  67. WM_COMPACTING, "Compacting",
  68. WM_COMMNOTIFY, "CommNotify",
  69. WM_WINDOWPOSCHANGING, "WindowPosChanging",
  70. WM_WINDOWPOSCHANGED, "WindowPosChanged",
  71. WM_POWER, "Power",
  72. WM_COPYDATA, "CopyData",
  73. WM_CANCELJOURNAL, "CancelJournal",
  74. WM_NOTIFY, "Notify",
  75. WM_INPUTLANGCHANGEREQUEST, "InputLangChangeRequest",
  76. WM_INPUTLANGCHANGE, "InputLangChange",
  77. WM_TCARD, "TCard",
  78. WM_HELP, "Help",
  79. WM_USERCHANGED, "UserChanged",
  80. WM_NOTIFYFORMAT, "NotifyFormat",
  81. WM_CONTEXTMENU, "ContextMenu",
  82. WM_STYLECHANGING, "StyleChanging",
  83. WM_STYLECHANGED, "StyleChanged",
  84. WM_DISPLAYCHANGE, "DisplayChange",
  85. WM_GETICON, "GetIcon",
  86. WM_SETICON, "SetIcon",
  87. WM_NCCREATE, "NCCreate",
  88. WM_NCDESTROY, "NCDestroy",
  89. WM_NCCALCSIZE, "NCCalcSize",
  90. WM_NCHITTEST, "NCHitTest",
  91. WM_NCPAINT, "NCPaint",
  92. WM_NCACTIVATE, "NCActivate",
  93. WM_GETDLGCODE, "GetDialogCode",
  94. WM_SYNCPAINT, "SyncPaint",
  95. WM_NCMOUSEMOVE, "NCMouseMove",
  96. WM_NCLBUTTONDOWN, "NCLeftButtonDown",
  97. WM_NCLBUTTONUP, "NCLeftButtonUp",
  98. WM_NCLBUTTONDBLCLK, "NCLeftButtonDoubleClick",
  99. WM_NCRBUTTONDOWN, "NCRightButtonDown",
  100. WM_NCRBUTTONUP, "NCRightButtonUp",
  101. WM_NCRBUTTONDBLCLK, "NCRightButtonDoubleClick",
  102. WM_NCMBUTTONDOWN, "NCMiddleButtonDown",
  103. WM_NCMBUTTONUP, "NCMiddleButtonUp",
  104. WM_NCMBUTTONDBLCLK, "NCMiddleButtonDoubleClick",
  105. WM_NCXBUTTONDOWN, "NCXButtonDown",
  106. WM_NCXBUTTONUP, "NCXButtonUp",
  107. WM_NCXBUTTONDBLCLK, "NCXButtonDoubleClick",
  108. WM_KEYFIRST, "KeyFirst",
  109. WM_KEYDOWN, "KeyDown",
  110. WM_KEYUP, "KeyUp",
  111. WM_CHAR, "Char",
  112. WM_DEADCHAR, "DeadChar",
  113. WM_SYSKEYDOWN, "SysKeyDown",
  114. WM_SYSKEYUP, "SysKeyUp",
  115. WM_SYSCHAR, "SysChar",
  116. WM_SYSDEADCHAR, "SysDeadChar",
  117. WM_KEYLAST, "KeyLast",
  118. WM_IME_STARTCOMPOSITION, "IMEStartComposition",
  119. WM_IME_ENDCOMPOSITION, "IMEEndComposition",
  120. WM_IME_COMPOSITION, "IMEComposition",
  121. WM_IME_KEYLAST, "IMEKeyLast",
  122. WM_INITDIALOG, "InitDialog",
  123. WM_COMMAND, "Command",
  124. WM_SYSCOMMAND, "SysCommand",
  125. WM_TIMER, "Timer",
  126. WM_HSCROLL, "HScroll",
  127. WM_VSCROLL, "VScroll",
  128. WM_INITMENU, "InitMenu",
  129. WM_INITMENUPOPUP, "InitMenuPopup",
  130. WM_MENUSELECT, "MenuSelect",
  131. WM_MENUCHAR, "MenuChar",
  132. WM_ENTERIDLE, "EnterIdle",
  133. WM_MENURBUTTONUP, "MenuRightButtonUp",
  134. WM_MENUDRAG, "MenuDrag",
  135. WM_MENUGETOBJECT, "MenuGetObject",
  136. WM_UNINITMENUPOPUP, "UninitMenuPopup",
  137. WM_MENUCOMMAND, "MenuCommand",
  138. WM_CHANGEUISTATE, "ChangeUIState",
  139. WM_UPDATEUISTATE, "UpdateUIState",
  140. WM_QUERYUISTATE, "QueryUIState",
  141. WM_CTLCOLORMSGBOX, "CtlColorMsgBox",
  142. WM_CTLCOLOREDIT, "CtlColorEdit",
  143. WM_CTLCOLORLISTBOX, "CtlColorListBox",
  144. WM_CTLCOLORBTN, "CtlColorButton",
  145. WM_CTLCOLORDLG, "CtlColorDialog",
  146. WM_CTLCOLORSCROLLBAR, "CtlColorScrollBar",
  147. WM_CTLCOLORSTATIC, "CtlColorStatic",
  148. WM_MOUSEFIRST, "MouseFirst",
  149. WM_MOUSEMOVE, "MouseMove",
  150. WM_LBUTTONDOWN, "LeftButtonDown",
  151. WM_LBUTTONUP, "LeftButtonUp",
  152. WM_LBUTTONDBLCLK, "LeftButtonDoubleClick",
  153. WM_RBUTTONDOWN, "RightButtonDown",
  154. WM_RBUTTONUP, "RightButtonUp",
  155. WM_RBUTTONDBLCLK, "RightButtonDoubleClick",
  156. WM_MBUTTONDOWN, "MiddleButtonDown",
  157. WM_MBUTTONUP, "MiddleButtonUp",
  158. WM_MBUTTONDBLCLK, "MiddleButtonDoubleClick",
  159. WM_MOUSEWHEEL, "MouseWheel",
  160. WM_XBUTTONDOWN, "XButtonDown",
  161. WM_XBUTTONUP, "XButtonUp",
  162. WM_XBUTTONDBLCLK, "XButtonDoubleClick",
  163. WM_MOUSELAST, "MouseLast",
  164. WM_PARENTNOTIFY, "ParentNotify",
  165. WM_ENTERMENULOOP, "EnterMenuLoop",
  166. WM_EXITMENULOOP, "ExitMenuLoop",
  167. WM_NEXTMENU, "NextMenu",
  168. WM_SIZING, "Sizing",
  169. WM_CAPTURECHANGED, "CaptureChanged",
  170. WM_MOVING, "Moving",
  171. WM_POWERBROADCAST, "PowerBroadcast",
  172. WM_DEVICECHANGE, "DeviceChange",
  173. WM_MDICREATE, "MDICreate",
  174. WM_MDIDESTROY, "MDIDestroy",
  175. WM_MDIACTIVATE, "MDIActivate",
  176. WM_MDIRESTORE, "MDIRestore",
  177. WM_MDINEXT, "MDINext",
  178. WM_MDIMAXIMIZE, "MDIMaximize",
  179. WM_MDITILE, "MDITitle",
  180. WM_MDICASCADE, "MDICascade",
  181. WM_MDIICONARRANGE, "MDIIconArrange",
  182. WM_MDIGETACTIVE, "MDIGetActive",
  183. WM_MDISETMENU, "MDISetMenu",
  184. WM_ENTERSIZEMOVE, "EnterSizeMove",
  185. WM_EXITSIZEMOVE, "ExitSizeMove",
  186. WM_DROPFILES, "DropFiles",
  187. WM_MDIREFRESHMENU, "MDIRefreshMenu",
  188. WM_IME_SETCONTEXT, "IMESetContext",
  189. WM_IME_NOTIFY, "IMENotify",
  190. WM_IME_CONTROL, "IMEControl",
  191. WM_IME_COMPOSITIONFULL, "IMECompositionFull",
  192. WM_IME_SELECT, "IMESelect",
  193. WM_IME_CHAR, "IMEChar",
  194. WM_IME_REQUEST, "IMERequest",
  195. WM_IME_KEYDOWN, "IMEKeyDown",
  196. WM_IME_KEYUP, "IMEKeyUp",
  197. WM_MOUSEHOVER, "MouseHover",
  198. WM_MOUSELEAVE, "MouseLeave",
  199. WM_NCMOUSEHOVER, "NCMouseHover",
  200. WM_NCMOUSELEAVE, "NCMouseLeave",
  201. WM_CUT, "Cut",
  202. WM_COPY, "Copy",
  203. WM_PASTE, "Paste",
  204. WM_CLEAR, "Clear",
  205. WM_UNDO, "Undo",
  206. WM_RENDERFORMAT, "RenderFormat",
  207. WM_RENDERALLFORMATS, "RenderAllFormats",
  208. WM_DESTROYCLIPBOARD, "DestroyClipboard",
  209. WM_DRAWCLIPBOARD, "DrawClipboard",
  210. WM_PAINTCLIPBOARD, "PaintClipboard",
  211. WM_VSCROLLCLIPBOARD, "VScrollClipboard",
  212. WM_SIZECLIPBOARD, "SizeClipboard",
  213. WM_ASKCBFORMATNAME, "AskCBFormatName",
  214. WM_CHANGECBCHAIN, "ChangeCBChain",
  215. WM_HSCROLLCLIPBOARD, "HScrollClipboard",
  216. WM_QUERYNEWPALETTE, "QueryNewPalette",
  217. WM_PALETTEISCHANGING, "PaletteIsChanging",
  218. WM_PALETTECHANGED, "PaletteChanged",
  219. WM_HOTKEY, "HotKey",
  220. WM_PRINT, "Print",
  221. WM_PRINTCLIENT, "PrintClient",
  222. WM_APPCOMMAND, "AppCommand",
  223. WM_HANDHELDFIRST, "HandHeldFirst",
  224. WM_HANDHELDLAST, "HandHeldLast",
  225. WM_AFXFIRST, "AFXFirst",
  226. WM_AFXLAST, "AFXLast",
  227. WM_PENWINFIRST, "PenWinFirst",
  228. WM_PENWINLAST, "PenWinLast",
  229. WM_USER, "User",
  230. WM_APP, "App",
  231. 0x00, NULL
  232. };
  233. NAMETABLE SrvReqNames[] =
  234. {
  235. SRVREQ_NONE, "None",
  236. SRVREQ_BUSY, "Busy",
  237. SRVREQ_GETCLIENTINFO, "GetClientInfo",
  238. SRVREQ_SETCLIENTINFO, "SetClientInfo",
  239. SRVREQ_TERMINATE, "Terminate",
  240. 0x00, NULL
  241. };
  242. /*++
  243. @doc INTERNAL
  244. @func VOID | TRDebugPrint | Print to system debugger.
  245. @parm IN LPCSTR | format | Points to the format string.
  246. @parm ... | Arguments.
  247. @rvalue SUCCESS | returns the number of chars stored in the buffer not
  248. counting the terminating null characters.
  249. @rvalue FAILURE | returns less than the length of the expected output.
  250. --*/
  251. int
  252. TRDebugPrint(
  253. IN LPCSTR format,
  254. ...
  255. )
  256. {
  257. int n;
  258. static char szMessage[256] = {0};
  259. va_list arglist;
  260. va_start(arglist, format);
  261. n = wvsprintfA(szMessage, format, arglist);
  262. va_end(arglist);
  263. OutputDebugStringA(szMessage);
  264. return n;
  265. } //TRDebugPrint
  266. /*++
  267. @doc INTERNAL
  268. @func PSZ | LookupName |
  269. Look up name string of a code in the given name table.
  270. @parm IN ULONG | Code | The given code to lookup.
  271. @parm IN PNAMETABLE | NameTable | The name table to look into.
  272. @rvalue SUCCESS - Returns pointer to the minor function name string.
  273. @rvalue FAILURE - Returns "unknown".
  274. --*/
  275. PSZ
  276. LookupName(
  277. IN ULONG Code,
  278. IN PNAMETABLE NameTable
  279. )
  280. {
  281. PSZ pszName = NULL;
  282. static char szUnknown[64];
  283. while (NameTable->pszName != NULL)
  284. {
  285. if (Code == NameTable->Code)
  286. {
  287. pszName = NameTable->pszName;
  288. break;
  289. }
  290. NameTable++;
  291. }
  292. if (pszName == NULL)
  293. {
  294. wsprintfA(szUnknown, "unknown[0x%x(%d)]", Code, Code);
  295. pszName = szUnknown;
  296. }
  297. return pszName;
  298. } //LookupName
  299. #endif //ifdef TRDEBUG