summaryrefslogtreecommitdiffstats
path: root/private/mvdm/vdmutils
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/vdmutils
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/mvdm/vdmutils')
-rw-r--r--private/mvdm/vdmutils/dirs28
-rw-r--r--private/mvdm/vdmutils/forcedos/forcedos.c296
-rw-r--r--private/mvdm/vdmutils/forcedos/forcedos.h36
-rw-r--r--private/mvdm/vdmutils/forcedos/forcedos.rc44
-rw-r--r--private/mvdm/vdmutils/forcedos/makefile6
-rw-r--r--private/mvdm/vdmutils/forcedos/pif.h100
-rw-r--r--private/mvdm/vdmutils/forcedos/sources59
-rw-r--r--private/mvdm/vdmutils/graftabl/graftabl.c92
-rw-r--r--private/mvdm/vdmutils/graftabl/graftabl.h11
-rw-r--r--private/mvdm/vdmutils/graftabl/graftabl.rc20
-rw-r--r--private/mvdm/vdmutils/graftabl/makefile6
-rw-r--r--private/mvdm/vdmutils/graftabl/sources63
-rw-r--r--private/mvdm/vdmutils/pifedit/makefile6
-rw-r--r--private/mvdm/vdmutils/pifedit/mods.c44
-rw-r--r--private/mvdm/vdmutils/pifedit/mods.h11
-rw-r--r--private/mvdm/vdmutils/pifedit/pif.def21
-rw-r--r--private/mvdm/vdmutils/pifedit/pifedit.c3776
-rw-r--r--private/mvdm/vdmutils/pifedit/pifedit.h144
-rw-r--r--private/mvdm/vdmutils/pifedit/pifedit.icobin0 -> 1086 bytes
-rw-r--r--private/mvdm/vdmutils/pifedit/pifedit.rc499
-rw-r--r--private/mvdm/vdmutils/pifedit/pifedit.rcv18
-rw-r--r--private/mvdm/vdmutils/pifedit/pifhelp.h145
-rw-r--r--private/mvdm/vdmutils/pifedit/pifsubs.c2280
-rw-r--r--private/mvdm/vdmutils/pifedit/sources25
-rw-r--r--private/mvdm/vdmutils/win/makefile6
-rw-r--r--private/mvdm/vdmutils/win/sources42
-rw-r--r--private/mvdm/vdmutils/win/win.c184
-rw-r--r--private/mvdm/vdmutils/win/win.rc9
28 files changed, 7971 insertions, 0 deletions
diff --git a/private/mvdm/vdmutils/dirs b/private/mvdm/vdmutils/dirs
new file mode 100644
index 000000000..f534748a2
--- /dev/null
+++ b/private/mvdm/vdmutils/dirs
@@ -0,0 +1,28 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+History:
+ Created 27-Mar-91 by Jeff Parsons (jeffpar)
+ from template created 12-Apr-1990 by Steve Wood (stevewo)
+
+
+NOTE: Commented description of this file is in \nt\public\oak\bin\dirs.tpl
+
+!ENDIF
+
+
+DIRS=graftabl \
+ forcedos \
+ win
+
+OPTIONAL_DIRS=
diff --git a/private/mvdm/vdmutils/forcedos/forcedos.c b/private/mvdm/vdmutils/forcedos/forcedos.c
new file mode 100644
index 000000000..127adc80b
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/forcedos.c
@@ -0,0 +1,296 @@
+
+
+/*++
+
+Module Name:
+
+ forcedos.c
+
+Abstract:
+ This program forces NT to treat and execute the given program
+ as a DOS application.
+
+Author:
+
+ William Hsieh - williamh 25-Jan-1993
+
+Revision History:
+
+--*/
+
+/*
+ Some applications have Windows or OS/2 executable format while
+ run these program under NT, users will get the following message:
+ Please run this program under DOS. Since NT selects the subsystem
+ for application based on application executable format. There is
+ no way for NT to "run this program under DOS". This utility was provided
+ for this purpose. We create a pif file for the application and then
+ create a process for the pif. Since pif file always goes to NTVDM
+ we got the chance to play game on the program. NTVDM will decode
+ the pif file and dispatch the program to DOS. All the subsequent program
+ exec from the first program will be forced to execute under DOS.
+*/
+#define UNICODE 1
+
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <memory.h>
+#include "forcedos.h"
+
+WCHAR * Extention[MAX_EXTENTION];
+WCHAR EXEExtention[] = L".EXE";
+WCHAR COMExtention[] = L".COM";
+WCHAR BATExtention[] = L".BAT";
+WCHAR ProgramNameBuffer[MAX_PATH + 1];
+WCHAR SearchPathName[MAX_PATH + 1];
+WCHAR DefDirectory[MAX_PATH + 1];
+char CommandLine[MAX_PATH + 1];
+char ProgramName[MAX_PATH + 1];
+WCHAR UnicodeMessage[MAX_MSG_LENGTH];
+char OemMessage[MAX_MSG_LENGTH * 2];
+
+#if DBG
+BOOL fOutputDebugInfo = FALSE;
+#endif
+
+void
+_cdecl
+main(
+ int argc,
+ char *argv[]
+ )
+{
+ char * pCommandLine;
+ char * pCurDirectory;
+ char * pProgramName;
+ char * p;
+ BOOL fDisplayUsage;
+ ULONG i, nChar, Length, CommandLineLength;
+ PROCESS_INFORMATION ProcessInformation;
+ DWORD ExitCode, dw;
+ STARTUPINFO StartupInfo;
+ PUNICODE_STRING pTebUnicodeString;
+ NTSTATUS Status;
+ OEM_STRING OemString, CmdLineString;
+ UNICODE_STRING UnicodeString;
+ WCHAR *pwch, *pFilePart;
+ Extention[0] = COMExtention;
+ Extention[1] = EXEExtention;
+ Extention[2] = BATExtention;
+
+
+ pCurDirectory = pProgramName = NULL;
+ pCommandLine = CommandLine;
+ CommandLineLength = 0;
+ pTebUnicodeString = &NtCurrentTeb()->StaticUnicodeString;
+ fDisplayUsage = TRUE;
+
+ if ( argc > 1 ) {
+ fDisplayUsage = FALSE;
+ while (--argc != 0) {
+ p = *++argv;
+ if (pProgramName == NULL) {
+ if (*p == '/' || *p == '-') {
+ switch (*++p) {
+ case '?':
+ fDisplayUsage = TRUE;
+ break;
+ case 'D':
+ case 'd':
+ // if the directory follows the /D immediately
+ // get it
+ if (*++p != 0) {
+ pCurDirectory = p;
+ break;
+ }
+ else if (--argc > 1)
+ // the next argument must be the curdirectory
+ pCurDirectory = *++argv;
+ else
+ fDisplayUsage = TRUE;
+ break;
+
+ default:
+ fDisplayUsage = TRUE;
+ break;
+ }
+ }
+ else {
+ pProgramName = p;
+ nChar = strlen(p);
+ strncpy(CommandLine, pProgramName, nChar);
+ pCommandLine = CommandLine + nChar;
+ CommandLineLength = nChar + 1;
+ }
+ }
+ else {
+ // aggregate command line from all subsequent argvs
+ nChar = strlen(p);
+ if (CommandLineLength != 0) {
+ strncpy(pCommandLine, " ", 1);
+ pCommandLine++;
+ }
+ strncpy(pCommandLine, p, nChar);
+ pCommandLine += nChar;
+ CommandLineLength += nChar + 1;
+ }
+ if (fDisplayUsage)
+ break;
+ }
+ if (pProgramName == NULL)
+ fDisplayUsage = TRUE;
+ }
+
+ if ( fDisplayUsage) {
+ OemString.Length = 0;
+ OemString.MaximumLength = MAX_MSG_LENGTH << 1;
+ OemString.Buffer = OemMessage;
+ UnicodeString.Length = 0;
+ UnicodeString.Buffer = UnicodeMessage;
+ UnicodeString.MaximumLength = MAX_MSG_LENGTH << 1;
+ for (i = ID_USAGE_BASE; i <= ID_USAGE_MAX; i++) {
+ nChar = LoadString(NULL, i, UnicodeString.Buffer,
+ UnicodeString.MaximumLength);
+ UnicodeString.Length = (USHORT)(nChar << 1);
+ Status = RtlUnicodeStringToOemString(
+ &OemString,
+ &UnicodeString,
+ FALSE
+ );
+ if (!NT_SUCCESS(Status))
+ break;
+ if (!WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
+ OemString.Buffer,
+ OemString.Length,
+ &Length, NULL) ||
+ Length != OemString.Length)
+ break;
+ }
+ ExitProcess(0xFF);
+ }
+
+ if (pCurDirectory != NULL) {
+#if DBG
+ if (fOutputDebugInfo)
+ printf("Default directory = %s\n", pCurDirectory);
+#endif
+
+ RtlInitString((PSTRING)&OemString, pCurDirectory);
+ UnicodeString.MaximumLength = (MAX_PATH + 1) * sizeof(WCHAR);
+ UnicodeString.Buffer = DefDirectory;
+ UnicodeString.Length = 0;
+ Status = RtlOemStringToUnicodeString(&UnicodeString, &OemString, FALSE);
+ if (!NT_SUCCESS(Status))
+ YellAndExit(ID_BAD_DEFDIR, 0xFF);
+ dw = GetFileAttributes(DefDirectory);
+ if (dw == (DWORD)(-1) || !(dw & FILE_ATTRIBUTE_DIRECTORY))
+ YellAndExit(ID_BAD_DEFDIR, 0xFF);
+ SetCurrentDirectory(DefDirectory);
+ }
+ else
+ GetCurrentDirectory(MAX_PATH + 1, DefDirectory);
+
+ // get a local copy of program name (for code conversion)
+ strcpy(ProgramName, pProgramName);
+ pProgramName = ProgramName;
+ // when we feed SearchPath with an initial path name ".;%path%"
+ // it will search the executable for use according to our requirement
+ // Currentdir -> path
+ SearchPathName[0] = L'.';
+ SearchPathName[1] = L';';
+ GetEnvironmentVariable(L"path", &SearchPathName[2], MAX_PATH + 1 - 2);
+ RtlInitString((PSTRING)&OemString, pProgramName);
+ Status = RtlOemStringToUnicodeString(pTebUnicodeString, &OemString, FALSE);
+ if (!NT_SUCCESS(Status))
+ YellAndExit(ID_BAD_PATH, 0xFF);
+ i = 0;
+ nChar = 0;
+ pwch = wcschr(pTebUnicodeString->Buffer, (WCHAR)'.');
+ Length = (pwch) ? 1 : MAX_EXTENTION;
+ while (i < Length &&
+ (nChar = SearchPath(
+ SearchPathName,
+ pTebUnicodeString->Buffer,
+ Extention[i],
+ MAX_PATH + 1,
+ ProgramNameBuffer,
+ &pFilePart
+ )) == 0)
+ i++;
+ if (nChar == 0)
+ YellAndExit(ID_NO_FILE, 0xFF);
+ nChar = GetFileAttributes(ProgramNameBuffer);
+ if (nChar == (DWORD) (-1) || (nChar & FILE_ATTRIBUTE_DIRECTORY))
+ YellAndExit(ID_NO_FILE, 0xFF);
+
+ if (OemString.Length + CommandLineLength > 128 - 2 - 1)
+ YellAndExit(ID_BAD_CMDLINE, 0xFF);
+#if DBG
+ if (fOutputDebugInfo)
+ printf("Program path name is %s\n", ProgramNameBuffer);
+#endif
+ RtlInitString((PSTRING)&CmdLineString, CommandLine);
+ Status = RtlOemStringToUnicodeString(pTebUnicodeString, &CmdLineString, FALSE);
+ if (!NT_SUCCESS(Status))
+ YellAndExit(ID_BAD_CMDLINE, 0xFF);
+
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFO));
+ StartupInfo.cb = sizeof (STARTUPINFO);
+ if (!CreateProcess(
+ ProgramNameBuffer, // program name
+ pTebUnicodeString->Buffer,// command line
+ NULL, // process attr
+ NULL, // thread attr
+ TRUE, // inherithandle
+ CREATE_FORCEDOS, // create flag
+ NULL, // environment
+ DefDirectory, // cur dir
+ &StartupInfo, // startupinfo
+ &ProcessInformation
+ )) {
+ YellAndExit(ID_BAD_PROCESS, 0xFF);
+#if DBG
+ if(fOutputDebugInfo)
+ printf("CreateProceess Failed, error code = %ld\n", GetLastError());
+#endif
+ }
+
+ WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
+ GetExitCodeProcess(ProcessInformation.hProcess, &ExitCode);
+ CloseHandle(ProcessInformation.hProcess);
+ ExitProcess(ExitCode);
+}
+
+
+VOID YellAndExit
+(
+UINT MsgID, // string table id from resource
+WORD ExitCode // exit code to be used
+)
+{
+ int MessageSize;
+ ULONG SizeWritten;
+ OEM_STRING OemString;
+ UNICODE_STRING UnicodeString;
+
+ MessageSize = LoadString(NULL, MsgID, UnicodeMessage, MAX_MSG_LENGTH << 1);
+ OemString.Buffer = OemMessage;
+ OemString.Length = 0;
+ OemString.MaximumLength = MAX_MSG_LENGTH * 2;
+ RtlInitUnicodeString(&UnicodeString, UnicodeMessage);
+ RtlUnicodeStringToOemString(&OemString, &UnicodeString, FALSE);
+
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE),
+ OemString.Buffer,
+ OemString.Length,
+ &SizeWritten,
+ NULL
+ );
+
+ ExitProcess(ExitCode);
+}
diff --git a/private/mvdm/vdmutils/forcedos/forcedos.h b/private/mvdm/vdmutils/forcedos/forcedos.h
new file mode 100644
index 000000000..b34f81f16
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/forcedos.h
@@ -0,0 +1,36 @@
+
+
+#define ID_NO_FILE 0
+#define ID_BAD_PATH 1
+#define ID_BAD_CMDLINE 2
+#define ID_BAD_DEFDIR 3
+#define ID_BAD_TEMPFILE 4
+#define ID_NO_PIF 5
+#define ID_BAD_PIF 6
+#define ID_NO_MEMORY 7
+#define ID_BAD_PROCESS 8
+
+// KEEP THEM TOGETHER, The code relies on the sequence.
+#define ID_USAGE_00 20
+#define ID_USAGE_01 21
+#define ID_USAGE_02 22
+#define ID_USAGE_03 23
+#define ID_USAGE_04 24
+#define ID_USAGE_BASE ID_USAGE_00
+#define ID_USAGE_MAX ID_USAGE_04
+
+
+#define MAX_EXTENTION 3
+#define MAX_MSG_LENGTH 256
+
+BOOL
+IsDirectory
+(
+char * pDirectory
+);
+
+VOID YellAndExit
+(
+UINT MsgID,
+WORD ExitCode
+);
diff --git a/private/mvdm/vdmutils/forcedos/forcedos.rc b/private/mvdm/vdmutils/forcedos/forcedos.rc
new file mode 100644
index 000000000..67e30cf47
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/forcedos.rc
@@ -0,0 +1,44 @@
+/*
+
+Filename : forceexe.rc
+Purpose : Contains resource file for FORCEDOS.EXE
+Author : William Hsieh
+
+Contains :
+ Strings
+
+Revision History :
+
+*/
+#include <windows.h>
+#include <ntverp.h>
+
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE VFT2_UNKNOWN
+#define VER_FILEDESCRIPTION_STR "Force DOS Execute Utility"
+#define VER_INTERNALNAME_STR "ForceDOS"
+#define VER_ORIGINALFILENAME_STR "ForceDOS.Exe"
+
+#include "common.ver"
+
+#include "forcedos.h"
+
+STRINGTABLE {
+
+ ID_NO_FILE L"FORCEDOS: Program file not found\n"
+ ID_BAD_PATH L"FORCEDOS: Bad program path name\n"
+ ID_BAD_CMDLINE L"FORCEDOS: Command line too long\n"
+ ID_BAD_DEFDIR L"FORCEDOS: Bad directory name\n"
+ ID_BAD_TEMPFILE L"FORCEDOS: Cannot create temporary file\n"
+ ID_NO_PIF L"FORCEDOS: _default.pif not found\n"
+ ID_BAD_PIF L"FORCEDOS: _default.pif corrupted\n"
+ ID_NO_MEMORY L"FORCEDOS: Not enough memory\n"
+ ID_BAD_PROCESS L"FORCEDOS: Failed to create the process\n"
+
+ ID_USAGE_00 L"\nFORCEDOS [/D directory] filename [parameters]\n"
+ ID_USAGE_01 L"/D directory Specifies the current directory for\n"
+ ID_USAGE_02 L" the specified program to use.\n"
+ ID_USAGE_03 L"filename Specifies the program to start.\n"
+ ID_USAGE_04 L"parameters Specifies parameters to pass to the program.\n"
+
+}
diff --git a/private/mvdm/vdmutils/forcedos/makefile b/private/mvdm/vdmutils/forcedos/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/mvdm/vdmutils/forcedos/pif.h b/private/mvdm/vdmutils/forcedos/pif.h
new file mode 100644
index 000000000..aeb72b007
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/pif.h
@@ -0,0 +1,100 @@
+#pragma pack(1)
+
+/*
+ * Structure and equates of PIF files
+ */
+
+#define PIFEDITMAXPIF 1024 /* maximum PIF file size we support */
+#define PIFEDITMAXPIFL 1024L
+
+#define PIFNAMESIZE 30
+#define PIFSTARTLOCSIZE 63
+#define PIFDEFPATHSIZE 64
+#define PIFPARAMSSIZE 64
+#define PIFSHPROGSIZE 64
+#define PIFSHDATASIZE 64
+
+#define PIFEXTSIGSIZE 16
+
+#define PIFSIZE 367 /* two bytes less, this is used for checksum */
+
+typedef struct {
+ char extsig[PIFEXTSIGSIZE];
+ unsigned short extnxthdrfloff;
+ unsigned short extfileoffset;
+ unsigned short extsizebytes;
+ } PIFEXTHEADER;
+
+#define LASTHEADERPTR 0xFFFF
+#define STDHDRSIG "MICROSOFT PIFEX"
+
+#define W386HDRSIG "WINDOWS 386 3.0"
+#define W286HDRSIG30 "WINDOWS 286 3.0"
+#define WNTHDRSIG31 "WINDOWS NT 3.1"
+
+typedef struct {
+ char unknown;
+ char id;
+ char name[PIFNAMESIZE];
+ short maxmem;
+ short minmem;
+ char startfile[PIFSTARTLOCSIZE];
+ char MSflags;
+ char reserved;
+ char defpath[PIFDEFPATHSIZE];
+ char params[PIFPARAMSSIZE];
+ char screen;
+ char cPages;
+ unsigned char lowVector;
+ unsigned char highVector;
+ char rows;
+ char cols;
+ char rowoff;
+ char coloff;
+ unsigned short sysmem;
+ char shprog[PIFSHPROGSIZE];
+ char shdata[PIFSHDATASIZE];
+ unsigned char behavior;
+ unsigned char sysflags;
+ PIFEXTHEADER stdpifext;
+ } PIFNEWSTRUCT;
+
+typedef struct {
+ short maxmem;
+ short minmem;
+ unsigned short PfFPriority;
+ unsigned short PfBPriority;
+ short PfMaxEMMK;
+ unsigned short PfMinEMMK;
+ short PfMaxXmsK;
+ unsigned short PfMinXmsK;
+ unsigned long PfW386Flags;
+ unsigned long PfW386Flags2;
+ unsigned short PfHotKeyScan;
+ unsigned short PfHotKeyShVal;
+ unsigned short PfHotKeyShMsk;
+ unsigned char PfHotKeyVal;
+ unsigned char PfHotKeyPad[9];
+ char params[PIFPARAMSSIZE];
+ } PIF386EXT;
+
+/* Windows NT extension format */
+typedef struct
+ {
+ DWORD dwWNTFlags;
+ DWORD dwRes1;
+ DWORD dwRes2;
+ char achConfigFile[PIFDEFPATHSIZE];
+ char achAutoexecFile[PIFDEFPATHSIZE];
+ } PIFWNTEXT;
+
+// equates for dwWNTFlags
+#define NTPIF_SUBSYSMASK 0x0000000F // sub system type mask
+#define SUBSYS_DEFAULT 0
+#define SUBSYS_DOS 1
+#define SUBSYS_WOW 2
+#define SUBSYS_OS2 3
+
+#define PIFWNTEXTSIZE sizeof(PIFWNTEXT)
+
+#pragma pack()
diff --git a/private/mvdm/vdmutils/forcedos/sources b/private/mvdm/vdmutils/forcedos/sources
new file mode 100644
index 000000000..d85762b98
--- /dev/null
+++ b/private/mvdm/vdmutils/forcedos/sources
@@ -0,0 +1,59 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=utils
+MINORCOMP=forcedos
+
+TARGETNAME=forcedos
+TARGETPATH=obj
+TARGETTYPE=LIBRARY
+
+SOURCES=forcedos.c forcedos.rc
+
+
+INCLUDES=\nt\public\sdk\inc
+
+!if "$(NTDEBUG)" == "cvp" || "$(NTDEBUG)" == "ntsd"
+!IFDEF NOMEMLEAK
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DUNICODE=1
+!ELSE
+!IFDEF STACK_TRACE
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DMEMLEAK -DSTACK_TRACE -DUNICODE=1
+!ELSE
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DMEMLEAK -DUNICODE=1
+!ENDIF
+!ENDIF
+!ELSE # NTDEBUG
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=0 -DUNICODE=1
+!ENDIF # NTDEBUG
+
+CXXFLAGS=+d
+UMLIBS=$(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib
+
+UMTYPE=console
+
+UMAPPL=forcedos
+
+UMRES=obj\*\forcedos.res
diff --git a/private/mvdm/vdmutils/graftabl/graftabl.c b/private/mvdm/vdmutils/graftabl/graftabl.c
new file mode 100644
index 000000000..0b4045a90
--- /dev/null
+++ b/private/mvdm/vdmutils/graftabl/graftabl.c
@@ -0,0 +1,92 @@
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <conio.h>
+#include <string.h>
+#include "graftabl.h"
+
+/************************************************************************\
+*
+* FUNCTION: 32-bit version of GRAFTABL
+*
+* Syntax: GRAFTABL [XXX]
+* GRAFTABL /STATUS
+*
+* COMMENTS: This program changes only Console Output CP and
+* cannot change console (input) CP as normal GRAFTABL
+* in MS-DOS 5.0
+*
+* HISTORY: Jan. 4, 1993
+* YSt
+*
+* Copyright Microsoft Corp. 1993
+*
+\************************************************************************/
+void _cdecl main( int argc, char* argv[] )
+{
+ int iCP, iPrevCP, iRet;
+ char szArgv[128];
+ TCHAR szSour[256];
+ char szDest[256];
+
+ iPrevCP = 0;
+ if(argc > 1) {
+ strcpy(szArgv, argv[1]);
+ _strupr(szArgv);
+
+// Help option
+ if(!strcmp(szArgv, "/?") || !strcmp(szArgv, "-?")) {
+ iRet = LoadString(NULL, HELP_TEXT, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+
+ printf(szDest);
+ exit(0);
+ }
+// Status option
+ else if(!strcmp(szArgv, "/STATUS") ||
+ !strcmp(szArgv, "-STATUS") ||
+ !strcmp(szArgv, "-STA") ||
+ !strcmp(szArgv, "/STA")) {
+
+ iRet = LoadString(NULL, ACTIVE_CP, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+
+ printf(szDest, GetConsoleOutputCP());
+ exit(0);
+ }
+
+
+// Change output CP
+ else {
+ iPrevCP = GetConsoleOutputCP();
+
+ if(((iCP = atoi(szArgv)) < 1) || (iCP > 10000)) {
+ iRet = LoadString(NULL, INVALID_SWITCH, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+
+ fprintf(stderr, szDest, argv[1]);
+ exit(1);
+ }
+ if(!SetConsoleOutputCP(iCP)) {
+ iRet = LoadString(NULL, NOT_ALLOWED, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+ fprintf(stderr, szDest, iCP);
+ exit(2);
+ }
+ }
+ }
+ if(iPrevCP) {
+ iRet = LoadString(NULL,PREVIOUS_CP, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+ printf(szDest, iPrevCP);
+ }
+ else {
+ iRet = LoadString(NULL,NONE_CP, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+ printf(szDest);
+ }
+
+ iRet = LoadString(NULL,ACTIVE_CP, szSour, sizeof(szSour)/sizeof(TCHAR));
+ CharToOem(szSour, szDest);
+ printf(szDest, GetConsoleOutputCP());
+}
diff --git a/private/mvdm/vdmutils/graftabl/graftabl.h b/private/mvdm/vdmutils/graftabl/graftabl.h
new file mode 100644
index 000000000..522f5aa73
--- /dev/null
+++ b/private/mvdm/vdmutils/graftabl/graftabl.h
@@ -0,0 +1,11 @@
+/* GRAFTABL.H
+ Date: 1/29/93
+ Message IDs fro CRAFTABL utility
+*/
+
+#define HELP_TEXT 100
+#define ACTIVE_CP 101
+#define INVALID_SWITCH 102
+#define NOT_ALLOWED 103
+#define PREVIOUS_CP 104
+#define NONE_CP 105
diff --git a/private/mvdm/vdmutils/graftabl/graftabl.rc b/private/mvdm/vdmutils/graftabl/graftabl.rc
new file mode 100644
index 000000000..aff6e7eb9
--- /dev/null
+++ b/private/mvdm/vdmutils/graftabl/graftabl.rc
@@ -0,0 +1,20 @@
+#include <windows.h>
+#include <ntverp.h>
+#include "graftabl.h"
+
+STRINGTABLE
+BEGIN
+HELP_TEXT "Enable Windows NT to display an extended character set in graphics mode.\n\nGRAFTABL [xxx]\nGRAFTABL /STATUS\n\n xxx Specifies a code page number.\n /STATUS Displays the current code page selected for use with GRAFTABL.\n"
+ACTIVE_CP "Active Code Page: %d\n"
+INVALID_SWITCH "Invalid switch - %s\n"
+NOT_ALLOWED "Parameter value not allowed - %d\n"
+PREVIOUS_CP "Previous Code Page: %d\n"
+NONE_CP "Previous Code Page: None\n"
+END
+
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE VFT2_UNKNOWN
+#define VER_FILEDESCRIPTION_STR "Graftabl Utility"
+#define VER_INTERNALNAME_STR "graftabl\0"
+
+#include "common.ver"
diff --git a/private/mvdm/vdmutils/graftabl/makefile b/private/mvdm/vdmutils/graftabl/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/mvdm/vdmutils/graftabl/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/mvdm/vdmutils/graftabl/sources b/private/mvdm/vdmutils/graftabl/sources
new file mode 100644
index 000000000..4e6b813c4
--- /dev/null
+++ b/private/mvdm/vdmutils/graftabl/sources
@@ -0,0 +1,63 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=utils
+MINORCOMP=graftabl
+
+TARGETNAME=graftabl
+TARGETPATH=obj
+TARGETTYPE=LIBRARY
+
+SOURCES=graftabl.c graftabl.rc
+
+
+INCLUDES=\nt\public\sdk\inc
+
+!if "$(NTDEBUG)" == "cvp" || "$(NTDEBUG)" == "ntsd"
+!IFDEF NOMEMLEAK
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DUNICODE=1
+!ELSE
+!IFDEF STACK_TRACE
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DMEMLEAK -DSTACK_TRACE -DUNICODE=1
+!ELSE
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=1 -DMEMLEAK -DUNICODE=1
+!ENDIF
+!ENDIF
+!ELSE # NTDEBUG
+C_DEFINES=-DCONDITION_HANDLING=1 -DNOMINMAX -DDBG=0 -DUNICODE=1
+!ENDIF # NTDEBUG
+
+CXXFLAGS=+d
+UMLIBS=\nt\public\sdk\lib\*\user32.lib
+
+UMTYPE=console
+
+UMAPPL=graftabl
+
+UMRES=obj\*\graftabl.res
+
+#
+# To build mode.com
+#
+_DOT_COM_FILE=1
diff --git a/private/mvdm/vdmutils/pifedit/makefile b/private/mvdm/vdmutils/pifedit/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/mvdm/vdmutils/pifedit/mods.c b/private/mvdm/vdmutils/pifedit/mods.c
new file mode 100644
index 000000000..5f06cff85
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/mods.c
@@ -0,0 +1,44 @@
+/* MODS.C - stubs, asm substitutes etc. for 32-bit port of pifedit.exe */
+#include "windows.h"
+#include "stdio.h"
+#include "memory.h"
+#include "mods.h"
+
+int MemCopy(LPSTR src, LPSTR dest, int cb)
+{
+ memcpy(dest, src, cb);
+ return(1);
+}
+
+
+BOOL SetInitialMode(void)
+{
+ return(1);
+}
+
+
+int CountLines(LPSTR lpstr)
+{
+ return(0);
+}
+
+
+DWORD GetTextExtent(HDC hdc, LPSTR lpszStr, int cbStr)
+{
+ SIZE size;
+
+ if(GetTextExtentPoint(hdc, lpszStr, cbStr, &size)) {
+ return( MAKELONG( (LOWORD(size.cy)), (LOWORD(size.cx)) ) );
+ }
+
+ else
+ return(0);
+}
+
+
+
+int delete(LPSTR lpszPath)
+{
+ return(unlink(lpszPath));
+
+}
diff --git a/private/mvdm/vdmutils/pifedit/mods.h b/private/mvdm/vdmutils/pifedit/mods.h
new file mode 100644
index 000000000..6d86ac54f
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/mods.h
@@ -0,0 +1,11 @@
+/* MODS.H - function prototypes for MODS.C */
+
+#define GetInstanceData(hinst, npstr, cb) (0)
+
+int MemCopy(LPSTR, LPSTR, int);
+BOOL SetInitialMode(void);
+int CountLines(LPSTR);
+DWORD GetTextExtent(HDC, LPSTR, int);
+int delete(LPSTR);
+
+
diff --git a/private/mvdm/vdmutils/pifedit/pif.def b/private/mvdm/vdmutils/pifedit/pif.def
new file mode 100644
index 000000000..277898262
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pif.def
@@ -0,0 +1,21 @@
+NAME PIFEDIT WINDOWAPI
+
+DESCRIPTION 'Program Information File Editor'
+EXETYPE WINDOWS
+PROTMODE
+STUB 'WINSTUB.EXE'
+
+CODE PRELOAD DISCARDABLE SHARED MOVEABLE
+DATA MOVEABLE MULTIPLE
+
+HEAPSIZE 4096
+STACKSIZE 8192
+
+EXPORTS
+ PifMainWndProc @1
+ PifWndProc @2
+ PifHotKyWndProc @3
+ PifAdvWndProc @4
+ PifNTWndProc @5
+
+
diff --git a/private/mvdm/vdmutils/pifedit/pifedit.c b/private/mvdm/vdmutils/pifedit/pifedit.c
new file mode 100644
index 000000000..1a42c3de4
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifedit.c
@@ -0,0 +1,3776 @@
+/* originally named PIF.C in Win3.1 -- changed to make build 32 happy */
+#define NOSOUND
+#define NOCOMM
+#define WIN31
+#include "pifedit.h"
+#include "commdlg.h"
+#include "shellapi.h"
+#include "mods.h"
+
+extern BOOL IsLastPifedit(void);
+extern int MemCopy(LPSTR,LPSTR,int);
+extern int MaybeSaveFile(void);
+extern int InitPifStruct(void);
+extern int UpdatePifScreen(void);
+extern int UpdatePifScreenAdv(void);
+extern int UpdatePifScreenNT(void);
+extern BOOL UpdatePifStruct(void);
+extern int LoadPifFile(PSTR);
+extern int SavePifFile(PSTR, int);
+extern BOOL SetInitialMode(void);
+extern int CountLines(LPSTR);
+extern int Warning(int,WORD);
+extern PIF386EXT UNALIGNED *AllocInit386Ext(void);
+extern PIFWNTEXT UNALIGNED *AllocInitNTExt(void);
+extern void SetFileOffsets(unsigned char *,WORD *,WORD *);
+extern void SetNTDlgItem(int);
+/*
+ * extern PIF286EXT31 *AllocInit286Ext31(void);
+ */
+extern PIF286EXT30 UNALIGNED *AllocInit286Ext30(void);
+extern BOOL DoFieldsWork(BOOL);
+extern BOOL DoFieldsWorkNT(BOOL);
+extern BOOL DoFieldsWorkAdv(BOOL);
+extern BOOL UpdatePif386Struc(void);
+extern BOOL UpdatePifNTStruc(void);
+
+#define SBUMAIN 0 // Scroll Bar update on Main
+#define SBUADV 1 // Scroll Bar update on Advanced
+#define SBUNT 2 // Scroll Bar update on NT
+#define SBUMAINADVNT 3 // Scroll Bar Update on Main, Advanced, and NT
+#define SBUSZMAIN 4 // SIZE and Scroll Bar update on Main
+#define SBUSZADV 5 // SIZE and Scroll Bar update on Advanced
+#define SBUSZNT 6 // SIZE and Scroll Bar update on NT
+#define SBUSZMAINADVNT 7 // SIZE and Scroll Bar update on Main, Advanced, and NT
+
+int SwitchAdvance386(HWND);
+int SwitchNT(HWND);
+unsigned char *PutUpDB(int);
+int DoHelp(unsigned int,unsigned int);
+int Disable386Advanced(HWND, HWND);
+int SetMainWndSize(int);
+int MainScroll(HWND, int, int, int, int);
+int ChangeHotKey(void);
+int SetHotKeyLen(void);
+int SetHotKeyState(WPARAM,LONG);
+int SetHotKeyTextFromPIF(void);
+int CmdArgAddCorrectExtension(unsigned char *);
+int SetHotKeyTextFromInMem(void);
+void CpyCmdStr( LPSTR szDst, LPSTR szSrc );
+
+
+CHAR szOldAutoexec[PIFDEFPATHSIZE*4];
+CHAR szOldConfig[PIFDEFPATHSIZE*4];
+
+BOOL CurrMode386; /* true if in Windows 386 mode, False if in Windows 286 mode */
+
+BOOL SysMode386; /* true if running Windows 386, False if running Windows 286 */
+
+BOOL ModeAdvanced = FALSE; /* true if in advanced PIF mode */
+
+BOOL AdvClose = FALSE; /* true if advanced PIF mode and Cancel = Close */
+
+BOOL NTClose = FALSE; /* true if NT PIF mode and Cancel = Close */
+
+BOOL FileChanged = FALSE;
+
+BOOL EditHotKey = FALSE;
+
+BOOL NewHotKey = FALSE;
+
+BOOL DoingMsg = FALSE;
+
+BOOL InitShWind = FALSE; /* true if initial ShowWindow has been done */
+
+BOOL CompleteKey = FALSE;
+
+BOOL SizingFlag = FALSE; /* Semaphore to prevent re-entrant sizing */
+
+/* invalid filename flags for NT autoexec & config files */
+BOOL fNoNTAWarn = FALSE;
+BOOL fNTAWarnne = FALSE;
+BOOL fNoNTCWarn = FALSE;
+BOOL fNTCWarnne = FALSE;
+
+HWND hwndPrivControl = (HWND)NULL;
+HWND hwndHelpDlgParent = (HWND)NULL; // This is actually mostly a flag that says
+ // we have the help engine up
+
+unsigned char MenuMnemonic1;
+unsigned char MenuMnemonic2;
+unsigned char MenuMnemonic3;
+
+unsigned char KeySepChr;
+
+unsigned char CurrHotKeyTxt[160];
+int CurrHotKeyTxtLen = 0;
+
+WORD fileoffset = 0;
+WORD extoffset = 0;
+WORD tmpfileoffset = 0;
+WORD tmpextoffset = 0;
+
+typedef VOID (FAR PASCAL *LPFNREGISTERPENAPP)(WORD, BOOL);
+static LPFNREGISTERPENAPP lpfnRegisterPenApp = NULL;
+
+#define NUM286ALIASES 8
+
+unsigned int Aliases286 [(NUM286ALIASES * 2)] = { IDI_MEMREQ,IDI_MEMREQ_286ALIAS,
+ IDI_XMAREQ,IDI_XMAREQ_286ALIAS,
+ IDI_XMADES,IDI_XMADES_286ALIAS,
+ /*
+ * IDI_EMSREQ,IDI_EMSREQ_286ALIAS,
+ * IDI_EMSDES,IDI_EMSDES_286ALIAS,
+ */
+ IDI_ALTTAB,IDI_ALTTAB_286ALIAS,
+ IDI_ALTESC,IDI_ALTESC_286ALIAS,
+ IDI_ALTPRTSC,IDI_ALTPRTSC_286ALIAS,
+ IDI_PRTSC,IDI_PRTSC_286ALIAS,
+ IDI_CTRLESC,IDI_CTRLESC_286ALIAS };
+
+unsigned TmpHotKeyScan;
+unsigned TmpHotKeyShVal;
+unsigned TmpHotKeyShMsk = 0x000F; /* Either CTRL, ALT or SHIFT */
+unsigned char TmpHotKeyVal;
+
+unsigned InMemHotKeyScan = 0;
+unsigned InMemHotKeyShVal = 0;
+unsigned InMemHotKeyShMsk = 0;
+unsigned char InMemHotKeyVal;
+
+BOOL ChangeHkey = FALSE; /* Prevent re-entrancy */
+
+BOOL bMouse;
+HCURSOR hArrowCurs;
+HCURSOR hWaitCurs;
+
+int SysCharHeight;
+int SysCharWidth;
+
+HFONT HotKyFnt = 0;
+int HotKyFntHgt = 0;
+HFONT SysFixedFont;
+int SysFixedHeight;
+int SysFixedWidth;
+
+HINSTANCE hPifInstance;
+HWND hwndPifDlg = (HWND)NULL;
+HWND hwndNTPifDlg = (HWND)NULL;
+HWND hwndAdvPifDlg = (HWND)NULL;
+HWND hParentWnd = (HWND)NULL;
+HWND hwndFocusMain = (HWND)NULL;
+HWND hwndFocusAdv = (HWND)NULL;
+HWND hwndFocusNT = (HWND)NULL;
+BOOL bNTDlgOpen = FALSE;
+BOOL bAdvDlgOpen = FALSE;
+int FocusIDMain = IDI_ENAME;
+int FocusIDMainMenu = 0;
+int FocusIDAdvMenu = 0;
+int FocusIDAdv = IDI_BPRI;
+int FocusIDNTMenu = 0;
+int FocusIDNT = IDI_AUTOEXEC;
+HWND hwndFocus = (HWND)NULL;
+int FocusID = IDI_ENAME;
+
+unsigned char FocStatTextMain[PIFSTATUSLEN*2] = { 0 };
+unsigned char FocStatTextAdv[PIFSTATUSLEN*2] = { 0 };
+unsigned char FocStatTextNT[PIFSTATUSLEN*2] = { 0 };
+
+PIFSTATUSPAINT StatusPntData;
+
+RECT StatRecSizeMain;
+RECT StatRecSizeAdv;
+RECT StatRecSizeNT;
+
+HWND hMainwnd = (HWND)NULL;
+
+int MainScrollRange = 0;
+int MainScrollLineSz = 0;
+int MainWndLines = 0;
+int MaxMainNeg = 0;
+int MainWndSize = SIZENORMAL;
+
+int AdvScrollRange = 0;
+int AdvScrollLineSz = 0;
+int AdvWndLines = 0;
+int MaxAdvNeg = 0;
+int AdvWndSize = SIZENORMAL;
+
+int NTScrollRange = 0;
+int NTScrollLineSz = 0;
+int NTWndLines = 0;
+int MaxNTNeg = 0;
+int NTWndSize = SIZENORMAL;
+
+HACCEL hAccel;
+
+unsigned char CurPifFile[256]; /* this is name IN ANSI!! */
+unsigned char PifBuf[PIFEDITMAXPIF*2];
+unsigned char NTSys32Root[PIFDEFPATHSIZE*2];
+
+PIFNEWSTRUCT UNALIGNED *PifFile;
+PIF386EXT UNALIGNED *Pif386ext = (PIF386EXT *)NULL;
+/*
+ * PIF286EXT31 *Pif286ext31 = (PIF286EXT31 *)NULL;
+ */
+PIF286EXT30 UNALIGNED *Pif286ext30 = (PIF286EXT30 *)NULL;
+PIFWNTEXT UNALIGNED *PifNText = (PIFWNTEXT *)NULL;
+
+OFSTRUCT ofReopen;
+unsigned char rgchInsMem[320];
+unsigned char rgchTitle[60];
+unsigned char szExtSave[] = "\\*.PIF";
+
+HMENU hSysMenuMain = (HMENU)NULL;
+HMENU hFileMenu = (HMENU)NULL;
+HMENU hModeMenu = (HMENU)NULL;
+HMENU hHelpMenu = (HMENU)NULL;
+HMENU hSysMenuAdv = (HMENU)NULL;
+HMENU hSysMenuNT = (HMENU)NULL;
+
+FARPROC lpfnPifWnd;
+FARPROC lpfnAdvPifWnd;
+FARPROC lpfnNTPifWnd;
+
+void InvalidateStatusBar(HWND hwnd)
+{
+ RECT rc;
+
+ if((hwnd == hwndAdvPifDlg) && AdvScrollRange) /* No status bar if scroll bar */
+ return;
+
+ if((hwnd == hwndNTPifDlg) && NTScrollRange) /* No status bar if scroll bar */
+ return;
+
+ GetClientRect(hwnd, &rc);
+ if(rc.bottom >= (StatusPntData.dyStatus + StatusPntData.dyBorderx2)) {
+ rc.top = rc.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ InvalidateRect(hwnd,(CONST RECT *)&rc,FALSE);
+ }
+}
+
+void InvalidateAllStatus(void)
+{
+
+ if(hMainwnd) {
+ InvalidateStatusBar(hMainwnd);
+ }
+ if(hwndAdvPifDlg) {
+ InvalidateStatusBar(hwndAdvPifDlg);
+ }
+ if(hwndNTPifDlg) {
+ InvalidateStatusBar(hwndNTPifDlg);
+ }
+}
+
+void SetStatusText(HWND hwnd,int FocID,BOOL redrawflg)
+{
+ unsigned char *dst;
+
+ if(hwnd == hMainwnd) {
+ dst = FocStatTextMain;
+ } else if (hwnd == hwndAdvPifDlg) {
+ dst = FocStatTextAdv;
+ } else {
+ dst = FocStatTextNT;
+ }
+ if((FocID == IDADVCANCEL) && AdvClose) {
+ FocID = IDI_CANCLOSE;
+ }
+
+ if(!LoadString(hPifInstance, FocID, dst, PIFSTATUSLEN-1)) {
+ /* if string not defined above, try getting the generic string */
+ if(!LoadString(hPifInstance, IDI_GENSTAT, dst, PIFDEFPATHSIZE-1)) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ }
+ if(redrawflg) {
+ InvalidateStatusBar(hwnd);
+ }
+}
+
+void PaintStatus(HWND hwnd)
+{
+ HDC hdc;
+ RECT rc, rcTemp, rcTemp2;
+ HBRUSH hBrush;
+ PAINTSTRUCT ps;
+ BOOL bEGA;
+ unsigned char *txtpnt;
+ unsigned char blank[] = " ";
+
+ if((hwnd == hwndAdvPifDlg) && AdvScrollRange) /* No status bar if scroll bar */
+ return;
+
+ if((hwnd == hwndNTPifDlg) && NTScrollRange) /* No status bar if scroll bar */
+ return;
+
+ hdc = BeginPaint(hwnd, &ps);
+
+ GetClientRect(hwnd, &rc);
+ StatusPntData.hFontStatus = SelectObject(hdc, StatusPntData.hFontStatus);
+
+ rc.top = rc.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+
+ bEGA = GetNearestColor(hdc, GetSysColor(COLOR_BTNHIGHLIGHT)) ==
+ GetNearestColor(hdc, GetSysColor(COLOR_BTNFACE));
+
+ if (bEGA) {
+
+ /* EGA type display */
+
+ SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
+ SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
+
+ } else {
+
+ /* VGA type display */
+
+ /* draw the frame */
+
+ /* Border color */
+
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
+
+ /* top and bottom border */
+
+ /* Top */
+
+ rcTemp = rc;
+ rcTemp.bottom = rcTemp.top + StatusPntData.dyBorderx3;
+ rcTemp.top += StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ /* Bottom */
+
+ rcTemp = rc;
+ rcTemp.top = rcTemp.bottom - StatusPntData.dyBorderx2;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ /* left and right border */
+
+ /* Left */
+
+ rcTemp = rc;
+ rcTemp.right = 8 * StatusPntData.dyBorder;
+ rcTemp.top += StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ /* Right */
+
+ rcTemp = rc;
+ rcTemp.left = rcTemp.right - (8 * StatusPntData.dyBorder);
+ rcTemp.top += StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ DeleteObject((HGDIOBJ)hBrush);
+
+ /* Shadow color */
+
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
+
+ /* Top and left shadow */
+
+ /* Top */
+
+ rcTemp.left = 8 * StatusPntData.dyBorder;
+ rcTemp.right = rcTemp.right - 8 * StatusPntData.dyBorder;
+ rcTemp.top = rc.top + StatusPntData.dyBorderx3;
+ rcTemp.bottom = rcTemp.top + StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ /* Left */
+
+ rcTemp = rc;
+ rcTemp.left = 8 * StatusPntData.dyBorder;
+ rcTemp.right = rcTemp.left + StatusPntData.dyBorder;
+ rcTemp.top += StatusPntData.dyBorderx3;
+ rcTemp.bottom -= StatusPntData.dyBorderx2;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ DeleteObject((HGDIOBJ)hBrush);
+
+ /* Hilight color */
+
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNHIGHLIGHT));
+
+ /* Right and bottom hilight */
+
+ /* Bottom */
+
+ rcTemp = rc;
+ rcTemp.left = 8 * StatusPntData.dyBorder;
+ rcTemp.right = rcTemp.right - 8 * StatusPntData.dyBorder;
+ rcTemp.top = rc.bottom - 3 * StatusPntData.dyBorder;
+ rcTemp.bottom = rcTemp.top + StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ /* Right */
+
+ rcTemp = rc;
+ rcTemp.left = rcTemp.right - 9 * StatusPntData.dyBorder;
+ rcTemp.right = rcTemp.left + StatusPntData.dyBorder;
+ rcTemp.top += StatusPntData.dyBorderx3;
+ rcTemp.bottom -= StatusPntData.dyBorderx2;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+
+ DeleteObject((HGDIOBJ)hBrush);
+
+ SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
+ SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
+ }
+
+ /* solid black line across top */
+
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOWTEXT));
+ rcTemp = rc;
+ rcTemp.bottom = rcTemp.top;
+ rcTemp.bottom += StatusPntData.dyBorder;
+ FillRect(hdc, (CONST RECT *)&rcTemp, hBrush);
+ DeleteObject((HGDIOBJ)hBrush);
+
+ /* now the text, with the button face background */
+
+ rcTemp.top = rc.top + ((1+2+1) * StatusPntData.dyBorder);
+ rcTemp.bottom = rc.bottom - StatusPntData.dyBorderx3;
+ rcTemp.left = 9 * StatusPntData.dyBorder;
+ rcTemp.right = rc.right - 9 * StatusPntData.dyBorder;
+
+ if (bEGA) {
+ rcTemp2 = rc;
+ rcTemp2.top += StatusPntData.dyBorder;
+ } else {
+ rcTemp2 = rcTemp;
+ }
+
+ if(DoingMsg) {
+ txtpnt = blank;
+ } else {
+ if(hwnd == hMainwnd) {
+ txtpnt = FocStatTextMain;
+ } else if(hwnd == hwndAdvPifDlg) {
+ txtpnt = FocStatTextAdv;
+ } else {
+ txtpnt = FocStatTextNT;
+ }
+ }
+
+ ExtTextOut(hdc, rcTemp.left + StatusPntData.dyBorderx2, rcTemp.top,
+ ETO_OPAQUE | ETO_CLIPPED, (CONST RECT *)&rcTemp2, (LPSTR)txtpnt,
+ lstrlen((LPSTR)txtpnt), NULL);
+
+ StatusPntData.hFontStatus = SelectObject(hdc, StatusPntData.hFontStatus);
+
+ EndPaint(hwnd, (CONST PAINTSTRUCT *)&ps);
+
+}
+
+void HourGlass(BOOL bOn)
+{
+ /* toggle hourglass cursor */
+
+ if(!bMouse) /* Turn cursor on/off if no mouse */
+ ShowCursor(bOn);
+ SetCursor(bOn ? hWaitCurs : hArrowCurs);
+}
+
+void SetMainTitle(void)
+{
+ int i;
+ int j;
+ HANDLE hFile;
+ unsigned char buf[(MAX_PATH*2)+360];
+ unsigned char buf2[360];
+ unsigned char *pch;
+ WIN32_FIND_DATA fd;
+
+ if(!(i = LoadString(hPifInstance, PIFCAPTION, (LPSTR)buf, sizeof(buf)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+
+ if(hwndAdvPifDlg) {
+ if(!(j = LoadString(hPifInstance, PIFCAPTIONADV, (LPSTR)buf2, sizeof(buf2)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ }
+ else if(hwndNTPifDlg) {
+ if(!(j = LoadString(hPifInstance, PIFCAPTIONNT, (LPSTR)buf2, sizeof(buf2)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ }
+ if(CurPifFile[0] == 0) {
+ if(!LoadString(hPifInstance, NOTITLE, (LPSTR)(buf+i), (sizeof(buf)-i))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+/*
+ * if(hwndAdvPifDlg) {
+ * if(!LoadString(hPifInstance, NOTITLE, (LPSTR)(buf2+j), (sizeof(buf2)-j))) {
+ * Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ * }
+ * }
+ */
+ } else {
+ if((hFile = FindFirstFile(CurPifFile, &fd)) != INVALID_HANDLE_VALUE) {
+ lstrcat((LPSTR)buf, fd.cFileName);
+ FindClose(hFile);
+ }
+ else {
+ pch = CurPifFile+fileoffset;
+ lstrcat((LPSTR)buf, (LPSTR)pch);
+ }
+ /*
+ * if(hwndAdvPifDlg)
+ * lstrcat((LPSTR)buf2, (LPSTR)pch);
+ */
+ }
+ SetWindowText(hMainwnd,(LPSTR)buf);
+
+ if(hwndAdvPifDlg) {
+ SetWindowText(hwndAdvPifDlg,(LPSTR)buf2);
+ }
+ else if(hwndNTPifDlg) {
+ SetWindowText(hwndNTPifDlg,(LPSTR)buf2);
+ }
+}
+
+
+UndoNTClose(void)
+{
+ unsigned char chBuf[40];
+
+ if(NTClose && hwndNTPifDlg) {
+ if(!LoadString(hPifInstance, PIFCANCELSTRNG , (LPSTR)chBuf, sizeof(chBuf))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndNTPifDlg,IDNTCANCEL,(LPSTR)chBuf);
+ }
+ NTClose = FALSE;
+ if(FocusIDNT == IDNTCANCEL) {
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ }
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+UndoAdvClose(void)
+{
+ unsigned char chBuf[40];
+
+ if(AdvClose && hwndAdvPifDlg) {
+ if(!LoadString(hPifInstance, PIFCANCELSTRNG , (LPSTR)chBuf, sizeof(chBuf))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndAdvPifDlg,IDADVCANCEL,(LPSTR)chBuf);
+ }
+ AdvClose = FALSE;
+ if(FocusIDAdv == IDADVCANCEL) {
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ }
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+DoDlgCommand(HWND hwnd, WPARAM wParam, LONG lParam)
+{
+ unsigned int value;
+ char buf[PIFDEFPATHSIZE*2];
+ int len, cmd;
+ int ivalue;
+ BOOL result;
+ BOOL OldFileChanged;
+
+ cmd = LOWORD(wParam);
+
+ switch (cmd) {
+
+/* case IDI_PSNONE:
+ * case IDI_PSTEXT:
+ * case IDI_PSGRAPH:
+ * CheckRadioButton(hwnd, IDI_PSFIRST, IDI_PSLAST, cmd);
+ * break;
+ */
+ case IDI_PSTEXT:
+ case IDI_PSGRAPH:
+ CheckRadioButton(hwnd, IDI_PSTEXT, IDI_PSGRAPH, cmd);
+ break;
+
+/*
+ * case IDI_SENONE:
+ * case IDI_SETEXT:
+ * case IDI_SEGRAPH:
+ * CheckRadioButton(hwnd, IDI_SEFIRST, IDI_SELAST, cmd);
+ * break;
+ */
+
+ case IDI_ADVANCED:
+ if(CurrMode386) {
+ HourGlass(TRUE);
+ SwitchAdvance386(hwnd);
+ HourGlass(FALSE);
+ } else {
+
+ }
+ break;
+
+ case IDI_NT:
+ if(CurrMode386) {
+ HourGlass(TRUE);
+ SwitchNT(hwnd);
+ HourGlass(FALSE);
+ } else {
+
+ }
+ break;
+
+ case IDI_PSNONE:
+ case IDI_SENONE:
+
+/* case IDI_DMSCREEN: */
+/* case IDI_DMMEM: */
+ case IDI_DMCOM1:
+ case IDI_DMCOM2:
+ case IDI_DMCOM3:
+ case IDI_DMCOM4:
+ case IDI_DMKBD:
+ case IDI_EXIT:
+ case IDI_BACK:
+ case IDI_EXCL:
+ case IDI_NOSAVVID:
+ case IDI_NTTIMER:
+ CheckDlgButton(hwnd, cmd, !IsDlgButtonChecked(hwnd, cmd));
+ break;
+
+ case IDI_POLL:
+ case IDI_ALTTAB:
+ case IDI_ALTESC:
+ case IDI_CTRLESC:
+ case IDI_ALTSPACE:
+ case IDI_ALTENTER:
+ case IDI_ALTPRTSC:
+ case IDI_PRTSC:
+ case IDI_NOHMA:
+ case IDI_INT16PST:
+ case IDI_VMLOCKED:
+ case IDI_XMSLOCKED:
+ case IDI_EMSLOCKED:
+ case IDI_TEXTEMULATE:
+ case IDI_RETAINALLO:
+ case IDI_TRAPTXT:
+ case IDI_TRAPLRGRFX:
+ case IDI_TRAPHRGRFX:
+ CheckDlgButton(hwnd, cmd, !IsDlgButtonChecked(hwnd, cmd));
+ UndoAdvClose();
+ break;
+
+ case IDI_VMODETXT:
+ CheckRadioButton(hwnd, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODETXT);
+ break;
+
+ case IDI_VMODELRGRFX:
+ CheckRadioButton(hwnd, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODELRGRFX);
+ break;
+
+ case IDI_VMODEHRGRFX:
+ CheckRadioButton(hwnd, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODEHRGRFX);
+ break;
+
+ case IDI_CLOSE:
+ CheckDlgButton(hwnd, cmd, !IsDlgButtonChecked(hwnd, cmd));
+ if(IsDlgButtonChecked(hwnd, cmd)) {
+ value = Warning(WARNCLOSE,MB_ICONHAND | MB_OKCANCEL);
+ if(value == IDCANCEL) {
+ CheckDlgButton(hwnd, cmd, FALSE);
+ }
+ }
+ UndoAdvClose();
+ break;
+
+ case IDI_FSCR:
+ case IDI_WND:
+ CheckRadioButton(hwnd, IDI_WND, IDI_FSCR, cmd);
+ break;
+
+ case IDI_FPRI:
+ case IDI_BPRI:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ len = GetDlgItemText(hwnd, cmd, (LPSTR)buf, sizeof(buf));
+ value = GetDlgItemInt(hwnd, cmd, (BOOL FAR *)&result, FALSE);
+ if((!result) && (len == 0)) {
+ UndoAdvClose();
+ } else if((!result) || (value == 0) || (value > 10000)) {
+ MessageBeep(0);
+ Warning(errBadNumberP,MB_ICONEXCLAMATION | MB_OK);
+ SetDlgItemInt(hwnd, cmd,
+ (cmd == IDI_FPRI ? Pif386ext->PfFPriority : Pif386ext->PfBPriority),
+ FALSE);
+ } else {
+ UndoAdvClose();
+ }
+ }
+ break;
+
+ case IDI_MEMDES:
+ case IDI_MEMREQ:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ len = GetDlgItemText(hwnd, cmd, (LPSTR)buf, sizeof(buf));
+ ivalue = (int)GetDlgItemInt(hwnd, cmd, (BOOL FAR *)&result, TRUE);
+ if(((!result) && (len == 0)) || ((!result) && (len == 1) && (buf[0] == '-'))) {
+ } else if((!result) || (ivalue < -1) || (ivalue > 640)) {
+ MessageBeep(0);
+ if(cmd == IDI_MEMREQ)
+ Warning(errBadNumberMR,MB_ICONEXCLAMATION | MB_OK);
+ else
+ Warning(errBadNumberMD,MB_ICONEXCLAMATION | MB_OK);
+ if(CurrMode386)
+ SetDlgItemInt(hwnd, cmd,
+ (cmd == IDI_MEMDES ? Pif386ext->maxmem : Pif386ext->minmem),
+ TRUE);
+ else
+ SetDlgItemInt(hwnd, cmd,
+ (cmd == IDI_MEMDES ? PifFile->maxmem : PifFile->minmem),
+ TRUE);
+ }
+ }
+ break;
+
+ case IDI_EMSDES:
+ case IDI_XMADES:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ len = GetDlgItemText(hwnd, cmd, (LPSTR)buf, sizeof(buf));
+ ivalue = (int)GetDlgItemInt(hwnd, cmd, (BOOL FAR *)&result, TRUE);
+ if(((!result) && (len == 0)) || ((!result) && (len == 1) && (buf[0] == '-'))) {
+ } else if((!result) || ((ivalue < -1) || (ivalue > 16384))) {
+ MessageBeep(0);
+ Warning(errBadNumberXEMSD,MB_ICONEXCLAMATION | MB_OK);
+ if(CurrMode386) {
+ if(Pif386ext) {
+ switch (cmd) {
+ case IDI_EMSDES:
+ SetDlgItemInt(hwnd, cmd, Pif386ext->PfMaxEMMK,TRUE);
+ break;
+ case IDI_XMADES:
+ SetDlgItemInt(hwnd, cmd, Pif386ext->PfMaxXmsK,TRUE);
+ break;
+ }
+ }
+ } else {
+ /*
+ *switch (cmd) {
+ *
+ * case IDI_EMSDES:
+ * if(Pif286ext31)
+ * SetDlgItemInt(hwnd, cmd, Pif286ext31->PfMaxEmsK,TRUE);
+ * break;
+ *
+ * case IDI_XMADES:
+ */
+ if(Pif286ext30)
+ SetDlgItemInt(hwnd, cmd, Pif286ext30->PfMaxXmsK,TRUE);
+ /*
+ * break;
+ *}
+ */
+ }
+ }
+ }
+ break;
+
+
+ case IDI_EMSREQ:
+ case IDI_XMAREQ:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ len = GetDlgItemText(hwnd, cmd, (LPSTR)buf, sizeof(buf));
+ value = GetDlgItemInt(hwnd, cmd, (BOOL FAR *)&result, FALSE);
+ if((!result) && (len == 0)) {
+ } else if((!result) || (value > 16384)) {
+ MessageBeep(0);
+ Warning(errBadNumberXEMSR,MB_ICONEXCLAMATION | MB_OK);
+ if(CurrMode386) {
+ if(Pif386ext) {
+ switch (cmd) {
+ case IDI_EMSREQ:
+ SetDlgItemInt(hwnd, cmd, Pif386ext->PfMinEMMK,FALSE);
+ break;
+ case IDI_XMAREQ:
+ SetDlgItemInt(hwnd, cmd, Pif386ext->PfMinXmsK,FALSE);
+ break;
+ }
+ }
+ } else {
+ /*
+ *switch (cmd) {
+ *
+ * case IDI_EMSREQ:
+ * if(Pif286ext31)
+ * SetDlgItemInt(hwnd, cmd, Pif286ext31->PfMinEmsK,FALSE);
+ * break;
+ *
+ * case IDI_XMAREQ:
+ */
+ if(Pif286ext30)
+ SetDlgItemInt(hwnd, cmd, Pif286ext30->PfMinXmsK,FALSE);
+ /*
+ * break;
+ *}
+ */
+ }
+ }
+ }
+ break;
+
+ case IDCANCEL:
+ case IDNTCANCEL:
+ case IDADVCANCEL:
+ if((hwnd == hwndAdvPifDlg) || (hwnd == hwndNTPifDlg)) {
+ SendMessage(hwnd,WM_PRIVCLOSECANCEL,0,0L);
+ }
+ break;
+
+ case IDOK:
+ case IDNTOK:
+ if(hwnd == hwndAdvPifDlg) {
+ if(CurrMode386) {
+ if(UpdatePif386Struc())
+ FileChanged = TRUE;
+ }
+ if(!DoFieldsWorkAdv(FALSE))
+ break;
+ SendMessage(hwnd,WM_PRIVCLOSEOK,0,0L);
+ }
+ else if(hwnd == hwndNTPifDlg) {
+ if(CurrMode386) {
+ if(UpdatePifNTStruc()) {
+ OldFileChanged = FileChanged;
+ FileChanged = TRUE;
+ }
+ }
+ if(!DoFieldsWorkNT(FALSE)) {
+ FileChanged = OldFileChanged;
+ break;
+ }
+ SendMessage(hwnd,WM_PRIVCLOSEOK,0,0L);
+ }
+ break;
+
+ }
+ return(TRUE);
+}
+
+
+long GetNTDlgSize(HWND hwnd)
+{
+ int i = 0;
+ RECT rc2;
+ RECT rc3;
+ RECT rc4;
+
+ /* get right side from the OK button */
+ GetWindowRect(GetDlgItem(hwnd,IDNTOK),(LPRECT)&rc2);
+
+ /* get left & bottom sides from the IDI_NTTIMER check box */
+ GetWindowRect(GetDlgItem(hwnd,IDI_NTTIMER),(LPRECT)&rc3);
+ GetWindowRect(hwnd,(LPRECT)&rc4);
+
+ if(NTScrollRange && (i = GetScrollPos(hwnd,SB_VERT))) {
+ i = min((i * NTScrollLineSz),MaxNTNeg);
+ }
+ return(MAKELONG((rc2.right - rc4.left) +
+ SysCharWidth -
+ GetSystemMetrics(SM_CXFRAME),
+ (rc3.bottom - rc4.top) +
+ (SysCharHeight/2) +
+ i -
+ (GetSystemMetrics(SM_CYCAPTION) +
+ GetSystemMetrics(SM_CYBORDER) +
+ GetSystemMetrics(SM_CYFRAME)) +
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2)));
+}
+
+
+long GetAdvDlgSize(HWND hwnd)
+{
+ int i = 0;
+ RECT rc2;
+ RECT rc3;
+
+ GetWindowRect(GetDlgItem(hwnd,IDI_OTHGRP),(LPRECT)&rc2);
+ GetWindowRect(hwnd,(LPRECT)&rc3);
+ if(AdvScrollRange && (i = GetScrollPos(hwnd,SB_VERT))) {
+ i = min((i * AdvScrollLineSz),MaxAdvNeg);
+ }
+ return(MAKELONG((rc2.right - rc3.left) +
+ SysCharWidth -
+ GetSystemMetrics(SM_CXFRAME),
+ (rc2.top-rc3.top) +
+ (rc2.bottom - rc2.top) +
+ (SysCharHeight/2) +
+ i -
+ (GetSystemMetrics(SM_CYCAPTION) +
+ GetSystemMetrics(SM_CYBORDER) +
+ GetSystemMetrics(SM_CYFRAME)) +
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2)));
+}
+
+
+ReEnableAdvButton(void)
+{
+ HWND hwndctl;
+
+ if(hwndPifDlg && CurrMode386) {
+
+ if(!bNTDlgOpen) {
+ hwndctl = GetDlgItem(hwndPifDlg,IDI_NT);
+ if(hwndFocusMain == hwndctl)
+ SendMessage(hwndctl,BM_SETSTYLE,BS_DEFPUSHBUTTON,1L);
+ else
+ SendMessage(hwndctl,BM_SETSTYLE,BS_PUSHBUTTON,1L);
+ EnableWindow(hwndctl,TRUE);
+ }
+
+ if(!bAdvDlgOpen) {
+ hwndctl = GetDlgItem(hwndPifDlg,IDI_ADVANCED);
+ if(hwndFocusMain == hwndctl)
+ SendMessage(hwndctl,BM_SETSTYLE,BS_DEFPUSHBUTTON,1L);
+ else
+ SendMessage(hwndctl,BM_SETSTYLE,BS_PUSHBUTTON,1L);
+ EnableWindow(hwndctl,TRUE);
+ }
+ }
+ return(TRUE);
+}
+
+DoOpenPifFile(HDROP DropHnd)
+{
+ HWND hwnd2;
+ unsigned char *pchBuf = (unsigned char *)NULL;
+ unsigned char *pch;
+
+ if (MaybeSaveFile()) {
+ if(DropHnd) {
+ if(!(pchBuf = (unsigned char *)LocalAlloc(LPTR, 132))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ if(!(DragQueryFile(DropHnd,0,(LPSTR)pchBuf,132))) {
+ LocalFree((HANDLE)pchBuf);
+ pchBuf = (unsigned char *)NULL;
+ } else {
+ SetFileOffsets(pchBuf,&tmpfileoffset,&tmpextoffset);
+ }
+ }
+ } else {
+ pchBuf = PutUpDB(DTOPEN);
+ }
+ }
+ if(pchBuf) {
+ AnsiUpper((LPSTR)pchBuf);
+ pch = pchBuf+tmpextoffset;
+ if((tmpextoffset == 0) || (lstrcmp((LPSTR)pch, (LPSTR)"PIF"))) {
+ if( Warning(errWrongExt,MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2) == IDCANCEL) {
+ LocalFree((HANDLE)pchBuf);
+ pchBuf = (unsigned char *)NULL;
+ }
+ }
+ }
+ if(pchBuf) {
+ HourGlass(TRUE);
+ LoadPifFile(pchBuf);
+ LocalFree((HANDLE)pchBuf);
+ SendMessage(hwndPifDlg,WM_NEXTDLGCTL,
+ (WPARAM)(hwnd2 = GetDlgItem(hwndPifDlg,IDI_ENAME)),1L);
+ SetFocus(hwnd2);
+ HourGlass(FALSE);
+ SetMainTitle();
+ }
+ if(DropHnd)
+ DragFinish(DropHnd);
+ return(TRUE);
+}
+
+
+int FAR PASCAL PifNTWndProc(HWND hwnd, UINT message, WPARAM wParam, LONG lParam)
+{
+ LPPOINT ppnt3;
+ LPPOINT ppnt4;
+ int width;
+ int height;
+ long size;
+ BOOL ChngFlg;
+ HMENU hmenu;
+ RECT rc;
+ CHAR buf[PIFDEFPATHSIZE*2];
+ int tmpFOCID;
+
+ switch (message) {
+
+ case WM_INITDIALOG:
+ if((hmenu = GetSystemMenu(hwnd,FALSE))) {
+ DeleteMenu(hmenu, SC_RESTORE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_SIZE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_MINIMIZE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_MAXIMIZE, MF_BYCOMMAND);
+ } else {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ lstrcpy(szOldAutoexec, (LPSTR)(PifNText->achAutoexecFile));
+ lstrcpy(szOldConfig, (LPSTR)(PifNText->achConfigFile));
+ hwndFocusNT = (HWND)wParam;
+ bNTDlgOpen = TRUE;
+ FocusIDNT = GetDlgCtrlID((HWND)wParam);
+ OemToAnsi((LPSTR)PifNText->achAutoexecFile, buf);
+ SetDlgItemText(hwnd, IDI_AUTOEXEC,(LPSTR)buf);
+ OemToAnsi((LPSTR)PifNText->achConfigFile, buf);
+ SetDlgItemText(hwnd, IDI_CONFIG, (LPSTR)buf);
+ SendDlgItemMessage(hwnd, IDI_AUTOEXEC, EM_LIMITTEXT, PIFDEFPATHSIZE-1, 0L);
+ SendDlgItemMessage(hwnd, IDI_CONFIG, EM_LIMITTEXT, PIFDEFPATHSIZE-1, 0L);
+ CheckDlgButton(hwnd, IDI_NTTIMER, (PifNText->dwWNTFlags & COMPAT_TIMERTIC ? TRUE : FALSE));
+ SetStatusText(hwnd,FocusIDNT,FALSE);
+ if(InitShWind) {
+ SetFocus((HWND)wParam); /* Give focus to wparam item */
+ SendMessage((HWND)wParam,EM_SETSEL,0,MAKELONG(0,0x7FFF));
+ return(FALSE);
+ } else {
+ return(FALSE); /* Do not set focus until init show */
+ }
+ break;
+
+ case WM_PAINT:
+ PaintStatus(hwnd);
+ return(FALSE);
+ break;
+
+ case WM_COMMAND:
+ SetStatusText(hwnd,FocusIDNT,TRUE);
+ FocusIDNTMenu = 0;
+ DoDlgCommand(hwnd, wParam, lParam);
+ break;
+
+ case WM_SYSCOLORCHANGE:
+ InvalidateStatusBar(hwnd);
+ break;
+
+ case WM_MENUSELECT:
+ tmpFOCID = FocusIDNTMenu;
+ if((HIWORD(wParam) == 0xFFFF) && (lParam == (LPARAM)NULL)) { // was menu closed?
+ SetStatusText(hwnd,FocusIDNT,TRUE);
+ tmpFOCID = FocusIDNTMenu = 0;
+ } else if(lParam == 0) { /* ignore these */
+ } else if(HIWORD(wParam) & MF_POPUP) {
+ if((HMENU)lParam == hSysMenuNT)
+ FocusIDNTMenu = M_SYSMENUNT;
+ } else {
+ if(LOWORD(wParam) != 0) /* separators have wparam of 0 */
+ FocusIDNTMenu = LOWORD(wParam);
+ if(FocusIDNTMenu == SC_CLOSE)
+ FocusIDNTMenu = SC_NTCLOSE;
+ }
+ if(tmpFOCID != FocusIDNTMenu)
+ SetStatusText(hwnd,FocusIDNTMenu,TRUE);
+ break;
+
+ case WM_SIZE:
+ GetClientRect(hwnd, &rc);
+ rc.top = rc.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ if(rc.top < StatRecSizeNT.top) {
+ /* Window SHRANK, need to invalidate current status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&rc,FALSE);
+ } else {
+ /* Window GREW, need to invalidate prev status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&StatRecSizeNT,TRUE);
+ }
+ switch (wParam) {
+ case SIZEFULLSCREEN:
+ case SIZENORMAL:
+ NTWndSize = wParam;
+ SetMainWndSize(SBUNT);
+ /* NOTE FALL THROUGH */
+ default:
+ return(FALSE);
+ break;
+ }
+ break;
+
+ case WM_VSCROLL:
+ if(NTScrollRange)
+ MainScroll(hwnd, (int)(LOWORD(wParam)), (int)(HIWORD(wParam)), 0, 0);
+ return(TRUE);
+ break;
+
+ case WM_PRIVCLOSECANCEL:
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ lstrcpy((LPSTR)(PifNText->achAutoexecFile), szOldAutoexec);
+ SetDlgItemText(hwnd, IDI_AUTOEXEC, szOldAutoexec);
+ lstrcpy((LPSTR)(PifNText->achConfigFile), szOldConfig);
+ SetDlgItemText(hwnd, IDI_CONFIG, szOldConfig);
+ SetNTDlgItem(IDI_AUTOEXEC);
+ UpdatePifScreenNT(); /* DISCARD any changes in NT */
+
+ /* NOTE FALL THROUGH */
+ case WM_PRIVCLOSEOK:
+ bNTDlgOpen = FALSE;
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ hwndNTPifDlg = (HWND)NULL;
+ hSysMenuNT = (HMENU)NULL;
+ /*
+ * WHAT IS THIS RANDOM SetFocus DOING HERE??? Well the advanced
+ * window is WS_OVERLAPPED, and Windows CAN get all confused
+ * about where the Focus should go on Destroy with this style.
+ * The style probably should be changed to WS_POPUP, but that
+ * is a change that may cause other problems.
+ */
+ SetFocus(hMainwnd);
+ DragAcceptFiles(hwnd,FALSE);
+ DestroyWindow(hwnd);
+ ReEnableAdvButton();
+ NTScrollRange = 0;
+ ModeAdvanced = FALSE;
+ return(TRUE);
+ break;
+
+ case WM_SYSCOMMAND:
+ switch (wParam) {
+ case SC_CLOSE:
+ SendMessage(hwnd,WM_PRIVCLOSECANCEL,0,0L);
+ return(TRUE);
+
+ default:
+ return(FALSE);
+ }
+ break;
+
+ case WM_PRIVGETSIZE: /* return correct size for client area */
+ *(long FAR *)lParam = GetNTDlgSize(hwnd);
+ break;
+
+ case WM_GETMINMAXINFO:
+ GetClientRect(hwnd, &StatRecSizeNT);
+ StatRecSizeNT.top = StatRecSizeNT.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ size = GetNTDlgSize(hwnd);
+ width = LOWORD(size) +
+ (2 * GetSystemMetrics(SM_CXFRAME)) +
+ GetSystemMetrics(SM_CXVSCROLL) +
+ GetSystemMetrics(SM_CXBORDER);
+ height = HIWORD(size) +
+ GetSystemMetrics(SM_CYCAPTION) +
+ (2 * GetSystemMetrics(SM_CYFRAME));
+ ppnt3 = ppnt4 = (LPPOINT)lParam;
+ ppnt3 += 3;
+ ppnt4 += 4;
+ if(height > (ppnt4->y - (4 * SysCharHeight)))
+ height = ppnt4->y - (4 * SysCharHeight);
+ ppnt3->y = height;
+ ppnt3->x = width;
+ return(TRUE);
+ break;
+
+ case WM_DROPFILES:
+ DoOpenPifFile((HDROP)wParam);
+ break;
+
+ default:
+ return(FALSE);
+
+ }
+ return(TRUE);
+}
+
+
+int FAR PASCAL PifAdvWndProc(HWND hwnd, UINT message, WPARAM wParam, LONG lParam)
+{
+ LPPOINT ppnt3;
+ LPPOINT ppnt4;
+ int width;
+ int height;
+ long size;
+ BOOL ChngFlg;
+ HMENU hmenu;
+ RECT rc;
+ int tmpFOCID;
+
+ switch (message) {
+
+ case WM_INITDIALOG:
+ if((hmenu = GetSystemMenu(hwnd,FALSE))) {
+ DeleteMenu(hmenu, SC_RESTORE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_SIZE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_MINIMIZE, MF_BYCOMMAND);
+ DeleteMenu(hmenu, SC_MAXIMIZE, MF_BYCOMMAND);
+ } else {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ hwndFocusAdv = (HWND)wParam;
+ bAdvDlgOpen = TRUE;
+ FocusIDAdv = GetDlgCtrlID((HWND)wParam);
+ SetStatusText(hwnd,FocusIDAdv,FALSE);
+ if(InitShWind) {
+ SetFocus((HWND)wParam); /* Give focus to wparam item */
+ SendMessage((HWND)wParam,EM_SETSEL,0,MAKELONG(0,0x7FFF));
+ return(FALSE);
+ } else {
+ return(FALSE); /* Do not set focus until init show */
+ }
+ break;
+
+ case WM_PAINT:
+ PaintStatus(hwnd);
+ return(FALSE);
+ break;
+
+ case WM_COMMAND:
+ SetStatusText(hwnd,FocusIDAdv,TRUE);
+ FocusIDAdvMenu = 0;
+ DoDlgCommand(hwnd, wParam, lParam);
+ break;
+
+ case WM_SYSCOLORCHANGE:
+ InvalidateStatusBar(hwnd);
+ break;
+
+ case WM_MENUSELECT:
+ tmpFOCID = FocusIDAdvMenu;
+ if((HIWORD(wParam) == 0xFFFF) && (lParam == (LPARAM)NULL)) { // was menu closed?
+ SetStatusText(hwnd,FocusIDAdv,TRUE);
+ tmpFOCID = FocusIDAdvMenu = 0;
+ } else if(lParam == 0) { /* ignore these */
+ } else if(HIWORD(wParam) & MF_POPUP) {
+ if((HMENU)lParam == hSysMenuAdv)
+ FocusIDAdvMenu = M_SYSMENUADV;
+ } else {
+ if(LOWORD(wParam) != 0) /* separators have wparam of 0 */
+ FocusIDAdvMenu = LOWORD(wParam);
+ if(FocusIDAdvMenu == SC_CLOSE)
+ FocusIDAdvMenu = SC_CLOSEADV;
+ }
+ if(tmpFOCID != FocusIDAdvMenu)
+ SetStatusText(hwnd,FocusIDAdvMenu,TRUE);
+ break;
+
+ case WM_SIZE:
+ GetClientRect(hwnd, &rc);
+ rc.top = rc.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ if(rc.top < StatRecSizeAdv.top) {
+ /* Window SHRANK, need to invalidate current status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&rc,FALSE);
+ } else {
+ /* Window GREW, need to invalidate prev status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&StatRecSizeAdv,TRUE);
+ }
+ switch (wParam) {
+ case SIZEFULLSCREEN:
+ case SIZENORMAL:
+ AdvWndSize = wParam;
+ SetMainWndSize(SBUADV);
+ /* NOTE FALL THROUGH */
+ default:
+ return(FALSE);
+ break;
+ }
+ break;
+
+ case WM_VSCROLL:
+ if(AdvScrollRange)
+ MainScroll(hwnd, (int)(LOWORD(wParam)), (int)(HIWORD(wParam)), 0, 0);
+ return(TRUE);
+ break;
+
+ case WM_PRIVCLOSECANCEL:
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ UpdatePifScreenAdv(); /* DISCARD any changes in advanced */
+ /* NOTE FALL THROUGH */
+ case WM_PRIVCLOSEOK:
+ bAdvDlgOpen = FALSE;
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ hwndAdvPifDlg = (HWND)NULL;
+ hSysMenuAdv = (HMENU)NULL;
+ /*
+ * WHAT IS THIS RANDOM SetFocus DOING HERE??? Well the advanced
+ * window is WS_OVERLAPPED, and Windows CAN get all confused
+ * about where the Focus should go on Destroy with this style.
+ * The style probably should be changed to WS_POPUP, but that
+ * is a change that may cause other problems.
+ */
+ SetFocus(hMainwnd);
+ DragAcceptFiles(hwnd,FALSE);
+ DestroyWindow(hwnd);
+ ReEnableAdvButton();
+ AdvScrollRange = 0;
+ ModeAdvanced = FALSE;
+ return(TRUE);
+ break;
+
+ case WM_SYSCOMMAND:
+ switch (wParam) {
+ case SC_CLOSE:
+ SendMessage(hwnd,WM_PRIVCLOSECANCEL,0,0L);
+ return(TRUE);
+
+ default:
+ return(FALSE);
+ }
+ break;
+
+ case WM_PRIVGETSIZE: /* return correct size for client area */
+ *(long FAR *)lParam = GetAdvDlgSize(hwnd);
+ break;
+
+ case WM_GETMINMAXINFO:
+ GetClientRect(hwnd, &StatRecSizeAdv);
+ StatRecSizeAdv.top = StatRecSizeAdv.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ size = GetAdvDlgSize(hwnd);
+ width = LOWORD(size) +
+ (2 * GetSystemMetrics(SM_CXFRAME)) +
+ GetSystemMetrics(SM_CXVSCROLL) +
+ GetSystemMetrics(SM_CXBORDER);
+ height = HIWORD(size) +
+ GetSystemMetrics(SM_CYCAPTION) +
+ (2 * GetSystemMetrics(SM_CYFRAME));
+ ppnt3 = ppnt4 = (LPPOINT)lParam;
+ ppnt3 += 3;
+ ppnt4 += 4;
+ if(height > (ppnt4->y - (4 * SysCharHeight)))
+ height = ppnt4->y - (4 * SysCharHeight);
+ ppnt3->y = height;
+ ppnt3->x = width;
+ return(TRUE);
+ break;
+
+ case WM_DROPFILES:
+ DoOpenPifFile((HDROP)wParam);
+ break;
+
+ default:
+ return(FALSE);
+
+ }
+ return(TRUE);
+}
+
+int FAR PASCAL PifWndProc(HWND hwnd, UINT message, WPARAM wParam, LONG lParam)
+{
+ RECT rc2;
+ RECT rc3;
+ RECT rc4;
+
+ switch (message) {
+
+ case WM_INITDIALOG:
+ hwndFocusMain = (HWND)wParam;
+ FocusIDMain = GetDlgCtrlID((HWND)wParam);
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ if(InitShWind) {
+ SetFocus((HWND)wParam); /* Give focus to wparam item */
+ SendMessage((HWND)wParam,EM_SETSEL,0,MAKELONG(0,0x7FFF));
+ return(FALSE);
+ } else {
+ return(FALSE); /* Do not set focus until init show */
+ }
+ break;
+
+ case WM_COMMAND:
+ DoDlgCommand(hwnd, wParam, lParam);
+ break;
+
+ case WM_PRIVGETSIZE: /* return correct size for parent window client area */
+ GetWindowRect(hwnd,(LPRECT)&rc3);
+ if(CurrMode386) {
+ GetWindowRect(GetDlgItem(hwnd,IDI_BACK),(LPRECT)&rc4);
+ GetWindowRect(GetDlgItem(hwnd,IDI_EXIT),(LPRECT)&rc2);
+ } else {
+ GetWindowRect(GetDlgItem(hwnd,IDI_EPATH),(LPRECT)&rc4);
+ GetWindowRect(GetDlgItem(hwnd,IDI_ALTPRTSC),(LPRECT)&rc2);
+ }
+ *(long FAR *)lParam = MAKELONG((rc4.right - rc3.left) +
+ SysCharWidth,
+ (rc2.top-rc3.top) +
+ (rc2.bottom - rc2.top) +
+ ((rc2.bottom - rc2.top)/3) +
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2));
+ if(!wParam) {
+ SetWindowPos(hwnd,
+ (HWND)NULL,
+ 0,
+ 0,
+ 0,
+ 0,
+ SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ }
+ break;
+
+ case WM_DROPFILES:
+ DoOpenPifFile((HDROP)wParam);
+ break;
+
+ default:
+ return(FALSE);
+
+ }
+ return(TRUE);
+}
+
+
+SwitchNT(HWND hwnd)
+{
+ BOOL ChngFlg;
+
+ hwndFocusMain = hwndFocusAdv = hwndFocusNT = hwndFocus = (HWND)NULL;
+ if(ModeAdvanced) {
+ Disable386Advanced(hwndAdvPifDlg, hwndNTPifDlg);
+ }
+ else {
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ if(!bNTDlgOpen) {
+ EnableWindow(GetDlgItem(hwnd,IDI_NT),FALSE);
+ NTScrollRange = 0;
+/*
+ NTClose = TRUE;
+*/
+ hwndNTPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIFNTTEMPLT),
+ hMainwnd ,
+ (DLGPROC)lpfnNTPifWnd);
+ }
+ if(hwndNTPifDlg == (HWND)NULL) {
+ hwndNTPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ Disable386Advanced(hwndAdvPifDlg, hwndNTPifDlg);
+ } else {
+ hSysMenuNT = GetSystemMenu(hwndNTPifDlg,FALSE);
+ DragAcceptFiles(hwndNTPifDlg,TRUE);
+ ModeAdvanced = TRUE;
+ SetMainTitle();
+ UpdatePifScreen();
+ hwndFocusMain = GetDlgItem(hwndPifDlg,IDI_ENAME);
+ FocusIDMain = IDI_ENAME;
+ SetMainWndSize(SBUSZNT);
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ }
+ }
+ if(hwndNTPifDlg) {
+ ShowWindow(hwndNTPifDlg, SW_SHOWNORMAL);
+ SendDlgItemMessage(hwndNTPifDlg,IDI_AUTOEXEC,EM_SETSEL,0,MAKELONG(0,0x7FFF));
+ }
+ return(TRUE);
+}
+
+
+
+SwitchAdvance386(HWND hwnd)
+{
+ BOOL ChngFlg;
+
+ hwndFocusMain = hwndFocusAdv = hwndFocusNT = hwndFocus = (HWND)NULL;
+ if(ModeAdvanced) {
+ Disable386Advanced(hwndAdvPifDlg, hwndNTPifDlg);
+ } else {
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ if(!bAdvDlgOpen)
+ EnableWindow(GetDlgItem(hwnd,IDI_ADVANCED),FALSE);
+ AdvScrollRange = 0;
+ AdvClose = TRUE;
+ hwndAdvPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIF386ADVTEMPLT),
+ hMainwnd ,
+ (DLGPROC)lpfnAdvPifWnd);
+ if(hwndAdvPifDlg == (HWND)NULL) {
+ hwndAdvPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ Disable386Advanced(hwndAdvPifDlg, hwndNTPifDlg);
+ } else {
+ hSysMenuAdv = GetSystemMenu(hwndAdvPifDlg,FALSE);
+ DragAcceptFiles(hwndAdvPifDlg,TRUE);
+ ModeAdvanced = TRUE;
+ SetMainTitle();
+ UpdatePifScreen();
+ hwndFocusMain = GetDlgItem(hwndPifDlg,IDI_ENAME);
+ FocusIDMain = IDI_ENAME;
+ SetMainWndSize(SBUSZADV);
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ }
+ }
+ if(hwndAdvPifDlg) {
+ ShowWindow(hwndAdvPifDlg, SW_SHOWNORMAL);
+ SendDlgItemMessage(hwndAdvPifDlg,IDI_BPRI,EM_SETSEL,0,MAKELONG(0,0x7FFF));
+ }
+ return(TRUE);
+}
+
+
+BOOL EnableMode286(HWND hwnd,BOOL showflg)
+{
+ HMENU hMenu;
+ HWND hWndSv;
+
+ if(!Pif286ext30) {
+ if(!(Pif286ext30 = AllocInit286Ext30())) {
+ Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ /*
+ * if(!Pif286ext31) {
+ * if(!(Pif286ext31 = AllocInit286Ext31())) {
+ * Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
+ * return(FALSE);
+ * }
+ * }
+ */
+ hwndFocusMain = hwndFocusAdv = hwndFocusNT = hwndFocus = (HWND)NULL;
+ if(hwndAdvPifDlg)
+ SendMessage(hwndAdvPifDlg,WM_PRIVCLOSEOK,0,0L);
+ if(hwndNTPifDlg)
+ SendMessage(hwndNTPifDlg,WM_PRIVCLOSEOK,0,0L);
+ if(hwndPifDlg) {
+ hWndSv = hwndPifDlg;
+ hwndPifDlg = (HWND)NULL;
+ DragAcceptFiles(hWndSv,FALSE);
+ DestroyWindow(hWndSv);
+ }
+
+ CurrMode386 = FALSE;
+
+ if(Pif386ext && !(Pif286ext30->PfW286Flags &
+ (fALTTABdis286 | fALTESCdis286 | fCTRLESCdis286 | fALTPRTSCdis286 | fPRTSCdis286))) {
+ if(Pif386ext->PfW386Flags & fALTTABdis)
+ Pif286ext30->PfW286Flags |= fALTTABdis286;
+ if(Pif386ext->PfW386Flags & fALTESCdis)
+ Pif286ext30->PfW286Flags |= fALTESCdis286;
+ if(Pif386ext->PfW386Flags & fCTRLESCdis)
+ Pif286ext30->PfW286Flags |= fCTRLESCdis286;
+ if(Pif386ext->PfW386Flags & fALTPRTSCdis)
+ Pif286ext30->PfW286Flags |= fALTPRTSCdis286;
+ if(Pif386ext->PfW386Flags & fPRTSCdis)
+ Pif286ext30->PfW286Flags |= fPRTSCdis286;
+ }
+
+ hwndPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIF286TEMPLATE),
+ hwnd,
+ (DLGPROC)lpfnPifWnd);
+
+ if(hwndPifDlg == (HWND)NULL) {
+ hwndPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ } else {
+ DragAcceptFiles(hwndPifDlg,TRUE);
+ CheckMenuItem((hMenu = GetMenu(hwnd)),M_286,MF_BYCOMMAND + MF_CHECKED);
+ CheckMenuItem(hMenu,M_386,MF_BYCOMMAND + MF_UNCHECKED);
+ SetMainWndSize(SBUSZMAINADVNT);
+ SendDlgItemMessage(hwndPifDlg, IDI_ENAME, EM_LIMITTEXT, PIFSTARTLOCSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_EPARM, EM_LIMITTEXT, PIFPARAMSSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_EPATH, EM_LIMITTEXT, PIFDEFPATHSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_ETITLE, EM_LIMITTEXT, PIFNAMESIZE, 0L);
+ UpdatePifScreen();
+ if(showflg) {
+ ShowWindow(hwndPifDlg, SW_SHOWNORMAL);
+ if(hwndAdvPifDlg)
+ ShowWindow(hwndAdvPifDlg, SW_SHOWNORMAL);
+ if(hwndNTPifDlg)
+ ShowWindow(hwndNTPifDlg, SW_SHOWNORMAL);
+ }
+ return(TRUE);
+ }
+}
+
+
+EnableMode386(HWND hwnd,BOOL showflg)
+{
+ HMENU hMenu;
+ HWND hWndSv;
+ unsigned char buf[20];
+ unsigned char buf2[100];
+ unsigned char buf3[100];
+ unsigned char buf4[100];
+
+ if(!Pif386ext) {
+ if(!(Pif386ext = AllocInit386Ext())) {
+ Warning(NOMODE386,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ if(!PifNText) {
+ if(!(PifNText = AllocInitNTExt())) {
+ Warning(NOMODENT,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ hwndFocusMain = hwndFocusAdv = hwndFocusNT = hwndFocus = (HWND)NULL;
+ if(hwndAdvPifDlg)
+ SendMessage(hwndAdvPifDlg,WM_PRIVCLOSEOK,0,0L);
+ if(hwndNTPifDlg)
+ SendMessage(hwndNTPifDlg,WM_PRIVCLOSEOK,0,0L);
+ if(hwndPifDlg) {
+ hWndSv = hwndPifDlg;
+ hwndPifDlg = (HWND)NULL;
+ DragAcceptFiles(hWndSv,FALSE);
+ DestroyWindow(hWndSv);
+ }
+
+ CurrMode386 = TRUE;
+ ModeAdvanced = FALSE;
+
+ if(Pif286ext30 && !(Pif386ext->PfW386Flags &
+ (fALTTABdis | fALTESCdis | fCTRLESCdis | fALTPRTSCdis | fPRTSCdis))) {
+ if(Pif286ext30->PfW286Flags & fALTTABdis286)
+ Pif386ext->PfW386Flags |= fALTTABdis;
+ if(Pif286ext30->PfW286Flags & fALTESCdis286)
+ Pif386ext->PfW386Flags |= fALTESCdis;
+ if(Pif286ext30->PfW286Flags & fCTRLESCdis286)
+ Pif386ext->PfW386Flags |= fCTRLESCdis;
+ if(Pif286ext30->PfW286Flags & fALTPRTSCdis286)
+ Pif386ext->PfW386Flags |= fALTPRTSCdis;
+ if(Pif286ext30->PfW286Flags & fPRTSCdis286)
+ Pif386ext->PfW386Flags |= fPRTSCdis;
+
+ }
+
+ hwndPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIF386TEMPLATE),
+ hwnd ,
+ (DLGPROC)lpfnPifWnd);
+
+ if(hwndPifDlg == (HWND)NULL) {
+ hwndPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ } else {
+ DragAcceptFiles(hwndPifDlg,TRUE);
+ CheckMenuItem((hMenu = GetMenu(hwnd)),M_386,MF_BYCOMMAND + MF_CHECKED);
+ CheckMenuItem(hMenu,M_286,MF_BYCOMMAND + MF_UNCHECKED);
+ if(LoadString(hPifInstance, WININISECT, (LPSTR)buf, sizeof(buf)) &&
+ LoadString(hPifInstance, WININIADV, (LPSTR)buf2, sizeof(buf2)) &&
+ LoadString(hPifInstance, WININION, (LPSTR)buf3, sizeof(buf3))) {
+ GetProfileString((LPSTR)buf,(LPSTR)buf2,(LPSTR)"",(LPSTR)buf4,sizeof(buf4));
+ if(!lstrcmp(AnsiUpper((LPSTR)buf4),AnsiUpper((LPSTR)buf3)))
+ ModeAdvanced = TRUE;
+ }
+ if(ModeAdvanced) {
+ EnableWindow(GetDlgItem(hwndPifDlg,IDI_ADVANCED),FALSE);
+ AdvScrollRange = 0;
+ AdvClose = TRUE;
+ hwndAdvPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIF386ADVTEMPLT),
+ hwnd ,
+ (DLGPROC)lpfnAdvPifWnd);
+ if(hwndAdvPifDlg == (HWND)NULL) {
+ hwndAdvPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ ReEnableAdvButton();
+ return(FALSE);
+ }
+ hSysMenuAdv = GetSystemMenu(hwndAdvPifDlg,FALSE);
+ DragAcceptFiles(hwndAdvPifDlg,TRUE);
+
+ EnableWindow(GetDlgItem(hwndPifDlg,IDI_NT),FALSE);
+ NTScrollRange = 0;
+/*
+ NTClose = TRUE;
+*/
+ hwndNTPifDlg = CreateDialog(hPifInstance,
+ MAKEINTRESOURCE(ID_PIFNTTEMPLT),
+ hwnd ,
+ (DLGPROC)lpfnNTPifWnd);
+ if(hwndNTPifDlg == (HWND)NULL) {
+ hwndNTPifDlg = (HWND)NULL;
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ ReEnableAdvButton();
+ return(FALSE);
+ }
+ hSysMenuNT = GetSystemMenu(hwndNTPifDlg,FALSE);
+ DragAcceptFiles(hwndNTPifDlg,TRUE);
+ SetMainTitle();
+ } else {
+ ReEnableAdvButton();
+ }
+ SetMainWndSize(SBUSZMAINADVNT);
+ SendDlgItemMessage(hwndPifDlg, IDI_ENAME, EM_LIMITTEXT, PIFSTARTLOCSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_EPARM, EM_LIMITTEXT, PIFPARAMSSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_EPATH, EM_LIMITTEXT, PIFDEFPATHSIZE-1, 0L);
+ SendDlgItemMessage(hwndPifDlg, IDI_ETITLE, EM_LIMITTEXT, PIFNAMESIZE, 0L);
+ UpdatePifScreen();
+ if(showflg) {
+ ShowWindow(hwndPifDlg, SW_SHOWNORMAL);
+ if(hwndAdvPifDlg)
+ ShowWindow(hwndAdvPifDlg, SW_SHOWNORMAL);
+ if(hwndNTPifDlg)
+ ShowWindow(hwndNTPifDlg, SW_SHOWNORMAL);
+ }
+ return(TRUE);
+ }
+}
+
+
+DoPifCommand(HWND hwnd,WPARAM wParam,LONG lParam)
+{
+ int i, cmd;
+ unsigned char *pch;
+ unsigned char *pchBuf;
+ HWND hwnd2;
+ BOOL ChngFlg;
+
+ cmd = LOWORD(wParam);
+
+ switch (cmd) {
+ case M_NEW:
+ if (MaybeSaveFile()) {
+ InitPifStruct();
+ UpdatePifScreen();
+ UpdatePifStruct();
+ FileChanged = FALSE;
+ ofReopen.szPathName[0] = 0;
+ CurPifFile[0] = 0;
+
+ PifFile->id = 0; /* compute check sum */
+ pch = (PUCHAR)PifFile->name;
+ i = PIFSIZE;
+ while (i--)
+ PifFile->id += *pch++;
+ SendMessage(hwndPifDlg,WM_NEXTDLGCTL,
+ (WPARAM)(hwnd2 = GetDlgItem(hwndPifDlg,IDI_ENAME)),1L);
+ SetFocus(hwnd2);
+ SetMainTitle();
+ }
+ break;
+
+ case M_OPEN:
+ DoOpenPifFile((HDROP)NULL);
+ break;
+
+ case M_SAVE:
+ if (CurPifFile[0]) {
+ pchBuf = CurPifFile;
+ goto Save;
+ }
+ case M_SAVEAS:
+SaveAs:
+ if(pchBuf = PutUpDB(DTSAVE)) {
+Save:
+ HourGlass(TRUE);
+ i = SavePifFile(pchBuf, cmd);
+ if (pchBuf != CurPifFile) {
+ LocalFree((HANDLE)pchBuf);
+ }
+ HourGlass(FALSE);
+ if (i == SAVERETRY)
+ goto SaveAs;
+ }
+ SetMainTitle();
+ break;
+
+ case M_INDXHELP:
+ if(CurrMode386) {
+ if(ModeAdvanced) {
+ if(hwnd == hwndAdvPifDlg) {
+ DoHelp(IDXID_386AHELP,IDXID_386AHELP);
+ }
+ else {
+ DoHelp(IDXID_NTHELP,IDXID_NTHELP);
+ }
+ } else {
+ DoHelp(IDXID_386HELP,IDXID_386HELP);
+ }
+ } else {
+ DoHelp(IDXID_286HELP,IDXID_286HELP);
+ }
+ break;
+
+ case M_HELPHELP:
+ case M_286HELP:
+ case M_386HELP:
+ case M_386AHELP:
+ case M_NTHELP:
+ case M_SHELP:
+ DoHelp(cmd,0);
+ break;
+
+ case M_AHELP:
+ DoHelp(0,0);
+ break;
+
+ case M_ABOUT:
+ PutUpDB(DTABOUT);
+ break;
+
+ case M_286:
+ if(CurrMode386) {
+ if(SysMode386) {
+ if(Warning(IS286,MB_ICONASTERISK | MB_OKCANCEL) == IDCANCEL) {
+ break;
+ }
+ }
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ if(!DoFieldsWork(FALSE))
+ break;
+ HourGlass(TRUE);
+ if(!EnableMode286(hwnd,TRUE))
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ HourGlass(FALSE);
+ }
+ break;
+
+ case M_386:
+ if(!CurrMode386) {
+ if(!SysMode386) {
+ if(Warning(IS386,MB_ICONASTERISK | MB_OKCANCEL) == IDCANCEL) {
+ break;
+ }
+ }
+ ChngFlg = UpdatePifStruct();
+ if(ChngFlg)
+ FileChanged = ChngFlg;
+ if(!DoFieldsWork(FALSE))
+ break;
+ HourGlass(TRUE);
+ if(!EnableMode386(hwnd,TRUE))
+ SendMessage(hwnd,WM_CLOSE,0,0);
+ HourGlass(FALSE);
+ }
+ break;
+
+ case M_EXIT:
+ PostMessage(hwnd, WM_CLOSE, 0, 0L);
+ break;
+
+ }
+ return(TRUE);
+}
+
+
+long FAR PASCAL PifMainWndProc(HWND hwnd, UINT message, WPARAM wParam, LONG lParam)
+{
+ LPPOINT ppnt3;
+ LPPOINT ppnt4;
+ int width;
+ int height;
+ int tmpFOCID;
+ long size;
+ RECT rc;
+ HWND Hparsav;
+
+ switch (message) {
+
+
+ case WM_SETFOCUS:
+ if(hwndFocusMain) {
+ /*
+ * How can hwndFocusMain != 0 but hwndPifDlg == 0, I hear you
+ * ask. Well it's due to a message race. Windows has sent the
+ * WM_INITDIALOG to hwndPifDlg which sets hwndFocusMain, but
+ * the CreateDialog call has not actually returned yet so
+ * hwndPifDlg is still 0.
+ *
+ */
+ if(hwndPifDlg)
+ SendMessage(hwndPifDlg,WM_NEXTDLGCTL,(WPARAM)hwndFocusMain,1L);
+ SetFocus(hwndFocusMain);
+ }
+ return(TRUE);
+
+ case WM_PAINT:
+ PaintStatus(hwnd);
+ goto DoDef;
+ break;
+
+ case WM_MENUSELECT:
+ tmpFOCID = FocusIDMainMenu;
+ if((HIWORD(wParam) == 0xFFFF) && (lParam == (LPARAM)NULL)) { // was menu closed?
+ SetStatusText(hwnd,FocusIDMain,TRUE);
+ tmpFOCID = FocusIDMainMenu = 0;
+ } else if(lParam == 0) { /* ignore these */
+ } else if(HIWORD(wParam) & MF_POPUP) {
+ if((HMENU)lParam == hSysMenuMain)
+ FocusIDMainMenu = M_SYSMENUMAIN;
+ else if((HMENU)lParam == hFileMenu)
+ FocusIDMainMenu = M_FILEMENU;
+ else if((HMENU)lParam == hModeMenu)
+ FocusIDMainMenu = M_MODEMENU;
+ else if((HMENU)lParam == hHelpMenu)
+ FocusIDMainMenu = M_HELPMENU;
+ } else {
+ if(LOWORD(wParam) != 0) /* separators have wparam of 0 */
+ FocusIDMainMenu = LOWORD(wParam);
+ }
+ if(tmpFOCID != FocusIDMainMenu)
+ SetStatusText(hwnd,FocusIDMainMenu,TRUE);
+ goto DoDef;
+ break;
+
+ case WM_QUERYENDSESSION:
+ if(DoingMsg) {
+ Hparsav = hParentWnd;
+ hParentWnd = 0;
+ Warning(errNOEND,MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
+ hParentWnd = Hparsav;
+ return(FALSE);
+ }
+ case WM_CLOSE:
+ if (MaybeSaveFile()) {
+ if (message == WM_CLOSE) {
+ if(hwndHelpDlgParent) {
+ WinHelp(hwndHelpDlgParent,(LPSTR)PIFHELPFILENAME,HELP_QUIT,(DWORD)NULL);
+ hwndHelpDlgParent = (HWND)NULL;
+ }
+ DragAcceptFiles(hwnd,FALSE);
+ DestroyWindow(hwnd);
+ }
+ return(TRUE);
+ }
+ return(FALSE);
+ break;
+
+ case WM_COMMAND:
+ SetStatusText(hwnd,FocusIDMain,TRUE);
+ tmpFOCID = FocusIDMainMenu = 0;
+ DoPifCommand(hwnd,wParam,lParam);
+ break;
+
+ case WM_VSCROLL:
+ if(MainScrollRange)
+ MainScroll(hwnd, (int)(LOWORD(wParam)), (int)(HIWORD(wParam)), 0, 0);
+ break;
+
+ case WM_SYSCOLORCHANGE:
+ InvalidateStatusBar(hwnd);
+ break;
+
+ case WM_SIZE:
+ GetClientRect(hwnd, &rc);
+ rc.top = rc.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ if(rc.top < StatRecSizeMain.top) {
+ /* Window SHRANK, need to invalidate current status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&rc,FALSE);
+ } else {
+ /* Window GREW, need to invalidate prev status rect */
+ InvalidateRect(hwnd, (CONST RECT *)&StatRecSizeMain,TRUE);
+ }
+ switch (wParam) {
+ case SIZEFULLSCREEN:
+ case SIZENORMAL:
+ MainWndSize = wParam;
+ SetMainWndSize(SBUMAIN);
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case WM_GETMINMAXINFO:
+ if(!hwndPifDlg)
+ goto DoDef;
+ GetClientRect(hwnd, &StatRecSizeMain);
+ StatRecSizeMain.top = StatRecSizeMain.bottom - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ SendMessage(hwndPifDlg,WM_PRIVGETSIZE,1,(LONG)(long FAR *)&size);
+ width = LOWORD(size) +
+ (2 * GetSystemMetrics(SM_CXFRAME)) +
+ GetSystemMetrics(SM_CXVSCROLL) +
+ GetSystemMetrics(SM_CXBORDER);
+ height = HIWORD(size) +
+ GetSystemMetrics(SM_CYCAPTION) +
+ GetSystemMetrics(SM_CYMENU) +
+ (2 * GetSystemMetrics(SM_CYFRAME));
+ ppnt3 = ppnt4 = (LPPOINT)lParam;
+ ppnt3 += 3;
+ ppnt4 += 4;
+ if(height > (ppnt4->y - (4 * SysCharHeight)))
+ height = ppnt4->y - (4 * SysCharHeight);
+ ppnt3->y = height;
+ ppnt3->x = width;
+ break;
+
+ case WM_DESTROY:
+ if(HotKyFnt) {
+ DeleteObject((HGDIOBJ)HotKyFnt);
+ HotKyFnt = (HFONT)NULL;
+ }
+ if(StatusPntData.hFontStatus) {
+ DeleteObject(StatusPntData.hFontStatus);
+ StatusPntData.hFontStatus = (HGDIOBJ)NULL;
+ }
+ PostQuitMessage(0);
+ break;
+
+ case WM_DROPFILES:
+ DoOpenPifFile((HDROP)wParam);
+ break;
+
+/* this must be just before the default section */
+ case WM_SYSCOMMAND:
+DoDef:
+ default:
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ }
+ return(TRUE);
+
+}
+
+
+AdjustFocusCtrl(HWND hwnd)
+{
+ RECT rc;
+ RECT rc2;
+ POINT cTLpt;
+ POINT cLRpt;
+ int i;
+ int tmpFOCID;
+ HWND tmpFocWnd;
+
+ if(hwnd == hwndAdvPifDlg) {
+ if(!(tmpFocWnd = hwndFocusAdv))
+ return(TRUE);
+ } else if(hwnd == hwndNTPifDlg) {
+ if(!(tmpFocWnd = hwndFocusNT))
+ return(TRUE);
+ } else {
+ if(!(tmpFocWnd = hwndFocusMain))
+ return(TRUE);
+ }
+ for(i = 0; i < 20; i++) {
+ if((hwnd == hwndAdvPifDlg) || (hwnd == hwndNTPifDlg)) {
+ GetWindowRect(tmpFocWnd,(LPRECT)&rc2);
+ GetWindowRect(hwnd,(LPRECT)&rc);
+ rc.bottom -= GetSystemMetrics(SM_CYFRAME) + (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ rc.top += GetSystemMetrics(SM_CYFRAME) +
+ GetSystemMetrics(SM_CYCAPTION);
+ } else {
+ GetClientRect(hMainwnd,(LPRECT)&rc);
+ cTLpt.x = rc.left;
+ cTLpt.y = rc.top;
+ cLRpt.x = rc.right;
+ cLRpt.y = rc.bottom;
+ ClientToScreen(hMainwnd,(LPPOINT)&cTLpt);
+ ClientToScreen(hMainwnd,(LPPOINT)&cLRpt);
+ rc.left = cTLpt.x;
+ rc.top = cTLpt.y;
+ rc.right = cLRpt.x;
+ rc.bottom = cLRpt.y - (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ GetWindowRect(tmpFocWnd,(LPRECT)&rc2);
+ }
+ if((rc2.top >= rc.top) && (rc2.bottom <= rc.bottom)) {
+ if(hwnd == hwndAdvPifDlg) {
+ if(tmpFocWnd == hwndFocusAdv)
+ return(TRUE);
+ hwndFocus = hwndFocusAdv = tmpFocWnd;
+ tmpFOCID = FocusIDAdv;
+ FocusID = FocusIDAdv = GetDlgCtrlID(hwndFocusAdv);
+ if(tmpFOCID != FocusIDAdv)
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ } else if(hwnd == hwndNTPifDlg) {
+ if(tmpFocWnd == hwndFocusNT)
+ return(TRUE);
+ hwndFocus = hwndFocusNT = tmpFocWnd;
+ tmpFOCID = FocusIDNT;
+ FocusID = FocusIDNT = GetDlgCtrlID(hwndFocusNT);
+ if(tmpFOCID != FocusIDNT)
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ } else {
+ if(tmpFocWnd == hwndFocusMain)
+ return(TRUE);
+ hwndFocus = hwndFocusMain = tmpFocWnd;
+ tmpFOCID = FocusIDMain;
+ FocusID = FocusIDMain = GetDlgCtrlID(hwndFocusMain);
+ if(tmpFOCID != FocusIDMain)
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ }
+ SendMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)tmpFocWnd,1L);
+ SetFocus(tmpFocWnd);
+ return(TRUE);
+ } else if (rc2.top < rc.top) {
+ tmpFocWnd = GetNextDlgTabItem(hwnd,tmpFocWnd,0);
+ } else {
+ tmpFocWnd = GetNextDlgTabItem(hwnd,tmpFocWnd,1);
+ }
+ }
+ if(hwnd == hwndAdvPifDlg) {
+ if(tmpFocWnd == hwndFocusAdv)
+ return(TRUE);
+ hwndFocus = hwndFocusAdv = tmpFocWnd;
+ tmpFOCID = FocusIDAdv;
+ FocusID = FocusIDAdv = GetDlgCtrlID(hwndFocusAdv);
+ if(tmpFOCID != FocusIDAdv)
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ } else if(hwnd == hwndNTPifDlg) {
+ if(tmpFocWnd == hwndFocusNT)
+ return(TRUE);
+ hwndFocus = hwndFocusNT = tmpFocWnd;
+ tmpFOCID = FocusIDNT;
+ FocusID = FocusIDNT = GetDlgCtrlID(hwndFocusNT);
+ if(tmpFOCID != FocusIDNT)
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ } else {
+ if(tmpFocWnd == hwndFocusMain)
+ return(TRUE);
+ hwndFocus = hwndFocusMain = tmpFocWnd;
+ tmpFOCID = FocusIDMain;
+ FocusID = FocusIDMain = GetDlgCtrlID(hwndFocusMain);
+ if(tmpFOCID != FocusIDMain)
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ }
+ SendMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)tmpFocWnd,1L);
+ SetFocus(tmpFocWnd);
+ return(TRUE);
+}
+
+
+MainScrollTrack(HWND hwnd,int cmd,int mindistance)
+{
+ int *ScrollLineSz;
+
+ if(hwnd == hwndAdvPifDlg) {
+ ScrollLineSz = &AdvScrollLineSz;
+ } else if(hwnd == hwndNTPifDlg) {
+ ScrollLineSz = &NTScrollLineSz;
+ } else {
+ ScrollLineSz = &MainScrollLineSz;
+ }
+
+ if(mindistance <= *ScrollLineSz) {
+ MainScroll(hwnd,cmd,0,0,0);
+ } else {
+ MainScroll(hwnd,cmd,0,
+ (mindistance + (2* *ScrollLineSz) - 1) / *ScrollLineSz,
+ 0);
+ }
+ return(TRUE);
+}
+
+MainScroll(HWND hwnd, int cmd, int pos, int multiln, int callflag)
+{
+
+ int oldScrollPos;
+ int newScrollPos;
+ int *ScrollRange;
+ int *ScrollLineSz;
+ int *WndLines;
+ int *MaxNeg;
+ RECT rc2;
+
+ if(hwnd == hwndAdvPifDlg) {
+ ScrollRange = &AdvScrollRange;
+ ScrollLineSz = &AdvScrollLineSz;
+ WndLines = &AdvWndLines;
+ MaxNeg = &MaxAdvNeg;
+ } else if(hwnd == hwndNTPifDlg) {
+ ScrollRange = &NTScrollRange;
+ ScrollLineSz = &NTScrollLineSz;
+ WndLines = &NTWndLines;
+ MaxNeg = &MaxNTNeg;
+ } else {
+ ScrollRange = &MainScrollRange;
+ ScrollLineSz = &MainScrollLineSz;
+ WndLines = &MainWndLines;
+ MaxNeg = &MaxMainNeg;
+ }
+
+ newScrollPos = oldScrollPos = GetScrollPos(hwnd,SB_VERT);
+
+ switch (cmd) {
+ case SB_LINEUP:
+ if (oldScrollPos)
+ if(multiln)
+ newScrollPos -= min(oldScrollPos,multiln);
+ else
+ newScrollPos--;
+ break;
+
+ case SB_LINEDOWN:
+ if (oldScrollPos < *ScrollRange)
+ if(multiln)
+ newScrollPos += min((*ScrollRange -
+ oldScrollPos),multiln);
+ else
+ newScrollPos++;
+ break;
+
+ case SB_PAGEUP:
+ newScrollPos -= *WndLines;
+ if ( newScrollPos < 0)
+ newScrollPos = 0;
+ break;
+
+ case SB_PAGEDOWN:
+ newScrollPos += *WndLines;
+ if (newScrollPos > *ScrollRange)
+ newScrollPos = *ScrollRange;
+ break;
+
+ case SB_THUMBPOSITION:
+ SetScrollPos(hwnd, SB_VERT, pos, TRUE);
+ return(TRUE);
+
+ case SB_THUMBTRACK:
+ newScrollPos = pos;
+ break;
+
+ case SB_TOP:
+ if (!callflag && GetKeyState(VK_CONTROL) >= 0)
+ return(TRUE); /* top of data must be Ctrl+Home */
+ newScrollPos = 0;
+ break;
+
+ case SB_BOTTOM:
+ if (!callflag && GetKeyState(VK_CONTROL) >= 0)
+ return(TRUE); /* end of data must be Ctrl+End */
+ newScrollPos = *ScrollRange;
+ break;
+ }
+ if (newScrollPos != oldScrollPos) {
+ if (cmd != SB_THUMBTRACK)
+ SetScrollPos(hwnd, SB_VERT, newScrollPos, TRUE);
+ newScrollPos = min((newScrollPos * *ScrollLineSz),*MaxNeg);
+ oldScrollPos = min((oldScrollPos * *ScrollLineSz),*MaxNeg);
+ GetClientRect(hwnd,(LPRECT)&rc2);
+ if((hwnd == hwndAdvPifDlg) || (hwnd == hwndNTPifDlg)) {
+ ScrollWindow(hwnd,
+ 0,
+ oldScrollPos-newScrollPos,
+ (CONST RECT *)NULL,
+ (CONST RECT *)NULL);
+ UpdateWindow(hwnd);
+ AdjustFocusCtrl(hwnd);
+ } else {
+ SetWindowPos(hwndPifDlg,
+ (HWND)NULL,
+ 0,
+ -newScrollPos,
+ rc2.right - rc2.left,
+ rc2.bottom - rc2.top + newScrollPos -
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2),
+ SWP_NOZORDER | SWP_NOACTIVATE);
+ UpdateWindow(hwndPifDlg);
+ AdjustFocusCtrl(hwndPifDlg);
+ }
+ InvalidateStatusBar(hwnd);
+ }
+ return(TRUE);
+}
+
+
+DoHkeyCaret(HWND hwnd)
+{
+ HDC hdc;
+ HFONT hfont;
+ SIZE size;
+
+ if(!(hdc = GetDC(hwnd))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ if(HotKyFnt)
+ hfont = (HFONT)SelectObject(hdc,(HGDIOBJ)HotKyFnt);
+ GetTextExtentPoint(hdc,(LPSTR)CurrHotKeyTxt,CurrHotKeyTxtLen, &size);
+ SetCaretPos(size.cx+4,1);
+ if(HotKyFnt && hfont)
+ SelectObject(hdc,(HGDIOBJ)hfont);
+ ReleaseDC(hwnd,hdc);
+ return(TRUE);
+}
+
+
+/*
+ *
+ * This is the Windows Proc for the private Hot Key Control in
+ * the WIN386 dialog box
+ *
+ */
+long FAR PASCAL PifHotKyWndProc(HWND hwnd, UINT message, WPARAM wParam, LONG lParam)
+{
+ PAINTSTRUCT ps;
+ HFONT hfont;
+ DWORD txtcolor;
+
+ switch (message) {
+
+ case WM_SETFOCUS:
+ if(HotKyFntHgt)
+ CreateCaret(hwnd,NULL,0,HotKyFntHgt);
+ else
+ CreateCaret(hwnd,NULL,0,SysCharHeight);
+ DoHkeyCaret(hwnd);
+ ShowCaret(hwnd);
+ break;
+
+ case WM_KILLFOCUS:
+/* ChangeHotKey(); */
+ DestroyCaret();
+ break;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ switch (wParam) {
+ case VK_BACK:
+ if(GetKeyState(VK_SHIFT) & 0x8000) {
+ InMemHotKeyScan = 0;
+ InMemHotKeyShVal = 0;
+ InMemHotKeyShMsk = 0;
+ NewHotKey = TRUE;
+ UndoAdvClose();
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ if(!LoadString(hPifInstance,
+ NONE,
+ (LPSTR)CurrHotKeyTxt,
+ sizeof(CurrHotKeyTxt))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ } else {
+ CompleteKey = FALSE;
+ EditHotKey = TRUE;
+ NewHotKey = TRUE;
+ CurrHotKeyTxt[0] = '\0';
+ }
+ SetHotKeyLen();
+ InvalidateRect(hwnd,(CONST RECT *)NULL,TRUE);
+ DoHkeyCaret(hwnd);
+ break;
+
+ case VK_RETURN:
+ if(!(GetKeyState(VK_SHIFT) & 0x8000) &&
+ !(GetKeyState(VK_MENU) & 0x8000) &&
+ !(GetKeyState(VK_CONTROL) & 0x8000)) {
+ PostMessage(hwndAdvPifDlg,WM_COMMAND,IDOK,0L);
+ } else {
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ SetHotKeyTextFromInMem();
+ DoHkeyCaret(hwnd);
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ }
+ break;
+
+ case VK_TAB:
+ if(GetKeyState(VK_MENU) & 0x8000) {
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ SetHotKeyTextFromInMem();
+ DoHkeyCaret(hwnd);
+ } else {
+ ChangeHotKey();
+ DoHkeyCaret(hwnd);
+ }
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ break;
+
+ case VK_CONTROL: /* Add modifier */
+ case VK_MENU:
+ if(!EditHotKey) {
+StartHotKey:
+ CompleteKey = FALSE;
+ EditHotKey = TRUE;
+ CurrHotKeyTxt[0] = '\0';
+ SetHotKeyLen();
+ }
+SetHotKey:
+ SetHotKeyState(wParam,lParam);
+ InvalidateRect(hwnd,(CONST RECT *)NULL,TRUE);
+ DoHkeyCaret(hwnd);
+ UndoAdvClose();
+ break;
+
+ case VK_SHIFT:
+ if(EditHotKey && !CompleteKey && (CurrHotKeyTxtLen != 0))
+ goto SetHotKey;
+ break;
+
+ case VK_ESCAPE:
+ if((GetKeyState(VK_MENU) & 0x8000) ||
+ (GetKeyState(VK_CONTROL) & 0x8000)) {
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ SetHotKeyTextFromInMem();
+ DoHkeyCaret(hwnd);
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ } else {
+ if(GetKeyState(VK_SHIFT) & 0x8000)
+ MessageBeep(0);
+ else {
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ PostMessage(hwndAdvPifDlg,WM_COMMAND,IDCANCEL,0L);
+ }
+ }
+ break;
+
+ case VK_SPACE:
+ case VK_MULTIPLY:
+ CompleteKey = FALSE;
+ EditHotKey = FALSE;
+ NewHotKey = FALSE;
+ SetHotKeyTextFromInMem();
+ DoHkeyCaret(hwnd);
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ break;
+
+ default: /* Set Key */
+ if(!EditHotKey || CompleteKey)
+ goto StartHotKey;
+ goto SetHotKey;
+ break;
+ }
+ break;
+
+ case WM_SYSCHAR:
+ case WM_CHAR:
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ switch (wParam) {
+ case VK_SPACE:
+ case VK_MULTIPLY:
+ case VK_RETURN:
+ case VK_ESCAPE:
+ case VK_TAB:
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case WM_LBUTTONDOWN:
+ SetFocus(hwnd);
+ break;
+
+ case WM_CREATE:
+ hwndPrivControl = hwnd;
+ SetHotKeyTextFromPIF();
+ break;
+
+ case WM_PAINT:
+ if(!BeginPaint(hwnd, (LPPAINTSTRUCT)&ps)) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ break;
+ }
+ if(HotKyFnt)
+ hfont = (HFONT)SelectObject(ps.hdc,(HGDIOBJ)HotKyFnt);
+ txtcolor = GetSysColor(COLOR_WINDOWTEXT);
+ SetTextColor(ps.hdc,txtcolor);
+ txtcolor = GetSysColor(COLOR_WINDOW);
+ SetBkColor(ps.hdc,txtcolor);
+ TextOut(ps.hdc, 4, 1, (LPSTR)CurrHotKeyTxt, sizeof(CurrHotKeyTxt));
+ if(HotKyFnt && hfont)
+ SelectObject(ps.hdc,(HGDIOBJ)hfont);
+ EndPaint(hwnd, (CONST PAINTSTRUCT *)&ps);
+ break;
+
+ case WM_DESTROY:
+ hwndPrivControl = (HWND)NULL;
+ default:
+ return(DefWindowProc(hwnd, message, wParam, lParam));
+ }
+ return(TRUE);
+}
+
+
+SetHotKeyState(WPARAM keyid,LONG lParam)
+{
+ unsigned char *cptr;
+ BOOL FirstEl = FALSE;
+
+ cptr = CurrHotKeyTxt;
+
+ if(lParam & 0x01000000L)
+ TmpHotKeyVal = 1;
+ else
+ TmpHotKeyVal = 0;
+
+ if(GetKeyState(VK_MENU) & 0x8000) {
+ cptr += GetKeyNameText(ALTLPARAM,(LPSTR)cptr,
+ sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ FirstEl = TRUE;
+ TmpHotKeyShVal |= 0x0008;
+ } else {
+ TmpHotKeyShVal &= ~0x0008;
+ }
+ if(GetKeyState(VK_CONTROL) & 0x8000) {
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+ cptr += GetKeyNameText(CTRLLPARAM,(LPSTR)cptr,
+ sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ TmpHotKeyShVal |= 0x0004;
+ } else {
+ TmpHotKeyShVal &= ~0x0004;
+ }
+ if(GetKeyState(VK_SHIFT) & 0x8000) {
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+ cptr += GetKeyNameText(SHIFTLPARAM,(LPSTR)cptr,
+ sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ TmpHotKeyShVal |= 0x0003;
+ } else {
+ TmpHotKeyShVal &= ~0x0003;
+ }
+
+ if((keyid != VK_MENU) && (keyid != VK_SHIFT) && (keyid != VK_CONTROL)) {
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+
+ if((GetKeyNameText(lParam,(LPSTR)cptr,
+ sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt)))
+ && (TmpHotKeyShVal & 0x000C)) {
+ TmpHotKeyScan = HIWORD(lParam) & 0x00FF;
+ CompleteKey = TRUE;
+ }
+ }
+
+ SetHotKeyLen();
+ return(TRUE);
+}
+
+
+ChangeHotKey()
+{
+
+ if(!ChangeHkey) {
+ ChangeHkey = TRUE;
+ if(EditHotKey) {
+ if(CompleteKey) {
+ InMemHotKeyScan = TmpHotKeyScan;
+ InMemHotKeyShVal = TmpHotKeyShVal;
+ InMemHotKeyShMsk = TmpHotKeyShMsk;
+ InMemHotKeyVal = TmpHotKeyVal;
+ NewHotKey = TRUE;
+ } else if (CurrHotKeyTxtLen == 0) {
+ SetHotKeyTextFromPIF();
+ NewHotKey = FALSE;
+ } else {
+ Warning(BADHK,MB_ICONEXCLAMATION | MB_OK);
+ SetHotKeyTextFromPIF();
+ NewHotKey = FALSE;
+ }
+ EditHotKey = FALSE;
+ CompleteKey = FALSE;
+ }
+ ChangeHkey = FALSE;
+ }
+ return(TRUE);
+}
+
+BOOL UpdateHotKeyStruc(void)
+{
+ ChangeHotKey();
+ if(((UINT)Pif386ext->PfHotKeyScan != InMemHotKeyScan) ||
+ ((UINT)Pif386ext->PfHotKeyShVal != InMemHotKeyShVal) ||
+ ((UINT)Pif386ext->PfHotKeyShMsk != InMemHotKeyShMsk) ||
+ (Pif386ext->PfHotKeyVal != InMemHotKeyVal)) {
+
+ Pif386ext->PfHotKeyScan = InMemHotKeyScan;
+ Pif386ext->PfHotKeyShVal = InMemHotKeyShVal;
+ Pif386ext->PfHotKeyShMsk = InMemHotKeyShMsk;
+ Pif386ext->PfHotKeyVal = InMemHotKeyVal;
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+}
+
+
+SetHotKeyTextFromInMem(void)
+{
+ unsigned char *cptr;
+ BOOL FirstEl = FALSE;
+
+ cptr = CurrHotKeyTxt;
+
+ if((InMemHotKeyScan == 0) &&
+ (InMemHotKeyShVal == 0) &&
+ (InMemHotKeyShMsk == 0)) {
+ if(!LoadString(hPifInstance, NONE, (LPSTR)CurrHotKeyTxt, sizeof(CurrHotKeyTxt))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+ } else {
+ if(InMemHotKeyShVal & 0x0008) {
+ cptr += GetKeyNameText(ALTLPARAM,(LPSTR)cptr
+ ,sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ FirstEl = TRUE;
+ }
+ if(InMemHotKeyShVal & 0x0004) {
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+ cptr += GetKeyNameText(CTRLLPARAM,(LPSTR)cptr
+ ,sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ }
+ if(InMemHotKeyShVal & 0x0003) {
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+ cptr += GetKeyNameText(SHIFTLPARAM,(LPSTR)cptr
+ ,sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt));
+ }
+ if(FirstEl) {
+ *cptr++ = KeySepChr;
+ } else {
+ FirstEl = TRUE;
+ }
+
+ if(GetKeyNameText(InMemHotKeyVal ? ((DWORD)InMemHotKeyScan << 16L | 0x01000000L) : ((DWORD)InMemHotKeyScan << 16L),
+ (LPSTR)cptr,
+ sizeof(CurrHotKeyTxt)-(cptr-CurrHotKeyTxt)) == 0 ||
+ (!(InMemHotKeyShVal & 0x000C)) ||
+ (InMemHotKeyShMsk != 0x000F)) {
+
+ if(CurrMode386 && hwndAdvPifDlg)
+ Warning(BADHK,MB_ICONEXCLAMATION | MB_OK);
+ InMemHotKeyScan = 0;
+ InMemHotKeyShVal = 0;
+ InMemHotKeyShMsk = 0;
+ InMemHotKeyVal = 0;
+ if(!LoadString(hPifInstance, NONE, (LPSTR)CurrHotKeyTxt, sizeof(CurrHotKeyTxt))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ }
+
+ }
+ }
+ SetHotKeyLen();
+ if(CurrMode386 && hwndAdvPifDlg)
+ InvalidateRect(GetDlgItem(hwndAdvPifDlg, IDI_HOTKEY),
+ (CONST RECT *)NULL,
+ TRUE);
+ return(TRUE);
+}
+
+
+SetHotKeyTextFromPIF()
+{
+ if(!Pif386ext)
+ return(FALSE);
+ InMemHotKeyScan = Pif386ext->PfHotKeyScan;
+ InMemHotKeyShVal = Pif386ext->PfHotKeyShVal;
+ InMemHotKeyShMsk = Pif386ext->PfHotKeyShMsk;
+ InMemHotKeyVal = Pif386ext->PfHotKeyVal;
+ SetHotKeyTextFromInMem();
+ return(TRUE);
+}
+
+SetHotKeyLen()
+{
+ int i;
+ BOOL dospc;
+
+ for(dospc = FALSE, i = 0; i < sizeof(CurrHotKeyTxt); i++) {
+ if(dospc) {
+ CurrHotKeyTxt[i] = ' ';
+ } else {
+ if(!CurrHotKeyTxt[i]){
+ CurrHotKeyTxt[i] = ' ';
+ CurrHotKeyTxtLen = i;
+ dospc = TRUE;
+ }
+ }
+ }
+ return(TRUE);
+}
+
+Disable386Advanced(HWND hAdvwnd, HWND hNTwnd)
+{
+
+ if(hAdvwnd) {
+ if(CurrMode386) {
+ if(UpdatePif386Struc())
+ FileChanged = TRUE;
+ if(UpdatePifNTStruc())
+ FileChanged = TRUE;
+ }
+ if(!DoFieldsWorkAdv(FALSE))
+ return(FALSE);
+ if(!DoFieldsWorkNT(FALSE))
+ return(FALSE);
+ SendMessage(hNTwnd,WM_PRIVCLOSEOK,0,0L);
+ }
+ ModeAdvanced = FALSE;
+ ReEnableAdvButton();
+ return(TRUE);
+}
+
+/*
+ * routine added so that pifedit can hack in normal menu functionality.
+ * Want Alt+Mnemonic to work like normal windows, even though pifedit is
+ * really a dialog box. Look for Alt+Mnemonic before letting message go
+ * to the dialog manager.
+ * 08-Jun-1987. davidhab.
+ */
+BOOL PifMenuMnemonic(LPMSG lpmsg)
+{
+ unsigned char chMenu;
+ HWND hwAct;
+
+ if (lpmsg->message == WM_SYSCHAR && GetActiveWindow() == hMainwnd) {
+ chMenu = (unsigned char)AnsiUpper((LPSTR)(DWORD)(unsigned char)lpmsg->wParam);
+ if ((chMenu == MenuMnemonic1) || (chMenu == MenuMnemonic2) ||
+ (chMenu == MenuMnemonic3)) {
+ DefWindowProc(hwndPifDlg, lpmsg->message, lpmsg->wParam, lpmsg->lParam);
+ return(TRUE);
+ }
+ /*
+ *
+ * The following allows keyboard access to the main window scroll bar
+ *
+ */
+ } else if ((lpmsg->message == WM_KEYDOWN) &&
+ (((hwAct = GetActiveWindow()) == hMainwnd) ||
+ (hwndAdvPifDlg && (hwAct == hwndAdvPifDlg)))) {
+ switch (lpmsg->wParam) {
+ case VK_HOME:
+ PostMessage(hwAct, WM_VSCROLL, SB_TOP, 0L);
+ break;
+
+ case VK_END:
+ PostMessage(hwAct, WM_VSCROLL, SB_BOTTOM, 0L);
+ break;
+
+ case VK_NEXT:
+ PostMessage(hwAct, WM_VSCROLL, SB_PAGEDOWN, 0L);
+ break;
+
+ case VK_PRIOR:
+ PostMessage(hwAct, WM_VSCROLL, SB_PAGEUP, 0L);
+ break;
+
+ default:
+ break;
+ }
+ return(FALSE);
+ }
+ return(FALSE);
+}
+
+
+FilterPrivateMsg(HWND hwnd, unsigned message, WPARAM wParam, LONG lParam)
+{
+ switch (message) {
+ case WM_KEYDOWN:
+ case WM_CHAR:
+ case WM_KEYUP:
+ case WM_SYSKEYDOWN:
+ case WM_SYSCHAR:
+ case WM_SYSKEYUP:
+ switch (wParam) {
+ case VK_TAB:
+ return(TRUE);
+
+ case VK_SPACE:
+ case VK_RETURN:
+ case VK_ESCAPE:
+ case VK_MULTIPLY:
+ if(GetKeyState(VK_MENU) & 0x8000)
+ return(TRUE);
+ else
+ return(FALSE);
+
+ default:
+ return(FALSE);
+ }
+ break;
+
+ default:
+ return(TRUE);
+ }
+}
+
+
+BOOL InitPifStuff(HINSTANCE hPrevInstance)
+{
+ unsigned char buf[20];
+ PWNDCLASS pClass;
+ HDC hIC;
+ HFONT hfont;
+ TEXTMETRIC Metrics;
+ HANDLE mhand;
+ HDC hdcScreen;
+ char szHelv[] = "MS Sans Serif"; // don't use Helv, mapping problems
+ TEXTMETRIC tm;
+ int dxText;
+
+ if (lpfnRegisterPenApp = (LPFNREGISTERPENAPP)GetProcAddress((HMODULE)(GetSystemMetrics(SM_PENWINDOWS)), "RegisterPenApp")) {
+ (*lpfnRegisterPenApp)((WORD)1, TRUE); /* be Pen-Enhanced */
+ }
+
+ if (!hPrevInstance) {
+
+ StatusPntData.dyBorder = GetSystemMetrics(SM_CYBORDER);
+ StatusPntData.dyBorderx2 = StatusPntData.dyBorder * 2;
+ StatusPntData.dyBorderx3 = StatusPntData.dyBorder * 3;
+
+ if(!(hdcScreen = GetDC(NULL)))
+ goto NoMem;
+
+ StatusPntData.Fntheight = MulDiv(-10, GetDeviceCaps(hdcScreen, LOGPIXELSY), 72);
+
+ dxText = LOWORD(GetTextExtent(hdcScreen, "M", 1));
+
+ if(!(StatusPntData.hFontStatus = (HGDIOBJ)CreateFont(StatusPntData.Fntheight, 0, 0, 0, 400, 0, 0, 0,
+ ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, (LPCTSTR)szHelv)))
+ goto NoMem;
+ mhand = SelectObject(hdcScreen, StatusPntData.hFontStatus);
+
+ GetTextMetrics(hdcScreen, &tm);
+
+ SelectObject(hdcScreen, mhand);
+ StatusPntData.dyStatus = tm.tmHeight + tm.tmExternalLeading + 7 * StatusPntData.dyBorder;
+ ReleaseDC(NULL, hdcScreen);
+
+ } else {
+ if(!GetInstanceData(hPrevInstance,(NPSTR)&StatusPntData,sizeof(StatusPntData))) {
+ StatusPntData.hFontStatus = (HGDIOBJ)NULL;
+ goto NoMem;
+ }
+ if(!(StatusPntData.hFontStatus = (HGDIOBJ)CreateFont(StatusPntData.Fntheight, 0, 0, 0, 400, 0, 0, 0,
+ ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, szHelv)))
+ goto NoMem;
+ }
+
+ if(!(lpfnPifWnd = (FARPROC) MakeProcInstance(PifWndProc, hPifInstance))) {
+NoMem:
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+
+ if(!(lpfnAdvPifWnd = (FARPROC) MakeProcInstance(PifAdvWndProc, hPifInstance)))
+ goto NoMem;
+
+ if(!(lpfnNTPifWnd = (FARPROC) MakeProcInstance(PifNTWndProc, hPifInstance)))
+ goto NoMem;
+
+ if(!LoadString(hPifInstance, errTitle, (LPSTR)rgchTitle, sizeof(rgchTitle)))
+ goto NoMem;
+
+ if(!(hAccel = LoadAccelerators(hPifInstance, (LPSTR)"pifaccels")))
+ goto NoMem;
+
+ if(!LoadString(hPifInstance, MENUMNEMONIC1, (LPSTR)buf, sizeof(buf)))
+ goto NoMem;
+ MenuMnemonic1 = buf[0];
+
+ if(!LoadString(hPifInstance, MENUMNEMONIC2, (LPSTR)buf, sizeof(buf)))
+ goto NoMem;
+ MenuMnemonic2 = buf[0];
+
+ if(!LoadString(hPifInstance, MENUMNEMONIC3, (LPSTR)buf, sizeof(buf)))
+ goto NoMem;
+ MenuMnemonic3 = buf[0];
+
+ if(!LoadString(hPifInstance, KEYSEPCHAR, (LPSTR)buf, sizeof(buf)))
+ goto NoMem;
+ KeySepChr = buf[0];
+
+ if(!(hArrowCurs = LoadCursor((HANDLE)NULL,(LPSTR)IDC_ARROW)))
+ goto NoMem;
+ if(!(hWaitCurs = LoadCursor((HANDLE)NULL,(LPSTR)IDC_WAIT)))
+ goto NoMem;
+
+ bMouse = GetSystemMetrics(SM_MOUSEPRESENT);
+ hIC = CreateIC((LPSTR)"DISPLAY", (LPSTR)NULL, (LPSTR)NULL, (LPDEVMODE)NULL);
+ if (!hIC)
+ return(FALSE);
+ /* Setup the fonts */
+ GetTextMetrics(hIC, (LPTEXTMETRIC)(&Metrics)); /* find out what kind of font it really is */
+ SysCharHeight = Metrics.tmHeight; /* the height */
+ SysCharWidth = Metrics.tmAveCharWidth; /* the average width */
+
+ SysFixedFont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
+ SelectObject(hIC,(HGDIOBJ)SysFixedFont);
+ GetTextMetrics(hIC, (LPTEXTMETRIC)(&Metrics));
+ SysFixedHeight = Metrics.tmHeight;
+ SysFixedWidth = Metrics.tmAveCharWidth;
+ if(Metrics.tmPitchAndFamily & 1) {
+ SysFixedFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
+ SelectObject(hIC,(HGDIOBJ)SysFixedFont);
+ GetTextMetrics(hIC, (LPTEXTMETRIC)(&Metrics)); /* find out what kind of font it really is */
+ SysFixedHeight = Metrics.tmHeight; /* the height */
+ SysFixedWidth = Metrics.tmAveCharWidth; /* the average width */
+ }
+
+ HotKyFnt = CreateFont(8, /* lfHeight */
+ 0, /* lfWidth */
+ 0, /* lfEscapement */
+ 0, /* lfOrientation*/
+ FW_BOLD, /* lfWeight */
+ FALSE, /* lfItalic */
+ FALSE, /* lfUnderline */
+ FALSE, /* lfStrikeout */
+ ANSI_CHARSET, /* lfCharset */
+ OUT_DEFAULT_PRECIS, /* lfOutPrec */
+ OUT_DEFAULT_PRECIS, /* lfClipPrec */
+ DEFAULT_QUALITY, /* lfQuality */
+ VARIABLE_PITCH | FF_SWISS, /* lfPitchAndFam*/
+ (LPSTR)"MS Sans Serif"); /* lfFacename */
+
+ if(HotKyFnt) {
+ if((hfont = (HFONT)SelectObject(hIC,(HGDIOBJ)HotKyFnt))) {
+ if(GetTextMetrics(hIC, (LPTEXTMETRIC)(&Metrics))) {
+ HotKyFntHgt = Metrics.tmHeight;
+ }
+ SelectObject(hIC,(HGDIOBJ)hfont);
+ }
+ }
+ DeleteDC(hIC);
+
+ /* only register classes if first instance. 23-Oct-1987. davidhab. */
+ if (!hPrevInstance) {
+ if(!(pClass = (PWNDCLASS)LocalAlloc(LPTR, sizeof(WNDCLASS))))
+ goto NoMem;
+
+ pClass->hCursor = LoadCursor(NULL, IDC_ARROW);
+ pClass->hIcon = LoadIcon(hPifInstance, MAKEINTRESOURCE(ID_PIFICON));
+ pClass->lpszMenuName = MAKEINTRESOURCE(ID_PIFMENU);
+ pClass->hInstance = hPifInstance;
+ pClass->lpszClassName = (LPSTR)"Pif";
+ pClass->hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ pClass->lpfnWndProc = (WNDPROC)PifMainWndProc;
+ pClass->style = CS_BYTEALIGNCLIENT;
+ if (!RegisterClass((CONST WNDCLASS *)pClass))
+ return(FALSE);
+ LocalFree((HANDLE)pClass);
+
+ if(!(pClass = (PWNDCLASS)LocalAlloc(LPTR, sizeof(WNDCLASS))))
+ goto NoMem;
+
+ pClass->hCursor = LoadCursor(NULL, IDC_ARROW);
+ pClass->hIcon = (HICON)NULL;
+ pClass->hInstance = hPifInstance;
+ pClass->lpszClassName = (LPSTR)"PifHKy";
+ pClass->hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ pClass->lpfnWndProc = (WNDPROC)PifHotKyWndProc;
+ pClass->style = 0;
+ if (!RegisterClass((CONST WNDCLASS *)pClass))
+ return(FALSE);
+ LocalFree((HANDLE)pClass);
+ }
+ return(TRUE);
+}
+
+
+int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCommandLine, int cmdShow)
+{
+ MSG msg;
+ BYTE *p;
+ PSTR pchFileName;
+ HWND hWndTmp;
+ HWND hWndTmp2;
+ HMENU hMenu;
+ int i;
+ unsigned char buf[160];
+ POINT cTLpt;
+ POINT cLRpt;
+ RECT rc1;
+ RECT rc2;
+ int tmpFOCID;
+
+ PifFile = (PIFNEWSTRUCT *)PifBuf;
+
+ if(!LoadString(hPifInstance, EINSMEMORY, (LPSTR)rgchInsMem, sizeof(rgchInsMem))) {
+ return(FALSE);
+ }
+ if(!LoadString(hPifInstance, NTSYSTEMROOT, (LPSTR)NTSys32Root, PIFDEFPATHSIZE-1)) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+
+ if(!LoadString(hPifInstance, NTSYSTEM32, (LPSTR)buf, PIFDEFPATHSIZE-1)) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ lstrcat(NTSys32Root, buf);
+
+ hPifInstance = hInstance;
+
+ if(!InitPifStuff(hPrevInstance)) {
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+
+ if(!(i = LoadString(hPifInstance, PIFCAPTION, (LPSTR)buf, sizeof(buf)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+
+ if(!LoadString(hPifInstance, NOTITLE, (LPSTR)(buf+i), (sizeof(buf)-i))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+
+ hParentWnd = hMainwnd = CreateWindow((LPSTR)"Pif",
+ (LPSTR)buf,
+ WS_OVERLAPPED | WS_THICKFRAME | WS_CAPTION |
+ WS_SYSMENU | WS_MINIMIZEBOX | WS_VSCROLL |
+ WS_MAXIMIZEBOX,
+ SysCharWidth * 2,
+ SysCharHeight * 3,
+ 0,
+ 0,
+ (HWND)NULL,
+ (HMENU)NULL,
+ hPifInstance,
+ (LPSTR)NULL);
+
+ if(!hMainwnd) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+ hSysMenuMain = GetSystemMenu(hMainwnd,FALSE);
+ hMenu = GetMenu(hMainwnd);
+ hFileMenu = GetSubMenu(hMenu,0);
+ hModeMenu = GetSubMenu(hMenu,1);
+ hHelpMenu = GetSubMenu(hMenu,2);
+
+ CurrMode386 = SysMode386 = SetInitialMode();
+
+ if(!InitPifStruct()){
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+
+ if(CurrMode386) {
+ if(!EnableMode386(hMainwnd,FALSE)) {
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+ } else {
+ if(!EnableMode286(hMainwnd,FALSE)) {
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+ }
+
+ if(hMainwnd) {
+ DragAcceptFiles(hMainwnd,TRUE);
+ }
+ if(hwndPifDlg) {
+ DragAcceptFiles(hwndPifDlg,TRUE);
+ }
+ if(hwndAdvPifDlg) {
+ DragAcceptFiles(hwndAdvPifDlg,TRUE);
+ }
+ if(hwndNTPifDlg) {
+ DragAcceptFiles(hwndNTPifDlg,TRUE);
+ }
+
+ if (*lpszCommandLine) {
+ if (pchFileName = (PSTR)LocalAlloc(LPTR, MAX_PATH)) {
+ if (lstrlen(lpszCommandLine) > (MAX_PATH - 5))
+ *(lpszCommandLine + (MAX_PATH - 5)) = 0;
+ CpyCmdStr((LPSTR)pchFileName, lpszCommandLine);
+ CmdArgAddCorrectExtension(pchFileName);
+ LoadPifFile(pchFileName);
+ LocalFree((HANDLE)pchFileName);
+ SetMainTitle();
+ } else {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(FALSE);
+ }
+ }
+
+ UpdatePifScreen();
+ UpdatePifStruct();
+
+ PifFile->id = 0; /* compute check sum */
+ p = (BYTE *)&PifFile->name[ 0 ];
+ i = PIFSIZE;
+ while (i--)
+ PifFile->id += *p++;
+
+
+ InitShWind = TRUE;
+ ShowWindow(hwndPifDlg, SW_SHOWNORMAL);
+ if(hwndAdvPifDlg)
+ ShowWindow(hwndAdvPifDlg, cmdShow);
+ if(hwndNTPifDlg)
+ ShowWindow(hwndNTPifDlg, cmdShow);
+ ShowWindow(hMainwnd, cmdShow);
+ /*
+ * The following HACK gets around a wierd problem where we end up with no
+ * ICON when started minimized. It is believed that this is due to the
+ * wierd stuff we do based on the InitShWind flag in WM_INITDIALOG.
+ */
+ if((cmdShow == SW_SHOWMINNOACTIVE) || (cmdShow == SW_SHOWMINIMIZED))
+ InvalidateRect(hMainwnd, (CONST RECT *)NULL, TRUE);
+
+ while (GetMessage((LPMSG)&msg, NULL, 0, 0)) {
+ if (!TranslateAccelerator(hMainwnd, hAccel, (LPMSG)&msg)) {
+ if(hwndPrivControl == msg.hwnd) {
+ if(!FilterPrivateMsg(msg.hwnd,msg.message,msg.wParam,msg.lParam)) {
+ TranslateMessage((CONST MSG *)&msg);
+ DispatchMessage((CONST MSG *)&msg);
+ goto CheckFocus;
+ }
+ }
+ if(PifMenuMnemonic((LPMSG)&msg))
+ goto CheckFocus;
+ if (!hwndPifDlg || !IsDialogMessage(hwndPifDlg, (LPMSG)&msg)) {
+ if(hwndAdvPifDlg && IsDialogMessage(hwndAdvPifDlg, (LPMSG)&msg))
+ goto CheckFocus;
+ if(hwndNTPifDlg && IsDialogMessage(hwndNTPifDlg, (LPMSG)&msg))
+ goto CheckFocus;
+ TranslateMessage((CONST MSG *)&msg);
+ DispatchMessage((CONST MSG *)&msg);
+ } else { /* Dialog message for hwndPifDlg or hwndAdvPifDlg */
+CheckFocus:
+ if (hWndTmp = GetFocus()) {
+ if((((hWndTmp2 = GetParent(hWndTmp)) == hwndPifDlg) ||
+ (hWndTmp2 == hwndAdvPifDlg) || (hWndTmp2 == hwndNTPifDlg))
+ && (hWndTmp != hwndFocus)) {
+ if((hWndTmp2 == hwndAdvPifDlg)
+ || (hWndTmp2 == hwndNTPifDlg))
+ hParentWnd = hWndTmp2;
+ else
+ hParentWnd = hMainwnd;
+ hwndFocus = hWndTmp;
+ FocusID = GetDlgCtrlID(hWndTmp);
+ if(hWndTmp2 == hwndPifDlg) {
+ hwndFocusMain = hwndFocus;
+ tmpFOCID = FocusIDMain;
+ FocusIDMain = FocusID;
+ if(tmpFOCID != FocusIDMain)
+ SetStatusText(hMainwnd,FocusIDMain,TRUE);
+ } else if(hWndTmp2 == hwndAdvPifDlg) {
+ hwndFocusAdv = hwndFocus;
+ tmpFOCID = FocusIDAdv;
+ FocusIDAdv = FocusID;
+ if(tmpFOCID != FocusIDAdv)
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ } else {
+ hwndFocusNT = hwndFocus;
+ tmpFOCID = FocusIDNT;
+ FocusIDNT = FocusID;
+ if(tmpFOCID != FocusIDNT)
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ }
+ /*
+ * Check to make sure this control is visible.
+ * If it isn't, scroll the window to make it
+ * visible.
+ *
+ */
+ if((hWndTmp2 == hwndPifDlg) && MainScrollRange) {
+ GetClientRect(hMainwnd,(LPRECT)&rc1);
+ rc1.bottom -= (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ cTLpt.x = rc1.left;
+ cTLpt.y = rc1.top;
+ cLRpt.x = rc1.right;
+ cLRpt.y = rc1.bottom;
+ ClientToScreen(hMainwnd,(LPPOINT)&cTLpt);
+ ClientToScreen(hMainwnd,(LPPOINT)&cLRpt);
+ GetWindowRect(hwndFocus,(LPRECT)&rc2);
+ if(rc2.top < cTLpt.y) {
+ MainScrollTrack(hMainwnd,SB_LINEUP,
+ cTLpt.y - rc2.top);
+ } else if(rc2.bottom > cLRpt.y) {
+ MainScrollTrack(hMainwnd,SB_LINEDOWN,
+ rc2.bottom - cLRpt.y);
+ }
+ } else if ((hWndTmp2 == hwndAdvPifDlg) && AdvScrollRange) {
+ GetClientRect(hwndAdvPifDlg,(LPRECT)&rc1);
+ rc1.bottom -= (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ cTLpt.x = rc1.left;
+ cTLpt.y = rc1.top;
+ cLRpt.x = rc1.right;
+ cLRpt.y = rc1.bottom;
+ ClientToScreen(hwndAdvPifDlg,(LPPOINT)&cTLpt);
+ ClientToScreen(hwndAdvPifDlg,(LPPOINT)&cLRpt);
+ GetWindowRect(hwndFocus,(LPRECT)&rc2);
+ if(rc2.top < cTLpt.y) {
+ MainScrollTrack(hwndAdvPifDlg,SB_LINEUP,
+ cTLpt.y - rc2.top);
+ } else if(rc2.bottom > cLRpt.y) {
+ MainScrollTrack(hwndAdvPifDlg,SB_LINEDOWN,
+ rc2.bottom - cLRpt.y);
+ }
+
+ } else if((hWndTmp2 == hwndNTPifDlg) && NTScrollRange) {
+ GetClientRect(hwndNTPifDlg,(LPRECT)&rc1);
+ rc1.bottom -= (StatusPntData.dyStatus + StatusPntData.dyBorderx2);
+ cTLpt.x = rc1.left;
+ cTLpt.y = rc1.top;
+ cLRpt.x = rc1.right;
+ cLRpt.y = rc1.bottom;
+ ClientToScreen(hwndNTPifDlg,(LPPOINT)&cTLpt);
+ ClientToScreen(hwndNTPifDlg,(LPPOINT)&cLRpt);
+ GetWindowRect(hwndFocus,(LPRECT)&rc2);
+ if(rc2.top < cTLpt.y) {
+ MainScrollTrack(hwndNTPifDlg,SB_LINEUP,
+ cTLpt.y - rc2.top);
+ } else if(rc2.bottom > cLRpt.y) {
+ MainScrollTrack(hwndNTPifDlg,SB_LINEDOWN,
+ rc2.bottom - cLRpt.y);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if (lpfnRegisterPenApp)
+ (*lpfnRegisterPenApp)((WORD)1, FALSE); /* deregister */
+ return(0);
+}
+
+
+unsigned char *PutUpDB(int idb)
+{
+ OPENFILENAME OpnStruc;
+ BOOL MsgFlagSav;
+ unsigned char *pResultBuf = NULL;
+ char filespec[160];
+ char specbuf[80];
+ int i,j;
+ char extspec[] = "PIF";
+ char chbuf[100];
+ HICON hIcon;
+
+
+ if(!(i = LoadString(hPifInstance, errFlTypePIF, (LPSTR)filespec, sizeof(specbuf)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return((unsigned char *)NULL);
+ }
+ if(!(j = LoadString(hPifInstance,errFlTypeAll , (LPSTR)specbuf, sizeof(specbuf)))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return((unsigned char *)NULL);
+ }
+ i++; /* point to char after NUL at end of errFlTypePIF */
+ lstrcpy((LPSTR)&filespec[i],(LPSTR)"*.PIF");
+ i += 6; /* point to char after NUL at end of *.PIF */
+ lstrcpy((LPSTR)&filespec[i],(LPSTR)specbuf);
+ i += j + 1; /* point to char after NUL at end of errFlTypeAll */
+ lstrcpy((LPSTR)&filespec[i],(LPSTR)"*.*");
+ i += 4; /* point to char after NUL at end of *.* */
+ filespec[i] = '\0'; /* double nul terminate */
+
+
+ if((idb == DTOPEN) || (idb == DTSAVE)) {
+ if(!(pResultBuf = (unsigned char *)LocalAlloc(LPTR, 132))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return((unsigned char *)NULL);
+ }
+ lstrcpy((LPSTR)pResultBuf, (LPSTR)CurPifFile);
+ OpnStruc.lStructSize = (unsigned long)(sizeof(OpnStruc));
+ OpnStruc.hwndOwner = hMainwnd;
+ OpnStruc.hInstance = 0;
+ OpnStruc.lpstrFilter = (LPSTR)filespec;
+ OpnStruc.lpstrCustomFilter = (LPSTR)NULL;
+ OpnStruc.nMaxCustFilter = (DWORD)NULL;
+ OpnStruc.nFilterIndex = 1;
+ OpnStruc.lpstrFile = (LPSTR)pResultBuf;
+ OpnStruc.nMaxFile = 132;
+ /*
+ * We should use the next cookie to set our title BUT we still
+ * have to deal with file names we get from command line
+ * argument and drag drop, so to hell with it.
+ */
+ OpnStruc.lpstrFileTitle = (LPSTR)NULL;
+ OpnStruc.nMaxFileTitle = 0;
+ OpnStruc.lpstrInitialDir = (LPSTR)NULL;
+ OpnStruc.lpstrTitle = (LPSTR)NULL;
+ OpnStruc.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ OpnStruc.nFileOffset = 0;
+ OpnStruc.nFileExtension = 0;
+ OpnStruc.lpstrDefExt = (LPSTR)extspec;
+ OpnStruc.lCustData = 0;
+ OpnStruc.lpfnHook = (LPOFNHOOKPROC)NULL;
+ OpnStruc.lpTemplateName = (LPSTR)NULL;
+ } else if(idb == DTABOUT) {
+ if(!LoadString(hPifInstance, errTitle, (LPSTR)chbuf, sizeof(chbuf))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(pResultBuf);
+ }
+ hIcon = LoadIcon(hPifInstance, MAKEINTRESOURCE(ID_PIFICON));
+ }
+
+ /*
+ * These dialogs always come up via menu selections in the main window
+ * menu. The parent is therefore always hMainwnd
+ */
+ switch(idb) {
+
+ case DTOPEN:
+ MsgFlagSav = DoingMsg;
+ DoingMsg = TRUE;
+ if(MsgFlagSav != DoingMsg)
+ InvalidateAllStatus();
+ if(!(GetOpenFileName((LPOPENFILENAME)&OpnStruc))){
+ if(pResultBuf)
+ LocalFree((HANDLE)pResultBuf);
+ pResultBuf = (unsigned char *)NULL;
+ } else {
+ tmpfileoffset = OpnStruc.nFileOffset;
+ tmpextoffset = OpnStruc.nFileExtension;
+ }
+ if(MsgFlagSav != DoingMsg) {
+ DoingMsg = MsgFlagSav;
+ InvalidateAllStatus();
+ } else {
+ DoingMsg = MsgFlagSav;
+ }
+ break;
+
+ case DTSAVE:
+ MsgFlagSav = DoingMsg;
+ DoingMsg = TRUE;
+ if(MsgFlagSav != DoingMsg)
+ InvalidateAllStatus();
+ if(!(GetSaveFileName((LPOPENFILENAME)&OpnStruc))){
+ if(pResultBuf)
+ LocalFree((HANDLE)pResultBuf);
+ pResultBuf = (unsigned char *)NULL;
+ } else {
+ tmpfileoffset = OpnStruc.nFileOffset;
+ tmpextoffset = OpnStruc.nFileExtension;
+ }
+ if(MsgFlagSav != DoingMsg) {
+ DoingMsg = MsgFlagSav;
+ InvalidateAllStatus();
+ } else {
+ DoingMsg = MsgFlagSav;
+ }
+ break;
+
+ case DTABOUT:
+ MsgFlagSav = DoingMsg;
+ DoingMsg = TRUE;
+ if(MsgFlagSav != DoingMsg)
+ InvalidateAllStatus();
+ ShellAbout(hMainwnd, (LPSTR)chbuf, (LPSTR)NULL, hIcon);
+ pResultBuf = (unsigned char *)NULL;
+ if(MsgFlagSav != DoingMsg) {
+ DoingMsg = MsgFlagSav;
+ InvalidateAllStatus();
+ } else {
+ DoingMsg = MsgFlagSav;
+ }
+ break;
+ }
+ return(pResultBuf);
+}
+
+
+/* ** return TRUE iff 0 terminated string contains a '*' or '\' */
+BOOL FSearchSpec(unsigned char *sz)
+{
+ for (; *sz;sz=AnsiNext(sz)) {
+ if (*sz == '*' || *sz == '?')
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+CheckOkEnable(HWND hwnd, unsigned message)
+{
+ if (message == EN_CHANGE)
+ EnableWindow(GetDlgItem(hwnd, IDOK),
+ (BOOL)(SendMessage(GetDlgItem(hwnd, ID_EDIT),
+ WM_GETTEXTLENGTH, 0, 0L)));
+ return(TRUE);
+}
+
+/* ** Given filename or partial filename or search spec or partial
+ search spec, add appropriate extension. */
+CmdArgAddCorrectExtension(unsigned char *szEdit)
+{
+ register unsigned char *pchLast;
+ register unsigned char *pchT;
+ int ichExt;
+ BOOL fDone = FALSE;
+ int cchEdit;
+
+ pchT = pchLast = (unsigned char *)AnsiPrev((LPSTR)szEdit, (LPSTR)(szEdit + (cchEdit = lstrlen((LPSTR)szEdit))));
+
+ if ((*pchLast == '.' && *(AnsiPrev((LPSTR)szEdit, (LPSTR)pchLast)) == '.') && cchEdit == 2)
+ ichExt = 0;
+ else if (*pchLast == '\\' || *pchLast == ':')
+ ichExt = 1;
+ else {
+ ichExt = 2;
+ for (; pchT > szEdit; pchT = (unsigned char *)AnsiPrev((LPSTR)szEdit, (LPSTR)pchT)) {
+ /* If we're not searching and we encounter a period, don't add
+ any extension. If we are searching, period is assumed to be
+ part of directory name, so go ahead and add extension. However,
+ if we are searching and find a search spec, do not add any
+ extension. */
+ if (*pchT == '.') {
+ return(TRUE);
+ }
+ /* Quit when we get to beginning of last node. */
+ if (*pchT == '\\')
+ break;
+ }
+ }
+ lstrcpy((LPSTR)(pchLast+1), (LPSTR)(szExtSave+ichExt));
+ return(TRUE);
+}
+
+DoHelp(unsigned int hindx,unsigned int IDIndx)
+{
+ BOOL retval;
+ unsigned int *aliasptr;
+ int i;
+
+ if(hindx == 0)
+ hindx = (unsigned int)FocusID;
+
+ if(IDIndx == 0) {
+ if(CurrMode386) {
+ if(ModeAdvanced) {
+ IDIndx = IDXID_386AHELP;
+ } else {
+ IDIndx = IDXID_386HELP;
+ }
+ } else {
+ IDIndx = IDXID_286HELP;
+ }
+ }
+
+ if(hindx == M_HELPHELP) {
+ retval = WinHelp(hMainwnd,(LPSTR)NULL,HELP_HELPONHELP,(DWORD)0);
+ } else if(hindx == M_SHELP) {
+ retval = WinHelp(hMainwnd,(LPSTR)PIFHELPFILENAME,HELP_PARTIALKEY,(DWORD)(LPSTR)"");
+ } else if((hindx == IDXID_386AHELP) || (hindx == IDXID_386HELP) ||
+ (hindx == IDXID_286HELP)) {
+ WinHelp(hMainwnd,(LPSTR)PIFHELPFILENAME,HELP_CONTEXT,(DWORD)IDIndx);
+ retval = WinHelp(hMainwnd,(LPSTR)PIFHELPFILENAME,HELP_SETINDEX,(DWORD)IDIndx);
+ } else {
+ if(IDIndx == IDXID_286HELP) {
+ for(i = 1, aliasptr = Aliases286;
+ i <= NUM286ALIASES;
+ i++, aliasptr += 2) {
+
+ if(*aliasptr == hindx) {
+ aliasptr++;
+ hindx = *aliasptr;
+ break;
+ }
+ }
+ }
+ retval = WinHelp(hMainwnd,(LPSTR)PIFHELPFILENAME,HELP_CONTEXT,(DWORD)hindx);
+ WinHelp(hMainwnd,(LPSTR)PIFHELPFILENAME,HELP_SETINDEX,(DWORD)IDIndx);
+ }
+ if(retval) {
+ hwndHelpDlgParent = hMainwnd;
+ } else {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ return(TRUE);
+}
+
+
+int SetWndScroll(int sizeflg, HWND hMwnd, int WindHeight, int WindWidth,
+ int *WndSize, int *ScrollRange, int *ScrollLineSz,
+ int *WndLines, int *MaxNeg)
+{
+ int i;
+ int range;
+ int rangeFS;
+ int MaxrangeNRML;
+ int WndCapSz;
+ int newheight;
+ int newwidth;
+ int oldscrollpos;
+ int oldscrollOffset;
+ int newscrollOffset;
+ int oldscrollRange;
+
+ RECT rc1;
+ RECT rc2;
+
+ if(hMwnd == hMainwnd) {
+ WndCapSz = GetSystemMetrics(SM_CYCAPTION) +
+ GetSystemMetrics(SM_CYMENU);
+ } else {
+ WndCapSz = GetSystemMetrics(SM_CYCAPTION);
+ }
+
+ WndCapSz += (i = (2 * GetSystemMetrics(SM_CYFRAME)));
+
+ rangeFS = GetSystemMetrics(SM_CYSCREEN) + i;
+
+ MaxrangeNRML = rangeFS - (2 * SysCharHeight);
+
+ if(*WndSize != SIZEFULLSCREEN) {
+ range = MaxrangeNRML;
+ } else {
+ range = rangeFS;
+ }
+
+ WindHeight += WndCapSz;
+
+ if(sizeflg) {
+ if(WindHeight > range)
+ newheight = range;
+ else
+ newheight = WindHeight;
+ newwidth = WindWidth + (2 * GetSystemMetrics(SM_CXFRAME));
+ } else {
+ GetWindowRect(hMwnd,(LPRECT)&rc1);
+ newheight = rc1.bottom - rc1.top;
+ newwidth = rc1.right - rc1.left;
+ }
+
+ if(*WndSize == SIZEFULLSCREEN) {
+ newwidth = GetSystemMetrics(SM_CXSCREEN) +
+ (2 * GetSystemMetrics(SM_CXFRAME));
+ newheight = rangeFS;
+ }
+ newscrollOffset = 0;
+ /* Don't bother with SB stuff till window is visible */
+ if(IsWindowVisible(hMwnd)) {
+ oldscrollOffset = oldscrollpos = 0;
+ if((oldscrollRange = *ScrollRange)) {
+ oldscrollpos = GetScrollPos(hMwnd,SB_VERT);
+ newscrollOffset = oldscrollOffset =
+ min((oldscrollpos * *ScrollLineSz),*MaxNeg);
+ }
+ if(WindHeight > newheight) {
+ GetWindowRect(GetDlgItem(hwndPifDlg,IDI_ENAME),(LPRECT)&rc1);
+ GetWindowRect(GetDlgItem(hwndPifDlg,IDI_ETITLE),(LPRECT)&rc2);
+ *ScrollLineSz = rc2.top - rc1.top;
+ *MaxNeg = WindHeight - newheight;
+ *WndLines = range = (*MaxNeg + *ScrollLineSz - 1)/ *ScrollLineSz;
+ if(range != *ScrollRange) {
+ SetScrollRange(hMwnd, SB_VERT, 0, range, FALSE);
+ if(!oldscrollpos) {
+ SetScrollPos(hMwnd, SB_VERT, 0, TRUE);
+ } else if (oldscrollpos > range) {
+ SetScrollPos(hMwnd, SB_VERT, range, TRUE);
+ newscrollOffset = min((range * *ScrollLineSz),*MaxNeg);
+ } else {
+ SetScrollPos(hMwnd, SB_VERT, oldscrollpos, TRUE);
+ newscrollOffset = min((oldscrollpos * *ScrollLineSz),*MaxNeg);
+ }
+ *ScrollRange = range;
+ } else {
+ newscrollOffset = min((oldscrollpos * *ScrollLineSz),*MaxNeg);
+ }
+ if(oldscrollpos && (newscrollOffset != oldscrollOffset)) {
+ if((hMwnd == hwndAdvPifDlg) || (hMwnd == hwndNTPifDlg)) {
+ ScrollWindow(hMwnd,
+ 0,
+ oldscrollOffset-newscrollOffset,
+ (CONST RECT *)NULL,
+ (CONST RECT *)NULL);
+ UpdateWindow(hMwnd);
+ AdjustFocusCtrl(hMwnd);
+ } else {
+ SetWindowPos(hwndPifDlg,
+ (HWND)NULL,
+ 0,
+ -newscrollOffset,
+ newwidth,
+ newheight + newscrollOffset -
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2),
+ SWP_NOZORDER | SWP_NOACTIVATE);
+ UpdateWindow(hwndPifDlg);
+ AdjustFocusCtrl(hwndPifDlg);
+ }
+ InvalidateStatusBar(hMwnd);
+ }
+ } else {
+ if(*ScrollRange && oldscrollpos) {
+ MainScroll(hMwnd, SB_TOP, 0, 0, 1);
+ }
+ SetScrollRange(hMwnd, SB_VERT, 0, 0, FALSE);
+ *ScrollRange = 0;
+ }
+ }
+ if(sizeflg) {
+ SetWindowPos(hMwnd,
+ (HWND)NULL,
+ (int)NULL,
+ (int)NULL,
+ newwidth,
+ newheight,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+ }
+ return(newscrollOffset);
+}
+
+
+SetMainWndSize(int sizeflg)
+{
+ long SizeLong;
+ int MainWindHeight;
+ int MainWindWidth;
+ int AdvWindHeight;
+ int AdvWindWidth;
+ int NTWindHeight;
+ int NTWindWidth;
+ int PassFlg;
+ int ScrlOff;
+ RECT rc;
+
+ if(SizingFlag)
+ return(TRUE);
+ SizingFlag++;
+
+ switch(sizeflg) {
+ case SBUMAIN:
+ case SBUADV:
+ case SBUNT:
+ PassFlg = 0; /* Flag just SB update to do */
+ break;
+
+ default:
+ PassFlg = 1; /* Flag SB and SIZE update to do */
+ break;
+ }
+
+ switch(sizeflg) {
+ case SBUMAIN:
+ case SBUMAINADVNT:
+ case SBUSZMAIN:
+ case SBUSZMAINADVNT:
+ SendMessage(hwndPifDlg,WM_PRIVGETSIZE,0,(LONG)(long FAR *)&SizeLong);
+ MainWindHeight = HIWORD(SizeLong);
+ MainWindWidth = LOWORD(SizeLong);
+ ScrlOff = SetWndScroll(PassFlg,hMainwnd,MainWindHeight,
+ MainWindWidth,&MainWndSize,&MainScrollRange,
+ &MainScrollLineSz,&MainWndLines,&MaxMainNeg);
+ /*
+ * Clip the dialog so that it doesn't overlap the status bar
+ */
+ GetClientRect(hMainwnd,(LPRECT)&rc);
+ SetWindowPos(hwndPifDlg,
+ (HWND)NULL,
+ 0,
+ 0,
+ rc.right - rc.left,
+ rc.bottom - rc.top + ScrlOff -
+ (StatusPntData.dyStatus + StatusPntData.dyBorderx2),
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+ break;
+
+ default:
+ break;
+ }
+
+ if(hwndAdvPifDlg) {
+ switch(sizeflg) {
+ case SBUSZMAINADVNT:
+ case SBUMAINADVNT:
+ case SBUSZADV:
+ case SBUADV:
+ SendMessage(hwndAdvPifDlg,WM_PRIVGETSIZE,0,
+ (LONG)(long FAR *)&SizeLong);
+ AdvWindHeight = HIWORD(SizeLong);
+ AdvWindWidth = LOWORD(SizeLong);
+ ScrlOff = SetWndScroll(PassFlg,hwndAdvPifDlg,AdvWindHeight,
+ AdvWindWidth,&AdvWndSize,&AdvScrollRange,
+ &AdvScrollLineSz,&AdvWndLines,
+ &MaxAdvNeg);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if(hwndNTPifDlg) {
+ switch(sizeflg) {
+ case SBUSZMAINADVNT:
+ case SBUMAINADVNT:
+ case SBUSZNT:
+ case SBUNT:
+ SendMessage(hwndNTPifDlg,WM_PRIVGETSIZE,0,
+ (LONG)(long FAR *)&SizeLong);
+ NTWindHeight = HIWORD(SizeLong);
+ NTWindWidth = LOWORD(SizeLong);
+ ScrlOff = SetWndScroll(PassFlg,hwndNTPifDlg,NTWindHeight,
+ NTWindWidth,&NTWndSize,&NTScrollRange,
+ &NTScrollLineSz,&NTWndLines,
+ &MaxNTNeg);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ SizingFlag = 0;
+ return(TRUE);
+}
+
+
+/*
+ * CpyCmdStr( LPSTR szDst, LPSTR szSrc )
+ *
+ * Copies szSrc to szDst and correctly deals with double quotes
+ */
+void CpyCmdStr( LPSTR szDst, LPSTR szSrc ) {
+
+ do {
+ switch( *szSrc ) {
+ case '"':
+ /* eat double quotes */
+ break;
+
+#if 0
+ //
+ // This 'case' makes it difficult to put a '^' in a filename.
+ // (due to cmd processing, it needs to appear 4 times in the line)!
+ //
+ // With out this case, it is impossible to put a '"' in the middle
+ // of a filename, but " is illegal in a filename on _ALL_ NT
+ // filesystems, and is not supported by any command line utility
+ // in that context.
+ //
+ case '^':
+ /* use '^' to mean 'quote next char' */
+ szSrc++;
+ /* FALL THROUGH to default */
+#endif
+
+ default:
+ *szDst++ = *szSrc;
+ break;
+ }
+ }while( *szSrc++ );
+}
diff --git a/private/mvdm/vdmutils/pifedit/pifedit.h b/private/mvdm/vdmutils/pifedit/pifedit.h
new file mode 100644
index 000000000..37f453039
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifedit.h
@@ -0,0 +1,144 @@
+#include "windows.h"
+#include "pif.h"
+#include "pifhelp.h"
+
+extern char hextobyte(LPSTR);
+
+/* EQUATES for special virtual key values that are used a lot */
+#define ALTLPARAM (DWORD)((DWORD)(MapVirtualKey(VK_MENU,0)) << 16L)
+#define CTRLLPARAM (DWORD)((DWORD)(MapVirtualKey(VK_CONTROL,0)) << 16L)
+#define SHIFTLPARAM (DWORD)((DWORD)(MapVirtualKey(VK_SHIFT,0)) << 16L)
+
+/* Special private messages for PIFEDIT */
+#define WM_PRIVGETSIZE WM_USER+20
+#define WM_PRIVCLOSEOK WM_USER+21
+#define WM_PRIVCLOSECANCEL WM_USER+22
+#define IDADVCANCEL WM_USER+23
+#define IDNTCANCEL WM_USER+24
+#define IDNTOK WM_USER+25
+
+/* Max Length of all of the status bar texts, INCLUDING THE NUL */
+#define PIFSTATUSLEN 90
+
+/* There is no control for these, IDI_GENSTAT is for the default status text */
+#define IDI_GENSTAT 1001
+/* IDI_CLOSE is for when IDCANCEL appears as CLOSE */
+#define IDI_CANCLOSE 1002
+#define IDI_NTCANCLOSE 1003
+
+/* Status paint helper structure */
+typedef struct {
+ int dyBorder; /* System Border Width/Height */
+ int dyBorderx2; /* System Border Width/Height * 2 */
+ int dyBorderx3; /* System Border Width/Height * 3 */
+ int dyStatus; /* Status Bar height */
+ int Fntheight; /* Height of the font */
+ HGDIOBJ hFontStatus; /* Font used in status bar */
+} PIFSTATUSPAINT;
+
+/* String table equates */
+#define errTitle 2000
+#define errNoPIFfnf 2001
+#define errNoPIFpnf 2002
+#define errNoCreate 2003
+#define errMmMaxMin386 2004
+#define errHiLow 2005
+#define errNoFileHnds 2006
+#define warSave 2007
+#define errNoAcc 2008
+#define EINSMEMORY 2009
+#define errNOEND 2010
+#define EINVALIDFILE 2011
+#define errDiskFull 2012
+#define IABOUT 2013
+#define errBadExt 2014
+#define errBadProgram 2015
+#define IS386 2016
+#define IS286 2017
+#define PIFCAPTIONADV 2018
+#define PIFCAPTION 2019
+#define errNoOpen 2020
+#define PIFBADFIL 2021
+#define PIFOLDFIL 2022
+#define WARNCLOSE 2023
+#define NONE 2024
+#define BADHK 2025
+#define WININISECT 2026
+#define WININIADV 2027
+#define WININION 2028
+#define MENUMNEMONIC1 2029
+#define MENUMNEMONIC2 2030
+#define MENUMNEMONIC3 2031
+#define KEYSEPCHAR 2032
+#define errBadNumberP 2033
+#define errBadNumberMR 2034
+#define errBadNumberMD 2035
+#define errBadNumberXEMSR 2036
+#define errBadNumberXEMSD 2037
+#define NOMODE386 2038
+#define NOMODE286 2039
+#define NOTITLE 2040
+#define PIFCANCELSTRNG 2041
+#define PIFDONESTRNG 2042
+#define errXMSMaxMin386 2044
+#define errXMSMaxMin286 2045
+#define errEMMMaxMin386 2046
+/*
+ * #define PIFOLDFIL2 2047
+ * #define errEMMMaxMin286 2048
+ */
+#define errWrongExt 2049
+#define errSharing 2050
+#define errCrtRO 2051
+#define errFlTypePIF 2052
+#define errFlTypeAll 2053
+#define PIFCAPTIONNT 2054
+#define errNoNTAFile 2055
+#define errNoNTCFile 2056
+#define errNTAFilene 2057
+#define errNTCFilene 2058
+#define NTSYSTEMROOT 2059
+#define NTSYSTEM32 2060
+#define NOMODENT 2061
+#define NTAUTOEXECFILE 2062
+#define NTCONFIGFILE 2063
+#define errBadAutoPath 2064
+#define errBadConfigPath 2065
+#define errBadAutoName 2070
+#define errBadConName 2071
+
+/* DIALOG IDs for DialogBox dialogs */
+#define DTOPEN 10
+#define DTSAVE 11
+#define DTABOUT 12
+
+/* Return values for SAVE dialog */
+#define SAVERETRY 1
+#define SAVEDONE 2
+#define SAVEERROR 3
+
+/* IDs of special controls in Save As, Open, etc dialogs */
+#define ID_PATH 10
+#define ID_EDIT 11
+#define ID_LISTBOX 12
+#define ID_LISTBOXDIR 13
+#define IDSCROLL 16
+#define IDTEXTBOX 17
+
+#define PATHMAX 128
+
+/* LISTBOX type equates */
+#define ATTRDIRLIST 0xC010 /* dirs and drives only */
+#define ATTRFILELIST 0x0000 /* normal files */
+#define ATTRDIRFILE 0x4010 /* normal files */
+
+
+#define ID_PIFICON 1
+
+#define ID_PIFMENU 1
+
+/* Dialog templates for main and advanced window dialogs */
+#define ID_PIF286TEMPLATE 1
+#define ID_PIF386TEMPLATE 2
+#define ID_PIF386ADVTEMPLT 3
+#define ID_PIFNTTEMPLT 4
diff --git a/private/mvdm/vdmutils/pifedit/pifedit.ico b/private/mvdm/vdmutils/pifedit/pifedit.ico
new file mode 100644
index 000000000..7506cb72c
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifedit.ico
Binary files differ
diff --git a/private/mvdm/vdmutils/pifedit/pifedit.rc b/private/mvdm/vdmutils/pifedit/pifedit.rc
new file mode 100644
index 000000000..a19900b69
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifedit.rc
@@ -0,0 +1,499 @@
+#include "pifedit.h"
+
+#include "pifedit.rcv"
+
+
+/*
+ * NOTE to TRANSLATORS
+ *
+ * The IDI_OTHGRP box is used to determine advanced dialog box bottom and
+ * right edges. If you need more space in the dialog (for swedish
+ * "Prioriterad nar aktiv" for example), then you MUST GROW THE IDI_OTHGRP
+ * control AS WELL AS the Dialog template! Otherwise your new dialog size
+ * will not take effect.
+ */
+
+
+
+
+
+
+ID_PIFICON ICON PRELOAD PIFEDIT.ICO
+
+/*
+ * HACK ALERT. in order to allow Alt+Mnemonic work for menus even
+ * though pifedit is actually a dialog box, we must test all
+ * WM_SYSCHAR messages to see if we should bypass the dialog manager.
+ * In PifMenuMnemonic() we test for the mnemonic characters which are
+ * defined in the string table to be the mnemonics used here: F,O,M. If
+ * this is changed when translated,or more menus are added in the future,
+ * make sure to change the defines in pif.h and the procedure
+ * PifMenuMnemonic().
+ *
+ * NOTE TO TRANSLATORS: WHEN YOU TRANSLATE THESE MENU ITEMS MAKE SURE YOU
+ * ALSO TRANSLATE THE SINGLE CHARACTER STRINGS IN THE
+ * STRING TABLE THAT CORRESPOND (MENUMNEMONIC?).
+ *
+ * 07-Jun-1987. davidhab.
+ *
+ */
+ID_PIFMENU MENU PRELOAD
+{
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&New", M_NEW
+ MENUITEM "&Open...", M_OPEN
+ MENUITEM "&Save" M_SAVE
+ MENUITEM "Save &As...", M_SAVEAS
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", M_EXIT
+ END
+ POPUP "&Mode"
+ BEGIN
+ MENUITEM "&Standard", M_286
+ MENUITEM "&Enhanced", M_386
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&Contents", M_INDXHELP
+ MENUITEM "&Search for Help on...", M_SHELP
+ MENUITEM SEPARATOR
+ MENUITEM "&Standard Options", M_286HELP
+ MENUITEM "&Enhanced Options", M_386HELP
+ MENUITEM "A&dvanced Options", M_386AHELP
+ MENUITEM "&Windows NT Options", M_NTHELP
+ MENUITEM SEPARATOR
+ MENUITEM "&How to Use Help", M_HELPHELP
+ MENUITEM SEPARATOR
+ MENUITEM "&About PIF Editor...", M_ABOUT
+ END
+}
+
+pifaccels ACCELERATORS
+BEGIN
+ VK_F1, M_AHELP, VIRTKEY, NOINVERT
+END
+
+STRINGTABLE PRELOAD
+BEGIN
+ /* start status bar text */
+ IDI_ENAME, "Press F1 for Help on Program Filename."
+ IDI_ETITLE, "Press F1 for Help on Window Title."
+ IDI_EPARM, "Press F1 for Help on Optional Parameters."
+ IDI_EPATH, "Press F1 for Help on Startup Directory."
+ IDI_VMODETXT, "Press F1 for Help on Video Memory."
+ IDI_VMODELRGRFX, "Press F1 for Help on Video Memory."
+ IDI_VMODEHRGRFX, "Press F1 for Help on Video Memory."
+ IDI_MEMREQ, "Press F1 for Help on Memory Requirements."
+ IDI_MEMDES, "Press F1 for Help on Memory Requirements."
+ IDI_EMSREQ, "Press F1 for Help on EMS Memory."
+ IDI_EMSDES, "Press F1 for Help on EMS Memory."
+ IDI_XMAREQ, "Press F1 for Help on XMS Memory."
+ IDI_XMADES, "Press F1 for Help on XMS Memory."
+ IDI_FSCR, "Press F1 for Help on Display Usage."
+ IDI_WND, "Press F1 for Help on Display Usage."
+ IDI_BACK, "Press F1 for Help on Execution."
+ IDI_EXCL, "Press F1 for Help on Execution."
+ IDI_EXIT, "Press F1 for Help on Close Window on Exit."
+ IDI_ADVANCED, "Choose the Advanced button for more PIF Editor options."
+ IDI_PSTEXT, "Press F1 for Help on Video Mode."
+ IDI_PSGRAPH, "Press F1 for Help on Video Mode."
+ IDI_DMCOM1, "Press F1 for Help on Directly Modifies."
+ IDI_DMCOM2, "Press F1 for Help on Directly Modifies."
+ IDI_DMCOM3, "Press F1 for Help on Directly Modifies."
+ IDI_DMCOM4, "Press F1 for Help on Directly Modifies."
+ IDI_DMKBD, "Press F1 for Help on Directly Modifies."
+ IDI_SENONE, "Press F1 for Help on No Screen Exchange."
+ IDI_PSNONE, "Press F1 for Help on Prevent Program Switch."
+ IDI_NOSAVVID, "Press F1 for Help on No Save Screen."
+ M_SYSMENUMAIN, "Move, size, or close window."
+ M_FILEMENU, "Open or save PIF."
+ M_MODEMENU, "Change PIF Editor settings mode."
+ M_HELPMENU, "Get Help."
+ M_SYSMENUADV, "Move or close window."
+ M_286HELP, "Display Help contents for standard mode."
+ M_386HELP, "Display Help contents for enhanced mode."
+ M_386AHELP, "Display Help contents for advanced settings."
+ M_INDXHELP, "Display Help contents for current mode."
+ M_SHELP, "Find help topics using keywords."
+ M_HELPHELP, "Display introduction to Windows Help."
+ M_OPEN, "Open a saved PIF."
+ M_SAVE, "Save PIF."
+ M_NEW, "Create new PIF."
+ M_SAVEAS, "Save the PIF using a new name."
+ M_ABOUT, "Display program information."
+ M_EXIT, "Quit PIF Editor."
+ M_286, "Show settings for standard-mode Windows."
+ M_386, "Show settings for enhanced-mode Windows."
+ SC_SIZE, "Change window size."
+ SC_MOVE, "Change window position."
+ SC_MINIMIZE, "Reduce window to an icon."
+ SC_MAXIMIZE, "Enlarge window to full size."
+ SC_CLOSE, "Close window and quit PIF Editor."
+ SC_CLOSEADV, "Close advanced window and discard your changes."
+ SC_RESTORE, "Restore window to previous size."
+ SC_TASKLIST, "Activate Task List."
+ IDI_BPRI, "Press F1 for Help on Priority."
+ IDI_FPRI, "Press F1 for Help on Priority."
+ IDI_POLL, "Press F1 for Help on Detect Idle Time."
+ IDI_EMSLOCKED, "Press F1 for Help on EMS Memory Locked."
+ IDI_XMSLOCKED, "Press F1 for Help on XMS Memory Locked."
+ IDI_NOHMA, "Press F1 for Help on Uses High Memory Area."
+ IDI_VMLOCKED, "Press F1 for Help on Lock Application Memory."
+ IDI_TRAPTXT, "Press F1 for Help on Monitor Ports."
+ IDI_TRAPLRGRFX, "Press F1 for Help on Monitor Ports."
+ IDI_TRAPHRGRFX, "Press F1 for Help on Monitor Ports."
+ IDI_TEXTEMULATE, "Press F1 for Help on Emulate Text Mode."
+ IDI_RETAINALLO, "Press F1 for Help on Retain Video Memory."
+ IDI_INT16PST, "Press F1 for Help on Allow Fast Paste."
+ IDI_CLOSE, "Press F1 for Help on Allow Close When Active."
+ IDI_ALTTAB, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_PRTSC, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_ALTENTER, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_ALTESC, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_ALTPRTSC, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_CTRLESC, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_ALTSPACE, "Press F1 for Help on Reserve Shortcut Keys."
+ IDI_HOTKEY, "Press F1 for Help on Application Shortcut Key."
+ IDADVCANCEL, "Choose Cancel to discard changes and close the Advanced window."
+ IDI_CANCLOSE, "Choose Close to close the Advanced window."
+ IDOK, "Choose OK to accept changes and close the Advanced window."
+ IDI_NT, "Choose the Windows NT button for NT specific PIF Editor options."
+ IDI_AUTOEXEC, "Press F1 for Help on Autoexec Filename."
+ IDI_CONFIG, "Press F1 for Help on Config Filename."
+ IDI_NTTIMER, "Press F1 for Help on Compatible Timer Hardware Emulation."
+ SC_NTCLOSE, "Close Windows NT window and discard your changes."
+ M_NTHELP, "Display Help contents for Windows NT settings."
+ IDNTCANCEL, "Choose Cancel to discard changes and close the Windows NT window."
+ IDI_NTCANCLOSE, "Choose Close to close the Windows NT window."
+ IDNTOK, "Choose OK to accept changes and close the Windows NT window."
+ IDI_GENSTAT, "Press F1 for PIF Editor Help."
+ /* end status bar text */
+
+errTitle, "PIF Editor"
+errNOEND, "PIF Editor
+\r\rCannot quit PIF Editor."
+/*
+ * The following two items are the strings passed to COMMDLG for the
+ * file name list. Please do not be STUPID!!!!! NO, you cannot change
+ * the PIF file extension to something else by changing the DEF of
+ * errFlTypePIF. This is simply the text associated with the type, that
+ * is all!
+ */
+errFlTypePIF, "PIF Files (*.PIF)"
+errFlTypeAll, "All Files (*.*)"
+errNoPIFfnf, "File not found.
+\r\rCheck to ensure the path and filename are correct."
+errNoNTAFile, "No Autoexec filename specified.
+\r\rEnter a valid path and filename. Choose OK to ignore this warning."
+errNTAFilene, "Autoexec file specified doesn't exist.
+\r\rCheck to ensure the path and filename are correct. Choose OK to ignore this warning."
+errNoNTCFile, "No Config filename specified.
+\r\rEnter a valid path and filename. Choose OK to ignore this warning."
+errNTCFilene, "Config file specified doesn't exist.
+\r\rCheck to ensure the path and filename are correct. Choose OK to ignore this warning."
+errNoPIFpnf, "Path not found.
+\r\rCheck to ensure the path name is correctly specified, and that the file exists."
+errNoFileHnds, "Insufficient file handles.
+\r\rIncrease the FILES= entry in CONFIG.SYS."
+errNoAcc, "Access denied.
+\r\rYou cannot access this PIF now. Try again later."
+errSharing, "Sharing violation.
+\r\rSome other program is accessing this PIF now. Try again later."
+errNoCreate, "Cannot create PIF.
+\r\rCheck to ensure the disk has available space and the directory is correctly specified."
+errCrtRO, "This PIF is read-only.
+\r\rYou will have to turn off this file's read-only attribute, or select another name."
+errNoOpen, "PIF is too large to load.
+\r\rCheck to ensure the file is a PIF."
+errMmMaxMin386, "Windows KB Preferred memory less than KB Required memory.
+\r\rEither increase KB Preferred memory or decrease KB Required memory."
+errXMSMaxMin386,"Windows XMS KB Limit memory less than KB Required memory.
+\r\rEither increase XMS KB Limit memory or decrease KB Required memory."
+errXMSMaxMin286,"Windows XMS KB Limit memory less than KB Required memory.
+\r\rEither increase XMS KB Limit memory or decrease KB Required memory."
+errEMMMaxMin386,"Windows EMS KB Limit memory less than KB Required memory.
+\r\rEither increase EMS KB Limit memory or decrease KB Required memory."
+/*
+ * errEMMMaxMin286,"Windows EMS KB Limit memory less than KB Required memory;
+ * \r\reither increase EMS KB Limit memory or decrease KB Required memory."
+ * PIFOLDFIL2,"This file is a Windows 3.00 PIF. If you save it, the PIF editor will convert it to the new Windows 3.10 PIF format."
+ */
+errHiLow, "The PIF you are editing is damaged.
+\r\rCreate and save the file again."
+warSave, "Save current changes?"
+EINSMEMORY, "Insufficient memory to perform this operation.
+\r\rClose one or more Windows applications to increase available memory."
+EINVALIDFILE, "Invalid filename.
+\r\rCheck to ensure the filename has no more than 8 characters followed by a period and a 3-letter extension."
+errDiskFull, "Insufficient disk space.
+\r\rDelete one or more files to increase available disk space, and then try again."
+IABOUT, "About..."
+errBadExt, "Invalid extension in program name.
+\r\rCheck to ensure the extension is .EXE, .COM, or .BAT. Choose OK to ignore this error."
+errBadProgram, "Invalid program filename.
+\r\rCheck to ensure the name includes no more than 8 valid characters. Choose OK to ignore this error."
+errBadAutoName, "Invalid autoexec filename.
+\r\rCheck to ensure the name includes no more than 8 valid characters. Choose OK to ignore this error."
+errBadConName, "Invalid config filename.
+\r\rCheck to ensure the name includes no more than 8 valid characters. Choose OK to ignore this error."
+errBadNumberMR, "Numbers entered are invalid.
+\r\rKB Required numbers must be -1, or between 0 and 640."
+errBadNumberMD, "Numbers entered are invalid.
+\r\rKB Preferred numbers must be -1, or between 0 and 640."
+errBadNumberP, "Numbers entered are invalid.
+\r\rPriorities must be between 1 and 10000."
+errBadNumberXEMSR, "Numbers entered are invalid.
+\r\rKB Required numbers must be between 0 and 16384."
+errBadNumberXEMSD, "Numbers entered are invalid.
+\r\rKB Limit numbers must be -1, or between 0 and 16384."
+IS386,"Windows is not running in enhanced mode. The PIF information you enter may not be appropriate. Are you sure you want to switch to this mode?"
+IS286,"Windows is not running in standard mode. The PIF information you enter may not be appropriate. Are you sure you want to switch to this mode?"
+errBadAutoPath, "The path entered for the Autoexec Filename is invalid.
+\r\rCheck the path name for correctness."
+errBadConfigPath, "The path entered for the Config Filename is invalid.
+\r\rCheck the path name for correctness."
+PIFCAPTION, "PIF Editor - "
+PIFCAPTIONADV, "Advanced Options"
+PIFCAPTIONNT, "Windows NT Options"
+NTSYSTEMROOT, "%SystemRoot%"
+NTSYSTEM32, "\\SYSTEM32\\"
+NTAUTOEXECFILE, "AUTOEXEC.NT"
+NTCONFIGFILE, "CONFIG.NT"
+PIFBADFIL,"This is an invalid Windows PIF. If you save it, PIF Editor will convert it and information not relevant to Windows may be lost."
+PIFOLDFIL,"This file is an old Windows PIF. If you save it, PIF Editor will convert it to the new PIF format."
+WARNCLOSE,"Allowing applications to be closed when active can result in loss of data, and damage to your disk. Are you sure you want to allow this?"
+NONE, "None"
+BADHK, "Invalid shortcut key.
+\r\rPress F1 to determine valid keys or consult your documentation."
+errWrongExt,"This file does not have the .PIF filename extension. Are you sure you want to open this file?"
+WININISECT, "PIFEDIT"
+WININIADV, "advanced"
+WININION, "yes"
+MENUMNEMONIC1, "F"
+MENUMNEMONIC2, "M"
+MENUMNEMONIC3, "H"
+/* This is the char used to separate elements in the Shortcut Key control */
+KEYSEPCHAR, "+"
+NOMODE386, "Cannot switch to enhanced mode."
+NOMODENT, "Insufficient memory to invoke Windows NT options."
+NOMODE286, "Cannot switch to standard mode."
+NOTITLE, "(Untitled)"
+PIFCANCELSTRNG, "Cancel"
+PIFDONESTRNG, "Close"
+END
+
+ID_PIF386TEMPLATE DIALOG PRELOAD 0, 0, 252, 171
+STYLE WS_CHILD | DS_LOCALEDIT
+FONT 8,"MS Sans Serif"
+BEGIN
+ LTEXT "&Program Filename:", 900, 6, 4, 80, 10
+ EDITTEXT IDI_ENAME, 88, 2, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "Window &Title:", 901, 6, 19, 80, 10
+ EDITTEXT IDI_ETITLE, 88, 17, 120, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL
+
+ LTEXT "&Optional Parameters:",902, 6, 34, 80, 10
+ EDITTEXT IDI_EPARM, 88, 32, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "&Startup Directory:", 903, 6, 49, 80, 10
+ EDITTEXT IDI_EPATH, 88, 47, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "&Video Memory:", 921, 6, 65, 56, 10
+ RADIOBUTTON "Text", IDI_VMODETXT, 69, 63, 28, 12, WS_TABSTOP | WS_GROUP
+ RADIOBUTTON "Low Graphics", IDI_VMODELRGRFX, 109, 63, 60, 12
+ RADIOBUTTON "High Graphics",IDI_VMODEHRGRFX, 177, 63, 64, 12
+
+ LTEXT "Memory Requirements:", 904, 6, 78, 82, 10
+ LTEXT "KB &Required", 905, 89, 78, 50, 10
+ EDITTEXT IDI_MEMREQ, 144, 76, 18, 12, WS_TABSTOP | WS_GROUP
+ LTEXT "KB Preferre&d", 906, 170, 78, 49, 10
+ EDITTEXT IDI_MEMDES, 222, 76, 18, 12, WS_TABSTOP | WS_GROUP
+
+ LTEXT "EMS Memory:", 909, 6, 92, 56, 10
+ LTEXT "&KB Required", 910, 89, 92, 46, 10
+ EDITTEXT IDI_EMSREQ, 136, 91, 28, 12, WS_TABSTOP | WS_GROUP
+ LTEXT "KB &Limit", 911, 170, 92, 30, 10
+ EDITTEXT IDI_EMSDES, 212, 91, 28, 12, WS_TABSTOP | WS_GROUP
+
+ LTEXT "XMS Memory:", 912, 6,107, 56, 10
+ LTEXT "KB Re&quired", 913, 89,107, 46, 10
+ EDITTEXT IDI_XMAREQ, 136,106, 28, 12, WS_TABSTOP | WS_GROUP
+ LTEXT "KB L&imit", 914, 170,107, 30, 10
+ EDITTEXT IDI_XMADES, 212,106, 28, 12, WS_TABSTOP | WS_GROUP
+
+ LTEXT "Display Usage:", 907, 6,121, 56, 10
+ RADIOBUTTON "F&ull Screen", IDI_FSCR, 63,120, 55, 12, WS_TABSTOP | WS_GROUP
+ RADIOBUTTON "&Windowed", IDI_WND, 63,132, 48, 12
+
+ LTEXT "Execution:", 915, 149,121, 38, 10
+ /* INTL IDI_BACK Used to size main wnd Enh Right */
+ CHECKBOX "&Background", IDI_BACK, 190,120, 51, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "&Exclusive", IDI_EXCL, 190,132, 50, 12, WS_TABSTOP
+
+ CHECKBOX "&Close Window on Exit",IDI_EXIT, 6, 148, 97, 13, WS_TABSTOP | WS_GROUP
+ PUSHBUTTON "&Advanced...", IDI_ADVANCED, 122, 147, 52, 15, WS_TABSTOP | WS_GROUP
+ PUSHBUTTON "Windows &NT...", IDI_NT, 180, 147, 59, 15, WS_TABSTOP | WS_GROUP
+END
+
+/*
+ * NOTE to LOCALIZERS and INTERNATIONAL!!!!
+ *
+ * the IDI_OTHGRP box is used to determine advanced dialog box bottom and
+ * right edges. If you need more space in the dialog (for swedish
+ * "Prioriterad nar aktiv" for example), then you MUST GROW THE IDI_OTHGRP
+ * control AS WELL AS the Dialog template! Otherwise your new dialog size
+ * will not take effect.
+ */
+
+ID_PIF386ADVTEMPLT DIALOG 05, 20, 290, 201
+STYLE DS_LOCALEDIT | WS_OVERLAPPED | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU
+FONT 8,"MS Sans Serif"
+BEGIN
+ GROUPBOX "Multitasking Options", 143, 3, 3,219, 39, WS_GROUP
+
+ LTEXT "&Background Priority:", 908, 6, 15, 73, 10
+ EDITTEXT IDI_BPRI, 80, 14, 28, 12, WS_TABSTOP | WS_GROUP
+
+ LTEXT "&Foreground Priority:", 916, 113, 15, 73, 10
+ EDITTEXT IDI_FPRI, 187, 14, 28, 12, WS_TABSTOP | WS_GROUP
+
+ CHECKBOX "&Detect Idle Time", IDI_POLL, 76, 28, 76, 12, WS_TABSTOP | WS_GROUP
+
+
+ GROUPBOX "Memory Options", 144, 3, 43,256, 38, WS_GROUP
+
+ CHECKBOX "EMS Memory Loc&ked", IDI_EMSLOCKED, 22, 54,100, 12, WS_TABSTOP | WS_GROUP
+
+ CHECKBOX "XMS Memory L&ocked", IDI_XMSLOCKED, 147, 54,100, 12, WS_TABSTOP
+
+ CHECKBOX "Uses &High Memory Area", IDI_NOHMA, 22, 66,107, 12, WS_TABSTOP
+ CHECKBOX "&Lock Application Memory",IDI_VMLOCKED, 147, 66,108, 12, WS_TABSTOP
+
+
+ GROUPBOX "Display Options", 145, 3, 82,256, 38, WS_GROUP
+
+ LTEXT "Monitor Por&ts:", 924, 6, 94, 56, 10
+ CHECKBOX "Text", IDI_TRAPTXT, 76, 92, 28, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "Low Graphics", IDI_TRAPLRGRFX, 116, 92, 60, 12
+ CHECKBOX "High Graphics", IDI_TRAPHRGRFX, 184, 92, 64, 12
+
+ CHECKBOX "&Emulate Text Mode", IDI_TEXTEMULATE, 47,105, 85, 12, WS_TABSTOP
+ CHECKBOX "Retain Video &Memory", IDI_RETAINALLO, 136,105, 92, 12, WS_TABSTOP
+
+
+ /*
+ * INTL IDI_OTHGRP Used to Size adv wnd Bottom & Right
+ *
+ * NOTE to LOCALIZERS!!!!
+ *
+ * the IDI_OTHGRP box is used to determine advanced dialog box bottom and
+ * right edges. If you need more space in the dialog (for swedish
+ * "Prioriterad nar aktiv" for example), then you MUST GROW THE IDI_OTHGRP
+ * control AS WELL AS the Dialog template!
+ */
+ GROUPBOX "Other Options", IDI_OTHGRP, 3,121,256, 81, WS_GROUP
+
+ CHECKBOX "Allow Fast &Paste", IDI_INT16PST, 6,131, 74, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "Allow &Close When Active", IDI_CLOSE, 146,131,103, 12, WS_TABSTOP
+
+ LTEXT "Reserve &Shortcut Keys:", 918, 6,146, 88, 10
+ CHECKBOX "Alt+Tab", IDI_ALTTAB, 95,145, 40, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "PrtSc", IDI_PRTSC, 95,157, 33, 12, WS_TABSTOP
+ CHECKBOX "Alt+Enter", IDI_ALTENTER, 95,169, 47, 12, WS_TABSTOP
+ CHECKBOX "Alt+Esc", IDI_ALTESC, 139,145, 39, 12, WS_TABSTOP
+
+ /* INTL IDI_ALTPRTSC Used to size main wnd std Bottom */
+ CHECKBOX "Alt+PrtSc", IDI_ALTPRTSC, 139,157, 45, 12, WS_TABSTOP
+ CHECKBOX "Ctrl+Esc", IDI_CTRLESC, 188,145, 43, 12, WS_TABSTOP
+ CHECKBOX "Alt+Space", IDI_ALTSPACE, 188,157, 49, 12, WS_TABSTOP
+
+ LTEXT "&Application Shortcut Key:", 917, 6,185, 96, 10
+ CONTROL "", IDI_HOTKEY, "PifHKy", WS_BORDER | WS_TABSTOP | WS_CHILD | WS_GROUP, 103, 184, 116, 12
+
+
+ DEFPUSHBUTTON "OK", IDOK, 227, 8, 32, 14, WS_TABSTOP | WS_GROUP
+ PUSHBUTTON "Cancel", IDADVCANCEL, 227, 27, 32, 14, WS_TABSTOP
+END
+
+
+ID_PIFNTTEMPLT DIALOG 20, 7, 298, 65
+STYLE DS_LOCALEDIT | WS_OVERLAPPED | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU
+FONT 8,"MS Sans Serif"
+BEGIN
+
+ GROUPBOX "Custom MS-DOS Initialization Files", IDI_DOS,3, 3, 229, 47, WS_GROUP
+
+ LTEXT "&Autoexec Filename:", 919, 6, 16, 70, 10
+ EDITTEXT IDI_AUTOEXEC, 75, 15, 150, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "&Config Filename:", 920, 6, 32, 70, 10
+ EDITTEXT IDI_CONFIG, 75, 31, 150, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ /* INTL CHECKBOX Used to Size NT wnd bottom */
+ CHECKBOX "Compatible &Timer Hardware Emulation", IDI_NTTIMER, 3, 54, 140, 10, WS_TABSTOP | BS_CHECKBOX
+
+ /* INTL IDNTOK Used to Size NT wnd Right */
+ DEFPUSHBUTTON "OK", IDNTOK, 237, 7, 32, 14, WS_TABSTOP | WS_GROUP
+
+ PUSHBUTTON "Cancel", IDNTCANCEL, 237, 26, 32, 14, WS_TABSTOP
+END
+
+
+ID_PIF286TEMPLATE DIALOG PRELOAD 0, 0, 261, 180
+STYLE WS_CHILD | DS_LOCALEDIT
+FONT 8,"MS Sans Serif"
+BEGIN
+ LTEXT "&Program Filename:", 900, 6, 4, 80, 10
+ EDITTEXT IDI_ENAME, 90, 2, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "Window &Title:", 901, 6, 19, 80, 10
+ EDITTEXT IDI_ETITLE, 90, 17, 120, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL
+
+ LTEXT "&Optional Parameters:", 902, 6, 34, 80, 10
+ EDITTEXT IDI_EPARM, 90, 32, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "&Startup Directory:", 903, 6, 49, 80, 10
+ EDITTEXT IDI_EPATH, 90, 47, 152, 12, WS_TABSTOP | WS_GROUP | ES_AUTOHSCROLL | ES_OEMCONVERT
+
+ LTEXT "&Video Mode:", 930, 6, 63, 53, 10
+ RADIOBUTTON "Text", IDI_PSTEXT, 90, 62, 37, 12, WS_TABSTOP | WS_GROUP
+ RADIOBUTTON "Graphics/Multiple Text", IDI_PSGRAPH, 128, 62, 108, 12
+
+ LTEXT "Memory Requirements:", 904, 6, 77, 83, 10
+ LTEXT "KB &Required", 905, 90, 77, 45, 10
+ EDITTEXT IDI_MEMREQ, 136, 76, 18, 12, WS_TABSTOP | WS_GROUP
+
+ LTEXT "XMS Memory:", 912, 6, 92, 56, 10
+ LTEXT "KB Re&quired", 913, 90, 92, 45, 10
+ EDITTEXT IDI_XMAREQ, 136, 91, 28, 12, WS_TABSTOP | WS_GROUP
+ LTEXT "KB L&imit", 914, 176, 92, 29, 10
+ EDITTEXT IDI_XMADES, 206, 91, 28, 12, WS_TABSTOP | WS_GROUP
+
+/*
+ * LTEXT "EMS Memory:", 909, 6, 106, 56, 10
+ * LTEXT "KB Require&d", 910, 90, 106, 45, 10
+ * EDITTEXT IDI_EMSREQ, 136, 105, 28, 12, WS_TABSTOP | WS_GROUP
+ * LTEXT "KB &Limit", 911, 176, 106, 29, 10
+ * EDITTEXT IDI_EMSDES, 206, 105, 28, 12, WS_TABSTOP | WS_GROUP
+ */
+
+ LTEXT "Directly Modifies:", 907, 6, 107, 70, 10
+ CHECKBOX "COM&1", IDI_DMCOM1, 90, 106, 46, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "COM&2", IDI_DMCOM2, 90, 118, 46, 12, WS_TABSTOP
+ CHECKBOX "COM&3", IDI_DMCOM3, 139, 106, 41, 12, WS_TABSTOP
+ CHECKBOX "COM&4", IDI_DMCOM4, 139, 118, 43, 12, WS_TABSTOP
+ CHECKBOX "&Keyboard", IDI_DMKBD, 188, 106, 46, 12, WS_TABSTOP
+
+ CHECKBOX "No Screen &Exchange", IDI_SENONE, 6, 130, 92, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "Prevent Program S&witch",IDI_PSNONE, 122, 130, 105, 12, WS_TABSTOP
+ CHECKBOX "&Close Window on Exit", IDI_EXIT, 6, 142, 97, 12, WS_TABSTOP
+ CHECKBOX "&No Save Screen", IDI_NOSAVVID,122, 142, 97, 12, WS_TABSTOP
+
+ LTEXT "Reserve Shortc&ut Keys:",918, 6, 156, 83, 10
+ CHECKBOX "Alt+Tab", IDI_ALTTAB, 90, 155, 40, 12, WS_TABSTOP | WS_GROUP
+ CHECKBOX "PrtSc", IDI_PRTSC, 90, 167, 33, 12, WS_TABSTOP
+ CHECKBOX "Alt+Esc", IDI_ALTESC, 139, 155, 39, 12, WS_TABSTOP
+ CHECKBOX "Alt+PrtSc", IDI_ALTPRTSC,139, 167, 45, 12, WS_TABSTOP
+ CHECKBOX "Ctrl+Esc", IDI_CTRLESC, 188, 155, 43, 12, WS_TABSTOP
+END
diff --git a/private/mvdm/vdmutils/pifedit/pifedit.rcv b/private/mvdm/vdmutils/pifedit/pifedit.rcv
new file mode 100644
index 000000000..eeb04bd0f
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifedit.rcv
@@ -0,0 +1,18 @@
+/********************************************************************/
+/* PIFEDIT.RCV */
+/* Version control data generated from layouts.dat */
+/********************************************************************/
+// #include <version.h>
+#include <ntverp.h>
+
+
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE VFT_UNKNOWN
+#define VER_FILEDESCRIPTION_STR "Windows Program Information File Editor application file"
+#define VER_INTERNALNAME_STR "PIFEDIT"
+#define VER_LEGALCOPYRIGHT_YEARS "1991-1993"
+#define VER_ORIGINALFILENAME_STR "PIFEDIT.EXE"
+
+
+
+#include <common.ver>
diff --git a/private/mvdm/vdmutils/pifedit/pifhelp.h b/private/mvdm/vdmutils/pifedit/pifhelp.h
new file mode 100644
index 000000000..41df9b437
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifhelp.h
@@ -0,0 +1,145 @@
+#define PIFHELPFILENAME "PIFEDIT.HLP"
+
+/* Menu commands main window */
+#define M_OPEN 10
+#define M_SAVE 11
+#define M_NEW 12
+#define M_SAVEAS 13
+#define M_ABOUT 14 /* NOTE this is actually on help menu */
+#define M_EXIT 15
+#define M_AHELP 16 /* Item ID for F1 help key */
+#define M_286 17
+#define M_386 18
+
+/* Special HELP Menu item IDs */
+#define M_286HELP 0x0022
+#define M_386HELP 0x0023
+#define M_386AHELP 0x0024
+#define M_SHELP 0x0025
+#define M_NTHELP 0x0026
+#define M_INDXHELP 0xFFFF
+#define M_HELPHELP 0xFFFC
+
+/* Values used only for status bar text, these are for the main menu items */
+#define M_SYSMENUMAIN 19
+#define M_FILEMENU 20
+#define M_MODEMENU 21
+#define M_HELPMENU 22
+#define M_SYSMENUADV 23
+#define M_SYSMENUNT M_SYSMENUADV
+#define SC_CLOSEADV 24
+#define SC_NTCLOSE 25
+
+/* Help Index IDs */
+#define IDXID_286HELP 0x0050
+#define IDXID_386HELP 0x0051
+#define IDXID_386AHELP 0x0052
+#define IDXID_NTHELP 0x0053
+
+/* Special */
+#define IDI_ADVANCED 90
+#define IDI_NT 91
+
+/* edit fields IDs main windows (both 286 and 386) */
+#define IDI_ENAME 100
+#define IDI_ETITLE 101
+#define IDI_EPARM 102
+#define IDI_EPATH 103 /* Used to size main wnd std Right */
+#define IDI_MEMREQ 104
+#define IDI_MEMDES 105
+
+/* "directly modifies" checkbox group 286 */
+/* #define IDI_DMSCREEN 200 */
+#define IDI_DMCOM1 201
+/* #define IDI_DM8087 202 */
+#define IDI_DMKBD 203
+#define IDI_DMCOM2 204
+/* #define IDI_DMMEM 205 */
+#define IDI_DMCOM3 206
+#define IDI_DMCOM4 207
+
+/* Program switch radio group 286 */
+#define IDI_PSFIRST 300
+#define IDI_PSNONE 300
+#define IDI_PSTEXT 301
+#define IDI_PSGRAPH 302
+#define IDI_PSLAST 302
+#define IDI_NOSAVVID 308
+
+/* Screen exchange radio group 286 */
+/* #define IDI_SEFIRST 400 */
+#define IDI_SENONE 400
+/* #define IDI_SETEXT 401 */
+/* #define IDI_SEGRAPH 402 */
+/* #define IDI_SELAST 402 */
+
+/* Close window checkbox group 286/386 */
+#define IDI_EXIT 500 /* Used to size main wnd Enh Bottom */
+
+/* WIN386 group */
+#define IDI_OTHGRP 600 /* Used to Size adv wnd Bottom & Right*/
+#define IDI_FPRI 601
+#define IDI_BPRI 602
+#define IDI_POLL 603
+#define IDI_EMSREQ 604
+#define IDI_EMSDES 605
+#define IDI_EMSLOCKED 606
+#define IDI_XMAREQ 607
+#define IDI_XMADES 608
+#define IDI_XMSLOCKED 609
+#define IDI_BACK 610 /* Used to size main wnd Enh Right */
+#define IDI_WND 611
+#define IDI_FSCR 612
+#define IDI_EXCL 613
+#define IDI_CLOSE 614
+#define IDI_HOTKEY 615
+#define IDI_ALTTAB 616
+#define IDI_ALTESC 617
+#define IDI_ALTENTER 618
+#define IDI_ALTSPACE 619
+#define IDI_ALTPRTSC 620 /* Used to size main wnd std Bottom */
+#define IDI_PRTSC 621
+#define IDI_CTRLESC 622
+#define IDI_NOHMA 623
+#define IDI_INT16PST 624
+#define IDI_VMLOCKED 625
+/* WIN386 VIDEO GROUP */
+#define IDI_TEXTEMULATE 700
+#define IDI_TRAPTXT 701
+#define IDI_TRAPLRGRFX 702
+#define IDI_TRAPHRGRFX 703
+#define IDI_RETAINALLO 704
+#define IDI_VMODETXT 705
+#define IDI_VMODELRGRFX 706
+#define IDI_VMODEHRGRFX 707
+
+/* Windows NT group */
+#define IDI_AUTOEXEC 800
+#define IDI_CONFIG 801
+#define IDI_DOS 802
+#define IDI_NTTIMER 803 /* Used to size NT wnd Bottom */
+
+/*
+ * HELP Aliases.
+ *
+ * Some of the items have the same ID in both 286 and 386 mode, but
+ * the help is different depending on the mode (286 help != 386 help
+ * for this item). These are the ALIASES for these items so that we
+ * can pass a different ID when in 286 mode.
+ *
+ */
+#define IDI_MEMREQ_286ALIAS 900
+
+#define IDI_XMAREQ_286ALIAS 901
+#define IDI_XMADES_286ALIAS 902
+
+#define IDI_ALTTAB_286ALIAS 903
+#define IDI_ALTESC_286ALIAS 904
+#define IDI_ALTPRTSC_286ALIAS 905
+#define IDI_PRTSC_286ALIAS 906
+#define IDI_CTRLESC_286ALIAS 907
+
+/*
+ *#define IDI_EMSREQ_286ALIAS 908
+ *#define IDI_EMSDES_286ALIAS 909
+ */
diff --git a/private/mvdm/vdmutils/pifedit/pifsubs.c b/private/mvdm/vdmutils/pifedit/pifsubs.c
new file mode 100644
index 000000000..674b31865
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/pifsubs.c
@@ -0,0 +1,2280 @@
+#define NOSOUND
+#define NOCOMM
+#include "pifedit.h"
+
+extern int SetHotKeyTextFromPIF(void);
+extern int delete(PSTR);
+extern BOOL UpdateHotKeyStruc(void);
+extern unsigned char *PutUpDB(int);
+extern void SetStatusText(HWND,int,BOOL);
+extern void InvalidateAllStatus(void);
+extern int CmdArgAddCorrectExtension(unsigned char *);
+extern HINSTANCE hPifInstance;
+extern HWND hwndPifDlg;
+extern HWND hwndAdvPifDlg;
+extern HWND hwndNTPifDlg;
+extern HWND hMainwnd;
+extern HWND hParentWnd;
+extern BOOL CurrMode386;
+extern BOOL NewHotKey;
+extern BOOL FileChanged;
+extern BOOL DoingMsg;
+extern unsigned char rgchInsMem[80];
+extern unsigned char rgchTitle[60];
+extern unsigned char CurPifFile[];
+extern unsigned char PifBuf[];
+extern unsigned char NTSys32Root[];
+extern BOOL AdvClose;
+extern BOOL NTClose;
+extern unsigned InMemHotKeyScan;
+extern unsigned InMemHotKeyShVal;
+extern unsigned InMemHotKeyShMsk;
+extern int FocusIDAdv;
+extern int FocusIDNT;
+extern WORD fileoffset;
+extern WORD extoffset;
+
+extern PIFNEWSTRUCT UNALIGNED *PifFile;
+extern PIF386EXT UNALIGNED *Pif386ext;
+extern PIFWNTEXT UNALIGNED *PifNText;
+/*
+ * extern PIF286EXT31 *Pif286ext31;
+ */
+extern PIF286EXT30 UNALIGNED *Pif286ext30;
+extern BOOL fNoNTAWarn;
+extern BOOL fNTAWarnne;
+extern BOOL fNoNTCWarn;
+extern BOOL fNTCWarnne;
+
+int InitPif386Struc(void);
+int InitPifNTStruc(void);
+int InitPif286Struc(void);
+int InitStdPIFExt(void);
+int InitPifStruct(void);
+BOOL ValidFileSpec(LPSTR lpstr, int iCaller);
+BOOL ExpandFileSpec(LPSTR lpstrExp, LPSTR lpstr, int errID);
+
+unsigned int WarningSem = 0;
+
+PIFEXTHEADER UNALIGNED *LastPifExt;
+unsigned PifFileSize;
+
+char stdHdr[] = STDHDRSIG;
+char w386Hdr[] = W386HDRSIG;
+char w286Hdr30[] = W286HDRSIG30;
+char wNTHdr[] = WNTHDRSIG31;
+/*
+ * char w286Hdr31[] = W286HDRSIG31;
+ */
+
+/* char *SCANNames[] = { "00h","01h","02h","03h","04h","05h","06h","07h",
+ "08h","09h","0Ah","0Bh","0Ch","0Dh","0Eh","0Fh",
+ "10h","11h","12h","13h","14h","15h","16h","17h",
+ "18h","19h","1Ah","1Bh","1Ch","1Dh","1Eh","1Fh",
+ "20h","21h","22h","23h","24h","25h","26h","27h",
+ "28h","29h","2Ah","2Bh","2Ch","2Dh","2Eh","2Fh",
+ "30h","31h","32h","33h","34h","35h","36h","37h",
+ "38h","39h","3Ah","3Bh","3Ch","3Dh","3Eh","3Fh",
+ "40h","41h","42h","43h","44h","45h","46h","47h",
+ "48h","49h","4Ah","4Bh","4Ch","4Dh","4Eh","4Fh",
+ "50h","51h","52h","53h","54h","55h","56h","57h",
+ "58h","59h","5Ah","5Bh","5Ch","5Dh","5Eh","5Fh",
+ "60h","61h","62h","63h","64h","65h","66h","67h",
+ "68h","69h","6Ah","6Bh","6Ch","6Dh","6Eh","6Fh",
+ "70h","71h","72h","73h","74h","75h","76h","77h",
+ "78h","79h","7Ah","7Bh","7Ch","7Dh","7Eh","7Fh",
+ "80h","81h","82h","83h","84h","85h","86h","87h",
+ "88h","89h","8Ah","8Bh","8Ch","8Dh","8Eh","8Fh",
+ "90h","91h","92h","93h","94h","95h","96h","97h",
+ "98h","99h","9Ah","9Bh","9Ch","9Dh","9Eh","9Fh",
+ "A0h","A1h","A2h","A3h","A4h","A5h","A6h","A7h",
+ "A8h","A9h","AAh","ABh","ACh","ADh","AEh","AFh",
+ "B0h","B1h","B2h","B3h","B4h","B5h","B6h","B7h",
+ "B8h","B9h","BAh","BBh","BCh","BDh","BEh","BFh",
+ "C0h","C1h","C2h","C3h","C4h","C5h","C6h","C7h",
+ "C8h","C9h","CAh","CBh","CCh","CDh","CEh","CFh",
+ "D0h","D1h","D2h","D3h","D4h","D5h","D6h","D7h",
+ "D8h","D9h","DAh","DBh","DCh","DDh","DEh","DFh",
+ "E0h","E1h","E2h","E3h","E4h","E5h","E6h","E7h",
+ "E8h","E9h","EAh","EBh","ECh","EDh","EEh","EFh",
+ "F0h","F1h","F2h","F3h","F4h","F5h","F6h","F7h",
+ "F8h","F9h","FAh","FBh","FCh","FDh","FEh","FFh" }; */
+
+
+
+void SetFileOffsets(unsigned char *nmptr,WORD *fileoff,WORD *extoff)
+{
+ unsigned char *pch;
+ unsigned char ch;
+
+ pch = nmptr+lstrlen((LPSTR)nmptr);
+ while ((ch = *pch) != '\\' && ch != ':' && pch > nmptr)
+ pch = (unsigned char *)AnsiPrev((LPSTR)nmptr, (LPSTR)pch);
+ if((ch = *pch) == '\\' || ch == ':')
+ pch++;
+ *fileoff = pch - nmptr;
+ *extoff = 0;
+ while ((ch = *pch) != '.' && ch != '\0')
+ pch = (unsigned char *)AnsiNext((LPSTR)pch);
+ if(ch == '.') {
+ pch++;
+ if(*pch == '\0')
+ return;
+ else
+ *extoff = pch - nmptr;
+ }
+}
+
+
+int Warning(int ID,WORD type)
+{
+
+ unsigned char buf[500];
+ int retval;
+ BOOL MsgFlagSav;
+
+ if(hParentWnd != hMainwnd) {
+ if(!WarningSem) {
+ EnableWindow(hMainwnd,FALSE);
+ }
+ WarningSem++;
+
+ }
+ MsgFlagSav = DoingMsg;
+ DoingMsg = TRUE;
+ if(MsgFlagSav != DoingMsg)
+ InvalidateAllStatus();
+ if(ID == EINSMEMORY) {
+ retval = MessageBox(hParentWnd, (LPSTR)rgchInsMem, (LPSTR)rgchTitle, type);
+ } else if(LoadString(hPifInstance, ID, (LPSTR)buf, sizeof(buf))) {
+ retval = MessageBox(hParentWnd, (LPSTR)buf, (LPSTR)rgchTitle, type);
+ } else {
+ MessageBox(hParentWnd, (LPSTR)rgchInsMem, (LPSTR)rgchTitle, MB_ICONEXCLAMATION | MB_OK);
+ retval = IDCANCEL;
+ }
+ if(hParentWnd != hMainwnd) {
+ if(WarningSem == 1) {
+ EnableWindow(hMainwnd,TRUE);
+ }
+ WarningSem--;
+ }
+ if(retval == 0) { /* map messagebox failure to cancel */
+ retval = IDCANCEL;
+ }
+ if(MsgFlagSav != DoingMsg) {
+ DoingMsg = MsgFlagSav;
+ InvalidateAllStatus();
+ } else {
+ DoingMsg = MsgFlagSav;
+ }
+ return(retval);
+}
+
+
+PIFWNTEXT UNALIGNED *AllocInitNTExt(void)
+{
+ PIFWNTEXT UNALIGNED *extNT;
+ char buf[PIFDEFPATHSIZE*2];
+ char buf2[PIFDEFPATHSIZE*4];
+
+ if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIFWNTEXT) + sizeof(PIFEXTHEADER))) {
+ return((PIFWNTEXT *)NULL);
+ }
+
+ LastPifExt->extnxthdrfloff = PifFileSize;
+
+ LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
+
+ LastPifExt->extnxthdrfloff = LASTHEADERPTR;
+ LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
+ LastPifExt->extsizebytes = sizeof(PIFWNTEXT);
+ lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)wNTHdr);
+ PifFileSize += sizeof(PIFWNTEXT) + sizeof(PIFEXTHEADER);
+
+ extNT = (PIFWNTEXT *)(PifBuf + LastPifExt->extfileoffset);
+
+ extNT->dwWNTFlags = 0;
+ extNT->dwRes1 = 0;
+ extNT->dwRes2 = 0;
+ fNoNTAWarn = FALSE;
+ fNTAWarnne = FALSE;
+ fNoNTCWarn = FALSE;
+ fNTCWarnne = FALSE;
+
+ lstrcpy((LPTSTR)buf2, (LPCTSTR)NTSys32Root);
+ if(LoadString(hPifInstance, NTAUTOEXECFILE, (LPSTR)buf, PIFDEFPATHSIZE-1)) {
+ lstrcat((LPTSTR)buf2, (LPCTSTR)buf);
+ AnsiToOem(buf2, (LPTSTR)extNT->achAutoexecFile);
+ }
+
+ lstrcpy((LPTSTR)buf2, (LPCTSTR)NTSys32Root);
+ if(LoadString(hPifInstance, NTCONFIGFILE, (LPSTR)buf, PIFDEFPATHSIZE-1)) {
+ lstrcat((LPTSTR)buf2, (LPCTSTR)buf);
+ AnsiToOem(buf2, (LPTSTR)extNT->achConfigFile);
+ }
+
+ return(extNT);
+
+}
+
+
+PIF386EXT UNALIGNED *AllocInit386Ext(void)
+{
+ PIF386EXT UNALIGNED *ext386;
+ unsigned char *src,*dst;
+ int i;
+
+ if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF386EXT) + sizeof(PIFEXTHEADER))) {
+ return((PIF386EXT *)NULL);
+ }
+
+ LastPifExt->extnxthdrfloff = PifFileSize;
+
+ LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
+
+ LastPifExt->extnxthdrfloff = LASTHEADERPTR;
+ LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
+ LastPifExt->extsizebytes = sizeof(PIF386EXT);
+ lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w386Hdr);
+ PifFileSize += sizeof(PIF386EXT) + sizeof(PIFEXTHEADER);
+
+ ext386 = (PIF386EXT *)(PifBuf + LastPifExt->extfileoffset);
+
+ dst = (PUCHAR)ext386->params;
+ src = (PUCHAR)(((PIFOLD286STR *)PifBuf)->params);
+ for(i=0;i<PIFPARAMSSIZE;i++)
+ *dst++ = *src++;
+
+ ext386->maxmem = 640;
+ ext386->minmem = 128;
+ ext386->PfFPriority = 100;
+ ext386->PfBPriority = 50;
+ ext386->PfMaxEMMK = 1024;
+ ext386->PfMinEMMK = 0;
+ ext386->PfMaxXmsK = 1024;
+ ext386->PfMinXmsK = 0;
+ ext386->PfW386Flags = fFullScreen | fPollingDetect | fINT16Paste;
+ if(Pif286ext30) {
+ if(Pif286ext30->PfW286Flags & fALTTABdis286)
+ ext386->PfW386Flags |= fALTTABdis;
+ if(Pif286ext30->PfW286Flags & fALTESCdis286)
+ ext386->PfW386Flags |= fALTESCdis;
+ if(Pif286ext30->PfW286Flags & fCTRLESCdis286)
+ ext386->PfW386Flags |= fCTRLESCdis;
+ if(Pif286ext30->PfW286Flags & fALTPRTSCdis286)
+ ext386->PfW386Flags |= fALTPRTSCdis;
+ if(Pif286ext30->PfW286Flags & fPRTSCdis286)
+ ext386->PfW386Flags |= fPRTSCdis;
+ }
+ ext386->PfW386Flags2 = fVidTxtEmulate | fVidNoTrpTxt | fVidNoTrpLRGrfx
+ | fVidTextMd;
+ /*
+ * The following is if( > EGA), then don't trap Hi Res graphics ports
+ * The setting of this bit is irrelevant on HERC CGA and PLASMA,
+ * so the fact that these guys also get "caught" by this doesn't
+ * matter. EGA is the only low res guy that matters.
+ *
+ */
+ if(GetSystemMetrics(SM_CYSCREEN) > 350) {
+ ext386->PfW386Flags2 |= fVidNoTrpHRGrfx;
+ }
+ ext386->PfHotKeyScan = 0;
+ ext386->PfHotKeyShVal = 0;
+ ext386->PfHotKeyShMsk = 0;
+ InMemHotKeyScan = 0;
+ InMemHotKeyShVal = 0;
+ InMemHotKeyShMsk = 0;
+ NewHotKey = FALSE;
+ SetHotKeyTextFromPIF();
+ return(ext386);
+
+}
+
+PIF286EXT30 UNALIGNED *AllocInit286Ext30(void)
+{
+ PIF286EXT30 UNALIGNED *ext286;
+
+ if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF286EXT30) + sizeof(PIFEXTHEADER))) {
+ return((PIF286EXT30 *)NULL);
+ }
+
+ LastPifExt->extnxthdrfloff = PifFileSize;
+
+ LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
+
+ LastPifExt->extnxthdrfloff = LASTHEADERPTR;
+ LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
+ LastPifExt->extsizebytes = sizeof(PIF286EXT30);
+ lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w286Hdr30);
+ PifFileSize += sizeof(PIF286EXT30) + sizeof(PIFEXTHEADER);
+
+ ext286 = (PIF286EXT30 *)(PifBuf + LastPifExt->extfileoffset);
+
+ ext286->PfMaxXmsK = 0;
+ ext286->PfMinXmsK = 0;
+ ext286->PfW286Flags = 0;
+ if(Pif386ext) {
+ if(Pif386ext->PfW386Flags & fALTTABdis)
+ ext286->PfW286Flags |= fALTTABdis286;
+ if(Pif386ext->PfW386Flags & fALTESCdis)
+ ext286->PfW286Flags |= fALTESCdis286;
+ if(Pif386ext->PfW386Flags & fCTRLESCdis)
+ ext286->PfW286Flags |= fCTRLESCdis286;
+ if(Pif386ext->PfW386Flags & fALTPRTSCdis)
+ ext286->PfW286Flags |= fALTPRTSCdis286;
+ if(Pif386ext->PfW386Flags & fPRTSCdis)
+ ext286->PfW286Flags |= fPRTSCdis286;
+ }
+ return(ext286);
+}
+
+/*
+ * PIF286EXT31 *AllocInit286Ext31(void)
+ * {
+ * PIF286EXT31 *ext286;
+ *
+ * if(PifFileSize >= PIFEDITMAXPIF - (sizeof(PIF286EXT31) + sizeof(PIFEXTHEADER))) {
+ * return((PIF286EXT31 *)NULL);
+ * }
+ *
+ * LastPifExt->extnxthdrfloff = PifFileSize;
+ *
+ * LastPifExt = (PIFEXTHEADER *)(PifBuf + PifFileSize);
+ *
+ * LastPifExt->extnxthdrfloff = LASTHEADERPTR;
+ * LastPifExt->extfileoffset = PifFileSize + sizeof(PIFEXTHEADER);
+ * LastPifExt->extsizebytes = sizeof(PIF286EXT31);
+ * lstrcpy((LPSTR)LastPifExt->extsig,(LPSTR)w286Hdr31);
+ * PifFileSize += sizeof(PIF286EXT31) + sizeof(PIFEXTHEADER);
+ *
+ * ext286 = (PIF286EXT31 *)(PifBuf + LastPifExt->extfileoffset);
+ *
+ * ext286->PfMaxEmsK = 0;
+ * ext286->PfMinEmsK = 0;
+ * return(ext286);
+ * }
+ */
+
+UpdatePifScreenAdv(void)
+{
+ unsigned char rgch[200];
+
+ if(hwndAdvPifDlg) {
+ if(!AdvClose) {
+ if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndAdvPifDlg,IDCANCEL,(LPSTR)rgch);
+ }
+ AdvClose = TRUE;
+ if(FocusIDAdv == IDCANCEL) {
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ }
+ }
+ if(CurrMode386) {
+ SetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, Pif386ext->PfFPriority, FALSE);
+ SetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, Pif386ext->PfBPriority, FALSE);
+ CheckDlgButton(hwndAdvPifDlg, IDI_POLL, Pif386ext->PfW386Flags & fPollingDetect ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_CLOSE, Pif386ext->PfW386Flags & fEnableClose ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_ALTTAB, Pif386ext->PfW386Flags & fALTTABdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_ALTESC, Pif386ext->PfW386Flags & fALTESCdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_CTRLESC, Pif386ext->PfW386Flags & fCTRLESCdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_ALTSPACE, Pif386ext->PfW386Flags & fALTSPACEdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_ALTENTER, Pif386ext->PfW386Flags & fALTENTERdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_ALTPRTSC, Pif386ext->PfW386Flags & fALTPRTSCdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_PRTSC, Pif386ext->PfW386Flags & fPRTSCdis ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_NOHMA, Pif386ext->PfW386Flags & fNoHMA ? FALSE : TRUE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_INT16PST, Pif386ext->PfW386Flags & fINT16Paste ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_VMLOCKED, Pif386ext->PfW386Flags & fVMLocked ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_XMSLOCKED, Pif386ext->PfW386Flags & fXMSLocked ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_EMSLOCKED, Pif386ext->PfW386Flags & fEMSLocked ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_TEXTEMULATE, Pif386ext->PfW386Flags2 & fVidTxtEmulate ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_RETAINALLO, Pif386ext->PfW386Flags2 & fVidRetainAllo ? TRUE : FALSE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_TRAPTXT, Pif386ext->PfW386Flags2 & fVidNoTrpTxt ? FALSE : TRUE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_TRAPLRGRFX, Pif386ext->PfW386Flags2 & fVidNoTrpLRGrfx ? FALSE : TRUE );
+ CheckDlgButton(hwndAdvPifDlg, IDI_TRAPHRGRFX, Pif386ext->PfW386Flags2 & fVidNoTrpHRGrfx ? FALSE : TRUE );
+ SetHotKeyTextFromPIF();
+ } else {
+
+ }
+ }
+ return(TRUE);
+}
+
+
+UpdatePifScreenNT(void)
+{
+ unsigned char rgch[PIFDEFPATHSIZE*4];
+
+ if(hwndNTPifDlg) {
+ if(!NTClose) {
+ if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndNTPifDlg,IDCANCEL,(LPSTR)rgch);
+ }
+ NTClose = TRUE;
+ if(FocusIDNT == IDCANCEL) {
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ }
+ }
+ if(CurrMode386) {
+ OemToAnsi((LPCTSTR)PifNText->achAutoexecFile, rgch);
+ SetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,(LPCTSTR)rgch);
+ OemToAnsi((LPCTSTR)PifNText->achConfigFile, rgch);
+ SetDlgItemText(hwndNTPifDlg,IDI_CONFIG,(LPCTSTR)rgch);
+ CheckDlgButton(hwndNTPifDlg, IDI_NTTIMER, (PifNText->dwWNTFlags & COMPAT_TIMERTIC));
+ } else {
+
+ }
+ }
+ return(TRUE);
+}
+
+
+/* make the screen match the structure */
+UpdatePifScreen(void)
+{
+ unsigned char rgch[200];
+ int i;
+
+ /*
+ * make sure of nul terminator before calling OemToAnsi
+ */
+ PifFile->startfile[PIFSTARTLOCSIZE-1] = '\0';
+ OemToAnsi((LPSTR)PifFile->startfile,(LPSTR)rgch);
+ SetDlgItemText(hwndPifDlg, IDI_ENAME, (LPSTR)rgch);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_SETMODIFY, FALSE, 0L);
+ /*
+ * NOTE: the PifFile->name field MAY NOT be nul terminated!!!!!!
+ */
+ for(i = 0;i < PIFNAMESIZE; i++)
+ rgch[i] = PifFile->name[i];
+ rgch[i] = '\0';
+ OemToAnsi((LPSTR)rgch,(LPSTR)rgch);
+ SetDlgItemText(hwndPifDlg, IDI_ETITLE, (LPSTR)rgch);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_SETMODIFY, FALSE, 0L);
+ /*
+ * make sure of nul terminator before calling OemToAnsi
+ */
+ PifFile->defpath[PIFDEFPATHSIZE-1] = '\0';
+ OemToAnsi((LPSTR)PifFile->defpath,(LPSTR)rgch);
+ SetDlgItemText(hwndPifDlg, IDI_EPATH, (LPSTR)rgch);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_SETMODIFY, FALSE, 0L);
+ CheckDlgButton(hwndPifDlg, IDI_EXIT , PifFile->MSflags & EXITMASK ? TRUE : FALSE );
+ if(CurrMode386) {
+ /*
+ * make sure of nul terminator before calling OemToAnsi
+ */
+ Pif386ext->params[PIFPARAMSSIZE-1] = '\0';
+ OemToAnsi((LPSTR)Pif386ext->params,(LPSTR)rgch);
+ SetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)rgch);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
+ SetDlgItemInt(hwndPifDlg, IDI_MEMREQ, Pif386ext->minmem, TRUE);
+ if (Pif386ext->maxmem) {
+ SetDlgItemInt(hwndPifDlg, IDI_MEMDES, Pif386ext->maxmem, TRUE);
+ } else {
+ SetDlgItemText(hwndPifDlg, IDI_MEMDES, (LPSTR)"");
+ }
+ CheckRadioButton(hwndPifDlg, IDI_WND, IDI_FSCR,Pif386ext->PfW386Flags & fFullScreen ? IDI_FSCR : IDI_WND);
+ CheckDlgButton(hwndPifDlg, IDI_BACK, Pif386ext->PfW386Flags & fBackground ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_EXCL, Pif386ext->PfW386Flags & fExclusive ? TRUE : FALSE );
+ if (Pif386ext->PfW386Flags2 & fVidTextMd ) {
+ CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODETXT);
+ } else if (Pif386ext->PfW386Flags2 & fVidLowRsGrfxMd) {
+ CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODELRGRFX);
+ } else {
+ CheckRadioButton(hwndPifDlg, IDI_VMODETXT, IDI_VMODEHRGRFX, IDI_VMODEHRGRFX);
+ }
+ SetDlgItemInt(hwndPifDlg, IDI_EMSREQ, Pif386ext->PfMinEMMK, FALSE);
+ SetDlgItemInt(hwndPifDlg, IDI_EMSDES, Pif386ext->PfMaxEMMK, TRUE);
+ SetDlgItemInt(hwndPifDlg, IDI_XMAREQ, Pif386ext->PfMinXmsK, FALSE);
+ SetDlgItemInt(hwndPifDlg, IDI_XMADES, Pif386ext->PfMaxXmsK, TRUE);
+ UpdatePifScreenAdv();
+ UpdatePifScreenNT();
+ } else {
+ /*
+ * make sure of nul terminator before calling OemToAnsi
+ */
+ PifFile->params[PIFPARAMSSIZE-1] = '\0';
+ OemToAnsi((LPSTR)PifFile->params,(LPSTR)rgch);
+ SetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)rgch);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
+ SetDlgItemInt(hwndPifDlg, IDI_MEMREQ, PifFile->minmem, TRUE);
+/*
+ * if (PifFile->maxmem) {
+ * SetDlgItemInt(hwndPifDlg, IDI_MEMDES, PifFile->maxmem, TRUE);
+ * } else {
+ * SetDlgItemText(hwndPifDlg, IDI_MEMDES, (LPSTR)"");
+ * }
+ * CheckDlgButton(hwndPifDlg, IDI_DMSCREEN, PifFile->behavior & SCRMASK ? TRUE : FALSE );
+ * CheckDlgButton(hwndPifDlg, IDI_DMMEM , PifFile->MSflags & MEMMASK ? TRUE : FALSE );
+ */
+
+ CheckDlgButton(hwndPifDlg, IDI_DMKBD , PifFile->behavior & KEYMASK ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM1 , PifFile->MSflags & COM1MASK ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM2 , PifFile->MSflags & COM2MASK ? TRUE : FALSE );
+ if(Pif286ext30) {
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM3 , Pif286ext30->PfW286Flags & fCOM3_286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM4 , Pif286ext30->PfW286Flags & fCOM4_286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTTAB, Pif286ext30->PfW286Flags & fALTTABdis286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTESC, Pif286ext30->PfW286Flags & fALTESCdis286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_CTRLESC, Pif286ext30->PfW286Flags & fCTRLESCdis286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTPRTSC, Pif286ext30->PfW286Flags & fALTPRTSCdis286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_PRTSC, Pif286ext30->PfW286Flags & fPRTSCdis286 ? TRUE : FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_NOSAVVID, Pif286ext30->PfW286Flags & fNoSaveVid286 ? TRUE : FALSE );
+ SetDlgItemInt(hwndPifDlg, IDI_XMAREQ, Pif286ext30->PfMinXmsK, FALSE);
+ SetDlgItemInt(hwndPifDlg, IDI_XMADES, Pif286ext30->PfMaxXmsK, TRUE);
+ } else {
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM3 , FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_DMCOM4 , FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTTAB, FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTESC, FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_CTRLESC, FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_ALTPRTSC, FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_PRTSC, FALSE );
+ CheckDlgButton(hwndPifDlg, IDI_NOSAVVID, FALSE );
+ SetDlgItemText(hwndPifDlg, IDI_XMAREQ, (LPSTR)"0");
+ SetDlgItemText(hwndPifDlg, IDI_XMADES, (LPSTR)"0");
+ }
+ /*
+ * if(Pif286ext31) {
+ * SetDlgItemInt(hwndPifDlg, IDI_EMSREQ, Pif286ext31->PfMinEmsK, FALSE);
+ * SetDlgItemInt(hwndPifDlg, IDI_EMSDES, Pif286ext31->PfMaxEmsK, TRUE);
+ * } else {
+ * SetDlgItemText(hwndPifDlg, IDI_EMSREQ, (LPSTR)"0");
+ * SetDlgItemText(hwndPifDlg, IDI_EMSDES, (LPSTR)"0");
+ * }
+ */
+ if (PifFile->MSflags & SGMASK) {
+ CheckDlgButton(hwndPifDlg, IDI_SENONE, TRUE);
+ } else {
+ CheckDlgButton(hwndPifDlg, IDI_SENONE, FALSE);
+ }
+ if (PifFile->MSflags & PSMASK) {
+ CheckDlgButton(hwndPifDlg, IDI_PSNONE, TRUE);
+ } else {
+ CheckDlgButton(hwndPifDlg, IDI_PSNONE, FALSE);
+ }
+
+ CheckRadioButton(hwndPifDlg, IDI_PSTEXT, IDI_PSGRAPH,
+ (PifFile->sysmem < 16 ? IDI_PSTEXT : IDI_PSGRAPH));
+
+/*
+ * if (PifFile->MSflags & SGMASK) {
+ * CheckRadioButton(hwndPifDlg, IDI_SEFIRST, IDI_SELAST, IDI_SENONE);
+ * } else {
+ * CheckRadioButton(hwndPifDlg, IDI_SEFIRST, IDI_SELAST,
+ * (PifFile->MSflags & GRAPHMASK ? IDI_SEGRAPH : IDI_SETEXT));
+ * }
+ *
+ * if (PifFile->MSflags & PSMASK) {
+ * CheckRadioButton(hwndPifDlg, IDI_PSFIRST, IDI_PSLAST, IDI_PSNONE);
+ * } else {
+ * CheckRadioButton(hwndPifDlg, IDI_PSFIRST, IDI_PSLAST,
+ * (PifFile->sysmem < 16 ? IDI_PSTEXT : IDI_PSGRAPH));
+ * }
+ */
+
+
+ }
+ return(TRUE);
+}
+
+
+BOOL UpdateParms(unsigned char *parmPtr)
+{
+ int cch;
+ unsigned char *pch;
+ BOOL result;
+
+ result = FALSE;
+
+ if (SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_GETMODIFY, 0, 0L))
+ result = TRUE;
+
+ cch = GetDlgItemText(hwndPifDlg, IDI_EPARM, (LPSTR)parmPtr, PIFPARAMSSIZE);
+ AnsiToOem((LPSTR)parmPtr,(LPSTR)parmPtr);
+ /*
+ * Trim leading spaces
+ */
+ for (pch = parmPtr; *pch == ' '; pch=AnsiNext(pch))
+ ;
+ lstrcpy((LPSTR)parmPtr, (LPSTR)pch);
+ /*
+ * Point to last char
+ */
+ for (pch = parmPtr; *pch; pch=AnsiNext(pch))
+ ;
+ if (pch > parmPtr)
+ pch =AnsiPrev(parmPtr,pch);
+ /*
+ * Trim trailing spaces
+ */
+ while (*pch == ' ' && pch > parmPtr)
+ pch=AnsiPrev(parmPtr,pch);
+ *++pch = 0;
+
+ cch = pch - parmPtr;
+ if(!CurrMode386) {
+ if (cch) {
+ PifFile->sysflags |= PARMMASK;
+ } else {
+ PifFile->sysflags &= NOTPARMMASK;
+ }
+ }
+ if (cch) {
+ pch++;
+ cch++;
+ }
+
+ /*
+ * Space pad out to full field width
+ */
+ for ( ; cch <PIFPARAMSSIZE; ++pch, ++cch)
+ *pch = ' ';
+ return(result);
+}
+
+
+void FixString(LPSTR lpstrIn)
+{
+ int i;
+ char str[PIFDEFPATHSIZE*2];
+ LPSTR lpstr;
+
+ lpstr = lpstrIn;
+
+ while(*lpstr == ' ')
+ lpstr++;
+
+ i = 0;
+ while((*lpstr != '\0') && (*lpstr != ' ')) {
+ str[i++] = *lpstr++;
+ }
+
+ str[i] = '\0';
+
+ lstrcpy(lpstrIn, str);
+
+ // don't Uppercase environment vars
+ i = lstrlen(lpstrIn)-1;
+ while(i > 0) {
+ if(lpstrIn[i] == '%') {
+ i++;
+ break;
+ }
+ i--;
+ }
+
+ AnsiUpper(&(lpstrIn[i]));
+}
+
+
+
+
+BOOL UpdatePifNTStruc(void)
+{
+ BOOL result;
+ char rgch[60];
+ char szFile[PIFDEFPATHSIZE*2];
+
+ result = FALSE; /* did anything change? */
+
+ if(hwndNTPifDlg) {
+ if(!NTClose) {
+ if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndNTPifDlg,IDCANCEL,(LPSTR)rgch);
+ }
+ NTClose = TRUE;
+ if(FocusIDNT == IDCANCEL) {
+ SetStatusText(hwndNTPifDlg,FocusIDNT,TRUE);
+ }
+ }
+ GetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,szFile,PIFDEFPATHSIZE-1);
+ FixString(szFile);
+ AnsiToOem(szFile, szFile);
+ if(lstrcmp((LPTSTR)PifNText->achAutoexecFile, (LPCTSTR)szFile)) {
+ lstrcpy((LPTSTR)PifNText->achAutoexecFile, (LPCTSTR)szFile);
+ fNoNTAWarn = FALSE;
+ fNTAWarnne = FALSE;
+ result = TRUE;
+ }
+
+ GetDlgItemText(hwndNTPifDlg,IDI_CONFIG,szFile,PIFDEFPATHSIZE-1);
+ FixString(szFile);
+ AnsiToOem(szFile, szFile);
+ if(lstrcmp((LPTSTR)PifNText->achConfigFile, (LPCTSTR)szFile)) {
+ lstrcpy((LPTSTR)PifNText->achConfigFile, (LPCTSTR)szFile);
+ fNoNTCWarn = FALSE;
+ fNTCWarnne = FALSE;
+ result = TRUE;
+ }
+
+ // is checkbox checked?
+ if(IsDlgButtonChecked(hwndNTPifDlg, IDI_NTTIMER)) {
+ // if it wasn't, note the change
+ if(!(PifNText->dwWNTFlags & COMPAT_TIMERTIC)) {
+ result = TRUE;
+ }
+ PifNText->dwWNTFlags |= COMPAT_TIMERTIC; // mark it as checked
+ }
+ else {
+ if(PifNText->dwWNTFlags & COMPAT_TIMERTIC) {
+ result = TRUE;
+ }
+ PifNText->dwWNTFlags &= ~COMPAT_TIMERTIC;
+ }
+
+ }
+
+ return(result);
+}
+
+
+
+BOOL UpdatePif386Struc(void)
+{
+ int result, i;
+ unsigned int u;
+ unsigned long W386flags;
+ char rgch[60];
+ BOOL iresult;
+
+ result = FALSE; /* did anything change? */
+
+
+ if(UpdateParms((PUCHAR)Pif386ext->params))
+ result = TRUE;
+
+ /*
+ * Return of zero here ignored (set IDI_MEMREQ to 0)
+ */
+ ;
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&iresult, TRUE))
+ != Pif386ext->minmem) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->minmem = i;
+ }
+ }
+
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&iresult, TRUE))
+ != Pif386ext->maxmem) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->maxmem = i;
+ }
+ }
+
+ if(UpdateHotKeyStruc())
+ result = TRUE;
+
+ W386flags = Pif386ext->PfW386Flags;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_FSCR))
+ W386flags |= fFullScreen;
+ else
+ W386flags &= ~fFullScreen;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_EXCL))
+ W386flags |= fExclusive;
+ else
+ W386flags &= ~fExclusive;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_BACK))
+ W386flags |= fBackground;
+ else
+ W386flags &= ~fBackground;
+
+ if ((u = GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&iresult, FALSE))
+ != (UINT)Pif386ext->PfMinEMMK) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfMinEMMK = u;
+ }
+ }
+
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&iresult, TRUE))
+ != Pif386ext->PfMaxEMMK) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfMaxEMMK = i;
+ }
+ }
+
+ if ((u = GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&iresult, FALSE))
+ != (UINT)Pif386ext->PfMinXmsK) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfMinXmsK = u;
+ }
+ }
+
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&iresult, TRUE))
+ != Pif386ext->PfMaxXmsK) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfMaxXmsK = i;
+ }
+ }
+
+ if(hwndAdvPifDlg) {
+ if(!AdvClose) {
+ if(!LoadString(hPifInstance, PIFDONESTRNG , (LPSTR)rgch, sizeof(rgch))) {
+ Warning(EINSMEMORY,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+ SetDlgItemText(hwndAdvPifDlg,IDCANCEL,(LPSTR)rgch);
+ }
+ AdvClose = TRUE;
+ if(FocusIDAdv == IDCANCEL) {
+ SetStatusText(hwndAdvPifDlg,FocusIDAdv,TRUE);
+ }
+ }
+
+ if ((u = GetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, (BOOL FAR *)&iresult, FALSE))
+ != (UINT)Pif386ext->PfFPriority) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfFPriority = u;
+ }
+ }
+
+ if ((u = GetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, (BOOL FAR *)&iresult, FALSE))
+ != (UINT)Pif386ext->PfBPriority) {
+ if(iresult) {
+ result = TRUE;
+ Pif386ext->PfBPriority = u;
+ }
+ }
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_POLL))
+ W386flags |= fPollingDetect;
+ else
+ W386flags &= ~fPollingDetect;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTTAB))
+ W386flags |= fALTTABdis;
+ else
+ W386flags &= ~fALTTABdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTESC))
+ W386flags |= fALTESCdis;
+ else
+ W386flags &= ~fALTESCdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_CTRLESC))
+ W386flags |= fCTRLESCdis;
+ else
+ W386flags &= ~fCTRLESCdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTSPACE))
+ W386flags |= fALTSPACEdis;
+ else
+ W386flags &= ~fALTSPACEdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTENTER))
+ W386flags |= fALTENTERdis;
+ else
+ W386flags &= ~fALTENTERdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_ALTPRTSC))
+ W386flags |= fALTPRTSCdis;
+ else
+ W386flags &= ~fALTPRTSCdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_PRTSC))
+ W386flags |= fPRTSCdis;
+ else
+ W386flags &= ~fPRTSCdis;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_NOHMA))
+ W386flags &= ~fNoHMA;
+ else
+ W386flags |= fNoHMA;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_INT16PST))
+ W386flags |= fINT16Paste;
+ else
+ W386flags &= ~fINT16Paste;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_VMLOCKED))
+ W386flags |= fVMLocked;
+ else
+ W386flags &= ~fVMLocked;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_CLOSE))
+ W386flags |= fEnableClose;
+ else
+ W386flags &= ~fEnableClose;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_EMSLOCKED))
+ W386flags |= fEMSLocked;
+ else
+ W386flags &= ~fEMSLocked;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_XMSLOCKED))
+ W386flags |= fXMSLocked;
+ else
+ W386flags &= ~fXMSLocked;
+ }
+
+ if((Pif386ext->PfHotKeyScan != 0)||(Pif386ext->PfHotKeyShVal != 0)||(Pif386ext->PfHotKeyShMsk != 0))
+ W386flags |= fHasHotKey;
+ else
+ W386flags &= ~fHasHotKey;
+
+ if (W386flags != Pif386ext->PfW386Flags) {
+ Pif386ext->PfW386Flags = W386flags;
+ result = TRUE;
+ }
+
+ W386flags = Pif386ext->PfW386Flags2;
+
+ W386flags &= ~(fVidTextMd | fVidLowRsGrfxMd | fVidHghRsGrfxMd);
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_VMODETXT))
+ W386flags |= fVidTextMd;
+ else if (IsDlgButtonChecked(hwndPifDlg, IDI_VMODELRGRFX))
+ W386flags |= fVidLowRsGrfxMd;
+ else
+ W386flags |= fVidHghRsGrfxMd;
+
+ if(hwndAdvPifDlg) {
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_RETAINALLO))
+ W386flags |= fVidRetainAllo;
+ else
+ W386flags &= ~fVidRetainAllo;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TEXTEMULATE))
+ W386flags |= fVidTxtEmulate;
+ else
+ W386flags &= ~fVidTxtEmulate;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPTXT))
+ W386flags &= ~fVidNoTrpTxt;
+ else
+ W386flags |= fVidNoTrpTxt;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPLRGRFX))
+ W386flags &= ~fVidNoTrpLRGrfx;
+ else
+ W386flags |= fVidNoTrpLRGrfx;
+
+ if (IsDlgButtonChecked(hwndAdvPifDlg, IDI_TRAPHRGRFX))
+ W386flags &= ~fVidNoTrpHRGrfx;
+ else
+ W386flags |= fVidNoTrpHRGrfx;
+
+ }
+ if (W386flags != Pif386ext->PfW386Flags2) {
+ Pif386ext->PfW386Flags2 = W386flags;
+ result = TRUE;
+ }
+
+ return(result);
+}
+
+/* make the structure match the screen */
+BOOL UpdatePifStruct(void)
+{
+ unsigned char rgch[200];
+ int cch;
+ unsigned char *pch;
+ char flags;
+ unsigned flags2;
+ int result;
+ BOOL iresult;
+ int i;
+ unsigned int u;
+
+ result = FALSE; /* did anything change? */
+
+ if (SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_GETMODIFY, 0, 0L))
+ result = TRUE;
+ cch = GetDlgItemText(hwndPifDlg, IDI_ENAME, (LPSTR)PifFile->startfile, PIFSTARTLOCSIZE);
+ AnsiUpper((LPSTR)PifFile->startfile);
+ AnsiToOem((LPSTR)PifFile->startfile,(LPSTR)PifFile->startfile);
+ /*
+ * Trim off leading spaces
+ */
+ for (pch = (PUCHAR)PifFile->startfile; *pch == ' '; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
+ ;
+ lstrcpy((LPTSTR)PifFile->startfile, (LPCTSTR)pch);
+ /*
+ * Point to last char of string
+ */
+ for (pch = (PUCHAR)PifFile->startfile; *pch; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
+ ;
+ if (pch > PifFile->startfile)
+ pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->startfile,(LPCTSTR)pch);
+ /*
+ * Trim trailing spaces
+ */
+ while (*pch == ' ' && pch > PifFile->startfile)
+ pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->startfile,(LPCTSTR)pch);
+ pch=AnsiNext(pch);
+ *pch++ = 0;
+ /*
+ * Space pad out to full field width
+ */
+ for (cch = pch - PifFile->startfile; cch < PIFSTARTLOCSIZE; ++cch)
+ *pch++ = ' ';
+ if (SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_GETMODIFY, 0, 0L))
+ result = TRUE;
+ cch = GetDlgItemText(hwndPifDlg, IDI_ETITLE, (LPSTR)rgch, PIFNAMESIZE+1);
+ AnsiToOem((LPSTR)rgch,(LPSTR)rgch);
+ /*
+ * NOTE: the PifFile->name field will NOT be nul terminated if it is
+ * PIFNAMESIZE bytes long
+ *
+ * Trim off leading spaces
+ */
+ for (pch = rgch; *pch == ' '; pch=AnsiNext(pch))
+ ;
+ lstrcpy((LPSTR)rgch, (LPSTR)pch);
+ /*
+ * Point to last char of string
+ */
+ for (pch = rgch; *pch; pch=AnsiNext(pch))
+ ;
+ if (pch > rgch)
+ pch =AnsiPrev(rgch,pch);
+ /*
+ * Trim trailing spaces
+ */
+ while (*pch == ' ' && pch > rgch)
+ pch=AnsiPrev(rgch,pch);
+ pch=AnsiNext(pch);
+ *pch++ = '\0';
+ /*
+ * Space pad out to full field width
+ */
+ for (cch = pch - rgch; cch < PIFNAMESIZE; ++cch)
+ *pch++ = ' ';
+ for(i = 0;i < PIFNAMESIZE; i++)
+ PifFile->name[i] = rgch[i];
+ if (SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_GETMODIFY, 0, 0L))
+ result = TRUE;
+ cch = GetDlgItemText(hwndPifDlg, IDI_EPATH, (LPSTR)PifFile->defpath, PIFDEFPATHSIZE-1);
+ AnsiUpper((LPSTR)PifFile->defpath);
+ AnsiToOem((LPSTR)PifFile->defpath,(LPSTR)PifFile->defpath);
+ /*
+ * Trim off leading spaces
+ */
+ for (pch = (PUCHAR)PifFile->defpath;*pch == ' '; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
+ ;
+ lstrcpy((LPSTR)PifFile->defpath, (LPSTR)pch);
+ /*
+ * Point to last char of string
+ */
+ for (pch = (PUCHAR)PifFile->defpath; *pch; pch=(PUCHAR)AnsiNext((LPCTSTR)pch))
+ ;
+ if (pch > PifFile->defpath)
+ pch = (PUCHAR)AnsiPrev((LPCTSTR)PifFile->defpath,(LPCTSTR)pch);
+ /*
+ * Trim trailing spaces
+ */
+ while (*pch == ' ' && pch > PifFile->defpath)
+ pch = (PUCHAR)AnsiPrev((LPCTSTR)PifFile->defpath,(LPCTSTR)pch);
+ pch = (PUCHAR)AnsiNext((LPCTSTR)pch);
+ *pch++ = 0;
+ /*
+ * Space pad out to full field width
+ */
+ for (cch = pch - PifFile->defpath; cch < PIFDEFPATHSIZE; ++cch)
+ *pch++ = ' ';
+
+ flags = PifFile->MSflags;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_EXIT))
+ flags |= EXITMASK;
+ else
+ flags &= NOTEXITMASK;
+
+ if(CurrMode386) {
+ if(UpdatePif386Struc())
+ result = TRUE;
+ if(UpdatePifNTStruc())
+ result = TRUE;
+ } else {
+ if(UpdateParms((PUCHAR)PifFile->params))
+ result = TRUE;
+
+ /*
+ * Return of zero here ignored (set IDI_MEMREQ to 0)
+ */
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&iresult, TRUE))
+ != PifFile->minmem) {
+ if(iresult) {
+ result = TRUE;
+ PifFile->minmem = i;
+ }
+ }
+
+ /*
+ * if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&iresult, TRUE))
+ * != PifFile->maxmem) {
+ * if(iresult) {
+ * result = TRUE;
+ * PifFile->maxmem = i;
+ * }
+ * }
+ */
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_PSNONE)) {
+ flags |= PSMASK;
+ } else {
+ flags &= NOTPSMASK;
+ }
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_SENONE)) {
+ flags |= SGMASK; /* disable screen grabber */
+ } else {
+ flags &= NOTSGMASK;
+ }
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_PSTEXT) ) {
+ if (PifFile->sysmem >= 16)
+ PifFile->sysmem = 7;
+ flags &= TEXTMASK;
+ } else {
+ if (PifFile->sysmem < 16)
+ PifFile->sysmem = 23;
+ flags |= GRAPHMASK;
+ }
+
+/*
+ * if (IsDlgButtonChecked(hwndPifDlg, IDI_PSNONE)) {
+ * flags |= PSMASK;
+ * } else {
+ * flags &= NOTPSMASK;
+ * if ((IsDlgButtonChecked(hwndPifDlg, IDI_PSTEXT)) && (PifFile->sysmem >= 16))
+ * PifFile->sysmem = 7;
+ * else if ((IsDlgButtonChecked(hwndPifDlg, IDI_PSGRAPH)) && (PifFile->sysmem < 16) )
+ * PifFile->sysmem = 23;
+ * }
+ *
+ * if (IsDlgButtonChecked(hwndPifDlg, IDI_SENONE)) {
+ * flags |= SGMASK;
+ * } else if (IsDlgButtonChecked(hwndPifDlg, IDI_SETEXT)) {
+ * flags &= TEXTMASK;
+ * flags &= NOTSGMASK;
+ * } else if (IsDlgButtonChecked(hwndPifDlg, IDI_SEGRAPH)) {
+ * flags |= GRAPHMASK;
+ * flags &= NOTSGMASK;
+ * }
+ *
+ * if (IsDlgButtonChecked(hwndPifDlg, IDI_DMSCREEN)) {
+ * if (!(PifFile->behavior & SCRMASK))
+ * result = TRUE;
+ * PifFile->behavior |= SCRMASK;
+ * } else {
+ * if (PifFile->behavior & SCRMASK)
+ * result = TRUE;
+ * PifFile->behavior &= NOTSCRMASK;
+ * }
+ *
+ * if (IsDlgButtonChecked(hwndPifDlg, IDI_DMMEM))
+ * flags |= MEMMASK;
+ * else
+ * flags &= NOTMEMMASK;
+ */
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_DMKBD)) {
+ if (!(PifFile->behavior & KEYMASK))
+ result = TRUE;
+ PifFile->behavior |= KEYMASK;
+ } else {
+ if (PifFile->behavior & KEYMASK)
+ result = TRUE;
+ PifFile->behavior &= NOTKEYMASK;
+ }
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM1))
+ flags |= COM1MASK;
+ else
+ flags &= NOTCOM1MASK;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM2))
+ flags |= COM2MASK;
+ else
+ flags &= NOTCOM2MASK;
+
+ if(Pif286ext30) {
+
+ flags2 = 0;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_NOSAVVID))
+ flags2 |= fNoSaveVid286;
+ else
+ flags2 &= ~fNoSaveVid286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM3))
+ flags2 |= fCOM3_286;
+ else
+ flags2 &= ~fCOM3_286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_DMCOM4))
+ flags2 |= fCOM4_286;
+ else
+ flags2 &= ~fCOM4_286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTTAB))
+ flags2 |= fALTTABdis286;
+ else
+ flags2 &= ~fALTTABdis286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTESC))
+ flags2 |= fALTESCdis286;
+ else
+ flags2 &= ~fALTESCdis286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_CTRLESC))
+ flags2 |= fCTRLESCdis286;
+ else
+ flags2 &= ~fCTRLESCdis286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_ALTPRTSC))
+ flags2 |= fALTPRTSCdis286;
+ else
+ flags2 &= ~fALTPRTSCdis286;
+
+ if (IsDlgButtonChecked(hwndPifDlg, IDI_PRTSC))
+ flags2 |= fPRTSCdis286;
+ else
+ flags2 &= ~fPRTSCdis286;
+
+ if ((u = GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&iresult, FALSE))
+ != (UINT)Pif286ext30->PfMinXmsK) {
+ if(iresult) {
+ result = TRUE;
+ Pif286ext30->PfMinXmsK = u;
+ }
+ }
+
+ if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&iresult, TRUE))
+ != Pif286ext30->PfMaxXmsK) {
+ if(iresult) {
+ result = TRUE;
+ Pif286ext30->PfMaxXmsK = i;
+ }
+ }
+ if (flags2 != (unsigned)Pif286ext30->PfW286Flags) {
+ Pif286ext30->PfW286Flags = flags2;
+ result = TRUE;
+ }
+ }
+ /*
+ * if(Pif286ext31) {
+ *
+ * if ((u = GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&iresult, FALSE))
+ * != Pif286ext31->PfMinEmsK) {
+ * if(iresult) {
+ * result = TRUE;
+ * Pif286ext31->PfMinEmsK = u;
+ * }
+ * }
+ *
+ * if ((i = (int)GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&iresult, TRUE))
+ * != Pif286ext31->PfMaxEmsK) {
+ * if(iresult) {
+ * result = TRUE;
+ * Pif286ext31->PfMaxEmsK = i;
+ * }
+ * }
+ * }
+ */
+ }
+ if (flags != PifFile->MSflags) {
+ PifFile->MSflags = flags;
+ result = TRUE;
+ }
+ return(result);
+}
+
+BOOL DoFieldsWorkAdv(BOOL all)
+{
+ BOOL result;
+ BOOL result2;
+
+
+ /*
+ * Check to make sure numeric edit controls actually have numbers in them
+ */
+ if(hwndAdvPifDlg) {
+ GetDlgItemInt(hwndAdvPifDlg, IDI_BPRI, (BOOL FAR *)&result, FALSE);
+ GetDlgItemInt(hwndAdvPifDlg, IDI_FPRI, (BOOL FAR *)&result2, FALSE);
+ if((!result) || (!result2)) {
+ Warning(errBadNumberP,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ if (Pif386ext && CurrMode386) {
+ if ((Pif386ext->PfMaxEMMK > 0) && ((int)Pif386ext->PfMinEMMK > Pif386ext->PfMaxEMMK)) {
+ Warning(errEMMMaxMin386,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+
+ if ((Pif386ext->PfMaxXmsK > 0) && ((int)Pif386ext->PfMinXmsK > Pif386ext->PfMaxXmsK)) {
+ Warning(errXMSMaxMin386,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+}
+
+
+
+void SetNTDlgItem(int itemID)
+{
+ HWND hwnd;
+ SetStatusText(hwndNTPifDlg, itemID, TRUE);
+ hwnd = GetDlgItem(hwndNTPifDlg, itemID);
+ SetFocus(hwnd);
+ SendMessage(hwnd, EM_SETSEL,0,-1);
+}
+
+
+
+BOOL DoFieldsWorkNT(BOOL all)
+{
+ UCHAR szFile[PIFDEFPATHSIZE*2];
+ UCHAR szFileExp[PIFDEFPATHSIZE*4];
+ OFSTRUCT of;
+
+
+ /*
+ * Check to make sure Autoexec & Config fields have valid filenames in them
+ */
+ if(hwndNTPifDlg) {
+
+ if(!GetDlgItemText(hwndNTPifDlg,IDI_AUTOEXEC,szFile,PIFDEFPATHSIZE-1)) {
+ if(!fNoNTAWarn) {
+ if(Warning(errNoNTAFile,
+ MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
+ == IDCANCEL) {
+ SetNTDlgItem(IDI_AUTOEXEC);
+ return(FALSE);
+ }
+ else
+ fNoNTAWarn = TRUE;
+ }
+ }
+ else {
+ if(ExpandFileSpec(szFileExp, szFile, errBadAutoPath)) {
+ if(OpenFile(szFileExp,&of,OF_EXIST) == HFILE_ERROR) {
+ if(!fNTAWarnne){
+ if(Warning(errNTAFilene, MB_ICONEXCLAMATION |
+ MB_OKCANCEL |
+ MB_DEFBUTTON2) == IDCANCEL) {
+ SetNTDlgItem(IDI_AUTOEXEC);
+ return(FALSE);
+ }
+ else
+ fNTAWarnne = TRUE;
+ }
+ }
+ }
+ else {
+ SetNTDlgItem(IDI_AUTOEXEC);
+ return(FALSE);
+ }
+ }
+
+ if(!GetDlgItemText(hwndNTPifDlg,IDI_CONFIG,szFile,PIFDEFPATHSIZE-1)) {
+ if(!fNoNTCWarn) {
+ if(Warning(errNoNTCFile,
+ MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
+ == IDCANCEL) {
+ SetNTDlgItem(IDI_CONFIG);
+ return(FALSE);
+ }
+ else
+ fNoNTCWarn = TRUE;
+ }
+ }
+ else {
+ if(ExpandFileSpec(szFileExp, szFile, errBadConfigPath)) {
+ if(OpenFile(szFileExp,&of,OF_EXIST) == HFILE_ERROR) {
+ if(!fNTCWarnne){
+ if(Warning(errNTCFilene, MB_ICONEXCLAMATION |
+ MB_OKCANCEL |
+ MB_DEFBUTTON2) == IDCANCEL) {
+ SetNTDlgItem(IDI_CONFIG);
+ return(FALSE);
+ }
+ else
+ fNTCWarnne = TRUE;
+ }
+ }
+ }
+ else {
+ SetNTDlgItem(IDI_CONFIG);
+ return(FALSE);
+ }
+ }
+ }
+ return(TRUE);
+}
+
+
+BOOL DoFieldsWork(BOOL all)
+{
+ BOOL result;
+ BOOL result2;
+
+ if(!DoFieldsWorkAdv(all))
+ return(FALSE);
+
+ if(!DoFieldsWorkNT(all))
+ return(FALSE);
+
+ /*
+ * Check to make sure numeric edit controls actually have numbers in them
+ */
+ if(hwndPifDlg) {
+ if(CurrMode386) {
+ GetDlgItemInt(hwndPifDlg, IDI_MEMDES, (BOOL FAR *)&result, TRUE);
+ } else {
+ result = TRUE;
+ }
+ GetDlgItemInt(hwndPifDlg, IDI_MEMREQ, (BOOL FAR *)&result2, TRUE);
+ if(!result2) {
+ Warning(errBadNumberMR,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ if(!result) {
+ Warning(errBadNumberMD,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ GetDlgItemInt(hwndPifDlg, IDI_XMADES, (BOOL FAR *)&result, TRUE);
+ GetDlgItemInt(hwndPifDlg, IDI_XMAREQ, (BOOL FAR *)&result2, FALSE);
+ if(!result2) {
+ Warning(errBadNumberXEMSR,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ if(!result) {
+ Warning(errBadNumberXEMSD,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ if(CurrMode386) {
+ GetDlgItemInt(hwndPifDlg, IDI_EMSDES, (BOOL FAR *)&result, TRUE);
+ GetDlgItemInt(hwndPifDlg, IDI_EMSREQ, (BOOL FAR *)&result2, FALSE);
+ if(!result2) {
+ Warning(errBadNumberXEMSR,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ if(!result) {
+ Warning(errBadNumberXEMSD,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ } else {
+ }
+ }
+
+ if (Pif386ext && CurrMode386) {
+ if ((Pif386ext->maxmem > 0) &&
+ ((Pif386ext->minmem == -1) || (Pif386ext->minmem > Pif386ext->maxmem))
+ ) {
+ Warning(errMmMaxMin386,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+
+ if ((PifFile->maxmem > 0) &&
+ ((PifFile->minmem == -1) || (PifFile->minmem > PifFile->maxmem))
+ ) {
+ /*
+ * Warning(errMmMaxMin286,MB_ICONEXCLAMATION | MB_OK);
+ * return(FALSE);
+ */
+ PifFile->maxmem = PifFile->minmem;
+ }
+
+ if (Pif286ext30) {
+ if ((Pif286ext30->PfMaxXmsK > 0) && ((int)Pif286ext30->PfMinXmsK > Pif286ext30->PfMaxXmsK)) {
+ Warning(errXMSMaxMin286,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ /*
+ * if (Pif286ext31) {
+ * if ((Pif286ext31->PfMaxEmsK > 0) && ((int)Pif286ext31->PfMinEmsK > Pif286ext31->PfMaxEmsK)) {
+ * Warning(errEMMMaxMin286,MB_ICONEXCLAMATION | MB_OK);
+ * return(FALSE);
+ * }
+ * }
+ */
+
+ if(all) {
+ if (PifFile->lowVector > PifFile->highVector && (PifFile->sysflags & SWAPMASK)) {
+ Warning(errHiLow,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+
+ if(!ValidFileSpec((LPSTR)PifFile->startfile, errBadProgram))
+ return(FALSE);
+
+ }
+ return(TRUE);
+}
+
+
+
+BOOL ExpandFileSpec(LPSTR lpstrExp, LPSTR lpstr, int errID)
+{
+ int len, cPath;
+ UCHAR sz[PIFDEFPATHSIZE*2];
+ LPSTR psz;
+
+ if(!ValidFileSpec(lpstr, errID)) {
+ return(FALSE);
+ }
+
+ cPath = PIFDEFPATHSIZE * 2;
+ while(*lpstr) {
+
+ if(*lpstr == '%') {
+ lpstr++;
+ lstrcpy(sz, lpstr);
+ psz = &sz[0];
+ while(*psz && (*psz != '%')) {
+ psz++;
+ }
+ if(*psz != '%') {
+ Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
+ return(FALSE);
+ }
+ len = psz - &sz[0];
+ sz[len] = '\0';
+ lpstr += len + 1;
+ if(len = GetEnvironmentVariable(sz, lpstrExp, cPath)) {
+ cPath -= len;
+ if(cPath <= 0) {
+ Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
+ return(FALSE);
+ }
+ lpstrExp += len;
+ }
+ else {
+ Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
+ return(FALSE);
+ }
+ }
+ else {
+ *lpstrExp++ = *lpstr++;
+ cPath--;
+ }
+ if(cPath <= 0) {
+ Warning(errID, MB_ICONEXCLAMATION | MB_OK | MB_DEFBUTTON2);
+ return(FALSE);
+ }
+ }
+
+ *lpstrExp = '\0';
+
+ return(TRUE);
+}
+
+
+
+BOOL ValidFileSpec(LPSTR lpstr, int iCaller)
+{
+ int len;
+ LPSTR pch, pch2;
+ int errID;
+ BOOL fExt = FALSE;
+
+ switch( iCaller ) {
+
+ case errBadAutoPath:
+ errID = errBadAutoName;
+ break;
+
+ case errBadConfigPath:
+ errID = errBadConName;
+ break;
+
+ default:
+ fExt = TRUE;
+ errID = errBadProgram;
+ break;
+ }
+
+
+ len = lstrlen((LPSTR)lpstr);
+ pch = lpstr + len;
+ pch = AnsiPrev(lpstr,pch);
+ while (*pch &&
+ *pch != ':' &&
+ *pch != '.' &&
+ *pch != '\\' &&
+ pch > lpstr)
+ pch=AnsiPrev(lpstr,pch);
+
+ if (*pch != '.') {
+ if(fExt) {
+ if(Warning(errBadExt,MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2)
+ == IDCANCEL)
+ return(FALSE);
+ }
+
+ /*
+ * No extension given, reset pch to end of the string so
+ * following 8 char name check doesn't trip as well unless
+ * it is supposed to.
+ */
+ pch = lpstr + len;
+ }
+ else if(fExt){
+ /*
+ * At this point we know *pch == '.'
+ */
+ if (lstrcmp((LPSTR)(pch+1), (LPSTR)"EXE") &&
+ lstrcmp((LPSTR)(pch+1), (LPSTR)"COM") &&
+ lstrcmp((LPSTR)(pch+1), (LPSTR)"BAT")) {
+
+ if(Warning(errBadExt,MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2)
+ == IDCANCEL)
+ return(FALSE);
+ }
+ }
+
+ if(pch <= lpstr) {
+ if(Warning(errID, MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
+ == IDCANCEL)
+ return(FALSE);
+ }
+ else {
+ for (pch2 = AnsiPrev(lpstr,pch);
+ pch2 > lpstr && *pch2 != '\\' && *pch2 != ':';
+ pch2 = AnsiPrev(lpstr,pch2)) {
+
+ if(*pch2 < ' ' ||
+ *pch2 == '*' ||
+ *pch2 == '?' ||
+ *pch2 == '[' ||
+ *pch2 == ']' ||
+ *pch2 == '>' ||
+ *pch2 == '<' ||
+ *pch2 == '|' ||
+ *pch2 == '"' ||
+ *pch2 == '=' ||
+ *pch2 == '+' ||
+ *pch2 == ';' ||
+ *pch2 == ',' ||
+ *pch2 == '.' ) {
+
+ if(Warning(errID,
+ MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2)
+ == IDCANCEL)
+ return(FALSE);
+ else
+ break; /* from for loop */
+ }
+ }
+
+ if((*pch2 == '\\') || (*pch2 == ':'))
+ pch2=AnsiNext(pch2);
+
+ if (pch - pch2 > 8 || pch - pch2 == 0) {
+ if(Warning(errID,MB_ICONEXCLAMATION | MB_OKCANCEL | MB_DEFBUTTON2) == IDCANCEL)
+ return(FALSE);
+ }
+ }
+
+ return(TRUE);
+}
+
+
+
+ResetStd(void)
+{
+ InitStdPIFExt();
+ InitPif386Struc();
+ InitPif286Struc();
+ InitPifNTStruc();
+ return(TRUE);
+}
+
+
+LoadPifFile(PSTR pchFile)
+{
+ int fh;
+ unsigned char *pch;
+ OFSTRUCT ofReopen;
+ unsigned long fsize;
+ PIFEXTHEADER UNALIGNED *hdrptr;
+ BOOL scandone;
+ BOOL Pif2X = FALSE;
+
+ ofReopen.szPathName[0] = 0;
+ if ((fh = OpenFile((LPSTR)pchFile, (LPOFSTRUCT)&ofReopen, OF_READ | OF_SHARE_DENY_WRITE)) != -1) {
+
+ fsize = _llseek( fh, 0L, 2);
+ _llseek( fh, 0L, 0);
+
+ if(fsize >= PIFEDITMAXPIFL) {
+ Warning(errNoOpen,MB_ICONEXCLAMATION | MB_OK);
+ InitPifStruct();
+ _lclose(fh);
+ return(FALSE);
+ }
+
+ _lread(fh, (LPSTR)PifBuf, PIFEDITMAXPIF);
+
+ FileChanged = FALSE;
+
+ Pif386ext = (PIF386EXT *)NULL;
+ PifNText = (PIFWNTEXT *)NULL;
+ Pif286ext30 = (PIF286EXT30 *)NULL;
+ /*
+ * Pif286ext31 = (PIF286EXT31 *)NULL;
+ */
+
+ PifFileSize = LOWORD(fsize);
+
+ if(fsize < (long)sizeof(PIFOLD286STR)) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ } else if(fsize == (long)sizeof(PIFOLD286STR)) {
+ Warning(PIFOLDFIL,MB_ICONEXCLAMATION | MB_OK);
+ Pif2X = TRUE;
+ ResetStd();
+ FileChanged = TRUE;
+ if(Pif386ext) {
+ Pif386ext->PfHotKeyScan = InMemHotKeyScan = 0;
+ Pif386ext->PfHotKeyShVal = InMemHotKeyShVal = 0;
+ Pif386ext->PfHotKeyShMsk = InMemHotKeyShMsk = 0;
+ if (PifFile->behavior & KEYMASK)
+ Pif386ext->PfW386Flags |= fExclusive;
+ else
+ Pif386ext->PfW386Flags &= ~fExclusive;
+ if (PifFile->MSflags & MEMMASK)
+ Pif386ext->PfW386Flags |= fBackground;
+ else
+ Pif386ext->PfW386Flags &= ~fBackground;
+ if (PifFile->behavior & SCRMASK)
+ Pif386ext->PfW386Flags |= fFullScreen;
+ else
+ Pif386ext->PfW386Flags &= ~fFullScreen;
+ Pif386ext->maxmem = PifFile->maxmem;
+ Pif386ext->minmem = PifFile->minmem;
+ }
+ if(Pif286ext30) {
+ Pif286ext30->PfMaxXmsK = 0;
+ Pif286ext30->PfMinXmsK = 0;
+ Pif286ext30->PfW286Flags = 0;
+ if(Pif386ext) {
+ if(Pif386ext->PfW386Flags & fALTTABdis)
+ Pif286ext30->PfW286Flags |= fALTTABdis286;
+ if(Pif386ext->PfW386Flags & fALTESCdis)
+ Pif286ext30->PfW286Flags |= fALTESCdis286;
+ if(Pif386ext->PfW386Flags & fCTRLESCdis)
+ Pif286ext30->PfW286Flags |= fCTRLESCdis286;
+ if(Pif386ext->PfW386Flags & fALTPRTSCdis)
+ Pif286ext30->PfW286Flags |= fALTPRTSCdis286;
+ if(Pif386ext->PfW386Flags & fPRTSCdis)
+ Pif286ext30->PfW286Flags |= fPRTSCdis286;
+ }
+ }
+ /*
+ * if(Pif286ext31) {
+ * Pif286ext31->PfMaxEmsK = 0;
+ * Pif286ext31->PfMinEmsK = 0;
+ * }
+ */
+ } else {
+ if(lstrcmp((LPSTR)PifFile->stdpifext.extsig, (LPSTR)stdHdr)) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ } else {
+ hdrptr = &PifFile->stdpifext;
+ scandone = FALSE;
+ while(!scandone) {
+ if(hdrptr->extnxthdrfloff == LASTHEADERPTR) {
+ scandone = TRUE;
+ LastPifExt = hdrptr;
+ } else if((unsigned)hdrptr->extnxthdrfloff >= PifFileSize) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ break;
+ }
+ if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w386Hdr)) {
+ if((hdrptr->extsizebytes == sizeof(PIF386EXT)) &&
+ ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIF386EXT))) {
+ Pif386ext = (PIF386EXT *)(PifBuf + hdrptr->extfileoffset);
+ SetHotKeyTextFromPIF();
+ } else {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ break;
+ }
+ } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w286Hdr30)) {
+ if((hdrptr->extsizebytes == sizeof(PIF286EXT30)) &&
+ ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIF286EXT30))) {
+ Pif286ext30 = (PIF286EXT30 *)(PifBuf + hdrptr->extfileoffset);
+ } else {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ break;
+ }
+ } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)wNTHdr)) {
+ if((hdrptr->extsizebytes == sizeof(PIFWNTEXT)) &&
+ ((unsigned)hdrptr->extfileoffset <= PifFileSize - sizeof(PIFWNTEXT))) {
+ PifNText = (PIFWNTEXT *)(PifBuf + hdrptr->extfileoffset);
+ } else {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ FileChanged = TRUE;
+ break;
+ }
+ }
+ /*
+ * } else if(!lstrcmp((LPSTR)hdrptr->extsig, (LPSTR)w286Hdr31)) {
+ * if((hdrptr->extsizebytes == sizeof(PIF286EXT31)) &&
+ * (hdrptr->extfileoffset <= PifFileSize - sizeof(PIF286EXT31))) {
+ * Pif286ext31 = (PIF286EXT31 *)(PifBuf + hdrptr->extfileoffset);
+ * } else {
+ * Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ * ResetStd();
+ * FileChanged = TRUE;
+ * break;
+ * }
+ * }
+ */
+ if(!scandone)
+ hdrptr = (PIFEXTHEADER *)(PifBuf + hdrptr->extnxthdrfloff);
+ }
+ }
+ }
+
+ if(CurrMode386) {
+ if(!Pif386ext) {
+ if(!(Pif386ext = AllocInit386Ext())) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ }
+ FileChanged = TRUE;
+ }
+ } else {
+ /*
+ * if(!Pif286ext31) {
+ * if(Pif286ext30 && !Pif2X)
+ * Warning(PIFOLDFIL2,MB_ICONEXCLAMATION | MB_OK);
+ * if(!(Pif286ext31 = AllocInit286Ext31())) {
+ * Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ * ResetStd();
+ * }
+ * FileChanged = TRUE;
+ * }
+ */
+ if(!Pif286ext30) {
+ if(!(Pif286ext30 = AllocInit286Ext30())) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ }
+ FileChanged = TRUE;
+ }
+ if((PifFile->MSflags & GRAPHMASK) && (PifFile->sysmem <= 16))
+ PifFile->sysmem = 23;
+ if((!(PifFile->MSflags & GRAPHMASK)) && (PifFile->sysmem > 16))
+ PifFile->MSflags |= GRAPHMASK;
+ }
+ if(CurrMode386) {
+ if(!PifNText) {
+ if(!(PifNText = AllocInitNTExt())) {
+ Warning(PIFBADFIL,MB_ICONEXCLAMATION | MB_OK);
+ ResetStd();
+ }
+ //FileChanged = TRUE; //can be confusing if they don't change it
+ }
+ }
+
+ _lclose(fh);
+
+ /* Make sure that we have valid memory values. */
+
+ if (PifFile->minmem != -1) {
+ PifFile->minmem = max(PifFile->minmem, 0);
+ PifFile->minmem = min(PifFile->minmem, 640);
+ }
+ if (PifFile->maxmem != -1) {
+ PifFile->maxmem = max(PifFile->maxmem, 0);
+ PifFile->maxmem = min(PifFile->maxmem, 640);
+ }
+
+ if(Pif386ext) {
+ if (Pif386ext->minmem != -1) {
+ Pif386ext->minmem = max(Pif386ext->minmem, 0);
+ Pif386ext->minmem = min(Pif386ext->minmem, 640);
+ }
+ if (Pif386ext->maxmem != -1) {
+ Pif386ext->maxmem = max(Pif386ext->maxmem, 0);
+ Pif386ext->maxmem = min(Pif386ext->maxmem, 640);
+ }
+
+ Pif386ext->PfMinEMMK = max(Pif386ext->PfMinEMMK, 0);
+ Pif386ext->PfMinEMMK = min(Pif386ext->PfMinEMMK, 16384);
+ Pif386ext->PfMinXmsK = max(Pif386ext->PfMinXmsK, 0);
+ Pif386ext->PfMinXmsK = min(Pif386ext->PfMinXmsK, 16384);
+
+ if (Pif386ext->PfMaxEMMK != -1) {
+ Pif386ext->PfMaxEMMK = max(Pif386ext->PfMaxEMMK, 0);
+ Pif386ext->PfMaxEMMK = min(Pif386ext->PfMaxEMMK, 16384);
+ }
+ if (Pif386ext->PfMaxXmsK != -1) {
+ Pif386ext->PfMaxXmsK = max(Pif386ext->PfMaxXmsK, 0);
+ Pif386ext->PfMaxXmsK = min(Pif386ext->PfMaxXmsK, 16384);
+ }
+ if (Pif386ext->PfFPriority > 10000) {
+ Pif386ext->PfFPriority = 10000;
+ }
+ if (Pif386ext->PfBPriority > 10000) {
+ Pif386ext->PfBPriority = 10000;
+ }
+ if (Pif386ext->PfFPriority <= 0) {
+ Pif386ext->PfFPriority = 1;
+ }
+ if (Pif386ext->PfBPriority <= 0) {
+ Pif386ext->PfBPriority = 1;
+ }
+ }
+ /*
+ * if(Pif286ext31) {
+ * Pif286ext31->PfMinEmsK = max(Pif286ext31->PfMinEmsK, 0);
+ * Pif286ext31->PfMinEmsK = min(Pif286ext31->PfMinEmsK, 16384);
+ * if (Pif286ext31->PfMaxEmsK != -1) {
+ * Pif286ext31->PfMaxEmsK = max(Pif286ext31->PfMaxEmsK, 0);
+ * Pif286ext31->PfMaxEmsK = min(Pif286ext31->PfMaxEmsK, 16384);
+ * }
+ * }
+ */
+ if(Pif286ext30) {
+ Pif286ext30->PfMinXmsK = max(Pif286ext30->PfMinXmsK, 0);
+ Pif286ext30->PfMinXmsK = min(Pif286ext30->PfMinXmsK, 16384);
+ if (Pif286ext30->PfMaxXmsK != -1) {
+ Pif286ext30->PfMaxXmsK = max(Pif286ext30->PfMaxXmsK, 0);
+ Pif286ext30->PfMaxXmsK = min(Pif286ext30->PfMaxXmsK, 16384);
+ }
+ }
+
+ /*
+ * Trim trailing spaces off PifFile->name
+ */
+ for (pch = (PUCHAR)(PifFile->name+PIFNAMESIZE-1); *pch == ' ' && pch > PifFile->name; pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->name,(PUCHAR)pch))
+ ;
+ *++pch = 0;
+ /*
+ * Trim trailing spaces off PifFile->params (and Pif386ext->params)
+ */
+ for (pch = (PUCHAR)(PifFile->params+PIFPARAMSSIZE-1); *pch == ' ' && pch > PifFile->params; pch=(PUCHAR)AnsiPrev((LPCTSTR)PifFile->params,(PUCHAR)pch))
+ ;
+ *++pch = 0;
+ if(Pif386ext) {
+ for (pch = (PUCHAR)(Pif386ext->params+PIFPARAMSSIZE-1); *pch == ' ' && pch > Pif386ext->params; pch=(PUCHAR)AnsiPrev((LPCTSTR)Pif386ext->params,(PUCHAR)pch))
+ ;
+ *++pch = 0;
+ }
+ UpdatePifScreen();
+ //OemToAnsi((LPSTR)ofReopen.szPathName,(LPSTR)CurPifFile);
+ lstrcpy((LPSTR)CurPifFile, (LPSTR)ofReopen.szPathName);
+ AnsiUpper((LPSTR)CurPifFile);
+ SetFileOffsets(CurPifFile,&fileoffset,&extoffset);
+ } else {
+ fh = ofReopen.nErrCode;
+ switch (fh) {
+ case 2: /* File not found */
+ fh = errNoPIFfnf;
+ break;
+
+ case 3: /* Path not found */
+ fh = errNoPIFpnf;
+ break;
+
+ case 4: /* Too many open files */
+ fh = errNoFileHnds;
+ break;
+
+ case 5: /* Access denied */
+ fh = errNoAcc;
+ break;
+
+ case 32: /* Sharing violation */
+ fh = errSharing;
+ break;
+
+ default:
+ fh = errNoPIFfnf;
+ break;
+ }
+ Warning(fh,MB_ICONEXCLAMATION | MB_OK);
+ }
+ return(TRUE);
+}
+
+
+IsFileName(unsigned char *pchFile)
+{
+ while (*pchFile) {
+ if (*pchFile <= ' ')
+ return(FALSE);
+ pchFile=AnsiNext(pchFile);
+ }
+ return(TRUE);
+}
+
+
+ClearChanges(void)
+{
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_ENAME), EM_SETMODIFY, FALSE, 0L);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_ETITLE), EM_SETMODIFY, FALSE, 0L);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_EPATH), EM_SETMODIFY, FALSE, 0L);
+ SendMessage(GetDlgItem(hwndPifDlg, IDI_EPARM), EM_SETMODIFY, FALSE, 0L);
+ NewHotKey = FALSE;
+ FileChanged = FALSE;
+ return(TRUE);
+}
+
+
+int SavePifFile(PSTR pchFile, int wmcommand)
+{
+ int fh;
+ OFSTRUCT ofReopen;
+ int i;
+ BYTE *p;
+ int stuffspot;
+ int cch;
+
+#if 0
+ // This code is not needed since NTVDM can deal with long names in DAYTONA
+ // 24-Jan-1994 JonPa
+ if (!IsFileName(pchFile)) {
+ Warning(EINVALIDFILE,MB_ICONEXCLAMATION | MB_OK);
+ return(SAVERETRY);
+ }
+#endif
+
+ UpdatePifStruct();
+
+ if (DoFieldsWork(TRUE)) {
+ PifFile->id = 0;
+ stuffspot = -1;
+ for(i = 0;i < PIFNAMESIZE; i++)
+ if(!PifFile->name[i]) {
+ PifFile->name[i] = ' ';
+ stuffspot = i;
+ }
+ p = (BYTE *)&PifFile->name[ 0 ];
+ i = PIFSIZE;
+ while (i--)
+ PifFile->id += *p++;
+ AnsiUpper((LPSTR) pchFile );
+ ofReopen.szPathName[0] = 0;
+ if ((fh = OpenFile((LPSTR)pchFile, (LPOFSTRUCT)&ofReopen, OF_CREATE | OF_READWRITE | OF_SHARE_EXCLUSIVE)) == -1) {
+ fh = ofReopen.nErrCode;
+ switch (fh) {
+ case 2: /* File not found */
+ fh = errNoCreate;
+ break;
+
+ case 3: /* Path not found */
+ fh = errNoPIFpnf;
+ break;
+
+ case 4: /* Too many open files */
+ fh = errNoFileHnds;
+ break;
+
+ case 5: /* Access denied */
+ fh = errCrtRO;
+ break;
+
+ case 32: /* Sharing violation */
+ fh = errSharing;
+ break;
+
+ default:
+ fh = errNoCreate;
+ break;
+ }
+ Warning(fh,MB_ICONEXCLAMATION | MB_OK);
+ if(stuffspot != -1)
+ PifFile->name[stuffspot] = '\0';
+ return(SAVERETRY);
+ }
+ cch = _lwrite(fh, (LPSTR)PifBuf, PifFileSize);
+ if(stuffspot != -1)
+ PifFile->name[stuffspot] = '\0';
+ _lclose(fh);
+ if ((unsigned)cch != PifFileSize) {
+ delete(pchFile);
+ Warning(errDiskFull,MB_ICONEXCLAMATION | MB_OK);
+ } else {
+
+ }
+ } else
+ return(SAVEERROR);
+
+ lstrcpy((LPSTR)CurPifFile, (LPSTR)pchFile);
+ AnsiUpper((LPSTR)CurPifFile);
+ SetFileOffsets(CurPifFile,&fileoffset,&extoffset);
+ ClearChanges();
+ return(SAVEDONE);
+}
+
+
+InitStdPIFExt(void)
+{
+ lstrcpy((LPSTR)PifFile->stdpifext.extsig, (LPSTR)stdHdr);
+ PifFile->stdpifext.extnxthdrfloff = LASTHEADERPTR;
+ PifFile->stdpifext.extfileoffset = 0;
+ PifFile->stdpifext.extsizebytes = sizeof(PIFOLD286STR);
+
+ LastPifExt = &PifFile->stdpifext;
+ PifFileSize = sizeof(PIFNEWSTRUCT);
+ Pif386ext = (PIF386EXT *)NULL;
+ /*
+ * Pif286ext31 = (PIF286EXT31 *)NULL;
+ */
+ Pif286ext30 = (PIF286EXT30 *)NULL;
+ PifNText = (PIFWNTEXT *)NULL;
+ return(TRUE);
+}
+
+
+InitPifStruct(void)
+{
+ BOOL result = TRUE;
+
+ PifFile->unknown = 0;
+ *PifFile->name = 0;
+ PifFile->maxmem = 128;
+ PifFile->minmem = 128;
+ *PifFile->startfile = 0;
+ *PifFile->defpath = 0;
+ *PifFile->params = 0;
+ PifFile->screen = 0x7F;
+ PifFile->cPages = 1;
+ PifFile->lowVector = 0;
+ PifFile->highVector = 0x0ff;
+ PifFile->rows = 25;
+ PifFile->cols = 80;
+ PifFile->rowoff = 0;
+ PifFile->coloff = 0;
+ PifFile->sysmem = 7;
+ *PifFile->shprog = 0;
+ *PifFile->shdata = 0;
+ PifFile->behavior = SCRMASK | MASK8087;
+ PifFile->sysflags = SWAPS;
+ PifFile->MSflags = EXITMASK;
+ InitStdPIFExt();
+ if(!(InitPif386Struc()))
+ result = FALSE;
+ if(!(InitPif286Struc()))
+ result = FALSE;
+ if(!(InitPifNTStruc()))
+ result = FALSE;
+ return(result);
+}
+
+
+InitPifNTStruc(void)
+{
+
+ if(!PifNText) {
+ if(!(PifNText = AllocInitNTExt())) {
+ Warning(NOMODENT,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+}
+
+
+InitPif386Struc(void)
+{
+
+ if(!Pif386ext) {
+ if(!(Pif386ext = AllocInit386Ext())) {
+ Warning(NOMODE386,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+}
+
+InitPif286Struc(void)
+{
+
+ if(!Pif286ext30) {
+ if(!(Pif286ext30 = AllocInit286Ext30())) {
+ Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
+ return(FALSE);
+ }
+ }
+ /*
+ * if(!Pif286ext31) {
+ * if(!(Pif286ext31 = AllocInit286Ext31())) {
+ * Warning(NOMODE286,MB_ICONEXCLAMATION | MB_OK);
+ * return(FALSE);
+ * }
+ * }
+ */
+ return(TRUE);
+}
+
+MaybeSaveFile(void)
+{
+ int j;
+ unsigned char *pch;
+ int i;
+ unsigned char *pchFile;
+ unsigned char *pchBuf = 0;
+
+ if (UpdatePifStruct() || FileChanged) {
+ j = 0;
+ pch = (PUCHAR)PifFile->name;
+ i = PIFSIZE;
+ while (i--)
+ j += *pch++;
+ if (j != PifFile->id) {
+ i = Warning(warSave,MB_ICONEXCLAMATION | MB_YESNOCANCEL);
+ switch (i) {
+ case IDYES:
+ if (!CurPifFile[0]) {
+ if(pchBuf = PutUpDB(DTSAVE))
+ pchFile = pchBuf;
+ else
+ return(FALSE); /* cancelled */
+ } else {
+ pchFile = CurPifFile;
+ }
+ CmdArgAddCorrectExtension(pchFile);
+ i = SavePifFile(pchFile, M_SAVE);
+ if(pchBuf)
+ LocalFree((HANDLE)pchBuf);
+ return(i==SAVEDONE ? TRUE : FALSE);
+
+ case IDNO:
+ return(TRUE);
+
+ case IDCANCEL:
+ return(FALSE);
+ }
+ } else {
+ return(TRUE);
+ }
+ } else {
+ return(TRUE);
+ }
+}
diff --git a/private/mvdm/vdmutils/pifedit/sources b/private/mvdm/vdmutils/pifedit/sources
new file mode 100644
index 000000000..a7056f891
--- /dev/null
+++ b/private/mvdm/vdmutils/pifedit/sources
@@ -0,0 +1,25 @@
+MAJORCOMP=windows
+MINORCOMP=shell
+
+TARGETNAME=pifedit
+TARGETPATH=obj
+TARGETTYPE=LIBRARY
+TARGETLIBS=
+
+INCLUDES=\nt\private\windows\inc;..\..\inc
+
+
+SOURCES= pifedit.c mods.c pifsubs.c pifedit.rc
+
+C_DEFINES=-DWIN32 -DSTRICT
+
+UMTYPE=windows
+UMENTRY=winmain
+UMAPPL=pifedit
+UMLIBS= \
+ $(BASEDIR)\public\sdk\lib\*\comdlg32.lib \
+ $(BASEDIR)\public\sdk\lib\*\shell32.lib \
+ obj\*\pifsubs.obj \
+ obj\*\mods.obj \
+ obj\*\pifedit.res
+
diff --git a/private/mvdm/vdmutils/win/makefile b/private/mvdm/vdmutils/win/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/mvdm/vdmutils/win/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/mvdm/vdmutils/win/sources b/private/mvdm/vdmutils/win/sources
new file mode 100644
index 000000000..a553d950f
--- /dev/null
+++ b/private/mvdm/vdmutils/win/sources
@@ -0,0 +1,42 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=mvdm
+MINORCOMP=win
+
+TARGETNAME=win
+TARGETPATH=obj
+TARGETTYPE=UMAPPL_NOLIB
+
+SOURCES=win.c win.rc
+
+INCLUDES=.
+
+UMLIBS=
+
+UMTYPE=windows
+UMENTRY=winmain
+UMAPPL=win
+UMAPPLEXT=.com
+UMRES=obj\*\win.res
diff --git a/private/mvdm/vdmutils/win/win.c b/private/mvdm/vdmutils/win/win.c
new file mode 100644
index 000000000..1a8ab9903
--- /dev/null
+++ b/private/mvdm/vdmutils/win/win.c
@@ -0,0 +1,184 @@
+/*++
+ *
+ * WOW v1.0
+ *
+ * Copyright (c) 1993, Microsoft Corporation
+ *
+ * WIN.C
+ * Simple WIN.COM which spawns program given on command line.
+ * This allows DOS install which run "win appname" to work.
+ *
+ * History:
+ * Created 29-Mar-1993 Dave Hart (davehart)
+ * 20-Jul-1994 Dave Hart (davehart) Changed from console to windows app.
+--*/
+
+#include <windows.h>
+
+//
+// Support for debug output disabled for build (no console).
+// DPRINTF macro must be used with two sets of parens:
+// DPRINTF(("Hello %s\n", szName));
+//
+
+#if 0
+#include <stdio.h>
+#define DPRINTF(args) printf args
+#else
+#define DPRINTF(args)
+#endif
+
+
+//
+// SKIP_BLANKS -- Handy macro to skip blanks.
+//
+
+#define SKIP_BLANKS(pch) {while (' ' == *(pch)) { (pch)++; }}
+
+//
+// SKIP_NONBLANKS -- Handy macro to skip everything but blanks.
+//
+
+#define SKIP_NONBLANKS(pch) {while (*(pch) && ' ' != *(pch)) { (pch)++; }}
+
+
+
+
+//
+// WinMain
+//
+
+int WinMain(
+ HINSTANCE hInst,
+ HINSTANCE hPrevInst,
+ LPSTR pszCommandLine,
+ int nCmdShow
+ )
+{
+ char *psz;
+ BOOL fSuccess;
+ DWORD dwExitCode;
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+
+ DPRINTF(("win.com: Command line is '%s'.\n", pszCommandLine));
+
+ //
+ // Throw away any switches on the command line. The command line
+ // looks like:
+ //
+ // win [/r] [/2] [/s] [/3] [/n] [winapp winapp-args]
+ //
+ // So we'll go into a loop of skipping all words that begin with
+ // "/" or "-" until we hit a word that doesn't start with either,
+ // which is presumably the winapp name.
+ //
+
+ psz = pszCommandLine;
+ SKIP_BLANKS(psz);
+
+ //
+ // psz now points to either the first word of our command
+ // line ("win" not included), or to a null terminator if
+ // we were invoked without arguments.
+ //
+
+ while ('-' == *psz || '/' == *psz) {
+
+ SKIP_NONBLANKS(psz);
+
+ //
+ // psz now points to either a space or the null terminator.
+ //
+
+ SKIP_BLANKS(psz);
+
+ //
+ // psz now points to either the beginning of the next word
+ // on the command line, or the null terminator.
+ //
+
+ }
+
+ if (!(*psz)) {
+
+ //
+ // If psz now points to a null terminator, then win.com was invoked
+ // either without arguments or all arguments were switches that we
+ // skipped above. So there's nothing to do!
+ //
+
+ return 0;
+
+
+ }
+
+ DPRINTF(("win.com: Invoking '%s'.\n", psz));
+
+ //
+ // Run that program.
+ //
+
+ RtlZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+ si.dwFlags = STARTF_USESHOWWINDOW | STARTF_FORCEONFEEDBACK;
+ si.wShowWindow = nCmdShow;
+
+ fSuccess = CreateProcess(
+ NULL, // image name (in the command line instead)
+ psz, // command line (begins with image name)
+ NULL, // lpsaProcess
+ NULL, // lpsaThread
+ FALSE, // no handle inheritance
+ 0, // dwCreateOptions
+ NULL, // pointer to environment
+ NULL, // pointer to curdir
+ &si, // startup info struct
+ &pi // process information (gets handles)
+ );
+
+ if (!fSuccess) {
+
+ dwExitCode = GetLastError();
+ DPRINTF(("CreateProcess fails with error %d.\n", dwExitCode));
+ return dwExitCode;
+
+ }
+
+
+ //
+ // Close the thread handle, we're only using the process handle.
+ //
+
+ CloseHandle(pi.hThread);
+
+
+ //
+ // Wait for the process to terminate and return its exit code as
+ // our exit code.
+ //
+
+ if (0xffffffff == WaitForSingleObject(pi.hProcess, INFINITE)) {
+
+ dwExitCode = GetLastError();
+ DPRINTF(("WaitForSingleObject(hProcess, INFINITE) fails with error %d.\n",
+ dwExitCode));
+ goto Cleanup;
+
+ }
+
+
+ if (!GetExitCodeProcess(pi.hProcess, &dwExitCode)) {
+
+ dwExitCode = GetLastError();
+ DPRINTF(("GetExitCodeProcess() fails with error %d.\n", dwExitCode));
+ goto Cleanup;
+
+ }
+
+ DPRINTF(("win.com: Returning child's exit code (%d)\n", dwExitCode));
+
+ Cleanup:
+ CloseHandle(pi.hProcess);
+ return dwExitCode;
+}
diff --git a/private/mvdm/vdmutils/win/win.rc b/private/mvdm/vdmutils/win/win.rc
new file mode 100644
index 000000000..4ba9fc6c1
--- /dev/null
+++ b/private/mvdm/vdmutils/win/win.rc
@@ -0,0 +1,9 @@
+#include <windows.h>
+#include <ntverp.h>
+
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE VFT2_UNKNOWN
+#define VER_FILEDESCRIPTION_STR "WIN.COM for compatibility"
+#define VER_INTERNALNAME_STR "win\0"
+
+#include "common.ver"