Extracting WAD files
GoW Tool »
[Link]
Developer: HitmanHimself
To extract data from the .wad files, I used the tool called
GoW Tool. I originally found it
[Link]. The github page is
[Link], where you can read more. It's been designed for the PS4 version of the game, but since the WAD data structure is somewhat identical, it can process the PC version's data as well.
How to use:
[ 1 ] Download to a folder of your choice.
[ 2 ] In that same folder, create another folder called
extracted (this will be the folder where data will be extracted to).
Example: In my case, the main folder is
D:\Games Analysis\God of War\GoW Tool. Downloaded GOWTool.exe there, as well as created the
extracted folder. See pic above.
[ 3 ] Click in the address field and type in
cmd, then press Enter:
This will open the command prompt, setting the working folder as the current one:
[ 4 ] Type in "gowtool" and hit Enter to see the list of options you can run it with:
[ 5 ] The first thing you want to do is tell the tool where you game is. To do so, type in
gowtool settings [Enter]:
My game is located in
G:\SteamLibrary\steamapps\common\GodOfWar, so I will type in:
gowtool settings -g "G:\SteamLibrary\steamapps\common\GodOfWar"
Replace the folder above with yours.
What this will do is create a file in the GoW Tool's folder -
config.ini - that will be used when exporting data:
[ 6 ] Identify the WAD archive you want to extract. For that, go to your game folder, then enter the
exec folder, then
wad folder, then
pc_le folder. You will see a lot of .wad files there. Can't see file extensions? Learn to use Windows and google.com (google "how can I enable file extensions Windows 10").
There are currently
597 files in my folder:
From them, for this example, I picked
r_athena00.wad:
Click on the top bar and copy the folder path, as we'll need it:
[ 7 ] Back to our command prompt, type in
gowtool wad [Enter] so you see the arguments for this option:
So, to extract, we need 3 parameters to be given to the tool: path to .wad file, output path and which action to perform.
The first parameter will be
-p <our path to wad file>:
-p "G:\SteamLibrary\steamapps\common\GodOfWar\exec\wad\pc_le\r_athena00.wad"
Replace the game folder path with yours in the above.
The second parameter will be
-o <path to extract to>:
-o "D:\Games Analysis\God of War\GoW Tool\extracted"
And third parameter will be
-e.
So:
Checking the extracted files
HxD »
[Link]
Developer: Maël Hörz
Now, when you look at your
extracted folder, you will see a bunch of BIN files, as that's the default extension the tool exports them by. I am assuming it's not 100% sure of the file types to give them the proper extensions. The .bin extension is generic. In reality, these files are of different types.
For the next part you will need a HEX EDITOR. I am using HxD (linked above). Why do we need it? To be able to see what kind of file are we looking at.
For example, if I open
main.34.bin file in HxD hex editor, I see this:
There is no easy way to identify only Lua files, so you will have to check the file content by viewing them in the hex editor. At some point you will realize that files called MAT_* or other names are NOT Lua files and therefore not useful to us.
What we're looking for are LUA files. From file header we see indications to the original folder path and real name of file. It's a Lua compiled script, I am showing the signature byte (where the script file actually begins, at 0x1B byte) and the LuaR (Lua 5.2) signature.
Use the path in the header to create a series of directories in your
extracted folder:
%PROJ_PATH%/gameart/scripts/characters/athena00/main.lua
So I will create these folders:
Yes, I created them manually. If you don't want to make them manually, then in your command prompt paste the path you just copied and replace %PROJ_PATH% with your
extracted folder's path. Then prefix everything with
md (md command creates directories):
Anyway, I will code a tool that automatically creates the folder hierarchy for you from that %PROJ_PATH%[...] string.
Decompiling the LUA files
unluac »
[Link]
Author: Hans Wessels
For that task we'll need
unluac. At the time of writing this, you will download
unluac_2022_01_12.jar. Rename it to
unluac.jar and move it to your GoW Tool folder:
To be able to run this, YOU WILL ALSO NEED TO HAVE JAVA INSTALLED
- (optional) JRE: [Link] (in case the above isn't enough; don't remember)
In order to decompile the file, the syntax in the command prompt is:
java -jar unluac.jar [in_file] > [out_file]
But our file isn't a proper Lua compiled file yet. Remember that header till the 0x1B byte? That has to be removed:
So now it looks like this:
Now this is the Lua compiled script. SAVE the file (Ctrl+S). And move it outside the
extracted folder:
Back to the command prompt, we want to do this now:
Hit Enter and a file will be created on disk, which you can inspect with Notepad++:
Last step, move this
main.lua file to the folder path we created earlier:
And that's it. You're now looking at the original Lua script and placed it in the original path it was designed to be in.
Repeat the process with other .wad/.bin files as you see fit.
"One Ring to bring them all, and in the darkness bind them"
As mentioned, I will try to code a tool that does everything you saw above in one go. The logic is this:
- set the game folder through gowtool settings -g <path_to_game>
- create a list of .wad files from <path_to_game>exec\wad\pc_le
@@loop:
- start processing each file via gowtool wad -p <path_to_wad_file> -o <out_path> -e
- open each file in memory and check the header for the word %PROJ_PATH% (the bytes corresponding to this string)
- create the folder hierarchy based on this %PROJ_PATH%\<tree> value
- find 0x1B + "LuaR" signature and remove the header, thus obtaining the Lua compiled script buffer
- decompile file via unluac.jar
- move it to folder hierarchy created earlier
^ jmp loop till no file left
That's at least what I intend to do. We'll see how this goes
Something like this:
BR,
Sun