Leaked source code of windows server 2003
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.

100 lines
2.2 KiB

  1. #include <windows.h>
  2. #include "carddbg.h"
  3. DEBUG_KEY MyDebugKeys[] =
  4. {
  5. {DEB_ERROR, "Error"},
  6. {DEB_WARN, "Warning"},
  7. {DEB_TRACE, "Trace"},
  8. {DEB_TRACE_FUNC, "TraceFuncs"},
  9. {DEB_TRACE_MEM, "TraceMem"},
  10. {DEB_TRACE_TRANSMIT, "TraceTransmit"},
  11. {DEB_TRACE_PROXY, "TraceProxy"},
  12. {0, NULL}
  13. };
  14. #if DBG
  15. #include <stdio.h>
  16. #define CROW 16
  17. void I_DebugPrintBytes(LPWSTR pwszHdr, BYTE *pb, DWORD cbSize)
  18. {
  19. ULONG cb, i;
  20. CHAR rgsz[1024];
  21. ULONG cbOffset = 0;
  22. BOOL fTruncated = FALSE;
  23. if (NULL == pb || 0 == cbSize)
  24. return;
  25. memset(rgsz, 0, sizeof(rgsz));
  26. DebugLog((
  27. DEB_TRACE_TRANSMIT,
  28. "%S, %d bytes ::\n",
  29. pwszHdr,
  30. cbSize));
  31. // Don't overflow the debug library output buffer.
  32. if (cbSize > 50)
  33. {
  34. cbSize = 50;
  35. fTruncated = TRUE;
  36. }
  37. while (cbSize > 0)
  38. {
  39. // Start every row with extra space
  40. strcat(rgsz, " ");
  41. cbOffset = (ULONG) strlen(rgsz);
  42. cb = min(CROW, cbSize);
  43. cbSize -= cb;
  44. for (i = 0; i < cb; i++)
  45. {
  46. sprintf(
  47. rgsz + cbOffset,
  48. " %02x",
  49. pb[i]);
  50. cbOffset += 3;
  51. }
  52. for (i = cb; i < CROW; i++)
  53. {
  54. strcat(rgsz, " ");
  55. }
  56. strcat(rgsz, " '");
  57. cbOffset = (ULONG) strlen(rgsz);
  58. for (i = 0; i < cb; i++)
  59. {
  60. if (pb[i] >= 0x20 && pb[i] <= 0x7f)
  61. sprintf(
  62. rgsz + cbOffset,
  63. "%c",
  64. pb[i]);
  65. else
  66. sprintf(
  67. rgsz + cbOffset,
  68. ".",
  69. pb[i]);
  70. cbOffset++;
  71. }
  72. strcat(rgsz, "\n");
  73. pb += cb;
  74. }
  75. if (fTruncated)
  76. DebugLog((
  77. DEB_TRACE_TRANSMIT,
  78. "(truncated)\n%s",
  79. rgsz));
  80. else
  81. DebugLog((
  82. DEB_TRACE_TRANSMIT,
  83. "\n%s",
  84. rgsz));
  85. }
  86. #endif