Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 2.66 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using Ionic.Zlib;
  3. using System.Collections;
  4. using System.IO;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12.  
  13. namespace gsc_extractor
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             var oFile = new OpenFileDialog();
  25.             oFile.FileName = "";
  26.             oFile.Filter = "FF Files (*.ff)|*.ff";
  27.             oFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
  28.             oFile.Title = "Open an FF";
  29.             DialogResult res = oFile.ShowDialog();
  30.             if (res == DialogResult.OK)
  31.             {
  32.                 var ffName = oFile.FileName;
  33.                 var zoneWriter = new BinaryWriter(File.Create(Application.StartupPath + "\\" + Path.GetFileNameWithoutExtension(ffName) + ".zone"));
  34.                 var ffReader = new BinaryReader(File.OpenRead(ffName));
  35.                 var zlibHeader = new byte[] { 0x78, 0xDA };
  36.                 var blockStart = 37;
  37.                 ffReader.BaseStream.Position = blockStart;
  38.                 var blockSize = ffReader.ReadInt16();
  39.                 ffReader.BaseStream.Position = blockStart;
  40.                 var compData = ffReader.ReadBytes(blockSize);
  41.                 Buffer.SetByte(compData, 0, 0x78);
  42.                 Buffer.SetByte(compData, 1, 0xDA);
  43.                 var decompData = ZlibStream.UncompressBuffer(compData);
  44.                 zoneWriter.BaseStream.Write(decompData, 0, decompData.Length);
  45.                 Array.Clear(compData, 0, compData.Length);
  46.                 Array.Clear(decompData, 0, decompData.Length);
  47.                 long lastPos;
  48.                 for (var i = 0; i < 22; i++)
  49.                 {
  50.                     lastPos = ffReader.BaseStream.Position;
  51.                     blockSize = ffReader.ReadInt16();
  52.                     ffReader.BaseStream.Position = lastPos;
  53.                     compData = ffReader.ReadBytes(blockSize);
  54.                     Buffer.SetByte(compData, 0, 0x78);
  55.                     Buffer.SetByte(compData, 1, 0xDA);
  56.                     decompData = ZlibStream.UncompressBuffer(compData);
  57.                     zoneWriter.BaseStream.Write(decompData, 0, decompData.Length);
  58.                     Array.Clear(compData, 0, compData.Length);
  59.                     Array.Clear(decompData, 0, decompData.Length);
  60.                 }
  61.                 zoneWriter.Close();
  62.                 ffReader.Close();
  63.             }
  64.         }
  65.     }
  66. }