Hi All!
I recently developed a decompressor for dolphin's save states. It should work fine 'cose is based on the decompression code of dolphin.
Reading the "loading save state code", i noticed something strange.
Checking if the save state is compressed or not. If the save is decompressed, the code reads in the buffer the wrong data i think:
I recently developed a decompressor for dolphin's save states. It should work fine 'cose is based on the decompression code of dolphin.
Reading the "loading save state code", i noticed something strange.
Code:
fread(&header, sizeof(state_header), 1, f);
...
sz = header.sz;
bCompressedState = (sz != 0);
if (bCompressedState)
{
Core::DisplayMessage("Decompressing State...", 500);
lzo_uint i = 0;
buffer = new u8[sz];
...
while (true)
{
lzo_uint cur_len = 0;
lzo_uint new_len = 0;
if (fread(&cur_len, 1, sizeof(int), f) == 0)
break;
if (feof(f))
break; // don't know if this happens.
fread(out, 1, cur_len, f);
int res = lzo1x_decompress(out, cur_len, (buffer + i), &new_len, NULL);
i += new_len;
}
}
else
{
fseek(f, 0, SEEK_END);
sz = (int)(ftell(f) - sizeof(int));
fseek(f, sizeof(int), SEEK_SET);
buffer = new u8[sz];
fread(buffer, 1, sz, f);
}Checking if the save state is compressed or not. If the save is decompressed, the code reads in the buffer the wrong data i think:
Code:
fseek(f, 0, SEEK_END);
sz = (int)(ftell(f) - sizeof(int)); <-- should exclude the header size, not int size
fseek(f, sizeof(int), SEEK_SET); <-- should seek after header size, not int size
buffer = new u8[sz];
fread(buffer, 1, sz, f);