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.

174 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgdbg.cxx
  6. Abstract:
  7. Debug Device Debugger device
  8. Author:
  9. Steve Kiraly (SteveKi) 5-Dec-1995
  10. Revision History:
  11. --*/
  12. #include "precomp.hxx"
  13. #pragma hdrstop
  14. #include "dbgdbg.hxx"
  15. /*++
  16. Routine Name:
  17. DebugDeviceDebugger constructor
  18. Routine Description:
  19. Initializes the debug device
  20. Arguments:
  21. Pointer to object defined configuration string
  22. Return Value:
  23. Nothing
  24. --*/
  25. TDebugDeviceDebugger::
  26. TDebugDeviceDebugger(
  27. IN LPCTSTR pszConfiguration,
  28. IN EDebugType eDebugType
  29. ) : TDebugDevice( pszConfiguration, eDebugType ),
  30. _bAnsi( FALSE )
  31. {
  32. _bAnsi = eGetCharType() == TDebugDevice::kAnsi;
  33. }
  34. /*++
  35. Routine Name:
  36. DebugDevice Destructor
  37. Routine Description:
  38. Removes access to the debug device
  39. Arguments:
  40. None
  41. Return Value:
  42. Nothing
  43. --*/
  44. TDebugDeviceDebugger::
  45. ~TDebugDeviceDebugger(
  46. VOID
  47. )
  48. {
  49. }
  50. /*++
  51. Routine Name:
  52. Valid Object indicator
  53. Routine Description:
  54. Arguments:
  55. Return Value:
  56. --*/
  57. BOOL
  58. TDebugDeviceDebugger::
  59. bValid(
  60. VOID
  61. ) const
  62. {
  63. return TRUE;
  64. }
  65. /*++
  66. Routine Name:
  67. DebugDevice output
  68. Routine Description:
  69. Output the string to the debug device.
  70. Arguments:
  71. Number of bytes to output, including the null.
  72. Pointer to zero terminated debug string
  73. Return Value:
  74. TRUE string output out, FALSE on failure
  75. --*/
  76. BOOL
  77. TDebugDeviceDebugger::
  78. bOutput (
  79. IN UINT cbSize,
  80. IN LPBYTE pBuffer
  81. )
  82. {
  83. BYTE pTemp[256];
  84. UINT uIndex;
  85. //
  86. // OutputDebugString cannot handle strings large then
  87. // 4k so we do it in chunks.
  88. //
  89. for (uIndex = 0; cbSize; cbSize = cbSize - uIndex)
  90. {
  91. //
  92. // The current index is the small of the two either
  93. // the remaining data or the size of the temp buffer,
  94. // less the null terminator.
  95. //
  96. uIndex = min(sizeof(pTemp) - sizeof(WCHAR), cbSize);
  97. //
  98. // Copy the memory, we know it is not overlapping.
  99. //
  100. memcpy(pTemp, pBuffer, uIndex);
  101. //
  102. // Update the buffer count, and place the null.
  103. //
  104. pBuffer = pBuffer + uIndex;
  105. *(pTemp + uIndex + 0) = 0;
  106. *(pTemp + uIndex + 1) = 0;
  107. if (_bAnsi)
  108. {
  109. OutputDebugStringA( (LPSTR)pTemp );
  110. }
  111. else
  112. {
  113. OutputDebugStringW( (LPWSTR)pTemp );
  114. }
  115. }
  116. return TRUE;
  117. }