4 Commits 571b910b57 ... 42d0110dd6

Author SHA1 Message Date
  CYBERDEV 42d0110dd6 Bump version to v0.2.0, README & CHANGELOG update 2 weeks ago
  CYBERDEV 75bddabaa4 Change git host to Codeberg 2 weeks ago
  CYBERDEV c9cc5aa340 Fix `scriptDeflateOffset` debug-print + comment 2 weeks ago
  CYBERDEV 7bb1a61b04 Include cleanup 2 weeks ago
6 changed files with 156 additions and 46 deletions
  1. 30 0
      CHANGELOG.md
  2. 115 38
      README.md
  3. 3 3
      rewise.1
  4. 1 1
      src/pefile.c
  5. 6 3
      src/rewise.c
  6. 1 1
      src/version.h

+ 30 - 0
CHANGELOG.md

@@ -0,0 +1,30 @@
+# REWise v0.2.0
+
+ > Codename ZLIB
+
+ - Replaced the custom inflate and CRC32 code with an `zlib` implementation.
+   Tests showed that the `zlib` implementation is around 16 times faster!
+ - Maximum file sizes for `WiseScript.bin` and `WiseColors.bin` while
+   inflating.
+ - Fixed some compiler warnings.
+
+
+# REWise v0.1.0
+
+ > Codename INIT
+
+This is the initial version.
+
+The inflation process is heavily based on the inflation implementation of
+[WiseUnpacker](https://github.com/mnadareski/WiseUnpacker). So a lot of
+thanks to [mnadareski](https://github.com/mnadareski)!
+
+Most time was spend on reverse-engineering `WiseScript.bin` to extract
+files with their meta-data without as much of guessing as possible at that
+time.
+
+It can list, verify and extract files from various Valve game installers
+released from 1999 to 2003 like Half-Life GOTY and Counter-Strike 1.5.
+Return to Castle Wolfenstein (2001) and Wolfenstein: Enemy Territory (2001)
+are also supported. For a more complete list of working and not working
+installers see `README.md`.

+ 115 - 38
README.md

@@ -6,9 +6,9 @@ The aim of this project is to extract assets from old game installers made with
 Wise installer without executing the PE file (.exe), so they can be used with
 free software implementations of the game engine.
 
-```bash
+```
 ==============================================================
-              Welcome to REWise version 0.1.0
+              Welcome to REWise version 0.2.0
 ==============================================================
 
  Usage: rewise [OPERATION] [OPTIONS] INPUT_FILE
@@ -38,14 +38,13 @@ free software implementations of the game engine.
 # Acknowledgement
 
 The `WiseUnpacker` project helped a lot to give insight on how to unpack files
-from Wise installers. The `REWise` inflation process is heavily based on the
-inflation process of `WiseUnpacker`. So a lot of thanks to
+from Wise installers. So a lot of thanks to
 [mnadareski](https://github.com/mnadareski/)!
 
 Unlike `WiseUnpacker` which tries to support all versions of Wise installers,
 REWise tries to focus on old game installers (1999-2003) in the form of PE
 executables. But when `REWise` fails to extract any Wise installer feel free
-to open an [issue](https://notabug.org/CYBERDEViL/REWise/issues) (no
+to open an [issue](https://codeberg.org/CYBERDEV/REWise/issues) (no
 guarantees!).
 
 
@@ -53,24 +52,24 @@ guarantees!).
 
  > NOTE: The PE build date will not be the same as the installer creation date
  > (or release date) since the overlay-data is just appended to a existing
- > Wise PE on creation of the installer. The supported installer release
+ > Wise PE32 stub on creation of the installer. The supported installer release
  > dates seen so far are between 1999 and 2003. While the PE build dates are
  > between 1998 and 2001.
 
 A Wise installer is a PE executable (NE is also possible, but not supported at
 this time) with extra data appended to the end of it (overlay-data at the
 overlay-offset). The overlay-data contains a Wise specific header which is not
-very important to us (it might be, but no useable values have been found yet).
+very important to us (it might be, but no usable values have been found yet).
 After the Wise header there is raw `DEFLATE`d data without file-headers, after
 each `DEFLATE`d data entry there is a CRC32 for the inflated data. The
 `DEFLATE`d data + CRC32 continues until `EOF`.
 
-The first inflated file is a `.dib` file containing colours used by the
-installer, it is no use for us so we skip it.
+The first inflated file is a `.dib` file we call `WiseColors.dib`, containing
+colors used by the installer, it is no use for us so we skip it.
 
 The second inflated file is a binary file that has all sorts of data relevant
 for the installation (including custom file headers). Within REWise this file
-is named `WiseScript.bin`. Most time was spend on reverse engeneering
+is named `WiseScript.bin`. Most time was spend on reverse engineering
 different `WiseScript.bin` files with a hex-editor (ImHex) so a
 `WiseScript.bin` can be parsed without as much of guessing as possible. One
 discovered struct that is the most relevant for extracting files that would be
@@ -98,57 +97,124 @@ On how `REWise` handles a `WiseScript.bin` file: SEE `src/wisescript.h` and
 `src/wisescript.c`.
 
 
+### Stub from different Wise Installation System versions
+
+ > **NOTE**: Stubs are patched on creation of the installer so we cannot do
+   a sum of `compiled` installers and compare below. `VsVersionInfo` and
+   `StringFileInfo` are patched and a value in a section somewhere up is
+   patched to contain the overlay offset value.
+
+VERSION    | BUILD DATE-TIME     | OVERLAY OFFSET | SHA256
+:--------- | :------------------ | :------------- | :----------------------
+7.01       | 09-11-1998 21:17:09 | `0x00003800`   | 6a6266fc674bc61852d3e5dc2b3608de9205f518baf718880b81aa1a6179573f
+8.11.0.505 | 25-04-2000 16:37:12 | `0x00003A00`   | 23da437bde09458cd512644a139c6ce8d180187a9cc6d32e7bfef077ed99f580
+8.12.0.508 | 25-04-2000 16:37:12 | `0x00003A00`   | 23da437bde09458cd512644a139c6ce8d180187a9cc6d32e7bfef077ed99f580
+8.14.0.512 | 25-04-2000 16:37:12 | `0x00003A00`   | 23da437bde09458cd512644a139c6ce8d180187a9cc6d32e7bfef077ed99f580
+9.01.202.0 | 25-10-2001 21:47:11 | `0x00003A00`   | 96a173c62f632140e9d14a7eee0d42f8ef62bee4b66ed317f2077bdfaa32376a
+9.02.204.0 | 25-10-2001 21:47:11 | `0x00003A00`   | 96a173c62f632140e9d14a7eee0d42f8ef62bee4b66ed317f2077bdfaa32376a
+
+
 # State
 
+Do you know any Wise installer that is not listed below? Please consider
+reporting it for completeness and for further investigation.
+
 ## Known working Wise installers
 
 SHORT       | SOURCE     | FULL
 :---------- | :--------- | :--------------------------------------------
-CS15        | Download   | Counter-Strike 1.5 (2001)
-ET          | Download   | Wolfenstein: Enemy Territory (2001)
+HL:UL       | Download   | Half-Life Uplink (1999)
 GSPY220     | Download   | GameSpy 220 std (2000)
+OPFOR:DEMO  | Download   | Half-Life:Opposing Force Demo (2000)
 HL:CS       | Retail CD  | Half-Life Counter-Strike (2000)
 HL:GOTY     | Retail CD  | Half-Life Game Of The Year Edition (1999)
-HL1WON      | Download   | Half-Life 1 WON 1.1.1.0 Patch (2002)
-HL23SDK     | Download   | Half-Life SDK 2.3 (2002)
-HL:STEAM    | Download   | Steam Client with Half-Life Cache (2003)
-HL:UL       | Download   | Half-Life Uplink (1999)
-OPFOR:DEMO  | Download   | Half-Life:Opposing Force Demo (2000)
 RTCW        | Retail CD  | Return to Castle Wolfenstein (2001)
 RTCW:MPDEMO | Download   | Return to Castle Wolfenstein Multi-Player Demo (2001)
 RTCW:SPDEMO | Download   | Return to Castle Wolfenstein Single-Player Demo (2001)
+CS15        | Download   | Counter-Strike 1.5 (2001)
+GIFT        | Download   | Gift (PL) (2000) (aka Gifty (DE))
+HL1WON      | Download   | Half-Life 1 WON 1.1.1.0 Patch (2002)
+ET          | Download   | Wolfenstein: Enemy Territory (2001)
+HL23SDK     | Download   | Half-Life SDK 2.3 (2002)
+HL:STEAM    | Download   | Steam Client with Half-Life Cache (2003)
+
+___
+
+SHORT       | FILENAME                   | PE BUILD            | STUB
+:---------- | :------------------------- | :------------------ | :-----------
+HL:UL       | hluplink.exe               | 09-11-1998 21:17:09 | InstallMaster 7
+GSPY220     | gamespyinstaller220std.exe | 21-05-1999 22:48:48 | ?
+OPFOR:DEMO  | opfordemofull.exe          | 21-05-1999 22:48:48 | ?
+HL:CS       | counter-strike.exe         | 17-08-1999 17:25:48 | ?
+HL:GOTY     | SETUP.EXE                  | 25-04-2000 16:37:12 | InstallMaster 8
+RTCW        | Setup.exe                  | 25-04-2000 16:37:12 | InstallMaster 8
+RTCW:MPDEMO | Wolf_MPDemo.exe            | 25-04-2000 16:37:12 | InstallMaster 8
+RTCW:SPDEMO | wolf_spdemo.exe            | 25-04-2000 16:37:12 | InstallMaster 8
+CS15        | csv15full.exe              | 13-08-2001 19:13:38 | ?
+GIFT        | Gift.exe                   | 13-08-2001 19:13:38 | ?
+HL1WON      | hl1110.exe                 | 13-08-2001 19:13:38 | ?
+ET          | WolfET.exe                 | 25-10-2001 21:47:11 | Installation System 9
+HL23SDK     | hl_sdk_v23.exe             | 25-10-2001 21:47:11 | Installation System 9
+HL:STEAM    | steaminstall_halflife.exe  | 25-10-2001 21:47:11 | Installation System 9
+
+
+## Not working installers
+
+ > NOTE: All multi-disc installers are currently NOT supported.
+
+SHORT       | SOURCE     | FULL
+:---------- | :--------- | :--------------------------------------------
+WILDWHEELS  | Retail CD  | Wild Wheels (2002) (aka Buzzing Cars)
+HM:C        | Retail CD  | Hitman Contracts (2004)
+GOTHIC II   | Retail CD  | Gothic II (2003)
 
 ___
 
-SHORT       | FILENAME                   | PE BUILD
-:---------- | :------------------------- | :-----------------------------
-CS15        | csv15full.exe              | Mon Aug 13 19:13:38 2001 UTC+1
-ET          | WolfET.exe                 | Thu Oct 25 21:47:11 2001 UTC+1
-GSPY220     | gamespyinstaller220std.exe | Fri May 21 22:48:48 1999 UTC+1
-HL:CS       | counter-strike.exe         | Tue Aug 17 17:25:48 1999 UTC+1
-HL:GOTY     | SETUP.EXE                  | Tue Apr 25 16:37:12 2000 UTC+1
-HL1WON      | hl1110.exe                 | Mon Aug 13 19:13:38 2001 UTC+1
-HL23SDK     | hl_sdk_v23.exe             | Thu Oct 25 21:47:11 2001 UTC+1
-HL:STEAM    | steaminstall_halflife.exe  | Thu Oct 25 21:47:11 2001 UTC+1
-HL:UL       | hluplink.exe               | Mon Nov  9 21:17:09 1998 UTC+1
-OPFOR:DEMO  | opfordemofull.exe          | Fri May 21 22:48:48 1999 UTC+1
-RTCW        | Setup.exe                  | Tue Apr 25 16:37:12 2000 UTC+1
-RTCW:MPDEMO | Wolf_MPDemo.exe            | Tue Apr 25 16:37:12 2000 UTC+1
-RTCW:SPDEMO | wolf_spdemo.exe            | Tue Apr 25 16:37:12 2000 UTC+1
+SHORT       | FILENAME                   | PE BUILD            | STUB
+:---------- | :------------------------- | :------------------ | :-----------
+WILDWHEELS  | setup.EXE                  | 17-08-1999 17:25:48 | ?
+HM:C        | setup.exe                  | 25-04-2000 16:37:12 | InstallMaster 8
+GOTHIC II   | Gothic2-Setup.exe          | 25-10-2001 21:47:11 | Installation System 9
+
+
+#### `WILDWHEELS`
+
+In contrary to what we've seen before there are PK headers at inflate
+start which also contains the CRC32 (instead of just the CRC32 after
+the deflate data). It is either build with a different Wise package or
+maybe different configuration (maybe with the zip support option? still
+has to be analyzed).
+
+This game supposed to be open sourced, see [this](https://github.com/colobot/colobot/issues/896)
+, but have not found the source or license yet.
+
+
+#### `HM:C`
+
+This is a multi-disc installer which is not supported yet.
+
+Not aware of a free software implementation of this game, so it has no
+priority.
+
+
+#### `GOTHIC II`
+
+This is a multi-disc installer which is not supported yet.
+
+Would be nice to support for the use with [REGoth-bs](https://github.com/REGoth-project/REGoth-bs)
+or [OpenGothic](https://github.com/Try/OpenGothic).
 
 
 ## What can be done better
 
 In general:
 
- - Error handling.
- - The inflate process is currently custom made with
-   `https://github.com/mnadareski/WiseUnpacker` as a source of information. It
-   is doing fine but it probably will be better and faster with a `zlib`
-   implementation.
+ - Option(s) to extract only given file(s), maybe with wildcards or a
+   specified file list?
+ - Error handling (different exit codes for different errors).
 
 Values that are currently calculated that might be in the WiseHeader,
-somewhere in WiseScript.bin or a constant defined somewhere else are:
+somewhere in `WiseScript.bin` or a constant defined somewhere else are:
 
  - Total inflated size.
  - The deflate-offset that is added to deflateStart defined in the
@@ -156,6 +222,7 @@ somewhere in WiseScript.bin or a constant defined somewhere else are:
 
 Other values that are of interest but not found yet are:
 
+ - Deflated/Inflated size of `WiseColors.dib` and `WiseScript.bin`.
  - To determine what Wise package/version was used other then the PE build
    date.
    On [Wikipedia](https://en.wikipedia.org/wiki/Wise_installer) is a list of
@@ -170,6 +237,7 @@ Other values that are of interest but not found yet are:
     - WISE Installation System version 8 (1999) (InstallMaster)
     - WISE Installation System version 9 (2001)
 
+
 ## Things that might be a problem
 
  - REWise is only tested on Little Endian systems.
@@ -177,13 +245,22 @@ Other values that are of interest but not found yet are:
    installers that where created/released before 1999 or after 2003.
 
 
+# Dependencies
+
+NAME | LICENSE | URL
+:--- | :------ | :---------------------
+zlib | Zlib    | https://www.zlib.net/
+
+
 # Many thanks to
 
  - The [WiseUnpacker project](https://github.com/mnadareski/WiseUnpacker) for
    a great source of information.
  - The [FragNet community](https://www.frag-net.com) for testing and feedback.
 
+
 # Other projects
 
  - https://github.com/mnadareski/WiseUnpacker
  - https://github.com/lmop/exwise
+ - https://www.angelfire.com/ego/jmeister/hwun/

+ 3 - 3
rewise.1

@@ -110,7 +110,7 @@ allowed and will be resolved.
 .IP \[bu]
 REWise is only tested on Little Endian systems. Did you try REWise on a Big-
 Endian system then please report your results by opening a new issue at
-<https://notabug.org/CYBERDEViL/REWise/issues/>
+<https://codeberg.org/CYBERDEV/REWise/issues>
 
 .IP \[bu]
 REWise will not delete/cleanup extracted files when the process fails somehow,
@@ -146,8 +146,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
 
 .SH BUGS
 For known issues and reporting new issues: see
-<https://notabug.org/CYBERDEViL/REWise/issues/>.
+<https://codeberg.org/CYBERDEV/REWise/issues>.
 
 
 .SH HOMEPAGE
-https://notabug.org/CYBERDEViL/REWise
+https://codeberg.org/CYBERDEV/REWise

+ 1 - 1
src/pefile.c

@@ -15,9 +15,9 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 
-#include "reader.h"
 #include "pefile.h"
 #include "print.h"
 

+ 6 - 3
src/rewise.c

@@ -60,8 +60,10 @@
 // These are here to perform some sanity checks when inflating the
 // .dib and WiseScript.bin files and when doing RAW extract, for those
 // files the inflated size is unknown pre inflation.
-#define MAX_FILESIZE_DIB    (100 * SIZE_KiB)
-#define MAX_FILESIZE_SCRIPT (900 * SIZE_KiB)
+// NOTE: 'Gothic2-Setup.exe' has large .dib size (1.4 MiB), others only
+//       seen ~16 KiB.
+#define MAX_FILESIZE_DIB    (2 * SIZE_MiB)
+#define MAX_FILESIZE_SCRIPT (1 * SIZE_MiB)
 #define MAX_FILESIZE_RAW    (uint32_t)-1
 
 // Maximum user defined output path size
@@ -921,7 +923,8 @@ int main(int argc, char *argv[]) {
     // the real inflateStart offset in the PE file.)
     WiseScriptParsedInfo * parsedInfo = wiseScriptGetParsedInfo(tmpFileScript);
     ScriptDeflateOffset = filesize - parsedInfo->inflateStartOffset;
-    printDebug("scriptDeflateOffset: %ld (0x%08X).\n", parsedInfo->inflateStartOffset);
+    printDebug("scriptDeflateOffset: %ld (0x%08X).\n", ScriptDeflateOffset, ScriptDeflateOffset);
+    printDebug("inflateStartOffset : %ld (0x%08X).\n", parsedInfo->inflateStartOffset, parsedInfo->inflateStartOffset);
 
     WiseScriptCallbacks callbacks;
     initWiseScriptCallbacks(&callbacks);

+ 1 - 1
src/version.h

@@ -18,7 +18,7 @@
 #define H_REWISE_VERSION
 
 #define REWISE_VERSION_MAJOR 0
-#define REWISE_VERSION_MINOR 1
+#define REWISE_VERSION_MINOR 2
 #define REWISE_VERSION_PATCH 0
 
 #define _STRINGIFY(x) #x