Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2280 lines
65 KiB

  1. #define NOSOUND
  2. #define NOCOMM
  3. #include "pifedit.h"
  4. extern int SetHotKeyTextFromPIF(void);
  5. extern int delete(PSTR);
  6. extern BOOL UpdateHotKeyStruc(void);
  7. extern unsigned char *PutUpDB(int);
  8. extern void SetStatusText(HWND,int,BOOL);
  9. extern void InvalidateAllStatus(void);
  10. extern int CmdArgAddCorrectExtension(unsigned char *);
  11. extern HINSTANCE hPifInstance;
  12. extern HWND hwndPifDlg;
  13. extern HWND hwndAdvPifDlg;
  14. extern HWND hwndNTPifDlg;
  15. extern HWND hMainwnd;
  16. extern HWND hParentWnd;
  17. extern BOOL CurrMode386;
  18. extern BOOL NewHotKey;
  19. extern BOOL FileChanged;
  20. extern BOOL DoingMsg;
  21. extern unsigned char rgchInsMem[80];
  22. extern unsigned char rgchTitle[60];
  23. extern unsigned char CurPifFile[];
  24. extern unsigned char PifBuf[];
  25. extern unsigned char NTSys32Root[];
  26. extern BOOL AdvClose;
  27. extern BOOL NTClose;
  28. extern unsigned InMemHotKeyScan;
  29. extern unsigned InMemHotKeyShVal;
  30. extern unsigned InMemHotKeyShMsk;
  31. extern int FocusIDAdv;
  32. extern int FocusIDNT;
  33. extern WORD fileoffset;
  34. extern WORD extoffset;
  35. extern PIFNEWSTRUCT UNALIGNED *PifFile;
  36. extern PIF386EXT UNALIGNED *Pif386ext;
  37. extern PIFWNTEXT UNALIGNED *PifNText;
  38. /*
  39. * extern PIF286EXT31 *Pif286ext31;
  40. */
  41. extern PIF286EXT30 UNALIGNED *Pif286ext30;
  42. extern BOOL fNoNTAWarn;
  43. extern BOOL fNTAWarnne;
  44. extern BOOL fNoNTCWarn;
  45. extern BOOL fNTCWarnne;
  46. int InitPif386Struc(void);
  47. int InitPifNTStruc(void);
  48. int InitPif286Struc(void);
  49. int InitStdPIFExt(void);
  50. int InitPifStruct(void);
  51. BOOL ValidFileSpec(LPSTR lpstr, int iCaller);
  52. BOOL ExpandFileSpec(LPSTR lpstrExp, LPSTR lpstr, int errID);
  53. unsigned int WarningSem = 0;
  54. PIFEXTHEADER UNALIGNED *LastPifExt;
  55. unsigned PifFileSize;
  56. char stdHdr[] = STDHDRSIG;
  57. char w386Hdr[] = W386HDRSIG;
  58. char w286Hdr30[] = W286HDRSIG30;
  59. char wNTHdr[] = WNTHDRSIG31;
  60. /*
  61. * char w286Hdr31[] = W286HDRSIG31;
  62. */
  63. /* char *SCANNames[] = { "00h","01h","02h","03h","04h","05h","06h","07h",
  64. "08h","09h","0Ah","0Bh","0Ch","0Dh","0Eh","0Fh",
  65. "10h","11h","12h","13h","14h","15h","16h","17h",
  66. "18h","19h","1Ah","1Bh","1Ch","1Dh","1Eh","1Fh",
  67. "20h","21h","22h","23h","24h","25h","26h","27h",
  68. "28h","29h","2Ah","2Bh","2Ch","2Dh","2Eh","2Fh",
  69. "30h","31h","32h","33h","34h","35h","36h","37h",
  70. "38h","39h","3Ah","3Bh","3Ch","3Dh","3Eh","3Fh",
  71. "40h","41h","42h","43h","44h","45h","46h","47h",
  72. "48h","49h","4Ah","4Bh","4Ch","4Dh","4Eh","4Fh",
  73. "50h","51h","52h","53h","54h","55h","56h","57h",
  74. "58h","59h","5Ah","5Bh","5Ch","5Dh","5Eh","5Fh",
  75. "60h","61h","62h","63h","64h","65h","66h","67h",
  76. "68h","69h","6Ah","6Bh","6Ch","6Dh","6Eh","6Fh",
  77. "70h","71h","72h","73h","74h","75h","76h","77h",
  78. "78h","79h","7Ah","7Bh","7Ch","7Dh","7Eh","7Fh",
  79. "80h","81h","82h","83h","84h","85h","86h","87h",
  80. "88h","89h","8Ah","8Bh","8Ch","8Dh","8Eh","8Fh",
  81. "90h","91h","92h","93h","94h","95h","96h","97h",
  82. "98h","99h","9Ah","9Bh","9Ch","9Dh","9Eh","9Fh",
  83. "A0h","A1h","A2h","A3h","A4h","A5h","A6h","A7h",
  84. "A8h","A9h","AAh","ABh","ACh","ADh","AEh","AFh",
  85. "B0h","B1h","B2h","B3h","B4h","B5h","B6h","B7h",
  86. "B8h","B9h","BAh","BBh","BCh","BDh","BEh","BFh",
  87. "C0h","C1h","C2h","C3h","C4h","C5h","C6h","C7h",
  88. "C8h","C9h","CAh","CBh","CCh","CDh","CEh","CFh",
  89. "D0h","D1h","D2h","D3h","D4h","D5h","D6h","D7h",
  90. "D8h","D9h","DAh","DBh","DCh","DDh","DEh","DFh",
  91. "E0h","E1h","E2h","E3h","E4h","E5h","E6h","E7h",
  92. "E8h","E9h","EAh","EBh","ECh","EDh","EEh","EFh",
  93. "F0h","F1h","F2h","F3h","F4h","F5h","F6h","F7h",
  94. "F8h","F9h","FAh","FBh","FCh","FDh","FEh","FFh" }; */
  95. void SetFileOffsets(unsigned char *nmptr,WORD *fileoff,WORD *extoff)
  96. {
  97. unsigned char *pch;
  98. unsigned char ch;
  99. pch = nmptr+lstrlen((LPSTR)nmptr);
  100. while ((ch = *pch) != '\\' && ch != ':' && pch > nmptr)
  101. pch = (unsigned char *)AnsiPrev((LPSTR)nmptr, (LPSTR)pch);
  102. if((ch = *pch) == '\\' || ch == ':')
  103. pch++;
  104. *fileoff = pch - nmptr;
  105. *extoff = 0;
  106. while ((ch = *pch) != '.' && ch != '\0')
  107. pch = (unsigned char *)AnsiNext((LPSTR)pch);
  108. if(ch == '.') {
  109. pch++;
  110. if(*pch == '\0')
  111. return;
  112. else
  113. *extoff = pch - nmptr;
  114. }
  115. }
  116. int Warning(int ID,WORD type)
  117. {
  118. unsigned char buf[500];
  119. int retval;
  120. BOOL MsgFlagSav;
  121. if(hParentWnd != hMainwnd) {
  122. if(!WarningSem) {
  123. EnableWindow(hMainwnd,FALSE);
  124. }
  125. WarningSem++;
  126. }
  127. MsgFlagSav = DoingMsg;
  128. DoingMsg = TRUE;
  129. if(MsgFlagSav != DoingMsg)
  130. InvalidateAllStatus();
  131. if(ID == EINSMEMORY) {
  132. retval = MessageBox(hParentWnd, (LPSTR)rgchInsMem, (LPSTR)rgchTitle, type);
  133. } else if(LoadString(hPifInstance, ID, (LPSTR)buf, sizeof(buf))) {
  134. retval = MessageBox(hParentWnd, (LPSTR)buf, (LPSTR)rgchTitle, type);
  135. } else {
  136. MessageBox(hParentWnd, (LPSTR)rgchInsMem, (LPSTR)rgchTitle, MB_ICONEXCLAMATION | MB_OK);
  137. retval = IDCANCEL;
  138. }
  139. if(hParentWnd != hMainwnd) {
  140. if(WarningSem == 1) {
  141. EnableWindow(hMainwnd,TRUE);
  142. }
  143. WarningSem--;
  144. }
  145. if(retval == 0) { /* map messagebox failure to cancel */
  146. retval = IDCANCEL;
  147. }
  148. if(MsgFlagSav != DoingMsg) {
  149. DoingMsg = MsgFlagSav;
  150. InvalidateAllStatus();
  151. } else {
  152. DoingMsg = MsgFlagSav;
  153. }
  154. return(retval);
  155. }
  156. PIFWNTEXT UNALIGNED *AllocInitNTExt(void)
  157. {
  158. PIFWNTEXT UNALIGNED *extNT;
  159. char buf[PIFDEFPATHSIZE*2];
  160. char buf2[PIFDEFPATHSIZE*4];
  161. if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIFWNTEXT) + sizeof(PIFEXTHEADER))) {
  162. return((PIFWNTEXT *)NULL);
  163. }
  164. LastPifExt->extnxthdrfloff = PifFileSize;
  165. LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
  166. LastPifExt->extnxthdrfloff = LASTHEADERPTR;
  167. LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
  168. LastPifExt->extsizebytes = sizeof(PIFWNTEXT);
  169. lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)wNTHdr);
  170. PifFileSize += sizeof(PIFWNTEXT) + sizeof(PIFEXTHEADER);
  171. extNT = (PIFWNTEXT *)(PifBuf + LastPifExt->extfileoffset);
  172. extNT->dwWNTFlags = 0;
  173. extNT->dwRes1 = 0;
  174. extNT->dwRes2 = 0;
  175. fNoNTAWarn = FALSE;
  176. fNTAWarnne = FALSE;
  177. fNoNTCWarn = FALSE;
  178. fNTCWarnne = FALSE;
  179. lstrcpy((LPTSTR)buf2, (LPCTSTR)NTSys32Root);
  180. if(LoadString(hPifInstance, NTAUTOEXECFILE, (LPSTR)buf, PIFDEFPATHSIZE-1)) {
  181. lstrcat((LPTSTR)buf2, (LPCTSTR)buf);
  182. AnsiToOem(buf2, (LPTSTR)extNT->achAutoexecFile);
  183. }
  184. lstrcpy((LPTSTR)buf2, (LPCTSTR)NTSys32Root);
  185. if(LoadString(hPifInstance, NTCONFIGFILE, (LPSTR)buf, PIFDEFPATHSIZE-1)) {
  186. lstrcat((LPTSTR)buf2, (LPCTSTR)buf);
  187. AnsiToOem(buf2, (LPTSTR)extNT->achConfigFile);
  188. }
  189. return(extNT);
  190. }
  191. PIF386EXT UNALIGNED *AllocInit386Ext(void)
  192. {
  193. PIF386EXT UNALIGNED *ext386;
  194. unsigned char *src,*dst;
  195. int i;
  196. if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF386EXT) + sizeof(PIFEXTHEADER))) {
  197. return((PIF386EXT *)NULL);
  198. }
  199. LastPifExt->extnxthdrfloff = PifFileSize;
  200. LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
  201. LastPifExt->extnxthdrfloff = LASTHEADERPTR;
  202. LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
  203. LastPifExt->extsizebytes = sizeof(PIF386EXT);
  204. lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w386Hdr);
  205. PifFileSize += sizeof(PIF386EXT) + sizeof(PIFEXTHEADER);
  206. ext386 = (PIF386EXT *)(PifBuf + LastPifExt->extfileoffset);
  207. dst = (PUCHAR)ext386->params;
  208. src = (PUCHAR)(((PIFOLD286STR *)PifBuf)->params);
  209. for(i=0;i<PIFPARAMSSIZE;i++)
  210. *dst++ = *src++;
  211. ext386->maxmem = 640;
  212. ext386->minmem = 128;
  213. ext386->PfFPriority = 100;
  214. ext386->PfBPriority = 50;
  215. ext386->PfMaxEMMK = 1024;
  216. ext386->PfMinEMMK = 0;
  217. ext386->PfMaxXmsK = 1024;
  218. ext386->PfMinXmsK = 0;
  219. ext386->PfW386Flags = fFullScreen | fPollingDetect | fINT16Paste;
  220. if(Pif286ext30) {
  221. if(Pif286ext30->PfW286Flags & fALTTABdis286)
  222. ext386->PfW386Flags |= fALTTABdis;
  223. if(Pif286ext30->PfW286Flags & fALTESCdis286)
  224. ext386->PfW386Flags |= fALTESCdis;
  225. if(Pif286ext30->PfW286Flags & fCTRLESCdis286)
  226. ext386->PfW386Flags |= fCTRLESCdis;
  227. if(Pif286ext30->PfW286Flags & fALTPRTSCdis286)
  228. ext386->PfW386Flags |= fALTPRTSCdis;
  229. if(Pif286ext30->PfW286Flags & fPRTSCdis286)
  230. ext386->PfW386Flags |= fPRTSCdis;
  231. }
  232. ext386->PfW386Flags2 = fVidTxtEmulate | fVidNoTrpTxt | fVidNoTrpLRGrfx
  233. | fVidTextMd;
  234. /*
  235. * The following is if( > EGA), then don't trap Hi Res graphics ports
  236. * The setting of this bit is irrelevant on HERC CGA and PLASMA,
  237. * so the fact that these guys also get "caught" by this doesn't
  238. * matter. EGA is the only low res guy that matters.
  239. *
  240. */
  241. if(GetSystemMetrics(SM_CYSCREEN) > 350) {
  242. ext386->PfW386Flags2 |= fVidNoTrpHRGrfx;
  243. }
  244. ext386->PfHotKeyScan = 0;
  245. ext386->PfHotKeyShVal = 0;
  246. ext386->PfHotKeyShMsk = 0;
  247. InMemHotKeyScan = 0;
  248. InMemHotKeyShVal = 0;
  249. InMemHotKeyShMsk = 0;
  250. NewHotKey = FALSE;
  251. SetHotKeyTextFromPIF();
  252. return(ext386);
  253. }
  254. PIF286EXT30 UNALIGNED *AllocInit286Ext30(void)
  255. {
  256. PIF286EXT30 UNALIGNED *ext286;
  257. if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF286EXT30) + sizeof(PIFEXTHEADER))) {
  258. return((PIF286EXT30 *)NULL);
  259. }
  260. LastPifExt->extnxthdrfloff = PifFileSize;
  261. LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
  262. LastPifExt->extnxthdrfloff = LASTHEADERPTR;
  263. LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
  264. LastPifExt->extsizebytes = sizeof(PIF286EXT30);
  265. lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w286Hdr30);
  266. PifFileSize += sizeof(PIF286EXT30) + sizeof(PIFEXTHEADER);
  267. ext286 = (PIF286EXT30 *)(PifBuf + LastPifExt->extfileoffset);
  268. ext286->PfMaxXmsK = 0;
  269. ext286->PfMinXmsK = 0;
  270. ext286->PfW286Flags = 0;
  271. if(Pif386ext) {
  272. if(Pif386ext->PfW386Flags & fALTTABdis)
  273. ext286->PfW286Flags |= fALTTABdis286;
  274. if(Pif386ext->PfW386Flags & fALTESCdis)
  275. ext286->PfW286Flags |= fALTESCdis286;
  276. if(Pif386ext->PfW386Flags & fCTRLESCdis)
  277. ext286->PfW286Flags |= fCTRLESCdis286;
  278. if(Pif386ext->PfW386Flags & fALTPRTSCdis)
  279. ext286->PfW286Flags |= fALTPRTSCdis286;
  280. if(Pif386ext->PfW386Flags & fPRTSCdis)
  281. ext286->PfW286Flags |= fPRTSCdis286;
  282. }
  283. return(ext286);
  284. }
  285. /*
  286. * PIF286EXT31 *AllocInit286Ext31(void)
  287. * {
  288. * PIF286EXT31 *ext286;
  289. *
  290. * if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF286EXT31) + sizeof(PIFEXTHEADER))) {
  291. * return((PIF286EXT31 *)NULL);
  292. * }
  293. *
  294. * LastPifExt->extnxthdrfloff = PifFileSize;
  295. *
  296. * LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
  297. *
  298. * LastPifExt->extnxthdrfloff = LASTHEADERPTR;
  299. * LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
  300. * LastPifExt->extsizebytes = sizeof(PIF286EXT31);
  301. * lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w286Hdr31);
  302. * PifFileSize += sizeof(PIF286EXT31) + sizeof(PIFEXTHEADER);
  303. *
  304. * ext286 = (PIF286EXT31 *)(PifBuf + LastPifExt->extfileoffset);
  305. *
  306. * ext286->PfMaxEmsK = 0;
  307. * ext286->PfMinEmsK = 0;
  308. * return(ext286);
  309. * }
  310. */
  311. UpdatePifScreenAdv(void)
  312. {
  313. unsigned char rgch[200];
  314. if(hwndAdvPifDlg) {
  315. if(!AdvClose) {
  316. if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
  317. Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
  318. } else {
  319. SetDlgItemText(hwndAdvPifDlg,IDCANCEL,(LPSTR)rgch);
  320. }
  321. AdvClose = TRUE;
  322. if(FocusIDAdv == IDCANCEL) {
  323. SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
  324. }
  325. }
  326. if(CurrMode386) {
  327. SetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, Pif386ext->PfFPriority, FALSE);
  328. SetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, Pif386ext->PfBPriority, FALSE);
  329. CheckDlgButton(hwndAdvPifDlg, IDI_POLL, Pif386ext->PfW386Flags & fPollingDetect ? TRUE : FALSE );
  330. CheckDlgButton(hwndAdvPifDlg, IDI_CLOSE, Pif386ext->PfW386Flags & fEnableClose ? TRUE : FALSE );
  331. CheckDlgButton(hwndAdvPifDlg, IDI_ALTTAB, Pif386ext->PfW386Flags & fALTTABdis ? TRUE : FALSE );
  332. CheckDlgButton(hwndAdvPifDlg, IDI_ALTESC, Pif386ext->PfW386Flags & fALTESCdis ? TRUE : FALSE );
  333. CheckDlgButton(hwndAdvPifDlg, IDI_CTRLESC, Pif386ext->PfW386Flags & fCTRLESCdis ? TRUE : FALSE );
  334. CheckDlgButton(hwndAdvPifDlg, IDI_ALTSPACE, Pif386ext->PfW386Flags & fALTSPACEdis ? TRUE : FALSE );
  335. CheckDlgButton(hwndAdvPifDlg, IDI_ALTENTER, Pif386ext->PfW386Flags & fALTENTERdis ? TRUE : FALSE );
  336. CheckDlgButton(hwndAdvPifDlg, IDI_ALTPRTSC, Pif386ext->PfW386Flags & fALTPRTSCdis ? TRUE : FALSE );
  337. CheckDlgButton(hwndAdvPifDlg, IDI_PRTSC, Pif386ext->PfW386Flags & fPRTSCdis ? TRUE : FALSE );
  338. CheckDlgButton(hwndAdvPifDlg, IDI_NOHMA, Pif386ext->PfW386Flags & fNoHMA ? FALSE : TRUE );
  339. CheckDlgButton(hwndAdvPifDlg, IDI_INT16PST, Pif386ext->PfW386Flags & fINT16Paste ? TRUE : FALSE );
  340. CheckDlgButton(hwndAdvPifDlg, IDI_VMLOCKED, Pif386ext->PfW386Flags & fVMLocked ? TRUE : FALSE );
  341. CheckDlgButton(hwndAdvPifDlg, IDI_XMSLOCKED, Pif386ext->PfW386Flags & fXMSLocked ? TRUE : FALSE );
  342. CheckDlgButton(hwndAdvPifDlg, IDI_EMSLOCKED, Pif386ext->PfW386Flags & fEMSLocked ? TRUE : FALSE );
  343. CheckDlgButton(hwndAdvPifDlg, IDI_TEXTEMULATE, Pif386ext->PfW386Flags2 & fVidTxtEmulate ? TRUE : FALSE );
  344. CheckDlgButton(hwndAdvPifDlg, IDI_RETAINALLO, Pif386ext->PfW386Flags2 & fVidRetainAllo ? TRUE : FALSE );
  345. CheckDlgButton(hwndAdvPifDlg, IDI_TRAPTXT, Pif386ext->PfW386Flags2 & fVidNoTrpTxt ? FALSE : TRUE );
  346. CheckDlgButton(hwndAdvPifDlg, IDI_TRAPLRGRFX, Pif386ext->PfW386Flags2 & fVidNoTrpLRGrfx ? FALSE : TRUE );
  347. CheckDlgButton(hwndAdvPifDlg, IDI_TRAPHRGRFX, Pif386ext->PfW386Flags2 & fVidNoTrpHRGrfx ? FALSE : TRUE );
  348. SetHotKeyTextFromPIF();
  349. } else {
  350. }
  351. }
  352. return(TRUE);
  353. }
  354. UpdatePifScreenNT(void)
  355. {
  356. unsigned char rgch[PIFDEFPATHSIZE*4];
  357. if(hwndNTPifDlg) {
  358. if(!NTClose) {
  359. if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
  360. Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
  361. } else {
  362. SetDlgItemText(hwndNTPifDlg,IDCANCEL,(LPSTR)rgch);
  363. }
  364. NTClose = TRUE;
  365. if(FocusIDNT == IDCANCEL) {
  366. SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
  367. }
  368. }
  369. if(CurrMode386) {
  370. OemToAnsi((LPCTSTR)PifNText->achAutoexecFile, rgch);
  371. SetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,(LPCTSTR)rgch);
  372. OemToAnsi((LPCTSTR)PifNText->achConfigFile, rgch);
  373. SetDlgItemText(hwndNTPifDlg,IDI_CONFIG,(LPCTSTR)rgch);
  374. CheckDlgButton(hwndNTPifDlg, IDI_NTTIMER, (PifNText->dwWNTFlags & COMPAT_TIMERTIC));
  375. } else {
  376. }
  377. }
  378. return(TRUE);
  379. }
  380. /* make the screen match the structure */
  381. UpdatePifScreen(void)
  382. {
  383. unsigned char rgch[200];
  384. int i;
  385. /*
  386. * make sure of nul terminator before calling OemToAnsi
  387. */
  388. PifFile->startfile[PIFSTARTLOCSIZE-1] = '\0';
  389. OemToAnsi((LPSTR)PifFile->startfile,(LPSTR)rgch);
  390. SetDlgItemText(hwndPifDlg, IDI_ENAME, (LPSTR)rgch);
  391. SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_SETMODIFY, FALSE, 0L);
  392. /*
  393. * NOTE: the PifFile->name field MAY NOT be nul terminated!!!!!!
  394. */
  395. for(i = 0;i < PIFNAMESIZE; i++)
  396. rgch[i] = PifFile->name[i];
  397. rgch[i] = '\0';
  398. OemToAnsi((LPSTR)rgch,(LPSTR)rgch);
  399. SetDlgItemText(hwndPifDlg, IDI_ETITLE, (LPSTR)rgch);
  400. SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_SETMODIFY, FALSE, 0L);
  401. /*
  402. * make sure of nul terminator before calling OemToAnsi
  403. */
  404. PifFile->defpath[PIFDEFPATHSIZE-1] = '\0';
  405. OemToAnsi((LPSTR)PifFile->defpath,(LPSTR)rgch);
  406. SetDlgItemText(hwndPifDlg, IDI_EPATH, (LPSTR)rgch);
  407. SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_SETMODIFY, FALSE, 0L);
  408. CheckDlgButton(hwndPifDlg, IDI_EXIT , PifFile->MSflags & EXITMASK ? TRUE : FALSE );
  409. if(CurrMode386) {
  410. /*
  411. * make sure of nul terminator before calling OemToAnsi
  412. */
  413. Pif386ext->params[PIFPARAMSSIZE-1] = '\0';
  414. OemToAnsi((LPSTR)Pif386ext->params,(LPSTR)rgch);
  415. SetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)rgch);
  416. SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
  417. SetDlgItemInt(hwndPifDlg, IDI_MEMREQ, Pif386ext->minmem, TRUE);
  418. if (Pif386ext->maxmem) {
  419. SetDlgItemInt(hwndPifDlg, IDI_MEMDES, Pif386ext->maxmem, TRUE);
  420. } else {
  421. SetDlgItemText(hwndPifDlg, IDI_MEMDES, (LPSTR)"");
  422. }
  423. CheckRadioButton(hwndPifDlg, IDI_WND, IDI_FSCR,Pif386ext->PfW386Flags & fFullScreen ? IDI_FSCR : IDI_WND);
  424. CheckDlgButton(hwndPifDlg, IDI_BACK, Pif386ext->PfW386Flags & fBackground ? TRUE : FALSE );
  425. CheckDlgButton(hwndPifDlg, IDI_EXCL, Pif386ext->PfW386Flags & fExclusive ? TRUE : FALSE );
  426. if (Pif386ext->PfW386Flags2 & fVidTextMd ) {
  427. CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODETXT);
  428. } else if (Pif386ext->PfW386Flags2 & fVidLowRsGrfxMd) {
  429. CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODELRGRFX);
  430. } else {
  431. CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODEHRGRFX);
  432. }
  433. SetDlgItemInt(hwndPifDlg, IDI_EMSREQ, Pif386ext->PfMinEMMK, FALSE);
  434. SetDlgItemInt(hwndPifDlg, IDI_EMSDES, Pif386ext->PfMaxEMMK, TRUE);
  435. SetDlgItemInt(hwndPifDlg, IDI_XMAREQ, Pif386ext->PfMinXmsK, FALSE);
  436. SetDlgItemInt(hwndPifDlg, IDI_XMADES, Pif386ext->PfMaxXmsK, TRUE);
  437. UpdatePifScreenAdv();
  438. UpdatePifScreenNT();
  439. } else {
  440. /*
  441. * make sure of nul terminator before calling OemToAnsi
  442. */
  443. PifFile->params[PIFPARAMSSIZE-1] = '\0';
  444. OemToAnsi((LPSTR)PifFile->params,(LPSTR)rgch);
  445. SetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)rgch);
  446. SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
  447. SetDlgItemInt(hwndPifDlg, IDI_MEMREQ, PifFile->minmem, TRUE);
  448. /*
  449. * if (PifFile->maxmem) {
  450. * SetDlgItemInt(hwndPifDlg, IDI_MEMDES, PifFile->maxmem, TRUE);
  451. * } else {
  452. * SetDlgItemText(hwndPifDlg, IDI_MEMDES, (LPSTR)"");
  453. * }
  454. * CheckDlgButton(hwndPifDlg, IDI_DMSCREEN, PifFile->behavior & SCRMASK ? TRUE : FALSE );
  455. * CheckDlgButton(hwndPifDlg, IDI_DMMEM , PifFile->MSflags & MEMMASK ? TRUE : FALSE );
  456. */
  457. CheckDlgButton(hwndPifDlg, IDI_DMKBD , PifFile->behavior & KEYMASK ? TRUE : FALSE );
  458. CheckDlgButton(hwndPifDlg, IDI_DMCOM1 , PifFile->MSflags & COM1MASK ? TRUE : FALSE );
  459. CheckDlgButton(hwndPifDlg, IDI_DMCOM2 , PifFile->MSflags & COM2MASK ? TRUE : FALSE );
  460. if(Pif286ext30) {
  461. CheckDlgButton(hwndPifDlg, IDI_DMCOM3 , Pif286ext30->PfW286Flags & fCOM3_286 ? TRUE : FALSE );
  462. CheckDlgButton(hwndPifDlg, IDI_DMCOM4 , Pif286ext30->PfW286Flags & fCOM4_286 ? TRUE : FALSE );
  463. CheckDlgButton(hwndPifDlg, IDI_ALTTAB, Pif286ext30->PfW286Flags & fALTTABdis286 ? TRUE : FALSE );
  464. CheckDlgButton(hwndPifDlg, IDI_ALTESC, Pif286ext30->PfW286Flags & fALTESCdis286 ? TRUE : FALSE );
  465. CheckDlgButton(hwndPifDlg, IDI_CTRLESC, Pif286ext30->PfW286Flags & fCTRLESCdis286 ? TRUE : FALSE );
  466. CheckDlgButton(hwndPifDlg, IDI_ALTPRTSC, Pif286ext30->PfW286Flags & fALTPRTSCdis286 ? TRUE : FALSE );
  467. CheckDlgButton(hwndPifDlg, IDI_PRTSC, Pif286ext30->PfW286Flags & fPRTSCdis286 ? TRUE : FALSE );
  468. CheckDlgButton(hwndPifDlg, IDI_NOSAVVID, Pif286ext30->PfW286Flags & fNoSaveVid286 ? TRUE : FALSE );
  469. SetDlgItemInt(hwndPifDlg, IDI_XMAREQ, Pif286ext30->PfMinXmsK, FALSE);
  470. SetDlgItemInt(hwndPifDlg, IDI_XMADES, Pif286ext30->PfMaxXmsK, TRUE);
  471. } else {
  472. CheckDlgButton(hwndPifDlg, IDI_DMCOM3 , FALSE );
  473. CheckDlgButton(hwndPifDlg, IDI_DMCOM4 , FALSE );
  474. CheckDlgButton(hwndPifDlg, IDI_ALTTAB, FALSE );
  475. CheckDlgButton(hwndPifDlg, IDI_ALTESC, FALSE );
  476. CheckDlgButton(hwndPifDlg, IDI_CTRLESC, FALSE );
  477. CheckDlgButton(hwndPifDlg, IDI_ALTPRTSC, FALSE );
  478. CheckDlgButton(hwndPifDlg, IDI_PRTSC, FALSE );
  479. CheckDlgButton(hwndPifDlg, IDI_NOSAVVID, FALSE );
  480. SetDlgItemText(hwndPifDlg, IDI_XMAREQ, (LPSTR)"0");
  481. SetDlgItemText(hwndPifDlg, IDI_XMADES, (LPSTR)"0");
  482. }
  483. /*
  484. * if(Pif286ext31) {
  485. * SetDlgItemInt(hwndPifDlg, IDI_EMSREQ, Pif286ext31->PfMinEmsK, FALSE);
  486. * SetDlgItemInt(hwndPifDlg, IDI_EMSDES, Pif286ext31->PfMaxEmsK, TRUE);
  487. * } else {
  488. * SetDlgItemText(hwndPifDlg, IDI_EMSREQ, (LPSTR)"0");
  489. * SetDlgItemText(hwndPifDlg, IDI_EMSDES, (LPSTR)"0");
  490. * }
  491. */
  492. if (PifFile->MSflags & SGMASK) {
  493. CheckDlgButton(hwndPifDlg, IDI_SENONE, TRUE);
  494. } else {
  495. CheckDlgButton(hwndPifDlg, IDI_SENONE, FALSE);
  496. }
  497. if (PifFile->MSflags & PSMASK) {
  498. CheckDlgButton(hwndPifDlg, IDI_PSNONE, TRUE);
  499. } else {
  500. CheckDlgButton(hwndPifDlg, IDI_PSNONE, FALSE);
  501. }
  502. CheckRadioButton(hwndPifDlg, IDI_PSTEXT, IDI_PSGRAPH,
  503. (PifFile->sysmem < 16 ? IDI_PSTEXT : IDI_PSGRAPH));
  504. /*
  505. * if (PifFile->MSflags & SGMASK) {
  506. * CheckRadioButton(hwndPifDlg, IDI_SEFIRST, IDI_SELAST, IDI_SENONE);
  507. * } else {
  508. * CheckRadioButton(hwndPifDlg, IDI_SEFIRST, IDI_SELAST,
  509. * (PifFile->MSflags & GRAPHMASK ? IDI_SEGRAPH : IDI_SETEXT));
  510. * }
  511. *
  512. * if (PifFile->MSflags & PSMASK) {
  513. * CheckRadioButton(hwndPifDlg, IDI_PSFIRST, IDI_PSLAST, IDI_PSNONE);
  514. * } else {
  515. * CheckRadioButton(hwndPifDlg, IDI_PSFIRST, IDI_PSLAST,
  516. * (PifFile->sysmem < 16 ? IDI_PSTEXT : IDI_PSGRAPH));
  517. * }
  518. */
  519. }
  520. return(TRUE);
  521. }
  522. BOOL UpdateParms(unsigned char *parmPtr)
  523. {
  524. int cch;
  525. unsigned char *pch;
  526. BOOL result;
  527. result = FALSE;
  528. if (SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_GETMODIFY, 0, 0L))
  529. result = TRUE;
  530. cch = GetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)parmPtr, PIFPARAMSSIZE);
  531. AnsiToOem((LPSTR)parmPtr,(LPSTR)parmPtr);
  532. /*
  533. * Trim leading spaces
  534. */
  535. for (pch = parmPtr; *pch == ' '; pch=AnsiNext(pch))
  536. ;
  537. lstrcpy((LPSTR)parmPtr, (LPSTR)pch);
  538. /*
  539. * Point to last char
  540. */
  541. for (pch = parmPtr; *pch; pch=AnsiNext(pch))
  542. ;
  543. if (pch > parmPtr)
  544. pch =AnsiPrev(parmPtr,pch);
  545. /*
  546. * Trim trailing spaces
  547. */
  548. while (*pch == ' ' && pch > parmPtr)
  549. pch=AnsiPrev(parmPtr,pch);
  550. *++pch = 0;
  551. cch = pch - parmPtr;
  552. if(!CurrMode386) {
  553. if (cch) {
  554. PifFile->sysflags |= PARMMASK;
  555. } else {
  556. PifFile->sysflags &= NOTPARMMASK;
  557. }
  558. }
  559. if (cch) {
  560. pch++;
  561. cch++;
  562. }
  563. /*
  564. * Space pad out to full field width
  565. */
  566. for ( ; cch <PIFPARAMSSIZE; ++pch, ++cch)
  567. *pch = ' ';
  568. return(result);
  569. }
  570. void FixString(LPSTR lpstrIn)
  571. {
  572. int i;
  573. char str[PIFDEFPATHSIZE*2];
  574. LPSTR lpstr;
  575. lpstr = lpstrIn;
  576. while(*lpstr == ' ')
  577. lpstr++;
  578. i = 0;
  579. while((*lpstr != '\0') && (*lpstr != ' ')) {
  580. str[i++] = *lpstr++;
  581. }
  582. str[i] = '\0';
  583. lstrcpy(lpstrIn, str);
  584. // don't Uppercase environment vars
  585. i = lstrlen(lpstrIn)-1;
  586. while(i > 0) {
  587. if(lpstrIn[i] == '%') {
  588. i++;
  589. break;
  590. }
  591. i--;
  592. }
  593. AnsiUpper(&(lpstrIn[i]));
  594. }
  595. BOOL UpdatePifNTStruc(void)
  596. {
  597. BOOL result;
  598. char rgch[60];
  599. char szFile[PIFDEFPATHSIZE*2];
  600. result = FALSE; /* did anything change? */
  601. if(hwndNTPifDlg) {
  602. if(!NTClose) {
  603. if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
  604. Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
  605. } else {
  606. SetDlgItemText(hwndNTPifDlg,IDCANCEL,(LPSTR)rgch);
  607. }
  608. NTClose = TRUE;
  609. if(FocusIDNT == IDCANCEL) {
  610. SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
  611. }
  612. }
  613. GetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,szFile,PIFDEFPATHSIZE-1);
  614. FixString(szFile);
  615. AnsiToOem(szFile, szFile);
  616. if(lstrcmp((LPTSTR)PifNText->achAutoexecFile, (LPCTSTR)szFile)) {
  617. lstrcpy((LPTSTR)PifNText->achAutoexecFile, (LPCTSTR)szFile);
  618. fNoNTAWarn = FALSE;
  619. fNTAWarnne = FALSE;
  620. result = TRUE;
  621. }
  622. GetDlgItemText(hwndNTPifDlg,IDI_CONFIG,szFile,PIFDEFPATHSIZE-1);
  623. FixString(szFile);
  624. AnsiToOem(szFile, szFile);
  625. if(lstrcmp((LPTSTR)PifNText->achConfigFile, (LPCTSTR)szFile)) {
  626. lstrcpy((LPTSTR)PifNText->achConfigFile, (LPCTSTR)szFile);
  627. fNoNTCWarn = FALSE;
  628. fNTCWarnne = FALSE;
  629. result = TRUE;
  630. }
  631. // is checkbox checked?
  632. if(IsDlgButtonChecked(hwndNTPifDlg, IDI_NTTIMER)) {
  633. // if it wasn't, note the change
  634. if(!(PifNText->dwWNTFlags & COMPAT_TIMERTIC)) {
  635. result = TRUE;
  636. }
  637. PifNText->dwWNTFlags |= COMPAT_TIMERTIC; // mark it as checked
  638. }
  639. else {
  640. if(PifNText->dwWNTFlags & COMPAT_TIMERTIC) {
  641. result = TRUE;
  642. }
  643. PifNText->dwWNTFlags &= ~COMPAT_TIMERTIC;
  644. }
  645. }
  646. return(result);
  647. }
  648. BOOL UpdatePif386Struc(void)
  649. {
  650. int result, i;
  651. unsigned int u;
  652. unsigned long W386flags;
  653. char rgch[60];
  654. BOOL iresult;
  655. result = FALSE; /* did anything change? */
  656. if(UpdateParms((PUCHAR)Pif386ext->params))
  657. result = TRUE;
  658. /*
  659. * Return of zero here ignored (set IDI_MEMREQ to 0)
  660. */
  661. ;
  662. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&iresult, TRUE))
  663. != Pif386ext->minmem) {
  664. if(iresult) {
  665. result = TRUE;
  666. Pif386ext->minmem = i;
  667. }
  668. }
  669. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&iresult, TRUE))
  670. != Pif386ext->maxmem) {
  671. if(iresult) {
  672. result = TRUE;
  673. Pif386ext->maxmem = i;
  674. }
  675. }
  676. if(UpdateHotKeyStruc())
  677. result = TRUE;
  678. W386flags = Pif386ext->PfW386Flags;
  679. if (IsDlgButtonChecked(hwndPifDlg, IDI_FSCR))
  680. W386flags |= fFullScreen;
  681. else
  682. W386flags &= ~fFullScreen;
  683. if (IsDlgButtonChecked(hwndPifDlg, IDI_EXCL))
  684. W386flags |= fExclusive;
  685. else
  686. W386flags &= ~fExclusive;
  687. if (IsDlgButtonChecked(hwndPifDlg, IDI_BACK))
  688. W386flags |= fBackground;
  689. else
  690. W386flags &= ~fBackground;
  691. if ((u = GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&iresult, FALSE))
  692. != (UINT)Pif386ext->PfMinEMMK) {
  693. if(iresult) {
  694. result = TRUE;
  695. Pif386ext->PfMinEMMK = u;
  696. }
  697. }
  698. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&iresult, TRUE))
  699. != Pif386ext->PfMaxEMMK) {
  700. if(iresult) {
  701. result = TRUE;
  702. Pif386ext->PfMaxEMMK = i;
  703. }
  704. }
  705. if ((u = GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&iresult, FALSE))
  706. != (UINT)Pif386ext->PfMinXmsK) {
  707. if(iresult) {
  708. result = TRUE;
  709. Pif386ext->PfMinXmsK = u;
  710. }
  711. }
  712. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&iresult, TRUE))
  713. != Pif386ext->PfMaxXmsK) {
  714. if(iresult) {
  715. result = TRUE;
  716. Pif386ext->PfMaxXmsK = i;
  717. }
  718. }
  719. if(hwndAdvPifDlg) {
  720. if(!AdvClose) {
  721. if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
  722. Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
  723. } else {
  724. SetDlgItemText(hwndAdvPifDlg,IDCANCEL,(LPSTR)rgch);
  725. }
  726. AdvClose = TRUE;
  727. if(FocusIDAdv == IDCANCEL) {
  728. SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
  729. }
  730. }
  731. if ((u = GetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, (BOOL FAR *)&iresult, FALSE))
  732. != (UINT)Pif386ext->PfFPriority) {
  733. if(iresult) {
  734. result = TRUE;
  735. Pif386ext->PfFPriority = u;
  736. }
  737. }
  738. if ((u = GetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, (BOOL FAR *)&iresult, FALSE))
  739. != (UINT)Pif386ext->PfBPriority) {
  740. if(iresult) {
  741. result = TRUE;
  742. Pif386ext->PfBPriority = u;
  743. }
  744. }
  745. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_POLL))
  746. W386flags |= fPollingDetect;
  747. else
  748. W386flags &= ~fPollingDetect;
  749. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTTAB))
  750. W386flags |= fALTTABdis;
  751. else
  752. W386flags &= ~fALTTABdis;
  753. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTESC))
  754. W386flags |= fALTESCdis;
  755. else
  756. W386flags &= ~fALTESCdis;
  757. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_CTRLESC))
  758. W386flags |= fCTRLESCdis;
  759. else
  760. W386flags &= ~fCTRLESCdis;
  761. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTSPACE))
  762. W386flags |= fALTSPACEdis;
  763. else
  764. W386flags &= ~fALTSPACEdis;
  765. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTENTER))
  766. W386flags |= fALTENTERdis;
  767. else
  768. W386flags &= ~fALTENTERdis;
  769. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTPRTSC))
  770. W386flags |= fALTPRTSCdis;
  771. else
  772. W386flags &= ~fALTPRTSCdis;
  773. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_PRTSC))
  774. W386flags |= fPRTSCdis;
  775. else
  776. W386flags &= ~fPRTSCdis;
  777. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_NOHMA))
  778. W386flags &= ~fNoHMA;
  779. else
  780. W386flags |= fNoHMA;
  781. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_INT16PST))
  782. W386flags |= fINT16Paste;
  783. else
  784. W386flags &= ~fINT16Paste;
  785. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_VMLOCKED))
  786. W386flags |= fVMLocked;
  787. else
  788. W386flags &= ~fVMLocked;
  789. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_CLOSE))
  790. W386flags |= fEnableClose;
  791. else
  792. W386flags &= ~fEnableClose;
  793. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_EMSLOCKED))
  794. W386flags |= fEMSLocked;
  795. else
  796. W386flags &= ~fEMSLocked;
  797. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_XMSLOCKED))
  798. W386flags |= fXMSLocked;
  799. else
  800. W386flags &= ~fXMSLocked;
  801. }
  802. if((Pif386ext->PfHotKeyScan != 0)||(Pif386ext->PfHotKeyShVal != 0)||(Pif386ext->PfHotKeyShMsk != 0))
  803. W386flags |= fHasHotKey;
  804. else
  805. W386flags &= ~fHasHotKey;
  806. if (W386flags != Pif386ext->PfW386Flags) {
  807. Pif386ext->PfW386Flags = W386flags;
  808. result = TRUE;
  809. }
  810. W386flags = Pif386ext->PfW386Flags2;
  811. W386flags &= ~(fVidTextMd | fVidLowRsGrfxMd | fVidHghRsGrfxMd);
  812. if (IsDlgButtonChecked(hwndPifDlg, IDI_VMODETXT))
  813. W386flags |= fVidTextMd;
  814. else if (IsDlgButtonChecked(hwndPifDlg, IDI_VMODELRGRFX))
  815. W386flags |= fVidLowRsGrfxMd;
  816. else
  817. W386flags |= fVidHghRsGrfxMd;
  818. if(hwndAdvPifDlg) {
  819. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_RETAINALLO))
  820. W386flags |= fVidRetainAllo;
  821. else
  822. W386flags &= ~fVidRetainAllo;
  823. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TEXTEMULATE))
  824. W386flags |= fVidTxtEmulate;
  825. else
  826. W386flags &= ~fVidTxtEmulate;
  827. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPTXT))
  828. W386flags &= ~fVidNoTrpTxt;
  829. else
  830. W386flags |= fVidNoTrpTxt;
  831. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPLRGRFX))
  832. W386flags &= ~fVidNoTrpLRGrfx;
  833. else
  834. W386flags |= fVidNoTrpLRGrfx;
  835. if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPHRGRFX))
  836. W386flags &= ~fVidNoTrpHRGrfx;
  837. else
  838. W386flags |= fVidNoTrpHRGrfx;
  839. }
  840. if (W386flags != Pif386ext->PfW386Flags2) {
  841. Pif386ext->PfW386Flags2 = W386flags;
  842. result = TRUE;
  843. }
  844. return(result);
  845. }
  846. /* make the structure match the screen */
  847. BOOL UpdatePifStruct(void)
  848. {
  849. unsigned char rgch[200];
  850. int cch;
  851. unsigned char *pch;
  852. char flags;
  853. unsigned flags2;
  854. int result;
  855. BOOL iresult;
  856. int i;
  857. unsigned int u;
  858. result = FALSE; /* did anything change? */
  859. if (SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_GETMODIFY, 0, 0L))
  860. result = TRUE;
  861. cch = GetDlgItemText(hwndPifDlg, IDI_ENAME, (LPSTR)PifFile->startfile, PIFSTARTLOCSIZE);
  862. AnsiUpper((LPSTR)PifFile->startfile);
  863. AnsiToOem((LPSTR)PifFile->startfile,(LPSTR)PifFile->startfile);
  864. /*
  865. * Trim off leading spaces
  866. */
  867. for (pch = (PUCHAR)PifFile->startfile; *pch == ' '; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
  868. ;
  869. lstrcpy((LPTSTR)PifFile->startfile, (LPCTSTR)pch);
  870. /*
  871. * Point to last char of string
  872. */
  873. for (pch = (PUCHAR)PifFile->startfile; *pch; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
  874. ;
  875. if (pch > PifFile->startfile)
  876. pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->startfile,(LPCTSTR)pch);
  877. /*
  878. * Trim trailing spaces
  879. */
  880. while (*pch == ' ' && pch > PifFile->startfile)
  881. pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->startfile,(LPCTSTR)pch);
  882. pch=AnsiNext(pch);
  883. *pch++ = 0;
  884. /*
  885. * Space pad out to full field width
  886. */
  887. for (cch = pch - PifFile->startfile; cch < PIFSTARTLOCSIZE; ++cch)
  888. *pch++ = ' ';
  889. if (SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_GETMODIFY, 0, 0L))
  890. result = TRUE;
  891. cch = GetDlgItemText(hwndPifDlg, IDI_ETITLE, (LPSTR)rgch, PIFNAMESIZE+1);
  892. AnsiToOem((LPSTR)rgch,(LPSTR)rgch);
  893. /*
  894. * NOTE: the PifFile->name field will NOT be nul terminated if it is
  895. * PIFNAMESIZE bytes long
  896. *
  897. * Trim off leading spaces
  898. */
  899. for (pch = rgch; *pch == ' '; pch=AnsiNext(pch))
  900. ;
  901. lstrcpy((LPSTR)rgch, (LPSTR)pch);
  902. /*
  903. * Point to last char of string
  904. */
  905. for (pch = rgch; *pch; pch=AnsiNext(pch))
  906. ;
  907. if (pch > rgch)
  908. pch =AnsiPrev(rgch,pch);
  909. /*
  910. * Trim trailing spaces
  911. */
  912. while (*pch == ' ' && pch > rgch)
  913. pch=AnsiPrev(rgch,pch);
  914. pch=AnsiNext(pch);
  915. *pch++ = '\0';
  916. /*
  917. * Space pad out to full field width
  918. */
  919. for (cch = pch - rgch; cch < PIFNAMESIZE; ++cch)
  920. *pch++ = ' ';
  921. for(i = 0;i < PIFNAMESIZE; i++)
  922. PifFile->name[i] = rgch[i];
  923. if (SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_GETMODIFY, 0, 0L))
  924. result = TRUE;
  925. cch = GetDlgItemText(hwndPifDlg, IDI_EPATH, (LPSTR)PifFile->defpath, PIFDEFPATHSIZE-1);
  926. AnsiUpper((LPSTR)PifFile->defpath);
  927. AnsiToOem((LPSTR)PifFile->defpath,(LPSTR)PifFile->defpath);
  928. /*
  929. * Trim off leading spaces
  930. */
  931. for (pch = (PUCHAR)PifFile->defpath;*pch == ' '; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
  932. ;
  933. lstrcpy((LPSTR)PifFile->defpath, (LPSTR)pch);
  934. /*
  935. * Point to last char of string
  936. */
  937. for (pch = (PUCHAR)PifFile->defpath; *pch; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
  938. ;
  939. if (pch > PifFile->defpath)
  940. pch = (PUCHAR)AnsiPrev((LPCTSTR)PifFile->defpath,(LPCTSTR)pch);
  941. /*
  942. * Trim trailing spaces
  943. */
  944. while (*pch == ' ' && pch > PifFile->defpath)
  945. pch = (PUCHAR)AnsiPrev((LPCTSTR)PifFile->defpath,(LPCTSTR)pch);
  946. pch = (PUCHAR)AnsiNext((LPCTSTR)pch);
  947. *pch++ = 0;
  948. /*
  949. * Space pad out to full field width
  950. */
  951. for (cch = pch - PifFile->defpath; cch < PIFDEFPATHSIZE; ++cch)
  952. *pch++ = ' ';
  953. flags = PifFile->MSflags;
  954. if (IsDlgButtonChecked(hwndPifDlg, IDI_EXIT))
  955. flags |= EXITMASK;
  956. else
  957. flags &= NOTEXITMASK;
  958. if(CurrMode386) {
  959. if(UpdatePif386Struc())
  960. result = TRUE;
  961. if(UpdatePifNTStruc())
  962. result = TRUE;
  963. } else {
  964. if(UpdateParms((PUCHAR)PifFile->params))
  965. result = TRUE;
  966. /*
  967. * Return of zero here ignored (set IDI_MEMREQ to 0)
  968. */
  969. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&iresult, TRUE))
  970. != PifFile->minmem) {
  971. if(iresult) {
  972. result = TRUE;
  973. PifFile->minmem = i;
  974. }
  975. }
  976. /*
  977. * if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&iresult, TRUE))
  978. * != PifFile->maxmem) {
  979. * if(iresult) {
  980. * result = TRUE;
  981. * PifFile->maxmem = i;
  982. * }
  983. * }
  984. */
  985. if (IsDlgButtonChecked(hwndPifDlg, IDI_PSNONE)) {
  986. flags |= PSMASK;
  987. } else {
  988. flags &= NOTPSMASK;
  989. }
  990. if (IsDlgButtonChecked(hwndPifDlg, IDI_SENONE)) {
  991. flags |= SGMASK; /* disable screen grabber */
  992. } else {
  993. flags &= NOTSGMASK;
  994. }
  995. if (IsDlgButtonChecked(hwndPifDlg, IDI_PSTEXT) ) {
  996. if (PifFile->sysmem >= 16)
  997. PifFile->sysmem = 7;
  998. flags &= TEXTMASK;
  999. } else {
  1000. if (PifFile->sysmem < 16)
  1001. PifFile->sysmem = 23;
  1002. flags |= GRAPHMASK;
  1003. }
  1004. /*
  1005. * if (IsDlgButtonChecked(hwndPifDlg, IDI_PSNONE)) {
  1006. * flags |= PSMASK;
  1007. * } else {
  1008. * flags &= NOTPSMASK;
  1009. * if ((IsDlgButtonChecked(hwndPifDlg, IDI_PSTEXT)) && (PifFile->sysmem >= 16))
  1010. * PifFile->sysmem = 7;
  1011. * else if ((IsDlgButtonChecked(hwndPifDlg, IDI_PSGRAPH)) && (PifFile->sysmem < 16) )
  1012. * PifFile->sysmem = 23;
  1013. * }
  1014. *
  1015. * if (IsDlgButtonChecked(hwndPifDlg, IDI_SENONE)) {
  1016. * flags |= SGMASK;
  1017. * } else if (IsDlgButtonChecked(hwndPifDlg, IDI_SETEXT)) {
  1018. * flags &= TEXTMASK;
  1019. * flags &= NOTSGMASK;
  1020. * } else if (IsDlgButtonChecked(hwndPifDlg, IDI_SEGRAPH)) {
  1021. * flags |= GRAPHMASK;
  1022. * flags &= NOTSGMASK;
  1023. * }
  1024. *
  1025. * if (IsDlgButtonChecked(hwndPifDlg, IDI_DMSCREEN)) {
  1026. * if (!(PifFile->behavior & SCRMASK))
  1027. * result = TRUE;
  1028. * PifFile->behavior |= SCRMASK;
  1029. * } else {
  1030. * if (PifFile->behavior & SCRMASK)
  1031. * result = TRUE;
  1032. * PifFile->behavior &= NOTSCRMASK;
  1033. * }
  1034. *
  1035. * if (IsDlgButtonChecked(hwndPifDlg, IDI_DMMEM))
  1036. * flags |= MEMMASK;
  1037. * else
  1038. * flags &= NOTMEMMASK;
  1039. */
  1040. if (IsDlgButtonChecked(hwndPifDlg, IDI_DMKBD)) {
  1041. if (!(PifFile->behavior & KEYMASK))
  1042. result = TRUE;
  1043. PifFile->behavior |= KEYMASK;
  1044. } else {
  1045. if (PifFile->behavior & KEYMASK)
  1046. result = TRUE;
  1047. PifFile->behavior &= NOTKEYMASK;
  1048. }
  1049. if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM1))
  1050. flags |= COM1MASK;
  1051. else
  1052. flags &= NOTCOM1MASK;
  1053. if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM2))
  1054. flags |= COM2MASK;
  1055. else
  1056. flags &= NOTCOM2MASK;
  1057. if(Pif286ext30) {
  1058. flags2 = 0;
  1059. if (IsDlgButtonChecked(hwndPifDlg, IDI_NOSAVVID))
  1060. flags2 |= fNoSaveVid286;
  1061. else
  1062. flags2 &= ~fNoSaveVid286;
  1063. if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM3))
  1064. flags2 |= fCOM3_286;
  1065. else
  1066. flags2 &= ~fCOM3_286;
  1067. if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM4))
  1068. flags2 |= fCOM4_286;
  1069. else
  1070. flags2 &= ~fCOM4_286;
  1071. if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTTAB))
  1072. flags2 |= fALTTABdis286;
  1073. else
  1074. flags2 &= ~fALTTABdis286;
  1075. if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTESC))
  1076. flags2 |= fALTESCdis286;
  1077. else
  1078. flags2 &= ~fALTESCdis286;
  1079. if (IsDlgButtonChecked(hwndPifDlg, IDI_CTRLESC))
  1080. flags2 |= fCTRLESCdis286;
  1081. else
  1082. flags2 &= ~fCTRLESCdis286;
  1083. if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTPRTSC))
  1084. flags2 |= fALTPRTSCdis286;
  1085. else
  1086. flags2 &= ~fALTPRTSCdis286;
  1087. if (IsDlgButtonChecked(hwndPifDlg, IDI_PRTSC))
  1088. flags2 |= fPRTSCdis286;
  1089. else
  1090. flags2 &= ~fPRTSCdis286;
  1091. if ((u = GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&iresult, FALSE))
  1092. != (UINT)Pif286ext30->PfMinXmsK) {
  1093. if(iresult) {
  1094. result = TRUE;
  1095. Pif286ext30->PfMinXmsK = u;
  1096. }
  1097. }
  1098. if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&iresult, TRUE))
  1099. != Pif286ext30->PfMaxXmsK) {
  1100. if(iresult) {
  1101. result = TRUE;
  1102. Pif286ext30->PfMaxXmsK = i;
  1103. }
  1104. }
  1105. if (flags2 != (unsigned)Pif286ext30->PfW286Flags) {
  1106. Pif286ext30->PfW286Flags = flags2;
  1107. result = TRUE;
  1108. }
  1109. }
  1110. /*
  1111. * if(Pif286ext31) {
  1112. *
  1113. * if ((u = GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&iresult, FALSE))
  1114. * != Pif286ext31->PfMinEmsK) {
  1115. * if(iresult) {
  1116. * result = TRUE;
  1117. * Pif286ext31->PfMinEmsK = u;
  1118. * }
  1119. * }
  1120. *
  1121. * if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&iresult, TRUE))
  1122. * != Pif286ext31->PfMaxEmsK) {
  1123. * if(iresult) {
  1124. * result = TRUE;
  1125. * Pif286ext31->PfMaxEmsK = i;
  1126. * }
  1127. * }
  1128. * }
  1129. */
  1130. }
  1131. if (flags != PifFile->MSflags) {
  1132. PifFile->MSflags = flags;
  1133. result = TRUE;
  1134. }
  1135. return(result);
  1136. }
  1137. BOOL DoFieldsWorkAdv(BOOL all)
  1138. {
  1139. BOOL result;
  1140. BOOL result2;
  1141. /*
  1142. * Check to make sure numeric edit controls actually have numbers in them
  1143. */
  1144. if(hwndAdvPifDlg) {
  1145. GetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, (BOOL FAR *)&result, FALSE);
  1146. GetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, (BOOL FAR *)&result2, FALSE);
  1147. if((!result) || (!result2)) {
  1148. Warning(errBadNumberP,MB_ICONEXCLAMATION | MB_OK);
  1149. return(FALSE);
  1150. }
  1151. }
  1152. if (Pif386ext && CurrMode386) {
  1153. if ((Pif386ext->PfMaxEMMK > 0) && ((int)Pif386ext->PfMinEMMK > Pif386ext->PfMaxEMMK)) {
  1154. Warning(errEMMMaxMin386,MB_ICONEXCLAMATION | MB_OK);
  1155. return(FALSE);
  1156. }
  1157. if ((Pif386ext->PfMaxXmsK > 0) && ((int)Pif386ext->PfMinXmsK > Pif386ext->PfMaxXmsK)) {
  1158. Warning(errXMSMaxMin386,MB_ICONEXCLAMATION | MB_OK);
  1159. return(FALSE);
  1160. }
  1161. }
  1162. return(TRUE);
  1163. }
  1164. void SetNTDlgItem(int itemID)
  1165. {
  1166. HWND hwnd;
  1167. SetStatusText(hwndNTPifDlg, itemID, TRUE);
  1168. hwnd = GetDlgItem(hwndNTPifDlg, itemID);
  1169. SetFocus(hwnd);
  1170. SendMessage(hwnd, EM_SETSEL,0,-1);
  1171. }
  1172. BOOL DoFieldsWorkNT(BOOL all)
  1173. {
  1174. UCHAR szFile[PIFDEFPATHSIZE*2];
  1175. UCHAR szFileExp[PIFDEFPATHSIZE*4];
  1176. OFSTRUCT of;
  1177. /*
  1178. * Check to make sure Autoexec & Config fields have valid filenames in them
  1179. */
  1180. if(hwndNTPifDlg) {
  1181. if(!GetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,szFile,PIFDEFPATHSIZE-1)) {
  1182. if(!fNoNTAWarn) {
  1183. if(Warning(errNoNTAFile,
  1184. MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
  1185. == IDCANCEL) {
  1186. SetNTDlgItem(IDI_AUTOEXEC);
  1187. return(FALSE);
  1188. }
  1189. else
  1190. fNoNTAWarn = TRUE;
  1191. }
  1192. }
  1193. else {
  1194. if(ExpandFileSpec(szFileExp, szFile, errBadAutoPath)) {
  1195. if(OpenFile(szFileExp,&of,OF_EXIST) == HFILE_ERROR) {
  1196. if(!fNTAWarnne){
  1197. if(Warning(errNTAFilene, MB_ICONEXCLAMATION |
  1198. MB_OKCANCEL |
  1199. MB_DEFBUTTON2) == IDCANCEL) {
  1200. SetNTDlgItem(IDI_AUTOEXEC);
  1201. return(FALSE);
  1202. }
  1203. else
  1204. fNTAWarnne = TRUE;
  1205. }
  1206. }
  1207. }
  1208. else {
  1209. SetNTDlgItem(IDI_AUTOEXEC);
  1210. return(FALSE);
  1211. }
  1212. }
  1213. if(!GetDlgItemText(hwndNTPifDlg,IDI_CONFIG,szFile,PIFDEFPATHSIZE-1)) {
  1214. if(!fNoNTCWarn) {
  1215. if(Warning(errNoNTCFile,
  1216. MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
  1217. == IDCANCEL) {
  1218. SetNTDlgItem(IDI_CONFIG);
  1219. return(FALSE);
  1220. }
  1221. else
  1222. fNoNTCWarn = TRUE;
  1223. }
  1224. }
  1225. else {
  1226. if(ExpandFileSpec(szFileExp, szFile, errBadConfigPath)) {
  1227. if(OpenFile(szFileExp,&of,OF_EXIST) == HFILE_ERROR) {
  1228. if(!fNTCWarnne){
  1229. if(Warning(errNTCFilene, MB_ICONEXCLAMATION |
  1230. MB_OKCANCEL |
  1231. MB_DEFBUTTON2) == IDCANCEL) {
  1232. SetNTDlgItem(IDI_CONFIG);
  1233. return(FALSE);
  1234. }
  1235. else
  1236. fNTCWarnne = TRUE;
  1237. }
  1238. }
  1239. }
  1240. else {
  1241. SetNTDlgItem(IDI_CONFIG);
  1242. return(FALSE);
  1243. }
  1244. }
  1245. }
  1246. return(TRUE);
  1247. }
  1248. BOOL DoFieldsWork(BOOL all)
  1249. {
  1250. BOOL result;
  1251. BOOL result2;
  1252. if(!DoFieldsWorkAdv(all))
  1253. return(FALSE);
  1254. if(!DoFieldsWorkNT(all))
  1255. return(FALSE);
  1256. /*
  1257. * Check to make sure numeric edit controls actually have numbers in them
  1258. */
  1259. if(hwndPifDlg) {
  1260. if(CurrMode386) {
  1261. GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&result, TRUE);
  1262. } else {
  1263. result = TRUE;
  1264. }
  1265. GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&result2, TRUE);
  1266. if(!result2) {
  1267. Warning(errBadNumberMR,MB_ICONEXCLAMATION | MB_OK);
  1268. return(FALSE);
  1269. }
  1270. if(!result) {
  1271. Warning(errBadNumberMD,MB_ICONEXCLAMATION | MB_OK);
  1272. return(FALSE);
  1273. }
  1274. GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&result, TRUE);
  1275. GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&result2, FALSE);
  1276. if(!result2) {
  1277. Warning(errBadNumberXEMSR,MB_ICONEXCLAMATION | MB_OK);
  1278. return(FALSE);
  1279. }
  1280. if(!result) {
  1281. Warning(errBadNumberXEMSD,MB_ICONEXCLAMATION | MB_OK);
  1282. return(FALSE);
  1283. }
  1284. if(CurrMode386) {
  1285. GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&result, TRUE);
  1286. GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&result2, FALSE);
  1287. if(!result2) {
  1288. Warning(errBadNumberXEMSR,MB_ICONEXCLAMATION | MB_OK);
  1289. return(FALSE);
  1290. }
  1291. if(!result) {
  1292. Warning(errBadNumberXEMSD,MB_ICONEXCLAMATION | MB_OK);
  1293. return(FALSE);
  1294. }
  1295. } else {
  1296. }
  1297. }
  1298. if (Pif386ext && CurrMode386) {
  1299. if ((Pif386ext->maxmem > 0) &&
  1300. ((Pif386ext->minmem == -1) || (Pif386ext->minmem > Pif386ext->maxmem))
  1301. ) {
  1302. Warning(errMmMaxMin386,MB_ICONEXCLAMATION | MB_OK);
  1303. return(FALSE);
  1304. }
  1305. }
  1306. if ((PifFile->maxmem > 0) &&
  1307. ((PifFile->minmem == -1) || (PifFile->minmem > PifFile->maxmem))
  1308. ) {
  1309. /*
  1310. * Warning(errMmMaxMin286,MB_ICONEXCLAMATION | MB_OK);
  1311. * return(FALSE);
  1312. */
  1313. PifFile->maxmem = PifFile->minmem;
  1314. }
  1315. if (Pif286ext30) {
  1316. if ((Pif286ext30->PfMaxXmsK > 0) && ((int)Pif286ext30->PfMinXmsK > Pif286ext30->PfMaxXmsK)) {
  1317. Warning(errXMSMaxMin286,MB_ICONEXCLAMATION | MB_OK);
  1318. return(FALSE);
  1319. }
  1320. }
  1321. /*
  1322. * if (Pif286ext31) {
  1323. * if ((Pif286ext31->PfMaxEmsK > 0) && ((int)Pif286ext31->PfMinEmsK > Pif286ext31->PfMaxEmsK)) {
  1324. * Warning(errEMMMaxMin286,MB_ICONEXCLAMATION | MB_OK);
  1325. * return(FALSE);
  1326. * }
  1327. * }
  1328. */
  1329. if(all) {
  1330. if (PifFile->lowVector > PifFile->highVector && (PifFile->sysflags & SWAPMASK)) {
  1331. Warning(errHiLow,MB_ICONEXCLAMATION | MB_OK);
  1332. return(FALSE);
  1333. }
  1334. if(!ValidFileSpec((LPSTR)PifFile->startfile, errBadProgram))
  1335. return(FALSE);
  1336. }
  1337. return(TRUE);
  1338. }
  1339. BOOL ExpandFileSpec(LPSTR lpstrExp, LPSTR lpstr, int errID)
  1340. {
  1341. int len, cPath;
  1342. UCHAR sz[PIFDEFPATHSIZE*2];
  1343. LPSTR psz;
  1344. if(!ValidFileSpec(lpstr, errID)) {
  1345. return(FALSE);
  1346. }
  1347. cPath = PIFDEFPATHSIZE * 2;
  1348. while(*lpstr) {
  1349. if(*lpstr == '%') {
  1350. lpstr++;
  1351. lstrcpy(sz, lpstr);
  1352. psz = &sz[0];
  1353. while(*psz && (*psz != '%')) {
  1354. psz++;
  1355. }
  1356. if(*psz != '%') {
  1357. Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
  1358. return(FALSE);
  1359. }
  1360. len = psz - &sz[0];
  1361. sz[len] = '\0';
  1362. lpstr += len + 1;
  1363. if(len = GetEnvironmentVariable(sz, lpstrExp, cPath)) {
  1364. cPath -= len;
  1365. if(cPath <= 0) {
  1366. Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
  1367. return(FALSE);
  1368. }
  1369. lpstrExp += len;
  1370. }
  1371. else {
  1372. Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
  1373. return(FALSE);
  1374. }
  1375. }
  1376. else {
  1377. *lpstrExp++ = *lpstr++;
  1378. cPath--;
  1379. }
  1380. if(cPath <= 0) {
  1381. Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
  1382. return(FALSE);
  1383. }
  1384. }
  1385. *lpstrExp = '\0';
  1386. return(TRUE);
  1387. }
  1388. BOOL ValidFileSpec(LPSTR lpstr, int iCaller)
  1389. {
  1390. int len;
  1391. LPSTR pch, pch2;
  1392. int errID;
  1393. BOOL fExt = FALSE;
  1394. switch( iCaller ) {
  1395. case errBadAutoPath:
  1396. errID = errBadAutoName;
  1397. break;
  1398. case errBadConfigPath:
  1399. errID = errBadConName;
  1400. break;
  1401. default:
  1402. fExt = TRUE;
  1403. errID = errBadProgram;
  1404. break;
  1405. }
  1406. len = lstrlen((LPSTR)lpstr);
  1407. pch = lpstr + len;
  1408. pch = AnsiPrev(lpstr,pch);
  1409. while (*pch &&
  1410. *pch != ':' &&
  1411. *pch != '.' &&
  1412. *pch != '\\' &&
  1413. pch > lpstr)
  1414. pch=AnsiPrev(lpstr,pch);
  1415. if (*pch != '.') {
  1416. if(fExt) {
  1417. if(Warning(errBadExt,MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2)
  1418. == IDCANCEL)
  1419. return(FALSE);
  1420. }
  1421. /*
  1422. * No extension given, reset pch to end of the string so
  1423. * following 8 char name check doesn't trip as well unless
  1424. * it is supposed to.
  1425. */
  1426. pch = lpstr + len;
  1427. }
  1428. else if(fExt){
  1429. /*
  1430. * At this point we know *pch == '.'
  1431. */
  1432. if (lstrcmp((LPSTR)(pch+1), (LPSTR)"EXE") &&
  1433. lstrcmp((LPSTR)(pch+1), (LPSTR)"COM") &&
  1434. lstrcmp((LPSTR)(pch+1), (LPSTR)"BAT")) {
  1435. if(Warning(errBadExt,MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2)
  1436. == IDCANCEL)
  1437. return(FALSE);
  1438. }
  1439. }
  1440. if(pch <= lpstr) {
  1441. if(Warning(errID, MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
  1442. == IDCANCEL)
  1443. return(FALSE);
  1444. }
  1445. else {
  1446. for (pch2 = AnsiPrev(lpstr,pch);
  1447. pch2 > lpstr && *pch2 != '\\' && *pch2 != ':';
  1448. pch2 = AnsiPrev(lpstr,pch2)) {
  1449. if(*pch2 < ' ' ||
  1450. *pch2 == '*' ||
  1451. *pch2 == '?' ||
  1452. *pch2 == '[' ||
  1453. *pch2 == ']' ||
  1454. *pch2 == '>' ||
  1455. *pch2 == '<' ||
  1456. *pch2 == '|' ||
  1457. *pch2 == '"' ||
  1458. *pch2 == '=' ||
  1459. *pch2 == '+' ||
  1460. *pch2 == ';' ||
  1461. *pch2 == ',' ||
  1462. *pch2 == '.' ) {
  1463. if(Warning(errID,
  1464. MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
  1465. == IDCANCEL)
  1466. return(FALSE);
  1467. else
  1468. break; /* from for loop */
  1469. }
  1470. }
  1471. if((*pch2 == '\\') || (*pch2 == ':'))
  1472. pch2=AnsiNext(pch2);
  1473. if (pch - pch2 > 8 || pch - pch2 == 0) {
  1474. if(Warning(errID,MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2) == IDCANCEL)
  1475. return(FALSE);
  1476. }
  1477. }
  1478. return(TRUE);
  1479. }
  1480. ResetStd(void)
  1481. {
  1482. InitStdPIFExt();
  1483. InitPif386Struc();
  1484. InitPif286Struc();
  1485. InitPifNTStruc();
  1486. return(TRUE);
  1487. }
  1488. LoadPifFile(PSTR pchFile)
  1489. {
  1490. int fh;
  1491. unsigned char *pch;
  1492. OFSTRUCT ofReopen;
  1493. unsigned long fsize;
  1494. PIFEXTHEADER UNALIGNED *hdrptr;
  1495. BOOL scandone;
  1496. BOOL Pif2X = FALSE;
  1497. ofReopen.szPathName[0] = 0;
  1498. if ((fh = OpenFile((LPSTR)pchFile, (LPOFSTRUCT)&ofReopen, OF_READ | OF_SHARE_DENY_WRITE)) != -1) {
  1499. fsize = _llseek( fh, 0L, 2);
  1500. _llseek( fh, 0L, 0);
  1501. if(fsize >= PIFEDITMAXPIFL) {
  1502. Warning(errNoOpen,MB_ICONEXCLAMATION | MB_OK);
  1503. InitPifStruct();
  1504. _lclose(fh);
  1505. return(FALSE);
  1506. }
  1507. _lread(fh, (LPSTR)PifBuf, PIFEDITMAXPIF);
  1508. FileChanged = FALSE;
  1509. Pif386ext = (PIF386EXT *)NULL;
  1510. PifNText = (PIFWNTEXT *)NULL;
  1511. Pif286ext30 = (PIF286EXT30 *)NULL;
  1512. /*
  1513. * Pif286ext31 = (PIF286EXT31 *)NULL;
  1514. */
  1515. PifFileSize = LOWORD(fsize);
  1516. if(fsize < (long)sizeof(PIFOLD286STR)) {
  1517. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1518. ResetStd();
  1519. FileChanged = TRUE;
  1520. } else if(fsize == (long)sizeof(PIFOLD286STR)) {
  1521. Warning(PIFOLDFIL,MB_ICONEXCLAMATION | MB_OK);
  1522. Pif2X = TRUE;
  1523. ResetStd();
  1524. FileChanged = TRUE;
  1525. if(Pif386ext) {
  1526. Pif386ext->PfHotKeyScan = InMemHotKeyScan = 0;
  1527. Pif386ext->PfHotKeyShVal = InMemHotKeyShVal = 0;
  1528. Pif386ext->PfHotKeyShMsk = InMemHotKeyShMsk = 0;
  1529. if (PifFile->behavior & KEYMASK)
  1530. Pif386ext->PfW386Flags |= fExclusive;
  1531. else
  1532. Pif386ext->PfW386Flags &= ~fExclusive;
  1533. if (PifFile->MSflags & MEMMASK)
  1534. Pif386ext->PfW386Flags |= fBackground;
  1535. else
  1536. Pif386ext->PfW386Flags &= ~fBackground;
  1537. if (PifFile->behavior & SCRMASK)
  1538. Pif386ext->PfW386Flags |= fFullScreen;
  1539. else
  1540. Pif386ext->PfW386Flags &= ~fFullScreen;
  1541. Pif386ext->maxmem = PifFile->maxmem;
  1542. Pif386ext->minmem = PifFile->minmem;
  1543. }
  1544. if(Pif286ext30) {
  1545. Pif286ext30->PfMaxXmsK = 0;
  1546. Pif286ext30->PfMinXmsK = 0;
  1547. Pif286ext30->PfW286Flags = 0;
  1548. if(Pif386ext) {
  1549. if(Pif386ext->PfW386Flags & fALTTABdis)
  1550. Pif286ext30->PfW286Flags |= fALTTABdis286;
  1551. if(Pif386ext->PfW386Flags & fALTESCdis)
  1552. Pif286ext30->PfW286Flags |= fALTESCdis286;
  1553. if(Pif386ext->PfW386Flags & fCTRLESCdis)
  1554. Pif286ext30->PfW286Flags |= fCTRLESCdis286;
  1555. if(Pif386ext->PfW386Flags & fALTPRTSCdis)
  1556. Pif286ext30->PfW286Flags |= fALTPRTSCdis286;
  1557. if(Pif386ext->PfW386Flags & fPRTSCdis)
  1558. Pif286ext30->PfW286Flags |= fPRTSCdis286;
  1559. }
  1560. }
  1561. /*
  1562. * if(Pif286ext31) {
  1563. * Pif286ext31->PfMaxEmsK = 0;
  1564. * Pif286ext31->PfMinEmsK = 0;
  1565. * }
  1566. */
  1567. } else {
  1568. if(lstrcmp((LPSTR)PifFile->stdpifext.extsig, (LPSTR)stdHdr)) {
  1569. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1570. ResetStd();
  1571. FileChanged = TRUE;
  1572. } else {
  1573. hdrptr = &PifFile->stdpifext;
  1574. scandone = FALSE;
  1575. while(!scandone) {
  1576. if(hdrptr->extnxthdrfloff == LASTHEADERPTR) {
  1577. scandone = TRUE;
  1578. LastPifExt = hdrptr;
  1579. } else if((unsigned)hdrptr->extnxthdrfloff >= PifFileSize) {
  1580. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1581. ResetStd();
  1582. FileChanged = TRUE;
  1583. break;
  1584. }
  1585. if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w386Hdr)) {
  1586. if((hdrptr->extsizebytes == sizeof(PIF386EXT)) &&
  1587. ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIF386EXT))) {
  1588. Pif386ext = (PIF386EXT *)(PifBuf + hdrptr->extfileoffset);
  1589. SetHotKeyTextFromPIF();
  1590. } else {
  1591. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1592. ResetStd();
  1593. FileChanged = TRUE;
  1594. break;
  1595. }
  1596. } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w286Hdr30)) {
  1597. if((hdrptr->extsizebytes == sizeof(PIF286EXT30)) &&
  1598. ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIF286EXT30))) {
  1599. Pif286ext30 = (PIF286EXT30 *)(PifBuf + hdrptr->extfileoffset);
  1600. } else {
  1601. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1602. ResetStd();
  1603. FileChanged = TRUE;
  1604. break;
  1605. }
  1606. } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)wNTHdr)) {
  1607. if((hdrptr->extsizebytes == sizeof(PIFWNTEXT)) &&
  1608. ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIFWNTEXT))) {
  1609. PifNText = (PIFWNTEXT *)(PifBuf + hdrptr->extfileoffset);
  1610. } else {
  1611. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1612. ResetStd();
  1613. FileChanged = TRUE;
  1614. break;
  1615. }
  1616. }
  1617. /*
  1618. * } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w286Hdr31)) {
  1619. * if((hdrptr->extsizebytes == sizeof(PIF286EXT31)) &&
  1620. * (hdrptr->extfileoffset <= PifFileSize - sizeof(PIF286EXT31))) {
  1621. * Pif286ext31 = (PIF286EXT31 *)(PifBuf + hdrptr->extfileoffset);
  1622. * } else {
  1623. * Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1624. * ResetStd();
  1625. * FileChanged = TRUE;
  1626. * break;
  1627. * }
  1628. * }
  1629. */
  1630. if(!scandone)
  1631. hdrptr = (PIFEXTHEADER *)(PifBuf + hdrptr->extnxthdrfloff);
  1632. }
  1633. }
  1634. }
  1635. if(CurrMode386) {
  1636. if(!Pif386ext) {
  1637. if(!(Pif386ext = AllocInit386Ext())) {
  1638. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1639. ResetStd();
  1640. }
  1641. FileChanged = TRUE;
  1642. }
  1643. } else {
  1644. /*
  1645. * if(!Pif286ext31) {
  1646. * if(Pif286ext30 && !Pif2X)
  1647. * Warning(PIFOLDFIL2,MB_ICONEXCLAMATION | MB_OK);
  1648. * if(!(Pif286ext31 = AllocInit286Ext31())) {
  1649. * Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1650. * ResetStd();
  1651. * }
  1652. * FileChanged = TRUE;
  1653. * }
  1654. */
  1655. if(!Pif286ext30) {
  1656. if(!(Pif286ext30 = AllocInit286Ext30())) {
  1657. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1658. ResetStd();
  1659. }
  1660. FileChanged = TRUE;
  1661. }
  1662. if((PifFile->MSflags & GRAPHMASK) && (PifFile->sysmem <= 16))
  1663. PifFile->sysmem = 23;
  1664. if((!(PifFile->MSflags & GRAPHMASK)) && (PifFile->sysmem > 16))
  1665. PifFile->MSflags |= GRAPHMASK;
  1666. }
  1667. if(CurrMode386) {
  1668. if(!PifNText) {
  1669. if(!(PifNText = AllocInitNTExt())) {
  1670. Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
  1671. ResetStd();
  1672. }
  1673. //FileChanged = TRUE; //can be confusing if they don't change it
  1674. }
  1675. }
  1676. _lclose(fh);
  1677. /* Make sure that we have valid memory values. */
  1678. if (PifFile->minmem != -1) {
  1679. PifFile->minmem = max(PifFile->minmem, 0);
  1680. PifFile->minmem = min(PifFile->minmem, 640);
  1681. }
  1682. if (PifFile->maxmem != -1) {
  1683. PifFile->maxmem = max(PifFile->maxmem, 0);
  1684. PifFile->maxmem = min(PifFile->maxmem, 640);
  1685. }
  1686. if(Pif386ext) {
  1687. if (Pif386ext->minmem != -1) {
  1688. Pif386ext->minmem = max(Pif386ext->minmem, 0);
  1689. Pif386ext->minmem = min(Pif386ext->minmem, 640);
  1690. }
  1691. if (Pif386ext->maxmem != -1) {
  1692. Pif386ext->maxmem = max(Pif386ext->maxmem, 0);
  1693. Pif386ext->maxmem = min(Pif386ext->maxmem, 640);
  1694. }
  1695. Pif386ext->PfMinEMMK = max(Pif386ext->PfMinEMMK, 0);
  1696. Pif386ext->PfMinEMMK = min(Pif386ext->PfMinEMMK, 16384);
  1697. Pif386ext->PfMinXmsK = max(Pif386ext->PfMinXmsK, 0);
  1698. Pif386ext->PfMinXmsK = min(Pif386ext->PfMinXmsK, 16384);
  1699. if (Pif386ext->PfMaxEMMK != -1) {
  1700. Pif386ext->PfMaxEMMK = max(Pif386ext->PfMaxEMMK, 0);
  1701. Pif386ext->PfMaxEMMK = min(Pif386ext->PfMaxEMMK, 16384);
  1702. }
  1703. if (Pif386ext->PfMaxXmsK != -1) {
  1704. Pif386ext->PfMaxXmsK = max(Pif386ext->PfMaxXmsK, 0);
  1705. Pif386ext->PfMaxXmsK = min(Pif386ext->PfMaxXmsK, 16384);
  1706. }
  1707. if (Pif386ext->PfFPriority > 10000) {
  1708. Pif386ext->PfFPriority = 10000;
  1709. }
  1710. if (Pif386ext->PfBPriority > 10000) {
  1711. Pif386ext->PfBPriority = 10000;
  1712. }
  1713. if (Pif386ext->PfFPriority <= 0) {
  1714. Pif386ext->PfFPriority = 1;
  1715. }
  1716. if (Pif386ext->PfBPriority <= 0) {
  1717. Pif386ext->PfBPriority = 1;
  1718. }
  1719. }
  1720. /*
  1721. * if(Pif286ext31) {
  1722. * Pif286ext31->PfMinEmsK = max(Pif286ext31->PfMinEmsK, 0);
  1723. * Pif286ext31->PfMinEmsK = min(Pif286ext31->PfMinEmsK, 16384);
  1724. * if (Pif286ext31->PfMaxEmsK != -1) {
  1725. * Pif286ext31->PfMaxEmsK = max(Pif286ext31->PfMaxEmsK, 0);
  1726. * Pif286ext31->PfMaxEmsK = min(Pif286ext31->PfMaxEmsK, 16384);
  1727. * }
  1728. * }
  1729. */
  1730. if(Pif286ext30) {
  1731. Pif286ext30->PfMinXmsK = max(Pif286ext30->PfMinXmsK, 0);
  1732. Pif286ext30->PfMinXmsK = min(Pif286ext30->PfMinXmsK, 16384);
  1733. if (Pif286ext30->PfMaxXmsK != -1) {
  1734. Pif286ext30->PfMaxXmsK = max(Pif286ext30->PfMaxXmsK, 0);
  1735. Pif286ext30->PfMaxXmsK = min(Pif286ext30->PfMaxXmsK, 16384);
  1736. }
  1737. }
  1738. /*
  1739. * Trim trailing spaces off PifFile->name
  1740. */
  1741. for (pch = (PUCHAR)(PifFile->name+PIFNAMESIZE-1); *pch == ' ' && pch > PifFile->name; pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->name,(PUCHAR)pch))
  1742. ;
  1743. *++pch = 0;
  1744. /*
  1745. * Trim trailing spaces off PifFile->params (and Pif386ext->params)
  1746. */
  1747. for (pch = (PUCHAR)(PifFile->params+PIFPARAMSSIZE-1); *pch == ' ' && pch > PifFile->params; pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->params,(PUCHAR)pch))
  1748. ;
  1749. *++pch = 0;
  1750. if(Pif386ext) {
  1751. for (pch = (PUCHAR)(Pif386ext->params+PIFPARAMSSIZE-1); *pch == ' ' && pch > Pif386ext->params; pch=(PUCHAR)AnsiPrev((LPCTSTR)Pif386ext->params,(PUCHAR)pch))
  1752. ;
  1753. *++pch = 0;
  1754. }
  1755. UpdatePifScreen();
  1756. //OemToAnsi((LPSTR)ofReopen.szPathName,(LPSTR)CurPifFile);
  1757. lstrcpy((LPSTR)CurPifFile, (LPSTR)ofReopen.szPathName);
  1758. AnsiUpper((LPSTR)CurPifFile);
  1759. SetFileOffsets(CurPifFile,&fileoffset,&extoffset);
  1760. } else {
  1761. fh = ofReopen.nErrCode;
  1762. switch (fh) {
  1763. case 2: /* File not found */
  1764. fh = errNoPIFfnf;
  1765. break;
  1766. case 3: /* Path not found */
  1767. fh = errNoPIFpnf;
  1768. break;
  1769. case 4: /* Too many open files */
  1770. fh = errNoFileHnds;
  1771. break;
  1772. case 5: /* Access denied */
  1773. fh = errNoAcc;
  1774. break;
  1775. case 32: /* Sharing violation */
  1776. fh = errSharing;
  1777. break;
  1778. default:
  1779. fh = errNoPIFfnf;
  1780. break;
  1781. }
  1782. Warning(fh,MB_ICONEXCLAMATION | MB_OK);
  1783. }
  1784. return(TRUE);
  1785. }
  1786. IsFileName(unsigned char *pchFile)
  1787. {
  1788. while (*pchFile) {
  1789. if (*pchFile <= ' ')
  1790. return(FALSE);
  1791. pchFile=AnsiNext(pchFile);
  1792. }
  1793. return(TRUE);
  1794. }
  1795. ClearChanges(void)
  1796. {
  1797. SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_SETMODIFY, FALSE, 0L);
  1798. SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_SETMODIFY, FALSE, 0L);
  1799. SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_SETMODIFY, FALSE, 0L);
  1800. SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
  1801. NewHotKey = FALSE;
  1802. FileChanged = FALSE;
  1803. return(TRUE);
  1804. }
  1805. int SavePifFile(PSTR pchFile, int wmcommand)
  1806. {
  1807. int fh;
  1808. OFSTRUCT ofReopen;
  1809. int i;
  1810. BYTE *p;
  1811. int stuffspot;
  1812. int cch;
  1813. #if 0
  1814. // This code is not needed since NTVDM can deal with long names in DAYTONA
  1815. // 24-Jan-1994 JonPa
  1816. if (!IsFileName(pchFile)) {
  1817. Warning(EINVALIDFILE,MB_ICONEXCLAMATION | MB_OK);
  1818. return(SAVERETRY);
  1819. }
  1820. #endif
  1821. UpdatePifStruct();
  1822. if (DoFieldsWork(TRUE)) {
  1823. PifFile->id = 0;
  1824. stuffspot = -1;
  1825. for(i = 0;i < PIFNAMESIZE; i++)
  1826. if(!PifFile->name[i]) {
  1827. PifFile->name[i] = ' ';
  1828. stuffspot = i;
  1829. }
  1830. p = (BYTE *)&PifFile->name[ 0 ];
  1831. i = PIFSIZE;
  1832. while (i--)
  1833. PifFile->id += *p++;
  1834. AnsiUpper((LPSTR) pchFile );
  1835. ofReopen.szPathName[0] = 0;
  1836. if ((fh = OpenFile((LPSTR)pchFile, (LPOFSTRUCT)&ofReopen, OF_CREATE | OF_READWRITE | OF_SHARE_EXCLUSIVE)) == -1) {
  1837. fh = ofReopen.nErrCode;
  1838. switch (fh) {
  1839. case 2: /* File not found */
  1840. fh = errNoCreate;
  1841. break;
  1842. case 3: /* Path not found */
  1843. fh = errNoPIFpnf;
  1844. break;
  1845. case 4: /* Too many open files */
  1846. fh = errNoFileHnds;
  1847. break;
  1848. case 5: /* Access denied */
  1849. fh = errCrtRO;
  1850. break;
  1851. case 32: /* Sharing violation */
  1852. fh = errSharing;
  1853. break;
  1854. default:
  1855. fh = errNoCreate;
  1856. break;
  1857. }
  1858. Warning(fh,MB_ICONEXCLAMATION | MB_OK);
  1859. if(stuffspot != -1)
  1860. PifFile->name[stuffspot] = '\0';
  1861. return(SAVERETRY);
  1862. }
  1863. cch = _lwrite(fh, (LPSTR)PifBuf, PifFileSize);
  1864. if(stuffspot != -1)
  1865. PifFile->name[stuffspot] = '\0';
  1866. _lclose(fh);
  1867. if ((unsigned)cch != PifFileSize) {
  1868. delete(pchFile);
  1869. Warning(errDiskFull,MB_ICONEXCLAMATION | MB_OK);
  1870. } else {
  1871. }
  1872. } else
  1873. return(SAVEERROR);
  1874. lstrcpy((LPSTR)CurPifFile, (LPSTR)pchFile);
  1875. AnsiUpper((LPSTR)CurPifFile);
  1876. SetFileOffsets(CurPifFile,&fileoffset,&extoffset);
  1877. ClearChanges();
  1878. return(SAVEDONE);
  1879. }
  1880. InitStdPIFExt(void)
  1881. {
  1882. lstrcpy((LPSTR)PifFile->stdpifext.extsig, (LPSTR)stdHdr);
  1883. PifFile->stdpifext.extnxthdrfloff = LASTHEADERPTR;
  1884. PifFile->stdpifext.extfileoffset = 0;
  1885. PifFile->stdpifext.extsizebytes = sizeof(PIFOLD286STR);
  1886. LastPifExt = &PifFile->stdpifext;
  1887. PifFileSize = sizeof(PIFNEWSTRUCT);
  1888. Pif386ext = (PIF386EXT *)NULL;
  1889. /*
  1890. * Pif286ext31 = (PIF286EXT31 *)NULL;
  1891. */
  1892. Pif286ext30 = (PIF286EXT30 *)NULL;
  1893. PifNText = (PIFWNTEXT *)NULL;
  1894. return(TRUE);
  1895. }
  1896. InitPifStruct(void)
  1897. {
  1898. BOOL result = TRUE;
  1899. PifFile->unknown = 0;
  1900. *PifFile->name = 0;
  1901. PifFile->maxmem = 128;
  1902. PifFile->minmem = 128;
  1903. *PifFile->startfile = 0;
  1904. *PifFile->defpath = 0;
  1905. *PifFile->params = 0;
  1906. PifFile->screen = 0x7F;
  1907. PifFile->cPages = 1;
  1908. PifFile->lowVector = 0;
  1909. PifFile->highVector = 0x0ff;
  1910. PifFile->rows = 25;
  1911. PifFile->cols = 80;
  1912. PifFile->rowoff = 0;
  1913. PifFile->coloff = 0;
  1914. PifFile->sysmem = 7;
  1915. *PifFile->shprog = 0;
  1916. *PifFile->shdata = 0;
  1917. PifFile->behavior = SCRMASK | MASK8087;
  1918. PifFile->sysflags = SWAPS;
  1919. PifFile->MSflags = EXITMASK;
  1920. InitStdPIFExt();
  1921. if(!(InitPif386Struc()))
  1922. result = FALSE;
  1923. if(!(InitPif286Struc()))
  1924. result = FALSE;
  1925. if(!(InitPifNTStruc()))
  1926. result = FALSE;
  1927. return(result);
  1928. }
  1929. InitPifNTStruc(void)
  1930. {
  1931. if(!PifNText) {
  1932. if(!(PifNText = AllocInitNTExt())) {
  1933. Warning(NOMODENT,MB_ICONEXCLAMATION | MB_OK);
  1934. return(FALSE);
  1935. }
  1936. }
  1937. return(TRUE);
  1938. }
  1939. InitPif386Struc(void)
  1940. {
  1941. if(!Pif386ext) {
  1942. if(!(Pif386ext = AllocInit386Ext())) {
  1943. Warning(NOMODE386,MB_ICONEXCLAMATION | MB_OK);
  1944. return(FALSE);
  1945. }
  1946. }
  1947. return(TRUE);
  1948. }
  1949. InitPif286Struc(void)
  1950. {
  1951. if(!Pif286ext30) {
  1952. if(!(Pif286ext30 = AllocInit286Ext30())) {
  1953. Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
  1954. return(FALSE);
  1955. }
  1956. }
  1957. /*
  1958. * if(!Pif286ext31) {
  1959. * if(!(Pif286ext31 = AllocInit286Ext31())) {
  1960. * Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
  1961. * return(FALSE);
  1962. * }
  1963. * }
  1964. */
  1965. return(TRUE);
  1966. }
  1967. MaybeSaveFile(void)
  1968. {
  1969. int j;
  1970. unsigned char *pch;
  1971. int i;
  1972. unsigned char *pchFile;
  1973. unsigned char *pchBuf = 0;
  1974. if (UpdatePifStruct() || FileChanged) {
  1975. j = 0;
  1976. pch = (PUCHAR)PifFile->name;
  1977. i = PIFSIZE;
  1978. while (i--)
  1979. j += *pch++;
  1980. if (j != PifFile->id) {
  1981. i = Warning(warSave,MB_ICONEXCLAMATION | MB_YESNOCANCEL);
  1982. switch (i) {
  1983. case IDYES:
  1984. if (!CurPifFile[0]) {
  1985. if(pchBuf = PutUpDB(DTSAVE))
  1986. pchFile = pchBuf;
  1987. else
  1988. return(FALSE); /* cancelled */
  1989. } else {
  1990. pchFile = CurPifFile;
  1991. }
  1992. CmdArgAddCorrectExtension(pchFile);
  1993. i = SavePifFile(pchFile, M_SAVE);
  1994. if(pchBuf)
  1995. LocalFree((HANDLE)pchBuf);
  1996. return(i==SAVEDONE ? TRUE : FALSE);
  1997. case IDNO:
  1998. return(TRUE);
  1999. case IDCANCEL:
  2000. return(FALSE);
  2001. }
  2002. } else {
  2003. return(TRUE);
  2004. }
  2005. } else {
  2006. return(TRUE);
  2007. }
  2008. }