Did I need to repack the whole contents,not just files needing patched?
Just the files you want to patch should be enough.
Though, I wonder if there's a way to let th155.exe read the created pak. :3
To explain quickly, the pak files' header use RSA encryption. We need a private key to decrypt the header, and a public key to encrypt it.
The game contains the private key, and we can easily extract the key from the game. But Tasofro owns the public key, we can't get it.
For the 1st version of the th135 English patch, Riatre generated a set of private/public keys, and modified the game so that it would try both its original private key and Riatre's one. So the original game wasn't able to read files generated by th135arc, but the English patch could read both.
For the 2nd version of the th135 English patch (several months later), he managed to find the original public key. From what I heard, he computed it from the private key. It took 1 or 2 weeks of processing. But I'm not good enough in computer security to do that kind of things myself.
For the th145 English patch, I had to do something myself, and I decided that the easiest thing to do was to just remove the header encryption in the English patch, and create pak archives with a decrypted header. The English patch tests if the header is encrypted, and either copy the data directly to the game (if it isn't) or just let the game do its usual thing (if it is). It even has the advantage of loading *way* faster. You see the loading time in ULiL before it opens a window? If I unpack/repack both pak file with this and use the English patch, that loading time is almost instant.
For thcrap support, it was easier. Thcrap doesn't work by changing a pak file, it works by changing the game's memory at given moments. So let's just choose a moment
after the game decrypted the file header, that way we don't have to deal with the encryption ourselves!
For th155, the only English patch for now is thcrap - and as I said above, we don't need to deal with encryption. We don't even need to create pak files. So I updated th145arc by giving it the new RSA key, but that's the only change I made when I upgraded it to th155arc (I even forgot to rename it and change the game name in the help message). I never tested the packing feature with th155.
To go further, I wrote documentation here:
https://drive.google.com/drive/u/0/folders/0B1jzCIkoNdTRNFYwQVlJaDdQZUk . "TFPK format" one contains documentation about the format of pak files. "Binary hacks" contains the list of binary hacks I made for th145 (and everything you want to do with reverse-engineering), including the thing to remove encryption. the "D3DX9_43 th145" folder contains the C and ASM code executed when the patch runs. It is kind of the 2nd half of the "Binary hacks" document, and contains the code of the function that do this:
The English patch tests if the header is encrypted, and either copy the data directly to the game (if it isn't) or just let the game do its usual thing (if it is)
I'm also working on building a repository with all the tools for HM/ULiL/AoCF:
https://github.com/brliron/135tk