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.

177 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. hdrext.c
  5. Abstract:
  6. This file contains the generic routines
  7. for debugging NBF / DLC Headers.
  8. Author:
  9. Chaitanya Kodeboyina
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #include "hdrext.h"
  16. //
  17. // Exported Functions
  18. //
  19. DECLARE_API( nhdr )
  20. /*++
  21. Routine Description:
  22. Print an NBF packet header at an addr
  23. Arguments:
  24. args -
  25. Address of the packet header
  26. Detail of debug information
  27. Return Value:
  28. None
  29. --*/
  30. {
  31. NBF_HDR NbfPktHdr;
  32. ULONG printDetail;
  33. ULONG proxyPtr;
  34. // Get the detail of debug information needed
  35. printDetail = NORM_SHAL;
  36. if (*args)
  37. {
  38. sscanf(args, "%x %lu", &proxyPtr, &printDetail);
  39. }
  40. // Get the NBF header
  41. if (ReadNbfPktHdr(&NbfPktHdr, proxyPtr) != 0)
  42. return;
  43. // Print the header
  44. PrintNbfPktHdr(&NbfPktHdr, proxyPtr, printDetail);
  45. }
  46. //
  47. // Helper Functions
  48. //
  49. UINT
  50. ReadNbfPktHdr(PNBF_HDR pPktHdr, ULONG proxyPtr)
  51. {
  52. USHORT hdrlen;
  53. ULONG bytesRead;
  54. // Read the current packet header length
  55. if (!ReadMemory(proxyPtr, &hdrlen, sizeof(USHORT), &bytesRead))
  56. {
  57. dprintf("%s @ %08x: Could not read structure\n",
  58. "Packet Header", proxyPtr);
  59. return -1;
  60. }
  61. // Validate the length of the NBF header
  62. switch (hdrlen)
  63. {
  64. case sizeof(NBF_HDR_CONNECTION):
  65. // dprintf("Connection Oriented: \n");
  66. break;
  67. case sizeof(NBF_HDR_CONNECTIONLESS):
  68. // dprintf("Connection Less: \n");
  69. break;
  70. case sizeof(NBF_HDR_GENERIC):
  71. // dprintf("Generic Header: \n");
  72. break;
  73. default:
  74. dprintf("%s @ %08x: Improper len = %08x\n",
  75. "Packet Header", proxyPtr, hdrlen);
  76. return -1;
  77. }
  78. // Read the current packet header
  79. if (!ReadMemory(proxyPtr, pPktHdr, hdrlen, &bytesRead))
  80. {
  81. dprintf("%s @ %08x: Could not read structure\n",
  82. "Packet Header", proxyPtr);
  83. return -1;
  84. }
  85. return 0;
  86. }
  87. UINT
  88. PrintNbfPktHdr(PNBF_HDR pPktHdr, ULONG proxyPtr, ULONG printDetail)
  89. {
  90. // Is this a valid NBF packet header ?
  91. if (HEADER_SIGNATURE(&pPktHdr->Generic) != NETBIOS_SIGNATURE)
  92. {
  93. dprintf("%s @ %08x: Could not match signature\n",
  94. "Packet Header", proxyPtr);
  95. return -1;
  96. }
  97. // What detail do we have to print at ?
  98. if (printDetail > MAX_DETAIL)
  99. printDetail = MAX_DETAIL;
  100. // Print Information at reqd detail
  101. FieldInNbfPktHdr(proxyPtr, NULL, printDetail);
  102. return 0;
  103. }
  104. VOID
  105. FieldInNbfPktHdr(ULONG structAddr, CHAR *fieldName, ULONG printDetail)
  106. {
  107. NBF_HDR NbfHdr;
  108. StructAccessInfo *StInfo;
  109. if (ReadNbfPktHdr(&NbfHdr, structAddr) == 0)
  110. {
  111. switch (NbfHdr.Generic.Length)
  112. {
  113. case sizeof(NBF_HDR_CONNECTION):
  114. StInfo = &NbfConnectionHdrInfo;
  115. break;
  116. case sizeof(NBF_HDR_CONNECTIONLESS):
  117. StInfo = &NbfConnectionLessHdrInfo;
  118. break;
  119. case sizeof(NBF_HDR_GENERIC):
  120. StInfo = &NbfGenPktHdrInfo;
  121. break;
  122. default:
  123. return;
  124. }
  125. PrintFields(&NbfHdr, structAddr, fieldName, printDetail, StInfo);
  126. }
  127. }
  128. UINT
  129. FreeNbfPktHdr(PNBF_HDR pPktHdr)
  130. {
  131. return 0;
  132. }