Page 2 of 3

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 3:57 am
by chrrox
I might get to it this weekend.
Just look at the psarc format it is 99% identical to it.
its just inflate compression chunks.

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 1:41 pm
by Rick
Has nothing to do with psarc.

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 7:00 pm
by EcheloCross
I'm getting some similar results as quickbms using ICSharpCode.SharpZipLib.Zip.Compression; as some of the files the bms script tries seem to start inflating.
I told the inflater's SetInput() to use from the 8th byte of of the chunk the container is referring to.
I also got a similar result by trying from the 11th byte in another file.

I get these results after the inflate attempt on patch_compressed.vpp_xbox2 from TU1.
(The Title Update can be found on xbuc.net if anyone wants to try on the same file. Just search for its media id 130ABF66.)

jump_sm.xtbl
0x31 0x00 0x00 0x00 0x00 .....
pause_save_game.lua
0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x00 0x31 0x32 0x00 0x00 0x00 0x00 .....

Its like the inflater is trying because it doesn't throw an exception when I tell it where the real zlib data starts, but I may not be passing the correct chunk size or not looping correctly.

Anyone get similar results trying to inflate headerless zlib data?

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 7:44 pm
by chrrox
Rick wrote:Has nothing to do with psarc.
are you working on an editor?
If so i wont make a quickbms script.
from what i have seen its just using zlib chunks very simple format.

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 8:20 pm
by Ekey
Here tools by ThomasJepp for pack/unpack packs and localization.. Source code here

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 8:24 pm
by howfie
I thought on Rick's site Volition said they were going to (and have released some minor) extracting tools. The fact that they said they were going to release file format information, extracting tools, and an importer/exporter, I think we should all just wait to save us from wasting a lot of time. Then people can figure out the PS3 and XBox360 formats after the PC tools are released.

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 9:06 pm
by chrrox
cool tools released here was what i was working on in bms that is not needed. Also i dint put in padding that i think is needed in the format.

Code: Select all

endian big
comtype DEFLATE_NOERROR
IDSTRING "\x51\x89\x0A\xCE\x00\x00\x00\x0A"

get checksum long         
get ARCSIZE long
get UNKSIZE long
get FILES long
get NOFF long
get TOFF long
get TASIZE long
get TAZSIZE long
math NOFF + 0x28
math TOFF += NOFF
savepos TMP
for i = 0 < 2
   goto TMP
   #print "%TMP%"
   get NAME_OFF long   
   get MEM_OFFSET longlong
   get TSIZE long
   get TZSIZE long
   set FSIZE 0
   get COMPTYPE long
   savepos TMP
   math NAME_OFF + NOFF
   goto NAME_OFF
   #print "%NAME_OFF%"
   get NAME STRING
   if TSIZE != TZSIZE
   append
   Do
   goto TOFF
   get ZSIZE short
   math TOFF + ZSIZE
   math TOFF + 8
   get NULL short
   get SIZE long
   savepos OFFSET
   #print "%TOFF%, %OFFSET% , %ZSIZE% , %SIZE%"
   clog MEMORY_FILE OFFSET ZSIZE SIZE
   get FSIZE asize MEMORY_FILE
   #print "%FSIZE%, %TSIZE%"
   while FSIZE < TSIZE
   append
   log NAME 0 TSIZE MEMORY_FILE
   else
   goto TOFF
   savepos OFFSET
   log NAME OFFSET TSIZE
   math TOFF + TSIZE
   endif
next i

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 9:17 pm
by michalss
Here is Editor for X360

What can this editor do?
As of the current version (0.0.4), it can:
- Open Archive
- Extract Files
- Replace Files
- Save/Rebuild Archive

Download Binary :

Code: Select all

http://www.mediafire.com/download/enhqu8jo0ylxqb6/SR4_VPP.exe
Download Source

Code: Select all

http://www.mediafire.com/download/xxcjtdwecl58j9w/SR4_VPP_%5BSource%5D_%5BC%23%5D.zip
Autor : XBLToothPik


It does not decompress files, coz he does not know what compression is used. If you know this plsease advice and he will implement it

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 9:39 pm
by XBLToothPik
@Michalss

The editor isn't complete & not everything in the source is right as of now. Been waiting on more info before I finish it.

Re: Saints row IV ps3_vpp.

Posted: Thu Aug 29, 2013 10:56 pm
by howfie
somebody said xbox and ps3 files are identical just different endian, so i'm assuming zlib. post a screenshot of the hex where the compressed data starts. the PC files contain the zlib prefix 78DA so i don't think the xbox one will have the missing prefix. if it's a different compression i would first try one of the LZOs or the xmemcompress as they are fairly common to the xbox.

Re: Saints row IV ps3_vpp.

Posted: Fri Aug 30, 2013 1:39 am
by EcheloCross
howfie wrote:somebody said xbox and ps3 files are identical just different endian, so i'm assuming zlib. post a screenshot of the hex where the compressed data starts. the PC files contain the zlib prefix 78DA so i don't think the xbox one will have the missing prefix. if it's a different compression i would first try one of the LZOs or the xmemcompress as they are fairly common to the xbox.
The compressed data in the xbox360 file does not contain a regular zlib header. It may have some kind of truncated zlib header though.
I've yet to try XMemDecompress(), but was thinking about trying it next.

Here are some of the methods I've tried in C#....
Props to all who have been working on this. :)

This one attempts to use an ICSharpZipLib Inflater. I get the same results as Gh0stBlade's v1.2 bms script on some files.

Code: Select all

public byte[] Inflate(byte[] inputData)
{
    Inflater inflater = new Inflater(true);
    using (var inputStream = new MemoryStream(inputData))
    using (var ms = new MemoryStream())
    {
        var inputBuffer = new byte[4096];
        var outputBuffer = new byte[4096];        

        while (inputStream.Position < inputData.Length)
        {
            var read = inputStream.Read(inputBuffer, 0, inputBuffer.Length);

            inflater.SetInput(inputBuffer, 11, (read - 11));

            while (inflater.IsNeedingInput == false)
            {
                var written = inflater.Inflate(outputBuffer, 0, outputBuffer.Length);

                if (written == 0)
                    break;

                ms.Write(outputBuffer, 0, written);
            }

            if (inflater.IsFinished == true)
                break;
        }

        inflater.Reset();

        return ms.ToArray();
    }
}
The next one I pulled from Rick's Volition source. This method was returning an error something like bad header checksum, as I think it attempts to decompress using a normal zlib header.

Code: Select all

public byte[] ZLibDecompress(byte[] zLibCompressedBuffer)
{
    byte[] resBuffer = null;

    MemoryStream mInStream = new MemoryStream(zLibCompressedBuffer);
    MemoryStream mOutStream = new MemoryStream(zLibCompressedBuffer.Length);
    InflaterInputStream infStream = new InflaterInputStream(mInStream);

    mInStream.Position = 0;

    try
    {
        byte[] tmpBuffer = new byte[zLibCompressedBuffer.Length];
        int read = 0;

        do
        {
            read = infStream.Read(tmpBuffer, 0, tmpBuffer.Length);
            if (read > 0)
                mOutStream.Write(tmpBuffer, 0, read);

        } while (read > 0);

        resBuffer = mOutStream.ToArray();
    }
    finally
    {
        infStream.Close();
        mInStream.Close();
        mOutStream.Close();
    }

    return resBuffer;
}
The next one I tried is pulled from the SR4 VPP source posted above. This one returned similar errors (broken uncompressed block, unknown block type).

Code: Select all

public static byte[] Decompress(byte[] data)
{
    var compressedStream = new MemoryStream(data);
    var zipStream = new DeflateStream(compressedStream, CompressionMode.Decompress);

    var resultStream = new MemoryStream();

    var buffer = new byte[4096];
    int read;

    while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0)
        resultStream.Write(buffer, 0, read);

    return resultStream.ToArray();
}
Another one I tried is based on the ThomasJepp source posted above. This code specifically tests jump_sm.xtbl from TU1 on the xbox.

Code: Select all

byte[] fileTmp = File.ReadAllBytes(this.textBox1.Text);
Stream stream = File.OpenRead(this.textBox1.Text);
Stream DataStream;
stream.Read(fileTmp, 0, fileTmp.Length);
FileStream fs = new FileStream(currentPath + "\\" + Path.GetFileNameWithoutExtension(currentFile) + ".test.bin", FileMode.Create, FileAccess.Write);
using (MemoryStream tempStream = new MemoryStream(fileTmp))
{
    using (Stream s = new ZlibStream(tempStream, CompressionMode.Decompress, true))
    {
        byte[] uncompressedData = new byte[64411];
        s.Read(uncompressedData, 0, uncompressedData.Length);
        DataStream = new MemoryStream(uncompressedData);
        DataStream.CopyTo(fs);
    }
}
fs.Close();
I also tried some other quick tests using a few different methods. Again with various errors.

Code: Select all

---------------------------------------------------------------------------------------------------
FileStream s1 = new FileStream(this.textBox1.Text, FileMode.Open, FileAccess.Read);
FileStream sw1 = new FileStream(this.textBox1.Text + ".test.bin", FileMode.Create, FileAccess.Write);
DeflateStream ds1 = new DeflateStream(s1, CompressionMode.Decompress);
ds1.CopyTo(sw1);
ds1.Dispose();
s1.Close();
sw1.Close();
---------------------------------------------------------------------------------------------------
byte[] dst = new byte[UInt32.Parse(vx2SectionTable[(int)i][2])];
Inflater ifr = new Inflater(true);
ifr.SetInput(fileTmp, 8, (fileTmp.Length - 8));
ifr.Inflate(dst, 0, dst.Length);
File.WriteAllBytes(currentPath + "\\" + Path.GetFileNameWithoutExtension(currentFile) + "_compressed_files\\decompressed\\" + vx2NamesTable[(int)i], dst);
ifr.Reset();
---------------------------------------------------------------------------------------------------
byte[] dst = new byte[UInt32.Parse(vx2SectionTable[(int)i][2])];
[DllImport("zlib1.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int uncompress(byte[] dest, ref uint destLen, byte[] source, uint sourceLen);
uint dstSize = UInt32.Parse(vx2SectionTable[(int)i][2]);
uint srcSize = UInt32.Parse(vx2SectionTable[(int)i][3]);
uncompress(dst, ref dstSize, fileTmp, (uint)srcSize);
File.WriteAllBytes(currentPath + "\\" + Path.GetFileNameWithoutExtension(currentFile) + "_compressed_files\\decompressed\\" + vx2NamesTable[(int)i], dst);
---------------------------------------------------------------------------------------------------
I'm not using the alignment or compression flags that look like they are there in the header sections. Has anyone made any progress on inflating?
Its probably something simple that I'm not doing.

Re: Saints row IV ps3_vpp.

Posted: Fri Aug 30, 2013 3:02 am
by howfie
anyone got an xbox sample?

Re: Saints row IV ps3_vpp.

Posted: Fri Aug 30, 2013 3:04 am
by EcheloCross
howfie wrote:anyone got an xbox sample?
You can grab one from xbuc.net. Search for 130ABF66 in the search bar and unpack the downloaded file with wxpirs or another container tool.
Once the container is extracted, you will have 3 files. The one I'm testing on is patch_compressed.vpp_xbox2.

patch_compressed.vpp_xbox2's contents are as follows..

Code: Select all

ammo.xtbl
cmp_common.lua
credits_xbox2.xtbl
customization_items.xtbl
jump_sm.xtbl
m17.lua
m22_1.lua
menu_DE.be_strings
menu_ES.be_strings
menu_FR.be_strings
menu_IT.be_strings
menu_US.be_strings
pause_menu_common.lua
pause_save_game.lua
ui_bms_dlc_al.cpeg_xbox2
ui_bms_dlc_al.gpeg_xbox2
ui_bms_dlc_al.xtbl
ui_bms_store_weapon_costumes.xtbl
vdo_hint_bar.lua
weapon_costumes.xtbl
I've been trying to decompress jump_sm.xtbl in some tests, because its the first in the loop in the string table.

Re: Saints row IV ps3_vpp.

Posted: Fri Aug 30, 2013 5:54 am
by michalss
XBLToothPik wrote:@Michalss

The editor isn't complete & not everything in the source is right as of now. Been waiting on more info before I finish it.
:) Thats why i posted it in here on the first place.

Re: Saints row IV ps3_vpp.

Posted: Fri Aug 30, 2013 5:56 am
by michalss
howfie wrote:I thought on Rick's site Volition said they were going to (and have released some minor) extracting tools. The fact that they said they were going to release file format information, extracting tools, and an importer/exporter, I think we should all just wait to save us from wasting a lot of time. Then people can figure out the PS3 and XBox360 formats after the PC tools are released.
sent you samples i hope you gonna figure it out :D