|
|
Microsoft Windows NT Build 328 10-12-1992
#define MAXBUF 256
#define MAXPATH 64
#include <assert.h>
#include <dos.h>
#include <io.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include "iniupd.h"
#define FALSE 0
#define TRUE 1
FILE *fpSysIni;
FILE *fpSysPre;
char *psz1;
char *psz2;
char *psz3;
char rgchBuf[MAXBUF];
char szTmpBuf[MAXBUF];
char szSysIni[MAXBUF];
char szSysOld[MAXBUF];
char szTempFile[MAXBUF];
char *szWinPath;
char *szVxdPath;
BOOL my_strnicmp( char *szStr1, char *szStr2, int count);
VOID stcpyf2n(char FAR *in, char *out);
/****************************************************************************
FUNCTION: LibMain(HANDLE, WORD, WORD, LPSTR)
PURPOSE: Is called by LibEntry. LibEntry is called by Windows when
the DLL is loaded. The LibEntry routine is provided in
the LIBENTRY.OBJ in the SDK Link Libraries disk. (The
source LIBENTRY.ASM is also provided.)
LibEntry initializes the DLL's heap, if a HEAPSIZE value is
specified in the DLL's DEF file. Then LibEntry calls
LibMain. The LibMain function below satisfies that call.
The LibMain function should perform additional initialization
tasks required by the DLL. In this example, no initialization
tasks are required. LibMain should return a value of 1 if
the initialization is successful.
*******************************************************************************/
int FAR PASCAL LibMain(hModule, wDataSeg, cbHeapSize, lpszCmdLine)
HANDLE hModule;
WORD wDataSeg;
WORD cbHeapSize;
LPSTR lpszCmdLine;
{
return 1;
}
/****************************************************************************
FUNCTION: BOOL my_strnicmp(char *szStr1, char *szStr2, int count )
PURPOSE: my_strnicmp is the same as the strnicmp function. Strnicmp
was not used because the linker could not find it in the library.
TRUE is returned if the first "count" characters of szStr1 are
the same as szStr2. FALSE is returned otherwise.
*******************************************************************************/
BOOL my_strnicmp(char *szStr1, char *szStr2, int count )
{
int i;
for (i = 0; i < count; i++)
{
if (toupper(szStr1[i]) != toupper(szStr2[i]))
return FALSE;
}
return TRUE;
}
/****************************************************************************
FUNCTION: VOID strcpyf2n(char FAR *in, char *out )
PURPOSE: strcpyf2n copyies the contents of the far string in to the
near string out. Memory must be allocated for out for the
full string length including the terminatined '\0'
*******************************************************************************/
VOID strcpyf2n (char FAR *in, char *out)
{
while (*out++ = *in++);
}
/****************************************************************************
FUNCTION: WEP(int)
PURPOSE: Performs cleanup tasks when the DLL is unloaded. WEP() is
called automatically by Windows when the DLL is unloaded (no
remaining tasks still have the DLL loaded). It is strongly
recommended that a DLL have a WEP() function, even if it does
nothing but returns success (1), as in this example.
*******************************************************************************/
int FAR PASCAL WEP (bSystemExit)
int bSystemExit;
{
return(1);
}
/****************************************************************************
****************************************************************************/
BOOL FAR PASCAL MakeSystemIni(LPSTR lpszWinPath, LPSTR lpszVxdPath)
{
unsigned char fDevAdded = FALSE;
//Using Windows as DPMI provider ...
szWinPath = (char *) malloc (lstrlen(lpszWinPath)+1);
szVxdPath = (char *) malloc (lstrlen(lpszVxdPath)+1);
strcpyf2n(lpszWinPath, szWinPath);
strcpyf2n(lpszVxdPath, szVxdPath);
szSysIni[0] = '\0';
strcat(strcpy(szSysIni, szWinPath), "SYSTEM.INI");
szTempFile[0] = '\0';
strcat(strcpy(szTempFile, szWinPath), "$win32s$.tmp" );
if ((fpSysIni = fopen(szSysIni, "r")) == NULL)
{
wsprintf(szTmpBuf, "%s cannot be opened for read from %s. Setup is unable to make modifications.", szSysIni, szWinPath);
MessageBox((HWND)NULL, szTmpBuf, "Setup Message", MB_OK | MB_ICONEXCLAMATION);
return(FALSE);
}
strcat(strcpy(szSysOld, szWinPath), "SYSTEM.OLD");
if ((fpSysPre = fopen(szSysOld, "wt")) == NULL)
{
sprintf(szTmpBuf, "%s cannot be opened for write. Setup is unable to make modifications.", szSysOld);
MessageBox((HWND)NULL, szTmpBuf, "Setup Message", MB_OK | MB_ICONEXCLAMATION);
fclose(fpSysIni);
return(FALSE);
}
while (fgets(rgchBuf, MAXBUF, fpSysIni))
{
fputs(rgchBuf, fpSysPre);
if (my_strnicmp(rgchBuf, "[386Enh]", 8)==TRUE)
{
// only add to the [386Enh] section.
if (fDevAdded == FALSE)
{
fputs("device=", fpSysPre);
fputs(szVxdPath, fpSysPre);
fputc('\n', fpSysPre);
fDevAdded = TRUE;
}
do
{
if (!(psz1 = fgets(rgchBuf, MAXBUF, fpSysIni)))
break;
if (my_strnicmp(rgchBuf, "device", 6) == FALSE)
fputs(rgchBuf, fpSysPre);
else
{
if ((psz2 = strchr(psz1, '=')) != NULL)
{
if ( ((psz3 = strchr(psz2, szVxdPath[0])) != NULL) &&
(my_strnicmp(psz3, szVxdPath, strlen(szVxdPath)) == TRUE) )
continue;
else
fputs(rgchBuf, fpSysPre);
}
else
fputs(rgchBuf, fpSysPre);
}
} while (*psz1 != '[');
}
}
fclose(fpSysIni);
fclose(fpSysPre);
// Rename o' rama
rename( szSysIni, szTempFile );
rename( szSysOld, szSysIni );
rename( szTempFile, szSysOld );
/* PostMessage(NULL, STF_SHL_INTERP, 0, 0L); */
return(TRUE);
}
/*
*/
BOOL FAR PASCAL RestartWindows( LPSTR lpszOleCliPath )
{
// Guarantee that OleCli.Dll is locked. This will result
// in setup doing appriate reboot via ExitExecRestart()
LoadLibrary ( lpszOleCliPath );
return(TRUE);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.