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.

1209 lines
46 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*8];
  230. _tcscpy( strBuffer, strNote );
  231. TCHAR* pEndOfLine;
  232. TCHAR* pCurrent = strBuffer;
  233. TCHAR* pStartOfNext;
  234. BOOL bFirstTime = TRUE;
  235. pEndOfLine = _tcschr( pCurrent, TEXT('\r') );
  236. if( pEndOfLine == NULL )
  237. {
  238. _ftprintf(pFile, TEXT("%s\n"), pCurrent );
  239. return S_OK;
  240. }
  241. while(TRUE)
  242. {
  243. *pEndOfLine = 0;
  244. pStartOfNext = pEndOfLine + 2;
  245. // Output the current line, iff its not a "To test" line
  246. if( _tcsstr( pCurrent, TEXT("To test") ) == NULL )
  247. {
  248. // Ouput trailing spaces everytime except the first time
  249. if( !bFirstTime )
  250. _ftprintf(pFile, TEXT(" ") );
  251. bFirstTime = FALSE;
  252. _ftprintf(pFile, TEXT("%s\n"), pCurrent );
  253. }
  254. // Advance current
  255. pCurrent = pStartOfNext;
  256. // Look for the end of the next, and stop if there's no more
  257. pEndOfLine = _tcschr( pStartOfNext, TEXT('\r') );
  258. if( pEndOfLine == NULL )
  259. break;
  260. }
  261. return S_OK;
  262. }
  263. /****************************************************************************
  264. *
  265. * SaveNotesInfo
  266. *
  267. ****************************************************************************/
  268. HRESULT SaveNotesInfo(FILE* pFile, SysInfo* pSysInfo,
  269. DisplayInfo* pDisplayInfoFirst, SoundInfo* pSoundInfoFirst)
  270. {
  271. DisplayInfo* pDisplayInfo;
  272. SoundInfo* pSoundInfo;
  273. DWORD dwIndex;
  274. _ftprintf(pFile, TEXT("------------\n"));
  275. _ftprintf(pFile, TEXT("DxDiag Notes\n"));
  276. _ftprintf(pFile, TEXT("------------\n"));
  277. _ftprintf(pFile, TEXT(" DirectX Files Tab: ") );
  278. SaveNote(pFile, pSysInfo->m_szDXFileNotesEnglish);
  279. dwIndex = 1;
  280. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  281. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  282. {
  283. _ftprintf(pFile, TEXT(" Display Tab %d: "), dwIndex);
  284. SaveNote(pFile, pDisplayInfo->m_szNotesEnglish);
  285. dwIndex++;
  286. }
  287. dwIndex = 1;
  288. for (pSoundInfo = pSoundInfoFirst; pSoundInfo != NULL;
  289. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  290. {
  291. _ftprintf(pFile, TEXT(" Sound Tab %d: "), dwIndex);
  292. SaveNote(pFile, pSoundInfo->m_szNotesEnglish);
  293. dwIndex++;
  294. }
  295. _ftprintf(pFile, TEXT(" Music Tab: "));
  296. SaveNote(pFile, pSysInfo->m_szMusicNotesEnglish);
  297. _ftprintf(pFile, TEXT(" Input Tab: "));
  298. SaveNote(pFile, pSysInfo->m_szInputNotesEnglish);
  299. _ftprintf(pFile, TEXT(" Network Tab: "));
  300. SaveNote(pFile, pSysInfo->m_szNetworkNotesEnglish);
  301. _ftprintf(pFile, TEXT("\n"));
  302. return S_OK;
  303. }
  304. /****************************************************************************
  305. *
  306. * SaveDxComponentFileInfo
  307. *
  308. ****************************************************************************/
  309. HRESULT SaveDxComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst)
  310. {
  311. FileInfo* pFileInfo;
  312. TCHAR sz[1024];
  313. _ftprintf(pFile, TEXT("------------------\n"));
  314. _ftprintf(pFile, TEXT("DirectX Components\n"));
  315. _ftprintf(pFile, TEXT("------------------\n"));
  316. for (pFileInfo = pFileInfoFirst; pFileInfo != NULL;
  317. pFileInfo = pFileInfo->m_pFileInfoNext)
  318. {
  319. if (!pFileInfo->m_bExists && !pFileInfo->m_bProblem)
  320. continue;
  321. wsprintf(sz, TEXT("%12s: %s %s %s %s %s %d bytes %s\n"),
  322. pFileInfo->m_szName,
  323. pFileInfo->m_szVersion,
  324. pFileInfo->m_szLanguage,
  325. pFileInfo->m_bBeta ? TEXT("Beta") : TEXT("Final"),
  326. pFileInfo->m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  327. pFileInfo->m_szDatestamp,
  328. pFileInfo->m_numBytes,
  329. pFileInfo->m_bSigned ? TEXT("Digitally Signed") : TEXT(""));
  330. _ftprintf(pFile, sz);
  331. }
  332. _ftprintf(pFile, TEXT("\n"));
  333. return S_OK;
  334. }
  335. /****************************************************************************
  336. *
  337. * SaveDxWinComponentFileInfo
  338. *
  339. ****************************************************************************/
  340. HRESULT SaveDxWinComponentFileInfo(FILE* pFile, FileInfo* pFileInfoFirst)
  341. {
  342. if (pFileInfoFirst == NULL)
  343. return S_OK;
  344. FileInfo* pFileInfo;
  345. TCHAR sz[1024];
  346. _ftprintf(pFile, TEXT("------------------------------------------------\n"));
  347. _ftprintf(pFile, TEXT("Components Incorrectly Located in Windows Folder\n"));
  348. _ftprintf(pFile, TEXT("------------------------------------------------\n"));
  349. for (pFileInfo = pFileInfoFirst; pFileInfo != NULL;
  350. pFileInfo = pFileInfo->m_pFileInfoNext)
  351. {
  352. wsprintf(sz, TEXT("%12s: %s %s %s %s %s %d bytes %s\n"),
  353. pFileInfo->m_szName,
  354. pFileInfo->m_szVersion,
  355. pFileInfo->m_szLanguage,
  356. pFileInfo->m_bBeta ? TEXT("Beta") : TEXT("Final"),
  357. pFileInfo->m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  358. pFileInfo->m_szDatestamp,
  359. pFileInfo->m_numBytes,
  360. pFileInfo->m_bSigned ? "Digitally Signed" : "");
  361. _ftprintf(pFile, sz);
  362. }
  363. _ftprintf(pFile, TEXT("\n"));
  364. return S_OK;
  365. }
  366. /****************************************************************************
  367. *
  368. * SaveBackedUpFileInfo - Since this only shows up in the saved report,
  369. * we gather this info on the fly.
  370. *
  371. ****************************************************************************/
  372. HRESULT SaveBackedUpFileInfo(FILE* pFile)
  373. {
  374. FileInfo fileInfo;
  375. TCHAR szBackupDir[1024];
  376. TCHAR szCurrentDir[1024];
  377. TCHAR szFileSpec[1024];
  378. HANDLE hFindFile;
  379. WIN32_FIND_DATA findData;
  380. BOOL bFirstFile = TRUE;
  381. BOOL bFirstFileThisDir;
  382. HANDLE hFindFile2;
  383. WIN32_FIND_DATA findData2;
  384. GetSystemDirectory(szBackupDir, MAX_PATH);
  385. lstrcat(szBackupDir, TEXT("\\DXBackup"));
  386. lstrcpy(szFileSpec, szBackupDir);
  387. lstrcat(szFileSpec, TEXT("\\*.*"));
  388. hFindFile = FindFirstFile(szFileSpec, &findData);
  389. if (hFindFile != INVALID_HANDLE_VALUE)
  390. {
  391. while (TRUE)
  392. {
  393. if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
  394. lstrcmp(findData.cFileName, TEXT(".")) != 0 &&
  395. lstrcmp(findData.cFileName, TEXT("..")) != 0)
  396. {
  397. bFirstFileThisDir = TRUE;
  398. wsprintf(szCurrentDir, TEXT("%s\\%s"), szBackupDir, findData.cFileName);
  399. lstrcpy(szFileSpec, szCurrentDir);
  400. lstrcat(szFileSpec, TEXT("\\*.*"));
  401. hFindFile2 = FindFirstFile(szFileSpec, &findData2);
  402. if (hFindFile2 != INVALID_HANDLE_VALUE)
  403. {
  404. while (TRUE)
  405. {
  406. if ((findData2.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
  407. {
  408. if (bFirstFile)
  409. {
  410. bFirstFile = FALSE;
  411. _ftprintf(pFile, TEXT("-----------------------------------------------\n"));
  412. _ftprintf(pFile, TEXT("Backed-up drivers in %s\n"), szBackupDir);
  413. _ftprintf(pFile, TEXT("-----------------------------------------------\n"));
  414. }
  415. else if (bFirstFileThisDir)
  416. {
  417. _ftprintf(pFile, TEXT("\n"));
  418. }
  419. if (bFirstFileThisDir)
  420. {
  421. bFirstFileThisDir = FALSE;
  422. _ftprintf(pFile, TEXT("%s:\n"), szCurrentDir);
  423. }
  424. wsprintf(szFileSpec, TEXT("%s\\%s"), szCurrentDir, findData2.cFileName);
  425. ZeroMemory(&fileInfo, sizeof(fileInfo));
  426. lstrcpy(fileInfo.m_szName, findData2.cFileName);
  427. GetFileVersion(szFileSpec, fileInfo.m_szVersion, fileInfo.m_szAttributes, fileInfo.m_szLanguageLocal, fileInfo.m_szLanguage, &fileInfo.m_bBeta, &fileInfo.m_bDebug);
  428. GetFileDateAndSize(szFileSpec, fileInfo.m_szDatestampLocal, fileInfo.m_szDatestamp, &fileInfo.m_numBytes);
  429. FileIsSigned(szFileSpec, &fileInfo.m_bSigned, NULL);
  430. _ftprintf(pFile, TEXT("%12s: %s %s %s %s Date: %s Size: %d bytes %s\n"),
  431. fileInfo.m_szName,
  432. fileInfo.m_szVersion,
  433. fileInfo.m_szLanguage,
  434. fileInfo.m_bBeta ? TEXT("Beta") : TEXT("Final"),
  435. fileInfo.m_bDebug ? TEXT("Debug") : TEXT("Retail"),
  436. fileInfo.m_szDatestamp,
  437. fileInfo.m_numBytes,
  438. fileInfo.m_bSigned ? TEXT("Digitally Signed") : TEXT(""));
  439. }
  440. if (!FindNextFile(hFindFile2, &findData2))
  441. break;
  442. }
  443. FindClose(hFindFile2);
  444. }
  445. }
  446. if (!FindNextFile(hFindFile, &findData))
  447. break;
  448. }
  449. FindClose(hFindFile);
  450. };
  451. if (!bFirstFile)
  452. _ftprintf(pFile, TEXT("\n"));
  453. return S_OK;
  454. }
  455. /****************************************************************************
  456. *
  457. * SaveDisplayInfo
  458. *
  459. ****************************************************************************/
  460. HRESULT SaveDisplayInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst)
  461. {
  462. DisplayInfo* pDisplayInfo;
  463. TCHAR szVersion[1024];
  464. _ftprintf(pFile, TEXT("---------------\n"));
  465. _ftprintf(pFile, TEXT("Display Devices\n"));
  466. _ftprintf(pFile, TEXT("---------------\n"));
  467. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  468. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  469. {
  470. wsprintf(szVersion, TEXT("%s (%s)"), pDisplayInfo->m_szDriverVersion, pDisplayInfo->m_szDriverLanguage);
  471. _ftprintf(pFile, TEXT(" Card name: %s\n"), pDisplayInfo->m_szDescription);
  472. _ftprintf(pFile, TEXT(" Manufacturer: %s\n"), pDisplayInfo->m_szManufacturer);
  473. _ftprintf(pFile, TEXT(" Chip type: %s\n"), pDisplayInfo->m_szChipType);
  474. _ftprintf(pFile, TEXT(" DAC type: %s\n"), pDisplayInfo->m_szDACType);
  475. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pDisplayInfo->m_szKeyDeviceID);
  476. _ftprintf(pFile, TEXT(" Display Memory: %s\n"), pDisplayInfo->m_szDisplayMemoryEnglish);
  477. _ftprintf(pFile, TEXT(" Current Mode: %s\n"), pDisplayInfo->m_szDisplayModeEnglish);
  478. _ftprintf(pFile, TEXT(" Monitor: %s\n"), pDisplayInfo->m_szMonitorName);
  479. _ftprintf(pFile, TEXT(" Monitor Max Res: %s\n"), pDisplayInfo->m_szMonitorMaxRes);
  480. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pDisplayInfo->m_szDriverName);
  481. _ftprintf(pFile, TEXT(" Driver Version: %s\n"), szVersion);
  482. _ftprintf(pFile, TEXT(" DDI Version: %s\n"), pDisplayInfo->m_szDDIVersion);
  483. _ftprintf(pFile, TEXT("Driver Attributes: %s %s\n"), pDisplayInfo->m_bDriverBeta ? TEXT("Beta") : TEXT("Final"), pDisplayInfo->m_bDriverDebug ? TEXT("Debug") : TEXT("Retail"));
  484. _ftprintf(pFile, TEXT(" Driver Date/Size: %s, %d bytes\n"), pDisplayInfo->m_szDriverDate, pDisplayInfo->m_cbDriver);
  485. _ftprintf(pFile, TEXT(" Driver Signed: %s\n"), pDisplayInfo->m_bDriverSignedValid ? ( pDisplayInfo->m_bDriverSigned ? TEXT("Yes") : TEXT("No") ) : TEXT("n/a") );
  486. _ftprintf(pFile, TEXT(" WHQL Date Stamp: %s\n"), pDisplayInfo->m_bDX8DriverSignedValid ? ( pDisplayInfo->m_bDX8DriverSigned ? pDisplayInfo->m_szDX8DriverSignDate : TEXT("None") ) : TEXT("n/a") );
  487. _ftprintf(pFile, TEXT(" VDD: %s\n"), pDisplayInfo->m_szVdd);
  488. _ftprintf(pFile, TEXT(" Mini VDD: %s\n"), pDisplayInfo->m_szMiniVdd);
  489. _ftprintf(pFile, TEXT(" Mini VDD Date: %s, %d bytes\n"), pDisplayInfo->m_szMiniVddDate, pDisplayInfo->m_cbMiniVdd);
  490. _ftprintf(pFile, TEXT("Device Identifier: %s\n"), pDisplayInfo->m_szDX8DeviceIdentifier );
  491. _ftprintf(pFile, TEXT(" Vendor ID: %s\n"), pDisplayInfo->m_szDX8VendorId );
  492. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pDisplayInfo->m_szDX8DeviceId );
  493. _ftprintf(pFile, TEXT(" SubSys ID: %s\n"), pDisplayInfo->m_szDX8SubSysId );
  494. _ftprintf(pFile, TEXT(" Revision ID: %s\n"), pDisplayInfo->m_szDX8Revision );
  495. if (pDisplayInfo->m_pRegErrorFirst == NULL)
  496. {
  497. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  498. }
  499. else
  500. {
  501. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  502. SaveRegistryErrorInfo(pFile, pDisplayInfo->m_pRegErrorFirst);
  503. }
  504. _ftprintf(pFile, TEXT(" DDraw Status: %s\n"), pDisplayInfo->m_szDDStatusEnglish);
  505. _ftprintf(pFile, TEXT(" D3D Status: %s\n"), pDisplayInfo->m_szD3DStatusEnglish);
  506. _ftprintf(pFile, TEXT(" AGP Status: %s\n"), pDisplayInfo->m_szAGPStatusEnglish);
  507. _ftprintf(pFile, TEXT("DDraw Test Result: %s\n"), pDisplayInfo->m_testResultDD.m_szDescriptionEnglish);
  508. _ftprintf(pFile, TEXT(" D3D7 Test Result: %s\n"), pDisplayInfo->m_testResultD3D7.m_szDescriptionEnglish);
  509. _ftprintf(pFile, TEXT(" D3D8 Test Result: %s\n"), pDisplayInfo->m_testResultD3D8.m_szDescriptionEnglish);
  510. _ftprintf(pFile, TEXT("\n"));
  511. }
  512. return S_OK;
  513. }
  514. /****************************************************************************
  515. *
  516. * SaveSoundInfo
  517. *
  518. ****************************************************************************/
  519. HRESULT SaveSoundInfo(FILE* pFile, SoundInfo* pSoundInfoFirst)
  520. {
  521. SoundInfo* pSoundInfo;
  522. TCHAR szAcceleration[1024];
  523. TCHAR szVersion[1024];
  524. TCHAR szAttributes[1024];
  525. TCHAR szSigned[1024];
  526. TCHAR szDateSize[1024];
  527. _ftprintf(pFile, TEXT("-------------\n"));
  528. _ftprintf(pFile, TEXT("Sound Devices\n"));
  529. _ftprintf(pFile, TEXT("-------------\n"));
  530. for (pSoundInfo = pSoundInfoFirst; pSoundInfo != NULL;
  531. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  532. {
  533. switch (pSoundInfo->m_lwAccelerationLevel)
  534. {
  535. case 0:
  536. lstrcpy(szAcceleration, TEXT("Emulation Only"));
  537. break;
  538. case 1:
  539. lstrcpy(szAcceleration, TEXT("Basic"));
  540. break;
  541. case 2:
  542. lstrcpy(szAcceleration, TEXT("Standard"));
  543. break;
  544. case 3:
  545. lstrcpy(szAcceleration, TEXT("Full"));
  546. break;
  547. default:
  548. lstrcpy(szAcceleration, TEXT("Unknown"));
  549. break;
  550. }
  551. if (lstrlen(pSoundInfo->m_szDriverName) > 0)
  552. {
  553. wsprintf(szVersion, TEXT("%s (%s)"), pSoundInfo->m_szDriverVersion, pSoundInfo->m_szDriverLanguage);
  554. wsprintf(szAttributes, TEXT("%s %s"), pSoundInfo->m_bDriverBeta ? TEXT("Beta") : TEXT("Final"), pSoundInfo->m_bDriverDebug ? TEXT("Debug") : TEXT("Retail"));
  555. wsprintf(szSigned, TEXT("%s"), pSoundInfo->m_bDriverSignedValid ? ( pSoundInfo->m_bDriverSigned ? TEXT("Yes") : TEXT("No") ) : TEXT("n/a") );
  556. wsprintf(szDateSize, TEXT("%s, %d bytes"), pSoundInfo->m_szDriverDate, pSoundInfo->m_numBytes);
  557. }
  558. else
  559. {
  560. lstrcpy(szVersion, TEXT(""));
  561. lstrcpy(szAttributes, TEXT(""));
  562. lstrcpy(szSigned, TEXT(""));
  563. lstrcpy(szDateSize, TEXT(""));
  564. }
  565. _ftprintf(pFile, TEXT(" Description: %s\n"), pSoundInfo->m_szDescription);
  566. _ftprintf(pFile, TEXT(" Device ID: %s\n"), pSoundInfo->m_szDeviceID);
  567. _ftprintf(pFile, TEXT(" Manufacturer ID: %s\n"), pSoundInfo->m_szManufacturerID);
  568. _ftprintf(pFile, TEXT(" Product ID: %s\n"), pSoundInfo->m_szProductID);
  569. _ftprintf(pFile, TEXT(" Type: %s\n"), pSoundInfo->m_szType);
  570. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pSoundInfo->m_szDriverName);
  571. _ftprintf(pFile, TEXT(" Driver Version: %s\n"), szVersion);
  572. _ftprintf(pFile, TEXT("Driver Attributes: %s\n"), szAttributes);
  573. _ftprintf(pFile, TEXT(" Driver Signed: %s\n"), szSigned);
  574. _ftprintf(pFile, TEXT(" Date and Size: %s\n"), szDateSize);
  575. _ftprintf(pFile, TEXT(" Other Files: %s\n"), pSoundInfo->m_szOtherDrivers);
  576. _ftprintf(pFile, TEXT(" Driver Provider: %s\n"), pSoundInfo->m_szProvider);
  577. _ftprintf(pFile, TEXT(" HW Accel Level: %s\n"), szAcceleration);
  578. if (pSoundInfo->m_pRegErrorFirst == NULL)
  579. {
  580. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  581. }
  582. else
  583. {
  584. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  585. SaveRegistryErrorInfo(pFile, pSoundInfo->m_pRegErrorFirst);
  586. }
  587. _ftprintf(pFile, TEXT("Sound Test Result: %s\n"), pSoundInfo->m_testResultSnd.m_szDescriptionEnglish);
  588. _ftprintf(pFile, TEXT("\n"));
  589. }
  590. return S_OK;
  591. }
  592. /****************************************************************************
  593. *
  594. * SaveMusicInfo
  595. *
  596. ****************************************************************************/
  597. HRESULT SaveMusicInfo(FILE* pFile, MusicInfo* pMusicInfo)
  598. {
  599. MusicPort* pMusicPort;
  600. if (pMusicInfo == NULL || !pMusicInfo->m_bDMusicInstalled)
  601. return S_OK;
  602. _ftprintf(pFile, TEXT("-----------\n"));
  603. _ftprintf(pFile, TEXT("DirectMusic\n"));
  604. _ftprintf(pFile, TEXT("-----------\n"));
  605. _ftprintf(pFile, TEXT(" DLS Path: %s\n"), pMusicInfo->m_szGMFilePath);
  606. _ftprintf(pFile, TEXT(" Version: %s\n"), pMusicInfo->m_szGMFileVersion);
  607. _ftprintf(pFile, TEXT(" Ports:\n"));
  608. for (pMusicPort = pMusicInfo->m_pMusicPortFirst; pMusicPort != NULL;
  609. pMusicPort = pMusicPort->m_pMusicPortNext)
  610. {
  611. _ftprintf(pFile, TEXT(" %s, %s (%s), %s, %s, %s%s\n"),
  612. pMusicPort->m_szDescription,
  613. pMusicPort->m_bSoftware ? TEXT("Software") : TEXT("Hardware"),
  614. pMusicPort->m_bKernelMode ? TEXT("Kernel Mode") : TEXT("Not Kernel Mode"),
  615. pMusicPort->m_bOutputPort ? TEXT("Output") : TEXT("Input"),
  616. pMusicPort->m_bUsesDLS ? TEXT("DLS") : TEXT("No DLS"),
  617. pMusicPort->m_bExternal ? TEXT("External") : TEXT("Internal"),
  618. pMusicPort->m_bDefaultPort ? TEXT(", Default Port") : TEXT("")
  619. );
  620. }
  621. if (pMusicInfo->m_pRegErrorFirst == NULL)
  622. {
  623. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  624. }
  625. else
  626. {
  627. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  628. SaveRegistryErrorInfo(pFile, pMusicInfo->m_pRegErrorFirst);
  629. }
  630. _ftprintf(pFile, TEXT("Music Test Result: %s\n"), pMusicInfo->m_testResult.m_szDescriptionEnglish);
  631. _ftprintf(pFile, TEXT("\n"));
  632. return S_OK;
  633. }
  634. /****************************************************************************
  635. *
  636. * SaveShowInfo - Since this only shows up in the saved report,
  637. * we gather this info on the fly.
  638. *
  639. ****************************************************************************/
  640. HRESULT SaveShowInfo(FILE* pFile, ShowInfo* pShowInfo)
  641. {
  642. if( pShowInfo == NULL )
  643. return S_OK;
  644. _ftprintf(pFile, TEXT("------------------\n"));
  645. _ftprintf(pFile, TEXT("DirectShow Filters\n"));
  646. _ftprintf(pFile, TEXT("------------------\n"));
  647. FilterInfo* pFilterInfo;
  648. TCHAR szCurCatName[1024];
  649. TCHAR* szFileName = NULL;
  650. TCHAR* szLastSlash = NULL;
  651. _tcscpy( szCurCatName, TEXT("") );
  652. pFilterInfo = pShowInfo->m_pFilters;
  653. while(pFilterInfo)
  654. {
  655. if( _tcscmp( pFilterInfo->m_szCatName, szCurCatName ) != 0 )
  656. {
  657. _ftprintf(pFile, TEXT("\n%s:\n"), pFilterInfo->m_szCatName);
  658. _tcscpy( szCurCatName, pFilterInfo->m_szCatName );
  659. }
  660. _ftprintf(pFile, TEXT("%s,"), pFilterInfo->m_szName);
  661. _ftprintf(pFile, TEXT("0x%08x,"), pFilterInfo->m_dwMerit);
  662. _ftprintf(pFile, TEXT("%d,"), pFilterInfo->m_dwInputs);
  663. _ftprintf(pFile, TEXT("%d,"), pFilterInfo->m_dwOutputs);
  664. // Display only the file name
  665. szFileName = pFilterInfo->m_szFileName;
  666. szLastSlash = _tcsrchr( pFilterInfo->m_szFileName, TEXT('\\') );
  667. if( szLastSlash )
  668. szFileName = szLastSlash + 1;
  669. _ftprintf(pFile, TEXT("%s,"), szFileName);
  670. _ftprintf(pFile, TEXT("%s\n"), pFilterInfo->m_szFileVersion);
  671. pFilterInfo = pFilterInfo->m_pFilterInfoNext;
  672. }
  673. _ftprintf(pFile, TEXT("\n"));
  674. return S_OK;
  675. }
  676. /****************************************************************************
  677. *
  678. * SaveInputInfo
  679. *
  680. ****************************************************************************/
  681. HRESULT SaveInputInfo(FILE* pFile, InputInfo* pInputInfo)
  682. {
  683. InputDeviceInfo* pInputDeviceInfo;
  684. InputDeviceInfoNT* pInputDeviceInfoNT;
  685. InputDriverInfo* pInputDriverInfo;
  686. _ftprintf(pFile, TEXT("-------------\n"));
  687. _ftprintf(pFile, TEXT("Input Devices\n"));
  688. _ftprintf(pFile, TEXT("-------------\n"));
  689. if( pInputInfo == NULL )
  690. return S_OK;
  691. if (pInputInfo->m_bNT)
  692. {
  693. for (pInputDeviceInfoNT = pInputInfo->m_pInputDeviceInfoNTFirst; pInputDeviceInfoNT != NULL;
  694. pInputDeviceInfoNT = pInputDeviceInfoNT->m_pInputDeviceInfoNTNext)
  695. {
  696. _ftprintf(pFile, TEXT(" Device Name: %s\n"), pInputDeviceInfoNT->m_szName);
  697. _ftprintf(pFile, TEXT(" Provider: %s\n"), pInputDeviceInfoNT->m_szProvider);
  698. _ftprintf(pFile, TEXT(" Hardware ID: %s\n"), pInputDeviceInfoNT->m_szId);
  699. _ftprintf(pFile, TEXT(" Status: %d\n"), pInputDeviceInfoNT->m_dwProblem);
  700. _ftprintf(pFile, TEXT(" Port Name: %s\n"), pInputDeviceInfoNT->m_szPortName);
  701. _ftprintf(pFile, TEXT(" Port Provider: %s\n"), pInputDeviceInfoNT->m_szPortProvider);
  702. _ftprintf(pFile, TEXT(" Port ID: %s\n"), pInputDeviceInfoNT->m_szPortId);
  703. _ftprintf(pFile, TEXT(" Port Status: %d\n"), pInputDeviceInfoNT->m_dwPortProblem);
  704. _ftprintf(pFile, TEXT("\n"));
  705. }
  706. }
  707. else
  708. {
  709. for (pInputDeviceInfo = pInputInfo->m_pInputDeviceInfoFirst; pInputDeviceInfo != NULL;
  710. pInputDeviceInfo = pInputDeviceInfo->m_pInputDeviceInfoNext)
  711. {
  712. _ftprintf(pFile, TEXT(" Device Name: %s\n"), pInputDeviceInfo->m_szDeviceName);
  713. _ftprintf(pFile, TEXT(" Driver Name: %s\n"), pInputDeviceInfo->m_szDriverName);
  714. _ftprintf(pFile, TEXT(" Driver Version: %s"), pInputDeviceInfo->m_szDriverVersion);
  715. _ftprintf(pFile, TEXT(" (%s)\n"), pInputDeviceInfo->m_szDriverLanguage);
  716. _ftprintf(pFile, TEXT("Driver Attributes: %s %s\n"), pInputDeviceInfo->m_bBeta ? "Beta" : "Final", pInputDeviceInfo->m_bDebug ? "Debug" : "Retail");
  717. _ftprintf(pFile, TEXT(" Date and Size: %s, %d bytes\n"), pInputDeviceInfo->m_szDriverDate, pInputDeviceInfo->m_numBytes);
  718. _ftprintf(pFile, TEXT("\n"));
  719. }
  720. }
  721. _ftprintf(pFile, TEXT("Poll w/ Interrupt: "));
  722. _ftprintf(pFile, (pInputInfo->m_bPollFlags) ? TEXT("Yes\n") : TEXT("No\n") );
  723. if (pInputInfo->m_pRegErrorFirst == NULL)
  724. {
  725. _ftprintf(pFile, TEXT(" Registry: OK\n"));
  726. }
  727. else
  728. {
  729. _ftprintf(pFile, TEXT(" Registry: Errors found:\n"));
  730. SaveRegistryErrorInfo(pFile, pInputInfo->m_pRegErrorFirst);
  731. }
  732. _ftprintf(pFile, TEXT("\n"));
  733. _ftprintf(pFile, TEXT("-------------\n"));
  734. _ftprintf(pFile, TEXT("Input Drivers\n"));
  735. _ftprintf(pFile, TEXT("-------------\n"));
  736. for (pInputDriverInfo = pInputInfo->m_pInputDriverInfoFirst; pInputDriverInfo != NULL;
  737. pInputDriverInfo = pInputDriverInfo->m_pInputDriverInfoNext)
  738. {
  739. _ftprintf(pFile, TEXT(" Registry Key: %s\n"), pInputDriverInfo->m_szRegKey);
  740. _ftprintf(pFile, TEXT(" Active: %s\n"), pInputDriverInfo->m_bActive ? "Yes" : "No");
  741. _ftprintf(pFile, TEXT(" DeviceID: %s\n"), pInputDriverInfo->m_szDeviceID);
  742. _ftprintf(pFile, TEXT("Matching DevID: %s\n"), pInputDriverInfo->m_szMatchingDeviceID);
  743. _ftprintf(pFile, TEXT(" 16-bit Driver: %s\n"), pInputDriverInfo->m_szDriver16);
  744. _ftprintf(pFile, TEXT(" 32-bit Driver: %s\n"), pInputDriverInfo->m_szDriver32);
  745. _ftprintf(pFile, TEXT("\n"));
  746. }
  747. _ftprintf(pFile, TEXT("\n"));
  748. return S_OK;
  749. }
  750. /****************************************************************************
  751. *
  752. * SaveNetInfo
  753. *
  754. ****************************************************************************/
  755. HRESULT SaveNetInfo(FILE* pFile, NetInfo* pNetInfo)
  756. {
  757. NetSP* pNetSP;
  758. NetApp* pNetApp;
  759. _ftprintf(pFile, TEXT("----------------------------\n"));
  760. _ftprintf(pFile, TEXT("DirectPlay Service Providers\n"));
  761. _ftprintf(pFile, TEXT("----------------------------\n"));
  762. if( pNetInfo == NULL )
  763. return S_OK;
  764. for (pNetSP = pNetInfo->m_pNetSPFirst; pNetSP != NULL; pNetSP = pNetSP->m_pNetSPNext)
  765. {
  766. _ftprintf(pFile, TEXT("%s - Registry: %s, File: %s (%s)\n"),
  767. pNetSP->m_szNameEnglish,
  768. pNetSP->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  769. pNetSP->m_szFile,
  770. pNetSP->m_szVersionEnglish);
  771. }
  772. _ftprintf(pFile, TEXT("DirectPlay Test Result: %s\n"), pNetInfo->m_testResult.m_szDescriptionEnglish);
  773. _ftprintf(pFile, TEXT("\n"));
  774. _ftprintf(pFile, TEXT("-------------------------\n"));
  775. _ftprintf(pFile, TEXT("DirectPlay Lobbyable Apps\n"));
  776. _ftprintf(pFile, TEXT("-------------------------\n"));
  777. for (pNetApp = pNetInfo->m_pNetAppFirst; pNetApp != NULL; pNetApp = pNetApp->m_pNetAppNext)
  778. {
  779. if( pNetApp->m_dwDXVer == 7 )
  780. {
  781. _ftprintf(pFile, TEXT("%s (DX%d) - Registry: %s, ExeFile: %s (%s)\n"),
  782. pNetApp->m_szName,
  783. pNetApp->m_dwDXVer,
  784. pNetApp->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  785. pNetApp->m_szExeFile,
  786. pNetApp->m_szExeVersionEnglish);
  787. }
  788. else
  789. {
  790. _ftprintf(pFile, TEXT("%s (DX%d) - Registry: %s, ExeFile: %s (%s) LauncherFile: %s (%s)\n"),
  791. pNetApp->m_szName,
  792. pNetApp->m_dwDXVer,
  793. pNetApp->m_bRegistryOK ? TEXT("OK") : TEXT("Error"),
  794. pNetApp->m_szExeFile,
  795. pNetApp->m_szExeVersionEnglish,
  796. pNetApp->m_szLauncherFile,
  797. pNetApp->m_szLauncherVersionEnglish);
  798. }
  799. }
  800. _ftprintf(pFile, TEXT("\n"));
  801. return S_OK;
  802. }
  803. /****************************************************************************
  804. *
  805. * SaveInactiveDriverInfo
  806. *
  807. ****************************************************************************/
  808. HRESULT SaveInactiveDriverInfo(FILE* pFile, DisplayInfo* pDisplayInfoFirst)
  809. {
  810. BOOL bNoInactive;
  811. HKEY hKey;
  812. DWORD cbData;
  813. DWORD dwIndex;
  814. TCHAR szSubKeyName[1024];
  815. DisplayInfo* pDisplayInfo;
  816. HKEY hSubKey;
  817. TCHAR szSubSubKey[1024];
  818. TCHAR szDriverDesc[1024];
  819. DWORD ulType;
  820. TCHAR szTempString[1024];
  821. if (BIsPlatformNT())
  822. return S_OK;
  823. _ftprintf(pFile, TEXT("------------------------------------\n"));
  824. _ftprintf(pFile, TEXT("Inactive Display Entries in Registry\n"));
  825. _ftprintf(pFile, TEXT("------------------------------------\n"));
  826. bNoInactive = TRUE;
  827. // Display info (inactive).
  828. hKey = 0;
  829. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\Class\\Display"), 0, KEY_READ, &hKey))
  830. {
  831. cbData = sizeof szSubKeyName;
  832. dwIndex = 0;
  833. while (!RegEnumKeyEx(hKey, dwIndex, szSubKeyName, &cbData, NULL, NULL, NULL, NULL))
  834. {
  835. TCHAR* pch;
  836. BOOL bMatch = FALSE;
  837. // See if this driver is used:
  838. for (pDisplayInfo = pDisplayInfoFirst; pDisplayInfo != NULL;
  839. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  840. {
  841. pch = _tcsrchr(pDisplayInfo->m_szKeyDeviceKey, TEXT('\\'));
  842. if (pch != NULL)
  843. {
  844. pch++;
  845. if (lstrcmp(szSubKeyName, pch) == 0)
  846. {
  847. bMatch = TRUE;
  848. break;
  849. }
  850. }
  851. }
  852. if (!bMatch)
  853. {
  854. hSubKey = 0;
  855. wsprintf(szSubSubKey, TEXT("System\\CurrentControlSet\\Services\\Class\\Display\\%s"), szSubKeyName);
  856. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szSubSubKey, 0, KEY_READ, &hSubKey))
  857. {
  858. cbData = sizeof szDriverDesc;
  859. szDriverDesc[0] = 0;
  860. RegQueryValueEx(hSubKey, TEXT("DriverDesc"), 0, &ulType, (LPBYTE)szDriverDesc, &cbData);
  861. _ftprintf(pFile, TEXT(" Card name: %s\n"), szDriverDesc);
  862. bNoInactive = FALSE;
  863. }
  864. if (hSubKey)
  865. {
  866. RegCloseKey(hSubKey);
  867. hSubKey = 0;
  868. }
  869. wsprintf(szSubSubKey, TEXT("System\\CurrentControlSet\\Services\\Class\\Display\\%s\\DEFAULT"), szSubKeyName);
  870. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szSubSubKey, 0, KEY_READ, &hSubKey))
  871. {
  872. TCHAR szDisplayDriverName[1024];
  873. cbData = sizeof szDisplayDriverName;
  874. szDisplayDriverName[0] = 0;
  875. RegQueryValueEx(hSubKey, TEXT("DRV"), 0, &ulType, (LPBYTE)szDisplayDriverName, &cbData);
  876. _ftprintf(pFile, TEXT(" Driver: %s\n"), szDisplayDriverName);
  877. bNoInactive = FALSE;
  878. }
  879. if (hSubKey)
  880. {
  881. RegCloseKey(hSubKey);
  882. hSubKey = 0;
  883. }
  884. }
  885. cbData = sizeof szSubKeyName;
  886. dwIndex++;
  887. }
  888. }
  889. if (hKey)
  890. {
  891. RegCloseKey(hKey);
  892. hKey = 0;
  893. }
  894. if (bNoInactive)
  895. _ftprintf(pFile, TEXT(" None\n"));
  896. _ftprintf(pFile, TEXT("\n"));
  897. _ftprintf(pFile, TEXT("----------------------------------\n"));
  898. _ftprintf(pFile, TEXT("Inactive Sound Entries in Registry\n"));
  899. _ftprintf(pFile, TEXT("----------------------------------\n"));
  900. bNoInactive = TRUE;
  901. hKey = 0;
  902. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\control\\MediaResources\\wave"), 0, KEY_READ, &hKey))
  903. {
  904. dwIndex = 0;
  905. while (TRUE)
  906. {
  907. cbData = sizeof szSubKeyName;
  908. if (ERROR_SUCCESS != RegEnumKeyEx(hKey, dwIndex, szSubKeyName, &cbData, NULL, NULL, NULL, NULL))
  909. break;
  910. if (!RegOpenKeyEx(hKey, szSubKeyName, 0, KEY_READ, &hSubKey))
  911. {
  912. cbData = sizeof szTempString;
  913. if (!RegQueryValueEx(hSubKey, TEXT("Active"), 0, &ulType, (LPBYTE)szTempString, &cbData))
  914. {
  915. if (lstrcmp(szTempString, TEXT("0")) == 0)
  916. {
  917. TCHAR szWaveOutDesc[1024];
  918. TCHAR szWaveDriverName[1024];
  919. cbData = sizeof szWaveOutDesc;
  920. RegQueryValueEx(hSubKey, TEXT("Description"), 0, &ulType, (LPBYTE)szWaveOutDesc, &cbData);
  921. cbData = sizeof szWaveDriverName;
  922. RegQueryValueEx(hSubKey, TEXT("Driver"), 0, &ulType, (LPBYTE)szWaveDriverName, &cbData);
  923. _ftprintf(pFile, TEXT(" Card name: %s\n"), szWaveOutDesc);
  924. _ftprintf(pFile, TEXT(" Driver: %s\n"), szWaveDriverName);
  925. bNoInactive = FALSE;
  926. }
  927. }
  928. RegCloseKey(hSubKey);
  929. }
  930. dwIndex++;
  931. }
  932. RegCloseKey(hKey);
  933. }
  934. if (bNoInactive)
  935. _ftprintf(pFile, TEXT(" None\n"));
  936. _ftprintf(pFile, TEXT("\n"));
  937. return S_OK;
  938. }
  939. /****************************************************************************
  940. *
  941. * SaveRegistryErrorInfo
  942. *
  943. ****************************************************************************/
  944. HRESULT SaveRegistryErrorInfo(FILE* pFile, RegError* pRegErrorFirst)
  945. {
  946. RegError* pRegError = pRegErrorFirst;
  947. DWORD i;
  948. CHAR* pszRoot;
  949. while (pRegError != NULL)
  950. {
  951. switch ((DWORD_PTR)pRegError->m_hkeyRoot)
  952. {
  953. case (DWORD_PTR)HKEY_LOCAL_MACHINE:
  954. pszRoot = "HKLM";
  955. break;
  956. case (DWORD_PTR)HKEY_CURRENT_USER:
  957. pszRoot = "HKCU";
  958. break;
  959. case (DWORD_PTR)HKEY_CLASSES_ROOT:
  960. pszRoot = "HKCR";
  961. break;
  962. case (DWORD_PTR)HKEY_USERS:
  963. pszRoot = "HKU";
  964. break;
  965. case (DWORD_PTR)HKEY_CURRENT_CONFIG:
  966. pszRoot = "HKCC";
  967. break;
  968. default:
  969. pszRoot = "";
  970. break;
  971. }
  972. _ftprintf(pFile, TEXT("Key '%s\\%s'"), pszRoot, pRegError->m_szKey);
  973. switch (pRegError->m_ret)
  974. {
  975. case RET_MISSINGKEY:
  976. _ftprintf(pFile, TEXT(" is missing.\n"));
  977. break;
  978. case RET_MISSINGVALUE:
  979. _ftprintf(pFile, TEXT(" is missing value '%s'.\n"), pRegError->m_szValue);
  980. break;
  981. case RET_VALUEWRONGTYPE:
  982. _ftprintf(pFile, TEXT(" has value '%s', but it is the wrong type.\n"), pRegError->m_szValue);
  983. break;
  984. case RET_VALUEWRONGDATA:
  985. _ftprintf(pFile, TEXT(", Value '%s'"), pRegError->m_szValue);
  986. switch(pRegError->m_dwTypeActual)
  987. {
  988. case REG_DWORD:
  989. _ftprintf(pFile, TEXT(", should be '%d' but is '%d'.\n"), pRegError->m_dwExpected, pRegError->m_dwActual);
  990. break;
  991. case REG_SZ:
  992. _ftprintf(pFile, TEXT(", should be '%s'"), pRegError->m_szExpected);
  993. _ftprintf(pFile, TEXT(", but is '%s'.\n"), pRegError->m_szActual);
  994. break;
  995. case REG_BINARY:
  996. _ftprintf(pFile, TEXT(", should be '"));
  997. for (i = 0; i < pRegError->m_dwExpectedSize; i++)
  998. _ftprintf(pFile, TEXT("%02x"), pRegError->m_bExpected[i]);
  999. _ftprintf(pFile, TEXT("' but is '"));
  1000. for (i = 0; i < pRegError->m_dwActualSize; i++)
  1001. _ftprintf(pFile, TEXT("%02x"), pRegError->m_bActual[i]);
  1002. _ftprintf(pFile, TEXT("'.\n"));
  1003. break;
  1004. }
  1005. break;
  1006. }
  1007. pRegError = pRegError->m_pRegErrorNext;
  1008. }
  1009. return S_OK;
  1010. }
  1011. /****************************************************************************
  1012. *
  1013. * SaveDebugLevels
  1014. *
  1015. ****************************************************************************/
  1016. HRESULT SaveDebugLevels(FILE* pFile, SysInfo* pSysInfo)
  1017. {
  1018. TCHAR sz[1024];
  1019. if( pSysInfo->m_bIsD3D8DebugRuntimeAvailable ||
  1020. pSysInfo->m_bIsDInput8DebugRuntimeAvailable ||
  1021. pSysInfo->m_bIsDMusicDebugRuntimeAvailable ||
  1022. pSysInfo->m_bIsDDrawDebugRuntime ||
  1023. pSysInfo->m_bIsDSoundDebugRuntime ||
  1024. pSysInfo->m_bIsDPlayDebugRuntime ||
  1025. pSysInfo->m_nD3DDebugLevel > 0 ||
  1026. pSysInfo->m_nDDrawDebugLevel > 0 ||
  1027. pSysInfo->m_nDIDebugLevel > 0 ||
  1028. pSysInfo->m_nDMusicDebugLevel > 0 ||
  1029. pSysInfo->m_nDPlayDebugLevel > 0 ||
  1030. pSysInfo->m_nDSoundDebugLevel > 0 )
  1031. {
  1032. _ftprintf(pFile, TEXT("--------------------\n"));
  1033. _ftprintf(pFile, TEXT("DirectX Debug Levels\n"));
  1034. _ftprintf(pFile, TEXT("--------------------\n"));
  1035. _stprintf(sz, TEXT("Direct3D: %d/4 (%s)\n"), pSysInfo->m_nD3DDebugLevel, pSysInfo->m_bIsD3D8DebugRuntimeAvailable ? (pSysInfo->m_bIsD3DDebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1036. _ftprintf(pFile, sz);
  1037. _stprintf(sz, TEXT("DirectDraw: %d/4 (%s)\n"), pSysInfo->m_nDDrawDebugLevel, pSysInfo->m_bIsDDrawDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1038. _ftprintf(pFile, sz);
  1039. _stprintf(sz, TEXT("DirectInput: %d/5 (%s)\n"), pSysInfo->m_nDIDebugLevel, pSysInfo->m_bIsDInput8DebugRuntimeAvailable ? (pSysInfo->m_bIsDInput8DebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1040. _ftprintf(pFile, sz);
  1041. _stprintf(sz, TEXT("DirectMusic: %d/5 (%s)\n"), pSysInfo->m_nDMusicDebugLevel, pSysInfo->m_bIsDMusicDebugRuntimeAvailable ? (pSysInfo->m_bIsDMusicDebugRuntime ? TEXT("debug") : TEXT("retail") ) : TEXT("n/a") );
  1042. _ftprintf(pFile, sz);
  1043. _stprintf(sz, TEXT("DirectPlay: %d/9 (%s)\n"), pSysInfo->m_nDPlayDebugLevel, pSysInfo->m_bIsDPlayDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1044. _ftprintf(pFile, sz);
  1045. _stprintf(sz, TEXT("DirectSound: %d/5 (%s)\n"), pSysInfo->m_nDSoundDebugLevel, pSysInfo->m_bIsDSoundDebugRuntime ? TEXT("debug") : TEXT("retail") );
  1046. _ftprintf(pFile, sz);
  1047. _ftprintf(pFile, TEXT("\n"));
  1048. }
  1049. return S_OK;
  1050. }