Giter Club home page Giter Club logo

easage's Introduction

easage

Build Status Build Status GitHub (pre-)release Chat on IRC

A library that provides programmatic manipulation of BIG archives.


What is a BIG archive?

BIG files are an archive format used in many games published by Electronic Arts. The supported features vary between games, with some using compression or encryption, but for SAGE, the files are trivially concatenated together and wrapped with a header containing a series of index entries that located a given file within the archive.

Note: The above was lifted directly from https://github.com/TheAssemblyArmada/Thyme/wiki/BIG-File-Format

Notable games built on the SAGE engine are:

  • Battle For Middle-Earth (1, 2, RotWK)
  • Command & Conquer Generals (and the expansion Zero Hour)

Building

You must have the Rust toolchain installed (which includes cargo):

cargo build --release

Testing

To run the included unit tests execute the following command in the root of the project:

cargo test

We do require that all tests pass before a PR is merged.

If you need help getting a test to pass (existing or one you have written) do not hesitate to reach out to us (either via GitHub issues or on IRC).

Running

Included in this source tree is a command-line application named easage that uses the easage library.

See the src/bin/ directory for more details.


See contrib for more usage suggestions.

Getting help

I am often present in the #orcaware channel on irc.freenode.net.

Note that this channel has many topics of discussion so you may see conversation about other projects there too.

If IRC is not your thing or you don't get a good response I am happy to respond to GitHub issues as well.

License

MIT

Contributing

Any contribution you intentionally submit for inclusion in the work, as defined in the LICENSE.md file, shall be licensed as above, and are subject to the project's CLA.

easage's People

Contributors

phrohdoh avatar teteros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

easage's Issues

Cut down on the noise that easage-list generates

easage list is quite noisy at the moment.

Planned changes:

  • Introduce a --verbose flag
  • Output only entry names if the verbose flag is not present
  • Output the currently-outputted information if the verbose flag is present

For reference this is what easage list currently produces on a test BIG archive I have locally:

Archive:
  kind: BigF
  size: 218
  len: 2
  data start: 0x36
Entries:
  test/b.txt
    offset: 0x36
    len: 20
  test/a.txt
    offset: 0x4a
    len: 144

Require library users to decide on entry order criteria when packing

ab256a1 added a TODO that this ticket covers.

The writer module's pack_directory function will want to take in a settings/options/configuration/etc. struct that contains a EntryOrderCriteria enum variant.

pub struct Settings {
    entry_order_criteria: EntryOrderCriteria,
}

pub enum EntryOrderCriteria {
    Length,
    Path,
}

easage-list.cmd

Hello, can you let this command to print out a log file ?

BIGF archives packed by easage are corrupted

Test case:

Original ControlBar.wnd from WindowSource

└> cat WindowSource/ControlBar.wnd | md5sum
325877c142f77f6f7c2b89756c709bd2  -

ControlBar.wnd packed by FinalBIG and extracted by easage unpack

└> cat WindowFinalBigOut/ControlBar.wnd | md5sum
325877c142f77f6f7c2b89756c709bd2  -

ControlBar.wnd packed by easage pack and extracted by easage unpack

└> cat WindowEasageOut/ControlBar.wnd |md5sum
9d8ee3949c812da38ce5267534d4858f  -

easage list data start: offset differs

$ ./easage list window-easage.big
Archive:
  kind: BigF
  size: 1994438
  len: 7
  data start: 0x139
Entries:
  Window/Menus/MapSelectMenu.wnd
    offset: 0x139
    len: 60534
  Window/Menus/LanMapSelectMenu.wnd
    offset: 0xedaf
    len: 68064
  Window/Menus/SkirmishGameOptionsMenu.wnd
    offset: 0x6d798
    len: 929866
  Window/ControlBar.wnd
    offset: 0x10bd5
    len: 351194
  Window/Menus/WOLMapSelectMenu.wnd
    offset: 0x10b19
    len: 68120
  Window/Menus/SkirmishMapSelectMenu.wnd
    offset: 0x10b51
    len: 68252
  Window/Menus/OptionsMenu.wnd
    offset: 0x55d13
    len: 448095


$ ./easage list window-finalbig.big

Archive:
  kind: BigF
  size: 1994435
  len: 7
  data start: 0x135
Entries:
  Window\Menus\MapSelectMenu.wnd
    offset: 0x666f0
    len: 60534
  Window\Menus\OptionsMenu.wnd
    offset: 0x75366
    len: 448095
  Window\ControlBar.wnd
    offset: 0x136
    len: 351194
  Window\Menus\SkirmishMapSelectMenu.wnd
    offset: 0x1c5a0f
    len: 68252
  Window\Menus\LanMapSelectMenu.wnd
    offset: 0x55d10
    len: 68064
  Window\Menus\WOLMapSelectMenu.wnd
    offset: 0x1d64ab
    len: 68120
  Window\Menus\SkirmishGameOptionsMenu.wnd
    offset: 0xe29c5
    len: 929866

Attachment

Includes x64 linux and windows easage

easage-bigf.zip

easage-pack: Set defaults for BIGF kind

As discussed on IRC and in #8:

I'd like to suggest defaults for easage-pack under current functionality should be to target BIGF by default, and to list by path rather than lenght/file size. (finalbig behaviour)

This would make

easage pack --source foo --output bar.big

be equivalent to

easage pack --kind BIGF --order path --source foo --output bar.big

It's worth a mention that completions are available on windows (#25)
but I think setting defaults for the most common use case is still the norm in archivers.

Document VC++ x64 requirement

Conversation from IRC:

14:04:13 triatomic recently updated to latest windows 10 via fast ring image 
14:04:18           esage binary throwing me a dependency error 
14:04:23           VCRUNTIME140.dll 
14:04:47           its weird cause i believe i didn't have that on older windows 10 :( 
14:05:09 @Phrohdoh hm, give me a moment 
14:05:27 triatomic this is the CLI version 
14:05:48 @Phrohdoh Are you able to determine which version of the vcruntime you currently have installed? (probably via the Control Panel) 
14:06:22 triatomic last one installed is 2015 
14:06:24 @Phrohdoh Or possibly query the registry: https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
14:06:51           Well, I'm more wondering if you have the x86 or x64 version installed. 
14:07:10 triatomic (x86) 
14:07:46           ok gona install the (x64) 
14:07:49 @Phrohdoh Would you install the latest x64 https://support.microsoft.com/bn-bd/help/2977003/the-latest-supported-visual-c-downloads and see if that changes anything? 
14:08:24 triatomic worked :D 
14:08:34 @Phrohdoh Great! 
14:08:47 triatomic usually when i install AOEII:HD it installs those
14:09:36 @Phrohdoh BTW did you install the 2015 or 2017 version just now? 
14:09:45 triatomic 2015 (x64) 

We should create a wiki page with errors and associated resolutions starting with this one.

Error

The code execution cannot proceed because VCRUNTIME140.dll was not found.
Reinstalling the program may fix this problem.

Resolution

Install the 64-bit VC++ runtime (in this case the 2015 version is a known-working version).

easage-unpack: --names cannot be used with specified arguments

$ ./easage unpack --output out --source foo.big --names 'Data/INI/GameData.ini'

error: The argument '--names <names>...' cannot be used with one or more of the other specified arguments

USAGE:
    easage unpack --output <output> --source <source> <--names <names>...|--all>

For more information try --help

From IRC:

@Phrohdoh │ teteros: oh huh
        ⤷ │ that is talking about a mutually exclusive arg
        ⤷ │ maybe a bug in clap
  teteros │ hm
@Phrohdoh │ https://github.com/Phrohdoh/easage/blob/b743a234921720198c0c15b4276e9542b0415b5b/src/bin/easage_unpack.rs#L30-L38
@Phrohdoh │ Also it looks like there is a logic bug in
          │ https://github.com/Phrohdoh/easage/blob/b743a234921720198c0c15b4276e9542b0415b5b/src/bin/easage_unpack.rs#L50-L54

Handle error on write-protected directories better

SAGE games like Generals can default their installation to C:\Program Files or C:\Program Files (x86) on x64 systems which you need UAC/Administrator privilidges to write for.

easage will fail if it does not have a "Run as Administrator" compatibility flag set, or is not elevated in other ways with I/O errors such as:

ss

on easage pack

and

ss

on easage unpack

We should let the user know why reading/writing is failing and possibly offer to elevate permissions (UAC Yes/No prompt) if easage detects it has no read/write permissions in output folder.

Implement adding files to an existing archive

A quick note from IRC:

there is a table of entry infos after the BIG header that has to be adjusted (which means the offsets in said table all need to be changed because the size of the table will change)

This also means the entire file has to be re-written.

Setup CI infrastructure

  • Automatically compile all PRs
  • Automatically test all PRs
  • Automatically deploy native binaries to GitHub when new a tag is pushed

Backslashes are not converted to directories on Unix-like systems

BIG archives made on Windows currently do not retain directory trees on Unix-like machines.
Backslashes \ are not converted to directories / (on e.g. linux) essentially.

Test case:

On Windows

mkdir foo & echo baz >foo\bar & easage pack --source foo --output foo.big

On Linux

easage list foo.big
Archive:
  kind: Big4
  size: 50
  len: 1
  data start: 0x2b
Entries:
  foo\bar
    offset: 0x2b
    len: 7
> easage extract --output . --source foo.big
└> ls -la
total 8
drwxr-xr-x  2 tete tete  80 Oct 23 13:34  .
drwxrwxrwt 10 root root 320 Oct 23 13:33  ..
-rw-r--r--  1 tete tete   7 Oct 23 13:34 'foo\bar'
-rw-r--r--  1 tete tete  50 Oct 23 13:27  foo.big

Expected: foo/bar

i.e. bar in folder called foo

The opposite works however

BIG archives created on Linux with easage pack will extract on Windows machines with folder paths respected.

foo.big with \ paths attached below

(wrapped in .zip due to github attachment support)
foo.big.zip

Rewrite archive 'packing' to be more flexible

Currently we only support 'packing' a directory recursively.

Ideally a user of the library would be able to pack any (name, data) items into an archive.

Possible function signatures (not the only options though!):

pub fn pack(items: Vec<(String, &[u8])>, settings: Settings) -> Result<Archive>;
pub fn pack(items: Vec<(String, &[u8])>, settings: Settings) -> Result<Vec<u8>>;
pub fn pack(buf: &mut [u8], items: Vec<(String, &[u8])>, settings: Settings) -> Result<usize>;

At this point library users could pack from a (collected) TCP stream if they felt so inclined.


Note: This will make unit testing the contents of an Archive simple (ref #38).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.