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.

1215 lines
48 KiB

  1. /****************************************************************************
  2. *
  3. * File: save.cpp
  4. * Project: DxDiag (DirectX Diagnostic Tool)
  5. * Author: Mike Anderson (manders@microsoft.com)
  6. * Purpose: Save gathered information to a file in text or CSV format
  7. *
  8. * Note that the text file is always ANSI, even on Unicode builds, to make
  9. * the resulting file easier to use (e.g., Win9x Notepad doesn't understand
  10. * Unicode).
  11. *
  12. * (C) Copyright 1998 Microsoft Corp. All rights reserved.
  13. *
  14. ****************************************************************************/
  15. #include <tchar.h>
  16. #include <Windows.h>
  17. #include <multimon.h>
  18. #include <stdio.h>
  19. #include "reginfo.h"
  20. #include "sysinfo.h"
  21. #include "fileinfo.h"
  22. #include "dispinfo.h"
  23. #include "sndinfo.h"
  24. #include "musinfo.h"
  25. #include "showinfo.h"
  26. #include "inptinfo.h"
  27. #include "netinfo.h"
  28. #include "save.h"
  29. static HRESULT SaveBugInfo(FILE* pFile, BugInfo* pBugInfo);
  30. static HRESULT SaveSysInfo(FILE* pFile, SysInfo* pSysInfo);
  31. static HRESULT SaveNotesInfo(FILE* pFile, SysInfo* pSysInfo, DisplayInfo* pDisplayInfoFirst, SoundInfo* pSoundInfoFirst);
  32. static HRESULT SaveNote(FILE* pFile, TCHAR* strNote );
  33. static HRESULT SaveDxComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst);
  34. static HRESULT SaveDxWinComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst);
  35. static HRESULT SaveBackedUpFileInfo(FILE* pFile);
  36. static HRESULT SaveDisplayInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst);
  37. static HRESULT SaveSoundInfo(FILE* pFile, SoundInfo* pSoundInfoFirst);
  38. static HRESULT SaveMusicInfo(FILE* pFile, MusicInfo* pMusicInfo);
  39. static HRESULT SaveShowInfo(FILE* pFile, ShowInfo* pShowInfo);
  40. static HRESULT SaveInputInfo(FILE* pFile, InputInfo* pInputInfo);
  41. static HRESULT SaveNetInfo(FILE* pFile, NetInfo* pNetInfo);
  42. static HRESULT SaveInactiveDriverInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst);
  43. static HRESULT SaveRegistryErrorInfo(FILE* pFile, RegError* pRegErrorFirst);
  44. static HRESULT SaveDebugLevels(FILE* pFile, SysInfo* pSysInfo);
  45. /****************************************************************************
  46. *
  47. * SaveAllInfo - Save all gathered information in text format.
  48. *
  49. ****************************************************************************/
  50. HRESULT SaveAllInfo(TCHAR* pszFile, SysInfo* pSysInfo,
  51. FileInfo* pFileInfoWinComponentsFirst, FileInfo* pFileInfoComponentsFirst,
  52. DisplayInfo* pDisplayInfoFirst, SoundInfo* pSoundInfoFirst,
  53. MusicInfo* pMusicInfo, InputInfo* pInputInfo,
  54. NetInfo* pNetInfo, ShowInfo* pShowInfo, BugInfo* pBugInfo)
  55. {
  56. HRESULT hr = S_OK;
  57. FILE* pFile;
  58. pFile = _tfopen(pszFile, TEXT("wt"));
  59. if (pFile == NULL)
  60. goto LEnd;
  61. if (pBugInfo != NULL)
  62. {
  63. if (FAILED(hr = SaveBugInfo(pFile, pBugInfo)))
  64. goto LEnd;
  65. }
  66. if (FAILED(hr = SaveSysInfo(pFile, pSysInfo)))
  67. goto LEnd;
  68. if (FAILED(hr = SaveNotesInfo(pFile, pSysInfo, pDisplayInfoFirst, pSoundInfoFirst)))
  69. goto LEnd;
  70. if (FAILED(hr = SaveDxComponentFileInfo(pFile, pFileInfoComponentsFirst)))
  71. goto LEnd;
  72. if (FAILED(hr = SaveDxWinComponentFileInfo(pFile, pFileInfoWinComponentsFirst)))
  73. goto LEnd;
  74. if (FAILED(hr = SaveBackedUpFileInfo(pFile)))
  75. goto LEnd;
  76. if (FAILED(hr = SaveDisplayInfo(pFile, pDisplayInfoFirst)))
  77. goto LEnd;
  78. if (FAILED(hr = SaveSoundInfo(pFile, pSoundInfoFirst)))
  79. goto LEnd;
  80. if (FAILED(hr = SaveMusicInfo(pFile, pMusicInfo)))
  81. goto LEnd;
  82. if (FAILED(hr = SaveShowInfo(pFile, pShowInfo)))
  83. goto LEnd;
  84. if (FAILED(hr = SaveInputInfo(pFile, pInputInfo)))
  85. goto LEnd;
  86. if (FAILED(hr = SaveNetInfo(pFile, pNetInfo)))
  87. goto LEnd;
  88. if (FAILED(hr = SaveInactiveDriverInfo(pFile, pDisplayInfoFirst)))
  89. goto LEnd;
  90. if (FAILED(hr = SaveDebugLevels(pFile, pSysInfo)))
  91. goto LEnd;
  92. LEnd:
  93. if (pFile != NULL)
  94. fclose(pFile);
  95. return hr;
  96. }
  97. /****************************************************************************
  98. *
  99. * SaveAllInfoCsv - Save all gathered information in CSV format.
  100. *
  101. ****************************************************************************/
  102. HRESULT SaveAllInfoCsv(TCHAR* pszFile, SysInfo* pSysInfo,
  103. FileInfo* pFileInfoComponentsFirst, DisplayInfo* pDisplayInfoFirst,
  104. SoundInfo* pSoundInfoFirst, InputInfo* pInputInfo)
  105. {
  106. HRESULT hr = S_OK;
  107. FILE* pFile;
  108. pFile = _tfopen(pszFile, TEXT("wt"));
  109. if (pFile == NULL)
  110. goto LEnd;
  111. // Date
  112. _ftprintf(pFile, TEXT("%02d%02d%d,%02d%02d"),
  113. pSysInfo->m_time.wMonth, pSysInfo->m_time.wDay, pSysInfo->m_time.wYear,
  114. pSysInfo->m_time.wHour, pSysInfo->m_time.wMinute);
  115. // Machine name
  116. _ftprintf(pFile, TEXT(",%s"), pSysInfo->m_szMachine);
  117. // DX Version
  118. _ftprintf(pFile, TEXT(",%s"), pSysInfo->m_szDirectXVersion);
  119. // OS
  120. _ftprintf(pFile, TEXT(",%s,%d.%d,%d,"),
  121. pSysInfo->m_szOS, pSysInfo->m_dwMajorVersion, pSysInfo->m_dwMinorVersion,
  122. LOWORD(pSysInfo->m_dwBuildNumber));
  123. _ftprintf(pFile, TEXT("%s"), pSysInfo->m_szCSDVersion);
  124. // Processor - string may have commas, so change them to semicolons
  125. TCHAR szProcessor[1024];
  126. TCHAR* psz;
  127. lstrcpy(szProcessor, pSysInfo->m_szProcessor);
  128. for (psz = szProcessor; *psz != TEXT('\0'); psz++)
  129. {
  130. if (*psz == TEXT(','))
  131. *psz = TEXT(';');
  132. }
  133. _ftprintf(pFile, TEXT(",%s"), szProcessor);
  134. // Display devices
  135. // (chip type, matching ID, DAC type, disp memory, driver name, driver version)
  136. DisplayInfo* pDisplayInfo;
  137. pDisplayInfo = pDisplayInfoFirst;
  138. {
  139. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szChipType);
  140. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szKeyDeviceID);
  141. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szDACType);
  142. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szDisplayMemoryEnglish);
  143. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szDriverName);
  144. _ftprintf(pFile, TEXT(",%s"), pDisplayInfo->m_szDriverVersion);
  145. }
  146. // Sound devices
  147. SoundInfo* pSoundInfo;
  148. for (pSoundInfo = pSoundInfoFirst; pSoundInfo != NULL;
  149. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  150. {
  151. _ftprintf(pFile, TEXT(",%s"), pSoundInfo->m_szDescription);
  152. _ftprintf(pFile, TEXT(",%s"), pSoundInfo->m_szDeviceID);
  153. _ftprintf(pFile, TEXT(",%s"), pSoundInfo->m_szDriverName);
  154. _ftprintf(pFile, TEXT(",%s"), pSoundInfo->m_szDriverVersion);
  155. }
  156. LEnd:
  157. if (pFile != NULL)
  158. fclose(pFile);
  159. return hr;
  160. }
  161. /****************************************************************************
  162. *
  163. * SaveBugInfo
  164. *
  165. ****************************************************************************/
  166. HRESULT SaveBugInfo(FILE* pFile, BugInfo* pBugInfo)
  167. {
  168. _ftprintf(pFile, TEXT("---------------\n"));
  169. _ftprintf(pFile, TEXT("Bug Information\n"));
  170. _ftprintf(pFile, TEXT("---------------\n"));
  171. _ftprintf(pFile, TEXT(" User name: %s\n"), pBugInfo->m_szName);
  172. _ftprintf(pFile, TEXT(" Email: %s\n"), pBugInfo->m_szEmail);
  173. _ftprintf(pFile, TEXT(" Company: %s\n"), pBugInfo->m_szCompany);
  174. _ftprintf(pFile, TEXT(" Phone: %s\n"), pBugInfo->m_szPhone);
  175. _ftprintf(pFile, TEXT(" City, State: %s\n"), pBugInfo->m_szCityState);
  176. _ftprintf(pFile, TEXT(" Country: %s\n"), pBugInfo->m_szCountry);
  177. _ftprintf(pFile, TEXT("Bug Description: %s\n"), pBugInfo->m_szBugDescription);
  178. _ftprintf(pFile, TEXT(" Repro Steps: %s\n"), pBugInfo->m_szReproSteps);
  179. _ftprintf(pFile, TEXT(" SW/HW Config: %s\n"), pBugInfo->m_szSwHw);
  180. _ftprintf(pFile, TEXT("\n"));
  181. return S_OK;
  182. }
  183. /****************************************************************************
  184. *
  185. * SaveSysInfo
  186. *
  187. ****************************************************************************/
  188. HRESULT SaveSysInfo(FILE* pFile, SysInfo* pSysInfo)
  189. {
  190. _ftprintf(pFile, TEXT("------------------\n"));
  191. _ftprintf(pFile, TEXT("System Information\n"));
  192. _ftprintf(pFile, TEXT("------------------\n"));
  193. _ftprintf(pFile, TEXT("Time of this report: %s\n"), pSysInfo->m_szTime);
  194. _ftprintf(pFile, TEXT(" Machine name: %s\n"), pSysInfo->m_szMachine);
  195. _ftprintf(pFile, TEXT(" Operating System: %s\n"), pSysInfo->m_szOSExLong);
  196. _ftprintf(pFile, TEXT(" Language: %s\n"), pSysInfo->m_szLanguages);
  197. _ftprintf(pFile, TEXT("System Manufacturer: %s\n"), pSysInfo->m_szSystemManufacturerEnglish);
  198. _ftprintf(pFile, TEXT(" System Model: %s\n"), pSysInfo->m_szSystemModelEnglish);
  199. _ftprintf(pFile, TEXT(" BIOS: %s\n"), pSysInfo->m_szBIOSEnglish);
  200. _ftprintf(pFile, TEXT(" Processor: %s\n"), pSysInfo->m_szProcessor);
  201. _ftprintf(pFile, TEXT(" Memory: %s\n"), pSysInfo->m_szPhysicalMemory);
  202. _ftprintf(pFile, TEXT(" Page File: %s\n"), pSysInfo->m_szPageFileEnglish);
  203. _ftprintf(pFile, TEXT("Primary File System: %s\n"), pSysInfo->m_szD3D8CacheFileSystem );
  204. _ftprintf(pFile, TEXT(" DirectX Version: %s\n"), pSysInfo->m_szDirectXVersionLong);
  205. _ftprintf(pFile, TEXT("DX Setup Parameters: %s\n"), pSysInfo->m_szSetupParam);
  206. TCHAR szUnicode[1024];
  207. TCHAR szBit[1024];
  208. #ifdef _WIN64
  209. _tcscpy(szBit, TEXT(" 64bit"));
  210. #else
  211. _tcscpy(szBit, TEXT(" 32bit"));
  212. #endif
  213. #ifdef UNICODE
  214. _tcscpy(szUnicode, TEXT(" Unicode"));
  215. #else
  216. _tcscpy(szUnicode, TEXT(""));
  217. #endif
  218. _ftprintf(pFile, TEXT(" DxDiag Version: %s%s%s\n"), pSysInfo->m_szDxDiagVersion, szBit, szUnicode );
  219. _ftprintf(pFile, TEXT("\n"));
  220. return S_OK;
  221. }
  222. /****************************************************************************
  223. *
  224. * SaveNote
  225. *
  226. ****************************************************************************/
  227. HRESULT SaveNote(FILE* pFile, TCHAR* strNote )
  228. {
  229. TCHAR strBuffer[1024*7];
  230. _tcsncpy( strBuffer, strNote, 1024*7-1 );
  231. strBuffer[1024*7-1]=0;
  232. TCHAR* pEndOfLine;
  233. TCHAR* pCurrent = strBuffer;
  234. TCHAR* pStartOfNext;
  235. BOOL bFirstTime = TRUE;
  236. pEndOfLine = _tcschr( pCurrent, TEXT('\r') );
  237. if( pEndOfLine == NULL )
  238. {
  239. _ftprintf(pFile, TEXT("%s\n"), pCurrent );
  240. return S_OK;
  241. }
  242. while(TRUE)
  243. {
  244. *pEndOfLine = 0;
  245. pStartOfNext = pEndOfLine + 2;
  246. // Output the current line, iff its not a "To test" line
  247. if( _tcsstr( pCurrent, TEXT("To test") ) == NULL )
  248. {
  249. // Ouput trailing spaces everytime except the first time
  250. if( !bFirstTime )
  251. _ftprintf(pFile, TEXT(" ") );
  252. bFirstTime = FALSE;
  253. _ftprintf(pFile, TEXT("%s\n"), pCurrent );
  254. }
  255. // Advance current
  256. pCurrent = pStartOfNext;
  257. // Look for the end of the next, and stop if there's no more
  258. pEndOfLine = _tcschr( pStartOfNext, TEXT('\r') );
  259. if( pEndOfLine == NULL )
  260. break;
  261. }
  262. return S_OK;
  263. }
  264. /****************************************************************************
  265. *
  266. * SaveNotesInfo
  267. *
  268. ****************************************************************************/
  269. HRESULT SaveNotesInfo(FILE* pFile, SysInfo* pSysInfo,
  270. DisplayInfo* pDisplayInfoFirst, SoundInfo* pSoundInfoFirst)
  271. {
  272. DisplayInfo* pDisplayInfo;
  273. SoundInfo* pSoundInfo;
  274. DWORD dwIndex;
  275. _ftprintf(pFile, TEXT("------------\n"));
  276. _ftprintf(pFile, TEXT("DxDiag Notes\n"));
  277. _ftprintf(pFile, TEXT("------------\n"));
  278. _ftprintf(pFile, TEXT(" DirectX Files Tab: ") );
  279. SaveNote(pFile, pSysInfo->m_szDXFileNotesEnglish);
  280. dwIndex = 1;
  281. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  282. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  283. {
  284. _ftprintf(pFile, TEXT(" Display Tab %d: "), dwIndex);
  285. SaveNote(pFile, pDisplayInfo->m_szNotesEnglish);
  286. dwIndex++;
  287. }
  288. dwIndex = 1;
  289. for (pSoundInfo = pSoundInfoFirst; pSoundInfo != NULL;
  290. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  291. {
  292. _ftprintf(pFile, TEXT(" Sound Tab %d: "), dwIndex);
  293. SaveNote(pFile, pSoundInfo->m_szNotesEnglish);
  294. dwIndex++;
  295. }
  296. _ftprintf(pFile, TEXT(" Music Tab: "));
  297. SaveNote(pFile, pSysInfo->m_szMusicNotesEnglish);
  298. _ftprintf(pFile, TEXT(" Input Tab: "));
  299. SaveNote(pFile, pSysInfo->m_szInputNotesEnglish);
  300. _ftprintf(pFile, TEXT(" Network Tab: "));
  301. SaveNote(pFile, pSysInfo->m_szNetworkNotesEnglish);
  302. _ftprintf(pFile, TEXT("\n"));
  303. return S_OK;
  304. }
  305. /****************************************************************************
  306. *
  307. * SaveDxComponentFileInfo
  308. *
  309. ****************************************************************************/
  310. HRESULT SaveDxComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst)
  311. {
  312. FileInfo* pFileInfo;
  313. TCHAR sz[1024];
  314. _ftprintf(pFile, TEXT("------------------\n"));
  315. _ftprintf(pFile, TEXT("DirectX Components\n"));
  316. _ftprintf(pFile, TEXT("------------------\n"));
  317. for (pFileInfo = pFileInfoFirst; pFileInfo != NULL;
  318. pFileInfo = pFileInfo->m_pFileInfoNext)
  319. {
  320. if (!pFileInfo->m_bExists && !pFileInfo->m_bProblem)
  321. continue;
  322. wsprintf(sz, TEXT("%12s: %s %s %s %s %s %d bytes %s\n"),
  323. pFileInfo->m_szName,
  324. pFileInfo->m_szVersion,
  325. pFileInfo->m_szLanguage,
  326. pFileInfo->m_bBeta ? TEXT("Beta") : TEXT("Final"),
  327. pFileInfo->m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  328. pFileInfo->m_szDatestamp,
  329. pFileInfo->m_numBytes,
  330. pFileInfo->m_bSigned ? TEXT("Digitally Signed") : TEXT(""));
  331. _ftprintf(pFile, sz);
  332. }
  333. _ftprintf(pFile, TEXT("\n"));
  334. return S_OK;
  335. }
  336. /****************************************************************************
  337. *
  338. * SaveDxWinComponentFileInfo
  339. *
  340. ****************************************************************************/
  341. HRESULT SaveDxWinComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst)
  342. {
  343. if (pFileInfoFirst == NULL)
  344. return S_OK;
  345. FileInfo* pFileInfo;
  346. TCHAR sz[1024];
  347. _ftprintf(pFile, TEXT("------------------------------------------------\n"));
  348. _ftprintf(pFile, TEXT("Components Incorrectly Located in Windows Folder\n"));
  349. _ftprintf(pFile, TEXT("------------------------------------------------\n"));
  350. for (pFileInfo = pFileInfoFirst; pFileInfo != NULL;
  351. pFileInfo = pFileInfo->m_pFileInfoNext)
  352. {
  353. _sntprintf(sz, 1024, TEXT("%12s: %s %s %s %s %s %d bytes %s\n"),
  354. pFileInfo->m_szName,
  355. pFileInfo->m_szVersion,
  356. pFileInfo->m_szLanguage,
  357. pFileInfo->m_bBeta ? TEXT("Beta") : TEXT("Final"),
  358. pFileInfo->m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  359. pFileInfo->m_szDatestamp,
  360. pFileInfo->m_numBytes,
  361. pFileInfo->m_bSigned ? TEXT("Digitally Signed") : TEXT(""));
  362. sz[1023]=0;
  363. _ftprintf(pFile, sz);
  364. }
  365. _ftprintf(pFile, TEXT("\n"));
  366. return S_OK;
  367. }
  368. /****************************************************************************
  369. *
  370. * SaveBackedUpFileInfo - Since this only shows up in the saved report,
  371. * we gather this info on the fly.
  372. *
  373. ****************************************************************************/
  374. HRESULT SaveBackedUpFileInfo(FILE* pFile)
  375. {
  376. FileInfo fileInfo;
  377. TCHAR szBackupDir[1024];
  378. TCHAR szCurrentDir[1024];
  379. TCHAR szFileSpec[1024];
  380. HANDLE hFindFile;
  381. WIN32_FIND_DATA findData;
  382. BOOL bFirstFile = TRUE;
  383. BOOL bFirstFileThisDir;
  384. HANDLE hFindFile2;
  385. WIN32_FIND_DATA findData2;
  386. GetSystemDirectory(szBackupDir, MAX_PATH);
  387. lstrcat(szBackupDir, TEXT("\\DXBackup"));
  388. lstrcpy(szFileSpec, szBackupDir);
  389. lstrcat(szFileSpec, TEXT("\\*.*"));
  390. hFindFile = FindFirstFile(szFileSpec, &findData);
  391. if (hFindFile != INVALID_HANDLE_VALUE)
  392. {
  393. while (TRUE)
  394. {
  395. if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
  396. lstrcmp(findData.cFileName, TEXT(".")) != 0 &&
  397. lstrcmp(findData.cFileName, TEXT("..")) != 0)
  398. {
  399. bFirstFileThisDir = TRUE;
  400. wsprintf(szCurrentDir, TEXT("%s\\%s"), szBackupDir, findData.cFileName);
  401. lstrcpy(szFileSpec, szCurrentDir);
  402. lstrcat(szFileSpec, TEXT("\\*.*"));
  403. hFindFile2 = FindFirstFile(szFileSpec, &findData2);
  404. if (hFindFile2 != INVALID_HANDLE_VALUE)
  405. {
  406. while (TRUE)
  407. {
  408. if ((findData2.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
  409. {
  410. if (bFirstFile)
  411. {
  412. bFirstFile = FALSE;
  413. _ftprintf(pFile, TEXT("-----------------------------------------------\n"));
  414. _ftprintf(pFile, TEXT("Backed-up drivers in %s\n"), szBackupDir);
  415. _ftprintf(pFile, TEXT("-----------------------------------------------\n"));
  416. }
  417. else if (bFirstFileThisDir)
  418. {
  419. _ftprintf(pFile, TEXT("\n"));
  420. }
  421. if (bFirstFileThisDir)
  422. {
  423. bFirstFileThisDir = FALSE;
  424. _ftprintf(pFile, TEXT("%s:\n"), szCurrentDir);
  425. }
  426. wsprintf(szFileSpec, TEXT("%s\\%s"), szCurrentDir, findData2.cFileName);
  427. ZeroMemory(&fileInfo, sizeof(fileInfo));
  428. lstrcpy(fileInfo.m_szName, findData2.cFileName);
  429. GetFileVersion(szFileSpec, fileInfo.m_szVersion, fileInfo.m_szAttributes, fileInfo.m_szLanguageLocal, fileInfo.m_szLanguage, &fileInfo.m_bBeta, &fileInfo.m_bDebug);
  430. GetFileDateAndSize(szFileSpec, fileInfo.m_szDatestampLocal, fileInfo.m_szDatestamp, &fileInfo.m_numBytes);
  431. FileIsSigned(szFileSpec, &fileInfo.m_bSigned, NULL);
  432. _ftprintf(pFile, TEXT("%12s: %s %s %s %s Date: %s Size: %d bytes %s\n"),
  433. fileInfo.m_szName,
  434. fileInfo.m_szVersion,
  435. fileInfo.m_szLanguage,
  436. fileInfo.m_bBeta ? TEXT("Beta") : TEXT("Final"),
  437. fileInfo.m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  438. fileInfo.m_szDatestamp,
  439. fileInfo.m_numBytes,
  440. fileInfo.m_bSigned ? TEXT("Digitally Signed") : TEXT(""));
  441. }
  442. if (!FindNextFile(hFindFile2, &findData2))
  443. break;
  444. }
  445. FindClose(hFindFile2);
  446. }
  447. }
  448. if (!FindNextFile(hFindFile, &findData))
  449. break;
  450. }
  451. FindClose(hFindFile);
  452. };
  453. if (!bFirstFile)
  454. _ftprintf(pFile, TEXT("\n"));
  455. return S_OK;
  456. }
  457. /****************************************************************************
  458. *
  459. * SaveDisplayInfo
  460. *
  461. ****************************************************************************/
  462. HRESULT SaveDisplayInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst)
  463. {
  464. DisplayInfo* pDisplayInfo;
  465. TCHAR szVersion[1024];
  466. _ftprintf(pFile, TEXT("---------------\n"));
  467. _ftprintf(pFile, TEXT("Display Devices\n"));
  468. _ftprintf(pFile, TEXT("---------------\n"));
  469. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  470. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  471. {
  472. wsprintf(szVersion, TEXT("%s (%s)"), pDisplayInfo->m_szDriverVersion, pDisplayInfo->m_szDriverLanguage);
  473. _ftprintf(pFile, TEXT(" Card name: %s\n"), pDisplayInfo->m_szDescription);
  474. _ftprintf(pFile, TEXT(" Manufacturer: %s\n"), pDisplayInfo->m_szManufacturer);
  475. _ftprintf(pFile, TEXT(" Chip type: %s\n"), pDisplayInfo->m_szChipType);
  476. _ftprintf(pFile, TEXT(" DAC type: %s\n"), pDisplayInfo->m_szDACType);
  477. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pDisplayInfo->m_szKeyDeviceID);
  478. _ftprintf(pFile, TEXT(" Display Memory: %s\n"), pDisplayInfo->m_szDisplayMemoryEnglish);
  479. _ftprintf(pFile, TEXT(" Current Mode: %s\n"), pDisplayInfo->m_szDisplayModeEnglish);
  480. _ftprintf(pFile, TEXT(" Monitor: %s\n"), pDisplayInfo->m_szMonitorName);
  481. _ftprintf(pFile, TEXT(" Monitor Max Res: %s\n"), pDisplayInfo->m_szMonitorMaxRes);
  482. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pDisplayInfo->m_szDriverName);
  483. _ftprintf(pFile, TEXT(" Driver Version: %s\n"), szVersion);
  484. _ftprintf(pFile, TEXT(" DDI Version: %s\n"), pDisplayInfo->m_szDDIVersion);
  485. _ftprintf(pFile, TEXT("Driver Attributes: %s %s\n"), pDisplayInfo->m_bDriverBeta ? TEXT("Beta") : TEXT("Final"), pDisplayInfo->m_bDriverDebug ? TEXT("Debug") : TEXT("Retail"));
  486. _ftprintf(pFile, TEXT(" Driver Date/Size: %s, %d bytes\n"), pDisplayInfo->m_szDriverDate, pDisplayInfo->m_cbDriver);
  487. _ftprintf(pFile, TEXT(" Driver Signed: %s\n"), pDisplayInfo->m_bDriverSignedValid ? ( pDisplayInfo->m_bDriverSigned ? TEXT("Yes") : TEXT("No") ) : TEXT("n/a") );
  488. _ftprintf(pFile, TEXT(" WHQL Date Stamp: %s\n"), pDisplayInfo->m_bDX8DriverSignedValid ? ( pDisplayInfo->m_bDX8DriverSigned ? pDisplayInfo->m_szDX8DriverSignDate : TEXT("None") ) : TEXT("n/a") );
  489. _ftprintf(pFile, TEXT(" VDD: %s\n"), pDisplayInfo->m_szVdd);
  490. _ftprintf(pFile, TEXT(" Mini VDD: %s\n"), pDisplayInfo->m_szMiniVdd);
  491. _ftprintf(pFile, TEXT(" Mini VDD Date: %s, %d bytes\n"), pDisplayInfo->m_szMiniVddDate, pDisplayInfo->m_cbMiniVdd);
  492. _ftprintf(pFile, TEXT("Device Identifier: %s\n"), pDisplayInfo->m_szDX8DeviceIdentifier );
  493. _ftprintf(pFile, TEXT(" Vendor ID: %s\n"), pDisplayInfo->m_szDX8VendorId );
  494. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pDisplayInfo->m_szDX8DeviceId );
  495. _ftprintf(pFile, TEXT(" SubSys ID: %s\n"), pDisplayInfo->m_szDX8SubSysId );
  496. _ftprintf(pFile, TEXT(" Revision ID: %s\n"), pDisplayInfo->m_szDX8Revision );
  497. if (pDisplayInfo->m_pRegErrorFirst == NULL)
  498. {
  499. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  500. }
  501. else
  502. {
  503. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  504. SaveRegistryErrorInfo(pFile, pDisplayInfo->m_pRegErrorFirst);
  505. }
  506. _ftprintf(pFile, TEXT(" DDraw Status: %s\n"), pDisplayInfo->m_szDDStatusEnglish);
  507. _ftprintf(pFile, TEXT(" D3D Status: %s\n"), pDisplayInfo->m_szD3DStatusEnglish);
  508. _ftprintf(pFile, TEXT(" AGP Status: %s\n"), pDisplayInfo->m_szAGPStatusEnglish);
  509. _ftprintf(pFile, TEXT("DDraw Test Result: %s\n"), pDisplayInfo->m_testResultDD.m_szDescriptionEnglish);
  510. _ftprintf(pFile, TEXT(" D3D7 Test Result: %s\n"), pDisplayInfo->m_testResultD3D7.m_szDescriptionEnglish);
  511. _ftprintf(pFile, TEXT(" D3D8 Test Result: %s\n"), pDisplayInfo->m_testResultD3D8.m_szDescriptionEnglish);
  512. _ftprintf(pFile, TEXT("\n"));
  513. }
  514. return S_OK;
  515. }
  516. /****************************************************************************
  517. *
  518. * SaveSoundInfo
  519. *
  520. ****************************************************************************/
  521. HRESULT SaveSoundInfo(FILE* pFile, SoundInfo* pSoundInfoFirst)
  522. {
  523. SoundInfo* pSoundInfo;
  524. TCHAR szAcceleration[1024];
  525. TCHAR szVersion[1024];
  526. TCHAR szAttributes[1024];
  527. TCHAR szSigned[1024];
  528. TCHAR szDateSize[1024];
  529. _ftprintf(pFile, TEXT("-------------\n"));
  530. _ftprintf(pFile, TEXT("Sound Devices\n"));
  531. _ftprintf(pFile, TEXT("-------------\n"));
  532. for (pSoundInfo = pSoundInfoFirst; pSoundInfo != NULL;
  533. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  534. {
  535. switch (pSoundInfo->m_lwAccelerationLevel)
  536. {
  537. case 0:
  538. lstrcpy(szAcceleration, TEXT("Emulation Only"));
  539. break;
  540. case 1:
  541. lstrcpy(szAcceleration, TEXT("Basic"));
  542. break;
  543. case 2:
  544. lstrcpy(szAcceleration, TEXT("Standard"));
  545. break;
  546. case 3:
  547. lstrcpy(szAcceleration, TEXT("Full"));
  548. break;
  549. default:
  550. lstrcpy(szAcceleration, TEXT("Unknown"));
  551. break;
  552. }
  553. if (lstrlen(pSoundInfo->m_szDriverName) > 0)
  554. {
  555. wsprintf(szVersion, TEXT("%s (%s)"), pSoundInfo->m_szDriverVersion, pSoundInfo->m_szDriverLanguage);
  556. wsprintf(szAttributes, TEXT("%s %s"), pSoundInfo->m_bDriverBeta ? TEXT("Beta") : TEXT("Final"), pSoundInfo->m_bDriverDebug ? TEXT("Debug") : TEXT("Retail"));
  557. lstrcpy( szSigned, pSoundInfo->m_bDriverSignedValid ? ( pSoundInfo->m_bDriverSigned ? TEXT("Yes") : TEXT("No") ) : TEXT("n/a") );
  558. wsprintf(szDateSize, TEXT("%s, %d bytes"), pSoundInfo->m_szDriverDate, pSoundInfo->m_numBytes);
  559. }
  560. else
  561. {
  562. lstrcpy(szVersion, TEXT(""));
  563. lstrcpy(szAttributes, TEXT(""));
  564. lstrcpy(szSigned, TEXT(""));
  565. lstrcpy(szDateSize, TEXT(""));
  566. }
  567. _ftprintf(pFile, TEXT(" Description: %s\n"), pSoundInfo->m_szDescription);
  568. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pSoundInfo->m_szDeviceID);
  569. _ftprintf(pFile, TEXT(" Manufacturer ID: %s\n"), pSoundInfo->m_szManufacturerID);
  570. _ftprintf(pFile, TEXT(" Product ID: %s\n"), pSoundInfo->m_szProductID);
  571. _ftprintf(pFile, TEXT(" Type: %s\n"), pSoundInfo->m_szType);
  572. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pSoundInfo->m_szDriverName);
  573. _ftprintf(pFile, TEXT(" Driver Version: %s\n"), szVersion);
  574. _ftprintf(pFile, TEXT("Driver Attributes: %s\n"), szAttributes);
  575. _ftprintf(pFile, TEXT(" Driver Signed: %s\n"), szSigned);
  576. _ftprintf(pFile, TEXT(" Date and Size: %s\n"), szDateSize);
  577. _ftprintf(pFile, TEXT(" Other Files: %s\n"), pSoundInfo->m_szOtherDrivers);
  578. _ftprintf(pFile, TEXT(" Driver Provider: %s\n"), pSoundInfo->m_szProvider);
  579. _ftprintf(pFile, TEXT(" HW Accel Level: %s\n"), szAcceleration);
  580. if (pSoundInfo->m_pRegErrorFirst == NULL)
  581. {
  582. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  583. }
  584. else
  585. {
  586. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  587. SaveRegistryErrorInfo(pFile, pSoundInfo->m_pRegErrorFirst);
  588. }
  589. _ftprintf(pFile, TEXT("Sound Test Result: %s\n"), pSoundInfo->m_testResultSnd.m_szDescriptionEnglish);
  590. _ftprintf(pFile, TEXT("\n"));
  591. }
  592. return S_OK;
  593. }
  594. /****************************************************************************
  595. *
  596. * SaveMusicInfo
  597. *
  598. ****************************************************************************/
  599. HRESULT SaveMusicInfo(FILE* pFile, MusicInfo* pMusicInfo)
  600. {
  601. MusicPort* pMusicPort;
  602. if (pMusicInfo == NULL || !pMusicInfo->m_bDMusicInstalled)
  603. return S_OK;
  604. _ftprintf(pFile, TEXT("-----------\n"));
  605. _ftprintf(pFile, TEXT("DirectMusic\n"));
  606. _ftprintf(pFile, TEXT("-----------\n"));
  607. _ftprintf(pFile, TEXT(" DLS Path: %s\n"), pMusicInfo->m_szGMFilePath);
  608. _ftprintf(pFile, TEXT(" Version: %s\n"), pMusicInfo->m_szGMFileVersion);
  609. _ftprintf(pFile, TEXT(" Ports:\n"));
  610. for (pMusicPort = pMusicInfo->m_pMusicPortFirst; pMusicPort != NULL;
  611. pMusicPort = pMusicPort->m_pMusicPortNext)
  612. {
  613. _ftprintf(pFile, TEXT(" %s, %s (%s), %s, %s, %s%s\n"),
  614. pMusicPort->m_szDescription,
  615. pMusicPort->m_bSoftware ? TEXT("Software") : TEXT("Hardware"),
  616. pMusicPort->m_bKernelMode ? TEXT("Kernel Mode") : TEXT("Not Kernel Mode"),
  617. pMusicPort->m_bOutputPort ? TEXT("Output") : TEXT("Input"),
  618. pMusicPort->m_bUsesDLS ? TEXT("DLS") : TEXT("No DLS"),
  619. pMusicPort->m_bExternal ? TEXT("External") : TEXT("Internal"),
  620. pMusicPort->m_bDefaultPort ? TEXT(", Default Port") : TEXT("")
  621. );
  622. }
  623. if (pMusicInfo->m_pRegErrorFirst == NULL)
  624. {
  625. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  626. }
  627. else
  628. {
  629. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  630. SaveRegistryErrorInfo(pFile, pMusicInfo->m_pRegErrorFirst);
  631. }
  632. _ftprintf(pFile, TEXT("Music Test Result: %s\n"), pMusicInfo->m_testResult.m_szDescriptionEnglish);
  633. _ftprintf(pFile, TEXT("\n"));
  634. return S_OK;
  635. }
  636. /****************************************************************************
  637. *
  638. * SaveShowInfo - Since this only shows up in the saved report,
  639. * we gather this info on the fly.
  640. *
  641. ****************************************************************************/
  642. HRESULT SaveShowInfo(FILE* pFile, ShowInfo* pShowInfo)
  643. {
  644. if( pShowInfo == NULL )
  645. return S_OK;
  646. _ftprintf(pFile, TEXT("------------------\n"));
  647. _ftprintf(pFile, TEXT("DirectShow Filters\n"));
  648. _ftprintf(pFile, TEXT("------------------\n"));
  649. FilterInfo* pFilterInfo;
  650. TCHAR szCurCatName[1024];
  651. TCHAR* szFileName = NULL;
  652. TCHAR* szLastSlash = NULL;
  653. _tcscpy( szCurCatName, TEXT("") );
  654. pFilterInfo = pShowInfo->m_pFilters;
  655. while(pFilterInfo)
  656. {
  657. if( _tcscmp( pFilterInfo->m_szCatName, szCurCatName ) != 0 )
  658. {
  659. _ftprintf(pFile, TEXT("\n%s:\n"), pFilterInfo->m_szCatName);
  660. _tcscpy( szCurCatName, pFilterInfo->m_szCatName );
  661. }
  662. _ftprintf(pFile, TEXT("%s,"), pFilterInfo->m_szName);
  663. _ftprintf(pFile, TEXT("0x%08x,"), pFilterInfo->m_dwMerit);
  664. _ftprintf(pFile, TEXT("%d,"), pFilterInfo->m_dwInputs);
  665. _ftprintf(pFile, TEXT("%d,"), pFilterInfo->m_dwOutputs);
  666. // Display only the file name
  667. szFileName = pFilterInfo->m_szFileName;
  668. szLastSlash = _tcsrchr( pFilterInfo->m_szFileName, TEXT('\\') );
  669. if( szLastSlash )
  670. szFileName = szLastSlash + 1;
  671. _ftprintf(pFile, TEXT("%s,"), szFileName);
  672. _ftprintf(pFile, TEXT("%s\n"), pFilterInfo->m_szFileVersion);
  673. pFilterInfo = pFilterInfo->m_pFilterInfoNext;
  674. }
  675. _ftprintf(pFile, TEXT("\n"));
  676. return S_OK;
  677. }
  678. /****************************************************************************
  679. *
  680. * SaveInputInfo
  681. *
  682. ****************************************************************************/
  683. HRESULT SaveInputInfo(FILE* pFile, InputInfo* pInputInfo)
  684. {
  685. InputDeviceInfo* pInputDeviceInfo;
  686. InputDeviceInfoNT* pInputDeviceInfoNT;
  687. InputDriverInfo* pInputDriverInfo;
  688. _ftprintf(pFile, TEXT("-------------\n"));
  689. _ftprintf(pFile, TEXT("Input Devices\n"));
  690. _ftprintf(pFile, TEXT("-------------\n"));
  691. if( pInputInfo == NULL )
  692. return S_OK;
  693. if (pInputInfo->m_bNT)
  694. {
  695. for (pInputDeviceInfoNT = pInputInfo->m_pInputDeviceInfoNTFirst; pInputDeviceInfoNT != NULL;
  696. pInputDeviceInfoNT = pInputDeviceInfoNT->m_pInputDeviceInfoNTNext)
  697. {
  698. _ftprintf(pFile, TEXT(" Device Name: %s\n"), pInputDeviceInfoNT->m_szName);
  699. _ftprintf(pFile, TEXT(" Provider: %s\n"), pInputDeviceInfoNT->m_szProvider);
  700. _ftprintf(pFile, TEXT(" Hardware ID: %s\n"), pInputDeviceInfoNT->m_szId);
  701. _ftprintf(pFile, TEXT(" Status: %d\n"), pInputDeviceInfoNT->m_dwProblem);
  702. _ftprintf(pFile, TEXT(" Port Name: %s\n"), pInputDeviceInfoNT->m_szPortName);
  703. _ftprintf(pFile, TEXT(" Port Provider: %s\n"), pInputDeviceInfoNT->m_szPortProvider);
  704. _ftprintf(pFile, TEXT(" Port ID: %s\n"), pInputDeviceInfoNT->m_szPortId);
  705. _ftprintf(pFile, TEXT(" Port Status: %d\n"), pInputDeviceInfoNT->m_dwPortProblem);
  706. _ftprintf(pFile, TEXT("\n"));
  707. }
  708. }
  709. else
  710. {
  711. for (pInputDeviceInfo = pInputInfo->m_pInputDeviceInfoFirst; pInputDeviceInfo != NULL;
  712. pInputDeviceInfo = pInputDeviceInfo->m_pInputDeviceInfoNext)
  713. {
  714. _ftprintf(pFile, TEXT(" Device Name: %s\n"), pInputDeviceInfo->m_szDeviceName);
  715. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pInputDeviceInfo->m_szDriverName);
  716. _ftprintf(pFile, TEXT(" Driver Version: %s"), pInputDeviceInfo->m_szDriverVersion);
  717. _ftprintf(pFile, TEXT(" (%s)\n"), pInputDeviceInfo->m_szDriverLanguage);
  718. _ftprintf(pFile, TEXT("Driver Attributes: %s %s\n"), pInputDeviceInfo->m_bBeta ? TEXT("Beta") : TEXT("Final"), pInputDeviceInfo->m_bDebug ? TEXT("Debug") : TEXT("Retail") );
  719. _ftprintf(pFile, TEXT(" Date and Size: %s, %d bytes\n"), pInputDeviceInfo->m_szDriverDate, pInputDeviceInfo->m_numBytes);
  720. _ftprintf(pFile, TEXT("\n"));
  721. }
  722. }
  723. _ftprintf(pFile, TEXT("Poll w/ Interrupt: "));
  724. TCHAR sz[200];
  725. lstrcpy( sz, (pInputInfo->m_bPollFlags) ? TEXT("Yes\n") : TEXT("No\n") );
  726. _ftprintf(pFile, sz);
  727. if (pInputInfo->m_pRegErrorFirst == NULL)
  728. {
  729. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  730. }
  731. else
  732. {
  733. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  734. SaveRegistryErrorInfo(pFile, pInputInfo->m_pRegErrorFirst);
  735. }
  736. _ftprintf(pFile, TEXT("\n"));
  737. _ftprintf(pFile, TEXT("-------------\n"));
  738. _ftprintf(pFile, TEXT("Input Drivers\n"));
  739. _ftprintf(pFile, TEXT("-------------\n"));
  740. for (pInputDriverInfo = pInputInfo->m_pInputDriverInfoFirst; pInputDriverInfo != NULL;
  741. pInputDriverInfo = pInputDriverInfo->m_pInputDriverInfoNext)
  742. {
  743. _ftprintf(pFile, TEXT(" Registry Key: %s\n"), pInputDriverInfo->m_szRegKey);
  744. _ftprintf(pFile, TEXT(" Active: %s\n"), pInputDriverInfo->m_bActive ? TEXT("Yes") : TEXT("No") );
  745. _ftprintf(pFile, TEXT(" DeviceID: %s\n"), pInputDriverInfo->m_szDeviceID);
  746. _ftprintf(pFile, TEXT("Matching DevID: %s\n"), pInputDriverInfo->m_szMatchingDeviceID);
  747. _ftprintf(pFile, TEXT(" 16-bit Driver: %s\n"), pInputDriverInfo->m_szDriver16);
  748. _ftprintf(pFile, TEXT(" 32-bit Driver: %s\n"), pInputDriverInfo->m_szDriver32);
  749. _ftprintf(pFile, TEXT("\n"));
  750. }
  751. _ftprintf(pFile, TEXT("\n"));
  752. return S_OK;
  753. }
  754. /****************************************************************************
  755. *
  756. * SaveNetInfo
  757. *
  758. ****************************************************************************/
  759. HRESULT SaveNetInfo(FILE* pFile, NetInfo* pNetInfo)
  760. {
  761. NetSP* pNetSP;
  762. NetApp* pNetApp;
  763. _ftprintf(pFile, TEXT("----------------------------\n"));
  764. _ftprintf(pFile, TEXT("DirectPlay Service Providers\n"));
  765. _ftprintf(pFile, TEXT("----------------------------\n"));
  766. if( pNetInfo == NULL )
  767. return S_OK;
  768. for (pNetSP = pNetInfo->m_pNetSPFirst; pNetSP != NULL; pNetSP = pNetSP->m_pNetSPNext)
  769. {
  770. _ftprintf(pFile, TEXT("%s - Registry: %s, File: %s (%s)\n"),
  771. pNetSP->m_szNameEnglish,
  772. pNetSP->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  773. pNetSP->m_szFile,
  774. pNetSP->m_szVersionEnglish);
  775. }
  776. _ftprintf(pFile, TEXT("DirectPlay Test Result: %s\n"), pNetInfo->m_testResult.m_szDescriptionEnglish);
  777. _ftprintf(pFile, TEXT("\n"));
  778. _ftprintf(pFile, TEXT("-------------------------\n"));
  779. _ftprintf(pFile, TEXT("DirectPlay Lobbyable Apps\n"));
  780. _ftprintf(pFile, TEXT("-------------------------\n"));
  781. for (pNetApp = pNetInfo->m_pNetAppFirst; pNetApp != NULL; pNetApp = pNetApp->m_pNetAppNext)
  782. {
  783. if( pNetApp->m_dwDXVer == 7 )
  784. {
  785. _ftprintf(pFile, TEXT("%s (DX%d) - Registry: %s, ExeFile: %s (%s)\n"),
  786. pNetApp->m_szName,
  787. pNetApp->m_dwDXVer,
  788. pNetApp->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  789. pNetApp->m_szExeFile,
  790. pNetApp->m_szExeVersionEnglish);
  791. }
  792. else
  793. {
  794. _ftprintf(pFile, TEXT("%s (DX%d) - Registry: %s, ExeFile: %s (%s) LauncherFile: %s (%s)\n"),
  795. pNetApp->m_szName,
  796. pNetApp->m_dwDXVer,
  797. pNetApp->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  798. pNetApp->m_szExeFile,
  799. pNetApp->m_szExeVersionEnglish,
  800. pNetApp->m_szLauncherFile,
  801. pNetApp->m_szLauncherVersionEnglish);
  802. }
  803. }
  804. _ftprintf(pFile, TEXT("\n"));
  805. return S_OK;
  806. }
  807. /****************************************************************************
  808. *
  809. * SaveInactiveDriverInfo
  810. *
  811. ****************************************************************************/
  812. HRESULT SaveInactiveDriverInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst)
  813. {
  814. BOOL bNoInactive;
  815. HKEY hKey;
  816. DWORD cbData;
  817. DWORD dwIndex;
  818. TCHAR szSubKeyName[1024];
  819. DisplayInfo* pDisplayInfo;
  820. HKEY hSubKey;
  821. TCHAR szSubSubKey[1024];
  822. TCHAR szDriverDesc[1024];
  823. DWORD ulType;
  824. TCHAR szTempString[1024];
  825. if (BIsPlatformNT())
  826. return S_OK;
  827. _ftprintf(pFile, TEXT("------------------------------------\n"));
  828. _ftprintf(pFile, TEXT("Inactive Display Entries in Registry\n"));
  829. _ftprintf(pFile, TEXT("------------------------------------\n"));
  830. bNoInactive = TRUE;
  831. // Display info (inactive).
  832. hKey = 0;
  833. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\Class\\Display"), 0, KEY_READ, &hKey))
  834. {
  835. cbData = sizeof szSubKeyName;
  836. dwIndex = 0;
  837. while (!RegEnumKeyEx(hKey, dwIndex, szSubKeyName, &cbData, NULL, NULL, NULL, NULL))
  838. {
  839. TCHAR* pch;
  840. BOOL bMatch = FALSE;
  841. // See if this driver is used:
  842. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  843. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  844. {
  845. pch = _tcsrchr(pDisplayInfo->m_szKeyDeviceKey, TEXT('\\'));
  846. if (pch != NULL)
  847. {
  848. pch++;
  849. if (lstrcmp(szSubKeyName, pch) == 0)
  850. {
  851. bMatch = TRUE;
  852. break;
  853. }
  854. }
  855. }
  856. if (!bMatch)
  857. {
  858. hSubKey = 0;
  859. wsprintf(szSubSubKey, TEXT("System\\CurrentControlSet\\Services\\Class\\Display\\%s"), szSubKeyName);
  860. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szSubSubKey, 0, KEY_READ, &hSubKey))
  861. {
  862. cbData = sizeof szDriverDesc;
  863. szDriverDesc[0] = 0;
  864. RegQueryValueEx(hSubKey, TEXT("DriverDesc"), 0, &ulType, (LPBYTE)szDriverDesc, &cbData);
  865. _ftprintf(pFile, TEXT(" Card name: %s\n"), szDriverDesc);
  866. bNoInactive = FALSE;
  867. }
  868. if (hSubKey)
  869. {
  870. RegCloseKey(hSubKey);
  871. hSubKey = 0;
  872. }
  873. wsprintf(szSubSubKey, TEXT("System\\CurrentControlSet\\Services\\Class\\Display\\%s\\DEFAULT"), szSubKeyName);
  874. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szSubSubKey, 0, KEY_READ, &hSubKey))
  875. {
  876. TCHAR szDisplayDriverName[1024];
  877. cbData = sizeof szDisplayDriverName;
  878. szDisplayDriverName[0] = 0;
  879. RegQueryValueEx(hSubKey, TEXT("DRV"), 0, &ulType, (LPBYTE)szDisplayDriverName, &cbData);
  880. _ftprintf(pFile, TEXT(" Driver: %s\n"), szDisplayDriverName);
  881. bNoInactive = FALSE;
  882. }
  883. if (hSubKey)
  884. {
  885. RegCloseKey(hSubKey);
  886. hSubKey = 0;
  887. }
  888. }
  889. cbData = sizeof szSubKeyName;
  890. dwIndex++;
  891. }
  892. }
  893. if (hKey)
  894. {
  895. RegCloseKey(hKey);
  896. hKey = 0;
  897. }
  898. if (bNoInactive)
  899. _ftprintf(pFile, TEXT(" None\n"));
  900. _ftprintf(pFile, TEXT("\n"));
  901. _ftprintf(pFile, TEXT("----------------------------------\n"));
  902. _ftprintf(pFile, TEXT("Inactive Sound Entries in Registry\n"));
  903. _ftprintf(pFile, TEXT("----------------------------------\n"));
  904. bNoInactive = TRUE;
  905. hKey = 0;
  906. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\control\\MediaResources\\wave"), 0, KEY_READ, &hKey))
  907. {
  908. dwIndex = 0;
  909. while (TRUE)
  910. {
  911. cbData = sizeof szSubKeyName;
  912. if (ERROR_SUCCESS != RegEnumKeyEx(hKey, dwIndex, szSubKeyName, &cbData, NULL, NULL, NULL, NULL))
  913. break;
  914. if (!RegOpenKeyEx(hKey, szSubKeyName, 0, KEY_READ, &hSubKey))
  915. {
  916. cbData = sizeof szTempString;
  917. if (!RegQueryValueEx(hSubKey, TEXT("Active"), 0, &ulType, (LPBYTE)szTempString, &cbData))
  918. {
  919. if (lstrcmp(szTempString, TEXT("0")) == 0)
  920. {
  921. TCHAR szWaveOutDesc[1024];
  922. TCHAR szWaveDriverName[1024];
  923. cbData = sizeof szWaveOutDesc;
  924. RegQueryValueEx(hSubKey, TEXT("Description"), 0, &ulType, (LPBYTE)szWaveOutDesc, &cbData);
  925. cbData = sizeof szWaveDriverName;
  926. RegQueryValueEx(hSubKey, TEXT("Driver"), 0, &ulType, (LPBYTE)szWaveDriverName, &cbData);
  927. _ftprintf(pFile, TEXT(" Card name: %s\n"), szWaveOutDesc);
  928. _ftprintf(pFile, TEXT(" Driver: %s\n"), szWaveDriverName);
  929. bNoInactive = FALSE;
  930. }
  931. }
  932. RegCloseKey(hSubKey);
  933. }
  934. dwIndex++;
  935. }
  936. RegCloseKey(hKey);
  937. }
  938. if (bNoInactive)
  939. _ftprintf(pFile, TEXT(" None\n"));
  940. _ftprintf(pFile, TEXT("\n"));
  941. return S_OK;
  942. }
  943. /****************************************************************************
  944. *
  945. * SaveRegistryErrorInfo
  946. *
  947. ****************************************************************************/
  948. HRESULT SaveRegistryErrorInfo(FILE* pFile, RegError* pRegErrorFirst)
  949. {
  950. RegError* pRegError = pRegErrorFirst;
  951. DWORD i;
  952. TCHAR* pszRoot;
  953. while (pRegError != NULL)
  954. {
  955. switch ((DWORD_PTR)pRegError->m_hkeyRoot)
  956. {
  957. case (DWORD_PTR)HKEY_LOCAL_MACHINE:
  958. pszRoot = TEXT("HKLM");
  959. break;
  960. case (DWORD_PTR)HKEY_CURRENT_USER:
  961. pszRoot = TEXT("HKCU");
  962. break;
  963. case (DWORD_PTR)HKEY_CLASSES_ROOT:
  964. pszRoot = TEXT("HKCR");
  965. break;
  966. case (DWORD_PTR)HKEY_USERS:
  967. pszRoot = TEXT("HKU");
  968. break;
  969. case (DWORD_PTR)HKEY_CURRENT_CONFIG:
  970. pszRoot = TEXT("HKCC");
  971. break;
  972. default:
  973. pszRoot = TEXT("");
  974. break;
  975. }
  976. _ftprintf(pFile, TEXT("Key '%s\\%s'"), pszRoot, pRegError->m_szKey);
  977. switch (pRegError->m_ret)
  978. {
  979. case RET_MISSINGKEY:
  980. _ftprintf(pFile, TEXT(" is missing.\n"));
  981. break;
  982. case RET_MISSINGVALUE:
  983. _ftprintf(pFile, TEXT(" is missing value '%s'.\n"), pRegError->m_szValue);
  984. break;
  985. case RET_VALUEWRONGTYPE:
  986. _ftprintf(pFile, TEXT(" has value '%s', but it is the wrong type.\n"), pRegError->m_szValue);
  987. break;
  988. case RET_VALUEWRONGDATA:
  989. _ftprintf(pFile, TEXT(", Value '%s'"), pRegError->m_szValue);
  990. switch(pRegError->m_dwTypeActual)
  991. {
  992. case REG_DWORD:
  993. _ftprintf(pFile, TEXT(", should be '%d' but is '%d'.\n"), pRegError->m_dwExpected, pRegError->m_dwActual);
  994. break;
  995. case REG_SZ:
  996. _ftprintf(pFile, TEXT(", should be '%s'"), pRegError->m_szExpected);
  997. _ftprintf(pFile, TEXT(", but is '%s'.\n"), pRegError->m_szActual);
  998. break;
  999. case REG_BINARY:
  1000. _ftprintf(pFile, TEXT(", should be '"));
  1001. for (i = 0; i < pRegError->m_dwExpectedSize; i++)
  1002. _ftprintf(pFile, TEXT("%02x"), pRegError->m_bExpected[i]);
  1003. _ftprintf(pFile, TEXT("' but is '"));
  1004. for (i = 0; i < pRegError->m_dwActualSize; i++)
  1005. _ftprintf(pFile, TEXT("%02x"), pRegError->m_bActual[i]);
  1006. _ftprintf(pFile, TEXT("'.\n"));
  1007. break;
  1008. }
  1009. break;
  1010. }
  1011. pRegError = pRegError->m_pRegErrorNext;
  1012. }
  1013. return S_OK;
  1014. }
  1015. /****************************************************************************
  1016. *
  1017. * SaveDebugLevels
  1018. *
  1019. ****************************************************************************/
  1020. HRESULT SaveDebugLevels(FILE* pFile, SysInfo* pSysInfo)
  1021. {
  1022. TCHAR sz[1024];
  1023. if( pSysInfo->m_bIsD3D8DebugRuntimeAvailable ||
  1024. pSysInfo->m_bIsDInput8DebugRuntimeAvailable ||
  1025. pSysInfo->m_bIsDMusicDebugRuntimeAvailable ||
  1026. pSysInfo->m_bIsDDrawDebugRuntime ||
  1027. pSysInfo->m_bIsDSoundDebugRuntime ||
  1028. pSysInfo->m_bIsDPlayDebugRuntime ||
  1029. pSysInfo->m_nD3DDebugLevel > 0 ||
  1030. pSysInfo->m_nDDrawDebugLevel > 0 ||
  1031. pSysInfo->m_nDIDebugLevel > 0 ||
  1032. pSysInfo->m_nDMusicDebugLevel > 0 ||
  1033. pSysInfo->m_nDPlayDebugLevel > 0 ||
  1034. pSysInfo->m_nDSoundDebugLevel > 0 )
  1035. {
  1036. _ftprintf(pFile, TEXT("--------------------\n"));
  1037. _ftprintf(pFile, TEXT("DirectX Debug Levels\n"));
  1038. _ftprintf(pFile, TEXT("--------------------\n"));
  1039. _stprintf(sz, TEXT("Direct3D: %d/4 (%s)\n"), pSysInfo->m_nD3DDebugLevel, pSysInfo->m_bIsD3D8DebugRuntimeAvailable ? (pSysInfo->m_bIsD3DDebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1040. _ftprintf(pFile, sz);
  1041. _stprintf(sz, TEXT("DirectDraw: %d/4 (%s)\n"), pSysInfo->m_nDDrawDebugLevel, pSysInfo->m_bIsDDrawDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1042. _ftprintf(pFile, sz);
  1043. _stprintf(sz, TEXT("DirectInput: %d/5 (%s)\n"), pSysInfo->m_nDIDebugLevel, pSysInfo->m_bIsDInput8DebugRuntimeAvailable ? (pSysInfo->m_bIsDInput8DebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1044. _ftprintf(pFile, sz);
  1045. _stprintf(sz, TEXT("DirectMusic: %d/5 (%s)\n"), pSysInfo->m_nDMusicDebugLevel, pSysInfo->m_bIsDMusicDebugRuntimeAvailable ? (pSysInfo->m_bIsDMusicDebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1046. _ftprintf(pFile, sz);
  1047. _stprintf(sz, TEXT("DirectPlay: %d/9 (%s)\n"), pSysInfo->m_nDPlayDebugLevel, pSysInfo->m_bIsDPlayDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1048. _ftprintf(pFile, sz);
  1049. _stprintf(sz, TEXT("DirectSound: %d/5 (%s)\n"), pSysInfo->m_nDSoundDebugLevel, pSysInfo->m_bIsDSoundDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1050. _ftprintf(pFile, sz);
  1051. // fwrite( sz, sizeof( TCHAR ), lstrlen(sz), pFile );
  1052. //#pragma prefast(suppress:69, _ftprintf works and fwrite doesnt)
  1053. _ftprintf(pFile, TEXT("\n"));
  1054. }
  1055. return S_OK;
  1056. }