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.

152 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. log.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements !_log
  8. Author:
  9. KenRay stolen from jd
  10. Environment:
  11. User Mode.
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #include "genusbkd.h"
  16. #include "..\sys\genusb.h"
  17. VOID
  18. DumpLog(
  19. MEMLOC StartMemLoc,
  20. ULONG LogIndex,
  21. ULONG LogMask,
  22. ULONG NumEntriesToDump
  23. )
  24. {
  25. ULONG i;
  26. GENUSB_LOG_ENTRY32 logEntry32;
  27. GENUSB_LOG_ENTRY64 logEntry64;
  28. ULONG cb;
  29. SIG tag;
  30. MEMLOC mlog, m1, m2, m3;
  31. PrintfMemLoc("*TRANSFER LOGSTART: ", StartMemLoc, " ");
  32. dprintf("(%x) ", LogIndex);
  33. dprintf("# %d \n", NumEntriesToDump);
  34. for (i=0; i< NumEntriesToDump; i++, LogIndex--) {
  35. mlog = StartMemLoc + ((LogIndex & LogMask) * sizeof (GENUSB_LOG_ENTRY));
  36. if (IsPtr64()) {
  37. ReadMemory(mlog,
  38. &logEntry64,
  39. sizeof(logEntry64),
  40. &cb);
  41. tag.l = logEntry64.le_tag;
  42. m1 = logEntry64.le_info1;
  43. m2 = logEntry64.le_info2;
  44. m3 = logEntry64.le_info3;
  45. } else {
  46. ReadMemory(mlog,
  47. &logEntry32,
  48. sizeof(logEntry32),
  49. &cb);
  50. tag.l = logEntry32.le_tag;
  51. m1 = logEntry32.le_info1;
  52. m2 = logEntry32.le_info2;
  53. m3 = logEntry32.le_info3;
  54. }
  55. dprintf("[%3.3d]", i);
  56. PrintfMemLoc(" ", mlog, " ");
  57. dprintf("%c%c%c%c ", tag.c[0], tag.c[1], tag.c[2], tag.c[3]);
  58. PrintfMemLoc(" ", m1, " ");
  59. PrintfMemLoc(" ", m2, " ");
  60. PrintfMemLoc(" ", m3, "\n");
  61. }
  62. }
  63. DECLARE_API( dumplog )
  64. /*++
  65. Routine Description:
  66. dumps the extension
  67. Arguments:
  68. args - Address flags
  69. Return Value:
  70. None
  71. --*/
  72. {
  73. MEMLOC addr;
  74. PCSTR s;
  75. UCHAR buffer1[256];
  76. UCHAR buffer2[256];
  77. UCHAR buffer3[256];
  78. ULONG len = 5;
  79. MEMLOC logPtr;
  80. UCHAR cs[] = "genusb!_DEVICE_EXTENSION";
  81. ULONG logIndex, logMask;
  82. buffer1[0] = '\0';
  83. buffer2[0] = '\0';
  84. buffer3[0] = '\0';
  85. GetExpressionEx( args, &addr, &s );
  86. PrintfMemLoc("LOG@: ", addr, "\n");
  87. sscanf(s, "%s %s %s", &buffer1, &buffer2, &buffer3);
  88. if ('\0' != buffer1[0])
  89. {
  90. sscanf(buffer1, "%d", &len);
  91. }
  92. else
  93. {
  94. len = 20;
  95. }
  96. logPtr = UsbReadFieldPtr(addr, cs, "LogStart");
  97. logIndex = UsbReadFieldUlong(addr, cs, "LogIndex");
  98. logMask = UsbReadFieldUlong(addr, cs, "LogMask");
  99. dprintf(">LOG %p index = %x mask %x length %x\n",
  100. logPtr, logIndex, logMask, len);
  101. DumpLog (logPtr, logIndex, logMask, len);
  102. return S_OK;
  103. }