Hacking The Star Wars: Empire At War Demo

Apparently just two days after the demo’s release, some clever file hackers have already found ways to extract restricted content and modify designs in the demo itself.

What you need:
-The demo.Download here
-The megExtractor.exe and megInserter.exe, used to edit MEG files and Tools to edit in game text (check article below for usage). Both files are attached.
-You can view some demos created with this hack here

Extract the files into the game’s Data directory after backing up the originals
Makes the Empire playable, uses new vehicles, opens a new planet. EaW stores all its files in .meg files (short for Mega Files, how creative). As it turns out, they’re really straight forward, non-compresed data files, chock full of TGAs, MP3s, BIKs, and a crap load of LUA, XML, and TXT files that describe EVERY aspect of the game.

Config.meg – all the important data that makes configures the game (all the fun stuff!)

Everything else is really self explanatory. Movies are stored in the BINK video format (BIK), music is stored as MP3s, maps and models appear to be proprietary, and I haven’t checked the rest (textures might be TGAs).

As far as I see it, each MEG file consists of four parts – the number of files in it, the file name list, the file info list, and the files themselves. The tricky thing is that each of the latter three segments can be in different orders – the file info segment points to a filename and the data. (This threw me off at first, with a movie called Vader_Loop2 showing a rebel trooper.)

All numbers are stored least significant byte first, meaning the long 0x12345678 is stored [78][56][34][12]
//begin MEG file
[4 BYTES – NUMBER OF ENTRIES] (yup, it’s there twice. beats me?)
for each file
[n BYTES – FILENAME] (plain old ascii)
for each file
[4 BYTES – WTF VALUE] (see note below)
[4 BYTES – INDEX] (starts at zero, increases by one with each sequential file)
[4 BYTES – START OF DATA] (where the actual file data starts within the MEG file)
[4 BYTES – FILENAME] (points to a name in the filename table, with the first being zero)
for each file
//end MEG file

So yeah, that’s it. No encryption. No compression.
The wtf value is a value I can’t quite figure out – it appears to be some sort of percentage, as it increases from 00000000 to FFFFFFFF (four bytes) regardless of if the MEG has 20 or 2000 files. When you extract a MEG, it saves the wtf value with the filename in the list, and is reinserted when you rebuild the MEG file. Because of this, all I’ve really done is edit files. When a new file needed to be created, I simply replaced the contents of an old one, such as just making changes to the demo mission to make my own.

You can use the tools from file above.
megExtractor.exe will extract all the files out, and megInserter.exe will rebuild the MEG file.
If you run megExtractor.exe and type Config, it’ll attempt to load Config.meg, create a folder called Config, and will proceed to extract all the files into that folder. Doing the same in megInserter.exe will create Config.meg out of all the files in the Config folder. Pretty straight forward. Thus, to make changes, run megExtractor.exe, edit the files accordingly, and then run megInserter.exe – you’ll have a new MEG file with your changes, ready to be dropped in the game’s Data directory.

Some tips I picked up while browsing Config.meg:
– To enable play as the empire, simply move the Empire faction above the Rebel faction in DATAXMLFACTIONS.XML (it disables the second faction by default for purposes of the demo).

– An incredible amount of content is available (around 2000 models). However, the limiting feature is the maps: there are only 5, and most of them come with units already on the map. Thus, for my test mod, I simply used the asteroids level’s space map and replaced the tutorial maps with it with a different color background for each planet.

– You can configure the maps linked to a planet in DATAXMLPLANETS.XML, and can configure if you can build on land with Planet_Surface_Accessible.

– The demo campaign is located in DATAXMLCAMPAIGNS_SINGLEPLAYER.XML under the second instance of the word ‘demo’ (do a search). From here you can set home worlds, victory conditions, and starting units (including ones not used in the demo, like the Mon Calamari cruiser). To change which planets are shown, go into DATAXMLSTORY_SANDBOX_DEMO_REBEL.XML, which enables the view of planets and centers the camera (and I imagine lots of other stuff waiting to be enabled).

– Individal units are editable in GROUNDINFANTRY.XML, GROUNDVEHICLES.XML, and the SPACEUNITS*.XML files (along with some others), but the configurations for their groupings appear in files like SQUADRONS.XML and GROUNDCOMPANIES*.XML. The same thing applies for heroes.
And tons of other stuff I don’t have time to list (need some sleep before economics class).

Overall, I’m impressed with Petroglyph. This is definately an incredible game – it just needs a bigger demo. Here’s to hoping that they don’t do anything about their data files in the final version of the game – with the looks of that it supports custom levels, modding will be a blast!
Star Wars: Empire at War Tools – txtExtractor and txtInserter

*****using the tools*****
Use is just like with the Mega file suite; drop in a text database DAT file and run txtExtractor to make an editable version (complete with wtf value). Edit to your heart’s content and use txtInserter to rebuild the DAT file. Same thing goes as before: until I spend time figuring out what the wtf value is, don’t erase or add entries. Just edit the ones already there; with the full game content just sitting there, there’s plenty of file names for everyone.

Length is entries is changable too, just the number of entries is fixed for now. That means that the entry NAME is changable too, not just the text (should be). Note: All the unicode characters get wiped out as I simply dropped the second byte. The only problem I’ve seen so far is what I presume was a bullet turning into some weird high-ascii character in the objectives screen. Not a big deal to me, as you could just use an asterix or a dash (or hex edit for that matter).

***the .DAT file type:***
Each entry has a wtf value (see MEG description), a name (used to reference it
in various files, like the TXT scripts), and the text itself.
//begin DAT file
for each file
for each file
[2*n BYTES – TEXT] (stored in unicode, meaning two bytes per character)
for each file
[m BYTES – NAME] (stored in normal ascii)
//end DAT file

Unlike MEG files, data is sequential. The first entry’s text appears as the first n*2 characters in the text section, and its name appears as the first m characters in the name section. Pretty straight forward.

Leave a Reply