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.

63 lines
2.0 KiB

  1. #ifndef _RBDEBUG_H
  2. #define _RBDEBUG_H
  3. #include <objbase.h>
  4. // Registry Based Debug
  5. // We first look in HKCU, then HKLM (there's no HKCU for a service)
  6. // + HKCU\Software\Microsoft\Debug\MyApp.exe
  7. // . RBD_FLAGS = ...
  8. // + File
  9. // . FileName = ... (e.g.: c:\mytrace.txt)
  10. // + Pipe
  11. // . MachineName = ... [Default: "." (local machine)] (e.g.: stephstm_dev)
  12. // . PipeName = ... [Default: MyApp.exe (name of the app)] (e.g.: MyPipe)
  13. #define RBD_TRACE_NONE 0x00000000
  14. #define RBD_TRACE_OUTPUTDEBUG 0x00000001
  15. #define RBD_TRACE_TOFILEANSI 0x00000002
  16. #define RBD_TRACE_TOFILE 0x00000004
  17. #define RBD_TRACE_TOPIPE 0x00000008
  18. #define RBD_TRACE_MASK 0x000000FF
  19. #define RBD_ASSERT_NONE 0x00000000
  20. #define RBD_ASSERT_STOP 0x00000100
  21. #define RBD_ASSERT_TRACE 0x00000200
  22. #define RBD_ASSERT_BEEP 0x00000400
  23. #define RBD_ASSERT_MASK 0x0000FF00
  24. #define TF_ASSERT 0x80000000
  25. #define TF_NOFILEANDLINE 0x40000000
  26. #define TF_THREADID 0x20000000
  27. #define TF_TIME 0x10000000
  28. class CRBDebug
  29. {
  30. public:
  31. static void SetTraceFileAndLine(LPCSTR pszFile, const int iLine);
  32. static void __cdecl TraceMsg(DWORD dwFlags, LPTSTR pszMsg, ...);
  33. static HRESULT Init();
  34. private:
  35. static HRESULT _Init();
  36. static HRESULT _InitFile(HKEY hkeyRoot);
  37. static HRESULT _InitPipe(HKEY hkeyRoot);
  38. static void _Trace(LPTSTR pszMsg);
  39. public:
  40. static BOOL _fInited;
  41. static DWORD _dwTraceFlags;
  42. static DWORD _dwFlags;
  43. static TCHAR* _pszTraceFile;
  44. static TCHAR* _pszTracePipe;
  45. static TCHAR* _pszModuleName;
  46. static HANDLE _hfileTraceFile;
  47. // + 12: yep, limited to files of less than 10 billion lines...
  48. // + 13: for threadid
  49. // + 17: for time
  50. static TCHAR _szFileAndLine[MAX_PATH + 12 + 13 + 17];
  51. static CRITICAL_SECTION _cs;
  52. };
  53. #endif // _RBDEBUG_H