- using System;
- using Ionic.Zlib;
- using System.Collections;
- using System.IO;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace gsc_extractor
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- var oFile = new OpenFileDialog();
- oFile.FileName = "";
- oFile.Filter = "FF Files (*.ff)|*.ff";
- oFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- oFile.Title = "Open an FF";
- DialogResult res = oFile.ShowDialog();
- if (res == DialogResult.OK)
- {
- var ffName = oFile.FileName;
- var zoneWriter = new BinaryWriter(File.Create(Application.StartupPath + "\\" + Path.GetFileNameWithoutExtension(ffName) + ".zone"));
- var ffReader = new BinaryReader(File.OpenRead(ffName));
- var zlibHeader = new byte[] { 0x78, 0xDA };
- var blockStart = 37;
- ffReader.BaseStream.Position = blockStart;
- var blockSize = ffReader.ReadInt16();
- ffReader.BaseStream.Position = blockStart;
- var compData = ffReader.ReadBytes(blockSize);
- Buffer.SetByte(compData, 0, 0x78);
- Buffer.SetByte(compData, 1, 0xDA);
- var decompData = ZlibStream.UncompressBuffer(compData);
- zoneWriter.BaseStream.Write(decompData, 0, decompData.Length);
- Array.Clear(compData, 0, compData.Length);
- Array.Clear(decompData, 0, decompData.Length);
- long lastPos;
- for (var i = 0; i < 22; i++)
- {
- lastPos = ffReader.BaseStream.Position;
- blockSize = ffReader.ReadInt16();
- ffReader.BaseStream.Position = lastPos;
- compData = ffReader.ReadBytes(blockSize);
- Buffer.SetByte(compData, 0, 0x78);
- Buffer.SetByte(compData, 1, 0xDA);
- decompData = ZlibStream.UncompressBuffer(compData);
- zoneWriter.BaseStream.Write(decompData, 0, decompData.Length);
- Array.Clear(compData, 0, compData.Length);
- Array.Clear(decompData, 0, decompData.Length);
- }
- zoneWriter.Close();
- ffReader.Close();
- }
- }
- }
- }