PrintLn() public static method

public static PrintLn ( string s, bool update = false ) : void
s string
update bool
return void
Exemplo n.º 1
0
 private void ReadExportTable()
 {
     try
     {
         DebugLog.PrintLn("Reading Export Table...");
         Exports = new List <ExportEntry>();
         if (GeneralInfo.compressed)
         {
             UncompressRange(Header._offsetCompFlagEnd + 0xC, Header.HeaderLength - (Header._offsetCompFlagEnd + 0xC));
             Header.DeCompBuffer.Seek(Header.ExportOffset, 0);
             for (int i = 0; i < Header.ExportCount; i++)
             {
                 ExportEntry e = new ExportEntry();
                 e.idxClass     = ReadInt(Header.DeCompBuffer);
                 e.idxParent    = ReadInt(Header.DeCompBuffer);
                 e.idxLink      = ReadInt(Header.DeCompBuffer);
                 e.idxName      = ReadInt(Header.DeCompBuffer);
                 e.Index        = ReadInt(Header.DeCompBuffer);
                 e.idxArchetype = ReadInt(Header.DeCompBuffer);
                 e.Unk1         = ReadInt(Header.DeCompBuffer);
                 e.ObjectFlags  = ReadInt(Header.DeCompBuffer);
                 e.Datasize     = ReadInt(Header.DeCompBuffer);
                 e.Dataoffset   = ReadInt(Header.DeCompBuffer);
                 long pos = Header.DeCompBuffer.Position;
                 if (!GeneralInfo.loadfull)
                 {
                     e.DataLoaded = false;
                 }
                 else
                 {
                     e.Data       = GetObjectData(e.Dataoffset, e.Datasize);
                     e.DataLoaded = true;
                 }
                 Header.DeCompBuffer.Seek(pos, 0);
                 e.Unk2 = ReadInt(Header.DeCompBuffer);
                 int count = ReadInt(Header.DeCompBuffer);
                 e.Unk3 = new int[count];
                 for (int j = 0; j < count; j++)
                 {
                     e.Unk3[j] = ReadInt(Header.DeCompBuffer);
                 }
                 e.Unk4 = ReadInt(Header.DeCompBuffer);
                 e.Unk5 = ReadInt(Header.DeCompBuffer);
                 e.Unk6 = ReadInt(Header.DeCompBuffer);
                 e.Unk7 = ReadInt(Header.DeCompBuffer);
                 e.Unk8 = ReadInt(Header.DeCompBuffer);
                 Exports.Add(e);
             }
         }
         else
         {
             Source.Seek(Header.ExportOffset, 0);
             for (int i = 0; i < Header.ExportCount; i++)
             {
                 ExportEntry e = new ExportEntry();
                 e.idxClass     = ReadInt(Source);
                 e.idxParent    = ReadInt(Source);
                 e.idxLink      = ReadInt(Source);
                 e.idxName      = ReadInt(Source);
                 e.Index        = ReadInt(Source);
                 e.idxArchetype = ReadInt(Source);
                 e.Unk1         = ReadInt(Source);
                 e.ObjectFlags  = ReadInt(Source);
                 e.Datasize     = ReadInt(Source);
                 e.Dataoffset   = ReadInt(Source);
                 long pos = Source.Position;
                 if (!GeneralInfo.loadfull)
                 {
                     e.DataLoaded = false;
                 }
                 else
                 {
                     e.Data       = GetObjectData(e.Dataoffset, e.Datasize);
                     e.DataLoaded = true;
                 }
                 Source.Seek(pos, 0);
                 e.Unk2 = ReadInt(Source);
                 int count = ReadInt(Source);
                 e.Unk3 = new int[count];
                 for (int j = 0; j < count; j++)
                 {
                     e.Unk3[j] = ReadInt(Source);
                 }
                 e.Unk4 = ReadInt(Source);
                 e.Unk5 = ReadInt(Source);
                 e.Unk6 = ReadInt(Source);
                 e.Unk7 = ReadInt(Source);
                 e.Unk8 = ReadInt(Source);
                 Exports.Add(e);
             }
         }
         DebugLog.PrintLn("Done.");
     }
     catch (Exception ex)
     {
         DebugLog.PrintLn("PCCPACKAGE::READEXPORTTABLE ERROR:\n" + ex.Message);
     }
 }
Exemplo n.º 2
0
 public void Save()
 {
     try
     {
         DebugLog.PrintLn("Writing Header...", true);
         MemoryStream m = new MemoryStream();
         m.Write(BitConverter.GetBytes(Header.magic), 0, 4);
         m.Write(BitConverter.GetBytes(Header.ver1), 0, 2);
         m.Write(BitConverter.GetBytes(Header.ver2), 0, 2);
         m.Write(BitConverter.GetBytes(Header.HeaderLength), 0, 4);
         WriteUString(Header.Group, m);
         if (GeneralInfo.compressed)
         {
             m.Write(BitConverter.GetBytes(Header.Flags ^ 0x02000000), 0, 4);
         }
         else
         {
             m.Write(BitConverter.GetBytes(Header.Flags), 0, 4);
         }
         m.Write(BitConverter.GetBytes(Header.unk1), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk2), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk3), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk4), 0, 4);
         m.Write(Header.GUID, 0, 16);
         m.Write(BitConverter.GetBytes(Header.Generations.Count), 0, 4);
         foreach (Generation g in Header.Generations)
         {
             m.Write(BitConverter.GetBytes(g.ExportCount), 0, 4);
             m.Write(BitConverter.GetBytes(g.ImportCount), 0, 4);
             m.Write(BitConverter.GetBytes(g.NetObjCount), 0, 4);
         }
         m.Write(BitConverter.GetBytes(Header.EngineVersion), 0, 4);
         m.Write(BitConverter.GetBytes(Header.CookerVersion), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk5), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk6), 0, 4);
         m.Write(BitConverter.GetBytes(Header.CompressionFlag), 0, 4);
         m.Write(BitConverter.GetBytes(0), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk7), 0, 4);
         m.Write(BitConverter.GetBytes(Header.unk8), 0, 4);
         DebugLog.PrintLn("Writing Name Table...", true);
         Header.NameOffset = (uint)m.Position;
         Header.NameCount  = (uint)Names.Count;
         foreach (string s in Names)
         {
             WriteUString(s, m);
         }
         DebugLog.PrintLn("Writing Import Table...", true);
         Header.ImportOffset = (uint)m.Position;
         Header.ImportCount  = (uint)Imports.Count;
         foreach (ImportEntry e in Imports)
         {
             m.Write(BitConverter.GetBytes(e.idxPackage), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk1), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxClass), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk2), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxLink), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxName), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk3), 0, 4);
         }
         DebugLog.PrintLn("Writing Export Table...", true);
         Header.ExportOffset = (uint)m.Position;
         Header.ExportCount  = (uint)Exports.Count;
         for (int i = 0; i < Exports.Count; i++)
         {
             ExportEntry e = Exports[i];
             e._infooffset = (uint)m.Position;
             Exports[i]    = e;
             m.Write(BitConverter.GetBytes(e.idxClass), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxParent), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxLink), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxName), 0, 4);
             m.Write(BitConverter.GetBytes(e.Index), 0, 4);
             m.Write(BitConverter.GetBytes(e.idxArchetype), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk1), 0, 4);
             m.Write(BitConverter.GetBytes(e.ObjectFlags), 0, 4);
             m.Write(BitConverter.GetBytes(0), 0, 4);
             m.Write(BitConverter.GetBytes(0), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk2), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk3.Length), 0, 4);
             foreach (int j in e.Unk3)
             {
                 m.Write(BitConverter.GetBytes(j), 0, 4);
             }
             m.Write(BitConverter.GetBytes(e.Unk4), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk5), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk6), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk7), 0, 4);
             m.Write(BitConverter.GetBytes(e.Unk8), 0, 4);
         }
         DebugLog.PrintLn("Writing Free Zone...", true);
         int FreeZoneSize = (int)Header.FreeZoneEnd - (int)Header.FreeZoneStart;
         Header.FreeZoneStart = (uint)m.Position;
         m.Write(new byte[FreeZoneSize], 0, FreeZoneSize);
         Header.FreeZoneEnd = Header.HeaderLength = (uint)m.Position;
         DebugLog.PrintLn("Writing Export Data...", true);
         for (int i = 0; i < Exports.Count; i++)
         {
             ExportEntry e    = Exports[i];
             byte[]      buff = GetObjectData(i);
             e.Dataoffset = (int)m.Position;
             e.Datasize   = buff.Length;
             m.Write(buff, 0, buff.Length);
             long pos = m.Position;
             m.Seek(e._infooffset + 32, 0);
             m.Write(BitConverter.GetBytes(e.Datasize), 0, 4);
             m.Write(BitConverter.GetBytes(e.Dataoffset), 0, 4);
             m.Seek(pos, 0);
         }
         DebugLog.PrintLn("Updating Header...", true);
         m.Seek(8, 0);
         m.Write(BitConverter.GetBytes(Header.HeaderLength), 0, 4);
         m.Seek(24 + (Header.Group.Length + 1) * 2, 0);
         m.Write(BitConverter.GetBytes(Header.NameCount), 0, 4);
         m.Write(BitConverter.GetBytes(Header.NameOffset), 0, 4);
         m.Write(BitConverter.GetBytes(Header.ExportCount), 0, 4);
         m.Write(BitConverter.GetBytes(Header.ExportOffset), 0, 4);
         m.Write(BitConverter.GetBytes(Header.ImportCount), 0, 4);
         m.Write(BitConverter.GetBytes(Header.ImportOffset), 0, 4);
         m.Write(BitConverter.GetBytes(Header.FreeZoneStart), 0, 4);
         m.Write(BitConverter.GetBytes(Header.FreeZoneEnd), 0, 4);
         DebugLog.PrintLn("Done generating.", true);
         if (GeneralInfo.inDLC)
         {
         }
         else
         {
             if (Source != null)
             {
                 Source.Close();
             }
             File.WriteAllBytes(GeneralInfo.filepath, m.ToArray());
         }
         DebugLog.PrintLn("Done.", true);
     }
     catch (Exception ex)
     {
         DebugLog.PrintLn("PCCPACKAGE::SAVE ERROR:\n" + ex.Message);
     }
 }
Exemplo n.º 3
0
 private void ReadHeader(Stream s)
 {
     try
     {
         s.Seek(0, 0);
         DebugLog.PrintLn("Reading Package Summary...");
         HeaderInfo h = new HeaderInfo();
         h.magic = ReadUInt(s);
         if (h.magic != 0x9E2A83C1)
         {
             throw new Exception("Not a valid PCC Package, wrong magic!");
         }
         h.ver1                 = ReadUInt16(s);
         h.ver2                 = ReadUInt16(s);
         h.HeaderLength         = ReadUInt(s);
         h.Group                = ReadUString(s);
         h._offsetFlag          = (uint)s.Position;
         h.Flags                = ReadUInt(s);
         GeneralInfo.compressed = (h.Flags & 0x02000000) != 0;
         DebugLog.PrintLn("Is Compressed : " + GeneralInfo.compressed);
         h.unk1 = ReadUInt(s);
         if (h.unk1 != 0)
         {
             throw new Exception("Not a valid PCC Package, Unk1 != 0");
         }
         h.NameCount     = ReadUInt(s);
         h.NameOffset    = ReadUInt(s);
         h.ExportCount   = ReadUInt(s);
         h.ExportOffset  = ReadUInt(s);
         h.ImportCount   = ReadUInt(s);
         h.ImportOffset  = ReadUInt(s);
         h.FreeZoneStart = ReadUInt(s);
         h.FreeZoneEnd   = ReadUInt(s);
         h.unk2          = ReadUInt(s);
         h.unk3          = ReadUInt(s);
         h.unk4          = ReadUInt(s);
         h.GUID          = new byte[16];
         s.Read(h.GUID, 0, 16);
         int count = ReadInt(s);
         DebugLog.PrintLn("Reading Generations...");
         h.Generations = new List <Generation>();
         for (int i = 0; i < count; i++)
         {
             Generation g = new Generation();
             g.ExportCount = ReadUInt(s);
             g.ImportCount = ReadUInt(s);
             g.NetObjCount = ReadUInt(s);
             h.Generations.Add(g);
         }
         DebugLog.PrintLn("Done.");
         h.EngineVersion      = ReadUInt(s);
         h.CookerVersion      = ReadUInt(s);
         h.unk5               = ReadUInt(s);
         h.unk6               = ReadUInt(s);
         h.CompressionFlag    = ReadUInt(s);
         h._offsetCompFlagEnd = (uint)s.Position;
         count    = ReadInt(s);
         h.Chunks = new List <CompressedChunk>();
         if (GeneralInfo.compressed)
         {
             DebugLog.PrintLn("Reading Chunktable...");
             for (int i = 0; i < count; i++)
             {
                 CompressedChunk c = new CompressedChunk();
                 c.UnCompOffset = ReadUInt(s);
                 c.UnCompSize   = ReadUInt(s);
                 c.CompOffset   = ReadUInt(s);
                 c.CompSize     = ReadUInt(s);
                 h.Chunks.Add(c);
             }
             h.DeCompBuffer = new MemoryStream();
             DebugLog.PrintLn("Done.");
         }
         h.unk7 = ReadUInt(s);
         h.unk8 = ReadUInt(s);
         Header = h;
         if (GeneralInfo.compressed)
         {
             ReadChunks(s);
         }
         DebugLog.PrintLn("Done.");
     }
     catch (Exception ex)
     {
         DebugLog.PrintLn("PCCPACKAGE::READHEADER ERROR:\n" + ex.Message);
     }
 }