Code: Select all
int ttarch_import_lua(u8 *ext, u8 *buff, int size, u8 **outBuff, int *outSize, int encrypt) {
if(ext && (!stricmp(ext, ".lua") || !stricmp(ext, ".lenc"))) {
if((size >= 3) && (IS_LUA(buff) || (encrypt && gamenum >= 58))) {
(*outBuff) = buff;
(*outSize) = size;
if (gamenum >= 58) {
u8 *newbuff = malloc(sizeof(u8) * (size + 4));
memcpy(newbuff, "\x1bLEo", 4);
memcpy(newbuff + 4, buff, size);
blowfish(newbuff + 4, size, encrypt);
(*outBuff) = newbuff;
(*outSize) = size + 4;
//blowfish(buff, size, encrypt);
} else if (gamenum >= 56) {
memcpy(buff, "\x1bLEn", 4);
blowfish(buff + 4, size - 4, encrypt);
} else {
blowfish(buff, size, encrypt);
}
return 0;
}
}
return -1;
}
Code: Select all
u64 crypt_it(FILE *fd, u8 *fname, u64 offset, int wanted_size /*signed!*/, int encrypt) {
...
u8 *outBuff = NULL;
int outSize = 0;
...
if(wanted_size < 0) {
if(ttarch_import_lua(ext, buff, size, &outBuff, &outSize, encrypt) < 0) {
blowfish(buff, size, encrypt);
}
} else {
if(ttarch_import_lua(ext, buff + offset, wanted_size, &outBuff, &outSize, encrypt) < 0) {
blowfish(buff + offset, wanted_size, encrypt);
}
}
if (outBuff != NULL) {
dumpa(fname, outBuff, outSize, NULL, 0);
return(outSize);
}
dumpa(fname, buff, size, NULL, 0);
return(size);
}
When use:
ttarchext -o -e 0 58 file.lua ..\Output