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.

295 lines
8.7 KiB

  1. //================================================================================
  2. // Copyright (C) 1998 Microsoft Corporation
  3. // Author: RameshV
  4. // Decription: This module just dumps several types of objects to the debugger.
  5. // This can be easily modified to be a ntsd extension etc..
  6. // No separate description is given as this is not supposed to be used for
  7. // regular use. This is just there for diagnostic purposes.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <winbase.h>
  11. #include <array.h>
  12. #include <opt.h>
  13. #include <optl.h>
  14. #include <optclass.h>
  15. #include <bitmask.h>
  16. #include <range.h>
  17. #include <reserve.h>
  18. #include <subnet.h>
  19. #include <optdefl.h>
  20. #include <classdefl.h>
  21. #include <oclassdl.h>
  22. #include <sscope.h>
  23. #include <server.h>
  24. #include <winsock2.h>
  25. #include <stdio.h>
  26. #define TAB do{int i = InitTab ; while(i--) printf("\t"); }while(0)
  27. typedef
  28. VOID
  29. DUMPFUNC( // any phonetic resemblance to "dum fuk" is purely incidental..
  30. IN ULONG InitTab,
  31. IN LPVOID Struct
  32. );
  33. static
  34. VOID
  35. DumpArray(
  36. IN PARRAY Array,
  37. IN ULONG InitTab,
  38. IN DUMPFUNC Func
  39. )
  40. {
  41. ARRAY_LOCATION Loc;
  42. LPVOID ThisElt;
  43. DWORD Err;
  44. for( Err = MemArrayInitLoc(Array, &Loc)
  45. ; ERROR_SUCCESS == Err ;
  46. Err = MemArrayNextLoc(Array, &Loc)
  47. ) {
  48. ThisElt = NULL;
  49. Err = MemArrayGetElement(Array, &Loc, &ThisElt);
  50. Func(InitTab, ThisElt);
  51. }
  52. if( ERROR_FILE_NOT_FOUND != Err ) {
  53. TAB; printf("Enumeration failure: %ld (0x%08lx)\n", Err, Err);
  54. }
  55. }
  56. #define HEX_CHAR(c) (((c) < 10)?((c)+'0'):((c) - 10 + 'A'))
  57. static
  58. VOID
  59. DumpHex(
  60. IN LPSTR Name,
  61. IN LPBYTE Bytes,
  62. IN ULONG nBytes
  63. )
  64. {
  65. printf("%s ", Name);
  66. while(nBytes--) {
  67. printf("%c%c ", HEX_CHAR(((*Bytes)&0xF0)>>4), HEX_CHAR((*Bytes)&0x0F));
  68. Bytes ++;
  69. }
  70. printf("\n");
  71. }
  72. //BeginExport(function)
  73. VOID
  74. MmDumpOption(
  75. IN ULONG InitTab,
  76. IN PM_OPTION Option
  77. ) //EndExport(function)
  78. {
  79. TAB; printf("Option %ld\n", Option->OptId);
  80. InitTab++;
  81. TAB; DumpHex("Option value:", Option->Val, Option->Len);
  82. }
  83. //BeginExport(function)
  84. VOID
  85. MmDumpOptList(
  86. IN ULONG InitTab,
  87. IN PM_OPTLIST OptList
  88. ) //EndExport(function)
  89. {
  90. DumpArray(OptList, InitTab, MmDumpOption);
  91. }
  92. //BeginExport(function)
  93. VOID
  94. MmDumpOneClassOptList(
  95. IN ULONG InitTab,
  96. IN PM_ONECLASS_OPTLIST OptList1
  97. ) //EndExport(function)
  98. {
  99. TAB; printf("OptList for UserClass %ld Vendor Class %ld\n", OptList1->ClassId, OptList1->VendorId);
  100. InitTab ++;
  101. MmDumpOptList(InitTab, &OptList1->OptList);
  102. }
  103. //BeginExport(function)
  104. VOID
  105. MmDumpOptions(
  106. IN ULONG InitTab,
  107. IN PM_OPTCLASS OptClass
  108. ) //EndExport(function)
  109. {
  110. DumpArray(&OptClass->Array, InitTab, MmDumpOneClassOptList);
  111. }
  112. //BeginExport(function)
  113. VOID
  114. MmDumpReservation(
  115. IN ULONG InitTab,
  116. IN PM_RESERVATION Res
  117. ) //EndExport(function)
  118. {
  119. TAB; printf("Reservation %s (Type %ld)\n", inet_ntoa(*(struct in_addr *)&Res->Address),Res->Flags);
  120. InitTab++;
  121. TAB; DumpHex("Reservation for", Res->ClientUID, Res->nBytes);
  122. MmDumpOptions(InitTab, &Res->Options);
  123. }
  124. //BeginExport(function)
  125. VOID
  126. MmDumpRange(
  127. IN ULONG InitTab,
  128. IN PM_RANGE Range
  129. ) //EndExport(function)
  130. {
  131. TAB; printf("Range: %s to ", inet_ntoa(*(struct in_addr *)&Range->Start));
  132. printf("%s mask (", inet_ntoa(*(struct in_addr *)&Range->End));
  133. printf("%s)\n", inet_ntoa(*(struct in_addr *)&Range->Mask));
  134. }
  135. //BeginExport(function)
  136. VOID
  137. MmDumpExclusion(
  138. IN ULONG InitTab,
  139. IN PM_EXCL Range
  140. ) //EndExport(function)
  141. {
  142. TAB; printf("Range: %s to ", inet_ntoa(*(struct in_addr *)&Range->Start));
  143. printf("%s\n", inet_ntoa(*(struct in_addr *)&Range->End));
  144. }
  145. //BeginExport(function)
  146. VOID
  147. MmDumpSubnets(
  148. IN ULONG InitTab,
  149. IN PM_SUBNET Subnet
  150. ) //EndExport(function)
  151. {
  152. TAB; printf("Scope %ws : ", Subnet->Name);
  153. if( Subnet->fSubnet ) {
  154. printf("ADDRESS %s ", inet_ntoa(*(struct in_addr*)&Subnet->Address));
  155. printf("MASK %s\n", inet_ntoa(*(struct in_addr*)&Subnet->Mask));
  156. } else {
  157. printf("SCOPEID %ld\n", Subnet->MScopeId);
  158. }
  159. InitTab++;
  160. TAB; printf("Subnet Description: %ws\n", Subnet->Description);
  161. TAB; printf("State/SuperScope/Policy: %ld/%ld/%ld\n", Subnet->State, Subnet->SuperScopeId, Subnet->Policy);
  162. DumpArray(&Subnet->Ranges, InitTab, MmDumpRange);
  163. DumpArray(&Subnet->Exclusions, InitTab, MmDumpExclusion);
  164. MmDumpOptions(InitTab, &Subnet->Options);
  165. DumpArray(&Subnet->Reservations, InitTab, MmDumpReservation);
  166. }
  167. //BeginExport(function)
  168. VOID
  169. MmDumpSscope(
  170. IN ULONG InitTab,
  171. IN PM_SSCOPE Sscope
  172. ) //EndExport(function)
  173. {
  174. TAB; printf("SuperScope %ws (%ld) Policy 0x%08lx\n",
  175. Sscope->Name, Sscope->SScopeId, Sscope->Policy
  176. );
  177. }
  178. //BeginExport(function)
  179. VOID
  180. MmDumpOptDef(
  181. IN ULONG InitTab,
  182. IN PM_OPTDEF OptDef
  183. ) //EndExport(function)
  184. {
  185. TAB; printf("Option <%ws> %ld\n", OptDef->OptName, OptDef->OptId);
  186. InitTab++;
  187. TAB; printf("Option Comment: %ws\n", OptDef->OptComment);
  188. TAB; DumpHex("Option Default Value:", OptDef->OptVal, OptDef->OptValLen);
  189. }
  190. //BeginExport(function)
  191. VOID
  192. MmDumpOptClassDefListOne(
  193. IN ULONG InitTab,
  194. IN PM_OPTCLASSDEFL_ONE OptDefList1
  195. ) //EndExport(function)
  196. {
  197. TAB; printf("Options for UserClass %ld Vendor Class %ld \n",
  198. OptDefList1->ClassId, OptDefList1->VendorId
  199. );
  200. InitTab++;
  201. DumpArray(&OptDefList1->OptDefList.OptDefArray, InitTab, MmDumpOptDef);
  202. }
  203. //BeginExport(function)
  204. VOID
  205. MmDumpOptClassDefList(
  206. IN ULONG InitTab,
  207. IN PM_OPTCLASSDEFLIST OptDefList
  208. ) //EndExport(function)
  209. {
  210. DumpArray(&OptDefList->Array, InitTab, MmDumpOptClassDefListOne);
  211. }
  212. //BeginExport(function)
  213. VOID
  214. MmDumpClassDef(
  215. IN ULONG InitTab,
  216. IN PM_CLASSDEF ClassDef
  217. ) //EndExport(function)
  218. {
  219. TAB; printf("Class <%ws> Id: %ld, %s\n", ClassDef->Name, ClassDef->ClassId,
  220. ClassDef->IsVendor? "VENDOR CLASS" : "USER CLASS"
  221. );
  222. InitTab ++;
  223. TAB; printf("ClassComment: %ws\n", ClassDef->Comment);
  224. TAB; printf("ClassType/RefCount: %ld/%ld\n", ClassDef->Type, ClassDef->RefCount);
  225. TAB; DumpHex("ClassData:", ClassDef->ActualBytes, ClassDef->nBytes);
  226. }
  227. //BeginExport(function)
  228. VOID
  229. MmDumpClassDefList(
  230. IN ULONG InitTab,
  231. IN PM_CLASSDEFLIST ClassDefList
  232. ) //EndExport(function)
  233. {
  234. DumpArray(&ClassDefList->ClassDefArray, InitTab, MmDumpClassDef);
  235. }
  236. //BeginExport(function)
  237. VOID
  238. MmDumpServer(
  239. IN ULONG InitTab, // how much to tab initially..
  240. IN PM_SERVER Server
  241. ) //EndExport(function)
  242. {
  243. DWORD Err;
  244. PM_SUBNET ThisSubnet;
  245. PM_MSCOPE ThisMScope;
  246. PM_SSCOPE ThisSScope;
  247. TAB;
  248. printf("Server: %s <%ws>\n", inet_ntoa(*(struct in_addr*)&Server->Address), Server->Name);
  249. InitTab++;
  250. TAB; printf("State: %ld (0x%08lx)\n", Server->State, Server->State);
  251. TAB; printf("Policy: %ld (0x%08lx)\n", Server->Policy, Server->Policy);
  252. MmDumpClassDefList(InitTab, &Server->ClassDefs);
  253. MmDumpOptClassDefList(InitTab, &Server->OptDefs);
  254. MmDumpOptions(InitTab, &Server->Options); // dump classes, option defs, options
  255. DumpArray(&Server->SuperScopes, InitTab, MmDumpSscope);
  256. DumpArray(&Server->Subnets, InitTab, MmDumpSubnets);
  257. DumpArray(&Server->MScopes, InitTab, MmDumpSubnets);
  258. }
  259. //================================================================================
  260. // End of file
  261. //================================================================================