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.

112 lines
2.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: D I A G C T X . H
  7. //
  8. // Contents: Implements the optional diagnostic context used by
  9. // CNetConfig.
  10. //
  11. // Notes:
  12. //
  13. // Author: shaunco 10 Feb 1999
  14. //
  15. //----------------------------------------------------------------------------
  16. #pragma once
  17. #include <tracetag.h>
  18. enum DIAG_FLAGS
  19. {
  20. DF_SHOW_CONSOLE_OUTPUT = 0x00000001,
  21. DF_DONT_START_SERVICES = 0x00000002,
  22. DF_DONT_DO_PNP_BINDS = 0x00000004,
  23. DF_SUPRESS_E_NEED_REBOOT = 0x00000010,
  24. DF_REPAIR_REGISTRY_BINDINGS = 0x00000020,
  25. };
  26. // This structure is allocated dynamically by CDiagContext. Place anything
  27. // big in this structure (as opposed to CDiagContext) so that the size of
  28. // CNetConfig is not directly increased.
  29. //
  30. struct DIAG_CONTEXT
  31. {
  32. CHAR szPrintBuffer [4096];
  33. };
  34. class CDiagContext
  35. {
  36. private:
  37. DWORD m_dwFlags; // DIAG_FLAGS
  38. DIAG_CONTEXT* m_pCtx;
  39. FILE* m_pLogFile; // optional, and not owned by this class.
  40. PVOID m_pvScratchBuffer;
  41. DWORD m_cbScratchBuffer;
  42. public:
  43. CDiagContext ()
  44. {
  45. m_dwFlags = 0;
  46. m_pCtx = NULL;
  47. m_pLogFile = NULL;
  48. m_pvScratchBuffer = NULL;
  49. m_cbScratchBuffer = 0;
  50. }
  51. ~CDiagContext ()
  52. {
  53. MemFree (m_pCtx);
  54. MemFree (m_pvScratchBuffer);
  55. // Do not close m_pLogFile. It is not owned by this class.
  56. }
  57. VOID
  58. SetFlags (
  59. DWORD dwFlags /* DIAG_FLAGS */);
  60. VOID
  61. SetLogFile (
  62. FILE* pLogFile OPTIONAL)
  63. {
  64. m_pLogFile = pLogFile;
  65. }
  66. DWORD
  67. Flags () const;
  68. FILE *
  69. LogFile () const
  70. {
  71. return m_pLogFile;
  72. }
  73. PVOID
  74. GetScratchBuffer (
  75. OUT PDWORD pcbSize) const
  76. {
  77. *pcbSize = m_cbScratchBuffer;
  78. return m_pvScratchBuffer;
  79. }
  80. PVOID
  81. GrowScratchBuffer (
  82. IN OUT PDWORD pcbNewSize)
  83. {
  84. MemFree(m_pvScratchBuffer);
  85. m_pvScratchBuffer = MemAlloc (*pcbNewSize);
  86. m_cbScratchBuffer = (m_pvScratchBuffer) ? *pcbNewSize : 0;
  87. *pcbNewSize = m_cbScratchBuffer;
  88. return m_pvScratchBuffer;
  89. }
  90. VOID
  91. Printf (
  92. TRACETAGID ttid,
  93. PCSTR pszFormat,
  94. ...);
  95. };
  96. extern CDiagContext* g_pDiagCtx;