FanTranslatorsInternational / Kuriimu2

Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
GNU General Public License v3.0
308 stars 56 forks source link

ArgumentOutOfRangeException when opening certain .arc files #268

Open Splodge5 opened 1 year ago

Splodge5 commented 1 year ago

Trying to open .arc files from The Great Ace Attorney Chronicles with Kuriimu2 gives the following error: Specified argument was out of the range of valid values (Parameter 'length') Trying to open the same files with Karameru (installed with Kuriimu 1) gives the same error in more detail:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: length
    at Kontract.IO.SubStream..ctor(Stream baseStream, Int64 offset, Int64 length)
    at
archive_mt.MTARC.<>c__DisplayClass10_0.<ctor>b__1(FileMetadata metadata)
    at
System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
    at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
    at archive_mt.MTARC..ctor(Stream input)
    at archive_mt.MTArcManager.Load(String filename)
    at Karameru.Manager.OpenFile(String filename)
Splodge5 commented 1 year ago

Update: I've found a way to make the files work in Kuriimu2. The structure of most of the TGAAC .arc files has the content start on line 0x8000, and lines 0x0-0x8000 are the header. The header has a 5-byte chunk at the start (the first 3 bits corresponding to "ARC") then can be separated into alternating 128-byte and 16-byte chunks, with the 128-byte chunks containing file name & path data, before the header terminates with as many null bytes as necessary to reach 0x8000. The solution I found was that by trimming down the 128-byte chunks to be 64 bytes each (and padding the end of the header with null bytes to compensate) the file opened perfectly in Kuriimu2. I'm currently using a custom python script to do this but it seems like something that could be written in to the program without too much difficulty.

UltraAssassin64 commented 1 year ago

Hey! I'm having the EXACT same issue rn, would you be willing to help me out a bit as well? :3

Splodge5 commented 1 year ago

Hey! I'm having the EXACT same issue rn, would you be willing to help me out a bit as well? :3

Sure thing, I'm not sure if I should post links here though so it might be easier if you shoot me a message on discord (Splodge5#7141)

UltraAssassin64 commented 1 year ago

Will do! Thanks for replying!