C# Stream Positions

Programming related discussions related to game research
Aidan729
Posts: 13
Joined: Tue Jun 30, 2015 3:28 am

C# Stream Positions

Post by Aidan729 »

Hey guys,

So I am currently working on a Call Of Duty: Fast File Compiler, and im at the stage where I am opening and decompressing the rawfiles (http://codresearch.com/index.php/Rawfile_Asset) then getting the strings from the decompressed data to then load in a text box.

current code

Code: Select all

                rawfile rf = new rawfile();
                Stream stream = new MemoryStream(ff._zone);
                int pname = stream.ReadInt32();
                rf.compSize = stream.ReadInt32();
                rf.deflateSize = stream.ReadInt32();
                int pdata = stream.ReadInt32();
                if (pname == -1)
                    rf.name = stream.ReadCString();
                if (pdata == -1)
                {
                    if (rf.compSize > 0)
                        rf.data = ZlibStream.UncompressBuffer(stream.ReadBytes(rf.compSize));
                    else
                        rf.data = stream.ReadBytes(rf.deflateSize);
                }
                CodeBox1.Text = Encoding.UTF8.GetString(rf.data);



Now the problem doesn't lie within how anything is being done like the decompressing or anything like that.

where the problem lies is my position in the Fast Files Zone.

The zone is just a header you get when decompressing the Fast File

the zone stores a bunch of asset files including rawfiles

so my question is. What would be the easiest way to get to the correct position in memory without lets say pattern searching. (currently by reading the zone in a memory stream it thinks im at the beginning of the header)

thanks
atom0s
Posts: 250
Joined: Sat Dec 27, 2014 8:49 pm

Re: C# Stream Positions

Post by atom0s »

If you are referring to the base streams position, you can do:
stream.Position