mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 02:41:55 +01:00
-some more reverting, should be compilable again
This commit is contained in:
parent
08d5f5cd1f
commit
f7bfba3398
@ -388,10 +388,9 @@ static void free_block(wbfs_t *p,int bl)
|
||||
p->freeblks[i] = wbfs_htonl(v | 1 << j);
|
||||
}
|
||||
|
||||
int install_abort_signal = 0;
|
||||
u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data,progress_callback_t spinner,void *spinner_data,partition_selector_t sel,int copy_1_1)
|
||||
{
|
||||
int i,discn,ret;
|
||||
int i,discn;
|
||||
u32 tot,cur;
|
||||
u32 wii_sec_per_wbfs_sect = 1 << (p->wbfs_sec_sz_s - p->wii_sec_sz_s);
|
||||
wiidisc_t *d = 0;
|
||||
@ -451,8 +450,6 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
||||
|
||||
tot = num_wbfs_sect_to_copy * wii_sec_per_wbfs_sect;
|
||||
}
|
||||
|
||||
install_abort_signal = 0;
|
||||
/*
|
||||
// num of hd sectors to copy could be specified directly
|
||||
if (copy_1_1 > 1) {
|
||||
@ -460,6 +457,7 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
||||
num_wbfs_sect_to_copy = copy_1_1 / hd_sec_per_wii_sec / wii_sec_per_wbfs_sect;
|
||||
tot = num_wbfs_sect_to_copy * wii_sec_per_wbfs_sect;
|
||||
}*/
|
||||
int ret = 0;
|
||||
if(spinner) spinner(0, tot, spinner_data);
|
||||
for(i=0; i < num_wbfs_sect_to_copy; i++)
|
||||
{
|
||||
@ -497,22 +495,10 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
||||
if(spinner) spinner(cur,tot,spinner_data);
|
||||
}
|
||||
}
|
||||
if (install_abort_signal) break;
|
||||
if (ret) break;
|
||||
info->wlba_table[i] = wbfs_htons(bl);
|
||||
wbfs_sync(p);
|
||||
}
|
||||
|
||||
if(install_abort_signal)
|
||||
{
|
||||
for(int n = 0; n < i; n++)
|
||||
{
|
||||
u32 iwlba = wbfs_ntohs(info->wlba_table[n]);
|
||||
if (iwlba)
|
||||
free_block(p,iwlba);
|
||||
}
|
||||
wbfs_memset(info,0,p->disc_info_sz);
|
||||
p->head->disc_table[discn] = 0;
|
||||
}
|
||||
|
||||
// write disc info
|
||||
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;
|
||||
p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,info);
|
||||
|
@ -44,12 +44,12 @@ u8 fi[24], ri[24];
|
||||
u32 fkey[120];
|
||||
u32 rkey[120];
|
||||
|
||||
static inline u32 pack(u8 *b)
|
||||
static u32 pack(u8 *b)
|
||||
{ /* pack bytes into a 32-bit Word */
|
||||
return ((u32 ) b[3] << 24) | ((u32 ) b[2] << 16) | ((u32 ) b[1] << 8) | (u32 ) b[0];
|
||||
}
|
||||
|
||||
static inline void unpack(u32 a, u8 *b)
|
||||
static void unpack(u32 a, u8 *b)
|
||||
{ /* unpack bytes from a word */
|
||||
b[0] = (u8 ) a;
|
||||
b[1] = (u8 ) (a >> 8);
|
||||
@ -57,7 +57,7 @@ static inline void unpack(u32 a, u8 *b)
|
||||
b[3] = (u8 ) (a >> 24);
|
||||
}
|
||||
|
||||
static inline u8 xtime(u8 a)
|
||||
static u8 xtime(u8 a)
|
||||
{
|
||||
u8 b;
|
||||
if (a & 0x80)
|
||||
@ -68,14 +68,14 @@ static inline u8 xtime(u8 a)
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline u8 bmul(u8 x, u8 y)
|
||||
static u8 bmul(u8 x, u8 y)
|
||||
{ /* x.y= AntiLog(Log(x) + Log(y)) */
|
||||
if (x && y)
|
||||
return ptab[(ltab[x] + ltab[y]) % 255];
|
||||
else return 0;
|
||||
}
|
||||
|
||||
static inline u32 SubByte(u32 a)
|
||||
static u32 SubByte(u32 a)
|
||||
{
|
||||
u8 b[4];
|
||||
unpack(a, b);
|
||||
@ -86,7 +86,7 @@ static inline u32 SubByte(u32 a)
|
||||
return pack(b);
|
||||
}
|
||||
|
||||
static inline u8 product(u32 x, u32 y)
|
||||
static u8 product(u32 x, u32 y)
|
||||
{ /* dot product of two 4-byte arrays */
|
||||
u8 xb[4], yb[4];
|
||||
unpack(x, xb);
|
||||
@ -94,7 +94,7 @@ static inline u8 product(u32 x, u32 y)
|
||||
return bmul(xb[0], yb[0]) ^ bmul(xb[1], yb[1]) ^ bmul(xb[2], yb[2]) ^ bmul(xb[3], yb[3]);
|
||||
}
|
||||
|
||||
static inline u32 InvMixCol(u32 x)
|
||||
static u32 InvMixCol(u32 x)
|
||||
{ /* matrix Multiplication */
|
||||
u32 y, m;
|
||||
u8 b[4];
|
||||
@ -111,7 +111,7 @@ static inline u32 InvMixCol(u32 x)
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline u8 ByteSub(u8 x)
|
||||
u8 ByteSub(u8 x)
|
||||
{
|
||||
u8 y = ptab[255 - ltab[x]]; /* multiplicative inverse */
|
||||
x = y;
|
||||
@ -127,7 +127,7 @@ static inline u8 ByteSub(u8 x)
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline void gentables(void)
|
||||
void gentables(void)
|
||||
{ /* generate tables */
|
||||
int i;
|
||||
u8 y, b[4];
|
||||
@ -181,7 +181,7 @@ static inline void gentables(void)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gkey(int nb, int nk, char *key)
|
||||
void gkey(int nb, int nk, char *key)
|
||||
{ /* blocksize=32*nb bits. Key=32*nk bits */
|
||||
/* currently nb,bk = 4, 6 or 8 */
|
||||
/* key comes as 4*Nk bytes */
|
||||
@ -266,7 +266,7 @@ static inline void gkey(int nb, int nk, char *key)
|
||||
* Instead of just one ftable[], I could have 4, the other *
|
||||
* 3 pre-rotated to save the ROTL8, ROTL16 and ROTL24 overhead */
|
||||
|
||||
static inline void encrypt(char *buff)
|
||||
void encrypt(char *buff)
|
||||
{
|
||||
int i, j, k, m;
|
||||
u32 a[8], b[8], *x, *y, *t;
|
||||
@ -312,7 +312,7 @@ static inline void encrypt(char *buff)
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void decrypt(char *buff)
|
||||
void decrypt(char *buff)
|
||||
{
|
||||
int i, j, k, m;
|
||||
u32 a[8], b[8], *x, *y, *t;
|
||||
|
@ -27,8 +27,13 @@ static void _decrypt_title_key(u8 *tik, u8 *title_key)
|
||||
wbfs_memset(iv, 0, sizeof iv);
|
||||
wbfs_memcpy(iv, tik + 0x01dc, 8);
|
||||
aes_set_key(common_key);
|
||||
//_aes_cbc_dec(common_key, iv, tik + 0x01bf, 16, title_key);
|
||||
aes_decrypt(iv, tik + 0x01bf, title_key, 16);
|
||||
}
|
||||
static u32 _be32(const u8 *p)
|
||||
{
|
||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
}
|
||||
|
||||
static void disc_read(wiidisc_t *d, u32 offset, u8 *data, u32 len)
|
||||
{
|
||||
@ -102,8 +107,8 @@ static u32 do_fst(wiidisc_t *d, u8 *fst, const char *names, u32 i)
|
||||
const char *name;
|
||||
u32 j;
|
||||
|
||||
name = names + (wbfs_be32(fst + 12 * i) & 0x00ffffff);
|
||||
size = wbfs_be32(fst + 12 * i + 8);
|
||||
name = names + (_be32(fst + 12 * i) & 0x00ffffff);
|
||||
size = _be32(fst + 12 * i + 8);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
@ -122,7 +127,7 @@ static u32 do_fst(wiidisc_t *d, u8 *fst, const char *names, u32 i)
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = wbfs_be32(fst + 12 * i + 4);
|
||||
offset = _be32(fst + 12 * i + 4);
|
||||
if (d->extract_pathname && strcasecmp(name, d->extract_pathname) == 0)
|
||||
{
|
||||
d->extracted_buffer = wbfs_ioalloc(size);
|
||||
@ -150,13 +155,13 @@ static void do_files(wiidisc_t*d)
|
||||
u32 n_files;
|
||||
partition_read(d, 0, b, 0x480, 0);
|
||||
|
||||
dol_offset = wbfs_be32(b + 0x0420);
|
||||
fst_offset = wbfs_be32(b + 0x0424);
|
||||
fst_size = wbfs_be32(b + 0x0428) << 2;
|
||||
dol_offset = _be32(b + 0x0420);
|
||||
fst_offset = _be32(b + 0x0424);
|
||||
fst_size = _be32(b + 0x0428) << 2;
|
||||
|
||||
apl_offset = 0x2440 >> 2;
|
||||
partition_read(d, apl_offset, apl_header, 0x20, 0);
|
||||
apl_size = 0x20 + wbfs_be32(apl_header + 0x14) + wbfs_be32(apl_header + 0x18);
|
||||
apl_size = 0x20 + _be32(apl_header + 0x14) + _be32(apl_header + 0x18);
|
||||
// fake read dol and partition
|
||||
if (apl_size) partition_read(d, apl_offset, 0, apl_size, 1);
|
||||
partition_read(d, dol_offset, 0, (fst_offset - dol_offset) << 2, 1);
|
||||
@ -166,7 +171,7 @@ static void do_files(wiidisc_t*d)
|
||||
fst = wbfs_ioalloc(fst_size);
|
||||
if (fst == 0) wbfs_fatal("malloc fst");
|
||||
partition_read(d, fst_offset, fst, fst_size,0);
|
||||
n_files = wbfs_be32(fst + 8);
|
||||
n_files = _be32(fst + 8);
|
||||
|
||||
|
||||
if (d->extract_pathname && strcmp(d->extract_pathname, "FST") == 0)
|
||||
@ -204,12 +209,12 @@ static void do_partition(wiidisc_t*d)
|
||||
partition_raw_read(d, 0, tik, 0x2a4);
|
||||
partition_raw_read(d, 0x2a4 >> 2, b, 0x1c);
|
||||
|
||||
tmd_size = wbfs_be32(b);
|
||||
tmd_offset = wbfs_be32(b + 4);
|
||||
cert_size = wbfs_be32(b + 8);
|
||||
cert_offset = wbfs_be32(b + 0x0c);
|
||||
h3_offset = wbfs_be32(b + 0x10);
|
||||
d->partition_data_offset = wbfs_be32(b + 0x14);
|
||||
tmd_size = _be32(b);
|
||||
tmd_offset = _be32(b + 4);
|
||||
cert_size = _be32(b + 8);
|
||||
cert_offset = _be32(b + 0x0c);
|
||||
h3_offset = _be32(b + 0x10);
|
||||
d->partition_data_offset = _be32(b + 0x14);
|
||||
d->partition_block = (d->partition_raw_offset + d->partition_data_offset) >> 13;
|
||||
tmd = wbfs_ioalloc(tmd_size);
|
||||
if (tmd == 0) wbfs_fatal("malloc tmd");
|
||||
@ -261,7 +266,7 @@ static void do_disc(wiidisc_t *d)
|
||||
u32 magic;
|
||||
u32 i;
|
||||
disc_read(d, 0, b, 0x100);
|
||||
magic = wbfs_be32(b + 24);
|
||||
magic = _be32(b + 24);
|
||||
if (magic != 0x5D1C9EA3)
|
||||
{
|
||||
wbfs_iofree(b);
|
||||
@ -269,12 +274,12 @@ static void do_disc(wiidisc_t *d)
|
||||
return ;
|
||||
}
|
||||
disc_read(d, 0x40000 >> 2, b, 0x100);
|
||||
n_partitions = wbfs_be32(b);
|
||||
disc_read(d, wbfs_be32(b + 4), b, 0x100);
|
||||
n_partitions = _be32(b);
|
||||
disc_read(d, _be32(b + 4), b, 0x100);
|
||||
for (i = 0; i < n_partitions; i++)
|
||||
{
|
||||
partition_offset[i] = wbfs_be32(b + 8 * i);
|
||||
partition_type[i] = wbfs_be32(b + 8 * i + 4);
|
||||
partition_offset[i] = _be32(b + 8 * i);
|
||||
partition_type[i] = _be32(b + 8 * i + 4);
|
||||
}
|
||||
for (i = 0; i < n_partitions; i++)
|
||||
{
|
||||
@ -342,16 +347,16 @@ void wd_fix_partition_table(wiidisc_t *d, partition_selector_t selector, u8 *par
|
||||
u32 n_partitions, i, j;
|
||||
u32 *b32;
|
||||
if (selector == ALL_PARTITIONS) return;
|
||||
n_partitions = wbfs_be32(b);
|
||||
if (wbfs_be32(b + 4) - (0x40000 >> 2) > 0x50)
|
||||
n_partitions = _be32(b);
|
||||
if (_be32(b + 4) - (0x40000 >> 2) > 0x50)
|
||||
wbfs_fatal("cannot modify this partition table. Please report the bug.");
|
||||
|
||||
b += (wbfs_be32(b + 4) - (0x40000 >> 2)) * 4;
|
||||
b += (_be32(b + 4) - (0x40000 >> 2)) * 4;
|
||||
j = 0;
|
||||
for (i = 0; i < n_partitions; i++)
|
||||
{
|
||||
partition_offset = wbfs_be32(b + 8 * i);
|
||||
partition_type = wbfs_be32(b + 8 * i + 4);
|
||||
partition_offset = _be32(b + 8 * i);
|
||||
partition_type = _be32(b + 8 * i + 4);
|
||||
if (!test_parition_skip(partition_type, selector))
|
||||
{
|
||||
b32 = (u32*)(b + 8 * j);
|
||||
|
Loading…
Reference in New Issue
Block a user