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.

3016 lines
91 KiB

  1. //
  2. // 06.05.95 Joe Holman Created to copy the system files for
  3. // the new shell and cairo releases.
  4. // Currently, it only copies uncompressed system files.
  5. // 06.16.95 Joe Holman Allow debugging tools to be copied. Uses _media.inx
  6. // 06.19.95 Joe Holman Copy compressed version of file if specified in _layout.inx.
  7. // 06.22.95 Joe Holman Added bCairoSuckNameHack to pick up files from
  8. // the inf\cairo\_layout.cai file.
  9. // 06.22.95 Joe Holman Added the SRV_INF fix so that we will pick up the compressed
  10. // Server Infs in a different location than the Workstation compressed
  11. // 06.22.95 Joe Holman For now, we won't use compressed Cairo files. Will change in July.
  12. // INFs (due to the collision of names and difference with cdrom.w|s).
  13. // 06.28.95 Joe Holman Won't make CHECKED Server.
  14. // 07.07.95 Joe Holman For Cairo, we need to also look at the _layout.cai and
  15. // _media.cai files
  16. // for additional files (superset) that goes into Cairo.
  17. // 08.03.95 Joe Holman Allow Cairo to have compressed files -> note, build team needs to
  18. // private 2 locations, one for Shell release and one for Cairo release,
  19. // ie, \\x86fre\cdcomp$.
  20. // 08.14.95 Joe Holman Figure out if we copy the .dbg file for a particular file.
  21. // 08.14.95 Joe Holman Allow DBG files for Cairo.
  22. // 08.23.95 Joe Holman Add code to make tallying work with compressed/noncomp files and
  23. // winn32 local source space needed.
  24. // 10.13.95 Joe Holman Get MAPISVC.INF and MDM*.INF from Workstation location.
  25. // 10.25.95 Joe Holman Put code in to use SetupDecompressOrCopyFile.
  26. // 10.30.95 Joe Holman Don't give errors for vmmreg32.dbg - this is a file given
  27. // by Win95 guys.
  28. // 11.02.95 Joe Holman Allow multi-threaded support when SetupDecompressOrCopyFile
  29. // is fixed.
  30. // Pickup all for PPC on Cairo.
  31. // 11.17.95 Joe Holman Check for upgrade size.
  32. // 11.30.95 Joe Holman compare current dosnet.inf and txtsetup.sif values and error
  33. // if we go over. Search for //code here.
  34. // 12.04.95 Joe Holman Use Layout.inx instead of _layout.inx.
  35. // 03.11.96 Joe Holman Don't give errors on MFC*.dbg if missing, since no .dbgs
  36. // provided.
  37. // 04.05.96 Joe Holman Add values for INETSRV and DRVLIB.NIC directories. Both of
  38. // these get copied as local source. Inetsrv is NEVER installed
  39. // automatically (unless via an unattend file) and one card is
  40. // small. Thus, we will only add INETSRV and DRVLIB.NIC sizes
  41. // to local source code below.
  42. // and one or two of drvlib.nic MAY get installed.
  43. // 04.19.96 Joe Holman Add code to NOT count *.ppd files in order to reduce
  44. // minimum disk space required.
  45. // 09.10.96 Joe Holman Add code that supports setup's new disk space calculation.
  46. // Basically, we just need to provide values for each cluster
  47. // size stored in dosnet.inf.
  48. // 10.17.96 Joe Holman Comment out MIPS code, but leave in for P7.
  49. // 12.06.96 Joe Holman Backported MSKK's DBCS changes.
  50. // 01.20.97 Joe Holman Take out PPC.
  51. // 05.15.97 Joe Holman Grovels layout.inf on release shares rather than file chked-in.
  52. // xx.xx.xx Joe Holman Allow files not to worry about .dbgs for to be in a file.
  53. // xx.xx.xx Joe Holman Add code to check for 0 file size in layout.inf files.
  54. // xx.xx.xx Joe Holman Provide switch that flush bits to disk after copy, then does a DIFF.
  55. //
  56. #include <windows.h>
  57. #include <setupapi.h>
  58. #include <stdio.h>
  59. #include <time.h>
  60. #include <stdlib.h>
  61. #include <ctype.h>
  62. #define MFL 256
  63. CRITICAL_SECTION CriticalSection;
  64. #define MAX_NUMBER_OF_FILES_IN_PRODUCT 3500 // # greater than # of files in product.
  65. #define EIGHT_DOT_THREE 8+1+3+1
  66. struct _tag {
  67. WORD wNumFiles;
  68. BOOL bCopyDbg [MAX_NUMBER_OF_FILES_IN_PRODUCT];
  69. BOOL bCopyComp [MAX_NUMBER_OF_FILES_IN_PRODUCT];
  70. char wcFilesArray[MAX_NUMBER_OF_FILES_IN_PRODUCT][EIGHT_DOT_THREE];
  71. char wcSubPath [MAX_NUMBER_OF_FILES_IN_PRODUCT][EIGHT_DOT_THREE]; // used for debugging files
  72. BOOL bCountBytes [MAX_NUMBER_OF_FILES_IN_PRODUCT];
  73. };
  74. BOOL bFourPtO = FALSE;
  75. BOOL bChecked = FALSE;
  76. BOOL bVerifyBits = FALSE;
  77. BOOL bGetSizeLater = TRUE;
  78. struct _tag i386Workstation;
  79. struct _tag AlphaWorkstation;
  80. struct _tag i386Server;
  81. struct _tag AlphaServer;
  82. struct _tag X86Dbg;
  83. struct _tag AlphaDbg;
  84. BOOL fX86Wrk, fX86Srv;
  85. BOOL fAlphaWrk, fAlphaSrv;
  86. #define WORKSTATION 0
  87. #define SERVER 1
  88. //
  89. // Following are masks that correspond to the particular data in a DOS date
  90. //
  91. #define DOS_DATE_MASK_DAY (WORD) 0x001f // low 5 bits (1-31)
  92. #define DOS_DATE_MASK_MONTH (WORD) 0x01e0 // mid 4 bits (1-12)
  93. #define DOS_DATE_MASK_YEAR (WORD) 0xfe00 // high 7 bits (0-119)
  94. //
  95. // Following are masks that correspond to the particular data in a DOS time
  96. //
  97. #define DOS_TIME_MASK_SECONDS (WORD) 0x001f // low 5 bits (0-29)
  98. #define DOS_TIME_MASK_MINUTES (WORD) 0x07e0 // mid 6 bits (0-59)
  99. #define DOS_TIME_MASK_HOURS (WORD) 0xf800 // high 5 bits (0-23)
  100. //
  101. // Shift constants used for building/getting DOS dates and times
  102. //
  103. #define DOS_DATE_SHIFT_DAY 0
  104. #define DOS_DATE_SHIFT_MONTH 5
  105. #define DOS_DATE_SHIFT_YEAR 9
  106. #define DOS_TIME_SHIFT_SECONDS 0
  107. #define DOS_TIME_SHIFT_MINUTES 5
  108. #define DOS_TIME_SHIFT_HOURS 11
  109. //
  110. // Macros to extract the data out of DOS dates and times.
  111. //
  112. // Note: Dos years are offsets from 1980. Dos seconds have 2 second
  113. // granularity
  114. //
  115. #define GET_DOS_DATE_YEAR(wDate) ( ( (wDate & DOS_DATE_MASK_YEAR) >> \
  116. DOS_DATE_SHIFT_YEAR ) + \
  117. (WORD) 1980 )
  118. #define GET_DOS_DATE_MONTH(wDate) ( (wDate & DOS_DATE_MASK_MONTH) >> \
  119. DOS_DATE_SHIFT_MONTH )
  120. #define GET_DOS_DATE_DAY(wDate) ( wDate & DOS_DATE_MASK_DAY )
  121. #define GET_DOS_TIME_HOURS(wTime) ( (wTime & DOS_TIME_MASK_HOURS) >> \
  122. DOS_TIME_SHIFT_HOURS )
  123. #define GET_DOS_TIME_MINUTES(wTime) ( (wTime & DOS_TIME_MASK_MINUTES) >> \
  124. DOS_TIME_SHIFT_MINUTES )
  125. #define GET_DOS_TIME_SECONDS(wTime) ( (wTime & DOS_TIME_MASK_SECONDS) << 1 )
  126. // Paths loaded in from the command line.
  127. //
  128. char szLogFile[MFL];
  129. char szWrkX86Src[MFL];
  130. char szWrkAlphaSrc[MFL];
  131. char szSrvX86Src[MFL];
  132. char szSrvAlphaSrc[MFL];
  133. char szCompX86Src[MFL];
  134. char szCompAlphaSrc[MFL];
  135. char szEnlistDrv[MFL];
  136. char szWorkDstDrv[MFL];
  137. char szServDstDrv[MFL];
  138. char szX86Dbg[MFL];
  139. char szAlphaDbg[MFL];
  140. char szX86DbgSource[MFL];
  141. char szAlphaDbgSource[MFL];
  142. #define I386_DIR "\\i386\\SYSTEM32"
  143. #define ALPHA_DIR "\\ALPHA\\SYSTEM32"
  144. #define I386_DBG "\\support\\debug\\i386\\symbols"
  145. #define ALPHA_DBG "\\support\\debug\\alpha\\symbols"
  146. #define NETMON "\\netmon"
  147. #define I386_DIR_RAW "\\i386"
  148. #define ALPHA_DIR_RAW "\\ALPHA"
  149. #define I386_SRV_WINNT "\\clients\\srvtools\\winnt\\i386"
  150. #define ALPHA_SRV_WINNT "\\clients\\srvtools\\winnt\\alpha"
  151. #define NUM_EXTS 8
  152. char * cExtra[] = { "acm", "com", "cpl", "dll", "drv", "exe", "scr", "sys" };
  153. #define idBase 0
  154. #define idX86 1
  155. #define idALPHA 3
  156. #define idBaseDbg 5
  157. #define idX86Dbg 6
  158. // Tally up the # of bytes required for the system from the files included.
  159. //
  160. struct _ClusterSizes {
  161. DWORD Kh1;
  162. DWORD K1;
  163. DWORD K2;
  164. DWORD K4;
  165. DWORD K8;
  166. DWORD K16;
  167. DWORD K32;
  168. DWORD K64;
  169. DWORD K128;
  170. DWORD K256;
  171. };
  172. struct _ClusterSizes lX86Work;
  173. struct _ClusterSizes lX86Serv;
  174. struct _ClusterSizes lAlphaWork;
  175. struct _ClusterSizes lAlphaServ;
  176. DWORD bytesX86Work, bytesX86Serv;
  177. DWORD bytesAlphaWork, bytesAlphaServ;
  178. //
  179. // Macro for rounding up any number (x) to multiple of (n) which
  180. // must be a power of 2. For example, ROUNDUP( 2047, 512 ) would
  181. // yield result of 2048.
  182. //
  183. #define ROUNDUP2( x, n ) (((x) + ((n) - 1 )) & ~((n) - 1 ))
  184. #define LAYOUT_INX "\\nt\\private\\windows\\setup\\inf\\win4\\inf\\layout.inx"
  185. #define MEDIA_INX "\\nt\\private\\windows\\setup\\inf\\win4\\inf\\_media.inx"
  186. FILE* logFile;
  187. void GiveThreadId ( const CHAR * szFormat, ... ) {
  188. va_list vaArgs;
  189. va_start ( vaArgs, szFormat );
  190. vprintf ( szFormat, vaArgs );
  191. vfprintf ( logFile, szFormat, vaArgs );
  192. va_end ( vaArgs );
  193. }
  194. void Msg ( const CHAR * szFormat, ... ) {
  195. va_list vaArgs;
  196. EnterCriticalSection ( &CriticalSection );
  197. GiveThreadId ( "%ld: ", GetCurrentThreadId () );
  198. va_start ( vaArgs, szFormat );
  199. vprintf ( szFormat, vaArgs );
  200. vfprintf ( logFile, szFormat, vaArgs );
  201. va_end ( vaArgs );
  202. LeaveCriticalSection ( &CriticalSection );
  203. }
  204. void Header(argv,argc)
  205. char * argv[];
  206. int argc;
  207. {
  208. time_t t;
  209. char tmpTime[100];
  210. CHAR wtmpTime[200];
  211. Msg ( "\n=========== FILES ====================\n" );
  212. Msg ( "Log file : %s\n", szLogFile );
  213. Msg ( "x86 work Uncompressed files : %s\n", szWrkX86Src);
  214. Msg ( "alpha work Uncompressed files : %s\n", szWrkAlphaSrc);
  215. Msg ( "x86 Serv Uncompressed files : %s\n", szSrvX86Src);
  216. Msg ( "alpha Serv Uncompressed files : %s\n", szSrvAlphaSrc);
  217. Msg ( "x86 Compressed files : %s\n", szCompX86Src);
  218. Msg ( "alpha Compressed files : %s\n", szCompAlphaSrc);
  219. Msg ( "x86 dbg files : %s\n", szX86Dbg);
  220. Msg ( "alpha dbg files : %s\n", szAlphaDbg);
  221. Msg ( "x86 dbg source : %s\n", szX86DbgSource);
  222. Msg ( "alpha dbg source : %s\n", szAlphaDbgSource);
  223. Msg ( "enlisted drive : %s\n", szEnlistDrv );
  224. Msg ( "drive to put workstation files: %s\n", szWorkDstDrv );
  225. Msg ( "drive to put server files : %s\n", szServDstDrv );
  226. time(&t);
  227. Msg ( "Time: %s", ctime(&t) );
  228. Msg ( "========================================\n\n");
  229. }
  230. void Usage()
  231. {
  232. printf( "PURPOSE: Copies the system files that compose the product.\n");
  233. printf( "\n");
  234. printf( "PARAMETERS:\n");
  235. printf( "\n");
  236. printf( "[LogFile] - Path to append a log of actions and errors.\n");
  237. printf( "[files share] - location of work x86 uncompressed files.\n" );
  238. printf( "[files share] - location of work alpha uncompressed files.\n" );
  239. printf( "[files share] - location of serv x86 uncompressed files.\n" );
  240. printf( "[files share] - location of serv alpha uncompressed files.\n" );
  241. printf( "[files share] - location of x86 Compressed files.\n" );
  242. printf( "[files share] - location of alpha Compressed files.\n" );
  243. printf( "[files share] - location of x86 dbg files.\n" );
  244. printf( "[files share] - location of alpha dbg files.\n" );
  245. printf( "[files share] - location of x86 dbg source files.\n" );
  246. printf( "[files share] - location of alpha dbg source files.\n" );
  247. printf( "[enlisted drive]- drive that is enlisted\n" );
  248. printf( "[dest path workstation] - drive to put files\n" );
  249. printf( "[dest path server] - drive to put files\n" );
  250. printf( "\n" );
  251. }
  252. char dbgStr1[30];
  253. char dbgStr2[30];
  254. BOOL IsFileInSpecialWinnt32Directory ( char * szFileName ) {
  255. char szUpCasedName[MFL];
  256. int i;
  257. char * foo[] = {
  258. "WINNT32.EXE",
  259. "WINNT32A.DLL",
  260. "WINNT32U.DLL",
  261. "WINNT32.HLP",
  262. (char *) 0
  263. };
  264. strcpy ( szUpCasedName, szFileName );
  265. _strupr ( szUpCasedName );
  266. for ( i=0; foo[i] != 0; i++ ) {
  267. Msg ( "Comparing: %s vs. %s\n", szUpCasedName, foo[i] );
  268. if ( strstr ( szUpCasedName, foo[i] ) ) {
  269. return TRUE; // file should be in this directory
  270. }
  271. }
  272. return FALSE; // no, file doesn't go in the winnt32 directory
  273. }
  274. BOOL IsDebugFileToNotWorryAbout ( char * szFileName ) {
  275. char szUpCasedName[MFL];
  276. int i;
  277. char * foo[] = {
  278. "WEX",
  279. "CABINET.DBG",
  280. "IEDKCS32.DBG",
  281. "INETCFG.DBG",
  282. "INETWIZ.DBG",
  283. "CLASSR.DBG",
  284. "ICFGNT.DBG",
  285. "MSENCODE.DBG",
  286. "MSCONV97.DBG",
  287. "MSAWT",
  288. "JVIEW",
  289. "JDBGMGR",
  290. "JAVA",
  291. "ISIGN",
  292. "MSAPS",
  293. "ICW",
  294. "JAVA",
  295. "HLINK",
  296. "JSCRIPT.DBG",
  297. "MSAD",
  298. "MSDA",
  299. "VBSCRIPT.DBG",
  300. "VSREVOKE.DBG",
  301. "WSOCK32N.DBG",
  302. "DIGIINST.DBG",
  303. "ICCVID.DBG",
  304. "IR32_32.DBG",
  305. "VMHELPER.DBG",
  306. "MSJAVA",
  307. "VMMREG32.DBG",
  308. "SCRRUN.DBG",
  309. "MFC",
  310. "OLEPRO32.DBG",
  311. "MSJT3032.DBG",
  312. "ODBCJT32.DBG",
  313. "MSVCIRT.DBG",
  314. "MSVCRT40.dbg",
  315. "MSVCRT20.dbg",
  316. "JIT.DBG",
  317. "MSVC",
  318. (char *) 0
  319. };
  320. strcpy ( szUpCasedName, szFileName );
  321. _strupr ( szUpCasedName );
  322. for ( i=0; foo[i] != 0; i++ ) {
  323. Msg ( "IsDebug Comparing: %s vs. %s\n", szUpCasedName, foo[i] );
  324. if ( strstr ( szUpCasedName, foo[i] ) ) {
  325. return TRUE; // don't worry if this file is missing
  326. }
  327. }
  328. return FALSE; // worry about this one, we need it!
  329. }
  330. void ShowMeDosDateTime ( CHAR * srcPath, WORD wDateSrc, WORD wTimeSrc,
  331. CHAR * dstPath, WORD wDateDst, WORD wTimeDst ) {
  332. Msg ( "%s %02d.%02d.%02d %02d:%02d.%02d\n",
  333. srcPath,
  334. GET_DOS_DATE_MONTH(wDateSrc),
  335. GET_DOS_DATE_DAY(wDateSrc),
  336. GET_DOS_DATE_YEAR(wDateSrc),
  337. GET_DOS_TIME_HOURS(wTimeSrc),
  338. GET_DOS_TIME_MINUTES(wTimeSrc),
  339. GET_DOS_TIME_SECONDS(wTimeSrc) );
  340. Msg ( "%s %02d.%02d.%02d %02d:%02d.%02d\n",
  341. dstPath,
  342. GET_DOS_DATE_MONTH(wDateDst),
  343. GET_DOS_DATE_DAY(wDateDst),
  344. GET_DOS_DATE_YEAR(wDateDst),
  345. GET_DOS_TIME_HOURS(wTimeDst),
  346. GET_DOS_TIME_MINUTES(wTimeDst),
  347. GET_DOS_TIME_SECONDS(wTimeSrc) );
  348. }
  349. void Replay ( char * srcBuf, char * dstBuf, DWORD srcBytesRead, DWORD startIndex ) {
  350. DWORD i;
  351. for ( i = startIndex; (i < startIndex+5) && (i <= srcBytesRead); ++i ) {
  352. Msg ( "srcBuf[%ld] = %x, dstBuf[%ld] = %x\n", i, srcBuf[i], i, dstBuf[i] );
  353. }
  354. }
  355. BOOL IsDstCompressed ( char * szPath ) {
  356. // Msg ( ">>> char %s: %c\n", szPath, szPath[strlen(szPath)-1] );
  357. if ( szPath[strlen(szPath)-1] == '_' ) {
  358. return(TRUE);
  359. }
  360. return (FALSE);
  361. }
  362. #define V_WRK_I386 "C:\\wrk\\i386"
  363. #define V_WRK_ALPHA "C:\\wrk\\alpha"
  364. #define V_SRV_I386 "C:\\srv\\i386"
  365. #define V_SRV_ALPHA "C:\\srv\\alpha"
  366. BOOL MyCopyFile ( char * fileSrcPath, char * fileDstPath ) {
  367. HANDLE hSrc, hDst;
  368. WIN32_FIND_DATA wfdSrc, wfdDst;
  369. BOOL bDoCopy = FALSE;
  370. #define NUM_BYTES_TO_READ 2048
  371. unsigned char srcBuf[NUM_BYTES_TO_READ];
  372. unsigned char dstBuf[NUM_BYTES_TO_READ];
  373. WORD srcDate, srcTime, dstDate, dstTime;
  374. char szTmpFile[MFL] = { '\0' };
  375. UINT uiRetSize = 299;
  376. char szJustFileName[MFL];
  377. char szJustDirectoryName[MFL];
  378. // Find the source file.
  379. //
  380. hSrc = FindFirstFile ( fileSrcPath, &wfdSrc );
  381. if ( hSrc == INVALID_HANDLE_VALUE ) {
  382. // HACK: Since the release shares put WINNT32.EXE in the WINNT32 directory
  383. // instead of leaving it in the flat root, verify that if the fileSrcPath
  384. // contains WINNT32.EXE we look in the WINNT32 dir also before error'ing out.
  385. //
  386. if ( IsFileInSpecialWinnt32Directory ( fileSrcPath ) ) {
  387. char tmpSrcPath[MFL];
  388. strcpy ( tmpSrcPath, fileSrcPath );
  389. if ( strstr ( fileSrcPath, ".HLP" ) ||
  390. strstr ( fileSrcPath, ".hlp" ) ) {
  391. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.HLP" );
  392. }
  393. else if ( strstr ( fileSrcPath, "a.dll" ) ||
  394. strstr ( fileSrcPath, "A.DLL" ) ) {
  395. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32a.dll" );
  396. }
  397. else if ( strstr ( fileSrcPath, "u.dll" ) ||
  398. strstr ( fileSrcPath, "U.DLL" ) ) {
  399. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32u.dll" );
  400. }
  401. else {
  402. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.EXE" );
  403. }
  404. hSrc = FindFirstFile ( tmpSrcPath, &wfdSrc );
  405. if ( hSrc == INVALID_HANDLE_VALUE ) {
  406. Msg ( "ERROR on fileSrcPath(tmpSrcPath) = %s, gle = %ld\n", tmpSrcPath, GetLastError() );
  407. return (FALSE);
  408. }
  409. else {
  410. strcpy ( fileSrcPath, tmpSrcPath );
  411. }
  412. }
  413. else if ( IsDebugFileToNotWorryAbout ( fileSrcPath ) ) {
  414. // The following files do NOT have dbg files
  415. // available for them because they are provided by 3rd parties or other group.
  416. // So, don't report an error when we can't find them.
  417. //
  418. Msg ( "Warning: %s not copied over.\n", fileSrcPath );
  419. return (FALSE);
  420. }
  421. else {
  422. Msg ( "ERROR on fileSrcPath = %s, gle = %ld\n", fileSrcPath, GetLastError() );
  423. return (FALSE);
  424. }
  425. }
  426. // Find the destination file.
  427. //
  428. hDst = FindFirstFile ( fileDstPath, &wfdDst );
  429. if ( hDst == INVALID_HANDLE_VALUE ) {
  430. DWORD gle;
  431. gle = GetLastError();
  432. if ( gle == ERROR_FILE_NOT_FOUND ) {
  433. // The file doesn't exist on the destination. Do the copy.
  434. //
  435. bDoCopy = TRUE;
  436. }
  437. else {
  438. // Got another kind of error, report this problem.
  439. //
  440. Msg ( "ERROR FindFirstFile fileDstPath = %s, gle = %ld\n", fileDstPath, gle );
  441. FindClose ( hSrc );
  442. return ( FALSE );
  443. }
  444. }
  445. else {
  446. BOOL b;
  447. // Both the src and dst exist.
  448. // Let's see if the src is NEWER than the dst, if so, copy.
  449. //
  450. //
  451. b = FileTimeToDosDateTime ( &wfdSrc.ftLastWriteTime, &srcDate, &srcTime );
  452. b = FileTimeToDosDateTime ( &wfdDst.ftLastWriteTime, &dstDate, &dstTime );
  453. if ( (srcDate != dstDate) || (srcTime != dstTime) ) {
  454. ShowMeDosDateTime ( fileSrcPath, srcDate, srcTime, fileDstPath, dstDate, dstTime );
  455. bDoCopy = TRUE;
  456. }
  457. }
  458. // Additional check, verify the file sizes are the same.
  459. //
  460. if ( wfdSrc.nFileSizeLow != wfdSrc.nFileSizeLow ) {
  461. bDoCopy = TRUE;
  462. }
  463. if ( wfdSrc.nFileSizeHigh != wfdDst.nFileSizeHigh ) {
  464. bDoCopy = TRUE;
  465. }
  466. if ( bDoCopy ) {
  467. BOOL b;
  468. DWORD gle;
  469. DWORD dwAttributes = GetFileAttributes ( fileDstPath );
  470. // Check the attributes of the file.
  471. //
  472. if ( dwAttributes == 0xFFFFFFFF ) {
  473. // Ignore file not found on non-existant destination, but error on
  474. // anything else.
  475. //
  476. gle = GetLastError();
  477. if ( gle != ERROR_FILE_NOT_FOUND ) {
  478. Msg ( "ERROR: GetFileAttributes: gle = %ld, %s\n", gle, fileDstPath);
  479. }
  480. }
  481. else {
  482. // No error for GetFileAttributes.
  483. // Check the attribute for R-only, and change if set.
  484. //
  485. if ( dwAttributes & FILE_ATTRIBUTE_READONLY ||
  486. dwAttributes & FILE_ATTRIBUTE_HIDDEN ) {
  487. b = SetFileAttributes ( fileDstPath, FILE_ATTRIBUTE_NORMAL );
  488. if ( !b ) {
  489. Msg ( "ERROR: SetFileAttributes: gle = %ld, %s\n", GetLastError(), fileDstPath);
  490. }
  491. }
  492. }
  493. b = CopyFile ( fileSrcPath, fileDstPath, FALSE );
  494. if ( b ) {
  495. Msg ( "Copy: %s >>> %s [OK]\n", fileSrcPath, fileDstPath );
  496. }
  497. else {
  498. Msg ( "ERROR Copy: %s >>> %s, gle = %ld\n", fileSrcPath, fileDstPath, GetLastError() );
  499. }
  500. }
  501. else {
  502. Msg ( "%s %d %d %ld %ld +++ %s %d %d %ld %ld [SAME]\n", fileSrcPath, srcDate, srcTime, wfdSrc.nFileSizeLow, wfdSrc.nFileSizeHigh, fileDstPath , dstDate, dstTime, wfdDst.nFileSizeLow, wfdDst.nFileSizeHigh );
  503. }
  504. FindClose ( hSrc );
  505. FindClose ( hDst );
  506. // Do bit verification here on all files coming into MyCopyFile.
  507. //
  508. if ( bVerifyBits ) {
  509. BOOL bNoError = TRUE;
  510. HANDLE SrcFileHandle, DstFileHandle;
  511. BOOL b;
  512. BY_HANDLE_FILE_INFORMATION srcFileInformation;
  513. BY_HANDLE_FILE_INFORMATION dstFileInformation;
  514. DWORD srcBytesRead;
  515. DWORD dstBytesRead;
  516. DWORD i;
  517. DWORD totalBytesRead = 0;
  518. #define OFFSET_FILENAME 0x3C // address of file name in diamond header.
  519. // >>> use struct later instead of this hack.
  520. #define OFFSET_PAST_FILENAME 8 + 1 + 3 + 2 // we only use 8.3 filenames.
  521. char unCompressedFileName[OFFSET_PAST_FILENAME];
  522. BOOL bIsDstCompressed = FALSE;
  523. DWORD dw;
  524. char szExpandToDir[MFL];
  525. char target[MFL];
  526. int iRc;
  527. unsigned short unicodeFileLocation[MFL];
  528. unsigned short unicodeTargetLocation[MFL];
  529. bIsDstCompressed = IsDstCompressed ( fileDstPath );
  530. if ( bIsDstCompressed ) {
  531. FILE * fHandle;
  532. char szEndingFileName[MFL];
  533. // Figure out where source should be from.
  534. // Ie., we need to figure out the uncompressed path from the compressed path.
  535. //
  536. if ( fileDstPath[0] == szWorkDstDrv[0] ) {
  537. // We are working with Workstation binaries.
  538. //
  539. if ( strstr ( fileSrcPath, szCompX86Src ) ) {
  540. strcpy ( fileSrcPath, szWrkX86Src );
  541. strcpy ( szExpandToDir, V_WRK_I386 );
  542. }
  543. else if ( strstr ( fileSrcPath, szCompAlphaSrc ) ) {
  544. strcpy ( fileSrcPath, szWrkAlphaSrc );
  545. strcpy ( szExpandToDir, V_WRK_ALPHA );
  546. }
  547. else {
  548. Msg ( "ERROR: couldn't determined location for: %s\n", fileSrcPath );
  549. bNoError = FALSE;
  550. }
  551. }
  552. else if ( fileDstPath[0] == szServDstDrv[0] ) {
  553. // We are working with Workstation binaries.
  554. //
  555. if ( strstr ( fileSrcPath, szCompX86Src ) ) {
  556. strcpy ( fileSrcPath, szSrvX86Src );
  557. strcpy ( szExpandToDir, V_SRV_I386 );
  558. }
  559. else if ( strstr ( fileSrcPath, szCompAlphaSrc ) ) {
  560. strcpy ( fileSrcPath, szSrvAlphaSrc );
  561. strcpy ( szExpandToDir, V_SRV_ALPHA );
  562. }
  563. else {
  564. Msg ( "ERROR: couldn't determined Server location for: %s\n", fileSrcPath );
  565. bNoError = FALSE;
  566. goto cleanup0;
  567. }
  568. }
  569. else {
  570. Msg ( "ERROR: couldn't determined wks/srv drive for: %s\n", fileDstPath );
  571. bNoError = FALSE;
  572. goto cleanup0;
  573. }
  574. // NOTE: At this point, fileSrcPath ONLY has a path, it now has NO filename !
  575. //
  576. // Find the expanded file name from the compressed file.
  577. //
  578. fHandle = fopen ( fileDstPath, "rb" );
  579. if ( fHandle == NULL) {
  580. Msg ( "ERROR Couldn't open file with fopen to find expanded name: %s\n", fileDstPath );
  581. bNoError = FALSE;
  582. goto cleanup0;
  583. }
  584. else {
  585. size_t bytesRead;
  586. int location;
  587. location = fseek ( fHandle, OFFSET_FILENAME, SEEK_SET );
  588. if ( location != 0 ) {
  589. Msg ( "fseek ERROR\n" );
  590. bNoError = FALSE;
  591. fclose ( fHandle );
  592. goto cleanup0;
  593. }
  594. bytesRead = fread ( unCompressedFileName, 1, OFFSET_PAST_FILENAME, fHandle );
  595. /***
  596. for ( i = 0; i < bytesRead; ++i ) {
  597. printf ( "%X(%c) ", buffer[i], buffer[i] );
  598. }
  599. printf ( "\n" );
  600. ***/
  601. if ( bytesRead != OFFSET_PAST_FILENAME ) {
  602. Msg ( "ERROR: bytesRead = %x not %x\n", bytesRead, OFFSET_PAST_FILENAME );
  603. bNoError = FALSE;
  604. fclose ( fHandle );
  605. goto cleanup0;
  606. }
  607. fclose ( fHandle );
  608. }
  609. // Expand the file.
  610. //
  611. sprintf ( target, "%s\\%s", szExpandToDir, unCompressedFileName );
  612. iRc = MultiByteToWideChar ( CP_ACP,
  613. MB_PRECOMPOSED,
  614. fileDstPath,
  615. strlen ( fileDstPath )+1,
  616. unicodeFileLocation,
  617. MFL/2 );
  618. if ( !iRc ) {
  619. Msg ( "MultiByteToWideChar: ERROR, gle = %ld, %s\n", GetLastError(), fileDstPath );
  620. }
  621. iRc = MultiByteToWideChar ( CP_ACP,
  622. MB_PRECOMPOSED,
  623. target,
  624. strlen ( target )+1,
  625. unicodeTargetLocation,
  626. MFL/2 );
  627. if ( !iRc ) {
  628. Msg ( "MultiByteToWideChar: ERROR, gle = %ld, %s\n", GetLastError(), target );
  629. }
  630. dw = SetupDecompressOrCopyFileW (
  631. unicodeFileLocation,
  632. unicodeTargetLocation,
  633. NULL );
  634. if ( dw ) {
  635. Msg ( "ERROR SetupDecompressOrCopyFile, dw = %d, fileDstPath=%s, target=%s\n",
  636. dw, fileDstPath, target );
  637. bNoError = FALSE;
  638. goto cleanup0;
  639. }
  640. else {
  641. Msg ( "SetupDecompressOrCopyFile: %s >> %s [OK]\n", fileDstPath, target );
  642. }
  643. // Put the Source and Destination paths and filenames back together
  644. // now so we can do the file compare.
  645. //
  646. strcat ( fileSrcPath, "\\" );
  647. strcat ( fileSrcPath, unCompressedFileName );
  648. sprintf ( fileDstPath, "%s\\%s", szExpandToDir, unCompressedFileName );
  649. }
  650. SrcFileHandle = CreateFile ( fileSrcPath,
  651. GENERIC_READ /*| FILE_EXECUTE*/,
  652. FILE_SHARE_READ /*| FILE_SHARE_DELETE*/,
  653. NULL,
  654. OPEN_EXISTING,
  655. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING,
  656. NULL);
  657. if ( SrcFileHandle == INVALID_HANDLE_VALUE) {
  658. Msg ( "ERROR verify: Couldn't open source: %s, gle = %ld\n", fileSrcPath, GetLastError() );
  659. bNoError = FALSE;
  660. goto cleanup0;
  661. }
  662. DstFileHandle = CreateFile ( fileDstPath,
  663. GENERIC_READ /*| FILE_EXECUTE*/,
  664. FILE_SHARE_READ /*| FILE_SHARE_DELETE*/,
  665. NULL,
  666. OPEN_EXISTING,
  667. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING,
  668. NULL);
  669. if ( DstFileHandle == INVALID_HANDLE_VALUE) {
  670. Msg ( "ERROR verify: Couldn't open destination: %s, gle = %ld\n", fileDstPath, GetLastError() );
  671. bNoError = FALSE;
  672. CloseHandle ( SrcFileHandle );
  673. goto cleanup0;
  674. }
  675. //GetDiskFreeSpace(); // get sector size. // need to use this sector size in reads due to above NO_BUFFERING flag.
  676. b = GetFileInformationByHandle ( SrcFileHandle, &srcFileInformation );
  677. if ( !b ) {
  678. Msg ( "ERROR: GetFileInformationByHandle on src, gle = %ld\n", GetLastError() );
  679. bNoError = FALSE;
  680. srcFileInformation.nFileSizeLow = 0;
  681. goto cleanup1;
  682. }
  683. b = GetFileInformationByHandle ( DstFileHandle, &dstFileInformation );
  684. if ( !b ) {
  685. Msg ( "ERROR: GetFileInformationByHandle on dst, gle = %ld\n", GetLastError() );
  686. bNoError = FALSE;
  687. dstFileInformation.nFileSizeLow = 0;
  688. goto cleanup1;
  689. }
  690. // Make sure the files are the same size.
  691. //
  692. if ( srcFileInformation.nFileSizeLow != dstFileInformation.nFileSizeLow ) {
  693. Msg ( "ERROR: file size different: %s %ld %s %ld\n", fileSrcPath, srcFileInformation.nFileSizeLow, fileDstPath, dstFileInformation.nFileSizeLow );
  694. bNoError = FALSE;
  695. goto cleanup1;
  696. }
  697. // Compare the bits.
  698. //
  699. totalBytesRead = 0;
  700. while ( 1 ) {
  701. b = ReadFile ( SrcFileHandle, &srcBuf, NUM_BYTES_TO_READ, &srcBytesRead, NULL );
  702. if ( !b ) {
  703. Msg ( "ERROR: ReadFile src, gle = %ld\n", GetLastError() );
  704. bNoError = FALSE;
  705. goto cleanup1;
  706. break;
  707. }
  708. b = ReadFile ( DstFileHandle, &dstBuf, NUM_BYTES_TO_READ, &dstBytesRead, NULL );
  709. if ( !b ) {
  710. Msg ( "ERROR: ReadFile dst, gle = %ld\n", GetLastError() );
  711. bNoError = FALSE;
  712. goto cleanup1;
  713. break;
  714. }
  715. // Read # of bytes need to be the same.
  716. //
  717. if ( srcBytesRead != dstBytesRead ) {
  718. Msg ( "ERROR: file read sizes different: %ld vs. %ld\n", srcBytesRead, dstBytesRead );
  719. bNoError = FALSE;
  720. goto cleanup1;
  721. break;
  722. }
  723. // Successfully read to end of file, we can break out now.
  724. //
  725. if ( srcBytesRead == 0 || dstBytesRead == 0 ) {
  726. if ( totalBytesRead != srcFileInformation.nFileSizeLow ) {
  727. Msg ( "ERROR: totalBytesRead = %ld notequal srcFileInformation.nFileSizeLow = %ld\n",
  728. totalBytesRead, srcFileInformation.nFileSizeLow );
  729. bNoError = FALSE;
  730. goto cleanup1;
  731. }
  732. break;
  733. }
  734. totalBytesRead += srcBytesRead;
  735. for ( i = 0; i < srcBytesRead; ++i ) {
  736. if ( srcBuf[i] != dstBuf[i] ) {
  737. Msg ( "ERROR: srcBuf %d != dstBuf %d, i = %ld srcBytesRead = %ld totalBytesRead = %ld %s %s \n", srcBuf[i], dstBuf[i], i, srcBytesRead, totalBytesRead, fileSrcPath, fileDstPath );
  738. bNoError = FALSE;
  739. Replay ( srcBuf, dstBuf, srcBytesRead, i );
  740. goto cleanup1;
  741. }
  742. }
  743. //Msg ( "%s %ld of %ld examined...\n", fileSrcPath, totalBytesRead, srcFileInformation.nFileSizeLow );
  744. }
  745. // Close the file handles.
  746. //
  747. cleanup1:;
  748. CloseHandle ( SrcFileHandle );
  749. CloseHandle ( DstFileHandle );
  750. Msg ( "Verify: %s >>> %s [OK]\n", fileSrcPath, fileDstPath );
  751. cleanup0:;
  752. // If the file is compressed, ie. expanded, and the there wasn't an error
  753. // comparing, get rid of the expanded file so it doesn't take up any space.
  754. // But, if there was an error, leave it around for examination purposes.
  755. //
  756. if ( bIsDstCompressed && bNoError ) {
  757. char szDeleteFile[MFL];
  758. BOOL b;
  759. sprintf ( szDeleteFile, "%s\\%s", szExpandToDir, unCompressedFileName );
  760. b = DeleteFile ( szDeleteFile );
  761. if ( !b ) {
  762. Msg ( "ERROR: DeleteFile FAILED %s, gle = %ld\n", szDeleteFile, GetLastError() );
  763. }
  764. }
  765. }
  766. return (TRUE);
  767. }
  768. #define FILE_SECTION_BASE "[SourceDisksFiles]"
  769. #define FILE_SECTION_X86 "[SourceDisksFiles.x86]"
  770. #define FILE_SECTION_ALPHA "[SourceDisksFiles.alpha]"
  771. #define FILE_SECTION_DBG_BASE "[DbgFiles]"
  772. #define FILE_SECTION_DBG_X86 "[DbgFiles.x86]"
  773. BOOL CreateDir ( char * wcPath, BOOL bMakeDbgDirs ) {
  774. BOOL b;
  775. char cPath[MFL];
  776. char cPath2[MFL];
  777. int iIndex = 0;
  778. char * ptr=wcPath;
  779. // Msg ( "CreateDir: wcPath = %s, bMakeDbgDirs = %d\n", wcPath, bMakeDbgDirs );
  780. do {
  781. cPath[iIndex] = *wcPath;
  782. cPath[iIndex+1] = '\0';
  783. //Msg ( "cPath = %s\n", cPath );
  784. if ( cPath[iIndex] == '\\' || cPath[iIndex] == '\0' ) {
  785. if ( iIndex <= 2 ) {
  786. //Msg ( "skpdrv: iIndex = %d\n", iIndex );
  787. goto skipdrv;
  788. }
  789. strcpy ( cPath2, cPath );
  790. cPath2[iIndex] = '\0';
  791. //Msg ( "Create with: >>>%s<<<\n", cPath2 );
  792. b = CreateDirectory ( cPath, NULL );
  793. if ( !b ) {
  794. DWORD dwGle;
  795. dwGle = GetLastError();
  796. if ( dwGle != ERROR_ALREADY_EXISTS ) {
  797. Msg ( "ERROR CreateDirectory gle = %ld, wcPath = %s\n", dwGle, ptr );
  798. return(FALSE);
  799. }
  800. }
  801. else {
  802. Msg ( "Made dir: %s\n", cPath );
  803. }
  804. if ( cPath[iIndex] == '\0' ) {
  805. break;
  806. }
  807. }
  808. skipdrv:;
  809. ++iIndex;
  810. ++wcPath;
  811. } while ( 1 );
  812. if ( bMakeDbgDirs ) {
  813. int i;
  814. for ( i = 0; i < NUM_EXTS; ++i ) {
  815. sprintf ( cPath2, "%s\\%s", cPath, cExtra[i] );
  816. // Msg ( "bMakeDbgDirs to: %s\n", cPath2 );
  817. b = CreateDirectory ( cPath2, NULL );
  818. if ( !b ) {
  819. DWORD dwGle;
  820. dwGle = GetLastError();
  821. if ( dwGle != ERROR_ALREADY_EXISTS ) {
  822. Msg ( "ERROR CreateDirectory gle = %ld, cPath = %s\n", dwGle, cPath );
  823. return(FALSE);
  824. }
  825. }
  826. else {
  827. Msg ( "Made dir: %s\n", cPath );
  828. }
  829. }
  830. }
  831. return(TRUE);
  832. }
  833. BOOL CreateDestinationDirs ( void ) {
  834. CHAR dstDirectory[MFL];
  835. // Create the directories to compare the bits, used later in MyCopyFile().
  836. //
  837. CreateDir ( V_WRK_I386, FALSE );
  838. CreateDir ( V_WRK_ALPHA, FALSE );
  839. CreateDir ( V_SRV_I386, FALSE );
  840. CreateDir ( V_SRV_ALPHA, FALSE );
  841. // Create the Workstation %platform%\system32 directories.
  842. //
  843. sprintf ( dstDirectory, "%s%s", szWorkDstDrv, I386_DIR ); CreateDir ( dstDirectory,FALSE );
  844. sprintf ( dstDirectory, "%s%s", szWorkDstDrv, ALPHA_DIR ); CreateDir ( dstDirectory,FALSE );
  845. // Create the Workstation \support\debug\%platform%\symbols\%ext% directories.
  846. //
  847. sprintf ( dstDirectory, "%s%s", szWorkDstDrv, I386_DBG ); CreateDir ( dstDirectory,TRUE );
  848. sprintf ( dstDirectory, "%s%s", szWorkDstDrv, ALPHA_DBG ); CreateDir ( dstDirectory,TRUE );
  849. // Create the Server %platform% directories.
  850. //
  851. sprintf ( dstDirectory, "%s%s", szServDstDrv, I386_DIR ); CreateDir ( dstDirectory,FALSE );
  852. sprintf ( dstDirectory, "%s%s", szServDstDrv, ALPHA_DIR ); CreateDir ( dstDirectory,FALSE );
  853. // Create the Server \support\debug\%platform%\symbols\%ext% directories.
  854. //
  855. sprintf ( dstDirectory, "%s%s", szServDstDrv, I386_DBG ); CreateDir ( dstDirectory,TRUE );
  856. sprintf ( dstDirectory, "%s%s", szServDstDrv, ALPHA_DBG ); CreateDir ( dstDirectory,TRUE );
  857. // Create the Server %platform%\netmon directories - this is ONLY required on Server.
  858. //
  859. sprintf ( dstDirectory, "%s%s%s", szServDstDrv, I386_DIR_RAW, NETMON ); CreateDir ( dstDirectory,FALSE );
  860. sprintf ( dstDirectory, "%s%s%s", szServDstDrv, ALPHA_DIR_RAW, NETMON ); CreateDir ( dstDirectory,FALSE );
  861. // Create the Server \clients\srvtools\winnt\%platform% directories.
  862. //
  863. sprintf ( dstDirectory, "%s%s", szServDstDrv, I386_SRV_WINNT ); CreateDir ( dstDirectory,FALSE );
  864. sprintf ( dstDirectory, "%s%s", szServDstDrv, ALPHA_SRV_WINNT ); CreateDir ( dstDirectory,FALSE );
  865. return(TRUE);
  866. }
  867. DWORD CopyDbgFiles ( void ) {
  868. char fileSrcPath[MFL];
  869. char fileDstPath[MFL];
  870. DWORD i;
  871. for ( i = 0; i < X86Dbg.wNumFiles; ++i ) {
  872. sprintf ( fileSrcPath, "%s\\%s\\%s", szX86Dbg,
  873. X86Dbg.wcSubPath[i],
  874. X86Dbg.wcFilesArray[i] );
  875. sprintf ( fileDstPath, "%s\\support\\debug\\i386\\%s", szWorkDstDrv,
  876. X86Dbg.wcFilesArray[i] );
  877. MyCopyFile ( fileSrcPath, fileDstPath );
  878. if ( bChecked ) {
  879. // Don't make a Serv checked build.
  880. continue;
  881. }
  882. sprintf ( fileDstPath, "%s\\support\\debug\\i386\\%s", szServDstDrv,
  883. X86Dbg.wcFilesArray[i] );
  884. MyCopyFile ( fileSrcPath, fileDstPath );
  885. }
  886. for ( i = 0; i < AlphaDbg.wNumFiles; ++i ) {
  887. sprintf ( fileSrcPath, "%s\\%s\\%s", szAlphaDbg,
  888. AlphaDbg.wcSubPath[i],
  889. AlphaDbg.wcFilesArray[i] );
  890. sprintf ( fileDstPath, "%s\\support\\debug\\Alpha\\%s", szWorkDstDrv,
  891. AlphaDbg.wcFilesArray[i] );
  892. MyCopyFile ( fileSrcPath, fileDstPath );
  893. if ( bChecked ) {
  894. // Don't make a Serv checked build.
  895. continue;
  896. }
  897. sprintf ( fileDstPath, "%s\\support\\debug\\Alpha\\%s", szServDstDrv,
  898. AlphaDbg.wcFilesArray[i] );
  899. MyCopyFile ( fileSrcPath, fileDstPath );
  900. }
  901. return(TRUE);
  902. }
  903. VOID MakeCompName ( const char * inFile, char * outFile ) {
  904. unsigned i;
  905. unsigned period;
  906. strcpy( outFile, inFile );
  907. for ( period=(unsigned)(-1), i = 0 ; i < strlen(inFile); i++ ) {
  908. if ( inFile[i] == '.' ) {
  909. period = i;
  910. }
  911. }
  912. if ( period == (strlen(inFile)-4) ) {
  913. outFile[strlen(outFile)-1] = '_';
  914. }
  915. else if ( period == (unsigned)(-1)) {
  916. strcat ( outFile, "._");
  917. }
  918. else {
  919. strcat ( outFile, "_");
  920. }
  921. }
  922. VOID MakeDbgName( LPCSTR pszSourceName, LPSTR pszTargetName ) {
  923. //
  924. // Converts "filename.ext" into "ext\filename.dbg".
  925. //
  926. const char *p = strchr( pszSourceName, '.' );
  927. if ( p != NULL ) {
  928. strcpy( pszTargetName, p + 1 ); // old extension
  929. strcat( pszTargetName, "\\" ); // path separator
  930. strcat( pszTargetName, pszSourceName ); // base name
  931. strcpy( strchr( pszTargetName, '.' ), ".dbg" ); // new extension
  932. }
  933. else {
  934. strcpy( pszTargetName, pszSourceName );
  935. }
  936. }
  937. DWORD CopyX86Workstation ( void ) {
  938. char fileSrcPath[256];
  939. char fileDstPath[256];
  940. DWORD i;
  941. fX86Wrk = FALSE;
  942. for ( i = 0; i < i386Workstation.wNumFiles; ++i ) {
  943. // Copy the system file.
  944. //
  945. if ( i386Workstation.bCopyComp[i] ) {
  946. char szCompressedName[256];
  947. MakeCompName ( i386Workstation.wcFilesArray[i], szCompressedName );
  948. sprintf ( fileSrcPath, "%s\\%s", szCompX86Src, szCompressedName );
  949. sprintf ( fileDstPath, "%s\\i386\\%s", szWorkDstDrv, szCompressedName );
  950. Msg ( "compressed source Path = %s\n", fileSrcPath );
  951. }
  952. else {
  953. sprintf ( fileSrcPath, "%s\\%s", szWrkX86Src, i386Workstation.wcFilesArray[i] );
  954. sprintf ( fileDstPath, "%s\\i386\\%s", szWorkDstDrv, i386Workstation.wcFilesArray[i] );
  955. }
  956. MyCopyFile ( fileSrcPath, fileDstPath );
  957. // Copy the dbg file, if needed.
  958. //
  959. if ( i386Workstation.bCopyDbg[i] ) {
  960. char szDbgName[256];
  961. MakeDbgName ( i386Workstation.wcFilesArray[i], szDbgName );
  962. sprintf ( fileSrcPath, "%s\\%s", szX86DbgSource, szDbgName );
  963. sprintf ( fileDstPath, "%s\\support\\debug\\i386\\symbols\\%s", szWorkDstDrv, szDbgName );
  964. MyCopyFile ( fileSrcPath, fileDstPath );
  965. }
  966. }
  967. fX86Wrk = TRUE;
  968. return (TRUE);
  969. }
  970. DWORD CopyAlphaWorkstation ( void ) {
  971. CHAR fileSrcPath[256];
  972. CHAR fileDstPath[256];
  973. DWORD i;
  974. fAlphaWrk = FALSE;
  975. for ( i = 0; i < AlphaWorkstation.wNumFiles; ++i ) {
  976. // Copy the system file.
  977. //
  978. if ( AlphaWorkstation.bCopyComp[i] ) {
  979. char szCompressedName[256];
  980. MakeCompName ( AlphaWorkstation.wcFilesArray[i], szCompressedName );
  981. sprintf ( fileSrcPath, "%s\\%s", szCompAlphaSrc, szCompressedName );
  982. sprintf ( fileDstPath, "%s\\alpha\\%s", szWorkDstDrv, szCompressedName );
  983. }
  984. else {
  985. sprintf ( fileSrcPath, "%s\\%s", szWrkAlphaSrc, AlphaWorkstation.wcFilesArray[i] );
  986. sprintf ( fileDstPath, "%s\\alpha\\%s", szWorkDstDrv, AlphaWorkstation.wcFilesArray[i] );
  987. }
  988. MyCopyFile ( fileSrcPath, fileDstPath );
  989. // Copy the dbg file, if needed.
  990. //
  991. if ( AlphaWorkstation.bCopyDbg[i] ) {
  992. char szDbgName[256];
  993. MakeDbgName ( AlphaWorkstation.wcFilesArray[i], szDbgName );
  994. sprintf ( fileSrcPath, "%s\\%s", szAlphaDbgSource, szDbgName );
  995. sprintf ( fileDstPath, "%s\\support\\debug\\alpha\\symbols\\%s", szWorkDstDrv, szDbgName );
  996. MyCopyFile ( fileSrcPath, fileDstPath );
  997. }
  998. }
  999. fAlphaWrk = TRUE;
  1000. return (TRUE);
  1001. }
  1002. #define INF_SUFFIX ".inf"
  1003. #define SRV_INF "srv_inf"
  1004. BOOL SrvInfTest ( char * file ) {
  1005. if ( strstr ( file, INF_SUFFIX ) != NULL &&
  1006. _stricmp ( file, "MODEM.INF" ) != 0 && // these N Inf files are not built in
  1007. _stricmp ( file, "PAD.INF" ) != 0 && // setup\inf\...
  1008. _stricmp ( file, "SETUP16.INF" ) != 0 && // and won't be found in the Server INF location
  1009. _stricmp ( file, "XPORTS.INF" ) != 0 &&
  1010. _stricmp ( file, "SWITCH.INF" ) != 0 &&
  1011. _stricmp ( file, "MAPISVC.INF" ) != 0 &&
  1012. _stricmp ( file, "IE.INF" ) != 0 &&
  1013. _stricmp ( file, "INETFIND.INF" ) != 0 &&
  1014. _stricmp ( file, "MONITOR1.INF" ) != 0 &&
  1015. _stricmp ( file, "MONITOR2.INF" ) != 0 &&
  1016. _stricmp ( file, "MONITOR3.INF" ) != 0 &&
  1017. _stricmp ( file, "MONITOR4.INF" ) != 0 &&
  1018. _stricmp ( file, "MONITOR6.INF" ) != 0 &&
  1019. _stricmp ( file, "MSTASK.INF" ) != 0 &&
  1020. _stricmp ( file, "SBPNP.INF" ) != 0 &&
  1021. _stricmp ( file, "AMOVIE.INF" ) != 0 &&
  1022. _stricmp ( file, "ICWNT5.INF" ) != 0 &&
  1023. _stricmp ( file, "HMMNT5.INF" ) != 0 &&
  1024. _stricmp ( file, "NT5JAVA.INF" ) != 0 &&
  1025. _stricmp ( file, "ROUTING.INF" ) != 0 &&
  1026. _strnicmp ( file, "MDM", 3 ) != 0 // for all those MDM*.INF modem inf files
  1027. ) {
  1028. return (TRUE); // use SERVER INF dump location path.
  1029. }
  1030. else {
  1031. return (FALSE); // use WORKSTATION INF dump location path,
  1032. // such as for INFs that don't have a distinction
  1033. // between Workstation and Server.
  1034. }
  1035. }
  1036. DWORD CopyX86Server ( void ) {
  1037. CHAR fileSrcPath[256];
  1038. CHAR fileDstPath[256];
  1039. DWORD i;
  1040. fX86Srv = FALSE;
  1041. for ( i = 0; i < i386Server.wNumFiles; ++i ) {
  1042. // Copy the system file.
  1043. //
  1044. if ( i386Server.bCopyComp[i] ) {
  1045. char szCompressedName[256];
  1046. MakeCompName ( i386Server.wcFilesArray[i], szCompressedName );
  1047. sprintf ( fileSrcPath, "%s\\%s", szCompX86Src, szCompressedName );
  1048. sprintf ( fileDstPath, "%s\\i386\\%s", szServDstDrv, szCompressedName );
  1049. if ( SrvInfTest ( i386Server.wcFilesArray[i] ) ) {
  1050. sprintf ( fileSrcPath, "%s\\%s\\%s", szCompX86Src, SRV_INF, szCompressedName );
  1051. Msg ( "Server INF special src path: %s\n", fileSrcPath );
  1052. }
  1053. }
  1054. else {
  1055. sprintf ( fileSrcPath, "%s\\%s", szSrvX86Src, i386Server.wcFilesArray[i] );
  1056. sprintf ( fileDstPath, "%s\\i386\\%s", szServDstDrv, i386Server.wcFilesArray[i] );
  1057. }
  1058. MyCopyFile ( fileSrcPath, fileDstPath );
  1059. // Copy the dbg file, if needed.
  1060. //
  1061. if ( i386Server.bCopyDbg[i] ) {
  1062. char szDbgName[256];
  1063. MakeDbgName ( i386Server.wcFilesArray[i], szDbgName );
  1064. sprintf ( fileSrcPath, "%s\\%s", szX86DbgSource, szDbgName );
  1065. sprintf ( fileDstPath, "%s\\support\\debug\\i386\\symbols\\%s", szServDstDrv, szDbgName );
  1066. MyCopyFile ( fileSrcPath, fileDstPath );
  1067. }
  1068. }
  1069. fX86Srv = TRUE;
  1070. return (TRUE);
  1071. }
  1072. DWORD CopyAlphaServer ( void ) {
  1073. CHAR fileSrcPath[256];
  1074. CHAR fileDstPath[256];
  1075. DWORD i;
  1076. fAlphaSrv = FALSE;
  1077. for ( i = 0; i < AlphaServer.wNumFiles; ++i ) {
  1078. // Copy the system file.
  1079. //
  1080. if ( AlphaServer.bCopyComp[i] ) {
  1081. char szCompressedName[256];
  1082. MakeCompName ( AlphaServer.wcFilesArray[i], szCompressedName );
  1083. sprintf ( fileSrcPath, "%s\\%s", szCompAlphaSrc, szCompressedName );
  1084. sprintf ( fileDstPath, "%s\\alpha\\%s", szServDstDrv, szCompressedName );
  1085. if ( SrvInfTest ( AlphaServer.wcFilesArray[i] ) ) {
  1086. sprintf ( fileSrcPath, "%s\\%s\\%s", szCompAlphaSrc, SRV_INF, szCompressedName );
  1087. Msg ( "Server INF special src path: %s\n", fileSrcPath );
  1088. }
  1089. }
  1090. else {
  1091. sprintf ( fileSrcPath, "%s\\%s", szSrvAlphaSrc, AlphaServer.wcFilesArray[i] );
  1092. sprintf ( fileDstPath, "%s\\alpha\\%s", szServDstDrv, AlphaServer.wcFilesArray[i] );
  1093. }
  1094. MyCopyFile ( fileSrcPath, fileDstPath );
  1095. // Copy the dbg file, if needed.
  1096. //
  1097. if ( AlphaServer.bCopyDbg[i] ) {
  1098. char szDbgName[256];
  1099. MakeDbgName ( AlphaServer.wcFilesArray[i], szDbgName );
  1100. sprintf ( fileSrcPath, "%s\\%s", szAlphaDbgSource, szDbgName );
  1101. sprintf ( fileDstPath, "%s\\support\\debug\\alpha\\symbols\\%s", szServDstDrv, szDbgName );
  1102. MyCopyFile ( fileSrcPath, fileDstPath );
  1103. }
  1104. }
  1105. fAlphaSrv = TRUE;
  1106. return (TRUE);
  1107. }
  1108. BOOL CopyTheFiles ( void ) {
  1109. DWORD tId;
  1110. HANDLE hThread;
  1111. /***
  1112. if ( bVerifyBits ) {
  1113. // Don't multithread.
  1114. //
  1115. CopyX86Workstation ();
  1116. CopyX86Server ();
  1117. CopyAlphaWorkstation ();
  1118. CopyAlphaServer ();
  1119. return (TRUE);
  1120. }
  1121. ***/
  1122. hThread = CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE) CopyX86Workstation, NULL, 0, &tId );
  1123. if ( hThread == NULL ) {
  1124. Msg ( "x86w CreateThread ERROR gle = %ld\n", GetLastError() );
  1125. }
  1126. hThread = CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE) CopyX86Server, NULL, 0, &tId );
  1127. if ( hThread == NULL ) {
  1128. Msg ( "x86s CreateThread ERROR gle = %ld\n", GetLastError() );
  1129. }
  1130. hThread = CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE) CopyAlphaWorkstation, NULL, 0, &tId );
  1131. if ( hThread == NULL ) {
  1132. Msg ( "alphaw CreateThread ERROR gle = %ld\n", GetLastError() );
  1133. }
  1134. hThread = CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE) CopyAlphaServer, NULL, 0, &tId );
  1135. if ( hThread == NULL ) {
  1136. Msg ( "alphas CreateThread ERROR gle = %ld\n", GetLastError() );
  1137. }
  1138. // Copy the debugger files in the current thread.
  1139. //
  1140. CopyDbgFiles ();
  1141. while ( fX86Wrk == FALSE ||
  1142. fX86Srv == FALSE ||
  1143. fAlphaWrk == FALSE ||
  1144. fAlphaSrv == FALSE ) {
  1145. Sleep ( 1000 );
  1146. }
  1147. return(TRUE);
  1148. }
  1149. #define FILE_SECTION_NOT_USED 0xFFFF
  1150. DWORD dwInsideSection = FILE_SECTION_NOT_USED;
  1151. DWORD FigureSection ( char * Line ) {
  1152. Msg ( "FigureSection on: %s\n", Line );
  1153. if ( strstr ( Line, FILE_SECTION_BASE ) ) {
  1154. dwInsideSection = idBase;
  1155. }
  1156. else
  1157. if ( strstr ( Line, FILE_SECTION_X86 ) ) {
  1158. dwInsideSection = idX86;
  1159. }
  1160. else
  1161. if ( strstr ( Line, FILE_SECTION_ALPHA ) ) {
  1162. dwInsideSection = idALPHA;
  1163. }
  1164. else
  1165. if ( strstr ( Line, FILE_SECTION_DBG_BASE ) ) {
  1166. dwInsideSection = idBaseDbg;
  1167. }
  1168. else
  1169. if ( strstr ( Line, FILE_SECTION_DBG_X86 ) ) {
  1170. dwInsideSection = idX86Dbg;
  1171. }
  1172. else {
  1173. dwInsideSection = FILE_SECTION_NOT_USED;
  1174. }
  1175. Msg ( "dwInsideSection = %x\n", dwInsideSection );
  1176. return(dwInsideSection);
  1177. }
  1178. char * SuckName ( const char * Line ) {
  1179. static char szSuckedName[MFL];
  1180. DWORD dwIndex = 0;
  1181. // Copy the file name until a space is encountered.
  1182. //
  1183. while ( *Line != ' ' ) {
  1184. szSuckedName[dwIndex] = *Line;
  1185. szSuckedName[dwIndex+1] = '\0';
  1186. ++Line;
  1187. ++dwIndex;
  1188. }
  1189. return szSuckedName;
  1190. }
  1191. char * SuckSubName ( const char * Line ) {
  1192. static char szSub[150];
  1193. DWORD i = 0;
  1194. char * sPtr;
  1195. char * ePtr;
  1196. Msg ( "SuckSubName Line = %s\n", Line );
  1197. // Find the = sign in the line.
  1198. //
  1199. sPtr = strchr ( Line, '=' );
  1200. if ( sPtr == NULL ) {
  1201. Msg ( "SuckSubName ERROR, couldn't find '=' character in string: %s\n", Line );
  1202. strcpy ( szSub, "" );
  1203. return (szSub);
  1204. }
  1205. // Go past the '=' and 'space' character.
  1206. //
  1207. ++sPtr;
  1208. ++sPtr;
  1209. //Msg ( "sPtr = >>>%s<<<\n", sPtr );
  1210. // Find the , character, this is the end of the string.
  1211. //
  1212. ePtr = strchr ( Line, ',' );
  1213. if ( ePtr == NULL ) {
  1214. Msg ( "SuckSubName ERROR, couldn't find ',' character in string: %s\n", Line );
  1215. strcpy ( szSub, "" );
  1216. return (szSub);
  1217. }
  1218. // Copy the string.
  1219. do {
  1220. szSub[i] = *sPtr;
  1221. ++i;
  1222. ++sPtr;
  1223. } while ( sPtr < ePtr );
  1224. szSub[i] = '\0';
  1225. //Msg ( "szSub = >>>%s<<<\n\n", szSub );
  1226. return szSub;
  1227. }
  1228. void ShowX86Work ( void ) {
  1229. int i;
  1230. for ( i = 0; i < i386Workstation.wNumFiles; ++i ) {
  1231. Msg ( "%d %s Comp=%d Dbg=%d\n",
  1232. i,
  1233. i386Workstation.wcFilesArray[i],
  1234. i386Workstation.bCopyComp[i],
  1235. i386Workstation.bCopyDbg[i] );
  1236. }
  1237. }
  1238. void AddFileToX86Work ( const char * Line, BOOL bCopyComp, BOOL bCopyDbg ) {
  1239. i386Workstation.bCopyComp[i386Workstation.wNumFiles] = bCopyComp;
  1240. i386Workstation.bCopyDbg[i386Workstation.wNumFiles] = bCopyDbg;
  1241. i386Workstation.bCountBytes[i386Workstation.wNumFiles] = bGetSizeLater;
  1242. strcpy ( i386Workstation.wcFilesArray[i386Workstation.wNumFiles], SuckName (Line) );
  1243. ++i386Workstation.wNumFiles;
  1244. }
  1245. void AddFileToX86Serv ( const char * Line, BOOL bCopyComp, BOOL bCopyDbg ) {
  1246. if ( bChecked ) {
  1247. // Don't make a Serv checked build.
  1248. return;
  1249. }
  1250. i386Server.bCopyComp[i386Server.wNumFiles] = bCopyComp;
  1251. i386Server.bCopyDbg[i386Server.wNumFiles] = bCopyDbg;
  1252. i386Server.bCountBytes[i386Server.wNumFiles] = bGetSizeLater;
  1253. strcpy ( i386Server.wcFilesArray[i386Server.wNumFiles], SuckName (Line) );
  1254. ++i386Server.wNumFiles;
  1255. }
  1256. void AddFileToAlphaWork ( const char * Line, BOOL bCopyComp, BOOL bCopyDbg ) {
  1257. AlphaWorkstation.bCopyComp[AlphaWorkstation.wNumFiles] = bCopyComp;
  1258. AlphaWorkstation.bCopyDbg[AlphaWorkstation.wNumFiles] = bCopyDbg;
  1259. AlphaWorkstation.bCountBytes[AlphaWorkstation.wNumFiles] = bGetSizeLater;
  1260. strcpy ( AlphaWorkstation.wcFilesArray[AlphaWorkstation.wNumFiles], SuckName (Line) );
  1261. ++AlphaWorkstation.wNumFiles;
  1262. }
  1263. void AddFileToAlphaServ ( const char * Line, BOOL bCopyComp, BOOL bCopyDbg ) {
  1264. if ( bChecked ) {
  1265. // Don't make a Serv checked build.
  1266. return;
  1267. }
  1268. AlphaServer.bCopyComp[AlphaServer.wNumFiles] = bCopyComp;
  1269. AlphaServer.bCopyDbg[AlphaServer.wNumFiles] = bCopyDbg;
  1270. AlphaServer.bCountBytes[AlphaServer.wNumFiles] = bGetSizeLater;
  1271. strcpy ( AlphaServer.wcFilesArray[AlphaServer.wNumFiles], SuckName (Line) );
  1272. ++AlphaServer.wNumFiles;
  1273. }
  1274. void AddFileToX86Dbg ( const char * Line ) {
  1275. strcpy ( X86Dbg.wcFilesArray [X86Dbg.wNumFiles], SuckName (Line) );
  1276. strcpy ( X86Dbg.wcSubPath [X86Dbg.wNumFiles], SuckSubName (Line) );
  1277. ++X86Dbg.wNumFiles;
  1278. }
  1279. void AddFileToAlphaDbg ( const char * Line ) {
  1280. strcpy ( AlphaDbg.wcFilesArray [AlphaDbg.wNumFiles], SuckName (Line) );
  1281. strcpy ( AlphaDbg.wcSubPath [AlphaDbg.wNumFiles], SuckSubName (Line) );
  1282. ++AlphaDbg.wNumFiles;
  1283. }
  1284. BOOL CopyCompressedFile ( const char * Line ) {
  1285. const char * Ptr = Line;
  1286. DWORD i = 0;
  1287. #define COMP_FIELD 6
  1288. while ( *Line != '\0' ) {
  1289. // If we are at the correct field,
  1290. // then stop counting fields.
  1291. //
  1292. if ( i == COMP_FIELD ) {
  1293. break;
  1294. }
  1295. // Found another field, increment our counter.
  1296. //
  1297. if ( *Line == ',' ) {
  1298. ++i;
  1299. }
  1300. // Look at next char.
  1301. //
  1302. ++Line;
  1303. }
  1304. // If we are at the correct # of fields and the
  1305. // next char isn't a ',', we should keep this file
  1306. // uncompressed.
  1307. //
  1308. if ( i == COMP_FIELD && *Line != ',' ) {
  1309. Msg ( "don't compress this file =%c, %s", *Line, Ptr );
  1310. return ( FALSE );
  1311. }
  1312. //Msg ( "CopyCompressedFile TRUE=%s\n", Ptr );
  1313. return ( TRUE );
  1314. }
  1315. BOOL
  1316. ImageChk(
  1317. CHAR * ImageName )
  1318. {
  1319. HANDLE File;
  1320. HANDLE MemMap;
  1321. PIMAGE_DOS_HEADER DosHeader;
  1322. PIMAGE_NT_HEADERS NtHeader;
  1323. //NTSTATUS Status;
  1324. BY_HANDLE_FILE_INFORMATION FileInfo;
  1325. ULONG NumberOfPtes;
  1326. ULONG SectionVirtualSize;
  1327. ULONG i;
  1328. PIMAGE_SECTION_HEADER SectionTableEntry;
  1329. ULONG SectorOffset;
  1330. ULONG NumberOfSubsections;
  1331. PCHAR ExtendedHeader = NULL;
  1332. ULONG PreferredImageBase;
  1333. ULONG NextVa;
  1334. ULONG ImageFileSize;
  1335. ULONG OffsetToSectionTable;
  1336. ULONG ImageAlignment;
  1337. ULONG PtesInSubsection;
  1338. ULONG StartingSector;
  1339. ULONG EndingSector;
  1340. //LPSTR ImageName;
  1341. BOOL ImageOk;
  1342. Msg ( "ImageName = %s\n", ImageName );
  1343. DosHeader = NULL;
  1344. ImageOk = TRUE;
  1345. File = CreateFile (ImageName,
  1346. GENERIC_READ | FILE_EXECUTE,
  1347. FILE_SHARE_READ /*| FILE_SHARE_DELETE*/,
  1348. NULL,
  1349. OPEN_EXISTING,
  1350. FILE_ATTRIBUTE_NORMAL,
  1351. NULL);
  1352. if (File == INVALID_HANDLE_VALUE) {
  1353. // HACK: Since the release shares put WINNT32.EXE and WINNT32.HLP in the
  1354. // WINNT32 directory
  1355. // instead of leaving it in the flat root, verify that if the ImageName
  1356. // contains WINNT32, so we look in the WINNT32 dir also before error'ing out.
  1357. //
  1358. if ( strstr ( ImageName, "WINNT32.EXE" ) ||
  1359. strstr ( ImageName, "winnt32a.dll" ) ||
  1360. strstr ( ImageName, "winnt32u.dll" ) ||
  1361. strstr ( ImageName, "WINNT32A.DLL" ) ||
  1362. strstr ( ImageName, "WINNT32U.DLL" ) ||
  1363. strstr ( ImageName, "winnt32.exe" ) ) {
  1364. char tmpSrcPath[MFL];
  1365. strcpy ( tmpSrcPath, ImageName );
  1366. //Msg ( "ImageName = %s, tmpSrcPath = %s\n", ImageName, tmpSrcPath );
  1367. if ( strstr ( tmpSrcPath, "a.dll" ) ||
  1368. strstr ( tmpSrcPath, "A.DLL" ) ) {
  1369. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32a.dll" );
  1370. }
  1371. else if ( strstr ( tmpSrcPath, "u.dll" ) ||
  1372. strstr ( tmpSrcPath, "U.DLL" ) ) {
  1373. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32u.dll" );
  1374. }
  1375. else {
  1376. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.EXE" );
  1377. }
  1378. File = CreateFile (tmpSrcPath,
  1379. GENERIC_READ | FILE_EXECUTE,
  1380. FILE_SHARE_READ /*| FILE_SHARE_DELETE*/,
  1381. NULL,
  1382. OPEN_EXISTING,
  1383. FILE_ATTRIBUTE_NORMAL,
  1384. NULL);
  1385. if (File == INVALID_HANDLE_VALUE) {
  1386. Msg ( "ERROR on ImageName(tmpSrcPath) = %s, gle = %ld\n", tmpSrcPath, GetLastError() );
  1387. return (FALSE);
  1388. }
  1389. }
  1390. else {
  1391. Msg ( "ERROR, CreateFile(%s) gle = %ld\n", ImageName, GetLastError());
  1392. return (FALSE);
  1393. }
  1394. }
  1395. MemMap = CreateFileMapping (File,
  1396. NULL, // default security.
  1397. PAGE_READONLY, // file protection.
  1398. 0, // high-order file size.
  1399. 0,
  1400. NULL);
  1401. if (!GetFileInformationByHandle(File, &FileInfo)) {
  1402. Msg ("ERROR, GetFileInfo() %d, %s\n", GetLastError(), ImageName );
  1403. CloseHandle(File);
  1404. return (FALSE);
  1405. }
  1406. DosHeader = (PIMAGE_DOS_HEADER) MapViewOfFile(MemMap,
  1407. FILE_MAP_READ,
  1408. 0, // high
  1409. 0, // low
  1410. 0 // whole file
  1411. );
  1412. CloseHandle(MemMap);
  1413. if (!DosHeader) {
  1414. Msg ("ERROR, MapViewOfFile() %d\n", GetLastError());
  1415. ImageOk = FALSE;
  1416. goto NextImage;
  1417. }
  1418. try {
  1419. //
  1420. // Check to determine if this is an NT image (PE format) or
  1421. // a DOS image, Win-16 image, or OS/2 image. If the image is
  1422. // not NT format, return an error indicating which image it
  1423. // appears to be.
  1424. //
  1425. if (DosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
  1426. Msg ( "Warning: MZ header not found, %s\n", ImageName );
  1427. ImageOk = FALSE;
  1428. goto NeImage;
  1429. }
  1430. NtHeader = (PIMAGE_NT_HEADERS)((ULONG)DosHeader + (ULONG)DosHeader->e_lfanew);
  1431. if (NtHeader->Signature != IMAGE_NT_SIGNATURE) { //if not PE image
  1432. Msg ("Warning: Non 32-bit image, %s\n", ImageName);
  1433. ImageOk = FALSE;
  1434. goto NeImage;
  1435. }
  1436. /*****
  1437. //
  1438. // Check to see if this is an NT image or a DOS or OS/2 image.
  1439. //
  1440. Status = MiVerifyImageHeader (NtHeader, DosHeader, 50000);
  1441. if (Status != STATUS_SUCCESS) {
  1442. ImageOk = FALSE; //continue checking the image but don't print "OK"
  1443. }
  1444. *****/
  1445. //
  1446. // Verify machine type.
  1447. //
  1448. if (!((NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) ||
  1449. (NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_R3000) ||
  1450. (NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_R4000) ||
  1451. (NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_R10000) ||
  1452. (NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_ALPHA))) {
  1453. Msg ( "ERROR Unrecognized machine type x%lx\n",
  1454. NtHeader->FileHeader.Machine);
  1455. ImageOk = FALSE;
  1456. }
  1457. }
  1458. except ( EXCEPTION_EXECUTE_HANDLER ) {
  1459. Msg ( "Warning, try/except handler, %s\n", ImageName );
  1460. ImageOk = FALSE;
  1461. }
  1462. NextImage:
  1463. NeImage:
  1464. if ( File != INVALID_HANDLE_VALUE ) {
  1465. CloseHandle(File);
  1466. }
  1467. if ( DosHeader ) {
  1468. UnmapViewOfFile(DosHeader);
  1469. }
  1470. return (ImageOk);
  1471. }
  1472. BOOL CopyDbgFile ( const char * Line, DWORD dwInsideSection ) {
  1473. char szPath[MFL];
  1474. char szFile[20];
  1475. BOOL b;
  1476. LONG lType;
  1477. // Verify that this file name contains one of the extensions
  1478. // that we need files for debugging.
  1479. //
  1480. sprintf ( szFile, "%s", SuckName ( Line ) );
  1481. if ( strstr ( szFile, ".acm" ) == NULL &&
  1482. strstr ( szFile, ".com" ) == NULL &&
  1483. strstr ( szFile, ".cpl" ) == NULL &&
  1484. strstr ( szFile, ".dll" ) == NULL &&
  1485. strstr ( szFile, ".drv" ) == NULL &&
  1486. strstr ( szFile, ".exe" ) == NULL &&
  1487. strstr ( szFile, ".scr" ) == NULL &&
  1488. strstr ( szFile, ".sys" ) == NULL ) {
  1489. return (FALSE);
  1490. }
  1491. // Determine which release share to look at.
  1492. //
  1493. switch ( dwInsideSection ) {
  1494. case idBase :
  1495. case idX86 :
  1496. sprintf ( szPath, "%s\\%s", szWrkX86Src, szFile );
  1497. break;
  1498. case idALPHA :
  1499. sprintf ( szPath, "%s\\%s", szWrkAlphaSrc, szFile );
  1500. break;
  1501. case idBaseDbg :
  1502. case idX86Dbg :
  1503. return (FALSE);
  1504. default :
  1505. Msg ( "ERROR: CopyDbgFile, unknown switch value = %ld\n", dwInsideSection );
  1506. return (FALSE);
  1507. break;
  1508. }
  1509. // Since we are loading in each INF now, let's optimize this code, ie. if we have
  1510. // deemed the file to get it's debug file, don't do another ImageChk since it is
  1511. // unneccessary.
  1512. {
  1513. int i;
  1514. for ( i = 0; i < i386Workstation.wNumFiles; ++i ) {
  1515. if ( _stricmp ( i386Workstation.wcFilesArray[i], szFile ) == 0 ) {
  1516. //Msg ( ">>> files have same name for .dbg : %s %s\n",
  1517. // i386Workstation.wcFilesArray[i], szFile );
  1518. return TRUE;
  1519. }
  1520. }
  1521. }
  1522. // Look at the binary type. If it is a Win32 binary, pick it up.
  1523. //
  1524. b = ImageChk ( szPath );
  1525. return ( b );
  1526. }
  1527. #define X86_WRK 0
  1528. #define X86_SRV 1
  1529. #define ALPHA_WRK 2
  1530. #define ALPHA_SRV 3
  1531. #define DBGS_AND_NON_INSTALLED 4
  1532. BOOL GetTheFiles ( char * LayoutInfPath, char * layoutFile, int AddToList ) {
  1533. CHAR infFilePath[MFL];
  1534. DWORD dwErrorLine;
  1535. BOOL b;
  1536. char dstDirectory[MFL];
  1537. FILE * fHandle;
  1538. char Line[MFL];
  1539. // Open the inx file for processing.
  1540. //
  1541. sprintf ( infFilePath, "%s\\%s", LayoutInfPath, layoutFile );
  1542. Msg ( "infFilePath = %s\n", infFilePath );
  1543. fHandle = fopen ( infFilePath, "rt" );
  1544. if ( fHandle ) {
  1545. Msg ( "dwInsideSection = %x\n", dwInsideSection );
  1546. while ( fgets ( Line, sizeof(Line), fHandle ) ) {
  1547. int i;
  1548. BOOL bCopyComp = FALSE; // flag to tell if file shall be copied in its compressed format.
  1549. BOOL bCopyDbg = FALSE; // flag to tell if copying the file's .dbg file.
  1550. // Msg ( "Line: %s\n", Line );
  1551. if ( Line[0] == '[' ) {
  1552. // We may have a new section.
  1553. //
  1554. dwInsideSection = FigureSection ( Line );
  1555. continue;
  1556. }
  1557. // Reasons to ignore this line from further processing.
  1558. //
  1559. //
  1560. // File section not one we process.
  1561. //
  1562. if ( dwInsideSection == FILE_SECTION_NOT_USED ) {
  1563. continue;
  1564. }
  1565. // Line just contains a non-usefull short string.
  1566. //
  1567. i = strlen ( Line );
  1568. if ( i < 4 ) {
  1569. continue;
  1570. }
  1571. // Line contains just a comment.
  1572. //
  1573. if ( Line[0] == ';' ) {
  1574. continue;
  1575. }
  1576. // Determine if we should copy the compressed
  1577. // version of the file and if we should copy the .dbg file.
  1578. //
  1579. bCopyComp = CopyCompressedFile ( Line );
  1580. bCopyDbg = CopyDbgFile ( Line, dwInsideSection );
  1581. //Msg ( "file == %s\n", SuckName ( Line ) );
  1582. switch ( AddToList ) {
  1583. case X86_WRK :
  1584. if ( dwInsideSection == idBase || dwInsideSection == idX86 ) {
  1585. AddFileToX86Work ( Line, bCopyComp, bCopyDbg );
  1586. }
  1587. break;
  1588. case X86_SRV :
  1589. if ( dwInsideSection == idBase || dwInsideSection == idX86 ) {
  1590. AddFileToX86Serv ( Line, bCopyComp, bCopyDbg );
  1591. }
  1592. break;
  1593. case ALPHA_WRK :
  1594. if ( dwInsideSection == idBase || dwInsideSection == idALPHA ) {
  1595. AddFileToAlphaWork ( Line, bCopyComp, bCopyDbg );
  1596. }
  1597. break;
  1598. case ALPHA_SRV :
  1599. if ( dwInsideSection == idBase || dwInsideSection == idALPHA ) {
  1600. AddFileToAlphaServ ( Line, bCopyComp, bCopyDbg );
  1601. }
  1602. break;
  1603. case DBGS_AND_NON_INSTALLED :
  1604. if ( dwInsideSection == idBase ) {
  1605. AddFileToX86Work ( Line, bCopyComp, bCopyDbg );
  1606. AddFileToX86Serv ( Line, bCopyComp, bCopyDbg );
  1607. AddFileToAlphaWork ( Line, bCopyComp, bCopyDbg );
  1608. AddFileToAlphaServ ( Line, bCopyComp, bCopyDbg );
  1609. break;
  1610. }
  1611. if ( dwInsideSection == idX86 ) {
  1612. AddFileToX86Work ( Line, bCopyComp, bCopyDbg );
  1613. AddFileToX86Serv ( Line, bCopyComp, bCopyDbg );
  1614. break;
  1615. }
  1616. if ( dwInsideSection == idALPHA ) {
  1617. AddFileToAlphaWork ( Line, bCopyComp, bCopyDbg );
  1618. AddFileToAlphaServ ( Line, bCopyComp, bCopyDbg );
  1619. break;
  1620. }
  1621. if ( dwInsideSection == idBaseDbg ) {
  1622. AddFileToX86Dbg ( Line );
  1623. AddFileToAlphaDbg ( Line );
  1624. break;
  1625. }
  1626. if ( dwInsideSection == idX86Dbg ) {
  1627. AddFileToX86Dbg ( Line );
  1628. break;
  1629. }
  1630. break;
  1631. default :
  1632. Msg ( "ERROR: AddToList = %d\n", AddToList );
  1633. }
  1634. }
  1635. if ( ferror(fHandle) ) {
  1636. Msg ( "ERROR fgets reading from file...\n" );
  1637. }
  1638. }
  1639. else {
  1640. Msg ( "fopen ERROR %s\n", infFilePath );
  1641. return (FALSE);
  1642. }
  1643. fclose ( fHandle );
  1644. return (TRUE);
  1645. }
  1646. void TallyInstalled ( char * szUncompPath, char * szCompPath,
  1647. struct _tag * tagStruct,
  1648. DWORD * numBytes,
  1649. struct _ClusterSizes * localSrcBytes ) {
  1650. int i;
  1651. char szCompressedName[MFL];
  1652. char szPath[MFL];
  1653. *numBytes = 0;
  1654. localSrcBytes->Kh1 = 0;
  1655. localSrcBytes->K1 = 0;
  1656. localSrcBytes->K2 = 0;
  1657. localSrcBytes->K4 = 0;
  1658. localSrcBytes->K8 = 0;
  1659. localSrcBytes->K16 = 0;
  1660. localSrcBytes->K32 = 0;
  1661. localSrcBytes->K64 = 0;
  1662. localSrcBytes->K128 = 0;
  1663. localSrcBytes->K256 = 0;
  1664. for ( i = 0; i < tagStruct->wNumFiles; ++i ) {
  1665. WIN32_FIND_DATA wfd;
  1666. HANDLE hFind;
  1667. // Don't add in space requirements for files in media.inx, since
  1668. // these files are NEVER installed.
  1669. //
  1670. if ( !tagStruct->bCountBytes[i] ) {
  1671. Msg ( "Warning: not going to count bytes for: %s\n", tagStruct->wcFilesArray[i] );
  1672. continue;
  1673. }
  1674. // Calculate the minimum installed system space required.
  1675. //
  1676. //
  1677. sprintf ( szPath, "%s\\%s", szUncompPath, tagStruct->wcFilesArray[i] );
  1678. hFind = FindFirstFile ( szPath, &wfd );
  1679. if ( hFind == INVALID_HANDLE_VALUE ) {
  1680. if ( strstr ( szPath, "desktop.ini" ) ||
  1681. strstr ( szPath, "DESKTOP.INI" ) ) {
  1682. // Build lab sometimes doesn't put the uncompressed
  1683. // file on the release shares, say the file is 512 bytes.
  1684. //
  1685. #define MAX_SETUP_CLUSTER_SIZE 16*1024
  1686. *numBytes += ROUNDUP2 ( 512, MAX_SETUP_CLUSTER_SIZE );
  1687. }
  1688. else
  1689. if ( strstr ( szPath, "WINNT32.EXE" ) ||
  1690. strstr ( szPath, "winnt32.exe" ) ||
  1691. strstr ( szPath, "winnt32a.dll" ) ||
  1692. strstr ( szPath, "winnt32u.dll" ) ||
  1693. strstr ( szPath, "WINNT32A.DLL" ) ||
  1694. strstr ( szPath, "WINNT32U.DLL" ) ||
  1695. strstr ( szPath, "WINNT32.HLP" ) ||
  1696. strstr ( szPath, "winnt32.hlp" ) ) {
  1697. char tmpSrcPath[MFL];
  1698. strcpy ( tmpSrcPath, szPath );
  1699. if ( strstr ( tmpSrcPath, ".HLP" ) ||
  1700. strstr ( tmpSrcPath, ".hlp" ) ) {
  1701. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.HLP" );
  1702. }
  1703. else if ( strstr ( tmpSrcPath, "a.dll" ) ||
  1704. strstr ( tmpSrcPath, "A.DLL" ) ) {
  1705. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32a.dll" );
  1706. }
  1707. else if ( strstr ( tmpSrcPath, "u.dll" ) ||
  1708. strstr ( tmpSrcPath, "U.DLL" ) ) {
  1709. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32u.dll" );
  1710. }
  1711. else {
  1712. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.EXE" );
  1713. }
  1714. hFind = FindFirstFile ( tmpSrcPath, &wfd );
  1715. if ( hFind == INVALID_HANDLE_VALUE ) {
  1716. Msg ( "ERROR Tally: FindFirstFile %s(%s), gle = %ld\n", szPath, tmpSrcPath, GetLastError() );
  1717. }
  1718. }
  1719. else {
  1720. Msg ( "ERROR Tally: FindFirstFile %s, gle = %ld\n", szPath, GetLastError() );
  1721. }
  1722. }
  1723. else {
  1724. *numBytes += ROUNDUP2 ( wfd.nFileSizeLow, MAX_SETUP_CLUSTER_SIZE );
  1725. FindClose ( hFind );
  1726. //Msg ( "%s = %ld\n", szPath, *numBytes );
  1727. }
  1728. // Calculate the local space required.
  1729. //
  1730. //
  1731. if ( tagStruct->bCopyComp[i] ) {
  1732. char szCompressedName[MFL];
  1733. MakeCompName ( tagStruct->wcFilesArray[i], szCompressedName );
  1734. sprintf ( szPath, "%s\\%s", szCompPath, szCompressedName );
  1735. }
  1736. else {
  1737. sprintf ( szPath, "%s\\%s", szUncompPath, tagStruct->wcFilesArray[i] );
  1738. }
  1739. hFind = FindFirstFile ( szPath, &wfd );
  1740. if ( hFind == INVALID_HANDLE_VALUE ) {
  1741. if ( strstr ( szPath, "WINNT32.EXE" ) ||
  1742. strstr ( szPath, "winnt32.exe" ) ||
  1743. strstr ( szPath, "winnt32a.dll" ) ||
  1744. strstr ( szPath, "winnt32u.dll" ) ||
  1745. strstr ( szPath, "WINNT32A.DLL" ) ||
  1746. strstr ( szPath, "WINNT32U.DLL" ) ||
  1747. strstr ( szPath, "WINNT32.HLP" ) ||
  1748. strstr ( szPath, "winnt32.hlp" ) ) {
  1749. char tmpSrcPath[MFL];
  1750. strcpy ( tmpSrcPath, szPath );
  1751. if ( strstr ( tmpSrcPath, ".HLP" ) ||
  1752. strstr ( tmpSrcPath, ".hlp" ) ) {
  1753. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.HLP" );
  1754. }
  1755. else if ( strstr ( tmpSrcPath, "a.dll" ) ||
  1756. strstr ( tmpSrcPath, "A.DLL" ) ) {
  1757. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32a.dll" );
  1758. }
  1759. else if ( strstr ( tmpSrcPath, "u.dll" ) ||
  1760. strstr ( tmpSrcPath, "U.DLL" ) ) {
  1761. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 5 ], "\\WINNT32u.dll" );
  1762. }
  1763. else {
  1764. strcpy ( &tmpSrcPath[ strlen(tmpSrcPath) - 4 ], "\\WINNT32.EXE" );
  1765. }
  1766. hFind = FindFirstFile ( tmpSrcPath, &wfd );
  1767. if ( hFind == INVALID_HANDLE_VALUE ) {
  1768. Msg ( "ERROR Tally: FindFirstFile %s(%s), gle = %ld\n", szPath, tmpSrcPath, GetLastError() );
  1769. }
  1770. }
  1771. else {
  1772. Msg ( "ERROR Tally: FindFirstFile %s, gle = %ld\n", szPath, GetLastError() );
  1773. }
  1774. }
  1775. else {
  1776. #define _h1K 512
  1777. #define _1K 1*1024
  1778. #define _2K 2*1024
  1779. #define _4K 4*1024
  1780. #define _8K 8*1024
  1781. #define _16K 16*1024
  1782. #define _32K 32*1024
  1783. #define _64K 64*1024
  1784. #define _128K 128*1024
  1785. #define _256K 256*1024
  1786. localSrcBytes->Kh1 += ROUNDUP2 ( wfd.nFileSizeLow, _h1K );
  1787. localSrcBytes->K1 += ROUNDUP2 ( wfd.nFileSizeLow, _1K );
  1788. localSrcBytes->K2 += ROUNDUP2 ( wfd.nFileSizeLow, _2K );
  1789. localSrcBytes->K4 += ROUNDUP2 ( wfd.nFileSizeLow, _4K );
  1790. localSrcBytes->K8 += ROUNDUP2 ( wfd.nFileSizeLow, _8K );
  1791. localSrcBytes->K16 += ROUNDUP2 ( wfd.nFileSizeLow, _16K );
  1792. localSrcBytes->K32 += ROUNDUP2 ( wfd.nFileSizeLow, _32K );
  1793. localSrcBytes->K64 += ROUNDUP2 ( wfd.nFileSizeLow, _64K );
  1794. localSrcBytes->K128+= ROUNDUP2 ( wfd.nFileSizeLow, _128K );
  1795. localSrcBytes->K256+= ROUNDUP2 ( wfd.nFileSizeLow, _256K );
  1796. FindClose ( hFind );
  1797. //Msg ( "%s = %ld\n", szPath, *localSrcBytes );
  1798. }
  1799. }
  1800. }
  1801. DWORD GetTheSize ( const char * szPath, const char * szKey ) {
  1802. FILE * fHandle;
  1803. char Line[MFL];
  1804. Msg ( "GetTheSize: szPath = %s\n", szPath );
  1805. fHandle = fopen ( szPath, "rt" );
  1806. if ( fHandle ) {
  1807. while ( fgets ( Line, sizeof(Line), fHandle ) ) {
  1808. if ( strncmp ( Line, szKey, strlen(szKey)-1 ) == 0 ) {
  1809. char * LinePtr = Line;
  1810. Msg ( "key Line = %s\n", Line );
  1811. // Find the first character that is a number.
  1812. //
  1813. while ( isdigit(*LinePtr) == 0 ) {
  1814. ++LinePtr;
  1815. }
  1816. Msg ( "# = %s\n", LinePtr );
  1817. fclose ( fHandle );
  1818. return ( atoi ( LinePtr ) );
  1819. }
  1820. }
  1821. Msg ( "GetTheSize: Couldn't find key: %s\n", szKey );
  1822. fclose ( fHandle );
  1823. }
  1824. else {
  1825. Msg ( "GetTheSize: Couldn't fopen (%s)\n", szPath );
  1826. }
  1827. return 0;
  1828. }
  1829. DWORD ThreeMegFudge ( void ) {
  1830. // The following value incorporates:
  1831. //
  1832. // - boot files on hard drive, ie. the files that would go on the floppies
  1833. // - dir ents for all files on hard drive
  1834. // the first is about 4.8M, the latter about 1M.
  1835. // - plus, just a few 100K for fudge.
  1836. return ( 6*1024*1024 );
  1837. }
  1838. void ShowCheckLocalSpace ( struct _ClusterSizes * Section, char * String, char * netServer ) {
  1839. DWORD dwSize = 0;
  1840. #define OHPROBLEM "problem"
  1841. char returnedString[MFL];
  1842. #define SP "SpaceRequirements"
  1843. char dosnetFile[MFL];
  1844. if ( bFourPtO ) {
  1845. // For 4.0 just do the following section.
  1846. //
  1847. GetPrivateProfileString ( SP, "NtDrive", OHPROBLEM, returnedString, MFL, dosnetFile );
  1848. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1849. Msg ( "ERROR: NtDrive section not found\n" );
  1850. }
  1851. Msg ( "returnedString = >>%s<<\n", returnedString );
  1852. dwSize = atoi ( returnedString );
  1853. if ( Section->K16+ThreeMegFudge() > dwSize ) {
  1854. Msg ( "ERROR: %s dosnet.inf's NtDrive value is %ld Use: %ld\n", String, dwSize, Section->K16 + ThreeMegFudge ( ) );
  1855. }
  1856. // End of 4.0 section.
  1857. }
  1858. else {
  1859. // Begin of 5.0 stuff.
  1860. //
  1861. sprintf ( dosnetFile, "%s\\dosnet.inf", netServer );
  1862. Msg ( "Dosnet.Inf location: %s\n", dosnetFile );
  1863. Msg ( "%s 512 size = %ld\n", String, Section->Kh1 );
  1864. Msg ( "%s 1K size = %ld\n", String, Section->K1 );
  1865. Msg ( "%s 2K size = %ld\n", String, Section->K2 );
  1866. Msg ( "%s 4K size = %ld\n", String, Section->K4 );
  1867. Msg ( "%s 8K size = %ld\n", String, Section->K8 );
  1868. Msg ( "%s 16K size = %ld\n", String, Section->K16 );
  1869. Msg ( "%s 32K size = %ld\n", String, Section->K32 );
  1870. Msg ( "%s 64K size = %ld\n", String, Section->K64 ) ;
  1871. Msg ( "%s 128K size = %ld\n", String, Section->K128 );
  1872. Msg ( "%s 256K size = %ld\n", String, Section->K256 );
  1873. GetPrivateProfileString ( SP, "512", OHPROBLEM, returnedString, MFL, dosnetFile );
  1874. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1875. Msg ( "ERROR: 512 section not found\n" );
  1876. }
  1877. dwSize = atoi ( returnedString );
  1878. if ( Section->Kh1+ThreeMegFudge() > dwSize ) {
  1879. Msg ( "ERROR: %s dosnet.inf's 512 value is %ld Use: %ld\n", String, dwSize, Section->Kh1 + ThreeMegFudge ( ) );
  1880. }
  1881. GetPrivateProfileString ( SP, "1K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1882. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1883. Msg ( "ERROR: 1024 section not found\n" );
  1884. }
  1885. dwSize = atoi ( returnedString );
  1886. if ( Section->K1+ThreeMegFudge() > dwSize ) {
  1887. Msg ( "ERROR: %s dosnet.inf's 1K value is %ld Use: %ld\n", String, dwSize, Section->K1 + ThreeMegFudge ( ));
  1888. }
  1889. GetPrivateProfileString ( SP, "2K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1890. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1891. Msg ( "ERROR: 2048 section not found\n" );
  1892. }
  1893. dwSize = atoi ( returnedString );
  1894. if ( Section->K2+ThreeMegFudge() > dwSize ) {
  1895. Msg ( "ERROR: %s dosnet.inf's 2K value is %ld Use: %ld\n", String, dwSize, Section->K2 + ThreeMegFudge ( ));
  1896. }
  1897. GetPrivateProfileString ( SP, "4K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1898. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1899. Msg ( "ERROR: 4096 section not found\n" );
  1900. }
  1901. dwSize = atoi ( returnedString );
  1902. if ( Section->K4+ThreeMegFudge() > dwSize ) {
  1903. Msg ( "ERROR: %s dosnet.inf's 4K value is %ld Use: %ld\n", String, dwSize, Section->K4 + ThreeMegFudge () );
  1904. }
  1905. GetPrivateProfileString ( SP, "8K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1906. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1907. Msg ( "ERROR: 8192 section not found\n" );
  1908. }
  1909. dwSize = atoi ( returnedString );
  1910. if ( Section->K8+ThreeMegFudge() > dwSize ) {
  1911. Msg ( "ERROR: %s dosnet.inf's 8K value is %ld Use: %ld\n", String, dwSize, Section->K8 + ThreeMegFudge() );
  1912. }
  1913. GetPrivateProfileString ( SP, "16K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1914. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1915. Msg ( "ERROR: 16384 section not found\n" );
  1916. }
  1917. dwSize = atoi ( returnedString );
  1918. if ( Section->K16+ThreeMegFudge() > dwSize ) {
  1919. Msg ( "ERROR: %s dosnet.inf's 16K value is %ld Use: %ld\n", String, dwSize, Section->K16 + ThreeMegFudge () );
  1920. }
  1921. GetPrivateProfileString ( SP, "32K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1922. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1923. Msg ( "ERROR: 32768 section not found\n" );
  1924. }
  1925. dwSize = atoi ( returnedString );
  1926. if ( Section->K32+ThreeMegFudge() > dwSize ) {
  1927. Msg ( "ERROR: %s dosnet.inf's 32K value is %ld Use: %ld\n", String, dwSize, Section->K32 + ThreeMegFudge () );
  1928. }
  1929. GetPrivateProfileString ( SP, "64K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1930. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1931. Msg ( "ERROR: 65536 section not found\n" );
  1932. }
  1933. dwSize = atoi ( returnedString );
  1934. if ( Section->K64+ThreeMegFudge() > dwSize ) {
  1935. Msg ( "ERROR: %s dosnet.inf's 64K value is %ld Use: %ld\n", String, dwSize, Section->K64 + ThreeMegFudge () );
  1936. }
  1937. GetPrivateProfileString ( SP, "128K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1938. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1939. Msg ( "ERROR: 131072 section not found\n" );
  1940. }
  1941. dwSize = atoi ( returnedString );
  1942. if ( Section->K128+ThreeMegFudge() > dwSize ) {
  1943. Msg ( "ERROR: %s dosnet.inf's 128K value is %ld Use: %ld\n", String, dwSize, Section->K128 + ThreeMegFudge () );
  1944. }
  1945. GetPrivateProfileString ( SP, "256K", OHPROBLEM, returnedString, MFL, dosnetFile );
  1946. if ( strncmp ( returnedString, OHPROBLEM, sizeof ( OHPROBLEM ) ) == 0 ) {
  1947. Msg ( "ERROR: 262144 section not found\n" );
  1948. }
  1949. dwSize = atoi ( returnedString );
  1950. if ( Section->K256+ThreeMegFudge() > dwSize ) {
  1951. Msg ( "ERROR: %s dosnet.inf's 256K value is %ld Use: %ld\n", String, dwSize, Section->K256 + ThreeMegFudge () );
  1952. }
  1953. // End of 5.0 stuff.
  1954. }
  1955. }
  1956. int __cdecl main(argc,argv)
  1957. int argc;
  1958. char * argv[];
  1959. {
  1960. HANDLE h;
  1961. int records, i;
  1962. WIN32_FIND_DATA fd;
  1963. time_t t;
  1964. DWORD dwSize;
  1965. char szFileName[MFL];
  1966. DWORD upgX86Work ;
  1967. DWORD upgX86Serv ;
  1968. DWORD upgAlphaWork ;
  1969. DWORD upgAlphaServ ;
  1970. if ( argc != 15 ) {
  1971. printf ( "You specified %d arguments - you need 15.\n\n", argc );
  1972. for ( i = 0; i < argc; ++i ) {
  1973. printf ( "Argument #%d >>>%s<<<\n", i, argv[i] );
  1974. }
  1975. printf ( "\n\n" );
  1976. Usage();
  1977. return(1);
  1978. }
  1979. // Initialize the critical section object.
  1980. //
  1981. InitializeCriticalSection ( &CriticalSection );
  1982. // Retail %platform% files.
  1983. //
  1984. i386Workstation.wNumFiles = 0;
  1985. AlphaWorkstation.wNumFiles = 0;
  1986. i386Server.wNumFiles = 0;
  1987. AlphaServer.wNumFiles = 0;
  1988. // Debugger files.
  1989. //
  1990. X86Dbg.wNumFiles = 0;
  1991. AlphaDbg.wNumFiles = 0;
  1992. strcpy ( szLogFile, argv[1] );
  1993. strcpy ( szWrkX86Src, argv[2] );
  1994. strcpy ( szWrkAlphaSrc, argv[3] );
  1995. strcpy ( szSrvX86Src, argv[4] );
  1996. strcpy ( szSrvAlphaSrc, argv[5] );
  1997. strcpy ( szCompX86Src, argv[6] );
  1998. strcpy ( szCompAlphaSrc, argv[7] );
  1999. strcpy ( szX86Dbg, argv[8] );
  2000. strcpy ( szAlphaDbg, argv[9] );
  2001. strcpy ( szX86DbgSource, argv[10] );
  2002. strcpy ( szAlphaDbgSource,argv[11] );
  2003. strcpy ( szEnlistDrv, argv[12] );
  2004. strcpy ( szWorkDstDrv, argv[13] );
  2005. strcpy ( szServDstDrv, argv[14] );
  2006. logFile = fopen ( argv[1], "a" );
  2007. if ( logFile == NULL ) {
  2008. printf("ERROR Couldn't open log file: %s\n",argv[1]);
  2009. return(1);
  2010. }
  2011. #define FOUR_POINT_O_MEDIA "FOUR_POINT_O_MEDIA"
  2012. // Determine if we are doing a build of NT 4.0 to do special NtDrive calculation.
  2013. //
  2014. if ( getenv ( FOUR_POINT_O_MEDIA ) != NULL ) {
  2015. bFourPtO = TRUE;
  2016. Msg ( "Performing a NT 4.0 build...\n" );
  2017. }
  2018. #define CHECKED_MEDIA "CHECKED_MEDIA"
  2019. // Determine if we are doing the CHECKED binaries.
  2020. //
  2021. if ( getenv ( CHECKED_MEDIA ) != NULL ) {
  2022. bChecked = TRUE;
  2023. Msg ( "Performing a CHECKED build...\n" );
  2024. }
  2025. // Do bit comparison to release shares on all copies ?
  2026. //
  2027. #define VERIFY_COPIES "VERIFY"
  2028. if ( getenv ( VERIFY_COPIES ) != NULL ) {
  2029. bVerifyBits = TRUE;
  2030. Msg ( "Will verify copies...\n" );
  2031. }
  2032. Header(argv,argc);
  2033. CreateDestinationDirs ();
  2034. // Get files that product installs.
  2035. //
  2036. bGetSizeLater = TRUE;
  2037. GetTheFiles ( szWrkX86Src, "layout.inf", X86_WRK );
  2038. GetTheFiles ( szSrvX86Src, "layout.inf", X86_SRV );
  2039. GetTheFiles ( szWrkAlphaSrc,"layout.inf", ALPHA_WRK );
  2040. GetTheFiles ( szSrvAlphaSrc,"layout.inf", ALPHA_SRV );
  2041. bGetSizeLater = FALSE;
  2042. GetTheFiles ( "C:\\nt\\private\\windows\\setup\\bom"/*szWrkX86Src*/, "_media.inx", DBGS_AND_NON_INSTALLED );
  2043. //ShowX86Work();
  2044. // Make some threads and copy all the files.
  2045. //
  2046. CopyTheFiles();
  2047. Msg ( "# files i386 Workstation = %ld\n", i386Workstation.wNumFiles );
  2048. Msg ( "# files i386 Server = %ld\n", i386Server.wNumFiles );
  2049. Msg ( "# files Alpha Workstation = %ld\n", AlphaWorkstation.wNumFiles );
  2050. Msg ( "# files Alpha Server = %ld\n", AlphaServer.wNumFiles );
  2051. if ( i386Workstation.wNumFiles > MAX_NUMBER_OF_FILES_IN_PRODUCT ||
  2052. i386Server.wNumFiles > MAX_NUMBER_OF_FILES_IN_PRODUCT ||
  2053. AlphaWorkstation.wNumFiles> MAX_NUMBER_OF_FILES_IN_PRODUCT ||
  2054. AlphaServer.wNumFiles > MAX_NUMBER_OF_FILES_IN_PRODUCT ) {
  2055. Msg ( "ERROR: Increase MAX_NUM in Files.C\n" );
  2056. }
  2057. //
  2058. //
  2059. //
  2060. Msg ( "========= Minimum setup install bytes required (all files uncompressed): ==========\n" );
  2061. //
  2062. //
  2063. TallyInstalled ( szWrkX86Src, szCompX86Src, &i386Workstation, &bytesX86Work, &lX86Work );
  2064. TallyInstalled ( szSrvX86Src, szCompX86Src, &i386Server, &bytesX86Serv, &lX86Serv );
  2065. TallyInstalled ( szWrkAlphaSrc, szCompAlphaSrc, &AlphaWorkstation,&bytesAlphaWork, &lAlphaWork );
  2066. TallyInstalled ( szSrvAlphaSrc, szCompAlphaSrc, &AlphaServer, &bytesAlphaServ, &lAlphaServ );
  2067. // Give tally counts.
  2068. //
  2069. Msg ( "bytesX86Work = %ld\n", bytesX86Work );
  2070. Msg ( "bytesX86Serv = %ld\n", bytesX86Serv );
  2071. Msg ( "bytesAlphaWork= %ld\n", bytesAlphaWork );
  2072. Msg ( "bytesAlphaServ= %ld\n", bytesAlphaServ );
  2073. #define FUDGE_PLUS 4*1024*1024 // ie, grow by 4 M for future growth.
  2074. // Print out an error if the above sizes are greater than the hardcode sizes in:
  2075. //
  2076. // txtsetup.sif's FreeDiskSpace = <value>
  2077. //
  2078. Msg ( "ERROR: do new thing for 5.0 FreeDiskSpace...\n" );
  2079. #define FREEDISKSPACE "FreeDiskSpace"
  2080. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szWrkX86Src );
  2081. dwSize = 1024 * GetTheSize ( szFileName, FREEDISKSPACE );
  2082. if ( dwSize < bytesX86Work ) {
  2083. Msg ( "ERROR: x86 Work txtsetup.sif's FreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, bytesX86Work, (FUDGE_PLUS+bytesX86Work)/1024 );
  2084. }
  2085. else {
  2086. Msg ( "Box size -- X86 Workstation: %ld M\n", dwSize/1024/1024 );
  2087. }
  2088. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szSrvX86Src );
  2089. dwSize = 1024 * GetTheSize ( szFileName, FREEDISKSPACE );
  2090. if ( dwSize < bytesX86Serv ) {
  2091. Msg ( "ERROR: x86 Serv txtsetup.sif's FreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, bytesX86Serv, (FUDGE_PLUS+bytesX86Serv)/1024 );
  2092. }
  2093. else {
  2094. Msg ( "Box size -- X86 Server: %ld M\n", dwSize/1024/1024 );
  2095. }
  2096. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szWrkAlphaSrc );
  2097. dwSize = 1024 * GetTheSize ( szFileName, FREEDISKSPACE );
  2098. if ( dwSize < bytesAlphaWork ) {
  2099. Msg ( "ERROR: Alpha Work txtsetup.sif's FreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, bytesAlphaWork, (FUDGE_PLUS+bytesAlphaWork)/1024 );
  2100. }
  2101. else {
  2102. Msg ( "Box size -- Alpha Workstation: %ld M\n", dwSize/1024/1024 );
  2103. }
  2104. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szSrvAlphaSrc );
  2105. dwSize = 1024 * GetTheSize ( szFileName, FREEDISKSPACE );
  2106. if ( dwSize < bytesAlphaServ ) {
  2107. Msg ( "ERROR: Alpha Serv txtsetup.sif's FreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, bytesAlphaServ, (FUDGE_PLUS+bytesAlphaServ)/1024 );
  2108. }
  2109. else {
  2110. Msg ( "Box size -- Alpha Server: %ld M\n", dwSize/1024/1024 );
  2111. }
  2112. Msg ( "========= Maximum setup local-source bytes required (some files compressed) : =====\n" );
  2113. Msg ( "Note: setup automagically adds in the inetsrv and drvlib.nic sizes, not in below...\n" );
  2114. ShowCheckLocalSpace ( &lX86Work, "lX86Work", szWrkX86Src );
  2115. ShowCheckLocalSpace ( &lX86Serv, "lX86Serv", szSrvX86Src );
  2116. ShowCheckLocalSpace ( &lAlphaWork, "lAlphaWork",szWrkAlphaSrc );
  2117. ShowCheckLocalSpace ( &lAlphaServ, "lAlphaServ",szSrvAlphaSrc );
  2118. Msg ( "========= Specify at least this much for Upgrade using the NT build with the least amount of footprint: =====\n" );
  2119. // We'll start off with 1057 as our smallest footprint build.
  2120. // This data will have to be checked each time we ship for the next to be release build.
  2121. //
  2122. // 1057 3.51 All files in product expanded at 16K cluster size.
  2123. #define X86WKS 87572480
  2124. #define X86SRV 92798976
  2125. #define ALPWKS 107757568
  2126. #define ALPSRV 114900992
  2127. upgX86Work = bytesX86Work - X86WKS;
  2128. upgX86Serv = bytesX86Serv - X86SRV;
  2129. upgAlphaWork = bytesAlphaWork - ALPWKS;
  2130. upgAlphaServ = bytesAlphaServ - ALPSRV;
  2131. Msg ( "X86Work = %ld\n", upgX86Work );
  2132. Msg ( "X86Serv = %ld\n", upgX86Serv );
  2133. Msg ( "AlphaWork= %ld\n", upgAlphaWork );
  2134. Msg ( "AlphaServ= %ld\n", upgAlphaServ );
  2135. //////
  2136. //////
  2137. ////// Hopefully for NT 5.0, setup won't require UpgradeFreeDiskSpace.
  2138. ////// Ask TedM/JaimeS.
  2139. //////
  2140. Msg ( "ERROR: do new thing for 5.0 UpgradeFreeDiskSpace...\n" );
  2141. // Print out an error if the above sizes are greater than the hardcode sizes in:
  2142. //
  2143. // txtsetup.sif's UpgradeFreeDiskSpace = <value>
  2144. //
  2145. #define UPGRADEFREEDISKSPACE "UpgradeFreeDiskSpace"
  2146. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szWrkX86Src );
  2147. dwSize = 1024 * GetTheSize ( szFileName, UPGRADEFREEDISKSPACE );
  2148. if ( dwSize < upgX86Work ) {
  2149. Msg ( "ERROR: x86 Work txtsetup.sif's UpgradeFreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, upgX86Work, (FUDGE_PLUS+upgX86Work)/1024 );
  2150. }
  2151. else {
  2152. Msg ( "Box size upgrade Wrk x86 = %ld M\n", dwSize/1024/1024 );
  2153. }
  2154. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szSrvX86Src );
  2155. dwSize = 1024 * GetTheSize ( szFileName, UPGRADEFREEDISKSPACE );
  2156. if ( dwSize < upgX86Serv ) {
  2157. Msg ( "ERROR: x86 Serv txtsetup.sif's UpgradeFreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, upgX86Serv, (FUDGE_PLUS+upgX86Serv)/1024 );
  2158. }
  2159. else {
  2160. Msg ( "Box size upgrade Srv x86 = %ld M\n", dwSize/1024/1204 );
  2161. }
  2162. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szWrkAlphaSrc );
  2163. dwSize = 1024 * GetTheSize ( szFileName, UPGRADEFREEDISKSPACE );
  2164. if ( dwSize < upgAlphaWork ) {
  2165. Msg ( "ERROR: Alpha Work txtsetup.sif's UpgradeFreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, upgAlphaWork, (FUDGE_PLUS+upgAlphaWork)/1024 );
  2166. }
  2167. else {
  2168. Msg ( "Box size upgrade Wrk Alpha = %ld M\n", dwSize/1024/1204 );
  2169. }
  2170. sprintf ( szFileName, "%s\\TXTSETUP.SIF", szSrvAlphaSrc );
  2171. dwSize = 1024 * GetTheSize ( szFileName, UPGRADEFREEDISKSPACE );
  2172. if ( dwSize < upgAlphaServ ) {
  2173. Msg ( "ERROR: Alpha Serv txtsetup.sif's UpgradeFreeDiskSpace %ld < %ld Fix with value: %ld\n", dwSize, upgAlphaServ, (FUDGE_PLUS+upgAlphaServ)/1024 );
  2174. }
  2175. else {
  2176. Msg ( "Box size upgrade Srv Alpha = %ld M\n", dwSize/1024/1204 );
  2177. }
  2178. Msg ( "==============================\n");
  2179. time(&t);
  2180. Msg ( "Time: %s", ctime(&t) );
  2181. Msg ( "==============================\n\n");
  2182. fclose(logFile);
  2183. return(0);
  2184. }