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.

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