Eliot's Forum
Some stuff to add/remove... - Printable Version

+- Eliot's Forum (https://eliotvu.com/forum)
+-- Forum: UE Explorer (https://eliotvu.com/forum/forumdisplay.php?fid=1)
+--- Forum: General (https://eliotvu.com/forum/forumdisplay.php?fid=3)
+--- Thread: Some stuff to add/remove... (/showthread.php?tid=79)



Some stuff to add/remove... - VendorX - 07-01-2013

1. Can you remove this:
Quote:Table Index:19262
Table Offset:0x001831A0
Table Size:0x00000044
...or make it optional?
Reason: with +2000 files it's a little annoying when you must remove this by hand...

2. BatchExport will be nice...
Reason: with +2000 files it's a little annoying when you must export all classes by hand...

3. There is a little problem with iterators...
Decompiled:
Code:
I = 0;
J0x5A:
if(I < CapturePoints.Length)
{
    //...
    ++ I;
    goto J0x5A;
}

Original:
Code:
for(i = 0; i < CapturePoints.length; i++)
{
    //...
}

4. Support for decompression...


RE: Some stuff to add/remove... - eliot - 07-01-2013

(07-01-2013, 03:26 AM)VendorX Wrote: 1. Can you remove this:
Quote:Table Index:19262
Table Offset:0x001831A0
Table Size:0x00000044
...or make it optional?
Reason: with +2000 files it's a little annoying when you must remove this by hand...

2. BatchExport will be nice...
Reason: with +2000 files it's a little annoying when you must export all classes by hand...

3. There is a little problem with iterators...
Decompiled:
Code:
I = 0;
J0x5A:
if(I < CapturePoints.Length)
{
    //...
    ++ I;
    goto J0x5A;
}

Original:
Code:
for(i = 0; i < CapturePoints.length; i++)
{
    //...
}

4. Support for decompression...

1. This is only shown for objects decompiled through the Exports tab.

2. Tools -> Export classes? That's a feature that's always been there, there's also a commandline argument for this, it's explained here somewhere on the forums.

3. That's because "for" loops are compiled to "goto" statements by the Unreal Engine.

4. I've tried but failed to get it working. I might see if I can add auto decompression linked to Gildor's tool.


RE: Some stuff to add/remove... - VendorX - 07-01-2013

4. It's easy to do... Which language you using? Anyways, UnHood is a good example of how to decompress UE package - source can be found in net.


RE: Some stuff to add/remove... - eliot - 07-01-2013

C#, I got this implemented but the third party library just throws an arithmetic exception upon execution, not sure if I made a mistake or if the library is broken.


RE: Some stuff to add/remove... - VendorX - 07-01-2013

Easy way:
Decompressed data will start directly with the NameTable... Use the same PackageHeader except PackageFlags (set it to 1) and everything below CookerVersion (UE3...). Next step is to line up decompressed data to NameTableOffset - calculate the empty space between end of header and name table (NameTableOffset - SizeOfHeader). Into TempFile write modified header, empty space and decompressed data. Use TempFile to process...


RE: Some stuff to add/remove... - eliot - 07-01-2013

Well, https://gist.github.com/EliotVU/aaa50d9f285dbdc810b5 is my compression code, it just reads the chunks and attempts to decompress those chunks. But because this didn't work I threw out any code that tries to make a temporary decompressed file.


RE: Some stuff to add/remove... - VendorX - 07-01-2013

Tomorrow I can take a look at your decompression code.


RE: Some stuff to add/remove... - eliot - 07-06-2013

Have you looked yet? Smile


RE: Some stuff to add/remove... - VendorX - 07-07-2013

Problem is in CompressedChunkBlock.Deserialize - you can't read BlockCompressedData directly after reading BlockHeader, because first is BlockCount * BlockHeader then BlockCount * BlockCompressedData.

Compressed UE package:

// LZOChunk:
UncompressedOffset
UncompressedSize
CompressedOffset
CompressedSize

// CompressedChunk:
Signature
BlockSize
CompressedChunkSize
UncompressedChunkSize

// CompressedBlock:
// BlockCount * CompressedBlockHeader
CompressedBlockSize;
UncompressedBlockSize;

// BlockCount * CompressedBlockData
CompressedBlockData;

Try this:
Code:
public struct CompressedChunkHeader : IUnrealDeserializableClass
            {
                private uint _Signature;
                private int _BlockSize;
                private int _CompressedSize;
                private int _UncompressedSize;

                public CompressedChunkBlock[] Blocks;//UArray<CompressedChunkBlock> Blocks;

                public void Deserialize(BinaryReader stream)//IUnrealStream stream)
                {
                    _Signature = stream.ReadUInt32();
                    if (_Signature != 2653586369)//UnrealPackage.Signature)
                        throw new System.IO.FileLoadException("Unrecognized signature!");

                    _BlockSize = stream.ReadInt32();
                    _CompressedSize = stream.ReadInt32();
                    _UncompressedSize = stream.ReadInt32();

                    int BlockCount = (int)Math.Ceiling(_UncompressedSize / (float)_BlockSize);
                    Blocks = new CompressedChunkBlock[BlockCount];//UArray<CompressedChunkBlock>(stream, blockCount);

                    int BlockHeaderOffset = (int)stream.BaseStream.Position;
                    int CompressedBlockOffset = BlockHeaderOffset + BlockCount * 8;

                    // Bypass of your UArray...
                    for (int i = 0; i < Blocks.Length; i++)
                    {
                        CompressedChunkBlock inBlock = new CompressedChunkBlock();

                        stream.BaseStream.Position = BlockHeaderOffset;
                        inBlock.Deserialize(stream);
                        BlockHeaderOffset += 8;

                        stream.BaseStream.Position = CompressedBlockOffset;
                        inBlock._CompressedData = stream.ReadBytes(inBlock._CompressedSize);
                        CompressedBlockOffset += inBlock._CompressedSize;

                        Blocks[i] = inBlock;
                    }
                }

                public struct CompressedChunkBlock : IUnrealDeserializableClass
                {
                    public int _CompressedSize;
                    public int _UncompressedSize;
                    public byte[] _CompressedData;

                    public void Deserialize(BinaryReader stream)//IUnrealStream stream)
                    {
                        _CompressedSize = stream.ReadInt32();
                        _UncompressedSize = stream.ReadInt32();
                    }

                    public byte[] Decompress()
                    {
                        var _DecompressedData = new byte[_UncompressedSize];
                        ManagedLZO.MiniLZO.Decompress( _CompressedData, _DecompressedData );
                        return _DecompressedData;
                    }
                }
            }