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.

1762 lines
64 KiB

  1. #include "globals.h"
  2. #include "cmdline.h"
  3. #include "resource.h"
  4. #include <regstr.h>
  5. TCHAR g_WindowsDirectory[MAX_PATH];
  6. BOOL g_WalkStartMenu;
  7. #define NOT_CASE_SENSITIVE TRUE
  8. #define CASE_SENSITIVE FALSE
  9. typedef struct MYTIMESTRUCT
  10. {
  11. TCHAR szMonth[10];
  12. TCHAR szDay[10];
  13. TCHAR szYear[10];
  14. TCHAR szHour[10];
  15. TCHAR szMinute[10];
  16. TCHAR szSecond[10];
  17. TCHAR szMillisecond[10];
  18. }MyTimeStruct;
  19. PTCHAR GetUniqueFileName( void );
  20. void FillMyTime(MYTIMESTRUCT *MyTime);
  21. BOOL CLASS_GeneralInfo::Go(void)
  22. {
  23. BOOL ReturnValue;
  24. HWND HandleToStatic;
  25. TCHAR Status[MAX_PATH * 4];
  26. CLASS_GeneralAppWalk AppWalk(LogProc, gHandleToMainWindow);
  27. kCommandLine CommandLine;
  28. HandleToStatic = GetDlgItem(gHandleToMainWindow, IDC_STATIC_STATUS);
  29. wsprintf(Status, TEXT("Sysparse is now collecting information. During this process, it will not respond to mouse or keyboard commands, and may appear to be hung for up to 15 minutes."));
  30. if(INVALID_HANDLE_VALUE != HandleToStatic)
  31. SendMessage(HandleToStatic, WM_SETTEXT, 0, (LPARAM)Status);
  32. HandleToStatic = GetDlgItem(gHandleToMainWindow, IDC_STATIC_HELP);
  33. wsprintf(Status, TEXT(""));
  34. if(INVALID_HANDLE_VALUE != HandleToStatic)
  35. SendMessage(HandleToStatic, WM_SETTEXT, 0, (LPARAM)Status);
  36. ReturnValue = DetermineArgumentValidity();
  37. if (FALSE == ReturnValue)
  38. return FALSE;
  39. ReturnValue = InitLogFile();
  40. if (FALSE == ReturnValue)
  41. return FALSE;
  42. //
  43. // From this point forward we init'd the log file and will always write a section label and a value for each value request,
  44. // whether that value is a default (usually "Unknown" or "Blank") or the actual value requested.
  45. //
  46. WriteVersions();
  47. GetUUID();
  48. WriteArguments();
  49. WriteFreeDiskSpace();
  50. WriteVolumeType();
  51. WriteMemorySize();
  52. WriteOSVersion();
  53. switch (OSVersion)
  54. {
  55. case Win95:
  56. {
  57. TCHAR lWindir[MAX_PATH];
  58. HANDLE File;
  59. WIN32_FIND_DATA w32fd;
  60. GetSystemDirectory(lWindir, MAX_PATH);
  61. if ( '\\' == lWindir[lstrlen(lWindir)-1] )
  62. {
  63. lWindir[lstrlen(lWindir)-1]='\0';
  64. }
  65. lstrcat(lWindir, "\\cfgmgr32.dll");
  66. File = FindFirstFile(lWindir, &w32fd);
  67. if (INVALID_HANDLE_VALUE != File)
  68. {
  69. LogProc->LogString("\r\n,#Syspar32,,\r\n");
  70. kNT5DevWalk MainNT5DevWalk(LogProc);
  71. MainNT5DevWalk.Go();
  72. }
  73. else
  74. {
  75. LogProc->LogString("\r\n,#Syspar16,,\r\n");
  76. kWin9xDevWalk MainWin9xDevWalk(LogProc);
  77. MainWin9xDevWalk.Go();
  78. }
  79. break;
  80. }
  81. case NT4:
  82. {
  83. kNT4DevWalk MainNT4DevWalk(LogProc, gHandleToMainWindow);
  84. if (MainNT4DevWalk.Begin())
  85. MainNT4DevWalk.Walk();
  86. break;
  87. }
  88. case Win2000:
  89. case Whistler:
  90. {
  91. LogProc->LogString("\r\n,#Syspar32,,\r\n");
  92. kNT5DevWalk MainNT5DevWalk(LogProc);
  93. MainNT5DevWalk.Go();
  94. kNT5NetWalk MainNT5NetWalk(LogProc, gHandleToMainWindow);
  95. if (MainNT5NetWalk.Begin())
  96. MainNT5NetWalk.Walk();
  97. break;
  98. }
  99. case Win98:
  100. {
  101. LogProc->LogString("\r\n,#Syspar32,,\r\n");
  102. kNT5DevWalk MainNT5DevWalk(LogProc);
  103. MainNT5DevWalk.Go();
  104. break;
  105. }
  106. }
  107. WIN32_FIND_DATA *fd2 = (WIN32_FIND_DATA*)malloc(sizeof(WIN32_FIND_DATA));
  108. WIN32_FIND_DATA *fd3 = (WIN32_FIND_DATA*)malloc(sizeof(WIN32_FIND_DATA));
  109. if (!fd2)
  110. return FALSE;
  111. if(!fd3) {
  112. free(fd2);
  113. return FALSE;
  114. }
  115. FindFirstFile(LogProc->szFile, fd3);
  116. TCHAR szAr[MAX_PATH * 4];
  117. TCHAR szLogFilePath[MAX_PATH * 4];
  118. TCHAR szCurDirectory[MAX_PATH];
  119. //add specified file name
  120. if (CommandLine.IsSpecified(TEXT("/n"),NOT_CASE_SENSITIVE))
  121. lstrcpy(szAr,CommandLine.GetSwitchValue(TEXT("/n"),NOT_CASE_SENSITIVE));
  122. else if (CommandLine.IsSpecified(TEXT("/u"),NOT_CASE_SENSITIVE))
  123. // Whistler - Generate Unique filename (ComputerName+UserName+Time)
  124. lstrcpy(szAr, GetUniqueFileName());
  125. else
  126. lstrcpy(szAr, Profile);
  127. if (!(CommandLine.IsSpecified(TEXT("/x"),NOT_CASE_SENSITIVE)))
  128. lstrcat(szAr, PlatformExtension);
  129. szAr[8]='\0';
  130. if(CommandLine.IsSpecified(TEXT("/w"),NOT_CASE_SENSITIVE))
  131. lstrcpy(szLogFilePath, CommandLine.GetSwitchValue(TEXT("/w"),NOT_CASE_SENSITIVE));
  132. else
  133. lstrcpy(szLogFilePath, WindowsDirectory);
  134. // if(GetCurrentDirectory(MAX_PATH, szCurDirectory))
  135. // lstrcpy(szArp, szCurDirectory);
  136. if(szLogFilePath[lstrlen(szLogFilePath) - 1] != '\\')
  137. lstrcat(szLogFilePath, "\\");
  138. lstrcat(szLogFilePath, szAr);
  139. if (CommandLine.IsSpecified(TEXT("/l"),NOT_CASE_SENSITIVE))
  140. lstrcat(szLogFilePath, ".log");
  141. else
  142. lstrcat(szLogFilePath, ".csv");
  143. if(CommandLine.IsSpecified(TEXT("/u"),NOT_CASE_SENSITIVE))
  144. szLogFilePath[lstrlen(szLogFilePath) - (4 * sizeof(TCHAR))] = '\0';
  145. if (FindFirstFile(szLogFilePath, fd2) != INVALID_HANDLE_VALUE)
  146. {
  147. if ( (lstrlen(fd3->cFileName) > 12) && (NT4 != OSVersion) && (Win2000 != OSVersion) )
  148. {
  149. FILE *fGetFile, *fPutFile;
  150. DWORD dwRet = 0;
  151. DWORD dwBytesWrit;
  152. TCHAR szBuffer[50000];
  153. fGetFile = fopen(szLogFilePath, "r");
  154. fPutFile = fopen(LogProc->szFile, "a+");
  155. if (fGetFile && fPutFile)
  156. {
  157. while (fgets(szBuffer, 50000, fGetFile))
  158. {
  159. fputs(szBuffer, fPutFile);
  160. }
  161. fclose(fPutFile);
  162. fclose(fGetFile);
  163. }
  164. else
  165. {
  166. if (fPutFile)
  167. fclose(fPutFile);
  168. if (fGetFile)
  169. fclose(fGetFile);
  170. }
  171. if (fPutFile)
  172. fclose(fPutFile);
  173. if (fGetFile)
  174. fclose(fGetFile);
  175. DeleteFile(szLogFilePath);
  176. }
  177. if(fd2)
  178. free(fd2);
  179. if(fd3)
  180. free(fd3);
  181. }
  182. if (g_WalkStartMenu)
  183. {
  184. AppWalk.Walk();
  185. }
  186. LogProc->LogString(",#Stop parsing here,,\r\n");
  187. #ifndef NOCHKUPGRD
  188. if ( (RunChkupgrd) && (!CommandLine.IsSpecified(TEXT("/donotrun1"), TRUE)) )
  189. {
  190. TCHAR szUpgr[512];
  191. lstrcpy(szUpgr, LogProc->szLogDir);
  192. lstrcat(szUpgr, "\\chkupgrd.exe");
  193. LoadResourceFile(szUpgr, "EXEResource3" );
  194. _spawnl(_P_WAIT, szUpgr, szUpgr, "", "", NULL);
  195. DeleteFile(szUpgr);
  196. LogProc->LogString("\r\n,#Chkupgrd.log,,\r\n");
  197. if (Win2000 != OSVersion)
  198. {
  199. lstrcpy(szUpgr, LogProc->szLogDir);
  200. lstrcat(szUpgr, "\\winnt32.log");
  201. CatLogFile(szUpgr);
  202. DeleteFile(szUpgr);
  203. lstrcpy(szUpgr, LogProc->szLogDir);
  204. lstrcat(szUpgr, "\\config.dmp");
  205. CatLogFile(szUpgr);
  206. DeleteFile(szUpgr);
  207. }
  208. else
  209. {
  210. GetWindowsDirectory(szUpgr, 512);
  211. if ( '\\' == szUpgr[lstrlen(szUpgr)-1] )
  212. {
  213. szUpgr[lstrlen(szUpgr)-1]='\0';
  214. }
  215. lstrcat(szUpgr, "\\winnt32.log");
  216. CatLogFile(szUpgr);
  217. DeleteFile(szUpgr);
  218. GetWindowsDirectory(szUpgr, 512);
  219. if ( '\\' == szUpgr[lstrlen(szUpgr)-1] )
  220. {
  221. szUpgr[lstrlen(szUpgr)-1]='\0';
  222. }
  223. lstrcat(szUpgr, "\\config.dmp");
  224. CatLogFile(szUpgr);
  225. DeleteFile(szUpgr);
  226. }
  227. LogProc->LogString("\r\n,#END_Chkupgrd.log,,\r\n");
  228. }
  229. #endif
  230. #ifndef ALPHA
  231. if ( (RunDevdump) && (!CommandLine.IsSpecified(TEXT("/donotrun2"),NOT_CASE_SENSITIVE)) && (Win2000==OSVersion))
  232. #else
  233. if ( ((!RunDevdump) || (CommandLine.IsSpecified(TEXT("/donotrun2"),NOT_CASE_SENSITIVE))) && (Win2000==OSVersion))
  234. #endif
  235. {
  236. TCHAR szEx[512];
  237. TCHAR szUpgr[512];
  238. lstrcpy(szUpgr, LogProc->szLogDir);
  239. lstrcat(szUpgr, "\\devdump.exe");
  240. LoadResourceFile(szUpgr, "EXEResource4" );
  241. lstrcpy(szEx, szUpgr);
  242. lstrcat(szUpgr, " ");
  243. lstrcat(szUpgr, LogProc->szLogDir);
  244. lstrcat(szUpgr, "\\devdump.log /T");
  245. _spawnl(_P_WAIT, szEx, szUpgr, "", "", NULL);
  246. DeleteFile(szUpgr);
  247. LogProc->LogString("\r\n,#DevDump.log,,\r\n");
  248. lstrcpy(szUpgr, LogProc->szLogDir);
  249. lstrcat(szUpgr, "\\devdump.log");
  250. CatLogFile(szUpgr);
  251. DeleteFile(szUpgr);
  252. LogProc->LogString("\r\n,#END_DevDump.log,,\r\n");
  253. }
  254. HandleToStatic = GetDlgItem(gHandleToMainWindow, IDC_STATIC_STATUS);
  255. wsprintf(Status, TEXT("Logfile \"%s\" has been written to disk."), LogProc->szFile);
  256. //
  257. // If the filepath is specified on the command line, we are likely running under Winnt32
  258. // so we hide the files to set a good example to ISV's - bug #229053
  259. //
  260. if(CommandLine.IsSpecified(TEXT("/w"),NOT_CASE_SENSITIVE)) {
  261. SetFileAttributes(LogProc->szFile, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
  262. SetFileAttributes(szRegFile, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
  263. }
  264. SendMessage(HandleToStatic, WM_SETTEXT, 0, (LPARAM)Status);
  265. return TRUE;
  266. }
  267. CLASS_GeneralInfo::CLASS_GeneralInfo(kLogFile *Proc, HWND hIn)
  268. {
  269. LogProc=Proc;
  270. gHandleToMainWindow = hIn;
  271. GetCurrentWindowsDirectory();
  272. //RunDevdump = TRUE;
  273. RunDevdump = FALSE; // Disabled devdump due to whistler bug 355359
  274. RunChkupgrd = TRUE;
  275. AutoRun = FALSE;
  276. RunMinimized = FALSE;
  277. OverWrite = FALSE;
  278. UseComputerName = FALSE;
  279. }
  280. // Initialize the global WindowsDirectory variable
  281. void CLASS_GeneralInfo::GetCurrentWindowsDirectory(void)
  282. {
  283. HINSTANCE hInst2=LoadLibraryEx("kernel32.dll", NULL, DONT_RESOLVE_DLL_REFERENCES);
  284. LPFNDLLFUNC2 fProc = (LPFNDLLFUNC2)GetProcAddress(hInst2, "GetSystemWindowsDirectoryA");
  285. if (hInst2 && fProc)
  286. {
  287. fProc(WindowsDirectory, MAX_PATH);
  288. }
  289. else
  290. {
  291. GetWindowsDirectory(WindowsDirectory, MAX_PATH);
  292. }
  293. if ( '\\' == WindowsDirectory[lstrlen(WindowsDirectory)-1] )
  294. {
  295. WindowsDirectory[lstrlen(WindowsDirectory)-1]='\0';
  296. }
  297. lstrcpy(g_WindowsDirectory, WindowsDirectory);
  298. }
  299. void CLASS_GeneralInfo::DetermineOS(void)
  300. {
  301. OSVERSIONINFO osV;
  302. osV.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  303. if (GetVersionEx(&osV))
  304. {
  305. switch (osV.dwPlatformId)
  306. {
  307. case VER_PLATFORM_WIN32s:
  308. OSVersion = Unknown;
  309. break;
  310. case VER_PLATFORM_WIN32_WINDOWS:
  311. {
  312. if (osV.dwMinorVersion == 0)
  313. {
  314. OSVersion = Win95;
  315. }
  316. else if (osV.dwMinorVersion == 10)
  317. {
  318. OSVersion = Win98;
  319. }
  320. }
  321. break;
  322. case VER_PLATFORM_WIN32_NT:
  323. {
  324. if (osV.dwMajorVersion == 4)
  325. {
  326. OSVersion = NT4;
  327. }
  328. else if (osV.dwMajorVersion == 5)
  329. {
  330. if(LOWORD(osV.dwBuildNumber) == 2195)
  331. OSVersion = Win2000;
  332. else if(LOWORD(osV.dwBuildNumber) >= 2196)
  333. OSVersion = Whistler;
  334. else
  335. OSVersion = Unknown;
  336. }
  337. }
  338. break;
  339. default:
  340. OSVersion = Unknown;
  341. break;
  342. }
  343. }
  344. else
  345. {
  346. OSVersion = Unknown;
  347. }
  348. }
  349. BOOL CLASS_GeneralInfo::InitLogFile(void)
  350. {
  351. TCHAR szLogFileName[MAX_PATH * 4];
  352. TCHAR Windy[MAX_PATH * 4];
  353. TCHAR szCurDirectory[MAX_PATH];
  354. WIN32_FIND_DATA FileData;
  355. HANDLE HandleToSearch;
  356. kCommandLine CommandLine;
  357. DetermineOS();
  358. //default to windir
  359. lstrcpy(szLogFileName, WindowsDirectory);
  360. if (CommandLine.IsSpecified(TEXT("/w"),NOT_CASE_SENSITIVE))
  361. lstrcpy(szLogFileName, CommandLine.GetSwitchValue(TEXT("/w"),NOT_CASE_SENSITIVE));
  362. //if (GetCurrentDirectory(MAX_PATH, szCurDirectory))
  363. // lstrcpy(CSV, szCurDirectory);
  364. if(szLogFileName[lstrlen(szLogFileName) -1] != '\\')
  365. lstrcat(szLogFileName, "\\");
  366. if (CommandLine.IsSpecified(TEXT("/n"),NOT_CASE_SENSITIVE))
  367. lstrcat(szLogFileName,CommandLine.GetSwitchValue(TEXT("/n"),NOT_CASE_SENSITIVE));
  368. // For Whistler Pre-Beta1 test - Generate Unique filename (ComputerName+UserName+Time)
  369. else if (CommandLine.IsSpecified(TEXT("/u"),NOT_CASE_SENSITIVE))
  370. lstrcat(szLogFileName, GetUniqueFileName());
  371. else
  372. lstrcat(szLogFileName, Profile);
  373. lstrcpy(szRegFile, szLogFileName);
  374. lstrcat(szRegFile, TEXT(".reg"));
  375. switch (OSVersion)
  376. {
  377. case Win95:
  378. lstrcpy(PlatformExtension, TEXT("-w95"));
  379. break;
  380. case Win98:
  381. lstrcpy(PlatformExtension, TEXT("-w98"));
  382. break;
  383. case NT4:
  384. lstrcpy(PlatformExtension, TEXT("-nt4"));
  385. break;
  386. case Win2000:
  387. lstrcpy(PlatformExtension, TEXT("-w2k"));
  388. break;
  389. default:
  390. lstrcpy(PlatformExtension, TEXT("-unk"));
  391. break;
  392. }
  393. if (!(CommandLine.IsSpecified(TEXT("/x"),NOT_CASE_SENSITIVE)))
  394. lstrcat(szLogFileName, PlatformExtension);
  395. if (CommandLine.IsSpecified(TEXT("/l"),NOT_CASE_SENSITIVE))
  396. lstrcat(szLogFileName, ".log");
  397. else
  398. lstrcat(szLogFileName, ".csv");
  399. if(CommandLine.IsSpecified(TEXT("/u"),NOT_CASE_SENSITIVE))
  400. szLogFileName[lstrlen(szLogFileName) - (4 * sizeof (TCHAR))] = '\0';
  401. HandleToSearch = FindFirstFile(szLogFileName, &FileData);
  402. if (TRUE == OverWrite)
  403. DeleteFile(szLogFileName);
  404. else if (INVALID_HANDLE_VALUE != HandleToSearch)
  405. {
  406. //ask to overwrite
  407. TCHAR ErrorMessage[MAX_PATH * 4];
  408. int RetVal;
  409. wsprintf(ErrorMessage, TEXT("Overwrite %s?"), szLogFileName);
  410. RetVal=MessageBox(gHandleToMainWindow, ErrorMessage, TEXT("Sysparse"), MB_YESNO);
  411. if (IDYES == RetVal)
  412. DeleteFile(szLogFileName);
  413. else if (IDNO == RetVal)
  414. return FALSE;
  415. }
  416. if(HandleToSearch)
  417. FindClose(HandleToSearch);
  418. lstrcpy(Windy, WindowsDirectory);
  419. LogProc->InitFile(szLogFileName, Windy);
  420. return TRUE;
  421. }
  422. void CLASS_GeneralInfo::InitHelpers(void)
  423. {
  424. }
  425. void CLASS_GeneralInfo::DetermineCommandLine(void)
  426. {
  427. }
  428. BOOL CLASS_GeneralInfo::FillInArguments(void)
  429. {
  430. kCommandLine CommandLine;
  431. TCHAR ComputerName[MAX_COMPUTERNAME_LENGTH+1];
  432. TCHAR CurrentDirectory[MAX_PATH];
  433. HANDLE FileSearch;
  434. WIN32_FIND_DATA FileData;
  435. BOOL PrePopulateFileFound = FALSE;
  436. DWORD NameBufferSize = MAX_COMPUTERNAME_LENGTH + 1;
  437. lstrcpy(Corporation, "");
  438. lstrcpy(Email, "");
  439. lstrcpy(Manufacturer, "");
  440. lstrcpy(Model, "");
  441. lstrcpy(NumComp, "");
  442. lstrcpy(SiteID, "");
  443. lstrcpy(Profile, "");
  444. lstrcpy(BetaID, "");
  445. lstrcpy(MachineType, "");
  446. SiteIDIndex=0;
  447. MachineTypeIndex=0;
  448. if (0 != GetModuleFileName(NULL, CurrentDirectory, MAX_PATH))
  449. {
  450. DWORD NameCounter;
  451. NameCounter = lstrlen(CurrentDirectory);
  452. while ( ('\\' != CurrentDirectory[NameCounter]) && (0 != NameCounter) )
  453. NameCounter--;
  454. CurrentDirectory[NameCounter]='\0';
  455. if ('\\' != CurrentDirectory[lstrlen(CurrentDirectory)-1] )
  456. {
  457. lstrcat(CurrentDirectory, "\\sysparsq");
  458. }
  459. else
  460. {
  461. lstrcat(CurrentDirectory, "sysparsq");
  462. }
  463. FileSearch=FindFirstFile(CurrentDirectory, &FileData);
  464. if (INVALID_HANDLE_VALUE != FileSearch)
  465. {
  466. //found the INI
  467. ReadInFileInfo(CurrentDirectory);
  468. FindClose(FileSearch);
  469. PrePopulateFileFound = TRUE;
  470. }
  471. else
  472. {
  473. lstrcat(CurrentDirectory, TEXT(".ini"));
  474. FileSearch = FindFirstFile(CurrentDirectory, &FileData);
  475. if (INVALID_HANDLE_VALUE != FileSearch)
  476. {
  477. //found the INI
  478. ReadInFileInfo(CurrentDirectory);
  479. FindClose(FileSearch);
  480. PrePopulateFileFound = TRUE;
  481. }
  482. }
  483. if (CommandLine.IsSpecified("/p",NOT_CASE_SENSITIVE))
  484. {
  485. PTCHAR Switch;
  486. TCHAR Message1[MAX_PATH * 4], Message2[MAX_PATH * 4];
  487. DWORD ret;
  488. HANDLE SearchHandle;
  489. WIN32_FIND_DATA Data;
  490. Switch = CommandLine.GetSwitchValue("/p",NOT_CASE_SENSITIVE);
  491. if(!Switch)
  492. {
  493. SetLastError(ERROR_INVALID_PARAMETER);
  494. return FALSE;
  495. }
  496. lstrcpy (CurrentDirectory, Switch);
  497. //"/p filename" file to copy input values from
  498. SearchHandle = FindFirstFile(CurrentDirectory, &Data);
  499. if (INVALID_HANDLE_VALUE != SearchHandle)
  500. {
  501. PrePopulateFileFound = TRUE;
  502. ReadInFileInfo(CurrentDirectory);
  503. }
  504. else
  505. {
  506. wsprintf(Message2, "Could not find file %s specified with /p switch", CurrentDirectory);
  507. MessageBox(NULL, Message2, "Sysparse", MB_OK);
  508. return FALSE;
  509. }
  510. if(FileSearch)
  511. FindClose(FileSearch);
  512. }
  513. /*
  514. //fill this in with the above routine. (put it in a seperate routine and call it from here.)
  515. else if (CommandLine.IsSpecified("-p",TRUE))
  516. {
  517. TCHAR *Switch;
  518. Switch=CommandLine.GetSwitchValue("-p",TRUE);
  519. lstrcpy(CurrentDirectory, Switch);
  520. PrePopulateFileFound=TRUE;
  521. }
  522. */
  523. //No file to prepopulate sysparse with, find out if
  524. //there are any commandline arguments to look at
  525. if (CommandLine.IsSpecified("/a",NOT_CASE_SENSITIVE) || CommandLine.IsSpecified("-a",NOT_CASE_SENSITIVE))
  526. AutoRun = TRUE;
  527. if (CommandLine.IsSpecified("/m",NOT_CASE_SENSITIVE) || CommandLine.IsSpecified("-m",NOT_CASE_SENSITIVE))
  528. RunMinimized = TRUE;
  529. if (CommandLine.IsSpecified("/c",NOT_CASE_SENSITIVE) || CommandLine.IsSpecified("-c",NOT_CASE_SENSITIVE) || (TRUE == UseComputerName) )
  530. {
  531. UseComputerName = TRUE;
  532. if (GetComputerName(ComputerName, &NameBufferSize))
  533. {
  534. lstrcpy(Profile, ComputerName);
  535. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_PROFILE), WM_SETTEXT, 0, (LPARAM)Profile);
  536. }
  537. }
  538. if (CommandLine.IsSpecified(TEXT("/o"),NOT_CASE_SENSITIVE) || CommandLine.IsSpecified(TEXT("-o"), NOT_CASE_SENSITIVE))
  539. OverWrite = TRUE;
  540. if (CommandLine.IsSpecified(TEXT("/s"),NOT_CASE_SENSITIVE) || CommandLine.IsSpecified(TEXT("-s"), NOT_CASE_SENSITIVE))
  541. g_WalkStartMenu = FALSE;
  542. if (CommandLine.IsSpecified("/1",NOT_CASE_SENSITIVE))
  543. {
  544. lstrcpy(Corporation, CommandLine.GetSwitchValue("/1",NOT_CASE_SENSITIVE));
  545. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_CORPORATION), WM_SETTEXT, 0, (LPARAM)Corporation);
  546. }
  547. else if (CommandLine.IsSpecified("-1",NOT_CASE_SENSITIVE))
  548. {
  549. lstrcpy(Corporation, CommandLine.GetSwitchValue("-1",NOT_CASE_SENSITIVE));
  550. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_CORPORATION), WM_SETTEXT, 0, (LPARAM)Corporation);
  551. }
  552. if (CommandLine.IsSpecified("/2",NOT_CASE_SENSITIVE))
  553. {
  554. lstrcpy(Email, CommandLine.GetSwitchValue("/2",NOT_CASE_SENSITIVE));
  555. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_EMAIL), WM_SETTEXT, 0, (LPARAM)Email);
  556. }
  557. else if (CommandLine.IsSpecified("-2",NOT_CASE_SENSITIVE))
  558. {
  559. lstrcpy(Email, CommandLine.GetSwitchValue("-2",NOT_CASE_SENSITIVE));
  560. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_EMAIL), WM_SETTEXT, 0, (LPARAM)Email);
  561. }
  562. if (CommandLine.IsSpecified("/6",NOT_CASE_SENSITIVE))
  563. {
  564. lstrcpy(Manufacturer, CommandLine.GetSwitchValue("/6",NOT_CASE_SENSITIVE));
  565. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_MANUFACTURER), WM_SETTEXT, 0, (LPARAM)Manufacturer);
  566. }
  567. else if (CommandLine.IsSpecified("-6",NOT_CASE_SENSITIVE))
  568. {
  569. lstrcpy(Manufacturer, CommandLine.GetSwitchValue("-6",NOT_CASE_SENSITIVE));
  570. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_MANUFACTURER), WM_SETTEXT, 0, (LPARAM)Manufacturer);
  571. }
  572. if (CommandLine.IsSpecified("/7",NOT_CASE_SENSITIVE))
  573. {
  574. lstrcpy(Model, CommandLine.GetSwitchValue("/7",NOT_CASE_SENSITIVE));
  575. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_MODEL), WM_SETTEXT, 0, (LPARAM)Model);
  576. }
  577. else if (CommandLine.IsSpecified("-7",NOT_CASE_SENSITIVE))
  578. {
  579. lstrcpy(Model, CommandLine.GetSwitchValue("-7",NOT_CASE_SENSITIVE));
  580. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_MODEL), WM_SETTEXT, 0, (LPARAM)Model);
  581. }
  582. if (CommandLine.IsSpecified("/9",NOT_CASE_SENSITIVE))
  583. {
  584. lstrcpy(NumComp, CommandLine.GetSwitchValue("/9",NOT_CASE_SENSITIVE));
  585. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_NUMCOMP), WM_SETTEXT, 0, (LPARAM)NumComp);
  586. }
  587. else if (CommandLine.IsSpecified("-9",NOT_CASE_SENSITIVE))
  588. {
  589. lstrcpy(NumComp, CommandLine.GetSwitchValue("-9",NOT_CASE_SENSITIVE));
  590. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_NUMCOMP), WM_SETTEXT, 0, (LPARAM)NumComp);
  591. }
  592. if (CommandLine.IsSpecified("/3",NOT_CASE_SENSITIVE))
  593. {
  594. TCHAR Temp[MAX_PATH * 4];
  595. lstrcpy(Temp, CommandLine.GetSwitchValue("/3",NOT_CASE_SENSITIVE));
  596. SiteIDIndex=(UINT)_ttoi(Temp);
  597. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID), CB_SETCURSEL, SiteIDIndex+1, 0);
  598. SendMessage(gHandleToMainWindow, WM_COMMAND, MAKEWPARAM(IDC_COMBO_SITEID, 0), (LPARAM)GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID));
  599. }
  600. else if (CommandLine.IsSpecified("-3",NOT_CASE_SENSITIVE))
  601. {
  602. TCHAR Temp[MAX_PATH * 4];
  603. lstrcpy(Temp, CommandLine.GetSwitchValue("-3",NOT_CASE_SENSITIVE));
  604. SiteIDIndex = (UINT)_ttoi(Temp);
  605. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID), CB_SETCURSEL, SiteIDIndex+1, 0);
  606. SendMessage(gHandleToMainWindow, WM_COMMAND, MAKEWPARAM(IDC_COMBO_SITEID, 0), (LPARAM)GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID));
  607. }
  608. if (CommandLine.IsSpecified("/4",NOT_CASE_SENSITIVE))
  609. {
  610. if (!UseComputerName)
  611. {
  612. lstrcpy(Profile, CommandLine.GetSwitchValue("/4",NOT_CASE_SENSITIVE));
  613. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_PROFILE), WM_SETTEXT, 0, (LPARAM)Profile);
  614. }
  615. }
  616. else if (CommandLine.IsSpecified("-4",NOT_CASE_SENSITIVE))
  617. {
  618. if (!UseComputerName)
  619. {
  620. lstrcpy(Profile, CommandLine.GetSwitchValue("-4",NOT_CASE_SENSITIVE));
  621. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_PROFILE), WM_SETTEXT, 0, (LPARAM)Profile);
  622. }
  623. }
  624. if (CommandLine.IsSpecified("/5",NOT_CASE_SENSITIVE))
  625. {
  626. lstrcpy(BetaID, CommandLine.GetSwitchValue("/5",NOT_CASE_SENSITIVE));
  627. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_BETAID), WM_SETTEXT, 0, (LPARAM)BetaID);
  628. }
  629. else if (CommandLine.IsSpecified("-5",NOT_CASE_SENSITIVE))
  630. {
  631. lstrcpy(BetaID, CommandLine.GetSwitchValue("-5",NOT_CASE_SENSITIVE));
  632. SendMessage(GetDlgItem(gHandleToMainWindow, IDC_EDIT_BETAID), WM_SETTEXT, 0, (LPARAM)BetaID);
  633. }
  634. if (CommandLine.IsSpecified("/8",NOT_CASE_SENSITIVE))
  635. {
  636. TCHAR Temp[MAX_PATH * 4];
  637. lstrcpy (Temp, CommandLine.GetSwitchValue ("/8",NOT_CASE_SENSITIVE));
  638. MachineTypeIndex = (UINT)_ttoi(Temp);
  639. SendMessage (GetDlgItem (gHandleToMainWindow, IDC_COMBO_TYPE), CB_SETCURSEL, MachineTypeIndex + 1, 0);
  640. }
  641. else if (CommandLine.IsSpecified("-8",NOT_CASE_SENSITIVE))
  642. {
  643. TCHAR Temp[MAX_PATH * 4];
  644. SendMessage (GetDlgItem (gHandleToMainWindow, IDC_COMBO_TYPE), CB_SETCURSEL, MachineTypeIndex + 1, 0);
  645. }
  646. }
  647. return TRUE;
  648. }
  649. BOOL CLASS_GeneralInfo::ReadInFileInfo(PTCHAR pFileName)
  650. {
  651. TCHAR AutoRunText[MAX_PATH * 4];
  652. HWND HandleToControl;
  653. DWORD ret;
  654. if(!pFileName)
  655. return FALSE;
  656. if(!lstrlen(pFileName))
  657. return FALSE;
  658. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Corp\"", "", Corporation, MAX_PATH * 4, pFileName);
  659. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Make\"", "", Manufacturer, MAX_PATH * 4, pFileName);
  660. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Model\"", "", Model, MAX_PATH * 4, pFileName);
  661. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#UserID\"", "", Email, MAX_PATH * 4, pFileName);
  662. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"##machines_on_profile\"", "", NumComp, MAX_PATH * 4, pFileName);
  663. ret = 0;
  664. while ('\0' != NumComp[ret])
  665. {
  666. if ( (NumComp[ret] < 48) || (NumComp[ret] > 57) )
  667. {
  668. TCHAR Error[MAX_PATH * 4];
  669. wsprintf(Error, "##machines_on_profile in %s is not valid", pFileName);
  670. MessageBox(NULL, Error, "Sysparse", MB_OK);
  671. return FALSE;
  672. }
  673. ret++;
  674. }
  675. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Event\"", "", SiteID, MAX_PATH * 4, pFileName);
  676. if (0 != lstrlen(SiteID))
  677. {
  678. if (INVALID_HANDLE_VALUE != (HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID)))
  679. SiteIDIndex = (USHORT)SendMessage(HandleToControl, CB_FINDSTRINGEXACT, -1, (LPARAM)SiteID);
  680. if (CB_ERR == SiteIDIndex)
  681. {
  682. MessageBox(gHandleToMainWindow, "SiteID (#Event) specified in INI is invalid", "Sysparse", MB_OK);
  683. return FALSE;
  684. }
  685. else
  686. {
  687. SendMessage(HandleToControl, CB_SETCURSEL, SiteIDIndex, 0);
  688. SendMessage(gHandleToMainWindow, WM_COMMAND, MAKEWPARAM(IDC_COMBO_SITEID, 0), (LPARAM)GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID));
  689. }
  690. }
  691. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Profile\"", "", Profile, MAX_PATH * 4, pFileName);
  692. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#Location\"", "", BetaID, MAX_PATH * 4, pFileName);
  693. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#MachineType\"", "", MachineType, MAX_PATH * 4, pFileName);
  694. if (0 != lstrlen(MachineType))
  695. {
  696. if (INVALID_HANDLE_VALUE != (HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_COMBO_TYPE)))
  697. MachineTypeIndex = (USHORT)SendMessage(HandleToControl, CB_FINDSTRINGEXACT, -1, (LPARAM)MachineType);
  698. if (CB_ERR == MachineTypeIndex)
  699. {
  700. MessageBox(gHandleToMainWindow, "MachineType (#Event) specified in INI is not valid", "Sysparse", MB_OK);
  701. return FALSE;
  702. }
  703. else if(INVALID_HANDLE_VALUE != HandleToControl)
  704. {
  705. SendMessage(HandleToControl, CB_SETCURSEL, MachineTypeIndex, 0);
  706. }
  707. else {
  708. return FALSE;
  709. }
  710. }
  711. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#AutoRun\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  712. _tcslwr(AutoRunText);
  713. if (!lstrcmp(AutoRunText, TEXT("yes")))
  714. AutoRun = TRUE;
  715. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#OverWriteCSV\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  716. _tcslwr(AutoRunText);
  717. if (!lstrcmp(AutoRunText, TEXT("yes")))
  718. OverWrite = TRUE;
  719. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#RunMinimized\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  720. _tcslwr(AutoRunText);
  721. if (!lstrcmp(AutoRunText, TEXT("yes")))
  722. RunMinimized = TRUE;
  723. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#UseComputerName\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  724. _tcslwr(AutoRunText);
  725. if (!lstrcmp(AutoRunText, TEXT("yes")))
  726. UseComputerName = TRUE;
  727. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#donotrun1\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  728. _tcslwr(AutoRunText);
  729. if (!lstrcmp(AutoRunText, TEXT("yes")))
  730. RunChkupgrd=FALSE;
  731. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#donotrun2\"", "", AutoRunText, MAX_PATH * 4, pFileName);
  732. _tcslwr(AutoRunText);
  733. if (!lstrcmp(AutoRunText, TEXT("yes")))
  734. RunDevdump=FALSE;
  735. GetPrivateProfileString ("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse", "\"#MachineUUID\"", "", OriginalMachineUUID, MAX_PATH * 4, pFileName);
  736. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_CORPORATION);
  737. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)Corporation);
  738. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_EMAIL);
  739. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)Email);
  740. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_MANUFACTURER);
  741. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)Manufacturer);
  742. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_MODEL);
  743. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)Model);
  744. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_NUMCOMP);
  745. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)NumComp);
  746. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_PROFILE);
  747. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)Profile);
  748. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_BETAID);
  749. SendMessage(HandleToControl, WM_SETTEXT, 0, (LPARAM)BetaID);
  750. return TRUE;
  751. }
  752. BOOL CLASS_GeneralInfo::DetermineArgumentValidity(void)
  753. {
  754. BOOL ReturnValue;
  755. DWORD Counter;
  756. ReturnValue = CopyInput();
  757. if (FALSE == ReturnValue)
  758. return FALSE;
  759. Counter=0;
  760. while (Profile[Counter]!='\0')
  761. {
  762. if (Profile[Counter] != 'a' &&
  763. Profile[Counter] != 'b' &&
  764. Profile[Counter] != 'c' &&
  765. Profile[Counter] != 'd' &&
  766. Profile[Counter] != 'e' &&
  767. Profile[Counter] != 'f' &&
  768. Profile[Counter] != 'g' &&
  769. Profile[Counter] != 'h' &&
  770. Profile[Counter] != 'i' &&
  771. Profile[Counter] != 'j' &&
  772. Profile[Counter] != 'k' &&
  773. Profile[Counter] != 'l' &&
  774. Profile[Counter] != 'm' &&
  775. Profile[Counter] != 'n' &&
  776. Profile[Counter] != 'o' &&
  777. Profile[Counter] != 'p' &&
  778. Profile[Counter] != 'q' &&
  779. Profile[Counter] != 'r' &&
  780. Profile[Counter] != 's' &&
  781. Profile[Counter] != 't' &&
  782. Profile[Counter] != 'u' &&
  783. Profile[Counter] != 'v' &&
  784. Profile[Counter] != 'w' &&
  785. Profile[Counter] != 'x' &&
  786. Profile[Counter] != 'y' &&
  787. Profile[Counter] != 'z' &&
  788. Profile[Counter] != 'A' &&
  789. Profile[Counter] != 'B' &&
  790. Profile[Counter] != 'C' &&
  791. Profile[Counter] != 'D' &&
  792. Profile[Counter] != 'E' &&
  793. Profile[Counter] != 'F' &&
  794. Profile[Counter] != 'G' &&
  795. Profile[Counter] != 'H' &&
  796. Profile[Counter] != 'I' &&
  797. Profile[Counter] != 'J' &&
  798. Profile[Counter] != 'K' &&
  799. Profile[Counter] != 'L' &&
  800. Profile[Counter] != 'M' &&
  801. Profile[Counter] != 'N' &&
  802. Profile[Counter] != 'O' &&
  803. Profile[Counter] != 'P' &&
  804. Profile[Counter] != 'Q' &&
  805. Profile[Counter] != 'R' &&
  806. Profile[Counter] != 'S' &&
  807. Profile[Counter] != 'T' &&
  808. Profile[Counter] != 'U' &&
  809. Profile[Counter] != 'V' &&
  810. Profile[Counter] != 'W' &&
  811. Profile[Counter] != 'X' &&
  812. Profile[Counter] != 'Y' &&
  813. Profile[Counter] != 'Z' &&
  814. Profile[Counter] != '0' &&
  815. Profile[Counter] != '1' &&
  816. Profile[Counter] != '2' &&
  817. Profile[Counter] != '3' &&
  818. Profile[Counter] != '4' &&
  819. Profile[Counter] != '5' &&
  820. Profile[Counter] != '6' &&
  821. Profile[Counter] != '7' &&
  822. Profile[Counter] != '8' &&
  823. Profile[Counter] != '9' &&
  824. Profile[Counter] != ' ' &&
  825. Profile[Counter] != '_' &&
  826. Profile[Counter] != '-' )
  827. {
  828. Profile[Counter]=TEXT('_');
  829. }
  830. Counter++;
  831. }
  832. return TRUE;
  833. }
  834. void CLASS_GeneralInfo::ChangeSpaces(TCHAR *Input)
  835. {
  836. TCHAR Temp[MAX_PATH * 4];
  837. DWORD Counter;
  838. DWORD Len;
  839. Counter = 0;
  840. Len = lstrlen(Temp);
  841. lstrcpy(Temp, Input);
  842. while (('\0' != Temp[Counter]) && (Counter != Len))
  843. {
  844. if ( ' ' == Temp[Counter] )
  845. Temp[Counter]='_';
  846. Counter++;
  847. }
  848. lstrcpy(Input, Temp);
  849. }
  850. BOOL CLASS_GeneralInfo::CopyInput(void)
  851. {
  852. HWND HandleToControl;
  853. TCHAR Holder[MAX_PATH * 4];
  854. DWORD Retval;
  855. HandleToControl=GetDlgItem(gHandleToMainWindow, IDC_EDIT_CORPORATION);
  856. if (HandleToControl)
  857. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)Corporation);
  858. if (0 == lstrlen(Corporation))
  859. {
  860. MessageBox(gHandleToMainWindow, "Please enter a value for Corporation", "Sysparse", MB_OK);
  861. return FALSE;
  862. }
  863. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_EMAIL);
  864. if (HandleToControl)
  865. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)Email);
  866. if (0 == lstrlen(Email))
  867. {
  868. MessageBox(gHandleToMainWindow, "Please enter a value for E-mail", "Sysparse", MB_OK);
  869. return FALSE;
  870. }
  871. HandleToControl=GetDlgItem(gHandleToMainWindow, IDC_EDIT_MANUFACTURER);
  872. if (HandleToControl)
  873. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)Manufacturer);
  874. if (0 == lstrlen(Manufacturer))
  875. {
  876. MessageBox(gHandleToMainWindow, "Please enter a value for Manufacturer", "Sysparse", MB_OK);
  877. return FALSE;
  878. }
  879. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_MODEL);
  880. if (HandleToControl)
  881. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)Model);
  882. if (0 == lstrlen(Model))
  883. {
  884. MessageBox(gHandleToMainWindow, "Please enter a value for Model", "Sysparse", MB_OK);
  885. return FALSE;
  886. }
  887. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_NUMCOMP);
  888. if (HandleToControl)
  889. {
  890. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)NumComp);
  891. }
  892. if (0 == lstrlen(NumComp))
  893. {
  894. MessageBox(gHandleToMainWindow, "Please enter a value for # Computers", "Sysparse", MB_OK);
  895. return FALSE;
  896. }
  897. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_COMBO_SITEID);
  898. if (HandleToControl)
  899. {
  900. SiteIDIndex=(unsigned short)SendMessage(HandleToControl, CB_GETCURSEL, 0, 0);
  901. }
  902. #ifndef SB
  903. if (0 == SiteIDIndex)
  904. {
  905. MessageBox(gHandleToMainWindow, "Please select a value for Site ID", "Sysparse", MB_OK);
  906. return FALSE;
  907. }
  908. #else
  909. if (0 != SiteIDIndex)
  910. {
  911. MessageBox(gHandleToMainWindow, "Please select a value for Site ID", "Sysparse", MB_OK);
  912. return FALSE;
  913. }
  914. #endif
  915. else
  916. SendMessage(HandleToControl, CB_GETLBTEXT, SiteIDIndex, (LPARAM)SiteID);
  917. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_PROFILE);
  918. if (HandleToControl)
  919. Retval=(DWORD)SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)Profile);
  920. if (0 == Retval)
  921. {
  922. MessageBox(gHandleToMainWindow, "Please enter a value for Profile", "Sysparse", MB_OK);
  923. return FALSE;
  924. }
  925. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_EDIT_BETAID);
  926. if (HandleToControl)
  927. SendMessage(HandleToControl, WM_GETTEXT, MAX_PATH * 4, (LPARAM)BetaID);
  928. if (0 == lstrlen(BetaID))
  929. {
  930. MessageBox(gHandleToMainWindow, TEXT("Please enter a value for Beta ID"), TEXT("Sysparse"), MB_OK);
  931. return FALSE;
  932. }
  933. HandleToControl = GetDlgItem(gHandleToMainWindow, IDC_COMBO_TYPE);
  934. if (HandleToControl)
  935. MachineTypeIndex = (unsigned short)SendMessage(HandleToControl, CB_GETCURSEL, 0, 0);
  936. if (0 == MachineTypeIndex)
  937. {
  938. MessageBox(gHandleToMainWindow, TEXT("Please select a value for MachineType"), TEXT("Sysparse"), MB_OK);
  939. return FALSE;
  940. }
  941. else
  942. SendMessage(HandleToControl, CB_GETLBTEXT, MachineTypeIndex, (LPARAM)MachineType);
  943. return TRUE;
  944. }
  945. void CLASS_GeneralInfo::WriteVersions(void)
  946. {
  947. SYSTEMTIME SysTime;
  948. #ifdef INTERNAL
  949. LogProc->LogString(TEXT(",#Sysparse_Version,,\r\n,02.05.02I,\r\n"));
  950. #else
  951. LogProc->LogString(TEXT(",#Sysparse_Version,,\r\n,02.05.02E,\r\n"));
  952. #endif
  953. LogProc->LogString(TEXT(",#ParseTime,,\r\n"));
  954. GetSystemTime(&SysTime);
  955. LogProc->LogString (TEXT(",%2d/%2d/%4d %2d:%2d:%2d,\r\n"), SysTime.wMonth, SysTime.wDay, SysTime.wYear, SysTime.wHour, SysTime.wMinute, SysTime.wSecond);
  956. }
  957. void CLASS_GeneralInfo::WriteGeneralInfo(void)
  958. {
  959. }
  960. void CLASS_GeneralInfo::GetUUID(void)
  961. {
  962. HKEY hOpen;
  963. LONG lRet;
  964. lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\SysParse"), 0, KEY_ALL_ACCESS, &hOpen);
  965. if (ERROR_SUCCESS == lRet)
  966. {
  967. UCHAR *szreg = (UCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH * 4);
  968. TCHAR szFile[MAX_PATH];
  969. TCHAR szfilecont[50000];
  970. DWORD dwlen = MAX_PATH * 4;
  971. DWORD dwType;
  972. LPTSTR szval = (LPTSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH * 4);
  973. lstrcpy(szval, TEXT("#MachineUuid"));
  974. lRet = RegQueryValueEx(hOpen, szval, NULL, &dwType, szreg, &dwlen);
  975. if (ERROR_SUCCESS == lRet)
  976. {
  977. LogProc->LogString(TEXT(",#MachineUUID,,\r\n"));
  978. LogProc->LogString(TEXT(",%s,\r\n"), szreg);
  979. RegSetValueEx(hOpen, TEXT("#Profile"), 0, REG_SZ, (BYTE*)Profile, lstrlen((const char *)Profile)+1);
  980. RegSetValueEx(hOpen, TEXT("#Corp"), 0, REG_SZ, (BYTE*)Corporation, lstrlen((const char *)Corporation)+1);
  981. RegSetValueEx(hOpen, TEXT("#UserID"), 0, REG_SZ, (BYTE*)Email, lstrlen((const char *)Email)+1);
  982. RegSetValueEx(hOpen, TEXT("##machines_on_profile"), 0, REG_SZ, (BYTE*)NumComp, lstrlen((const char *)NumComp)+1);
  983. RegSetValueEx(hOpen, TEXT("#Make"), 0, REG_SZ, (BYTE*)Manufacturer, lstrlen((const char *)Manufacturer)+1);
  984. RegSetValueEx(hOpen, TEXT("#Model"), 0, REG_SZ, (BYTE*)Model, lstrlen((const char *)Model)+1);
  985. RegSetValueEx(hOpen, TEXT("#Event"), 0, REG_SZ, (BYTE*)BetaID, lstrlen((const char *)BetaID)+1);
  986. RegSetValueEx(hOpen, TEXT("#MachineType"), 0, REG_SZ, (BYTE*)MachineType, lstrlen((const char *)MachineType)+1);
  987. }
  988. else
  989. {
  990. LogProc->LogString(TEXT(",#MachineUUID,,\r\n"));
  991. UUID uuid;
  992. LONG wRet;
  993. UCHAR *szuuid = 0x0;
  994. wRet = UuidCreate(&uuid);
  995. if ((RPC_S_OK == wRet) || (RPC_S_UUID_LOCAL_ONLY))
  996. {
  997. wRet=UuidToString(&uuid, &szuuid);
  998. if (RPC_S_OK == wRet)
  999. LogProc->LogString(TEXT(",%s,\r\n"),szuuid);
  1000. else
  1001. LogProc->LogString(TEXT(",blank,\r\n"));
  1002. }
  1003. else
  1004. LogProc->LogString(TEXT(",blank,\r\n"));
  1005. HKEY hKey;
  1006. DWORD dwDisp;
  1007. RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\SysParse"), 0, TEXT("SZ_KEY"), 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp);
  1008. RegSetValueEx(hKey, TEXT("#MachineUuid"), 0, REG_SZ, szuuid, lstrlen((const char *)szuuid) + 1);
  1009. lstrcpy((TCHAR *) szreg, (TCHAR *)szuuid);
  1010. RegSetValueEx(hOpen, TEXT("#Profile"), 0, REG_SZ, (BYTE*)Profile, lstrlen((const char *)Profile) + 1);
  1011. RegSetValueEx(hOpen, TEXT("#Corp"), 0, REG_SZ, (BYTE*)Corporation, lstrlen((const char *)Corporation) + 1);
  1012. RegSetValueEx(hOpen, TEXT("#UserID"), 0, REG_SZ, (BYTE*)Email, lstrlen((const char *)Email) + 1);
  1013. RegSetValueEx(hOpen, TEXT("##machines_on_profile"), 0, REG_SZ, (BYTE*)NumComp, lstrlen((const char *)NumComp) + 1);
  1014. RegSetValueEx(hOpen, TEXT("#Make"), 0, REG_SZ, (BYTE*)Manufacturer, lstrlen((const char *)Manufacturer) + 1);
  1015. RegSetValueEx(hOpen, TEXT("#Model"), 0, REG_SZ, (BYTE*)Model, lstrlen((const char *)Model) + 1);
  1016. RegSetValueEx(hOpen, TEXT("#Event"), 0, REG_SZ, (BYTE*)BetaID, lstrlen((const char *)BetaID) + 1);
  1017. RegSetValueEx(hOpen, TEXT("#MachineType"), 0, REG_SZ, (BYTE*)MachineType, lstrlen((const char *)MachineType) + 1);
  1018. if (INVALID_HANDLE_VALUE != hKey )
  1019. RegCloseKey(hKey);
  1020. }
  1021. if (INVALID_HANDLE_VALUE != hOpen)
  1022. RegCloseKey(hOpen);
  1023. HANDLE hFile;
  1024. DWORD dwBytesWrit;
  1025. hFile = CreateFile(szRegFile, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  1026. if (hFile!=INVALID_HANDLE_VALUE)
  1027. {
  1028. wsprintf(szfilecont, TEXT("REGEDIT4\r\n\r\n[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse]\r\n"));
  1029. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1030. wsprintf(szfilecont, TEXT("\"#MachineUuid\"=\"%s\"\r\n"), szreg);
  1031. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1032. wsprintf(szfilecont, TEXT("\"#Profile\"=\"%s\"\r\n"), Profile);
  1033. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1034. wsprintf(szfilecont, TEXT("\"#Corp\"=\"%s\"\r\n"), Corporation);
  1035. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1036. wsprintf(szfilecont, TEXT("\"#UserID\"=\"%s\"\r\n"), Email);
  1037. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1038. wsprintf(szfilecont, TEXT("\"##machines_on_profile\"=\"%s\"\r\n"), NumComp);
  1039. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1040. wsprintf(szfilecont, TEXT("\"#Make\"=\"%s\"\r\n"), Manufacturer);
  1041. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1042. wsprintf(szfilecont, TEXT("\"#Model\"=\"%s\"\r\n"), Model);
  1043. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1044. wsprintf(szfilecont, TEXT("\"#Event\"=\"%s\"\r\n"), SiteID);
  1045. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1046. wsprintf(szfilecont, TEXT("\"#Location\"=\"%s\"\r\n"), BetaID);
  1047. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1048. wsprintf(szfilecont, TEXT("\"#MachineType\"=\"%s\"\r\n"), MachineType);
  1049. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1050. CloseHandle(hFile);
  1051. }
  1052. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, szreg);
  1053. }
  1054. else
  1055. {
  1056. LogProc->LogString(",#MachineUUID,,\r\n");
  1057. UUID uuid;
  1058. LONG wRet;
  1059. UCHAR *szuuid = 0x0;
  1060. wRet = UuidCreate(&uuid);
  1061. if ((RPC_S_OK == wRet) || (RPC_S_UUID_LOCAL_ONLY))
  1062. {
  1063. wRet = UuidToString(&uuid, &szuuid);
  1064. if (RPC_S_OK == wRet)
  1065. LogProc->LogString(",%s,\r\n",szuuid);
  1066. else
  1067. LogProc->LogString(",blank,\r\n");
  1068. }
  1069. else
  1070. LogProc->LogString(",blank,\r\n");
  1071. HKEY hKey;
  1072. DWORD dwDisp;
  1073. TCHAR szFile[MAX_PATH];
  1074. RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\SysParse", 0, "SZ_KEY", 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp);
  1075. RegSetValueEx(hKey, "#MachineUuid", 0, REG_SZ, szuuid, lstrlen((const char *)szuuid) + 1);
  1076. RegSetValueEx(hKey, TEXT("#Profile"), 0, REG_SZ, (BYTE*)Profile, lstrlen((const char *)Profile) + 1);
  1077. RegSetValueEx(hKey, TEXT("#Corp"), 0, REG_SZ, (BYTE*)Corporation, lstrlen((const char *)Corporation) + 1);
  1078. RegSetValueEx(hKey, TEXT("#UserID"), 0, REG_SZ, (BYTE*)Email, lstrlen((const char *)Email) + 1);
  1079. RegSetValueEx(hKey, TEXT("##machines_on_profile"), 0, REG_SZ, (BYTE*)NumComp, lstrlen((const char *)NumComp) + 1);
  1080. RegSetValueEx(hKey, TEXT("#Make"), 0, REG_SZ, (BYTE*)Manufacturer, lstrlen((const char *)Manufacturer) + 1);
  1081. RegSetValueEx(hKey, TEXT("#Model"), 0, REG_SZ, (BYTE*)Model, lstrlen((const char *)Model) + 1);
  1082. RegSetValueEx(hKey, TEXT("#Event"), 0, REG_SZ, (BYTE*)BetaID, lstrlen((const char *)BetaID) + 1);
  1083. RegSetValueEx(hKey, TEXT("#MachineType"), 0, REG_SZ, (BYTE*)MachineType, lstrlen((const char *)MachineType) + 1);
  1084. if (INVALID_HANDLE_VALUE != hKey)
  1085. RegCloseKey(hKey);
  1086. HANDLE hFile;
  1087. DWORD dwBytesWrit;
  1088. TCHAR szfilecont[50000];
  1089. hFile = CreateFile(szRegFile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  1090. if (hFile!=INVALID_HANDLE_VALUE)
  1091. {
  1092. wsprintf(szfilecont, TEXT("REGEDIT4\r\n\r\n[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\SysParse]\r\n"));
  1093. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1094. wsprintf(szfilecont, TEXT("\"#MachineUuid\"=\"%s\"\r\n"), szuuid);
  1095. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1096. wsprintf(szfilecont, TEXT("\"#Profile\"=\"%s\"\r\n"), Profile);
  1097. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1098. wsprintf(szfilecont, TEXT("\"#Corp\"=\"%s\"\r\n"), Corporation);
  1099. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1100. wsprintf(szfilecont, TEXT("\"#UserID\"=\"%s\"\r\n"), Email);
  1101. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1102. wsprintf(szfilecont, TEXT("\"##machines_on_profile\"=\"%s\"\r\n"), NumComp);
  1103. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1104. wsprintf(szfilecont, TEXT("\"#Make\"=\"%s\"\r\n"), Manufacturer);
  1105. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1106. wsprintf(szfilecont, TEXT("\"#Model\"=\"%s\"\r\n"), Model);
  1107. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1108. wsprintf(szfilecont, TEXT("\"#Event\"=\"%s\"\r\n"), SiteID);
  1109. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1110. wsprintf(szfilecont, TEXT("\"#Location\"=\"%s\"\r\n"), BetaID);
  1111. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1112. wsprintf(szfilecont, TEXT("\"#MachineType\"=\"%s\"\r\n"), MachineType);
  1113. WriteFile(hFile, szfilecont, strlen(szfilecont), &dwBytesWrit, NULL);
  1114. CloseHandle(hFile);
  1115. }
  1116. }
  1117. LONG wRet;
  1118. UUID uuid;
  1119. UCHAR *szuuid = 0x0;
  1120. LogProc->LogString(",#PassUUID,,\r\n");
  1121. wRet = UuidCreate(&uuid);
  1122. if ((RPC_S_OK == wRet) || (RPC_S_UUID_LOCAL_ONLY))
  1123. {
  1124. wRet = UuidToString(&uuid, &szuuid);
  1125. if (RPC_S_OK == wRet)
  1126. LogProc->LogString(",%s,\r\n",szuuid);
  1127. else
  1128. LogProc->LogString(",blank,\r\n");
  1129. }
  1130. else
  1131. LogProc->LogString(",blank,\r\n");
  1132. }
  1133. void CLASS_GeneralInfo::WriteArguments(void)
  1134. {
  1135. LogProc->StripCommas(Profile);
  1136. LogProc->LogString(",#Profile,,\r\n,%s,\r\n",Profile);
  1137. LogProc->StripCommas(Email);
  1138. LogProc->LogString(",#UserID,,\r\n,%s,\r\n",Email);
  1139. LogProc->StripCommas(NumComp);
  1140. LogProc->LogString(",##machines_on_profile,,\r\n,%s,\r\n",NumComp);
  1141. LogProc->StripCommas(Corporation);
  1142. LogProc->LogString(",#Corp,,\r\n,%s,\r\n",Corporation);
  1143. LogProc->StripCommas(Model);
  1144. LogProc->LogString(",#Model,,\r\n,%s,\r\n",Model);
  1145. LogProc->StripCommas(BetaID);
  1146. LogProc->LogString(",#Location,,\r\n,%s,\r\n",BetaID);
  1147. LogProc->LogString(",#BetaID,,\r\n,%s,\r\n",BetaID);
  1148. LogProc->StripCommas(MachineType);
  1149. LogProc->LogString(",#MachineType,,\r\n,%s,\r\n",MachineType);
  1150. LogProc->StripCommas(SiteID);
  1151. LogProc->LogString(",#Event,,\r\n,%s,\r\n",SiteID);
  1152. LogProc->StripCommas(Manufacturer);
  1153. LogProc->LogString(",#Make,,\r\n,%s,\r\n",Manufacturer);
  1154. }
  1155. void CLASS_GeneralInfo::WriteFreeDiskSpace(void)
  1156. {
  1157. TCHAR szWindir[MAX_PATH * 4];
  1158. lstrcpy(szWindir, WindowsDirectory);
  1159. if (0 != lstrlen(szWindir) )
  1160. {
  1161. ULARGE_INTEGER uliCaller, uliNumBytes, uliNumFreeBytes;
  1162. HINSTANCE hInst2 = LoadLibraryEx("kernel32.dll", NULL, DONT_RESOLVE_DLL_REFERENCES);
  1163. LPFNDLLFUNC1 fProc=(LPFNDLLFUNC1)GetProcAddress(hInst2, "GetDiskFreeSpaceExA");
  1164. if (hInst2 && fProc)
  1165. {
  1166. fProc("c:\\", &uliCaller, &uliNumBytes, &uliNumFreeBytes);
  1167. char szTemp[MAX_PATH * 4];
  1168. strcpy(szTemp, szWindir);
  1169. szTemp[3] = '\0';
  1170. LogProc->LogString(",#WinDir_Free_Space,,\r\n");
  1171. LogProc->StripCommas(szWindir);
  1172. LogProc->LogString(",%s,\r\n", szWindir);
  1173. LogProc->LogString(",%I64d,\r\n", uliNumFreeBytes.QuadPart);
  1174. }
  1175. else
  1176. {
  1177. DWORD dwSPC, dwPBS, dwNFC, dwTNC;
  1178. GetDiskFreeSpace("c:\\", &dwSPC, &dwPBS, &dwNFC, &dwTNC);
  1179. char szTemp[MAX_PATH * 4];
  1180. strcpy(szTemp, szWindir);
  1181. szTemp[3] = '\0';
  1182. GetDiskFreeSpace(szTemp,&dwSPC, &dwPBS, &dwNFC, &dwTNC);
  1183. LogProc->LogString(",#WinDir_Free_Space,,\r\n");
  1184. LogProc->StripCommas(szWindir);
  1185. LogProc->LogString(",%s,\r\n", szWindir);
  1186. LogProc->LogString(",%d,\r\n", dwSPC*dwPBS*dwNFC);
  1187. }
  1188. }
  1189. }
  1190. void CLASS_GeneralInfo::WriteVolumeType(void)
  1191. {
  1192. TCHAR szWind[MAX_PATH];
  1193. TCHAR szVol[MAX_PATH];
  1194. TCHAR szVolName[MAX_PATH];
  1195. DWORD dwSer, dwLen, dwFlags;
  1196. lstrcpy(szWind, WindowsDirectory);
  1197. //
  1198. // Lop off all but "%DriveLetter%:\"
  1199. //
  1200. szWind[3] = '\0';
  1201. GetVolumeInformation(szWind, szVol, MAX_PATH, &dwSer, &dwLen, &dwFlags, szVolName, MAX_PATH);
  1202. LogProc->LogString(",#WinDir_Volume_Type,,\r\n");
  1203. LogProc->StripCommas(szVolName);
  1204. LogProc->LogString(",%s,\r\n", szVolName);
  1205. }
  1206. void CLASS_GeneralInfo::WriteMemorySize(void)
  1207. {
  1208. LogProc->LogString(",#Total_Memory,,\r\n");
  1209. MEMORYSTATUS MemStat;
  1210. GlobalMemoryStatus(&MemStat);
  1211. LogProc->LogString(",%d,\r\n",MemStat.dwTotalPhys);
  1212. }
  1213. void CLASS_GeneralInfo::WriteOSVersion(void)
  1214. {
  1215. TCHAR szFullKey[MAX_PATH];
  1216. PTCHAR szProductName = NULL;
  1217. PTCHAR szString = NULL;
  1218. TCHAR szinf[MAX_PATH];
  1219. HANDLE hFile = INVALID_HANDLE_VALUE;
  1220. HKEY hKeyReg;
  1221. LPOSVERSIONINFO osv = NULL;
  1222. DWORD dwstringwrit, dwFileSize = 0, dwType, dwProductSize = 0;
  1223. lstrcpy(szFullKey, TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion"));
  1224. LogProc->LogString(TEXT(",#OS_Version,,\r\n"));
  1225. if ((Win2000 != OSVersion) && (NT4 != OSVersion) && (Whistler != OSVersion))
  1226. {
  1227. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_SETUP, 0, KEY_READ, &hKeyReg))
  1228. {
  1229. if(ERROR_SUCCESS == RegQueryValueEx(hKeyReg, TEXT("ProductName"), NULL, &dwType, NULL, &dwProductSize))
  1230. szProductName = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwProductSize);
  1231. if(szProductName)
  1232. {
  1233. RegQueryValueEx(hKeyReg, TEXT("ProductName"), NULL, &dwType, (LPBYTE)szProductName, &dwProductSize);
  1234. }
  1235. RegCloseKey(hKeyReg);
  1236. }
  1237. }
  1238. else
  1239. {
  1240. if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &hKeyReg))
  1241. {
  1242. if(ERROR_SUCCESS == RegQueryValueEx(hKeyReg, TEXT("ProductName"), NULL, &dwType, NULL, &dwProductSize))
  1243. szProductName = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwProductSize);
  1244. if(szProductName)
  1245. {
  1246. RegQueryValueEx(hKeyReg, TEXT("ProductName"), NULL, &dwType, (LPBYTE)szProductName, &dwProductSize);
  1247. }
  1248. RegCloseKey(hKeyReg);
  1249. }
  1250. }
  1251. //
  1252. // Ensure there is a value to write, otherwise write a default to avoid parser issues
  1253. //
  1254. if (dwProductSize)
  1255. {
  1256. LogProc->StripCommas(szProductName);
  1257. LogProc->LogString(TEXT(",%s,\r\n"), szProductName);
  1258. }
  1259. else
  1260. {
  1261. if (Win2000 == OSVersion)
  1262. LogProc->LogString(TEXT(",Microsoft Windows 2000,\r\n"));
  1263. else if (Whistler == OSVersion)
  1264. LogProc->LogString(TEXT(",Microsoft Windows Whistler,\r\n"));
  1265. else if (Win95 == OSVersion)
  1266. LogProc->LogString(TEXT(",Microsoft Windows 95,\r\n"));
  1267. else if (Win98 == OSVersion)
  1268. LogProc->LogString(TEXT(",Microsoft Windows 98,\r\n"));
  1269. else if (NT4 == OSVersion)
  1270. LogProc->LogString(TEXT(",Microsoft Windows NT4,\r\n"));
  1271. else
  1272. LogProc->LogString(TEXT(",Unknown,\r\n"));
  1273. }
  1274. if(szProductName)
  1275. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, szProductName);
  1276. if ( (Win2000 == OSVersion) || (NT4 == OSVersion) )
  1277. {
  1278. LogProc->LogString(",#NTType..\r\n");
  1279. lstrcpy(szFullKey, TEXT("System\\CurrentControlSet\\Control\\ProductOptions"));
  1280. if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &hKeyReg))
  1281. {
  1282. if(ERROR_SUCCESS == RegQueryValueEx(hKeyReg, TEXT("ProductType"), NULL, &dwType, NULL, &dwProductSize))
  1283. szProductName = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwProductSize);
  1284. if(!szProductName)
  1285. {
  1286. RegCloseKey(hKeyReg);
  1287. LogProc->LogString(",Workstation,\r\n");
  1288. goto GET_PREV_OS;
  1289. }
  1290. RegQueryValueEx(hKeyReg, TEXT("ProductType"), NULL, &dwType, (LPBYTE)szProductName, &dwProductSize);
  1291. if(dwProductSize)
  1292. {
  1293. if(ERROR_SUCCESS == RegQueryValueEx(hKeyReg, TEXT("ProductType"), NULL, &dwType, (LPBYTE)szProductName, &dwProductSize))
  1294. {
  1295. LogProc->StripCommas(szProductName);
  1296. LogProc->LogString(",%s,\r\n", szProductName);
  1297. }
  1298. }
  1299. else
  1300. LogProc->LogString(",Workstation,\r\n");
  1301. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, szProductName);
  1302. RegCloseKey(hKeyReg);
  1303. }
  1304. else
  1305. LogProc->LogString(",Workstation,\r\n");
  1306. }
  1307. GET_PREV_OS:
  1308. //
  1309. // Get the previous OS info, if any
  1310. //
  1311. LogProc->LogString(",#Prev_OS,,\r\n");
  1312. lstrcpy(szinf, WindowsDirectory);
  1313. lstrcat(szinf, TEXT("\\system32\\$winnt$.inf"));
  1314. hFile = CreateFile(szinf, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  1315. if (INVALID_HANDLE_VALUE != hFile)
  1316. {
  1317. LogProc->LogString(",Unknown,\r\n");
  1318. dwFileSize = GetFileSize(hFile, NULL);
  1319. szString = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwFileSize);
  1320. if(!szString)
  1321. {
  1322. LogProc->LogString(",Unknown,\r\n");
  1323. }
  1324. if(ReadFile(hFile, szString, dwFileSize, &dwstringwrit, NULL))
  1325. {
  1326. PTCHAR szLoc;
  1327. PTCHAR szLoc2;
  1328. PTCHAR szBuf = NULL;
  1329. TCHAR szFin[MAX_PATH];
  1330. //
  1331. // Find the address for "buildnumber" within $winnt$.inf
  1332. //
  1333. szLoc = strstr(szString, "BuildNumber");
  1334. szBuf = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwFileSize);
  1335. if (szLoc && szBuf)
  1336. {
  1337. //
  1338. // Find the address within that for the first double-quote
  1339. //
  1340. szLoc2 = strstr(szLoc, "\"");
  1341. if (szLoc2)
  1342. {
  1343. //
  1344. // Copy the rest of the string to the buffer
  1345. //
  1346. lstrcpy(szBuf, szLoc2);
  1347. //
  1348. // Just for fun...
  1349. //
  1350. szBuf[0] = '#';
  1351. //
  1352. // Find the last "
  1353. //
  1354. for ( DWORD i = 0; szBuf[i] != '\"'; i++);
  1355. //
  1356. // Terminate the string
  1357. //
  1358. szBuf[i] = '\0';
  1359. //
  1360. // Now, character by character, copy the string to the new buffer - this avoids the # at the beginning
  1361. // of the string
  1362. //
  1363. for (i = 0; i < strlen(szBuf); i++)
  1364. szFin[i] = szBuf[i + 1];
  1365. //
  1366. // Strip any commas and write to the logfile
  1367. //
  1368. LogProc->StripCommas(szFin);
  1369. LogProc->LogString(",%s,\r\n", szFin);
  1370. }
  1371. else
  1372. LogProc->LogString(",Unknown,\r\n");
  1373. }
  1374. else
  1375. LogProc->LogString(",Unknown,\r\n");
  1376. if(szBuf)
  1377. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, szBuf);
  1378. }
  1379. else
  1380. LogProc->LogString(",Unknown,\r\n");
  1381. CloseHandle(hFile);
  1382. }
  1383. if(szString)
  1384. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, szString);
  1385. osv = (LPOSVERSIONINFO)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(OSVERSIONINFO));
  1386. if(!osv)
  1387. {
  1388. LogProc->LogString(",#OS_Major_Version,,\r\n,Unknown,\r\n" ",#OS_Minor_Version,,\r\n,Unknown,\r\n" ",#OS_Build_Number,,\r\n,Unknown,\r\n" ",#OS_Platform_ID,,\r\n,Unknown,\r\n" ",#OS_Extra_Info,,\r\n,Unknown,\r\n");
  1389. }
  1390. else
  1391. {
  1392. osv->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  1393. GetVersionEx(osv);
  1394. LogProc->StripCommas(osv->szCSDVersion);
  1395. LogProc->LogString(",#OS_Major_Version,,\r\n,%d,\r\n" ",#OS_Minor_Version,,\r\n,%d,\r\n" ",#OS_Build_Number,,\r\n,%d,\r\n" ",#OS_Platform_ID,,\r\n,%d,\r\n" ",#OS_Extra_Info,,\r\n,%s,\r\n", osv->dwMajorVersion, osv->dwMinorVersion, LOWORD(osv->dwBuildNumber), osv->dwPlatformId, osv->szCSDVersion);
  1396. HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, osv);
  1397. }
  1398. }
  1399. void CLASS_GeneralInfo::CatLogFile(PTCHAR szFile)
  1400. {
  1401. FILE *fFile = NULL;
  1402. FILE *fOutFile = NULL;
  1403. PTCHAR szString = NULL;
  1404. if( !(fFile = fopen(szFile, "r")))
  1405. return;
  1406. if( !(fOutFile = fopen(LogProc->szFile, "a+")))
  1407. {
  1408. fclose(fFile);
  1409. return;
  1410. }
  1411. if( !(szString = (PTCHAR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 11000)))
  1412. {
  1413. fclose(fFile);
  1414. fclose(fOutFile);
  1415. return;
  1416. }
  1417. int iHold;
  1418. iHold = fgetc(fFile);
  1419. while (EOF != iHold)
  1420. {
  1421. fputc(iHold, fOutFile);
  1422. iHold = fgetc(fFile);
  1423. }
  1424. fclose(fFile);
  1425. fclose(fOutFile);
  1426. HeapFree(GetProcessHeap(), 0, szString);
  1427. }
  1428. BOOL CLASS_GeneralInfo::LoadResourceFile(PSTR FilePath, PSTR ResName)
  1429. {
  1430. HGLOBAL hObj;
  1431. HRSRC hResource;
  1432. LPSTR lpStr;
  1433. DWORD dwSize = 0;
  1434. DWORD dwBytesWritten = 0;
  1435. char ErrorString[MAX_PATH * 4];
  1436. HANDLE hfFile = INVALID_HANDLE_VALUE;
  1437. if ( !(hResource = FindResource(NULL, ResName, RT_RCDATA)) )
  1438. return FALSE;
  1439. if ( !(hObj = LoadResource(NULL,hResource)) )
  1440. return FALSE;
  1441. if ( !(lpStr = (LPSTR)LockResource(hObj)) )
  1442. return FALSE;
  1443. if ( !(dwSize = SizeofResource( NULL, hResource)))
  1444. {
  1445. UnlockResource(hObj);
  1446. return FALSE;
  1447. }
  1448. hfFile = CreateFile(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  1449. if (hfFile == INVALID_HANDLE_VALUE)
  1450. {
  1451. UnlockResource(hObj);
  1452. return FALSE;
  1453. }
  1454. if (!WriteFile(hfFile, lpStr, dwSize, &dwBytesWritten, NULL))
  1455. {
  1456. UnlockResource(hObj);
  1457. CloseHandle(hfFile);
  1458. return FALSE;
  1459. }
  1460. UnlockResource(hObj);
  1461. CloseHandle(hfFile);
  1462. return TRUE;
  1463. }
  1464. PTCHAR GetUniqueFileName( void )
  1465. {
  1466. MYTIMESTRUCT MyTime;
  1467. DWORD dwLen = MAX_PATH;
  1468. static TCHAR szUniqueFileName[MAX_PATH] = {'\0'};
  1469. if(!GetComputerName(szUniqueFileName, &dwLen))
  1470. lstrcpy(szUniqueFileName, "ErrorRetrievingComputerName");
  1471. lstrcat(szUniqueFileName+lstrlen(szUniqueFileName), "_");
  1472. if(!GetUserName(szUniqueFileName+lstrlen(szUniqueFileName), &dwLen))
  1473. lstrcat(szUniqueFileName, "ErrorRetrievingUsername");
  1474. FillMyTime(&MyTime);
  1475. wsprintf(szUniqueFileName+lstrlen(szUniqueFileName), "_%s%s%s%s%s%s%s.Sysparse", MyTime.szMonth, MyTime.szDay, MyTime.szYear, MyTime.szHour, MyTime.szMinute, MyTime.szSecond, MyTime.szMillisecond);
  1476. return(szUniqueFileName);
  1477. }
  1478. void FillMyTime(MYTIMESTRUCT *MyTime)
  1479. {
  1480. LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)malloc(sizeof(LPSYSTEMTIME));
  1481. TCHAR szTemp[MAX_PATH] = {0};
  1482. GetSystemTime(lpSystemTime);
  1483. if(!lpSystemTime)
  1484. return;
  1485. if(lpSystemTime->wMonth <= 9)
  1486. {
  1487. lstrcpy(MyTime->szMonth, "0");
  1488. wsprintf(szTemp, "%d", lpSystemTime->wMonth);
  1489. lstrcat(MyTime->szMonth, szTemp);
  1490. }
  1491. else
  1492. {
  1493. wsprintf(szTemp, "%d", lpSystemTime->wMonth);
  1494. lstrcpy(MyTime->szMonth, szTemp);
  1495. }
  1496. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1497. if(lpSystemTime->wDay <= 9)
  1498. {
  1499. lstrcpy(MyTime->szDay, "0");
  1500. wsprintf(szTemp, "%d", lpSystemTime->wDay);
  1501. lstrcat(MyTime->szDay, szTemp);
  1502. }
  1503. else
  1504. {
  1505. wsprintf(szTemp, "%d", lpSystemTime->wDay);
  1506. lstrcpy(MyTime->szDay, szTemp);
  1507. }
  1508. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1509. if(lpSystemTime->wYear <= 9)
  1510. {
  1511. lstrcpy(MyTime->szYear, "0");
  1512. wsprintf(szTemp, "%d", lpSystemTime->wYear);
  1513. lstrcat(MyTime->szYear, szTemp);
  1514. }
  1515. else
  1516. {
  1517. wsprintf(szTemp, "%d", lpSystemTime->wYear);
  1518. lstrcpy(MyTime->szYear, szTemp);
  1519. }
  1520. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1521. if(lpSystemTime->wHour <= 9)
  1522. {
  1523. lstrcpy(MyTime->szHour, "0");
  1524. wsprintf(szTemp, "%d", lpSystemTime->wHour);
  1525. lstrcat(MyTime->szHour, szTemp);
  1526. }
  1527. else
  1528. {
  1529. wsprintf(szTemp, "%d", lpSystemTime->wHour);
  1530. lstrcpy(MyTime->szHour, szTemp);
  1531. }
  1532. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1533. if(lpSystemTime->wMinute <= 9)
  1534. {
  1535. lstrcpy(MyTime->szMinute, "0");
  1536. wsprintf(szTemp, "%d", lpSystemTime->wMinute);
  1537. lstrcat(MyTime->szMinute, szTemp);
  1538. }
  1539. else
  1540. {
  1541. wsprintf(szTemp, "%d", lpSystemTime->wMinute);
  1542. lstrcpy(MyTime->szMinute, szTemp);
  1543. }
  1544. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1545. if(lpSystemTime->wSecond <= 9)
  1546. {
  1547. lstrcpy(MyTime->szSecond, "0");
  1548. wsprintf(szTemp, "%d", lpSystemTime->wSecond);
  1549. lstrcat(MyTime->szSecond, szTemp);
  1550. }
  1551. else
  1552. {
  1553. wsprintf(szTemp, "%d", lpSystemTime->wSecond);
  1554. lstrcpy(MyTime->szSecond, szTemp);
  1555. }
  1556. ZeroMemory(szTemp, MAX_PATH * sizeof(TCHAR));
  1557. if(lpSystemTime->wMilliseconds <= 9)
  1558. {
  1559. lstrcpy(MyTime->szMillisecond, "0");
  1560. wsprintf(szTemp, "%d", lpSystemTime->wMilliseconds);
  1561. lstrcat(MyTime->szMillisecond, szTemp);
  1562. }
  1563. else
  1564. {
  1565. wsprintf(szTemp, "%d", lpSystemTime->wMilliseconds);
  1566. lstrcpy(MyTime->szMillisecond, szTemp);
  1567. }
  1568. if(lpSystemTime)
  1569. free(lpSystemTime);
  1570. }