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.

384 lines
7.9 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. betacfg.c
  5. Abstract:
  6. This file enumerates various parts of the user's system and saves
  7. entries into the config log.
  8. The format of each line in config.dmp is:
  9. <ID>\t<data>\t<data>\t<data>
  10. Author:
  11. Jim Schmidt (jimschm) 04-Aug-1998
  12. Revision History:
  13. None.
  14. --*/
  15. #include "pch.h"
  16. //
  17. // Function type declaration
  18. //
  19. typedef VOID (DUMP_FUNCTION_PROTOTYPE)(VOID);
  20. typedef DUMP_FUNCTION_PROTOTYPE * DUMP_FUNCTION;
  21. //
  22. // Array of dump functions
  23. //
  24. #define FUNCTION_LIST \
  25. DEFMAC(pDumpUserName) \
  26. DEFMAC(pDumpHardware) \
  27. DEFMAC(pDumpDosLines) \
  28. DEFMAC(pDumpNetworkInfo) \
  29. DEFMAC(pDumpUninstallList) \
  30. DEFMAC(pDumpCompatReport) \
  31. // DEFMAC(pDumpUserShellFolders) \
  32. //
  33. // Declare the function prototypes
  34. //
  35. #define DEFMAC(x) DUMP_FUNCTION_PROTOTYPE x;
  36. FUNCTION_LIST
  37. #undef DEFMAC
  38. //
  39. // Create a lookup array
  40. //
  41. typedef struct {
  42. DUMP_FUNCTION Proc;
  43. } DUMP_FUNCTION_LIST, *PDUMP_FUNCTION_LIST;
  44. #define DEFMAC(x) {x},
  45. static DUMP_FUNCTION_LIST g_Functions[] = {
  46. FUNCTION_LIST /*,*/
  47. {NULL}
  48. };
  49. #undef DEFMAC
  50. VOID
  51. SaveConfigurationForBeta (
  52. VOID
  53. )
  54. {
  55. INT i;
  56. for (i = 0 ; g_Functions[i].Proc ; i++) {
  57. g_Functions[i].Proc();
  58. }
  59. }
  60. VOID
  61. pDumpUserName (
  62. VOID
  63. )
  64. {
  65. TCHAR UserName[MAX_USER_NAME];
  66. TCHAR ComputerName[MAX_COMPUTER_NAME];
  67. DWORD Size;
  68. Size = MAX_USER_NAME;
  69. if (!GetUserName (UserName, &Size)) {
  70. UserName[0] = 0;
  71. }
  72. Size = MAX_COMPUTER_NAME;
  73. if (!GetComputerName (ComputerName, &Size)) {
  74. ComputerName[0] = 0;
  75. }
  76. LOG ((LOG_CONFIG, "User\t%s", UserName));
  77. LOG ((LOG_CONFIG, "Computer Name\t%s", ComputerName));
  78. }
  79. VOID
  80. pDumpHardware (
  81. VOID
  82. )
  83. {
  84. HARDWARE_ENUM e;
  85. if (EnumFirstHardware (&e, ENUM_ALL_DEVICES, ENUM_WANT_ALL)) {
  86. do {
  87. LOG ((
  88. LOG_CONFIG,
  89. "Device\t%s\t%s\t%s\t%s\t%s\t%s\t%u\t%u\t%u\t%u",
  90. e.DeviceDesc,
  91. e.Mfg,
  92. e.HardwareID,
  93. e.CompatibleIDs,
  94. e.HWRevision,
  95. e.UserDriveLetter,
  96. e.Online,
  97. e.SuppliedByUi,
  98. e.HardwareIdCompatible,
  99. e.CompatibleIdCompatible
  100. ));
  101. } while (EnumNextHardware (&e));
  102. }
  103. }
  104. #if 0
  105. VOID
  106. pDumpShellFolder (
  107. IN PCTSTR ShellFolder
  108. )
  109. {
  110. SHELLFOLDER_ENUM e;
  111. TREE_ENUM te;
  112. if (EnumFirstShellFolder (&e, USF_9X, ShellFolder)) {
  113. do {
  114. if (EnumFirstFileInTree (&te, e.ShellFolder, NULL, FALSE)) {
  115. do {
  116. if (!te.Directory) {
  117. LOG ((
  118. LOG_CONFIG,
  119. "Shell Folder\t%s",
  120. te.FullPath
  121. ));
  122. }
  123. } while (EnumNextFileInTree (&te));
  124. }
  125. } while (EnumNextShellFolder (&e));
  126. }
  127. }
  128. VOID
  129. pDumpUserShellFolders (
  130. VOID
  131. )
  132. {
  133. pDumpShellFolder (TEXT("Start Menu"));
  134. pDumpShellFolder (TEXT("Programs"));
  135. pDumpShellFolder (TEXT("Startup"));
  136. pDumpShellFolder (TEXT("Desktop"));
  137. pDumpShellFolder (TEXT("Recent"));
  138. pDumpShellFolder (TEXT("AppData"));
  139. pDumpShellFolder (TEXT("Local AppData"));
  140. pDumpShellFolder (TEXT("Local Settings"));
  141. pDumpShellFolder (TEXT("My Pictures"));
  142. pDumpShellFolder (TEXT("SendTo"));
  143. pDumpShellFolder (TEXT("Templates"));
  144. }
  145. #endif
  146. VOID
  147. pDumpDosLines (
  148. VOID
  149. )
  150. {
  151. MEMDB_ENUM e;
  152. TCHAR line[MEMDB_MAX];
  153. if (MemDbEnumItems(&e, MEMDB_CATEGORY_DM_LINES)) {
  154. do {
  155. if (MemDbGetEndpointValueEx (
  156. MEMDB_CATEGORY_DM_LINES,
  157. e.szName,
  158. NULL,
  159. line
  160. )) {
  161. LOG ((
  162. LOG_CONFIG,
  163. "Dos Lines\t%s",
  164. line
  165. ));
  166. }
  167. } while (MemDbEnumNextValue (&e));
  168. }
  169. }
  170. VOID
  171. pDumpNetworkInfo (
  172. VOID
  173. )
  174. {
  175. MEMDB_ENUM e;
  176. TCHAR buffer[MEMDB_MAX];
  177. //
  178. // Network protocols.
  179. //
  180. if (MemDbEnumFields (&e, MEMDB_CATEGORY_AF_SECTIONS, S_PAGE_NETPROTOCOLS)) {
  181. do {
  182. if (MemDbBuildKeyFromOffset (e.dwValue, buffer, 1, NULL)) {
  183. LOG ((
  184. LOG_CONFIG,
  185. "Network Protocols\t%s",
  186. buffer
  187. ));
  188. }
  189. } while (MemDbEnumNextValue (&e));
  190. }
  191. //
  192. // Network clients.
  193. //
  194. if (MemDbEnumFields (&e, MEMDB_CATEGORY_AF_SECTIONS, S_PAGE_NETCLIENTS)) {
  195. do {
  196. if (MemDbBuildKeyFromOffset(e.dwValue,buffer,1,NULL)) {
  197. LOG ((
  198. LOG_CONFIG,
  199. "Network Clients\t%s",
  200. buffer
  201. ));
  202. }
  203. } while (MemDbEnumNextValue (&e));
  204. }
  205. //
  206. // Network services.
  207. //
  208. if (MemDbEnumFields (&e, MEMDB_CATEGORY_AF_SECTIONS, S_PAGE_NETSERVICES)) {
  209. do {
  210. if (MemDbBuildKeyFromOffset(e.dwValue,buffer,1,NULL)) {
  211. LOG ((
  212. LOG_CONFIG,
  213. "Network Services\t%s",
  214. buffer
  215. ));
  216. }
  217. } while (MemDbEnumNextValue (&e));
  218. }
  219. }
  220. VOID
  221. pDumpUninstallList (
  222. VOID
  223. )
  224. {
  225. REGKEY_ENUM e;
  226. PCTSTR DisplayName, UninstallString;
  227. HKEY Key;
  228. HKEY SubKey;
  229. Key = OpenRegKeyStr (TEXT("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"));
  230. if (Key) {
  231. if (EnumFirstRegKey (&e, Key)) {
  232. do {
  233. SubKey = OpenRegKey (Key, e.SubKeyName);
  234. if (SubKey) {
  235. DisplayName = GetRegValueString (SubKey, TEXT("DisplayName"));
  236. UninstallString = GetRegValueString (SubKey, TEXT("UninstallString"));
  237. if (DisplayName && UninstallString) {
  238. LOG ((LOG_CONFIG, "Add/Remove Programs\t%s\t%s", DisplayName, UninstallString));
  239. }
  240. if (DisplayName) {
  241. MemFree (g_hHeap, 0, DisplayName);
  242. }
  243. if (UninstallString) {
  244. MemFree (g_hHeap, 0, UninstallString);
  245. }
  246. CloseRegKey (SubKey);
  247. }
  248. } while (EnumNextRegKey (&e));
  249. }
  250. CloseRegKey (Key);
  251. }
  252. }
  253. VOID
  254. pDumpCompatReport (
  255. VOID
  256. )
  257. {
  258. MEMDB_ENUM e;
  259. TCHAR key[MEMDB_MAX];
  260. PTSTR p, q, append;
  261. TCHAR line[MEMDB_MAX];
  262. INT i;
  263. #define COMPONENT_ITEMS_MAX 2
  264. if (MemDbGetValueEx (&e, MEMDB_CATEGORY_COMPATREPORT, MEMDB_ITEM_OBJECTS, NULL)) {
  265. do {
  266. if (!MemDbBuildKeyFromOffset (e.dwValue, key, 3, NULL)) {
  267. continue;
  268. }
  269. line[0] = 0;
  270. append = StringCat (line, TEXT("Compat Report\t"));
  271. //
  272. // first append the Object that generated this entry
  273. //
  274. append = StringCat (append, e.szName);
  275. //
  276. // next append the Components as generated for the user report
  277. //
  278. p = key;
  279. for (i = 0; i < COMPONENT_ITEMS_MAX; i++) {
  280. q = _tcschr (p, TEXT('\\'));
  281. if (!q || !q[1]) {
  282. break;
  283. }
  284. *q = 0;
  285. append = StringCat (append, TEXT("\t"));
  286. append = StringCat (append, p);
  287. p = q + 1;
  288. }
  289. append = StringCat (append, TEXT("\t"));
  290. append = StringCat (append, p);
  291. LOG ((LOG_CONFIG, line));
  292. } while (MemDbEnumNextValue (&e));
  293. }
  294. }