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.

1852 lines
54 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. MakeFLOP.C
  5. Abstract:
  6. Boot Floppy disk creation setup dialog
  7. Author:
  8. Bob Watson (a-robw)
  9. Revision History:
  10. 17 Feb 94 Written
  11. --*/
  12. //
  13. // Windows Include Files
  14. //
  15. #include <windows.h>
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <malloc.h>
  19. #include <tchar.h> // unicode macros
  20. //
  21. // app include files
  22. //
  23. #include "otnboot.h"
  24. #include "otnbtdlg.h"
  25. // local windows message
  26. #define NCDU_START_FILE_COPY (WM_USER +1)
  27. #ifdef JAPAN
  28. //
  29. // For DOS/V setup disk define
  30. //
  31. #define SETUP_DOSV_1 1
  32. #define SETUP_DOSV_2 2
  33. #endif
  34. //
  35. // Module Static Data
  36. //
  37. static BOOL bCopying; // TRUE when copying files, FALSE to abort
  38. static
  39. BOOL
  40. IsZeroIpAddr (
  41. IN PUSHORT pwIpVal
  42. )
  43. /*++
  44. Routine Description:
  45. evaluates an IP address array structure to determine if it's all
  46. zeroes
  47. Arguments:
  48. IN PUSHORT pwIpVal
  49. pointer to an IP address array of integers
  50. Return Value:
  51. TRUE if all 4 elements in the array are 0, otherwise
  52. FALSE
  53. --*/
  54. {
  55. PUSHORT pwTest;
  56. int nElem;
  57. pwTest = pwIpVal;
  58. nElem = 0;
  59. while (nElem < 4) {
  60. if (*pwTest == 0) {
  61. pwTest++;
  62. nElem++;
  63. } else {
  64. return FALSE;
  65. }
  66. }
  67. return TRUE;
  68. }
  69. static
  70. LPCTSTR
  71. GetDirPathFromUnc (
  72. IN LPCTSTR szPath
  73. )
  74. /*++
  75. Routine Description:
  76. Parses the Directories from a UNC path specification, removing the
  77. Server and share point.
  78. Arguments:
  79. IN LPCTSTR szPath
  80. pointer to a zero terminated UNC path specification.
  81. Return Value:
  82. Pointer to somewhere in the string passed in the argument list where
  83. the directory path begins or a pointer to an empty string if
  84. the path specified contains only a server and sharepoint.
  85. --*/
  86. {
  87. int nSlashCount = 0;
  88. LPTSTR szPathPtr;
  89. szPathPtr = (LPTSTR)szPath;
  90. if (IsUncPath(szPath)) {
  91. while (szPathPtr != 0) {
  92. if (*szPathPtr == cBackslash) nSlashCount++;
  93. ++szPathPtr;
  94. if (nSlashCount == 4) {
  95. break; // exit loop
  96. }
  97. }
  98. }
  99. if (nSlashCount != 4) {
  100. return cszEmptyString;
  101. } else {
  102. return szPathPtr;
  103. }
  104. }
  105. static
  106. BOOL
  107. GetServerAndSharepointFromUnc (
  108. IN LPCTSTR szPath,
  109. OUT LPTSTR szServer
  110. )
  111. /*++
  112. Routine Description:
  113. copies only the server and share point to the buffer provided
  114. by the caller.
  115. Arguments:
  116. IN LPCTSTR szPath
  117. UNC path to parse
  118. OUT LPCTSTR szServer
  119. buffer provided to receive the Server and sharepoint. The buffer
  120. is assumed to be large enough to recieve the data.
  121. Return Value:
  122. TRUE if successful
  123. FALSE if error
  124. --*/
  125. {
  126. int nSlashCount = 0;
  127. LPTSTR szPathPtr;
  128. LPTSTR szServPtr;
  129. szPathPtr = (LPTSTR)szPath;
  130. szServPtr = szServer;
  131. if (IsUncPath(szPath)) {
  132. while (szPathPtr != 0) {
  133. if (*szPathPtr == cBackslash) nSlashCount++;
  134. if (nSlashCount < 4) {
  135. *szServPtr++ = *szPathPtr++;
  136. } else {
  137. break; // exit loop
  138. }
  139. }
  140. }
  141. *szServPtr = 0; // terminate server name
  142. if (szServPtr == szServer) {
  143. return FALSE;
  144. } else {
  145. return TRUE;
  146. }
  147. }
  148. static
  149. DWORD
  150. UpdatePercentComplete (
  151. IN HWND hwndDlg,
  152. IN DWORD dwDone,
  153. IN DWORD dwTotal
  154. )
  155. /*++
  156. Routine Description:
  157. Update's the percent complete text in the dialog box using the
  158. information from the argument list.
  159. Arguments:
  160. IN HWND hwndDlg
  161. Handle to the dialog box window
  162. IN DWORD dwDone
  163. Units completed (Must be less than 42,949,671)
  164. IN DWORD dwTotal
  165. Total Units (must be less than 4,394,967,296)
  166. Return Value:
  167. Percent completed.
  168. --*/
  169. {
  170. DWORD dwPercent = 0;
  171. LPTSTR szOutBuff;
  172. szOutBuff = (LPTSTR)GlobalAlloc(GPTR, MAX_PATH_BYTES);
  173. if (szOutBuff != NULL) {
  174. dwPercent = ((dwDone * 100) + 50) / dwTotal;
  175. if (dwPercent > 100) dwPercent = 100;
  176. _stprintf (szOutBuff,
  177. GetStringResource (FMT_PERCENT_COMPLETE), dwPercent);
  178. SetDlgItemText (hwndDlg, NCDU_PERCENT_COMPLETE, szOutBuff);
  179. FREE_IF_ALLOC (szOutBuff);
  180. }
  181. return dwPercent;
  182. }
  183. static
  184. BOOL
  185. IsDestBootableDosFloppy (
  186. )
  187. /*++
  188. Routine Description:
  189. Checks device in boot file path (from global structure) to see any
  190. of the "signature" boot files are present
  191. Arguments:
  192. None
  193. Return Value:
  194. TRUE if any of the boot files were found on the poot file path drive
  195. FALSE if not
  196. --*/
  197. {
  198. LPTSTR szTestFileName;
  199. LPTSTR *pszThisFile;
  200. LPTSTR szNameStart;
  201. BOOL bReturn = FALSE;
  202. szTestFileName = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  203. if (szTestFileName == NULL) return FALSE;
  204. if (!IsUncPath(pAppInfo->szBootFilesPath)) {
  205. lstrcpy (szTestFileName, pAppInfo->szBootFilesPath);
  206. if (szTestFileName[lstrlen(szTestFileName)-1] == cBackslash) lstrcat(szTestFileName, cszBackslash);
  207. szNameStart = &szTestFileName[lstrlen(szTestFileName)];
  208. // go through list of "test files" and see if any are present
  209. for (pszThisFile = (LPTSTR *)&szBootIdFiles[0];
  210. *pszThisFile != NULL;
  211. pszThisFile++) {
  212. lstrcpy (szNameStart, *pszThisFile);
  213. if (FileExists(szTestFileName)) bReturn = TRUE;
  214. }
  215. // if here then none of the files could be found.
  216. } else {
  217. // if a UNC name return false
  218. }
  219. FREE_IF_ALLOC (szTestFileName);
  220. return bReturn;
  221. }
  222. static
  223. BOOL
  224. WriteMszToFile (
  225. IN HWND hwndDlg,
  226. IN LPCTSTR mszList,
  227. IN LPCTSTR szFileName,
  228. IN DWORD dwCreateFlags
  229. )
  230. /*++
  231. Routine Description:
  232. Function to output each entry in the "list" as a record in the "file"
  233. Entries that start with a left "square bracket" ([) will be
  234. prefixed with a new line. (for INF file formatting);
  235. NOTE: this function outputs ANSI characters to an ANSI file regardless
  236. if the _UNICODE flags are set or not.
  237. Arguments:
  238. IN HWND hwndDlg
  239. Handle to dialog box window
  240. IN LPCTSTR mszList
  241. Multi SZ list to write to the files
  242. IN LPCTSTR szFileName
  243. file name & path to write data to
  244. IN DWORD dwCreateFlags
  245. flags used by CreateFile function to open file.
  246. Return Value:
  247. TRUE no errors
  248. FALSE error (use GetLastError() to get more error data)
  249. --*/
  250. {
  251. HANDLE hFile;
  252. LPTSTR szEntry;
  253. DWORD dwBytes;
  254. LPSTR szAnsiBuffer;
  255. BOOL bReturn;
  256. MSG msg;
  257. #if _UNICODE
  258. szAnsiBuffer = (LPSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  259. if (szAnsiBuffer == NULL) return FALSE;
  260. *(PDWORD)szAnsiBuffer = 0L;
  261. #endif
  262. hFile = CreateFile (
  263. szFileName,
  264. GENERIC_WRITE,
  265. (FILE_SHARE_READ | FILE_SHARE_WRITE),
  266. NULL,
  267. dwCreateFlags,
  268. FILE_ATTRIBUTE_NORMAL,
  269. NULL);
  270. if (hFile != INVALID_HANDLE_VALUE) {
  271. for (szEntry = (LPTSTR)mszList;
  272. *szEntry != 0;
  273. szEntry += lstrlen(szEntry) + 1) {
  274. #if _UNICODE
  275. // convert output buffer to ANSI
  276. //#if defined(DBCS)
  277. WideCharToMultiByte(CP_ACP,
  278. 0L,
  279. szEntry,
  280. -1,
  281. szAnsiBuffer,
  282. SMALL_BUFFER_SIZE,
  283. NULL,
  284. NULL);
  285. //#else // defined(DBCS)
  286. // wcstombs (szAnsiBuffer, szEntry, SMALL_BUFFER_SIZE);
  287. //#endif // defined(DBCS)
  288. #else
  289. // copy ansi data to output buffer
  290. szAnsiBuffer = szEntry;
  291. #endif
  292. // output to dialog box
  293. SetDlgItemText (hwndDlg, NCDU_FROM_PATH,
  294. GetStringResource (FMT_INTERNAL_BUFFER));
  295. SetDlgItemText (hwndDlg, NCDU_TO_PATH, _tcslwr((LPTSTR)szFileName));
  296. if (*szAnsiBuffer == '[') {
  297. WriteFile (hFile, "\r\n", 2, &dwBytes, NULL);
  298. }
  299. WriteFile (hFile, szAnsiBuffer, strlen(szAnsiBuffer),
  300. &dwBytes, NULL);
  301. WriteFile (hFile, "\r\n", 2, &dwBytes, NULL);
  302. // check for messages
  303. while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
  304. TranslateMessage (&msg);
  305. DispatchMessage (&msg);
  306. }
  307. }
  308. CloseHandle (hFile);
  309. bReturn = TRUE;
  310. } else {
  311. bReturn = FALSE;
  312. }
  313. #if _UNICODE
  314. FREE_IF_ALLOC(szAnsiBuffer);
  315. #endif
  316. return bReturn;
  317. }
  318. static
  319. BOOL
  320. LoadProtocolIni (
  321. OUT LPTSTR mszProtocolIni,
  322. OUT LPTSTR mszNetFileList,
  323. OUT PDWORD pdwNetFileCount
  324. )
  325. /*++
  326. Routine Description:
  327. Creates the Protocol.Ini file using information from the user specified
  328. configuration
  329. Arguments:
  330. OUT LPTSTR mszProtocolIni
  331. buffer to receive the file data
  332. OUT LPTSTR mszNetFileList
  333. buffer to recieve the list of files to copy as determined by
  334. scanning the INF based on the selected protocol & driver info.
  335. OUT PDWORD pdwNetFileCount
  336. pointer to DWORD variable used to maintain a running total count of
  337. the number of files to copy for the % done calculation.
  338. Return Value:
  339. TRUE if Protocol.INI file contents were generated
  340. FALSE if an error occured.
  341. --*/
  342. {
  343. LPTSTR szThisString;
  344. LPTSTR szTemp;
  345. LPTSTR szTemp2;
  346. LPTSTR szNifKey;
  347. LPTSTR szSectionBuffer;
  348. LPCTSTR szDefaultValue = cszEmptyString;
  349. BOOL bTcp; // TRUE if protocol is TCP
  350. BOOL bIpx; // TRUE if protocol is IPX
  351. szSectionBuffer = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE * sizeof(TCHAR));
  352. szTemp = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  353. szTemp2 = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  354. szNifKey = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  355. if ((szSectionBuffer == NULL) ||
  356. (szTemp == NULL) ||
  357. (szTemp2 == NULL) ||
  358. (szNifKey == NULL)) {
  359. return FALSE;
  360. }
  361. //
  362. // TCP/IP & IPX are special cases, so detect them here
  363. //
  364. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szKey, cszTcpKey, lstrlen(cszTcpKey)) == 0) {
  365. bTcp = TRUE;
  366. bIpx = FALSE;
  367. } else if (_tcsnicmp(pAppInfo->piFloppyProtocol.szName, cszIpxKey, lstrlen(cszTcpKey)) == 0) {
  368. bTcp = FALSE;
  369. bIpx = TRUE;
  370. } else { // it's neither
  371. bTcp = FALSE;
  372. bIpx = FALSE;
  373. }
  374. if (szSectionBuffer != NULL) {
  375. *(PDWORD)szSectionBuffer = 0;
  376. } else {
  377. return FALSE;
  378. }
  379. //fill in text of protocol ini file
  380. //
  381. // add common files to Net dir list
  382. //
  383. lstrcpy (szTemp, pAppInfo->szDistPath);
  384. if (szTemp[lstrlen(szTemp)-1] != cBackslash) lstrcat (szTemp, cszBackslash);
  385. lstrcat (szTemp, cszOtnBootInf);
  386. GetPrivateProfileSection (cszOTNCommonFiles,
  387. szSectionBuffer, SMALL_BUFFER_SIZE, szTemp);
  388. for (szThisString = szSectionBuffer;
  389. *szThisString != 0;
  390. szThisString += (lstrlen(szThisString)+1)) {
  391. AddStringToMultiSz (mszNetFileList, GetKeyFromEntry (szThisString));
  392. *pdwNetFileCount += 1;
  393. }
  394. //
  395. // add in protocol specific files here
  396. //
  397. GetPrivateProfileSection (pAppInfo->piFloppyProtocol.szKey,
  398. szSectionBuffer, SMALL_BUFFER_SIZE, szTemp);
  399. for (szThisString = szSectionBuffer;
  400. *szThisString != 0;
  401. szThisString += (lstrlen(szThisString)+1)) {
  402. AddStringToMultiSz (mszNetFileList, GetKeyFromEntry (szThisString));
  403. *pdwNetFileCount += 1;
  404. }
  405. // [network.setup] section
  406. AddStringToMultiSz (mszProtocolIni, cszNetworkSetup);
  407. AddStringToMultiSz (mszProtocolIni, cszInfVersion);
  408. // examine & log netcard info
  409. lstrcpy (szTemp2, pAppInfo->niNetCard.szInfKey);
  410. _tcsupr (szTemp2);
  411. _stprintf (szTemp, fmtNetcardDefEntry,
  412. pAppInfo->niNetCard.szInfKey,
  413. szTemp2);
  414. AddStringToMultiSz (mszProtocolIni, szTemp);
  415. // load transport information
  416. if (!bTcp) {
  417. // load the ndishlp transport
  418. AddStringToMultiSz (mszProtocolIni, fmtTransportDefEntry);
  419. }
  420. // load transport from listbox
  421. lstrcpy (szTemp2, pAppInfo->piFloppyProtocol.szKey);
  422. _tcsupr (szTemp2);
  423. _stprintf (szTemp, fmtTransportItem,
  424. pAppInfo->piFloppyProtocol.szKey,
  425. szTemp2);
  426. AddStringToMultiSz (mszProtocolIni, szTemp);
  427. // format the bindings
  428. _stprintf (szTemp, fmtLana0Entry,
  429. pAppInfo->niNetCard.szInfKey,
  430. pAppInfo->piFloppyProtocol.szKey);
  431. AddStringToMultiSz (mszProtocolIni, szTemp);
  432. if (!bTcp) {
  433. _stprintf (szTemp, fmtLana1Entry,
  434. pAppInfo->niNetCard.szInfKey);
  435. AddStringToMultiSz (mszProtocolIni, szTemp);
  436. }
  437. // format the netcard settings to the default values
  438. // add the net card driver file to the list of NetDir files
  439. QuietGetPrivateProfileString (pAppInfo->niNetCard.szDeviceKey,
  440. cszNdis2, cszEmptyString,
  441. szTemp2, MAX_PATH,
  442. pAppInfo->niNetCard.szInf);
  443. // save filename
  444. lstrcpy (pAppInfo->niNetCard.szDriverFile, GetFileNameFromEntry(szTemp2));
  445. AddStringToMultiSz (mszNetFileList, pAppInfo->niNetCard.szDriverFile);
  446. *pdwNetFileCount += 1;
  447. // output section with default values
  448. _stprintf (szTemp2, fmtIniSection, pAppInfo->niNetCard.szInfKey);
  449. AddStringToMultiSz (mszProtocolIni, szTemp2);
  450. // lookup parameters
  451. GetPrivateProfileSection (pAppInfo->niNetCard.szNifKey,
  452. szSectionBuffer, MEDIUM_BUFFER_SIZE,
  453. pAppInfo->niNetCard.szInf);
  454. // process section. Format of each line is:
  455. // entry=IniName,DescriptionString,Type,OptionRange,Default,?
  456. // for each entry, I'll print:
  457. // IniName=Default
  458. // in the protocol.ini file
  459. //
  460. for (szThisString = szSectionBuffer;
  461. *szThisString != 0;
  462. szThisString += lstrlen(szThisString) +1) {
  463. if (_tcsnicmp(szThisString, cszDrivername, 10) == 0) {
  464. // drivername entry is a special case
  465. AddStringToMultiSz (mszProtocolIni, szThisString);
  466. } else {
  467. szDefaultValue = GetItemFromEntry(szThisString, 5);
  468. _stprintf (szTemp, fmtCmntIniKeyEntry,
  469. GetItemFromEntry(szThisString, 1),
  470. szDefaultValue);
  471. AddStringToMultiSz (mszProtocolIni, szTemp);
  472. }
  473. }
  474. //
  475. // add protman files to the list
  476. //
  477. QuietGetPrivateProfileString (cszProtmanInstall,
  478. cszNetdir, cszEmptyString,
  479. szSectionBuffer, MEDIUM_BUFFER_SIZE,
  480. pAppInfo->niNetCard.szInf);
  481. // add all files to the list
  482. szThisString = _tcstok (szSectionBuffer, cszComma);
  483. while (szThisString != NULL ) {
  484. AddStringToMultiSz (mszNetFileList, GetFileNameFromEntry (szThisString));
  485. *pdwNetFileCount += 1;
  486. szThisString = _tcstok (NULL, cszComma);
  487. }
  488. // do protman entry
  489. AddStringToMultiSz (mszProtocolIni, fmtProtmanSection);
  490. lstrcpy (szNifKey, cszProtman);
  491. GetPrivateProfileSection (szNifKey,
  492. szSectionBuffer, MEDIUM_BUFFER_SIZE,
  493. pAppInfo->niNetCard.szInf);
  494. // process section. Format of each line is:
  495. // entry=IniName,DescriptionString,Type,Default
  496. // for each entry, I'll print:
  497. // IniName=Default
  498. // in the protocol.ini file
  499. //
  500. for (szThisString = szSectionBuffer;
  501. *szThisString != 0;
  502. szThisString += lstrlen(szThisString) +1) {
  503. if (_tcsnicmp(szThisString, cszDrivername, lstrlen(cszDrivername)) == 0) {
  504. // drivername entry is a special case
  505. AddStringToMultiSz (mszProtocolIni, szThisString);
  506. } else {
  507. szDefaultValue = GetItemFromEntry(szThisString, 4);
  508. if (lstrlen(szDefaultValue) > 0) {
  509. _stprintf (szTemp, fmtIniKeyEntry,
  510. GetItemFromEntry(szThisString, 1),
  511. szDefaultValue);
  512. AddStringToMultiSz (mszProtocolIni, szTemp);
  513. }
  514. }
  515. }
  516. if (!bTcp) {
  517. // do NdisHlp section
  518. AddStringToMultiSz (mszProtocolIni, cszMsNdisHlp);
  519. lstrcpy (szNifKey, cszMsNdisHlpXif);
  520. GetPrivateProfileSection (szNifKey,
  521. szSectionBuffer, MEDIUM_BUFFER_SIZE,
  522. pAppInfo->niNetCard.szInf);
  523. // process section. Format of each line is:
  524. // drivername=name
  525. //
  526. for (szThisString = szSectionBuffer;
  527. *szThisString != 0;
  528. szThisString += lstrlen(szThisString) +1) {
  529. if (_tcsnicmp(szThisString, cszDrivername, lstrlen(cszDrivername)) == 0) {
  530. // drivername entry is a special case
  531. AddStringToMultiSz (mszProtocolIni, szThisString);
  532. } else {
  533. _stprintf (szTemp, fmtIniKeyEntry,
  534. GetKeyFromEntry(szThisString),
  535. GetItemFromEntry(szThisString, 1));
  536. AddStringToMultiSz (mszProtocolIni, szTemp);
  537. }
  538. }
  539. // do bindings
  540. _stprintf (szTemp, fmtBindingsEntry, pAppInfo->niNetCard.szInfKey);
  541. AddStringToMultiSz (mszProtocolIni, szTemp);
  542. }
  543. // do Protocol configuration
  544. _stprintf (szTemp2, fmtIniSection, pAppInfo->piFloppyProtocol.szKey);
  545. AddStringToMultiSz (mszProtocolIni, szTemp2);
  546. _stprintf (szNifKey, fmtXifEntry, pAppInfo->piFloppyProtocol.szKey);
  547. if (bTcp) {
  548. // format the TCP/IP protocol section here using information
  549. // from the previous dialog boxes
  550. AddStringToMultiSz (mszProtocolIni, fmtNBSessions);
  551. if (IsZeroIpAddr (&pAppInfo->tiTcpIpInfo.DefaultGateway[0])) {
  552. _stprintf (szTemp, fmtEmptyParam, cszDefaultGateway);
  553. } else {
  554. _stprintf (szTemp, fmtIpParam, cszDefaultGateway,
  555. pAppInfo->tiTcpIpInfo.DefaultGateway[0],
  556. pAppInfo->tiTcpIpInfo.DefaultGateway[1],
  557. pAppInfo->tiTcpIpInfo.DefaultGateway[2],
  558. pAppInfo->tiTcpIpInfo.DefaultGateway[3]);
  559. }
  560. AddStringToMultiSz (mszProtocolIni, szTemp);
  561. if (IsZeroIpAddr (&pAppInfo->tiTcpIpInfo.SubNetMask[0])) {
  562. _stprintf (szTemp, fmtEmptyParam, cszSubNetMask);
  563. } else {
  564. _stprintf (szTemp, fmtIpParam, cszSubNetMask,
  565. pAppInfo->tiTcpIpInfo.SubNetMask[0],
  566. pAppInfo->tiTcpIpInfo.SubNetMask[1],
  567. pAppInfo->tiTcpIpInfo.SubNetMask[2],
  568. pAppInfo->tiTcpIpInfo.SubNetMask[3]);
  569. }
  570. AddStringToMultiSz (mszProtocolIni, szTemp);
  571. if (IsZeroIpAddr (&pAppInfo->tiTcpIpInfo.IpAddr[0])) {
  572. _stprintf (szTemp, fmtEmptyParam, cszIPAddress);
  573. } else {
  574. _stprintf (szTemp, fmtIpParam, cszIPAddress,
  575. pAppInfo->tiTcpIpInfo.IpAddr[0],
  576. pAppInfo->tiTcpIpInfo.IpAddr[1],
  577. pAppInfo->tiTcpIpInfo.IpAddr[2],
  578. pAppInfo->tiTcpIpInfo.IpAddr[3]);
  579. }
  580. AddStringToMultiSz (mszProtocolIni, szTemp);
  581. _stprintf (szTemp, fmtIniKeyEntry,
  582. cszDisableDHCP,
  583. ((pAppInfo->bUseDhcp) ? csz0 : csz1));
  584. AddStringToMultiSz (mszProtocolIni, szTemp);
  585. AddStringToMultiSz (mszProtocolIni, cszTcpIpDriver);
  586. } else {
  587. // for Protocols other than TCP/IP get the info from the INF
  588. GetPrivateProfileSection (szNifKey,
  589. szSectionBuffer, MEDIUM_BUFFER_SIZE,
  590. pAppInfo->niNetCard.szInf);
  591. // process section. Format of each line is:
  592. // entry=IniName,DescriptionString,Type,OptionRange,Default
  593. // for each entry, I'll print:
  594. // IniName=Default
  595. // in the protocol.ini file
  596. //
  597. for (szThisString = szSectionBuffer;
  598. *szThisString != 0;
  599. szThisString += lstrlen(szThisString) +1) {
  600. if (_tcsnicmp(szThisString, cszDrivername, lstrlen(cszDrivername)) == 0) {
  601. // drivername entry is a special case
  602. AddStringToMultiSz (mszProtocolIni, szThisString);
  603. } else {
  604. if (bIpx && pAppInfo->niNetCard.bTokenRing) {
  605. // another special case is when IPX is used with Token Ring
  606. // cards.
  607. if (_tcsnicmp(GetItemFromEntry(szThisString,1),
  608. cszFrame, lstrlen(cszFrame)) == 0) {
  609. szDefaultValue = cszTokenRingEntry;
  610. }
  611. } else {
  612. szDefaultValue = GetItemFromEntry(szThisString, 5);
  613. }
  614. // only write parameters that actually have a default value
  615. // to write
  616. if (lstrlen(szDefaultValue) > 0) {
  617. _stprintf (szTemp, fmtIniKeyEntry,
  618. GetItemFromEntry(szThisString, 1),
  619. szDefaultValue);
  620. AddStringToMultiSz (mszProtocolIni, szTemp);
  621. }
  622. }
  623. }
  624. }
  625. _stprintf (szTemp, fmtBindingsEntry, pAppInfo->niNetCard.szInfKey);
  626. AddStringToMultiSz (mszProtocolIni, szTemp);
  627. // IPX does not get a LANABASE entry
  628. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szKey, cszIpxKey, lstrlen(cszIpxKey)) != 0) {
  629. AddStringToMultiSz (mszProtocolIni, fmtLanabase0);
  630. }
  631. FREE_IF_ALLOC (szSectionBuffer);
  632. FREE_IF_ALLOC (szTemp);
  633. FREE_IF_ALLOC (szTemp2);
  634. FREE_IF_ALLOC (szNifKey);
  635. return TRUE;
  636. }
  637. static
  638. BOOL
  639. LoadSystemIni (
  640. OUT LPTSTR mszList
  641. )
  642. /*++
  643. Routine Description:
  644. Routine to generate the System.INI file for the boot floppy
  645. Arguments:
  646. OUT LPTSTR mszList
  647. buffer to fill with system.INI records
  648. NOTE: BUFFER SIZE is assumed to be sufficient (i.e. it's not checked!)
  649. Return Value:
  650. TRUE if entries generated
  651. FALSE if error
  652. --*/
  653. {
  654. LPTSTR szTemp1;
  655. LPTSTR szTemp2;
  656. LPSTR szAnsi1;
  657. BOOL bReturn;
  658. szTemp1 = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  659. szTemp2 = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  660. szAnsi1 = (LPSTR)GlobalAlloc (GPTR, MAX_PATH);
  661. if ((szTemp1 != NULL) &&
  662. (szTemp2 != NULL) &&
  663. (szAnsi1 != NULL)) {
  664. AddStringToMultiSz (mszList, cszNetworkSection);
  665. AddStringToMultiSz (mszList, fmtNoFilesharing);
  666. AddStringToMultiSz (mszList, fmtNoPrintsharing);
  667. AddStringToMultiSz (mszList, fmtYesAutologon);
  668. _stprintf (szTemp1, fmtComputernameEntry, pAppInfo->szComputerName);
  669. CharToOemBuff (szTemp1, szAnsi1, (DWORD)(lstrlen(szTemp1)+1));
  670. #ifdef UNICODE
  671. mbstowcs (szTemp2, szAnsi1, MAX_PATH);
  672. #else
  673. lstrcpy (szTemp2, szAnsi1);
  674. #endif
  675. AddStringToMultiSz (mszList, szTemp2);
  676. AddStringToMultiSz (mszList, fmtLanaRootOnA);
  677. _stprintf (szTemp1, fmtUsernameEntry, pAppInfo->szUsername);
  678. CharToOemBuff (szTemp1, szAnsi1, (DWORD)(lstrlen(szTemp1)+1));
  679. #ifdef UNICODE
  680. mbstowcs (szTemp2, szAnsi1, MAX_PATH);
  681. #else
  682. lstrcpy (szTemp2, szAnsi1);
  683. #endif
  684. AddStringToMultiSz (mszList, szTemp2);
  685. _stprintf (szTemp1, fmtWorkgroupEntry, pAppInfo->szDomain);
  686. CharToOemBuff (szTemp1, szAnsi1, (DWORD)(lstrlen(szTemp1)+1));
  687. #ifdef UNICODE
  688. mbstowcs (szTemp2, szAnsi1, MAX_PATH);
  689. #else
  690. lstrcpy (szTemp2, szAnsi1);
  691. #endif
  692. AddStringToMultiSz (mszList, szTemp2);
  693. AddStringToMultiSz (mszList, fmtNoReconnect);
  694. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szName, cszNetbeuiKey, lstrlen(cszNetbeuiKey)) == 0) {
  695. // only NetBEUI gets this
  696. AddStringToMultiSz (mszList, fmtNoDirectHost);
  697. }
  698. AddStringToMultiSz (mszList, fmtNoDosPopHotKey);
  699. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szKey, cszIpxKey, lstrlen(cszIpxKey)) == 0) {
  700. AddStringToMultiSz (mszList, fmtLmLogon1);
  701. } else {
  702. AddStringToMultiSz (mszList, fmtLmLogon0);
  703. }
  704. _stprintf (szTemp1, fmtLogonDomainEntry, pAppInfo->szDomain);
  705. CharToOemBuff (szTemp1, szAnsi1, (DWORD)(lstrlen(szTemp1)+1));
  706. #ifdef UNICODE
  707. mbstowcs (szTemp2, szAnsi1, MAX_PATH);
  708. #else
  709. lstrcpy (szTemp2, szAnsi1);
  710. #endif
  711. AddStringToMultiSz (mszList, szTemp2);
  712. AddStringToMultiSz (mszList, fmtPreferredRedirFull);
  713. AddStringToMultiSz (mszList, fmtAutostartFull);
  714. AddStringToMultiSz (mszList, fmtMaxConnections);
  715. // network driver section
  716. AddStringToMultiSz (mszList, fmtNetworkDriversSection);
  717. _stprintf (szTemp1, fmtNetcardEntry, pAppInfo->niNetCard.szDriverFile);
  718. CharToOemBuff (szTemp1, szAnsi1, (DWORD)(lstrlen(szTemp1)+1));
  719. #ifdef UNICODE
  720. mbstowcs (szTemp2, szAnsi1, MAX_PATH);
  721. #else
  722. lstrcpy (szTemp2, szAnsi1);
  723. #endif
  724. AddStringToMultiSz (mszList, szTemp2);
  725. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szName, cszTCP, lstrlen(cszTCP)) == 0 ) {
  726. // tcpip Transport
  727. lstrcpy (szTemp1, fmtTcpTransportEntry);
  728. } else {
  729. lstrcpy (szTemp1, fmtNdisTransportEntry);
  730. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szName, cszNetbeui, lstrlen(cszNetbeui)) == 0 ) {
  731. // add NetBEUI string
  732. lstrcat (szTemp1, fmtNetbeuiAddon);
  733. }
  734. }
  735. AddStringToMultiSz (mszList, szTemp1);
  736. AddStringToMultiSz (mszList, fmtDevdir);
  737. AddStringToMultiSz (mszList, fmtLoadRmDrivers);
  738. // password file list (header only)
  739. AddStringToMultiSz (mszList, fmtPasswordListSection);
  740. bReturn = TRUE;
  741. } else {
  742. bReturn = FALSE;
  743. }
  744. FREE_IF_ALLOC (szTemp1);
  745. FREE_IF_ALLOC (szTemp2);
  746. FREE_IF_ALLOC (szAnsi1);
  747. return bReturn;
  748. }
  749. static
  750. BOOL
  751. LoadAutoexecBat (
  752. OUT LPTSTR mszList
  753. )
  754. /*++
  755. Routine Description:
  756. Routine to generate the Autoexec.bat file for the boot floppy
  757. Arguments:
  758. OUT LPTSTR mszList
  759. Buffer to write autoexec.bat entries into
  760. NOTE: BUFFER SIZE is assumed to be sufficient (i.e. it's not checked!)
  761. Return Value:
  762. TRUE if entries generated
  763. FALSE if error
  764. --*/
  765. {
  766. LPTSTR szTemp;
  767. LPTSTR szTemp2;
  768. LPTSTR szSectionBuffer;
  769. LPTSTR szDir;
  770. LPTSTR szEntry;
  771. szSectionBuffer = GlobalAlloc (GPTR, (SMALL_BUFFER_SIZE * sizeof(TCHAR)));
  772. szTemp = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  773. szTemp2 = (LPTSTR)GlobalAlloc (GPTR, MAX_PATH_BYTES);
  774. if ((szSectionBuffer == NULL) ||
  775. (szTemp == NULL) ||
  776. (szTemp2 == NULL)) {
  777. return FALSE;
  778. }
  779. #ifdef JAPAN
  780. // fixed kkntbug #12382
  781. // NCAdmin:"[] Make Japanese startup disks" is not functioning.
  782. if (bJpnDisk) {
  783. AddStringToMultiSz (mszList, GetStringResource (FMT_LOAD_AUTOEXEC_ECHO));
  784. AddStringToMultiSz (mszList, fmtPause);
  785. }
  786. #endif
  787. AddStringToMultiSz (mszList, fmtPathSpec);
  788. // load network starting commands from INF
  789. // get commands from INF for this protocol
  790. //
  791. // put INF filename into szTemp
  792. //
  793. lstrcpy (szTemp, pAppInfo->szDistPath);
  794. if (szTemp[lstrlen(szTemp)-1] != cBackslash) lstrcat (szTemp, cszBackslash);
  795. lstrcat (szTemp, cszAppInfName);
  796. //
  797. // put key name made from protocol and "_autoexec" into szTemp2
  798. //
  799. lstrcpy (szTemp2, pAppInfo->piFloppyProtocol.szKey);
  800. lstrcat (szTemp2, fmtAutoexec);
  801. GetPrivateProfileSection (szTemp2, szSectionBuffer,
  802. SMALL_BUFFER_SIZE, szTemp);
  803. for (szEntry = szSectionBuffer;
  804. *szEntry != 0;
  805. szEntry += (lstrlen(szEntry) + 1)) {
  806. lstrcpy (szTemp, fmtNetPrefix);
  807. lstrcat (szTemp, GetKeyFromEntry(szEntry));
  808. AddStringToMultiSz (mszList, szTemp);
  809. }
  810. // create network connection commands
  811. if (GetServerAndSharepointFromUnc(pAppInfo->piTargetProtocol.szDir, szTemp2)) {
  812. _stprintf (szTemp, fmtNetUseDrive, szTemp2);
  813. AddStringToMultiSz (mszList, szTemp);
  814. } else {
  815. AddStringToMultiSz (mszList,
  816. GetStringResource (FMT_CONNECTING_COMMENT));
  817. }
  818. // create setup command
  819. szDir = (LPTSTR)GetDirPathFromUnc(pAppInfo->piTargetProtocol.szDir);
  820. if (lstrlen(szDir) > 0) {
  821. AddStringToMultiSz (mszList,
  822. GetStringResource (FMT_RUNNING_SETUP_COMMENT));
  823. _stprintf (szTemp, fmtSetupCommand,
  824. szDir, pAppInfo->szTargetSetupCmd);
  825. AddStringToMultiSz (mszList, szTemp);
  826. } else {
  827. AddStringToMultiSz (mszList,
  828. GetStringResource (FMT_OTN_COMMENT));
  829. }
  830. FREE_IF_ALLOC (szSectionBuffer);
  831. FREE_IF_ALLOC (szTemp);
  832. FREE_IF_ALLOC (szTemp2);
  833. return TRUE;
  834. }
  835. static
  836. BOOL
  837. LoadConfigSys (
  838. OUT LPTSTR mszList
  839. )
  840. /*++
  841. Routine Description:
  842. Routine to write Config.Sys entries for the Boot Floppy.
  843. Arguments:
  844. OUT LPTSTR mszList
  845. Buffer to write Config.sys commands into
  846. NOTE: BUFFER SIZE is assumed to be sufficient (i.e. it's not checked!)
  847. Return Value:
  848. TRUE
  849. --*/
  850. {
  851. AddStringToMultiSz (mszList, fmtFilesParam);
  852. AddStringToMultiSz (mszList, fmtDeviceIfsHlpSys);
  853. AddStringToMultiSz (mszList, fmtLastDrive);
  854. if (GetBootDiskDosVersion (pAppInfo->szBootFilesPath) >= 5) {
  855. AddStringToMultiSz (mszList, fmtLoadHiMem);
  856. AddStringToMultiSz (mszList, fmtLoadEMM386);
  857. AddStringToMultiSz (mszList, fmtDosHigh);
  858. #ifdef JAPAN
  859. // fixed kkntbug #12382
  860. // NCAdmin:"[] Make Japanese startup disks" is not functioning.
  861. if (bJpnDisk) {
  862. AddStringToMultiSz (mszList, fmtBilingual);
  863. AddStringToMultiSz (mszList, fmtFontSys);
  864. AddStringToMultiSz (mszList, fmtDispSys);
  865. AddStringToMultiSz (mszList, fmtKeyboard);
  866. AddStringToMultiSz (mszList, fmtNlsFunc);
  867. }
  868. #endif
  869. }
  870. return TRUE;
  871. }
  872. static
  873. BOOL
  874. MakeFlopDlg_NCDU_START_FILE_COPY (
  875. IN HWND hwndDlg,
  876. IN WPARAM wParam,
  877. IN LPARAM lParam
  878. )
  879. /*++
  880. Routine Description:
  881. Processes NCDU_START_FILE_COPY message. Allocates buffers to be
  882. used in creating boot and network configuration files. Fills
  883. them in using information from the pAppInfo struct then
  884. writes them to the output files on the destination drive.
  885. Once the generated files have been written, the other
  886. files are copied from the OTN dir to the destination drive.
  887. If all goes well, then the dialog box is closed.
  888. Arguments:
  889. IN HWND hwndDlg
  890. Handle to dialog box window
  891. IN WPARAM wParam
  892. Not Used
  893. IN LPARAM lParam
  894. Not Used
  895. Return Value:
  896. FALSE.
  897. --*/
  898. {
  899. LPTSTR mszNetFileList;
  900. LPTSTR mszProtocolIni;
  901. LPTSTR mszSystemIni;
  902. LPTSTR mszAutoexecBat;
  903. LPTSTR mszConfigSys;
  904. DWORD dwNetFileCount = 0;
  905. DWORD dwFilesCopied = 0;
  906. DWORD dwDestClusterSize = 0;
  907. DWORD dwFileBytesToCopy = 0;
  908. DWORD dwDestFreeSpace = 0;
  909. DWORD dwFileSize;
  910. LPTSTR szSrcFile;
  911. LPTSTR szSrcFilePart;
  912. LPTSTR szDestFile;
  913. LPTSTR szDestFilePart;
  914. LPTSTR szThisFile;
  915. LPTSTR szInfFile;
  916. int nMbResult;
  917. BOOL bBootable;
  918. BOOL bAborted = FALSE;
  919. DWORD dwSystemFileSize;
  920. MSG msg;
  921. UINT nExitCode = IDOK;
  922. #ifdef JAPAN
  923. LPTSTR szThisString;
  924. LPTSTR szVolumeName;
  925. LPTSTR szTextString;
  926. LPTSTR szSectionBuffer;
  927. LPTSTR szDOSVDirectory;
  928. LPTSTR szTemp;
  929. #endif
  930. mszNetFileList = (LPTSTR)GlobalAlloc(GPTR, MEDIUM_BUFFER_SIZE);
  931. mszProtocolIni = (LPTSTR)GlobalAlloc(GPTR, MEDIUM_BUFFER_SIZE);
  932. mszSystemIni = (LPTSTR)GlobalAlloc(GPTR, MEDIUM_BUFFER_SIZE);
  933. mszAutoexecBat = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  934. mszConfigSys = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  935. szSrcFile = (LPTSTR)GlobalAlloc(GPTR, MAX_PATH_BYTES);
  936. szDestFile = (LPTSTR)GlobalAlloc(GPTR, MAX_PATH_BYTES);
  937. szInfFile = (LPTSTR)GlobalAlloc(GPTR, MAX_PATH_BYTES);
  938. #ifdef JAPAN
  939. szVolumeName = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  940. szTextString = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  941. szSectionBuffer = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  942. szDOSVDirectory = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  943. szTemp = (LPTSTR)GlobalAlloc(GPTR, SMALL_BUFFER_SIZE);
  944. #endif
  945. if ((mszNetFileList != NULL) &&
  946. (mszProtocolIni != NULL) &&
  947. (mszConfigSys != NULL) &&
  948. (mszAutoexecBat != NULL) &&
  949. (szSrcFile != NULL) &&
  950. (szDestFile != NULL) &&
  951. (szInfFile != NULL) &&
  952. #ifdef JAPAN
  953. (szVolumeName != NULL) &&
  954. (szTextString != NULL) &&
  955. (szSectionBuffer != NULL) &&
  956. (szDOSVDirectory != NULL) &&
  957. (szTemp != NULL) &&
  958. #endif
  959. (mszSystemIni != NULL)) {
  960. *(PDWORD)mszNetFileList = 0L;
  961. *(PDWORD)mszProtocolIni = 0L;
  962. *(PDWORD)mszSystemIni = 0L;
  963. *(PDWORD)mszAutoexecBat = 0L;
  964. *(PDWORD)mszConfigSys = 0L;
  965. #ifdef JAPAN
  966. if (wParam) {
  967. wsprintf(szTemp, GetStringResource (FMT_OTN_BOOT_FILES_DOSV), wParam);
  968. SetDlgItemText (hwndDlg, NCDU_COPY_APPNAME, szTemp);
  969. }
  970. #endif
  971. szDestFilePart = szDestFile; // to initialize the var
  972. lstrcpy (szInfFile, pAppInfo->szDistPath);
  973. if (szInfFile[lstrlen(szInfFile)-1] != cBackslash)
  974. lstrcat (szInfFile, cszBackslash);
  975. lstrcat (szInfFile, cszAppInfName);
  976. if (GetPrivateProfileString (cszSizes, csz_SystemFileSize_,
  977. cszEmptyString, szSrcFile, MAX_PATH, szInfFile) > 0) {
  978. // a value was found so get the filesize value from the string
  979. dwSystemFileSize = GetSizeFromInfString (szSrcFile);
  980. } else {
  981. dwSystemFileSize = 0;
  982. }
  983. #ifdef JAPAN
  984. if (wParam == SETUP_DOSV_2) {
  985. _stprintf (szTextString,
  986. GetStringResource (FMT_LOAD_NET_CLIENT2),
  987. GetStringResource (
  988. (pAppInfo->mtBootDriveType == F3_1Pt44_512) ?
  989. CSZ_35_HD : CSZ_525_HD),
  990. pAppInfo->szBootFilesPath);
  991. while(1) {
  992. GetVolumeInformation(
  993. pAppInfo->szBootFilesPath,
  994. szVolumeName,
  995. SMALL_BUFFER_SIZE,
  996. NULL,
  997. NULL,
  998. NULL,
  999. NULL,
  1000. 0);
  1001. if (lstrcmp(szVolumeName, cszDOSVLabel1)) {
  1002. SetVolumeLabel(pAppInfo->szBootFilesPath, cszDOSVLabel2);
  1003. break;
  1004. }
  1005. else {
  1006. nMbResult = DisplayMessageBox (
  1007. hwndDlg,
  1008. NCDU_DRIVE_NOT_BOOTDISK,
  1009. FMT_LOAD_NET_CLIENT2_TITLE,
  1010. MB_OKCANCEL_TASK_EXCL);
  1011. if (nMbResult == IDCANCEL) {
  1012. bCopying = FALSE;
  1013. break;
  1014. }
  1015. }
  1016. }
  1017. }
  1018. #endif
  1019. if (!(bBootable = IsDestBootableDosFloppy())) {
  1020. #ifdef JAPAN
  1021. if (wParam == SETUP_DOSV_2) {
  1022. while ((nMbResult = DisplayMessageBox (
  1023. hwndDlg,
  1024. NCDU_DRIVE_NOT_BOOTDISK,
  1025. 0,
  1026. MB_OKCANCEL_TASK_INFO)) != IDCANCEL) {
  1027. if ((bBootable = IsDestBootableDosFloppy())) {
  1028. break;
  1029. }
  1030. }
  1031. if (nMbResult == IDCANCEL) bCopying = FALSE;
  1032. }
  1033. if (bCopying == FALSE)
  1034. #endif
  1035. AddMessageToExitList (pAppInfo, NCDU_COPY_TO_FLOPPY);
  1036. }
  1037. #ifdef JAPAN
  1038. if (wParam == SETUP_DOSV_1)
  1039. SetVolumeLabel(pAppInfo->szBootFilesPath, cszDOSVLabel1);
  1040. #endif
  1041. #ifdef JAPAN
  1042. if ((wParam == SETUP_DOSV_2) || !wParam) {
  1043. #endif
  1044. // generate protocol.ini
  1045. LoadProtocolIni (
  1046. mszProtocolIni,
  1047. mszNetFileList,
  1048. &dwNetFileCount);
  1049. dwNetFileCount += 1; // account for protocol.ini file
  1050. // generate system.ini
  1051. LoadSystemIni (mszSystemIni);
  1052. dwNetFileCount += 1;
  1053. #ifdef JAPAN
  1054. }
  1055. else {
  1056. if (QuietGetPrivateProfileString (cszOtnInstall, cszDOSV, cszEmptyString,
  1057. szDOSVDirectory, SMALL_BUFFER_SIZE, szInfFile) > 0) {
  1058. GetPrivateProfileSection (cszOTNDOSVFiles,
  1059. szSectionBuffer, SMALL_BUFFER_SIZE, szInfFile);
  1060. for (szThisString = szSectionBuffer;
  1061. *szThisString != 0;
  1062. szThisString += (lstrlen(szThisString)+1)) {
  1063. lstrcpy(szTemp, szDOSVDirectory);
  1064. lstrcat(szTemp, cszBackslash);
  1065. lstrcat(szTemp, GetKeyFromEntry (szThisString));
  1066. AddStringToMultiSz (mszNetFileList, szTemp);
  1067. dwNetFileCount += 1;
  1068. }
  1069. }
  1070. GetPrivateProfileSection (cszDOSVCommonFiles,
  1071. szSectionBuffer, SMALL_BUFFER_SIZE, szInfFile);
  1072. for (szThisString = szSectionBuffer;
  1073. *szThisString != 0;
  1074. szThisString += (lstrlen(szThisString)+1)) {
  1075. AddStringToMultiSz (mszNetFileList, GetKeyFromEntry (szThisString));
  1076. dwNetFileCount += 1;
  1077. }
  1078. }
  1079. #endif
  1080. // generate autoexec.bat
  1081. LoadAutoexecBat (mszAutoexecBat);
  1082. dwNetFileCount += 1;
  1083. #ifdef JAPAN
  1084. if ((wParam == SETUP_DOSV_1) || !wParam) {
  1085. #endif
  1086. // generate config.sys
  1087. LoadConfigSys (mszConfigSys);
  1088. dwNetFileCount += 1;
  1089. #ifdef JAPAN
  1090. }
  1091. #endif
  1092. // determine number of bytes to copy to destination
  1093. dwDestClusterSize = GetClusterSizeOfDisk (pAppInfo->szBootFilesPath);
  1094. dwFileBytesToCopy = 0; // clear
  1095. #ifdef JAPAN
  1096. if ((wParam == SETUP_DOSV_2) || !wParam) {
  1097. #endif
  1098. // get size of file that will be written
  1099. dwFileBytesToCopy += GetMultiSzLen (mszProtocolIni);
  1100. // and round up to the next sector size
  1101. dwFileBytesToCopy += dwDestClusterSize -
  1102. (dwFileBytesToCopy % dwDestClusterSize);
  1103. // get size of file that will be written
  1104. dwFileBytesToCopy += GetMultiSzLen (mszSystemIni);
  1105. // and round up to the next sector size
  1106. dwFileBytesToCopy += dwDestClusterSize -
  1107. (dwFileBytesToCopy % dwDestClusterSize);
  1108. #ifdef JAPAN
  1109. }
  1110. #endif
  1111. // get size of file that will be written
  1112. dwFileBytesToCopy += GetMultiSzLen (mszAutoexecBat);
  1113. // and round up to the next sector size
  1114. dwFileBytesToCopy += dwDestClusterSize -
  1115. (dwFileBytesToCopy % dwDestClusterSize);
  1116. #ifdef JAPAN
  1117. if ((wParam == SETUP_DOSV_1) || !wParam) {
  1118. #endif
  1119. // get size of file that will be written
  1120. dwFileBytesToCopy += GetMultiSzLen (mszConfigSys);
  1121. // and round up to the next sector size
  1122. dwFileBytesToCopy += dwDestClusterSize -
  1123. (dwFileBytesToCopy % dwDestClusterSize);
  1124. #ifdef JAPAN
  1125. }
  1126. #endif
  1127. #ifdef JAPAN
  1128. if ((wParam == SETUP_DOSV_1) || !wParam) {
  1129. #endif
  1130. // get size of files in copy list and add to internally created files
  1131. lstrcpy (szSrcFile, pAppInfo->piFloppyProtocol.szDir);
  1132. if (szSrcFile[lstrlen(szSrcFile)-1] != cBackslash) lstrcat (szSrcFile, cszBackslash);
  1133. szSrcFilePart = &szSrcFile[lstrlen(szSrcFile)];
  1134. #ifdef JAPAN
  1135. }
  1136. #endif
  1137. for (szThisFile = mszNetFileList;
  1138. *szThisFile != 0;
  1139. szThisFile += (lstrlen(szThisFile) + 1)) {
  1140. // make full path of filename
  1141. lstrcpy (szSrcFilePart, szThisFile);
  1142. // get the size of the file and add it to the total
  1143. dwFileSize = QuietGetFileSize (szSrcFile);
  1144. if (dwFileSize != 0xFFFFFFFF) {
  1145. dwFileBytesToCopy += dwFileSize;
  1146. // and round to the next larger allocation unit
  1147. dwFileBytesToCopy += dwDestClusterSize -
  1148. (dwFileBytesToCopy % dwDestClusterSize);
  1149. }
  1150. }
  1151. dwDestFreeSpace = ComputeFreeSpace (pAppInfo->szBootFilesPath);
  1152. if (dwDestFreeSpace < dwFileBytesToCopy) {
  1153. DisplayMessageBox (hwndDlg,
  1154. NCDU_INSUFFICIENT_DISK_SPACE,
  1155. 0,
  1156. MB_OK_TASK_EXCL);
  1157. bCopying = FALSE;
  1158. bAborted = TRUE;
  1159. nExitCode = IDCANCEL; // operation ended in error
  1160. } else {
  1161. if (!bBootable) {
  1162. // see if there will be room to add the system files
  1163. // later...
  1164. dwFileBytesToCopy += dwSystemFileSize;
  1165. if (dwDestFreeSpace < dwFileBytesToCopy) {
  1166. if (DisplayMessageBox (hwndDlg,
  1167. NCDU_SYSTEM_MAY_NOT_FIT,
  1168. 0,
  1169. MB_OKCANCEL_TASK_INFO | MB_DEFBUTTON2) == IDCANCEL) {
  1170. bCopying = FALSE;
  1171. bAborted = TRUE;
  1172. nExitCode = IDCANCEL; // operation ended in error
  1173. } else {
  1174. // they want to continue so stick a message in the
  1175. // exit messages
  1176. AddMessageToExitList (pAppInfo, NCDU_SMALL_DISK_WARN);
  1177. }
  1178. }
  1179. }
  1180. }
  1181. if (bCopying) {
  1182. // write files to root directory
  1183. lstrcpy (szDestFile, pAppInfo->szBootFilesPath);
  1184. if (szDestFile[lstrlen(szDestFile)-1] != cBackslash) lstrcat (szDestFile, cszBackslash);
  1185. szDestFilePart = &szDestFile[lstrlen(szDestFile)];
  1186. // make sure destination path exists
  1187. CreateDirectoryFromPath (szDestFile, NULL);
  1188. #ifdef JAPAN
  1189. if ((wParam == SETUP_DOSV_1) || !wParam) {
  1190. #endif
  1191. // config.sys
  1192. lstrcpy (szDestFilePart, cszConfigSys);
  1193. if (WriteMszToFile (hwndDlg, mszConfigSys, szDestFile, CREATE_ALWAYS)) {
  1194. UpdatePercentComplete (hwndDlg, ++dwFilesCopied, dwNetFileCount);
  1195. } else {
  1196. // bail out here since there was a copy error
  1197. nMbResult = MessageBox (
  1198. hwndDlg,
  1199. GetStringResource (CSZ_UNABLE_COPY),
  1200. szDestFile,
  1201. MB_OKCANCEL_TASK_EXCL);
  1202. if (nMbResult == IDCANCEL) {
  1203. bCopying = FALSE;
  1204. nExitCode = IDCANCEL; // operation ended in error
  1205. } else {
  1206. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1207. }
  1208. }
  1209. #ifdef JAPAN
  1210. }
  1211. #endif
  1212. }
  1213. if (bCopying) {
  1214. // autoexec.bat
  1215. lstrcpy (szDestFilePart, cszAutoexecBat);
  1216. if (WriteMszToFile (hwndDlg, mszAutoexecBat, szDestFile, CREATE_ALWAYS)) {
  1217. UpdatePercentComplete (hwndDlg, ++dwFilesCopied, dwNetFileCount);
  1218. } else {
  1219. // bail out here since there was a copy error
  1220. nMbResult = MessageBox (
  1221. hwndDlg,
  1222. GetStringResource (CSZ_UNABLE_COPY),
  1223. szDestFile,
  1224. MB_OKCANCEL_TASK_EXCL);
  1225. if (nMbResult == IDCANCEL) {
  1226. bCopying = FALSE;
  1227. nExitCode = IDCANCEL; // operation ended in error
  1228. } else {
  1229. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1230. }
  1231. }
  1232. }
  1233. if (bCopying) {
  1234. // write INI files
  1235. // make NET subdir
  1236. lstrcpy (szDestFilePart, cszNet);
  1237. CreateDirectory (szDestFile, NULL);
  1238. // add net sub dir to dest path
  1239. if (szDestFile[lstrlen(szDestFile)-1] != cBackslash) lstrcat (szDestFile, cszBackslash);
  1240. szDestFilePart = &szDestFile[lstrlen(szDestFile)];
  1241. #ifdef JAPAN
  1242. if ((wParam == SETUP_DOSV_2) || !wParam) {
  1243. #endif
  1244. lstrcpy (szDestFilePart, cszSystemIni);
  1245. if (WriteMszToFile (hwndDlg, mszSystemIni, szDestFile, CREATE_ALWAYS)) {
  1246. UpdatePercentComplete (hwndDlg, ++dwFilesCopied, dwNetFileCount);
  1247. } else {
  1248. // bail out here since there was a copy error
  1249. nMbResult = MessageBox (
  1250. hwndDlg,
  1251. GetStringResource (CSZ_UNABLE_COPY),
  1252. szDestFile,
  1253. MB_OKCANCEL_TASK_EXCL);
  1254. if (nMbResult == IDCANCEL) {
  1255. bCopying = FALSE;
  1256. nExitCode = IDCANCEL; // operation ended in error
  1257. } else {
  1258. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1259. }
  1260. }
  1261. #ifdef JAPAN
  1262. }
  1263. else {
  1264. // make DOSV subdir
  1265. lstrcpy (szDestFilePart, cszDOSV);
  1266. CreateDirectory (szDestFile, NULL);
  1267. }
  1268. #endif
  1269. }
  1270. #ifdef JAPAN
  1271. if ((wParam == SETUP_DOSV_2) || !wParam) {
  1272. #endif
  1273. if (bCopying) {
  1274. lstrcpy (szDestFilePart, cszProtocolIni);
  1275. if (WriteMszToFile (hwndDlg, mszProtocolIni, szDestFile, CREATE_ALWAYS)) {
  1276. UpdatePercentComplete (hwndDlg, ++dwFilesCopied, dwNetFileCount);
  1277. } else {
  1278. // bail out here since there was a copy error
  1279. nMbResult = MessageBox (
  1280. hwndDlg,
  1281. GetStringResource (CSZ_UNABLE_COPY),
  1282. szDestFile,
  1283. MB_OKCANCEL_TASK_EXCL);
  1284. if (nMbResult == IDCANCEL) {
  1285. bCopying = FALSE;
  1286. nExitCode = IDCANCEL; // operation ended in error
  1287. } else {
  1288. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1289. }
  1290. }
  1291. }
  1292. #ifdef JAPAN
  1293. }
  1294. #endif
  1295. if (bCopying) {
  1296. // copy files in list from ??? to destination dir
  1297. lstrcpy (szSrcFile, pAppInfo->piFloppyProtocol.szDir);
  1298. if (szSrcFile[lstrlen(szSrcFile)-1] != cBackslash) lstrcat (szSrcFile, cszBackslash);
  1299. szSrcFilePart = &szSrcFile[lstrlen(szSrcFile)];
  1300. for (szThisFile = mszNetFileList;
  1301. *szThisFile != 0;
  1302. szThisFile += (lstrlen(szThisFile) + 1)) {
  1303. lstrcpy (szSrcFilePart, szThisFile);
  1304. lstrcpy (szDestFilePart, szThisFile);
  1305. if (bCopying) {
  1306. SetDlgItemText (hwndDlg, NCDU_FROM_PATH, szSrcFile);
  1307. SetDlgItemText (hwndDlg, NCDU_TO_PATH, szDestFile);
  1308. if (!CopyFile (szSrcFile, szDestFile, FALSE)) {
  1309. // error in file copy so bail out here
  1310. // bail out here since there was a copy error
  1311. nMbResult = MessageBox (
  1312. hwndDlg,
  1313. GetStringResource (CSZ_UNABLE_COPY),
  1314. szSrcFile,
  1315. MB_OKCANCEL_TASK_EXCL);
  1316. if (nMbResult == IDCANCEL) {
  1317. bCopying = FALSE;
  1318. nExitCode = IDCANCEL; // operation ended in error
  1319. } else {
  1320. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1321. }
  1322. } else {
  1323. // copy was successful so update the % complete
  1324. // and Set destination File attributest to NORMAL
  1325. SetFileAttributes (szDestFile, FILE_ATTRIBUTE_NORMAL);
  1326. UpdatePercentComplete (hwndDlg, ++dwFilesCopied, dwNetFileCount);
  1327. }
  1328. // check for messages
  1329. while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
  1330. TranslateMessage (&msg);
  1331. DispatchMessage (&msg);
  1332. }
  1333. } else {
  1334. break;
  1335. }
  1336. }
  1337. }
  1338. }
  1339. #ifdef JAPAN
  1340. if (bCopying) {
  1341. if (wParam == SETUP_DOSV_1) {
  1342. _stprintf (szTextString,
  1343. GetStringResource (FMT_LOAD_NET_CLIENT2),
  1344. GetStringResource (
  1345. (pAppInfo->mtBootDriveType == F3_1Pt44_512) ?
  1346. CSZ_35_HD : CSZ_525_HD),
  1347. pAppInfo->szBootFilesPath);
  1348. nMbResult = MessageBox (
  1349. hwndDlg,
  1350. szTextString,
  1351. GetStringResource (FMT_LOAD_NET_CLIENT2_TITLE),
  1352. MB_OKCANCEL_TASK_EXCL);
  1353. if (nMbResult == IDCANCEL) {
  1354. bCopying = FALSE;
  1355. }
  1356. }
  1357. }
  1358. #endif
  1359. if (bCopying) {
  1360. #ifdef JAPAN
  1361. if (((wParam == SETUP_DOSV_2) && bBootable) || !wParam) {
  1362. #endif
  1363. // files copied completely, but check params.
  1364. AddMessageToExitList (pAppInfo, NCDU_CHECK_PROTOCOL_INI);
  1365. DisplayMessageBox (
  1366. hwndDlg,
  1367. NCDU_FLOPPY_COMPLETE,
  1368. 0,
  1369. MB_OK_TASK_INFO);
  1370. #ifdef JAPAN
  1371. }
  1372. #endif
  1373. } else {
  1374. if (!bAborted) {
  1375. // don't show "not copied" dialog since they know
  1376. // this
  1377. // floppy not copied completely
  1378. AddMessageToExitList (pAppInfo, NCDU_FLOPPY_NOT_COMPLETE);
  1379. DisplayMessageBox (
  1380. hwndDlg,
  1381. NCDU_FLOPPY_NOT_COMPLETE,
  1382. 0,
  1383. MB_OK_TASK_EXCL);
  1384. }
  1385. }
  1386. if (nExitCode == IDOK) {
  1387. // enable display of exit messages since a floppy was created
  1388. EnableExitMessage(TRUE);
  1389. }
  1390. #ifdef JAPAN
  1391. if (!wParam ||
  1392. (wParam == SETUP_DOSV_2) ||
  1393. ((wParam == SETUP_DOSV_1) && !bCopying)) {
  1394. #endif
  1395. EndDialog (hwndDlg, nExitCode);
  1396. #ifdef JAPAN
  1397. }
  1398. #endif
  1399. FREE_IF_ALLOC (mszNetFileList);
  1400. FREE_IF_ALLOC (mszProtocolIni);
  1401. FREE_IF_ALLOC (mszSystemIni);
  1402. FREE_IF_ALLOC (mszConfigSys);
  1403. FREE_IF_ALLOC (mszAutoexecBat);
  1404. FREE_IF_ALLOC (szSrcFile);
  1405. FREE_IF_ALLOC (szDestFile);
  1406. FREE_IF_ALLOC (szInfFile);
  1407. #ifdef JAPAN
  1408. FREE_IF_ALLOC (szVolumeName);
  1409. FREE_IF_ALLOC (szTextString);
  1410. FREE_IF_ALLOC (szSectionBuffer);
  1411. FREE_IF_ALLOC (szDOSVDirectory);
  1412. FREE_IF_ALLOC (szTemp);
  1413. #endif
  1414. #ifdef JAPAN
  1415. if ((wParam == SETUP_DOSV_1) && !bCopying)
  1416. return FALSE;
  1417. #endif
  1418. return TRUE;
  1419. }
  1420. static
  1421. BOOL
  1422. MakeFlopDlg_WM_INITDIALOG (
  1423. IN HWND hwndDlg,
  1424. IN WPARAM wParam,
  1425. IN LPARAM lParam
  1426. )
  1427. /*++
  1428. Routine Description:
  1429. Initializes the text fields of the dialog box and post's the
  1430. "start copying" message
  1431. Arguments:
  1432. IN HWND hwndDlg
  1433. Handle to dialog box window
  1434. IN WPARAM wParam
  1435. Not Used
  1436. IN LPARAM lParam
  1437. Not Used
  1438. Return Value:
  1439. --*/
  1440. {
  1441. // intialize Global data
  1442. bCopying = TRUE;
  1443. RemoveMaximizeFromSysMenu (hwndDlg);
  1444. PositionWindow (hwndDlg);
  1445. SetDlgItemText (hwndDlg, NCDU_COPY_APPNAME,
  1446. GetStringResource (FMT_OTN_BOOT_FILES));
  1447. SetDlgItemText (hwndDlg, NCDU_FROM_PATH, cszEmptyString);
  1448. SetDlgItemText (hwndDlg, NCDU_TO_PATH, cszEmptyString);
  1449. SetDlgItemText (hwndDlg, NCDU_PERCENT_COMPLETE,
  1450. GetStringResource (FMT_ZERO_PERCENT_COMPLETE));
  1451. SetFocus (GetDlgItem(hwndDlg, IDCANCEL));
  1452. // start copying files
  1453. PostMessage (hwndDlg, NCDU_START_FILE_COPY, 0, lParam);
  1454. // clear old Dialog and register current
  1455. PostMessage (GetParent(hwndDlg), NCDU_CLEAR_DLG, (WPARAM)hwndDlg, IDOK);
  1456. PostMessage (GetParent(hwndDlg), NCDU_REGISTER_DLG,
  1457. NCDU_COPYING_FILES_DLG, (LPARAM)hwndDlg);
  1458. SetCursor(LoadCursor(NULL, IDC_ARROW));
  1459. return FALSE;
  1460. }
  1461. static
  1462. BOOL
  1463. MakeFlopDlg_WM_COMMAND (
  1464. IN HWND hwndDlg,
  1465. IN WPARAM wParam,
  1466. IN LPARAM lParam
  1467. )
  1468. /*++
  1469. Routine Description:
  1470. Process WM_COMMAND message. Stops copying if the Cancel (abort)
  1471. button is pressed.
  1472. Arguments:
  1473. IN HWND hwndDlg
  1474. Handle to dialog box procedure
  1475. IN WPARAM wParam
  1476. LOWORD contains the id of the control that initiated this message
  1477. IN LPARAM lParam
  1478. Not Used
  1479. Return Value:
  1480. --*/
  1481. {
  1482. switch (LOWORD(wParam)) {
  1483. case IDCANCEL:
  1484. bCopying = FALSE;
  1485. return TRUE;
  1486. default: return FALSE;
  1487. }
  1488. }
  1489. INT_PTR CALLBACK
  1490. MakeFlopDlgProc (
  1491. IN HWND hwndDlg,
  1492. IN UINT message,
  1493. IN WPARAM wParam,
  1494. IN LPARAM lParam
  1495. )
  1496. /*++
  1497. Routine Description:
  1498. Main Dialog Box Procedure. Dispatches Windows messages to the appropriate
  1499. processing routine. The following windows messages are processed
  1500. by this module:
  1501. WM_INITDIALOG: dialog initialization routine
  1502. WM_COMMAND: user input
  1503. NCDU_START_FILE_COPY: local windows message to start copy op.
  1504. Arguments:
  1505. Standard WNDPROC arguments
  1506. Return Value:
  1507. FALSE if message is not processed by this routine, otherwise
  1508. the value returned by the dispatched routine.
  1509. --*/
  1510. {
  1511. switch (message) {
  1512. case WM_INITDIALOG: return (MakeFlopDlg_WM_INITDIALOG (hwndDlg, wParam, lParam));
  1513. case WM_COMMAND: return (MakeFlopDlg_WM_COMMAND (hwndDlg, wParam, lParam));
  1514. #ifdef JAPAN
  1515. // fixed kkntbug #12382
  1516. // NCAdmin:"[] Make Japanese startup disks" is not functioning.
  1517. case NCDU_START_FILE_COPY:
  1518. if (bJpnDisk) {
  1519. if (!MakeFlopDlg_NCDU_START_FILE_COPY (hwndDlg, SETUP_DOSV_1, lParam))
  1520. return TRUE;
  1521. return (MakeFlopDlg_NCDU_START_FILE_COPY (hwndDlg, SETUP_DOSV_2, lParam));
  1522. }
  1523. else
  1524. return (MakeFlopDlg_NCDU_START_FILE_COPY (hwndDlg, wParam, lParam));
  1525. #else
  1526. case NCDU_START_FILE_COPY: return (MakeFlopDlg_NCDU_START_FILE_COPY (hwndDlg, wParam, lParam));
  1527. #endif
  1528. case WM_PAINT: return (Dlg_WM_PAINT (hwndDlg, wParam, lParam));
  1529. case WM_MOVE: return (Dlg_WM_MOVE (hwndDlg, wParam, lParam));
  1530. case WM_SYSCOMMAND: return (Dlg_WM_SYSCOMMAND (hwndDlg, wParam, lParam));
  1531. default: return FALSE;
  1532. }
  1533. }