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.

239 lines
6.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: D I A G C M N . C P P
  7. //
  8. // Contents: Common functions for netcfg diagnostics
  9. //
  10. // Notes:
  11. //
  12. // Author: danielwe 23 Mar 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "diag.h"
  18. #include "ncstring.h"
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Function: SzFromCharacteristics
  22. //
  23. // Purpose: Converts a DWORD characteristics value into a string listing
  24. // the flags that are turned on.
  25. //
  26. // Arguments:
  27. // dwChars [in] DWORD of netcfg characteristics (i.e. NCF_HIDDEN)
  28. // pstrChars [out] tstring of flags that are turned on, separated by a
  29. // space.
  30. //
  31. // Returns: Nothing
  32. //
  33. // Author: danielwe 23 Mar 1999
  34. //
  35. // Notes:
  36. //
  37. VOID SzFromCharacteristics(DWORD dwChars, tstring *pstrChars) throw(std::bad_alloc)
  38. {
  39. INT i;
  40. const PCWSTR chars[] =
  41. {
  42. L"NCF_VIRTUAL ",
  43. L"NCF_SOFTWARE_ENUMERATED ",
  44. L"NCF_PHYSICAL ",
  45. L"NCF_HIDDEN ",
  46. L"NCF_NO_SERVICE ",
  47. L"NCF_NOT_USER_REMOVABLE ",
  48. L"NCF_MULTIPORT_INSTANCED_ADAPTER ",
  49. L"NCF_HAS_UI ",
  50. L"NCF_MODEM ",
  51. L"NCF_FILTER_DEVICE ",
  52. L"NCF_FILTER ",
  53. L"NCF_DONTEXPOSELOWER ",
  54. L"NCF_HIDE_BINDING ",
  55. L"0x4000 ",
  56. L"0x8000 ",
  57. L"NCF_FORCE_SCM_NOTIFY ",
  58. L"NCF_FIXED_BINDING ",
  59. };
  60. for (i = 0; i < celems(chars); i++)
  61. {
  62. if (dwChars & (1 << i) )
  63. {
  64. pstrChars->append(chars[i]);
  65. }
  66. }
  67. }
  68. //+---------------------------------------------------------------------------
  69. //
  70. // Function: SzFromNetconStatus
  71. //
  72. // Purpose: Converts a NETCON_STATUS value into a string
  73. //
  74. // Arguments:
  75. // Status [in] Status value to convert
  76. //
  77. // Returns: The string
  78. //
  79. // Author: danielwe 23 Mar 1999
  80. //
  81. // Notes:
  82. //
  83. PCWSTR SzFromNetconStatus(NETCON_STATUS Status) throw()
  84. {
  85. switch (Status)
  86. {
  87. case NCS_DISCONNECTED:
  88. return L"NCS_DISCONNECTED";
  89. case NCS_CONNECTING:
  90. return L"NCS_CONNECTING";
  91. case NCS_CONNECTED:
  92. return L"NCS_CONNECTED";
  93. case NCS_DISCONNECTING:
  94. return L"NCS_DISCONNECTING";
  95. case NCS_HARDWARE_NOT_PRESENT:
  96. return L"NCS_HARDWARE_NOT_PRESENT";
  97. case NCS_HARDWARE_DISABLED:
  98. return L"NCS_HARDWARE_DISABLED";
  99. case NCS_HARDWARE_MALFUNCTION:
  100. return L"NCS_HARDWARE_MALFUNCTION";
  101. }
  102. return L"Unknown";
  103. }
  104. //+---------------------------------------------------------------------------
  105. //
  106. // Function: SzFromCmProb
  107. //
  108. // Purpose: Converts a config manager (CM) problem value into a string
  109. //
  110. // Arguments:
  111. // ulProb [in] Problem value
  112. //
  113. // Returns: String version of value
  114. //
  115. // Author: danielwe 23 Mar 1999
  116. //
  117. // Notes:
  118. //
  119. PCWSTR SzFromCmProb(ULONG ulProb) throw()
  120. {
  121. const PCWSTR a_szProbs[] =
  122. {
  123. L"<no problem>",
  124. L"CM_PROB_NOT_CONFIGURED",
  125. L"CM_PROB_DEVLOADER_FAILED",
  126. L"CM_PROB_OUT_OF_MEMORY",
  127. L"CM_PROB_ENTRY_IS_WRONG_TYPE",
  128. L"CM_PROB_LACKED_ARBITRATOR",
  129. L"CM_PROB_BOOT_CONFIG_CONFLICT",
  130. L"CM_PROB_FAILED_FILTER",
  131. L"CM_PROB_DEVLOADER_NOT_FOUND",
  132. L"CM_PROB_INVALID_DATA",
  133. L"CM_PROB_FAILED_START",
  134. L"CM_PROB_LIAR",
  135. L"CM_PROB_NORMAL_CONFLICT",
  136. L"CM_PROB_NOT_VERIFIED",
  137. L"CM_PROB_NEED_RESTART",
  138. L"CM_PROB_REENUMERATION",
  139. L"CM_PROB_PARTIAL_LOG_CONF",
  140. L"CM_PROB_UNKNOWN_RESOURCE",
  141. L"CM_PROB_REINSTALL",
  142. L"CM_PROB_REGISTRY",
  143. L"CM_PROB_VXDLDR",
  144. L"CM_PROB_WILL_BE_REMOVED",
  145. L"CM_PROB_DISABLED",
  146. L"CM_PROB_DEVLOADER_NOT_READY",
  147. L"CM_PROB_DEVICE_NOT_THERE",
  148. L"CM_PROB_MOVED",
  149. L"CM_PROB_TOO_EARLY",
  150. L"CM_PROB_NO_VALID_LOG_CONF",
  151. L"CM_PROB_FAILED_INSTALL",
  152. L"CM_PROB_HARDWARE_DISABLED",
  153. L"CM_PROB_CANT_SHARE_IRQ",
  154. L"CM_PROB_FAILED_ADD",
  155. };
  156. return a_szProbs[ulProb];
  157. }
  158. //+---------------------------------------------------------------------------
  159. //
  160. // Function: SzFromCmStatus
  161. //
  162. // Purpose: Converts a config manager (CM) status value into a string
  163. // containing all flags that are turned on.
  164. //
  165. // Arguments:
  166. // ulStatus [in] CM status value
  167. // pstrStatus [out] Returns string of flags that are on
  168. //
  169. // Returns: Nothing
  170. //
  171. // Author: danielwe 23 Mar 1999
  172. //
  173. // Notes:
  174. //
  175. VOID SzFromCmStatus(ULONG ulStatus, tstring *pstrStatus) throw(std::bad_alloc)
  176. {
  177. INT i;
  178. const PCWSTR a_szStatus[] =
  179. {
  180. L"DN_ROOT_ENUMERATED ",
  181. L"DN_DRIVER_LOADED ",
  182. L"DN_ENUM_LOADED ",
  183. L"DN_STARTED ",
  184. L"DN_MANUAL ",
  185. L"DN_NEED_TO_ENUM ",
  186. L"DN_NOT_FIRST_TIME ",
  187. L"DN_HARDWARE_ENUM ",
  188. L"DN_LIAR/DN_NEED_RESTART ",
  189. L"DN_HAS_MARK ",
  190. L"DN_HAS_PROBLEM ",
  191. L"DN_FILTERED ",
  192. L"DN_MOVED ",
  193. L"DN_DISABLEABLE ",
  194. L"DN_REMOVABLE ",
  195. L"DN_PRIVATE_PROBLEM ",
  196. L"DN_MF_PARENT ",
  197. L"DN_MF_CHILD ",
  198. L"DN_WILL_BE_REMOVED ",
  199. L"DN_NOT_FIRST_TIMEE ",
  200. L"DN_STOP_FREE_RES ",
  201. L"DN_REBAL_CANDIDATE ",
  202. L"DN_BAD_PARTIAL ",
  203. L"DN_NT_ENUMERATOR ",
  204. L"DN_NT_DRIVER ",
  205. L"DN_NEEDS_LOCKING ",
  206. L"DN_ARM_WAKEUP ",
  207. L"DN_APM_ENUMERATOR ",
  208. L"DN_APM_DRIVER ",
  209. L"DN_SILENT_INSTALL ",
  210. L"DN_NO_SHOW_IN_DM ",
  211. L"DN_BOOT_LOG_PROB ",
  212. };
  213. for (i = 0; i < celems(a_szStatus); i++)
  214. {
  215. if (ulStatus & (1 << i) )
  216. {
  217. pstrStatus->append(a_szStatus[i]);
  218. }
  219. }
  220. }