Commits

Anonymous committed 27dad46

Dynamic decompression program for DOS games. Might be expanded later,
however, a lot of this is covered by UPX etc. You'd only want to do this
if you had an ancient program and didn't want the space to be permanently used
This concept is somewhat out of date.

Comments (0)

Files changed (2)

+/* Redneck EXECUTE, an advanced version of DynDecomp 1.6 */
+//------------------------------------------------------------------------------
+#include "execute.h"
+#include <stdio.h>
+#include "c:\bc5\projects\shared\smlfuncs\smlfuncs.h"
+#include <process.h>
+#include <string.h>
+#include <errno.h>
+#include <conio.h>
+#include <stdlib.h>
+//------------------------------------------------------------------------------
+int main(/*int argc, char * argv[]*/)
+{
+	printf("DYNAMIC DECOMPRESSION ROUTINE BY DAVID DUNCAN ROSS PALMER FOR REDNECK RAMPAGE\n"
+   		 "DynDecomp V1.6 (c)Copyright 1997, Abbott & Palmer Corporation.\n"
+          "-----------------------------------------------------------------------------\n\n");
+   printf("Testing execution conditions\n");
+   if (!CheckFileExistance("EXECUTE.EXE"))
+   {
+      printf("ERROR: Expected directory is invalid or required file missing!\n");
+      return 1;
+   }
+   if (!CheckFileExistance("REDNECK.EXE") || !CheckFileExistance("REDNECK.GRP"))
+   {
+   	/* Needs decompression */
+   	printf("Redneck is compressed, looking for package\n");
+   	if (!CheckFileExistance("RR.ZIP")) NoPack();
+   	printf("Decompressing Redneck\n");
+   	if (CheckFileExistance("REDBOX.COM"))
+   	{
+   		char* Program = "REDBOX.COM";
+   		FaultHandler(spawnlp(P_WAIT, Program, Program, NULL), Program);
+      }
+      char* Program = "PKUNZIP.EXE";
+      FaultHandler(spawnlp(P_WAIT, Program, Program, "rr " "-s ", NULL), Program);
+   }
+   else
+   {
+   	/* Does not need decompression */
+      printf("Redneck Rampage is already edpanded\n");
+   }
+   ExeRR();
+   DeleteExpandedFiles();
+}
+//------------------------------------------------------------------------------
+void ExeRR()
+{
+	char* Program = "NOBOX.COM";
+	if (CheckFileExistance((const char*)Program))
+   	FaultHandler(spawnlp(P_WAIT, Program, Program, NULL), Program);
+   strcpy(Program, "EREGCARD.EXE");
+   if (CheckFileExistance((const char*)Program))
+   {
+   	printf("Executing ERegCard image\n");
+      FaultHandler(spawnlp(P_WAIT, Program, Program, NULL), Program);
+   }
+   else
+   {
+   	printf("Warning! EREGCARD missing, unable to load!\n");
+   }
+   strcpy(Program, "REDNECK.EXE");
+   printf("Executing Redneck image\n");
+   FaultHandler(spawnlp(P_WAIT, Program, Program, NULL), Program);
+}
+//------------------------------------------------------------------------------
+void NoPack()
+{
+	printf("ERROR: Expected package file missing!\n");
+   exit(EXIT_FAILURE);
+}
+//------------------------------------------------------------------------------
+void FaultHandler(int ExecCondition, const char* ProgName)
+{
+	if (ExecCondition == -1)
+   {
+   	char* ErrorMessage = "";
+   	/* Some sort of execution error has occoured */
+      switch (errno)
+      {
+      	case E2BIG :
+         {
+         	strcpy(ErrorMessage, "Argument list to long");
+         	break;
+         }
+         case EINVAL :
+         {
+         	strcpy(ErrorMessage, "Invalid argument");
+            break;
+         }
+         case ENOENT :
+         {
+         	strcpy(ErrorMessage, "Path or filename not found");
+            break;
+         }
+         case ENOEXEC :
+         {
+         	strcpy(ErrorMessage, "Exec format error");
+            break;
+         }
+         case ENOMEM :
+         {
+         	strcpy(ErrorMessage, "Not enough memory to load");
+         	break;
+         }
+         default :
+         {
+         	strcpy(ErrorMessage, "Unknown error");
+         }
+      } /* switch */
+      strcat(ErrorMessage, " executing ");
+      strcat(ErrorMessage, ProgName);
+      strcat(ErrorMessage, "\n");
+      printf(ErrorMessage);
+      printf("PRESS ANY KEY TO CONTINUE\n");
+      getch();
+   } /* if (ExecCondition == -1) */
+   return;
+} /* end of function */
+//------------------------------------------------------------------------------
+void DeleteExpandedFiles()
+{
+	printf("Deleting expanded files\n");
+	char* Program = "";
+   strcpy(Program, "REDNECK.GRP");
+	if (CheckFileExistance(Program))
+   	unlink("REDNECK.GRP");
+   strcpy(Program, "REDNECK.EXE");
+   if (CheckFileExistance(Program))
+	   unlink(Program);
+}
+//------------------------------------------------------------------------------
+/* Header for Redneck Rampage execute (DynDecomp 1.6) */
+
+/* Function declarations */
+void ExeRR(void);
+void NoPack(void);
+void FaultHandler(int ExecCondition, const char* ProgName);
+void DeleteExpandedFiles(void);