Пример #1
0
 public JMPFile(string Location, string Output)
 {
     this.Location = Location;
     this.Output   = Output;
     using (BinaryReader br = new BinaryReader(File.OpenRead(Location)))
     {
         string Magic = Encoding.ASCII.GetString(br.ReadBytes(4));
         if (Magic != "DATA")
         {
             // Should check for HEX but nah ツ
             Console.WriteLine("No valid DATA.JMP file");
         }
         Version = Encoding.UTF8.GetString(br.ReadBytes(4), 0, 4);
         br.BaseStream.Seek(0x32, SeekOrigin.Begin);
         FileCount = br.ReadInt32();
         br.BaseStream.Seek(0x36, SeekOrigin.Begin);
         for (int i = 0; i < FileCount; i++)
         {
             var entry = new JMPEntry()
             {
                 Name   = Encoding.UTF8.GetString(br.ReadBytes(0x104), 0, 0x104).Replace("\0", string.Empty),
                 Offset = br.ReadInt32(),
                 Zsize  = br.ReadInt32(),
                 Size   = br.ReadInt32(),
                 Null   = Encoding.UTF8.GetString(br.ReadBytes(0x20), 0, 0x20)
             };
             Files.Add(entry);
         }
         Extract(br);
     }
 }
Пример #2
0
 public JMPFile(string BuildDirectory)
 {
     // We are building a complete new Data.jmp from scratch
     foreach (string file in Helper.GetFiles(BuildDirectory))
     {
         var      path       = file.Replace(BuildDirectory, "..");
         var      fileAsByte = File.ReadAllBytes(file);
         JMPEntry newEntry   = new JMPEntry()
         {
             Name           = path,
             Path           = file,
             Offset         = 0,
             Size           = fileAsByte.Count(),
             compressedFile = Ionic.Zlib.ZlibStream.CompressBuffer(fileAsByte)
         };
         fileAsByte = null;
         Files.Add(newEntry);
         Console.WriteLine("Registered File: " + path);
     }
     using (BinaryWriter bw = new BinaryWriter(File.Create(BuildDirectory + "\\Data_compiled.jmp")))
     {
         bw.Write(0x41544144);
         bw.Write(Encoding.ASCII.GetBytes("1.0")); // never was anything other than 1.0
         bw.BaseStream.Seek(0x32, SeekOrigin.Begin);
         bw.Write(Files.Count);
         bw.BaseStream.Seek(0x36, SeekOrigin.Begin);
         foreach (JMPEntry f in Files)
         {
             Console.WriteLine("Writing Meta Info of : " + f.Name);
             f.Write(bw);
         }
         foreach (JMPEntry f in Files)
         {
             Console.WriteLine("Writing Binary Info of : " + f.Name);
             Int32 currentPosition = Convert.ToInt32(bw.BaseStream.Position);
             // Go back and write Offset
             bw.BaseStream.Seek(f.BuildOffset, SeekOrigin.Begin);
             bw.Write(currentPosition);
             // Go now write compressed bytes
             bw.BaseStream.Seek(currentPosition, SeekOrigin.Begin);
             bw.Write(f.compressedFile);
             // Empty that shit
             f.compressedFile = null;
         }
         Console.WriteLine("Finished repacking...");
     }
 }