Commit graph

34 commits

Author SHA1 Message Date
Gered 7fd21a493c minor cleanups 2021-05-25 10:54:38 -04:00
Gered bf62db4507 add extra validation for .bin function_offset_table_offset 2021-05-25 10:51:45 -04:00
Gered d9e13fade0 add table area validation 2021-05-25 10:46:39 -04:00
Gered d27d9ad072 use wrapping_add here so this doesn't panic when loading non-.dat data 2021-05-25 10:45:28 -04:00
Gered 9dc6e0815e split main into crates for each command available 2021-05-24 19:00:32 -04:00
Gered 4f9ff44be9 add initial psogc_quest_tool utility
only supports showing quest file information
2021-05-24 18:49:41 -04:00
Gered 2da64f97e7 add Display impl for QuestArea 2021-05-24 18:49:02 -04:00
Gered 8a88429250 finish implementing the Quest struct 2021-05-24 16:16:40 -04:00
Gered 6874ed7a8c minor cleanup 2021-05-20 19:33:20 -04:00
Gered aade06d9a9 re-organize some unit tests 2021-05-20 19:32:09 -04:00
Gered 247e2f7482 add unit tests for quest qst loading from bad data 2021-05-20 18:54:48 -04:00
Gered 745c6703c8 switch these checks around so they are run in all cases 2021-05-20 18:54:33 -04:00
Gered 53d2658ea2 minor formatting cleanups 2021-05-20 17:09:22 -04:00
Gered 8aa4fa7c2d add unit tests for quest dat loading from bad data 2021-05-20 17:07:31 -04:00
Gered 8e93f4a3a2 add unit tests for quest bin loading from bad data 2021-05-20 14:21:05 -04:00
Gered 53ec92865b fix up LanguageError 2021-05-20 14:13:22 -04:00
Gered f055daa73d update prs compression functions to catch and return errors
this is probably not an exhaustive set of potential errors, but it
accounts for all the possible ones i've seen as i've been working on
this, that are basically always a result of "bad data".

still a bit worried about potential panics also resulting from bad data
related to overflows and such things ...but have not seen any so far
2021-05-20 13:49:01 -04:00
Gered 5e6dd30fd4 fix offset/len check. oops 2021-05-20 13:45:46 -04:00
Gered 0c57dcb1dd relax ReadFixedLengthByteArray generic constraint a bit
probably not a big deal, but meh, why not
2021-05-20 13:44:15 -04:00
Gered 7850c468ea remove to_fixed_length(), replace usages with to_array()
i don't know how much better or worse either one is really, but i think
i like to_array() better overall. guessing to_array() is probably a bit
better overall, as it should only be one allocation in all cases
2021-05-20 13:37:29 -04:00
Gered 36309879ce add unit tests for writing quest bin/dat/qst to files 2021-05-19 18:50:55 -04:00
Gered 142b03a39b move test assets into test-assets/
i like this better than `assets/tests/`. meh.
2021-05-19 17:58:02 -04:00
Gered 9f60802d37 add qst file support 2021-05-19 17:53:18 -04:00
Gered 20a838abd3 add initial packet stuff, including quest header/data packets 2021-05-18 18:00:47 -04:00
Gered 7f8a8f75e0 allow non-dword-sized data to be passed in to crypt()
this is not actually recommended, as it _technically_ does "mess up"
the sequence (1-3 zero-bytes are being encrypted along with your 1-3
remaining bytes in non-dword-sized data buffers, but those additional
encrypted zero-bytes are not being given back to you at the end).

however, in my opinion, this is quite unlikely to pose a problem for
anyone. for dealing with PSO packets, i'm pretty sure all of those end
up being dword-sized anyway, so no issue there. for encrypting and
decrypting offline quest data, the compressed bin/dat data _could_
technically be non-dword-sized (as i actually encountered today) so you
would otherwise need to pad the input data before calling crypt()
anyway. and in this case you are not going to be using that very same
Crypter instance to do any further encrypting/decrypting ... so it's
actually no problem at all.

so, to me, the convenience of having crypt() just automatically be able
to deal with any arbitrary size of data was worthwhile.

meh.
2021-05-18 15:05:00 -04:00
Gered c59d115aba add helper trait for reading fixed-length byte arrays
a minor thing, but helps turn this pattern into a nice 1-liner
2021-05-17 13:57:08 -04:00
Gered f2ec776d3f unit test cleanups
test using the safe getter methods, instead of directly accessing the
union fields
2021-05-16 20:47:23 -04:00
Gered 4bcc7904c2 minor method naming adjustments 2021-05-16 20:46:21 -04:00
Gered 2ceca5e673 some re-working of quest bin/dat reading/writing methods
get rid of the generalized traits that the read/write methods were
located in. now those methods are just located directly in the struct
impl itself

also cleaned up quest bin/dat errors

added validation checks in quest bin/dat reading
2021-05-16 19:10:06 -04:00
Gered 54a707f860 add to_array helper method 2021-05-16 16:31:14 -04:00
Gered 93c2180da2 call memcmp directly during prs_compress
since we're doing offset/length checks regardless, calling memcmp here
instead of doing a slice comparison is at least twice as fast during
non-release builds. this is nice, as prs_compress can be quite slow
during non-release builds. and obviously during release builds, this
would be compiled down to a memcmp-equivalent anyway.
2021-05-16 16:31:00 -04:00
Gered c84142dfe9 re-work quest errors
use individual error types for both bin and dat modules instead of
all three modules sharing the same error type. maybe marginally better
this way? at least should generally be more clear about whether the
error is related to a bin, dat or general quest processing now
2021-05-15 15:24:49 -04:00
Gered 6c672f3d27 initial quest file bin/dat support
includes loading as compressed/uncompressed. no saving support yet.
2021-05-15 14:48:33 -04:00
Gered c71f9997bd initial commit
starting conversion of these tools over to rust. ported fuzziqer
encryption and prs compression routines over
2021-05-15 14:47:19 -04:00