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.

773 lines
22 KiB

  1. #include "nt.h"
  2. #include "ntrtl.h"
  3. #include "nturtl.h"
  4. #include <windows.h>
  5. #include <lm.h>
  6. #include <stdio.h>
  7. #include <time.h>
  8. #include <winuserp.h>
  9. #include <shlobj.h>
  10. #include <shlwapi.h>
  11. // For PnP Stuff
  12. #include <devguid.h>
  13. #include <initguid.h>
  14. #include <setupapi.h>
  15. #include <syssetup.h>
  16. #include <regstr.h>
  17. #include <setupbat.h>
  18. #include <cfgmgr32.h>
  19. #include "tchar.h"
  20. #include "string.h"
  21. #include "setuplog.h"
  22. #include "setuplib.h"
  23. #include "pnpstuff.h"
  24. char * Days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  25. char * Months[] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  26. "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  27. extern DEV_INFO *g_pdiDevList; // Head of device list
  28. char OutputBuffer[ 8192 ];
  29. #define MAX_WAVEOUT_DEVICES 2
  30. struct {
  31. // Sound Card
  32. int nNumWaveOutDevices; // Number of WaveOut Devices (~ number of sound cards)
  33. char szWaveOutDesc[MAX_WAVEOUT_DEVICES][128];// WaveOut description
  34. char szWaveDriverName[MAX_WAVEOUT_DEVICES][128]; // Wave Driver name
  35. } m;
  36. #define SHORTCUT "IDW Logging Tool.lnk"
  37. char szValidHandle[] = "\r\nValid Handle\r\n";
  38. char szInvalidHandle[] = "\r\nInvalid handle. Err: %d\r\n";
  39. char szBadWrite[] = "WriteFile failed. Err: %d\r\n";
  40. char szGoodWrite[] = "WriteFile succeeded\r\n";
  41. // From warndoc.cpp:
  42. VOID
  43. GetNTSoundInfo()
  44. {
  45. HKEY hKey;
  46. DWORD cbData;
  47. ULONG ulType;
  48. LPTSTR sSubKey=TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32");
  49. INT i;
  50. TCHAR szSubKeyName[256];
  51. TCHAR szTempString[256];
  52. // Get Sound Card Info
  53. hKey = 0;
  54. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, sSubKey, 0, KEY_READ, &hKey)){
  55. m.nNumWaveOutDevices = 0;
  56. // Loop through the key to see how many wave devices we have, but skip mmdrv.dll.
  57. for (i = 0; i <= 1; i++){
  58. if (i)
  59. _stprintf(szSubKeyName, TEXT("wave%d"),i);
  60. else
  61. _tcscpy(szSubKeyName, TEXT("wave"));
  62. cbData = sizeof szTempString;
  63. if (RegQueryValueEx(hKey, szSubKeyName, 0, &ulType, (LPBYTE)szTempString, &cbData))
  64. break;
  65. else{
  66. if (szTempString[0] // We want to skip mmdrv.dll - not relevant.
  67. && _tcscmp(szTempString, TEXT("mmdrv.dll"))){
  68. strcpy(&m.szWaveDriverName[m.nNumWaveOutDevices][0], szTempString);
  69. m.nNumWaveOutDevices++;
  70. }
  71. }
  72. }
  73. }
  74. if (hKey){
  75. RegCloseKey(hKey);
  76. hKey = 0;
  77. }
  78. sSubKey = (LPTSTR)TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\drivers.desc");
  79. hKey = 0;
  80. if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, sSubKey, 0, KEY_READ, &hKey)){
  81. // Now grab the sound device string for each wave device
  82. for (i = 0; i < m.nNumWaveOutDevices; i++){
  83. cbData = sizeof szTempString;
  84. if (RegQueryValueEx(hKey, m.szWaveDriverName[i], 0, &ulType, (LPBYTE)szTempString, &cbData))
  85. _tcscpy(m.szWaveOutDesc[i], TEXT("Unknown"));
  86. else
  87. _tcscpy(m.szWaveOutDesc[i], szTempString);
  88. }
  89. }
  90. if (hKey){
  91. RegCloseKey(hKey);
  92. hKey = 0;
  93. }
  94. return;
  95. }
  96. //
  97. // GetVidInfo reads registry information about the installed
  98. // video cards and produces one string
  99. //
  100. #define HWKEY TEXT("SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services")
  101. #define SERVICEKEY TEXT("SYSTEM\\CurrentControlSet\\Services")
  102. #define DESCVAL TEXT("Device Description")
  103. #define TYPEVAL TEXT("HardwareInformation.ChipType")
  104. #define DACVAL TEXT("HardwareInformation.DacType")
  105. #define MEMVAL TEXT("HardwareInformation.MemorySize")
  106. VOID
  107. GetVidInfo (LPTSTR vidinfo)
  108. {
  109. HKEY hkHardware;
  110. HKEY hkCard;
  111. DWORD dwSize;
  112. TCHAR szBuf[256];
  113. WCHAR szWideBuf[128];
  114. TCHAR szSubKey[128];
  115. DWORD dwIndex=0;
  116. DWORD dwMem;
  117. *vidinfo = '\0';
  118. //
  119. // Look in HWKEY to find out what services are used.
  120. //
  121. if (ERROR_SUCCESS != RegOpenKeyEx (HKEY_LOCAL_MACHINE, HWKEY, 0, KEY_READ, &hkHardware))
  122. return;
  123. dwSize=128;
  124. while (ERROR_SUCCESS == RegEnumKeyEx (hkHardware, dwIndex++,szSubKey, &dwSize,NULL,NULL,NULL,NULL)){
  125. //
  126. // Append the subkey name to SERVICEKEY. Look up only Device0 for this card
  127. //
  128. _stprintf (szBuf, ("%s\\%s\\Device0"), SERVICEKEY, szSubKey);
  129. RegOpenKeyEx (HKEY_LOCAL_MACHINE, szBuf, 0, KEY_READ, &hkCard);
  130. //
  131. // First get the description
  132. //
  133. dwSize=256;
  134. if (ERROR_SUCCESS == RegQueryValueEx (hkCard, DESCVAL, NULL, NULL, szBuf, &dwSize)){
  135. if (_tcsclen(vidinfo)+dwSize < 254){
  136. _tcscat (vidinfo, szBuf);
  137. _tcscat (vidinfo, TEXT(" "));
  138. }
  139. }
  140. //
  141. // Read the chip type. This is a UNICODE string stored in REG_BINARY format
  142. //
  143. dwSize=256;
  144. lstrcpyW (szWideBuf, L"ChipType:");
  145. if (ERROR_SUCCESS == RegQueryValueEx (hkCard,TYPEVAL,NULL, NULL, (LPBYTE)(szWideBuf+9), &dwSize)){
  146. if ((dwSize=lstrlen(vidinfo))+lstrlenW(szWideBuf)<254) {
  147. WideCharToMultiByte (CP_ACP, 0,
  148. szWideBuf, -1,
  149. vidinfo+dwSize, 256-dwSize, NULL,NULL);
  150. lstrcat (vidinfo, " ");
  151. }
  152. }
  153. //
  154. // Read the DAC. Another UNICODE string
  155. //
  156. dwSize=256;
  157. lstrcpyW (szWideBuf, L"DACType:");
  158. if (ERROR_SUCCESS == RegQueryValueEx (hkCard,DACVAL,NULL, NULL, (LPBYTE)(szWideBuf+8), &dwSize)){
  159. if ((dwSize=lstrlen(vidinfo))+lstrlenW(szWideBuf)<254){
  160. WideCharToMultiByte (CP_ACP, 0,
  161. szWideBuf, -1,
  162. vidinfo+dwSize, 256-dwSize, NULL,NULL);
  163. lstrcat (vidinfo, " ");
  164. }
  165. }
  166. //
  167. // Read the memory size. This is a binary value.
  168. //
  169. dwSize=sizeof(DWORD);
  170. if (ERROR_SUCCESS == RegQueryValueEx (hkCard, MEMVAL, NULL,NULL,(LPBYTE)&dwMem, &dwSize)){
  171. _stprintf (szBuf, TEXT("Memory:0x%x ;"), dwMem);
  172. if (_tcsclen(vidinfo)+lstrlen(szBuf)<255)
  173. _tcscat (vidinfo, szBuf);
  174. }
  175. RegCloseKey (hkCard);
  176. dwSize=128;
  177. }
  178. RegCloseKey (hkHardware);
  179. }
  180. //
  181. // Hydra is denoted by "Terminal Server" in the ProductOptions key
  182. //
  183. BOOL
  184. IsHydra ()
  185. {
  186. BOOL rVal = FALSE;
  187. LONG Rslt;
  188. HKEY hKey = NULL;
  189. DWORD Type = 0;
  190. DWORD Size = 0;
  191. LPTSTR ProductSuite = NULL;
  192. LPTSTR p;
  193. Rslt = RegOpenKey(
  194. HKEY_LOCAL_MACHINE,
  195. TEXT("System\\CurrentControlSet\\Control\\ProductOptions"),
  196. &hKey
  197. );
  198. if (Rslt != ERROR_SUCCESS)
  199. goto exit;
  200. Rslt = RegQueryValueEx( hKey, TEXT("ProductSuite"), NULL, &Type, NULL, &Size );
  201. if (Rslt != ERROR_SUCCESS || !Size)
  202. goto exit;
  203. ProductSuite = (LPTSTR) LocalAlloc( LPTR, Size );
  204. if (!ProductSuite)
  205. goto exit;
  206. Rslt = RegQueryValueEx( hKey, TEXT("ProductSuite"), NULL, &Type,
  207. (LPBYTE) ProductSuite, &Size );
  208. if (Rslt != ERROR_SUCCESS || Type != REG_MULTI_SZ)
  209. goto exit;
  210. p = ProductSuite;
  211. while (*p) {
  212. if (_tcscmp( p, TEXT("Terminal Server") ) == 0) {
  213. rVal = TRUE;
  214. break;
  215. }
  216. p += (_tcslen( p ) + 1);
  217. }
  218. exit:
  219. if (ProductSuite)
  220. LocalFree( ProductSuite );
  221. if (hKey)
  222. RegCloseKey( hKey );
  223. return rVal;
  224. }
  225. VOID
  226. GetBuildNumber( LPTSTR BuildNumber )
  227. {
  228. OSVERSIONINFO osVer;
  229. osVer.dwOSVersionInfoSize= sizeof( osVer );
  230. if (GetVersionEx( &osVer )&&osVer.dwMajorVersion >= 5) {
  231. wsprintf( BuildNumber, TEXT("%d"), osVer.dwBuildNumber );
  232. } else {
  233. lstrcpy( BuildNumber, TEXT("") ); // return 0 if unknown
  234. }
  235. } // GetBuildNumber
  236. /*
  237. BOOL
  238. GetPnPDisplayInfo(
  239. LPTSTR pOutputData
  240. )
  241. {
  242. BOOL bRet = FALSE;
  243. HDEVINFO hDevInfo;
  244. SP_DEVINFO_DATA DeviceInfoData;
  245. DWORD index = 0;
  246. TCHAR RegistryProperty[256];
  247. ULONG BufferSize;
  248. //
  249. // Let's find all the video drivers that are installed in the system
  250. //
  251. hDevInfo = SetupDiGetClassDevs((LPGUID) &GUID_DEVCLASS_DISPLAY,
  252. NULL,
  253. NULL,
  254. 0);
  255. while (hDevInfo != INVALID_HANDLE_VALUE){
  256. if (bRet)
  257. strcat(pOutputData, TEXT(",") );
  258. ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA));
  259. DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  260. if (!SetupDiEnumDeviceInfo(hDevInfo,
  261. index++,
  262. &DeviceInfoData))
  263. break;
  264. BufferSize = sizeof(RegistryProperty);
  265. if (CR_SUCCESS ==
  266. CM_Get_Device_ID(DeviceInfoData.DevInst,
  267. RegistryProperty,
  268. sizeof(RegistryProperty),
  269. 0)){
  270. bRet = TRUE;
  271. strcat(pOutputData, RegistryProperty);
  272. }
  273. }
  274. return (bRet);
  275. }
  276. */
  277. VOID
  278. ConnectAndWrite(LPTSTR MachineName,
  279. LPTSTR Buffer
  280. )
  281. {
  282. NETRESOURCE NetResource ;
  283. TCHAR szLogFile[ MAX_PATH ];
  284. TCHAR szBinPath[MAX_PATH];
  285. TCHAR szExePath[MAX_PATH];
  286. TCHAR szErr[100];
  287. HANDLE hWrite = INVALID_HANDLE_VALUE;
  288. HANDLE hDebug = INVALID_HANDLE_VALUE;
  289. BOOL bRet;
  290. DWORD dwError;
  291. DWORD Size, Actual ;
  292. //
  293. // Blow through the list of servers.
  294. // and change the g_szServerShare to match.
  295. //
  296. if (TRUE == IsServerOnline(MachineName, NULL)){
  297. //
  298. // Set the server name now as we now have it
  299. // into the outputbuffer
  300. //
  301. _stprintf (Buffer+_tcsclen(Buffer),
  302. TEXT("IdwlogServer:%s\r\n"), g_szServerShare);
  303. ZeroMemory( &NetResource, sizeof( NetResource ) );
  304. NetResource.dwType = RESOURCETYPE_DISK ;
  305. NetResource.lpLocalName = "" ;
  306. NetResource.lpRemoteName = g_szServerShare;
  307. NetResource.lpProvider = "" ;
  308. GetModuleFileName (NULL, szExePath, MAX_PATH);
  309. // First, try to connect with the current user ID
  310. dwError = WNetAddConnection2( &NetResource,NULL,NULL,0 );
  311. if (dwError)
  312. dwError = WNetAddConnection2( &NetResource,LOGSHARE_PW,LOGSHARE_USER,0 );
  313. dwError = 0; // Hard reset.
  314. if ( dwError == 0 ){
  315. _stprintf (szLogFile, TEXT("%s\\%s"),g_szServerShare, MachineName );
  316. hDebug = CreateFile(TEXT("C:\\setuplog.dbg"),
  317. GENERIC_WRITE,
  318. 0, NULL, CREATE_ALWAYS,
  319. FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_HIDDEN | FILE_FLAG_WRITE_THROUGH,
  320. NULL);
  321. if (hDebug != INVALID_HANDLE_VALUE)
  322. WriteFile (hDebug, szExePath, _tcsclen(szExePath), &Actual, NULL);
  323. hWrite = CreateFile( szLogFile,
  324. GENERIC_WRITE,
  325. 0,
  326. NULL,
  327. CREATE_ALWAYS,
  328. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
  329. NULL );
  330. if ( hWrite != INVALID_HANDLE_VALUE ){
  331. SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
  332. SECURITY_DESCRIPTOR sd;
  333. if (hDebug != INVALID_HANDLE_VALUE)
  334. WriteFile (hDebug, szValidHandle, sizeof(szValidHandle), &Actual, NULL);
  335. Size = _tcsclen( Buffer );
  336. bRet = WriteFile( hWrite, Buffer, Size, &Actual, NULL );
  337. if (!bRet){
  338. if (hDebug != INVALID_HANDLE_VALUE){
  339. _stprintf (szErr, szBadWrite, GetLastError());
  340. WriteFile (hDebug, szErr, lstrlen(szErr), &Actual, NULL);
  341. }
  342. }
  343. else{
  344. if (hDebug != INVALID_HANDLE_VALUE)
  345. WriteFile (hDebug, szGoodWrite, sizeof(szGoodWrite), &Actual, NULL);
  346. }
  347. CloseHandle( hWrite );
  348. //
  349. // We should delete the shortcut to idwlog from startup group.
  350. //
  351. SHGetFolderPath (NULL, CSIDL_COMMON_STARTUP, NULL,0,szBinPath);
  352. PathAppend (szBinPath, SHORTCUT);
  353. DeleteFile (szBinPath);
  354. //
  355. // If this is idwlog.exe, delete the program.
  356. // We only need to write once.
  357. //
  358. if (strstr (CharLower(szExePath), "idwlog.exe"))
  359. MoveFileEx ((LPCTSTR)szExePath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  360. }
  361. else{
  362. if (hDebug != INVALID_HANDLE_VALUE){
  363. _stprintf (szErr, szInvalidHandle, GetLastError());
  364. WriteFile (hDebug, szErr, _tcsclen(szErr), &Actual, NULL);
  365. }
  366. }
  367. WNetCancelConnection2( g_szServerShare, 0, TRUE );
  368. if (hDebug != INVALID_HANDLE_VALUE)
  369. CloseHandle (hDebug);
  370. }
  371. }
  372. }
  373. VOID
  374. WriteDataToFile (IN LPTSTR szFileName,
  375. IN LPTSTR szFrom,
  376. IN LPNT32_CMD_PARAMS lpCmdL)
  377. {
  378. TCHAR username[MY_MAX_UNLEN + 1];
  379. TCHAR userdomain[ DNLEN+2 ];
  380. TCHAR architecture[ 16 ];
  381. SYSTEM_INFO SysInfo ;
  382. TCHAR build_number[256];
  383. TCHAR time[ 32 ];
  384. DWORD Size;
  385. DISPLAY_DEVICE displayDevice;
  386. DWORD iLoop;
  387. DEVMODE dmCurrent;
  388. TCHAR displayname[MY_MAX_UNLEN + 1];
  389. LPTSTR pch;
  390. TCHAR localename[4]; // locale abbreviation
  391. TCHAR netcards[256] = "\0";
  392. TCHAR vidinfo[256] = "\0";
  393. TCHAR modem[256] = "\0";
  394. TCHAR scsi[256] = "\0";
  395. BOOL bUSB = FALSE;
  396. BOOL bPCCard = FALSE;
  397. BOOL bACPI = FALSE;
  398. BOOL bIR = FALSE;
  399. BOOL bHydra = FALSE;
  400. INT iNumDisplays = GetSystemMetrics(SM_CMONITORS);
  401. MEMORYSTATUS msRAM;
  402. DEV_INFO *pdi;
  403. strcpy(username, UNKNOWN);
  404. strcpy(displayname, UNKNOWN);
  405. if (!GetEnvironmentVariable (USERNAME, username, MY_MAX_UNLEN))
  406. lstrcpy (username, "Unknown");
  407. // Get the build number
  408. if (!szFrom)
  409. GetBuildNumber (build_number);
  410. else
  411. _tcscpy (build_number, szFrom);
  412. GetSystemInfo( &SysInfo );
  413. if ( !GetEnvironmentVariable( "USERDOMAIN", userdomain, sizeof( userdomain) ) )
  414. _tcscpy (userdomain, "Unknown");
  415. if ( !GetEnvironmentVariable( "PROCESSOR_ARCHITECTURE", architecture, sizeof( architecture ) ) )
  416. _tcscpy (architecture, "Unknown");
  417. // Video Information for ChrisW
  418. displayDevice.cb = sizeof(DISPLAY_DEVICE);
  419. iLoop = 0;
  420. while (EnumDisplayDevices(NULL, iLoop, &displayDevice, 0)) {
  421. ZeroMemory( &dmCurrent, sizeof(dmCurrent) );
  422. dmCurrent.dmSize= sizeof(dmCurrent);
  423. if( EnumDisplaySettings( displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &dmCurrent ) ){
  424. if (iLoop == 0)
  425. *displayname = 0;
  426. else
  427. _tcscat( displayname, TEXT(",") );
  428. _tcscat( displayname, dmCurrent.dmDeviceName );
  429. }
  430. iLoop++;
  431. }
  432. // replace spaces so we don't break the perl script the build lab is using
  433. pch = displayname;
  434. while (*pch) {
  435. if (*pch == ' ') *pch = '.';
  436. pch++;
  437. }
  438. GetVidInfo (vidinfo);
  439. // Get locale abbreviation so we know about language pack usage
  440. if( GetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, localename, sizeof( localename)) == 0 )
  441. _tcscpy(localename,"unk");
  442. msRAM.dwLength = sizeof (msRAM);
  443. GlobalMemoryStatus (&msRAM);
  444. //
  445. // Get PNP net card info
  446. //
  447. *netcards='\0';
  448. *scsi='\0';
  449. CollectDevData ();
  450. pdi=g_pdiDevList;
  451. while (pdi){
  452. if (!lstrcmpi (pdi->szClass, "Net")){
  453. if (_tcsclen(netcards) + lstrlen(pdi->szDescription) + lstrlen(pdi->szService) < 250){
  454. _tcscat (netcards, pdi->szDescription);
  455. _tcscat (netcards, "(");
  456. _tcscat (netcards, pdi->szService);
  457. _tcscat (netcards, TEXT(") "));
  458. }
  459. }
  460. else if (!lstrcmpi (pdi->szClass, "SCSIAdapter")){
  461. if (_tcsclen(scsi) + lstrlen(pdi->szService) < 250){
  462. _tcscat (scsi, pdi->szService);
  463. _tcscat (scsi, TEXT(","));
  464. }
  465. }
  466. else if (!lstrcmpi (pdi->szClass, "Modem")){
  467. if (_tcsclen(modem) + lstrlen(pdi->szDescription) < 250){
  468. _tcscat (modem, pdi->szDescription);
  469. _tcscat (modem, TEXT(","));
  470. }
  471. }
  472. else if (!lstrcmpi (pdi->szClass, "USB"))
  473. bUSB = TRUE;
  474. else if (!lstrcmpi (pdi->szClass, "Infrared"))
  475. bIR = TRUE;
  476. else if (!lstrcmpi (pdi->szClass, "PCMCIA") || !lstrcmpi (pdi->szService, "PCMCIA"))
  477. bPCCard = TRUE;
  478. else if (strstr (pdi->szClass, "ACPI") || strstr (pdi->szService, "ACPI"))
  479. bACPI = TRUE;
  480. pdi=pdi->Next;
  481. }
  482. Cleanup(); //free all the pnp data and restore configuration
  483. if (!(*netcards))
  484. _tcscpy (netcards, TEXT("Unknown"));
  485. //
  486. // Get Sound info
  487. GetNTSoundInfo ();
  488. // format all our data
  489. bHydra= IsHydra ();
  490. // fix the number of displays for non Windows 2000 systems
  491. if (!iNumDisplays)
  492. iNumDisplays = 1;
  493. //wsprintf only accepts 1k buffers.
  494. // Break these up into more calls to
  495. // wsprintf to eliminate chance of overflow
  496. _stprintf (OutputBuffer,
  497. TEXT("MachineID:%lu\r\n")
  498. TEXT("Source Media:%s\r\n")
  499. TEXT("Type:%s\r\nUsername:%s\r\n")
  500. TEXT("RAM:%d\r\n")
  501. TEXT("FromBld:%s\r\n")
  502. TEXT("Arch:%s\r\nNumProcs:%d\r\n")
  503. TEXT("Vidinfo:%s\r\n"),
  504. lpCmdL->dwRandomID,
  505. lpCmdL->b_CDrom? TEXT("C"): TEXT("N"),
  506. lpCmdL->b_Upgrade?TEXT("U"):TEXT("I"),
  507. username,
  508. msRAM.dwTotalPhys/(1024*1024),
  509. szFrom?szFrom:build_number,
  510. architecture,
  511. SysInfo.dwNumberOfProcessors,
  512. vidinfo
  513. );
  514. _stprintf (OutputBuffer+_tcsclen(OutputBuffer),
  515. TEXT("VidDriver:%s\r\n")
  516. TEXT("Locale:%s\r\nSound:%s\r\nNetCards:%s\r\n")
  517. TEXT("ACPI:%d\r\n")
  518. TEXT("PCMCIA:%d\r\n")
  519. TEXT("CPU:%d\r\n")
  520. TEXT("SCSI:%s\r\n")
  521. TEXT("USB:%d\r\n")
  522. TEXT("Infrared:%d\r\n"),
  523. displayname,
  524. localename,
  525. m.nNumWaveOutDevices?m.szWaveDriverName[0]:TEXT("None"),
  526. netcards,
  527. bACPI,
  528. bPCCard,
  529. (DWORD)SysInfo.wProcessorLevel,
  530. scsi,
  531. bUSB,
  532. bIR
  533. );
  534. _stprintf (OutputBuffer+_tcsclen(OutputBuffer),
  535. TEXT("Modem:%s\r\n")
  536. TEXT("Hydra:%d\r\n")
  537. TEXT("Displays:%d\r\n")
  538. TEXT("MSI:%s\r\n"),
  539. modem,
  540. bHydra,
  541. iNumDisplays,
  542. lpCmdL->b_MsiInstall? TEXT("Y"):TEXT("N")
  543. );
  544. ConnectAndWrite( szFileName, OutputBuffer );
  545. }
  546. BOOL
  547. IsServerOnline(IN LPTSTR szMachineName, IN LPTSTR szSpecifyShare)
  548. /*++
  549. Routine Description:
  550. This will go through the list of servers specified in setuplogEXE.h
  551. It will return the first in it sees and reset the global server share
  552. name.
  553. Arguments:
  554. The machineName (Filename with build etc) so the test file will get overwritten.
  555. Manual Server Name: NULL will give default behaviour.
  556. Return Value:
  557. TRUE for success.
  558. FALSE for no name.
  559. --*/
  560. {
  561. DWORD dw;
  562. HANDLE hThrd;
  563. INT i;
  564. TCHAR szServerFile[ MAX_PATH ];
  565. DWORD dwTimeOutInterval;
  566. i = 0;
  567. //
  568. // This should allow for a
  569. // manually specified server.
  570. //
  571. if (NULL != szSpecifyShare){
  572. _tcscpy(g_szServerShare,szSpecifyShare);
  573. return TRUE;
  574. }
  575. //
  576. // Initialize the Server.
  577. // Variable. Since we are using a single thread
  578. // to do a time out we don't care about mutexes and
  579. // sychronization.
  580. //
  581. g_bServerOnline = FALSE;
  582. while ( i < NUM_SERVERS){
  583. _stprintf (szServerFile, TEXT("%s\\%s"),s[i].szSvr,szMachineName );
  584. //
  585. // Spawn the thread
  586. //
  587. hThrd = CreateThread(NULL,
  588. 0,
  589. (LPTHREAD_START_ROUTINE) ServerOnlineThread,
  590. (LPTSTR) szServerFile,
  591. 0,
  592. &dw);
  593. //
  594. // This is in milli seconds so the time out is secs.
  595. //
  596. dwTimeOutInterval = TIME_TIMEOUT * 1000;
  597. s[i].dwTimeOut = WaitForSingleObject (hThrd, dwTimeOutInterval);
  598. CloseHandle (hThrd);
  599. //
  600. // This means the server passed the timeout.
  601. //
  602. if (s[i].dwTimeOut != WAIT_TIMEOUT &&
  603. g_bServerOnline == TRUE){
  604. //
  605. // Copy the Share to the glowbal var.
  606. //
  607. _tcscpy(g_szServerShare,s[i].szSvr);
  608. return TRUE;
  609. }
  610. i++;
  611. }
  612. return FALSE;
  613. }
  614. BOOL
  615. ServerOnlineThread(IN LPTSTR szServerFile)
  616. /*++
  617. Routine Description:
  618. This create a thread and then time it out to see if we can get to
  619. a server faster.
  620. Arguments:
  621. The machineName so the test file will get overwritten.
  622. Return Value:
  623. --*/
  624. {
  625. BOOL bCopy = FALSE;
  626. TCHAR szFileSrc [MAX_PATH];
  627. TCHAR szServerTestFile [MAX_PATH];
  628. //
  629. // Use this to get the location
  630. // setuplog.exe is run from. this tool
  631. //
  632. GetModuleFileName (NULL, szFileSrc, MAX_PATH);
  633. //
  634. // Make a unique test file.
  635. //
  636. _stprintf(szServerTestFile,TEXT("%s.SERVERTEST"),szServerFile);
  637. bCopy = CopyFile( szFileSrc,szServerTestFile, FALSE);
  638. if (bCopy != FALSE){
  639. //
  640. // If Succeeded Delete the test file.
  641. //
  642. DeleteFile(szServerTestFile);
  643. g_bServerOnline = TRUE;
  644. return TRUE;
  645. }
  646. else{
  647. g_bServerOnline = FALSE;
  648. return FALSE;
  649. }
  650. }