#include #include #include #include #include #include #include main () { int fil, i; long fileng, offs; unsigned char ch, tempbuf[5]; puts(""); puts("DUKSNDFX for Duke Nukem 3D by Kenneth Silverman (04/26/2000)"); puts(""); puts("This program fixes a sound crashing bug in DUKE3D.EXE that occurs on newer"); puts(" (PCI?) sound cards. If the game crashes immediately upon entering Volume 1,"); puts(" Level 4 (as well as many other places), then you've found the right program."); puts(""); puts("This program supports these versions of Duke3D:"); puts(" v1.3d Shareware and Registered versions"); puts(" v1.5 Atomic Edition"); puts(""); puts("Also, be aware that as a side effect, reverberation will be disabled."); puts(""); puts("Do you want to continue with patching DUKE3D.EXE? (Y/N)"); do { ch = getch(); } while ((ch != 'n') && (ch != 'N') && (ch != 'y') && (ch != 'Y') && (ch != 27)); if ((ch == 'n') || (ch == 'N') || (ch == 27)) { puts("Operation aborted"); exit(0); } // DUKE3D.EXE version: size: date: time: offset: // 1.0 Shareware 1066391 01/29/96 13:00 0x74A29 //û // 1.1 Shareware 1076339 ? ? 0x75249 //(according to AshCorv) // 1.3d Shareware 1178963 ? ? 0x89090 //û // 1.3d Registered 1179131 04/19/96 13:30 0x89040 //û // 1.4 Plutonium Pak 1240151 10/21/96 13:40 0x8F1E1 //(according to Antonio Mignolli) // 1.5 Atomic Edition 1246231 12/11/96 13:50 0x8FE51 //û // 1.5 Aussie version 1246231 ? ? 0x8FE51 //(according to Jonathon Fowler) // 1.5 Walmart version 1246439 12/11/96 13:50 0x8FE81 //(according to AshCorv) if ((fil = open("DUKE3D.EXE",O_BINARY|O_RDWR,S_IREAD)) == -1) { puts("ERROR 1: Can't read DUKE3D.EXE: Make sure it is in the current directory."); exit(0); } fileng = filelength(fil); offs = -1; if (fileng == 1066391) offs = 0x74a29; //1.0 if (fileng == 1076339) offs = 0x75249; //1.1 if (fileng == 1178963) offs = 0x89090; //1.3d (s) if (fileng == 1179131) offs = 0x89040; //1.3d (r) if (fileng == 1240151) offs = 0x8f1e1; //1.4 if (fileng == 1246231) offs = 0x8fe51; //1.5 if (fileng == 1246439) offs = 0x8fe81; //1.5 (Walmart) if (offs == -1) { puts("ERROR 2: DUKE3D.EXE unrecognized or not currently supported."); exit(0); } lseek(fil,offs,SEEK_SET); read(fil,tempbuf,5); close(fil); if ((tempbuf[0] == 0xb8) && (tempbuf[1] == 0x00) && (tempbuf[2] == 0x00) && (tempbuf[3] == 0x00) && (tempbuf[4] == 0x00)) { puts("This sound patch has already been applied to DUKE3D.EXE."); exit(0); } if ((tempbuf[0] != 0x2d) || (tempbuf[1] != 0xe8) || (tempbuf[2] != 0x03) || (tempbuf[3] != 0x00) || (tempbuf[4] != 0x00)) { puts("ERROR 3: DUKE3D.EXE unrecognized, or not currently supported."); exit(0); } if (fileng == 1066391) { for(i=25;i;i--) puts(""); puts("Duke Nukem 3D v1.0 (shareware) has been detected:"); puts(""); puts("Please be aware that the v1.0 to v1.1 upgrade patch from 3D Realms won't"); puts("work any more if you apply this patch."); } if (fileng == 1076339) { for(i=25;i;i--) puts(""); puts("Duke Nukem 3D v1.1 (shareware) has been detected:"); puts(""); puts("Please be aware that the v1.1 to v1.3d upgrade patch from 3D Realms won't"); puts("work any more if you apply this patch."); } if (fileng == 1179131) { for(i=25;i;i--) puts(""); puts("Duke Nukem 3D v1.3d (registered) has been detected:"); puts(""); puts("Please be aware that using this patch will require you to reinstall from"); puts("the orginal CD if you purchase the Plutonium PAK at some point in the future"); } if (fileng == 1240151) { for(i=25;i;i--) puts(""); puts("Duke Nukem 3D v1.4 (Plutonium Pack) has been detected:"); puts(""); puts("It is HIGHLY recommended that you apply the free upgade to the Atomic"); puts("version (v1.5) BEFORE applying this patch! Should you decide to upgrade"); puts("to v1.5 in the future, you would have to reinstall v1.3d, upgrade to 1.4,"); puts("upgrade to v1.5, and finally reinstall this sound patch (YUCK!)"); } if ((fileng == 1066391) || (fileng == 1076339) || (fileng == 1179131) || (fileng == 1240151)) { puts(""); puts("Proceed anyway? (Y/N)"); do { ch = getch(); } while ((ch != 'n') && (ch != 'N') && (ch != 'y') && (ch != 'Y') && (ch != 27)); if ((ch == 'n') || (ch == 'N') || (ch == 27)) { puts("Operation aborted"); exit(0); } } //Actually modify the exe here: if ((fil = open("DUKE3D.EXE",O_BINARY|O_RDWR,S_IWRITE)) == -1) { puts("ERROR 4: Can't write to DUKE3D.EXE: Make sure it has write priviledges."); exit(0); } lseek(fil,offs,SEEK_SET); tempbuf[0] = 0xb8; tempbuf[1] = tempbuf[2] = tempbuf[3] = tempbuf[4] = 0; write(fil,tempbuf,5); close(fil); puts("SUCCESS! DUKE3D.EXE has been patched to prevent the sound crashing bug."); }