New GUI, MFA reader refactor,bugfixes

master
1987kostya 5 years ago
parent 0609171eaf
commit ea313aea55

Binary file not shown.

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<ApplicationIcon>E:\DotNetCTF\icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -64,7 +67,7 @@
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<DebugType>none</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
@ -72,14 +75,19 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Be.Windows.Forms.HexBox, Version=1.6.0.18788, Culture=neutral, PublicKeyToken=e0e5adf0ebc99863">
<HintPath>C:\Users\ivani\Desktop\Be.HexEditor-1.6.0\sources\Be.Windows.Forms.HexBox\bin\Debug\Be.Windows.Forms.HexBox.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zlib, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c">
<HintPath>..\packages\Ionic.Zlib.1.9.1.5\lib\Ionic.Zlib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -89,12 +97,31 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GUI\ChunkNode.cs" />
<Compile Include="GUI\CryptoKeyForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\CryptoKeyForm.Designer.cs">
<DependentUpon>CryptoKeyForm.cs</DependentUpon>
</Compile>
<Compile Include="GUI\HexViewForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\HexViewForm.Designer.cs">
<DependentUpon>HexViewForm.cs</DependentUpon>
</Compile>
<Compile Include="GUI\MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="GUI\PackDataForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\PackDataForm.Designer.cs">
<DependentUpon>PackDataForm.cs</DependentUpon>
</Compile>
<Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Events.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\EventsParts.cs" />
@ -118,8 +145,13 @@
<Compile Include="MMFParser\ChunkLoaders\ObjectInfo.cs" />
<Compile Include="MMFParser\ChunkLoaders\FrameItems.cs" />
<Compile Include="MMFParser\ChunkLoaders\ObjectNames.cs" />
<Compile Include="MMFParser\ChunkLoaders\Objects\Animations.cs" />
<Compile Include="MMFParser\ChunkLoaders\Objects\ObjectCommon.cs" />
<Compile Include="MMFParser\ChunkLoaders\Objects\Value.cs" />
<Compile Include="MMFParser\Data\DataLoader.cs" />
<Compile Include="MMFParser\Data\EXE.cs" />
<Compile Include="MMFParser\Decompiling\MFAGenerator.cs" />
<Compile Include="MMFParser\Decompiling\PAME2MFA.cs" />
<Compile Include="MMFParser\MFALoaders\ChunkList.cs" />
<Compile Include="MMFParser\MFALoaders\Frame.cs" />
<Compile Include="MMFParser\MFALoaders\FrameItem.cs" />
@ -135,28 +167,30 @@
<Compile Include="MMFParser\Data\MFA.cs" />
<Compile Include="MMFParser\ChunkLoaders\AppHeader.cs" />
<Compile Include="MMFParser\ChunkLoaders\ChunkLoader.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\FontBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Banks\FontBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Frame.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\ImageBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\MusicBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\SoundBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Banks\ImageBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Banks\MusicBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Banks\SoundBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\StringChunk.cs" />
<Compile Include="MMFParser\ChunkLoaders\yves.cs" />
<Compile Include="MMFParser\Constants.cs" />
<Compile Include="utils\BitDict.cs" />
<Compile Include="utils\ByteFlag.cs" />
<Compile Include="utils\ByteWriter.cs" />
<Compile Include="utils\Helper.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Utils\BitDict.cs" />
<Compile Include="Utils\ByteFlag.cs" />
<Compile Include="Utils\ByteWriter.cs" />
<Compile Include="Utils\Helper.cs" />
<Compile Include="MMFParser\Data\ChunkList.cs" />
<Compile Include="MMFParser\Data\GameData.cs" />
<Compile Include="MMFParser\Data\PackData.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils\ByteIO.cs" />
<Compile Include="utils\Decompressor.cs" />
<Compile Include="utils\Decryption.cs" />
<Compile Include="utils\ImageHelper.cs" />
<Compile Include="utils\Logger.cs" />
<Compile Include="Utils\ByteIO.cs" />
<Compile Include="Utils\Decompressor.cs" />
<Compile Include="Utils\Decryption.cs" />
<Compile Include="Utils\ImageDumper.cs" />
<Compile Include="Utils\ImageHelper.cs" />
<Compile Include="Utils\Logger.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
@ -175,9 +209,19 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GUI\CryptoKeyForm.resx">
<DependentUpon>CryptoKeyForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\HexViewForm.resx">
<DependentUpon>HexViewForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\PackDataForm.resx">
<DependentUpon>PackDataForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,28 @@
using System.Windows.Forms;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.Data;
namespace NetMFAPatcher.GUI
{
public class ChunkNode:TreeNode
{
public ChunkList.Chunk chunk;
public ChunkLoader loader;
public ChunkNode(string text, ChunkList.Chunk chunk) : base(text)
{
this.loader = chunk.Loader;
this.chunk = chunk;
}
public ChunkNode(string text, ChunkLoader loader) : base(text)
{
this.loader = loader;
this.chunk = loader.Chunk;
}
public ChunkNode(string text) : base(text)
{
}
}
}

@ -0,0 +1,130 @@
using System.ComponentModel;
namespace NetMFAPatcher.GUI
{
partial class CryptoKeyForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CryptoKeyForm));
this.charBox = new System.Windows.Forms.TextBox();
this.hexBox1 = new Be.Windows.Forms.HexBox();
this.plusButton = new System.Windows.Forms.Button();
this.minusButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// charBox
//
this.charBox.BackColor = System.Drawing.Color.Black;
this.charBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.charBox.Dock = System.Windows.Forms.DockStyle.Top;
this.charBox.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.charBox.Location = new System.Drawing.Point(0, 0);
this.charBox.Name = "charBox";
this.charBox.Size = new System.Drawing.Size(646, 20);
this.charBox.TabIndex = 0;
this.charBox.Text = "54";
this.charBox.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// hexBox1
//
this.hexBox1.BackColor = System.Drawing.Color.Black;
this.hexBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.hexBox1.ColumnInfoVisible = true;
this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.hexBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
this.hexBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.hexBox1.LineInfoVisible = true;
this.hexBox1.Location = new System.Drawing.Point(0, 20);
this.hexBox1.Name = "hexBox1";
this.hexBox1.SelectionBackColor = System.Drawing.Color.FromArgb(((int) (((byte) (128)))), ((int) (((byte) (64)))), ((int) (((byte) (0)))));
this.hexBox1.SelectionForeColor = System.Drawing.Color.Red;
this.hexBox1.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int) (((byte) (100)))), ((int) (((byte) (60)))), ((int) (((byte) (188)))), ((int) (((byte) (255)))));
this.hexBox1.Size = new System.Drawing.Size(646, 329);
this.hexBox1.StringViewVisible = true;
this.hexBox1.TabIndex = 5;
this.hexBox1.VScrollBarVisible = true;
//
// plusButton
//
this.plusButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.plusButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.plusButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.plusButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.plusButton.Location = new System.Drawing.Point(616, 0);
this.plusButton.Name = "plusButton";
this.plusButton.Size = new System.Drawing.Size(30, 20);
this.plusButton.TabIndex = 6;
this.plusButton.Text = "+";
this.plusButton.UseVisualStyleBackColor = false;
this.plusButton.Click += new System.EventHandler(this.plusButton_Click);
//
// minusButton
//
this.minusButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.minusButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.minusButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.minusButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.minusButton.Location = new System.Drawing.Point(589, 0);
this.minusButton.Name = "minusButton";
this.minusButton.Size = new System.Drawing.Size(30, 20);
this.minusButton.TabIndex = 7;
this.minusButton.Text = "-";
this.minusButton.UseVisualStyleBackColor = false;
this.minusButton.Click += new System.EventHandler(this.minusButton_Click);
//
// CryptoKeyForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(646, 349);
this.Controls.Add(this.minusButton);
this.Controls.Add(this.plusButton);
this.Controls.Add(this.hexBox1);
this.Controls.Add(this.charBox);
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.Name = "CryptoKeyForm";
this.Text = "Encryption Key";
this.Load += new System.EventHandler(this.CryptoKeyForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button minusButton;
private System.Windows.Forms.Button plusButton;
private Be.Windows.Forms.HexBox hexBox1;
private System.Windows.Forms.TextBox charBox;
#endregion
}
}

@ -0,0 +1,68 @@
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Be.Windows.Forms;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.GUI
{
public partial class CryptoKeyForm : Form
{
private string rawKey;
public CryptoKeyForm(string data,Color color)
{
InitializeComponent();
hexBox1.ForeColor = color;
hexBox1.InfoForeColor = Color.FromArgb(color.R/2, color.G/2, color.B/2);
hexBox1.SelectionForeColor=Color.FromArgb(color.R, color.G, color.B);
hexBox1.SelectionBackColor=Color.FromArgb(color.R/4, color.G/4, color.B/4);
hexBox1.ShadowSelectionColor=Color.FromArgb(150,color.R/4, color.G/4, color.B/4);
plusButton.ForeColor = color;
minusButton.ForeColor = color;
charBox.ForeColor = color;
rawKey = data;
}
private void CryptoKeyForm_Load(object sender, EventArgs e)
{
try
{
var previewKey = Decryption.MakeKeyFromBytes(rawKey, (byte) int.Parse((charBox.Text)));
hexBox1.ByteProvider=new DynamicByteProvider(previewKey);
}
catch
{
// ignored
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
var previewKey = Decryption.MakeKeyFromBytes(rawKey, (byte) int.Parse((charBox.Text)));
hexBox1.ByteProvider=new DynamicByteProvider(previewKey);
}
catch
{
}
}
private void plusButton_Click(object sender, EventArgs e)
{
charBox.Text = ((byte)int.Parse((charBox.Text))+1).ToString();
}
private void minusButton_Click(object sender, EventArgs e)
{
charBox.Text = ((byte)int.Parse((charBox.Text))-1).ToString();
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,107 @@
using System.ComponentModel;
namespace NetMFAPatcher.GUI
{
partial class HexViewForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexViewForm));
this.rawBox = new System.Windows.Forms.CheckBox();
this.hexBox1 = new Be.Windows.Forms.HexBox();
this.sizeLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// rawBox
//
this.rawBox.Dock = System.Windows.Forms.DockStyle.Top;
this.rawBox.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.rawBox.Location = new System.Drawing.Point(0, 0);
this.rawBox.Name = "rawBox";
this.rawBox.Size = new System.Drawing.Size(646, 28);
this.rawBox.TabIndex = 3;
this.rawBox.Text = "Raw";
this.rawBox.UseVisualStyleBackColor = true;
this.rawBox.CheckedChanged += new System.EventHandler(this.rawBox_CheckedChanged);
//
// hexBox1
//
this.hexBox1.BackColor = System.Drawing.Color.Black;
this.hexBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.hexBox1.ColumnInfoVisible = true;
this.hexBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.hexBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
this.hexBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.hexBox1.LineInfoVisible = true;
this.hexBox1.Location = new System.Drawing.Point(0, 28);
this.hexBox1.Name = "hexBox1";
this.hexBox1.SelectionBackColor = System.Drawing.Color.FromArgb(((int) (((byte) (128)))), ((int) (((byte) (64)))), ((int) (((byte) (0)))));
this.hexBox1.SelectionForeColor = System.Drawing.Color.Red;
this.hexBox1.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int) (((byte) (100)))), ((int) (((byte) (60)))), ((int) (((byte) (188)))), ((int) (((byte) (255)))));
this.hexBox1.Size = new System.Drawing.Size(646, 362);
this.hexBox1.StringViewVisible = true;
this.hexBox1.TabIndex = 4;
this.hexBox1.VScrollBarVisible = true;
this.hexBox1.CursorChanged += new System.EventHandler(this.hexBox1_Click);
//
// sizeLabel
//
this.sizeLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.sizeLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.sizeLabel.Location = new System.Drawing.Point(0, 369);
this.sizeLabel.Name = "sizeLabel";
this.sizeLabel.Size = new System.Drawing.Size(646, 21);
this.sizeLabel.TabIndex = 5;
this.sizeLabel.Text = "Size: 1000MB";
//
// HexViewForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(646, 390);
this.Controls.Add(this.sizeLabel);
this.Controls.Add(this.hexBox1);
this.Controls.Add(this.rawBox);
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.Name = "HexViewForm";
this.Text = "Hex View";
this.Load += new System.EventHandler(this.HexViewForm_Load);
this.ResumeLayout(false);
}
private System.Windows.Forms.Label sizeLabel;
private Be.Windows.Forms.HexBox hexBox1;
private System.Windows.Forms.CheckBox rawBox;
#endregion
}
}

@ -0,0 +1,82 @@
using System;
using System.ComponentModel.Design;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Be.Windows.Forms;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.GUI
{
public partial class HexViewForm : Form
{
public byte[] parsedData;
public byte[] rawData;
private ByteViewer _viewer;
public HexViewForm(byte[] parsedData, byte[] rawData,Color color)
{
InitializeComponent();
sizeLabel.ForeColor = color;
rawBox.ForeColor = color;
hexBox1.ForeColor = color;
hexBox1.InfoForeColor = Color.FromArgb(color.R/2, color.G/2, color.B/2);
hexBox1.SelectionForeColor=Color.FromArgb(color.R, color.G, color.B);
hexBox1.SelectionBackColor=Color.FromArgb(color.R/4, color.G/4, color.B/4);
hexBox1.ShadowSelectionColor=Color.FromArgb(150,color.R/4, color.G/4, color.B/4);
this.parsedData = parsedData;
this.rawData = rawData;
UpdateInfo(false);
}
public HexViewForm(byte[] parsedData, byte[] rawData, Color color, string name)
{
InitializeComponent();
sizeLabel.ForeColor = color;
rawBox.ForeColor = color;
hexBox1.ForeColor = color;
hexBox1.InfoForeColor = Color.FromArgb(color.R/2, color.G/2, color.B/2);
hexBox1.SelectionForeColor=Color.FromArgb(color.R, color.G, color.B);
hexBox1.SelectionBackColor=Color.FromArgb(color.R/4, color.G/4, color.B/4);
hexBox1.ShadowSelectionColor=Color.FromArgb(150,color.R/4, color.G/4, color.B/4);
this.parsedData = parsedData;
this.rawData = rawData;
this.Text = name;
UpdateInfo(false);
}
private void HexViewForm_Load(object sender, EventArgs e)
{
}
public void UpdateInfo(bool raw)
{
var bytes = raw ? rawData : parsedData;
hexBox1.ByteProvider = new DynamicByteProvider(bytes);
sizeLabel.Text = "Size: "+bytes.Length.ToPrettySize();
}
private void rawBox_CheckedChanged(object sender, EventArgs e)
{
UpdateInfo(rawBox.Checked);
}
private void hexBox1_Click(object sender, EventArgs e)
{
Console.WriteLine("Semen");
}
}
}

File diff suppressed because it is too large Load Diff

@ -1,4 +1,7 @@
namespace NetMFAPatcher.GUI
using System;
using System.Windows.Forms;
namespace NetMFAPatcher.GUI
{
partial class MainForm
{
@ -28,22 +31,45 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.button1 = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.treeView1 = new System.Windows.Forms.TreeView();
this.listBox1 = new System.Windows.Forms.ListBox();
this.GameInfo = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.ImageBox = new System.Windows.Forms.CheckBox();
this.SoundBox = new System.Windows.Forms.CheckBox();
this.ChunkBox = new System.Windows.Forms.CheckBox();
this.ImagesBar = new System.Windows.Forms.ProgressBar();
this.ImagesLabel = new System.Windows.Forms.Label();
this.SoundsLabel = new System.Windows.Forms.Label();
this.SoundBar = new System.Windows.Forms.ProgressBar();
this.FolderBTN = new System.Windows.Forms.Button();
this.MFABtn = new System.Windows.Forms.Button();
this.SoundsButton = new System.Windows.Forms.Button();
this.ImagesButton = new System.Windows.Forms.Button();
this.loadingLabel = new System.Windows.Forms.Label();
this.cryptKeyBtn = new System.Windows.Forms.Button();
this.showHexBtn = new System.Windows.Forms.Button();
this.dumpSortedBtn = new System.Windows.Forms.Button();
this.ChunkCombo = new System.Windows.Forms.ContextMenuStrip(this.components);
this.saveChunkBtn = new System.Windows.Forms.ToolStripMenuItem();
this.viewHexBtn = new System.Windows.Forms.ToolStripMenuItem();
this.packDataBtn = new System.Windows.Forms.Button();
this.ChunkCombo.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.Lime;
this.button1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.button1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(83, 23);
this.button1.Size = new System.Drawing.Size(101, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Select File";
this.button1.UseVisualStyleBackColor = false;
@ -51,53 +77,325 @@
//
// openFileDialog1
//
this.openFileDialog1.FileName = "SisterLocation.exe";
this.openFileDialog1.FileName = "fnaf3.exe";
this.openFileDialog1.Filter = "CTF Executable|*.exe";
this.openFileDialog1.InitialDirectory = "E:\\Games\\sl\\SisterLocation.exe";
this.openFileDialog1.InitialDirectory = "E:\\";
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.BackColor = System.Drawing.Color.Black;
this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.treeView1.ForeColor = System.Drawing.Color.Lime;
this.treeView1.Location = new System.Drawing.Point(645, 12);
this.treeView1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.treeView1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.treeView1.Location = new System.Drawing.Point(642, 9);
this.treeView1.Margin = new System.Windows.Forms.Padding(0);
this.treeView1.MaximumSize = new System.Drawing.Size(286, 900);
this.treeView1.MinimumSize = new System.Drawing.Size(286, 489);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(286, 426);
this.treeView1.Size = new System.Drawing.Size(286, 489);
this.treeView1.TabIndex = 1;
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
this.treeView1.DoubleClick += new System.EventHandler(this.treeView1_AfterDblClick);
this.treeView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_RightClick);
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.BackColor = System.Drawing.Color.Black;
this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listBox1.ForeColor = System.Drawing.Color.Lime;
this.listBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.listBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.listBox1.FormattingEnabled = true;
this.listBox1.IntegralHeight = false;
this.listBox1.ItemHeight = 14;
this.listBox1.Location = new System.Drawing.Point(459, 12);
this.listBox1.Margin = new System.Windows.Forms.Padding(0);
this.listBox1.MaximumSize = new System.Drawing.Size(180, 50000);
this.listBox1.MinimumSize = new System.Drawing.Size(180, 234);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(180, 299);
this.listBox1.TabIndex = 2;
this.listBox1.Size = new System.Drawing.Size(180, 281);
this.listBox1.TabIndex = 5;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// GameInfo
//
this.GameInfo.AutoSize = true;
this.GameInfo.ForeColor = System.Drawing.Color.Lime;
this.GameInfo.Location = new System.Drawing.Point(9, 49);
this.GameInfo.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.GameInfo.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.GameInfo.Location = new System.Drawing.Point(9, 55);
this.GameInfo.Margin = new System.Windows.Forms.Padding(5, 0, 3, 0);
this.GameInfo.Name = "GameInfo";
this.GameInfo.Size = new System.Drawing.Size(144, 13);
this.GameInfo.Size = new System.Drawing.Size(182, 45);
this.GameInfo.TabIndex = 3;
this.GameInfo.Text = "GameInfo would appear here";
this.GameInfo.Text = "GameInfo will appear here\r\nSemenLine\r\nLine3\r\n";
this.GameInfo.Visible = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.Lime;
this.label1.Location = new System.Drawing.Point(101, 17);
this.label1.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.label1.Location = new System.Drawing.Point(119, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(245, 13);
this.label1.Size = new System.Drawing.Size(176, 17);
this.label1.TabIndex = 4;
this.label1.Text = "CTF Dumper by Kostya and cool guys from discord";
this.label1.Text = "CTFDumper 0.1.1 Debug";
//
// ImageBox
//
this.ImageBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.ImageBox.ForeColor = System.Drawing.Color.Lime;
this.ImageBox.Location = new System.Drawing.Point(9, 239);
this.ImageBox.Name = "ImageBox";
this.ImageBox.Size = new System.Drawing.Size(104, 24);
this.ImageBox.TabIndex = 5;
this.ImageBox.Text = "Dump Images";
this.ImageBox.UseVisualStyleBackColor = true;
this.ImageBox.Visible = false;
this.ImageBox.CheckedChanged += new System.EventHandler(this.ImageBox_CheckedChanged);
//
// SoundBox
//
this.SoundBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.SoundBox.ForeColor = System.Drawing.Color.Lime;
this.SoundBox.Location = new System.Drawing.Point(9, 269);
this.SoundBox.Name = "SoundBox";
this.SoundBox.Size = new System.Drawing.Size(104, 24);
this.SoundBox.TabIndex = 6;
this.SoundBox.Text = "Dump Sounds";
this.SoundBox.UseVisualStyleBackColor = true;
this.SoundBox.Visible = false;
this.SoundBox.CheckedChanged += new System.EventHandler(this.SoundBox_CheckedChanged);
//
// ChunkBox
//
this.ChunkBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.ChunkBox.ForeColor = System.Drawing.Color.Lime;
this.ChunkBox.Location = new System.Drawing.Point(9, 299);
this.ChunkBox.Name = "ChunkBox";
this.ChunkBox.Size = new System.Drawing.Size(104, 24);
this.ChunkBox.TabIndex = 7;
this.ChunkBox.Text = "Export Chunks\r\n";
this.ChunkBox.UseVisualStyleBackColor = true;
this.ChunkBox.Visible = false;
this.ChunkBox.CheckedChanged += new System.EventHandler(this.ChunkBox_CheckedChanged);
//
// ImagesBar
//
this.ImagesBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ImagesBar.BackColor = System.Drawing.Color.Black;
this.ImagesBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.ImagesBar.Location = new System.Drawing.Point(190, 367);
this.ImagesBar.Name = "ImagesBar";
this.ImagesBar.Size = new System.Drawing.Size(126, 23);
this.ImagesBar.Step = 2;
this.ImagesBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.ImagesBar.TabIndex = 8;
this.ImagesBar.Visible = false;
//
// ImagesLabel
//
this.ImagesLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ImagesLabel.BackColor = System.Drawing.Color.Transparent;
this.ImagesLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.ImagesLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.ImagesLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.ImagesLabel.Location = new System.Drawing.Point(322, 367);
this.ImagesLabel.Name = "ImagesLabel";
this.ImagesLabel.Size = new System.Drawing.Size(126, 24);
this.ImagesLabel.TabIndex = 9;
this.ImagesLabel.Text = "0/0";
this.ImagesLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.ImagesLabel.Visible = false;
//
// SoundsLabel
//
this.SoundsLabel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SoundsLabel.BackColor = System.Drawing.Color.Black;
this.SoundsLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.SoundsLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.SoundsLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.SoundsLabel.Location = new System.Drawing.Point(322, 415);
this.SoundsLabel.Name = "SoundsLabel";
this.SoundsLabel.Size = new System.Drawing.Size(126, 24);
this.SoundsLabel.TabIndex = 11;
this.SoundsLabel.Text = "0/0";
this.SoundsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.SoundsLabel.Visible = false;
//
// SoundBar
//
this.SoundBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SoundBar.BackColor = System.Drawing.Color.Black;
this.SoundBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.SoundBar.Location = new System.Drawing.Point(190, 415);
this.SoundBar.Name = "SoundBar";
this.SoundBar.Size = new System.Drawing.Size(126, 23);
this.SoundBar.Step = 2;
this.SoundBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.SoundBar.TabIndex = 10;
this.SoundBar.Visible = false;
//
// FolderBTN
//
this.FolderBTN.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.FolderBTN.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.FolderBTN.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.FolderBTN.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.FolderBTN.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.FolderBTN.Location = new System.Drawing.Point(190, 453);
this.FolderBTN.Name = "FolderBTN";
this.FolderBTN.Size = new System.Drawing.Size(83, 42);
this.FolderBTN.TabIndex = 12;
this.FolderBTN.Text = "Open Dump Folder";
this.FolderBTN.UseVisualStyleBackColor = false;
this.FolderBTN.Visible = false;
this.FolderBTN.Click += new System.EventHandler(this.FolderBTN_Click);
//
// MFABtn
//
this.MFABtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.MFABtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.MFABtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.MFABtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.MFABtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.MFABtn.Location = new System.Drawing.Point(101, 453);
this.MFABtn.Name = "MFABtn";
this.MFABtn.Size = new System.Drawing.Size(83, 42);
this.MFABtn.TabIndex = 13;
this.MFABtn.Text = "Generate MFA";
this.MFABtn.UseVisualStyleBackColor = false;
this.MFABtn.Visible = false;
this.MFABtn.Click += new System.EventHandler(this.MFABtn_Click);
//
// SoundsButton
//
this.SoundsButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SoundsButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.SoundsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.SoundsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.SoundsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.SoundsButton.Location = new System.Drawing.Point(101, 405);
this.SoundsButton.Name = "SoundsButton";
this.SoundsButton.Size = new System.Drawing.Size(83, 42);
this.SoundsButton.TabIndex = 14;
this.SoundsButton.Text = "Dump Sounds";
this.SoundsButton.UseVisualStyleBackColor = false;
this.SoundsButton.Visible = false;
this.SoundsButton.Click += new System.EventHandler(this.SoundsButton_Click);
//
// ImagesButton
//
this.ImagesButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ImagesButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.ImagesButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.ImagesButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.ImagesButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.ImagesButton.Location = new System.Drawing.Point(101, 357);
this.ImagesButton.Name = "ImagesButton";
this.ImagesButton.Size = new System.Drawing.Size(83, 42);
this.ImagesButton.TabIndex = 15;
this.ImagesButton.Text = "Dump\r\nImages";
this.ImagesButton.UseVisualStyleBackColor = false;
this.ImagesButton.Visible = false;
this.ImagesButton.Click += new System.EventHandler(this.ImagesButton_Click);
//
// loadingLabel
//
this.loadingLabel.BackColor = System.Drawing.Color.Transparent;
this.loadingLabel.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.loadingLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.loadingLabel.Location = new System.Drawing.Point(119, 12);
this.loadingLabel.Name = "loadingLabel";
this.loadingLabel.Size = new System.Drawing.Size(335, 91);
this.loadingLabel.TabIndex = 16;
this.loadingLabel.Text = "Loading...";
this.loadingLabel.Click += new System.EventHandler(this.loadingLabel_Click);
//
// cryptKeyBtn
//
this.cryptKeyBtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cryptKeyBtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.cryptKeyBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cryptKeyBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.cryptKeyBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.cryptKeyBtn.Location = new System.Drawing.Point(12, 405);
this.cryptKeyBtn.Name = "cryptKeyBtn";
this.cryptKeyBtn.Size = new System.Drawing.Size(83, 42);
this.cryptKeyBtn.TabIndex = 17;
this.cryptKeyBtn.Text = "Crypto Key";
this.cryptKeyBtn.UseVisualStyleBackColor = false;
this.cryptKeyBtn.Visible = false;
this.cryptKeyBtn.Click += new System.EventHandler(this.cryptKeyBtn_Click);
//
// showHexBtn
//
this.showHexBtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.showHexBtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.showHexBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.showHexBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.showHexBtn.Location = new System.Drawing.Point(-171, 191);
this.showHexBtn.Name = "showHexBtn";
this.showHexBtn.Size = new System.Drawing.Size(180, 29);
this.showHexBtn.TabIndex = 18;
this.showHexBtn.Text = "Show hex";
this.showHexBtn.UseVisualStyleBackColor = false;
this.showHexBtn.Visible = false;
this.showHexBtn.Click += new System.EventHandler(this.ShowHex_Click);
//
// dumpSortedBtn
//
this.dumpSortedBtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.dumpSortedBtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.dumpSortedBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dumpSortedBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.dumpSortedBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.dumpSortedBtn.Location = new System.Drawing.Point(12, 453);
this.dumpSortedBtn.Name = "dumpSortedBtn";
this.dumpSortedBtn.Size = new System.Drawing.Size(83, 42);
this.dumpSortedBtn.TabIndex = 19;
this.dumpSortedBtn.Text = "Dump Sorted";
this.dumpSortedBtn.UseVisualStyleBackColor = false;
this.dumpSortedBtn.Visible = false;
this.dumpSortedBtn.Click += new System.EventHandler(this.dumpSortedBtn_Click);
//
// ChunkCombo
//
this.ChunkCombo.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.saveChunkBtn, this.viewHexBtn});
this.ChunkCombo.Name = "Save";
this.ChunkCombo.Size = new System.Drawing.Size(124, 48);
this.ChunkCombo.Opening += new System.ComponentModel.CancelEventHandler(this.ChunkCombo_Opening);
this.ChunkCombo.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ChunkCombo_ItemSelected);
//
// saveChunkBtn
//
this.saveChunkBtn.Name = "saveChunkBtn";
this.saveChunkBtn.Size = new System.Drawing.Size(123, 22);
this.saveChunkBtn.Text = "Save";
//
// viewHexBtn
//
this.viewHexBtn.Name = "viewHexBtn";
this.viewHexBtn.Size = new System.Drawing.Size(123, 22);
this.viewHexBtn.Text = "View Hex";
//
// packDataBtn
//
this.packDataBtn.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.packDataBtn.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.packDataBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.packDataBtn.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.packDataBtn.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.packDataBtn.Location = new System.Drawing.Point(12, 357);
this.packDataBtn.Name = "packDataBtn";
this.packDataBtn.Size = new System.Drawing.Size(83, 42);
this.packDataBtn.TabIndex = 20;
this.packDataBtn.Text = "Pack Data";
this.packDataBtn.UseVisualStyleBackColor = false;
this.packDataBtn.Visible = false;
this.packDataBtn.Click += new System.EventHandler(this.packDataBtn_Click);
//
// MainForm
//
@ -105,18 +403,70 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(943, 507);
this.Controls.Add(this.packDataBtn);
this.Controls.Add(this.dumpSortedBtn);
this.Controls.Add(this.showHexBtn);
this.Controls.Add(this.cryptKeyBtn);
this.Controls.Add(this.loadingLabel);
this.Controls.Add(this.ImagesButton);
this.Controls.Add(this.SoundsButton);
this.Controls.Add(this.MFABtn);
this.Controls.Add(this.FolderBTN);
this.Controls.Add(this.SoundsLabel);
this.Controls.Add(this.SoundBar);
this.Controls.Add(this.ImagesLabel);
this.Controls.Add(this.ImagesBar);
this.Controls.Add(this.ChunkBox);
this.Controls.Add(this.SoundBox);
this.Controls.Add(this.ImageBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.GameInfo);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.treeView1);
this.Controls.Add(this.button1);
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.Location = new System.Drawing.Point(15, 15);
this.Name = "MainForm";
this.Text = "DotNetCTFDumper";
this.Load += new System.EventHandler(this.MainForm_Load);
this.ChunkCombo.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button packDataBtn;
private System.Windows.Forms.ToolStripMenuItem saveChunkBtn;
private System.Windows.Forms.ToolStripMenuItem viewHexBtn;
private System.Windows.Forms.ContextMenuStrip ChunkCombo;
private System.Windows.Forms.Button dumpSortedBtn;
private System.Windows.Forms.Button showHexBtn;
private System.Windows.Forms.Button cryptKeyBtn;
private System.Windows.Forms.Label loadingLabel;
private System.Windows.Forms.Button ImagesButton;
private System.Windows.Forms.Button SoundsButton;
private System.Windows.Forms.Button FolderBTN;
private System.Windows.Forms.Button MFABtn;
private System.Windows.Forms.ProgressBar SoundBar;
private System.Windows.Forms.Label SoundsLabel;
private System.Windows.Forms.Label ImagesLabel;
private System.Windows.Forms.ProgressBar ImagesBar;
private System.Windows.Forms.CheckBox ChunkBox;
private System.Windows.Forms.CheckBox ImageBox;
private System.Windows.Forms.CheckBox SoundBox;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label GameInfo;
private System.Windows.Forms.Label label1;

@ -1,39 +1,68 @@
using NetMFAPatcher.MMFParser.Data;
using System;
using System.Collections.Generic;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Be.Windows.Forms;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.MMFParser.Decompiling;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.GUI
{
public partial class MainForm : Form
{
public static bool IsDumpingImages;
public static bool IsDumpingSounds;
public static bool BreakImages;
public static bool BreakSounds;
public Thread LoaderThread;
public Color colorTheme = Color.FromArgb(223,114,38);
public PackDataForm PackForm;
public MainForm()
{
//Buttons
InitializeComponent();
cryptKeyBtn.ForeColor = colorTheme;
dumpSortedBtn.ForeColor = colorTheme;
showHexBtn.ForeColor = colorTheme;
FolderBTN.ForeColor = colorTheme;
MFABtn.ForeColor = colorTheme;
ImagesButton.ForeColor = colorTheme;
SoundsButton.ForeColor = colorTheme;
packDataBtn.ForeColor = colorTheme;
//Menu
saveChunkBtn.ForeColor = colorTheme;
saveChunkBtn.BackColor=Color.Black;
viewHexBtn.ForeColor = colorTheme;
viewHexBtn.BackColor=Color.Black;
//Labels
label1.ForeColor = colorTheme;
label1.Text = Settings.DumperVersion;
button1.ForeColor = colorTheme;
GameInfo.ForeColor = colorTheme;
loadingLabel.ForeColor = colorTheme;
ImagesLabel.ForeColor = colorTheme;
SoundsLabel.ForeColor=colorTheme;
//Other
treeView1.ForeColor = colorTheme;
listBox1.ForeColor = colorTheme;
ImagesBar.ForeColor = colorTheme;
SoundBar.ForeColor = colorTheme;
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
var worker = new BackgroundWorker();
worker.DoWork += (senderA, eA) =>
{
StartReading();
};
worker.RunWorkerCompleted += (senderA, eA) =>
{
AfterLoad();
};
worker.DoWork += (senderA, eA) => { StartReading(); };
worker.RunWorkerCompleted += (senderA, eA) => { AfterLoad(); };
worker.RunWorkerAsync();
}
private void button1_Click(object sender, EventArgs e)
@ -45,50 +74,373 @@ namespace NetMFAPatcher.GUI
{
listBox1.Items.Clear();
loadingLabel.Visible = false;
}
void StartReading()
private void StartReading()
{
var path = openFileDialog1.FileName;
Program.ReadFile(path, false, false, false);
ImagesBar.Value = 0;
SoundBar.Value = 0;
GameInfo.Text = "";
loadingLabel.Visible = true;
ImagesLabel.Text = "0/0";
SoundsLabel.Text = "0/0";
ImageBox.Enabled = false;
SoundBox.Enabled = false;
ChunkBox.Enabled = false;
MFABtn.Visible = false;
FolderBTN.Visible = false;
ImagesButton.Visible = false;
SoundsButton.Visible = false;
cryptKeyBtn.Visible = false;
showHexBtn.Visible = false;
dumpSortedBtn.Visible = false;
packDataBtn.Visible = false;
Program.ReadFile(path, Settings.Verbose, Settings.DumpImages, Settings.DumpSounds);
}
private void treeView1_AfterDblClick(object sender, EventArgs e)
{
ChunkCombo.Show(Cursor.Position);
}
private void treeView1_RightClick(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Right) != 0)
{
ChunkCombo.Show(Cursor.Position);
}
}
private void ChunkCombo_ItemSelected(object sender, ToolStripItemClickedEventArgs e)
{
switch (e.ClickedItem.Name)
{
case "saveChunkBtn":
var chunk = ((ChunkNode) treeView1.SelectedNode).chunk;
if ( chunk!= null)
{
chunk.Save();
}
break;
case "viewHexBtn":
ShowHex();
break;
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
var currentFrame = Exe.LatestInst.GameData.Frames[treeView1.SelectedNode.Index];
var nodeChunk = ((ChunkNode) treeView1.SelectedNode).chunk;
var nodeLoader = ((ChunkNode) treeView1.SelectedNode).loader;
Console.WriteLine("NodeChunk:"+nodeChunk!=null);
Console.WriteLine("NodeLoader:"+nodeLoader!=null);
ChunkList.Chunk chunk = null;
listBox1.Items.Clear();
listBox1.Items.Add($"Size: {currentFrame.Width}x{currentFrame.Height}");
listBox1.Items.Add($"Number of objects: {currentFrame.CountOfObjs}");
if (nodeChunk != null) chunk = nodeChunk;
//if (nodeLoader.Chunk != null) chunk = nodeLoader.Chunk;
if (chunk != null)
{
chunk = nodeChunk;
listBox1.Items.Add($"Name: {chunk.Name}");
listBox1.Items.Add($"Id: {chunk.Id}");
listBox1.Items.Add($"Flag: {chunk.Flag}");
listBox1.Items.Add($"Size: {chunk.Size.ToPrettySize()}");
if (chunk.DecompressedSize>-1)listBox1.Items.Add($"Decompressed Size: {chunk.DecompressedSize.ToPrettySize()}");
}
if (nodeLoader != null)
{
var extData = nodeLoader.GetReadableData();
if (extData.Length > 0)
{
listBox1.Items.Add("");
listBox1.Items.Add("Loader Data:");
foreach (var item in extData)
{
var splitFlags = item.Split(';');
foreach (var splitItem in splitFlags) listBox1.Items.Add(splitItem);
}
}
}
}
public void AfterLoad()
{
GameData gameData = null;
gameData = Exe.LatestInst.GameData;
var gameData = Exe.LatestInst.GameData;
foreach (var item in gameData.Frames)
treeView1.Nodes.Clear();
foreach (var item in gameData.GameChunks.Chunks)
{
treeView1.Nodes.Add(item.Name);
string ActualName = item.Name;
if (item.Loader is Frame frm) ActualName = ActualName + " "+frm.Name;
ChunkNode newNode = Helper.GetChunkNode(item,ActualName);
//if (item.Loader != null) newNode = new ChunkNode(ActualName, item.Loader);
//else newNode = new ChunkNode(ActualName, item);
treeView1.Nodes.Add(newNode);
if (item.Loader is Frame frame)
foreach (var frmChunk in frame.Chunks.Chunks)
{
var frameNode = Helper.GetChunkNode(frmChunk);//new ChunkNode(frmChunk.Name, frmChunk);
newNode.Nodes.Add(frameNode);
if (frameNode.loader is ObjectInstances)
{
var objs = frame.Chunks.get_chunk<ObjectInstances>();
if (objs != null)
{
foreach (var frmitem in objs.Items)
{
var objNode = new ChunkNode(frmitem.Name, frmitem);
frameNode.Nodes.Add(objNode);
}
}
}
}
string toLog = "";
}
ImageBox.Enabled = true;
SoundBox.Enabled = true;
ChunkBox.Enabled = true;
MFABtn.Visible = true;
FolderBTN.Visible = true;
ImagesButton.Visible = true;
SoundsButton.Visible = true;
cryptKeyBtn.Visible = true;
//showHexBtn.Visible = true;
dumpSortedBtn.Visible = true;
packDataBtn.Visible = true;
GameInfo.Visible = true;
loadingLabel.Visible = false;
var toLog = "";
toLog += $"Title:{Exe.LatestInst.GameData.Name}\n";
toLog += $"Copyright:{Exe.LatestInst.GameData.Copyright}\n";
toLog += $"Editor Filename: {Exe.LatestInst.GameData.EditorFilename}\n";
//toLog += $"Build Filename: {EXE.LatestInst.game_data.TargetFilename}\n";
toLog += $"Product Build: {Exe.LatestInst.GameData.ProductBuild}\n";
toLog += $"Product Version: {Exe.LatestInst.GameData.ProductVersion}\n";
toLog += $"Build: {Exe.LatestInst.GameData.Build}\n";
toLog += $"Runtime Version: {Exe.LatestInst.GameData.RuntimeVersion}\n";
toLog += $"Number Of Images: {Exe.LatestInst.GameData.Images.NumberOfItems}\n";
toLog += $"Number Of Sounds: {Exe.LatestInst.GameData.Sounds.NumOfItems}\n";
toLog += $"Unique FrameItems: {Exe.LatestInst.GameData.Frameitems.NumberOfItems}\n";
toLog += $"Frame Count: {Exe.LatestInst.GameData.Frames.Count}\n";
toLog += $"Chunks Count: {Exe.LatestInst.GameData.GameChunks.Chunks.Count}\n";
//toLog += $"Runtime Subversion: {Exe.LatestInst.GameData.RuntimeSubversion}\n";
GameInfo.Text = toLog;
}
private void ImageBox_CheckedChanged(object sender, EventArgs e)
{
Settings.DumpImages = ImageBox.Checked;
ImagesBar.Visible = ImageBox.Checked;
ImagesLabel.Visible = ImageBox.Checked;
}
private void SoundBox_CheckedChanged(object sender, EventArgs e)
{
Settings.DumpSounds = SoundBox.Checked;
SoundBar.Visible = SoundBox.Checked;
SoundsLabel.Visible = SoundBox.Checked;
}
private void ChunkBox_CheckedChanged(object sender, EventArgs e)
{
Settings.SaveChunks = ChunkBox.Checked;
}
public void UpdateImageBar(int index, int all)
{
all -= 1;
ImagesBar.Value = (int) (index / (float) all * 100);
ImagesLabel.Text = $"{index}/{all}";
}
public void UpdateSoundBar(int index, int all)
{
all -= 1;
SoundBar.Value = (int) (index / (float) all * 100);
SoundsLabel.Text = $"{index}/{all}";
}
private void FolderBTN_Click(object sender, EventArgs e)
{
Process.Start($"{Settings.DumpPath}");
}
private void MFABtn_Click(object sender, EventArgs e)
{
MFAGenerator.BuildMFA();
}
private void SoundsButton_Click(object sender, EventArgs e)
{
if (!IsDumpingSounds)
{
SoundBar.Visible = true;
SoundsLabel.Visible = true;
SoundsButton.Text = "Cancel";
IsDumpingSounds = true;
var worker = new BackgroundWorker();
worker.DoWork += (senderA, eA) =>
{
var cachedImgState = Settings.DumpSounds;
Settings.DumpSounds = true;
Exe.LatestInst.GameData.GameChunks.get_chunk<SoundBank>().Read();
Settings.DumpSounds = cachedImgState;
};
worker.RunWorkerCompleted += (senderA, eA) =>
{
SoundBar.Visible = false;
SoundsLabel.Visible = false;
Logger.Log("Sounds done");
SoundsButton.Text = "Dump Sounds";
};
worker.RunWorkerAsync();
}
else
{
BreakSounds = true;
SoundBar.Visible = false;
SoundsLabel.Visible = false;
SoundsButton.Text = "Dump Sounds";
IsDumpingSounds = false;
}
}
private void ImagesButton_Click(object sender, EventArgs e)
{
if (!IsDumpingImages)
{
ImagesBar.Visible = true;
ImagesLabel.Visible = true;
ImagesButton.Text = "Cancel";
IsDumpingImages = true;
//ImagesLabel.BackColor=Color.Transparent;
//ImagesLabel.ForeColor=Color.Red;
;
var worker = new BackgroundWorker();
worker.DoWork += (senderA, eA) =>
{
var cachedImgState = Settings.DumpImages;
Settings.DumpImages = true;
Exe.LatestInst.GameData.GameChunks.get_chunk<ImageBank>().Read();
Settings.DumpImages = cachedImgState;
};
worker.RunWorkerCompleted += (senderA, eA) =>
{
ImagesBar.Visible = false;
ImagesLabel.Visible = false;
ImagesButton.Text = "Dump\nImages";
Logger.Log("Images done");
};
worker.RunWorkerAsync();
}
else
{
BreakImages = true;
ImagesBar.Visible = false;
ImagesLabel.Visible = false;
ImagesButton.Text = "Dump\nImages";
IsDumpingImages = false;
}
}
private void cryptKeyBtn_Click(object sender, EventArgs e)
{
var rawData = "";
if (Settings.Build > 284)
{
rawData += Settings.AppName;
rawData += Settings.Copyright;
rawData += Settings.ProjectPath;
}
else
{
rawData += Settings.ProjectPath;
rawData += Settings.AppName;
rawData += Settings.Copyright;
}
var KeyForm = new CryptoKeyForm(rawData,colorTheme);
KeyForm.Show();
}
private void ShowHex_Click(object sender, EventArgs e)
{
ShowHex();
}
private void ShowHex()
{
if ((ChunkNode) treeView1.SelectedNode != null)
{
var node = ((ChunkNode) treeView1.SelectedNode);
HexViewForm hexform = null;
hexform = new HexViewForm(node.chunk.ChunkData,node.chunk.RawData,colorTheme,$"Hew View: {node.chunk.Name}");
hexform.Show();
}
}
private void loadingLabel_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
private void dumpSortedBtn_Click(object sender, EventArgs e)
{
ImageDumper.DumpImages();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//throw new System.NotImplementedException();
}
private void ChunkCombo_Opening(object sender, CancelEventArgs e)
{
}
private void tabPage1_Click(object sender, EventArgs e)
{
throw new System.NotImplementedException();
}
private void packDataBtn_Click(object sender, EventArgs e)
{
if(PackForm==null)PackForm = new PackDataForm(Exe.LatestInst.PackData,colorTheme);
PackForm.Show();
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,124 @@
using System.ComponentModel;
namespace NetMFAPatcher.GUI
{
partial class PackDataForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PackDataForm));
this.listBox1 = new System.Windows.Forms.ListBox();
this.dumpButton = new System.Windows.Forms.Button();
this.dumpAllButton = new System.Windows.Forms.Button();
this.infoLabel = new System.Windows.Forms.Label();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.BackColor = System.Drawing.SystemColors.WindowText;
this.listBox1.Dock = System.Windows.Forms.DockStyle.Left;
this.listBox1.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.listBox1.FormattingEnabled = true;
this.listBox1.Items.AddRange(new object[] {"PackFile1", "PackFile2", "PackFile3", "PackFile4", "PackFile5", "PackFile6"});
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(198, 390);
this.listBox1.TabIndex = 0;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// dumpButton
//
this.dumpButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.dumpButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dumpButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.dumpButton.Location = new System.Drawing.Point(204, 105);
this.dumpButton.Name = "dumpButton";
this.dumpButton.Size = new System.Drawing.Size(143, 37);
this.dumpButton.TabIndex = 1;
this.dumpButton.Text = "Dump";
this.dumpButton.UseVisualStyleBackColor = false;
this.dumpButton.Click += new System.EventHandler(this.dumpButton_Click);
//
// dumpAllButton
//
this.dumpAllButton.BackColor = System.Drawing.Color.FromArgb(((int) (((byte) (64)))), ((int) (((byte) (64)))), ((int) (((byte) (64)))));
this.dumpAllButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dumpAllButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.dumpAllButton.Location = new System.Drawing.Point(204, 148);
this.dumpAllButton.Name = "dumpAllButton";
this.dumpAllButton.Size = new System.Drawing.Size(143, 37);
this.dumpAllButton.TabIndex = 2;
this.dumpAllButton.Text = "Dump All";
this.dumpAllButton.UseVisualStyleBackColor = false;
this.dumpAllButton.Click += new System.EventHandler(this.dumpAllButton_Click);
//
// infoLabel
//
this.infoLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.infoLabel.Location = new System.Drawing.Point(204, 14);
this.infoLabel.Name = "infoLabel";
this.infoLabel.Size = new System.Drawing.Size(142, 91);
this.infoLabel.TabIndex = 3;
this.infoLabel.Text = "Name: PackFile1.mvx\r\nSize: 5 MB\r\n";
//
// saveFileDialog1
//
this.saveFileDialog1.InitialDirectory = "C:\\Windows";
this.saveFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog1_FileOk);
//
// PackDataForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(646, 390);
this.Controls.Add(this.infoLabel);
this.Controls.Add(this.dumpAllButton);
this.Controls.Add(this.dumpButton);
this.Controls.Add(this.listBox1);
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.Name = "PackDataForm";
this.Text = "Pack Files";
this.Load += new System.EventHandler(this.HexViewForm_Load);
this.ResumeLayout(false);
}
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.Label infoLabel;
private System.Windows.Forms.Button dumpAllButton;
private System.Windows.Forms.Button dumpButton;
private System.Windows.Forms.ListBox listBox1;
#endregion
}
}

@ -0,0 +1,84 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Be.Windows.Forms;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.GUI
{
public partial class PackDataForm : Form
{
private PackData data;
public PackDataForm(PackData data,Color color)
{
InitializeComponent();
listBox1.ForeColor = color;
dumpButton.ForeColor = color;
dumpAllButton.ForeColor = color;
infoLabel.ForeColor = color;
this.data = data;
}
private void HexViewForm_Load(object sender, EventArgs e)
{
listBox1.Items.Clear();
foreach (var item in data.Items)
{
listBox1.Items.Add(item.PackFilename);
}
UpdateInfo(0);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateInfo(listBox1.SelectedIndex);
}
private void UpdateInfo(int index)
{
var item = data.Items[index];
infoLabel.Text = $"Name: {item.PackFilename}\nSize: {item.Data.Length.ToPrettySize()}";
}
private void dumpButton_Click(object sender, EventArgs e)
{
var item = data.Items[listBox1.SelectedIndex];
saveFileDialog1.FileName = item.PackFilename;
if (item.PackFilename.EndsWith(".mfx")) saveFileDialog1.Filter = "Clickteam Extension(*.mfx)|.mfx";
else if (item.PackFilename.EndsWith(".dll")) saveFileDialog1.Filter = "Clickteam Module(*.dll)|.dll";
saveFileDialog1.InitialDirectory = Path.GetFullPath(Settings.ExtensionPath);
saveFileDialog1.ShowDialog();
}
private void dumpAllButton_Click(object sender, EventArgs e)
{
foreach (var item in data.Items)
{
item.Dump();
}
}
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
var item = data.Items[listBox1.SelectedIndex];
item.Dump(saveFileDialog1.FileName);
}
}
}

File diff suppressed because it is too large Load Diff

@ -1,9 +1,9 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
@ -29,6 +29,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
while(true)
@ -89,6 +94,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
ObjectInfo = Reader.ReadUInt16();
@ -117,6 +127,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var currentPosition = Reader.Tell();

@ -1,13 +1,11 @@
using mmfparser;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using NetMFAPatcher.MMFParser.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
using static NetMFAPatcher.mmfparser.Constants;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
@ -17,7 +15,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int OtherFlags;
public int DefType;
public int NumberOfParameters;
public ObjectType ObjectType;
public Constants.ObjectType ObjectType;
public int Num;
public int ObjectInfo;
public int Identifier;
@ -33,7 +31,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
var currentPosition = Reader.Tell();
var size = Reader.ReadUInt16();
ObjectType = (ObjectType)Reader.ReadInt16();
ObjectType = (Constants.ObjectType)Reader.ReadInt16();
Num = Reader.ReadInt16();
ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = Reader.ReadInt16();
@ -65,7 +63,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int Flags;
public int OtherFlags;
public int DefType;
public ObjectType ObjectType;
public Constants.ObjectType ObjectType;
public int Num;
public int ObjectInfo;
public int ObjectInfoList;
@ -80,7 +78,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
var currentPosition = Reader.Tell();
var size = Reader.ReadUInt16();
ObjectType = (ObjectType)Reader.ReadInt16();
ObjectType = (Constants.ObjectType)Reader.ReadInt16();
Num = Reader.ReadInt16();
ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = Reader.ReadInt16();

@ -1,17 +1,12 @@
using mmfparser;
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Expressions
{
class Expression : DataLoader
{
public ObjectType ObjectType;
public Constants.ObjectType ObjectType;
public int Num;
public int ObjectInfo;
public int ObjectInfoList;

@ -1,9 +1,9 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,10 +1,5 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,5 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,10 +1,6 @@
using mmfparser;
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -1,9 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{

@ -15,6 +15,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var filename = Reader.ReadAscii();

@ -1,10 +1,9 @@
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -18,6 +17,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var numberOfItems = Reader.ReadUInt16();
@ -57,6 +61,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var count = Reader.ReadUInt32();

@ -1,10 +1,10 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -16,6 +16,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var start = Reader.Tell();

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects
{
public class Animations:ChunkLoader
{
public Dictionary<int, Animation> AnimationDict;
public Animations(ByteIO reader) : base(reader)
{
}
public Animations(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var currentPosition = Reader.Tell();
var size = Reader.ReadInt16();
var count = Reader.ReadInt16();
var offsets = new List<short>();
for (int i = 0; i < count; i++)
{
offsets.Add(Reader.ReadInt16());
}
AnimationDict = new Dictionary<int,Animation>();
if (offsets.Count <= 0) return;
for (int i = 0; i < 1; i++)//I am stupid faggot, i don't know, whats wrong with this list
{
var offset = offsets[i];
if (offset != 0)
{
Console.WriteLine("Offset: "+offset);
Reader.Seek(currentPosition+offset);
var anim = new Animation(Reader);
anim.Read();
AnimationDict.Add(i,anim);
}
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class Animation : ChunkLoader
{
public Dictionary<int, AnimationDirection> DirectionDict;
public Animation(ByteIO reader) : base(reader)
{
}
public Animation(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var currentPosition = Reader.Tell();
var offsets = new List<int>();
for (int i = 0; i < 32; i++)
{
offsets.Add(Reader.ReadInt16());
}
DirectionDict = new Dictionary<int,AnimationDirection>();
for (int i = 0; i < offsets.Count; i++)
{
var offset = offsets[i];
if (offset != 0)
{
Reader.Seek(currentPosition+offset);
var dir = new AnimationDirection(Reader);
dir.Read();
DirectionDict.Add(i,dir);
}
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class AnimationDirection : ChunkLoader
{
public int MinSpeed;
public int MaxSpeed;
public bool HasSingle;
public int Repeat;
public int BackTo;
public List<int> Frames = new List<int>();
public AnimationDirection(ByteIO reader) : base(reader)
{
}
public AnimationDirection(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
MinSpeed = Reader.ReadSByte();
MaxSpeed = Reader.ReadSByte();
Repeat = Reader.ReadInt16();
BackTo = Reader.ReadInt16();
var frameCount = Reader.ReadUInt16();
for (int i = 0; i < frameCount; i++)
{
var handle = Reader.ReadInt16();
Frames.Add(handle);
Console.WriteLine("Frame Found: "+handle);
}
}
public override void Print(bool ext)
{
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
}

@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects
{
public class ObjectCommon:ChunkLoader
{
private short _valuesOffset;
private short _stringsOffset;
private int _fadeinOffset;
private int _fadeoutOffset;
private ushort _movementsOffset;
private short _animationsOffset;
private short _systemObjectOffset;
private short _counterOffset;
private short _extensionOffset;
public Animations Animations;
private long _end;
public ObjectCommon(ByteIO reader) : base(reader)
{
}
public ObjectCommon(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var currentPosition = Reader.Tell();
var size = Reader.ReadInt32();
var newobj = Settings.Build > 284;
var newobj2 = true;
if (newobj&&newobj2)
{
_animationsOffset = (short) Reader.ReadUInt16();
_movementsOffset = Reader.ReadUInt16();
var Version = Reader.ReadInt16();
Reader.ReadBytes(2);
var extensionOffset = Reader.ReadUInt16();
var counterOffset = Reader.ReadUInt16();
var flags = Reader.ReadUInt32();
var end = Reader.Tell() + 16;
var qualifiers = new List<short>();
for (int i = 0; i < 8; i++)
{
var qualifier = Reader.ReadInt16();
if (qualifier == -1) break;
qualifiers.Add(qualifier);
}
Reader.Seek(end);
var systemObjectOffset = Reader.ReadInt16();
_valuesOffset = Reader.ReadInt16();
_stringsOffset = Reader.ReadInt16();
var newFlags = Reader.ReadUInt16();
var preferences = Reader.ReadFourCc();
var backColor = Reader.ReadColor();
var fadeinOffset = Reader.ReadInt32();
var fadeoutOffset = Reader.ReadInt32();
}
else if (newobj)
{
_counterOffset = Reader.ReadInt16();
var version = Reader.ReadInt16();
Reader.ReadBytes(2);
_movementsOffset = (ushort) Reader.ReadInt16();
_extensionOffset = Reader.ReadInt16();
_animationsOffset = Reader.ReadInt16();
var flags = Reader.ReadUInt32();
var end = Reader.Tell() + 16;
var qualifiers = new List<short>();
for (int i = 0; i < 8; i++)
{
var qualifier = Reader.ReadInt16();
if (qualifier == -1) break;
qualifiers.Add(qualifier);
}
Reader.Seek(end);
_valuesOffset = Reader.ReadInt16();
_stringsOffset = Reader.ReadInt16();
var newFlags = Reader.ReadUInt16();
var preferences = Reader.ReadFourCc();
var backColor = Reader.ReadColor();
_fadeinOffset = Reader.ReadInt32();
_fadeoutOffset = Reader.ReadInt32();
}
else
{
_movementsOffset = Reader.ReadUInt16();
_animationsOffset = Reader.ReadInt16();
var version = Reader.ReadInt16();
_counterOffset = Reader.ReadInt16();
_systemObjectOffset = Reader.ReadInt16();
Reader.ReadBytes(2);
var flags = Reader.ReadUInt32();
_end = Reader.Tell() + 16;
var qualifiers = new List<short>();
for (int i = 0; i < 8; i++)
{
var qualifier = Reader.ReadInt16();
if (qualifier == -1) break;
qualifiers.Add(qualifier);
}
Reader.Seek(_end);
_extensionOffset = Reader.ReadInt16();
_valuesOffset = Reader.ReadInt16();
_stringsOffset = Reader.ReadInt16();
var newFlags = Reader.ReadUInt16();
var preferences = Reader.ReadUInt16();
var identifier = Reader.ReadFourCc();
var backColor = Reader.ReadColor();
_fadeinOffset = Reader.ReadInt32();
_fadeoutOffset = Reader.ReadInt32();
}
if (_movementsOffset != 0)
{
//Reader.Seek(currentPosition+_movementsOffset);
//var movements = new Movements(Reader);
//movements.Read();
}
Console.WriteLine("Movements done");
if (_valuesOffset != 0)
{
Reader.Seek(currentPosition+_valuesOffset);
var values = new AlterableValues(Reader);
values.Read();
}
Console.WriteLine("Values done");
if (_stringsOffset != 0)
{
Reader.Seek(currentPosition+_stringsOffset);
var strings = new AlterableStrings(Reader);
strings.Read();
}
Console.WriteLine("Strings done");
if (_animationsOffset != 0)
{
Reader.Seek(currentPosition+_stringsOffset);
Animations = new Animations(Reader);
Animations.Read();
}
Console.WriteLine("Animations done");
Console.WriteLine("SysObjOff: "+_systemObjectOffset);
Console.WriteLine("ExtOff: "+_extensionOffset);
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
}

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Objects
{
public class AlterableValues:ChunkLoader
{
public AlterableValues(ByteIO reader) : base(reader)
{
}
public AlterableValues(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var items = new List<int>();
var count = Reader.ReadUInt16();
Console.WriteLine(count);
for (int i = 0; i < count; i++)
{
var item = Reader.ReadInt32();
items.Add(item);
Console.WriteLine("Found Value: "+item);
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class AlterableStrings:ChunkLoader
{
public AlterableStrings(ByteIO reader) : base(reader)
{
}
public AlterableStrings(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var items = new List<string>();
var count = Reader.ReadUInt16();
for (int i = 0; i < count; i++)
{
var item = Reader.ReadWideString();
items.Add(item);
Console.WriteLine("Found String: "+item);
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
}

@ -1,13 +1,11 @@
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using System.Windows.Forms;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using static NetMFAPatcher.mmfparser.Constants;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Constants;
namespace NetMFAPatcher.MMFParser.Data
{
@ -36,8 +34,8 @@ namespace NetMFAPatcher.MMFParser.Data
}
if (chunk.Verbose)
{
chunk.Print(Program.LogAll);
if(Program.LogAll) Console.ReadKey();
chunk.Print(false);
@ -67,9 +65,10 @@ namespace NetMFAPatcher.MMFParser.Data
public ChunkLoader Loader;
public byte[] ChunkData;
public byte[] RawData;
public ChunkFlags Flag;
public int Size = 0;
public int DecompressedSize = 0;
public int DecompressedSize = -1;
public bool Verbose = false;
public Chunk(int actualuid, ChunkList actualChunkList)
@ -86,10 +85,15 @@ namespace NetMFAPatcher.MMFParser.Data
public void Read(ByteIO exeReader)
{
Id = exeReader.ReadInt16();
Name = ((ChunkNames) Id).ToString();
Name = this.ActualName();
Flag = (ChunkFlags) exeReader.ReadInt16();
Size = exeReader.ReadInt32();
if((Id!=26214&&Id!=26216)) //To prevent RAM from commiting suicide
{
RawData = exeReader.ReadBytes(Size);
exeReader.BaseStream.Position -= Size;
}
switch (Flag)
{
@ -97,22 +101,17 @@ namespace NetMFAPatcher.MMFParser.Data
ChunkData = Decryption.DecodeChunk(exeReader.ReadBytes(Size),Size);
break;
case ChunkFlags.CompressedAndEncrypyed:
ChunkData = Decryption.DecodeMode3(exeReader.ReadBytes(Size), Size,Id);
ChunkData = Decryption.DecodeMode3(exeReader.ReadBytes(Size), Size,Id,out DecompressedSize);
break;
case ChunkFlags.Compressed:
ChunkData = Decompressor.Decompress(exeReader);
ChunkData = Decompressor.Decompress(exeReader,out DecompressedSize);
break;
case ChunkFlags.NotCompressed:
ChunkData = exeReader.ReadBytes(Size);
break;
}
if (ChunkData != null)
{
DecompressedSize = ChunkData.Length;
// string path = $"{Program.DumpPath}\\CHUNKS\\{Name}.chunk";
// File.WriteAllBytes(path, ChunkData);
}
int tempId=0;
int.TryParse(Name,out tempId);
if(tempId==Id)
@ -122,6 +121,16 @@ namespace NetMFAPatcher.MMFParser.Data
}
public void Save()
{
if (ChunkData != null)
{
string path = $"{Settings.ChunkPath}\\{Name}.chunk";
File.WriteAllBytes(path, ChunkData);
}
}
public void Print(bool extented)
{
if(extented)
@ -160,8 +169,12 @@ namespace NetMFAPatcher.MMFParser.Data
var projectChunk = _chunkList.get_chunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.Value;
Settings.AppName=title;
Settings.Copyright = copyright;
Settings.ProjectPath = project;
if (Exe.LatestInst.GameData.ProductBuild >= 284)
if (Exe.LatestInst.GameData.ProductBuild > 284)
{
Decryption.MakeKey(title, copyright, project);
}
@ -251,6 +264,10 @@ namespace NetMFAPatcher.MMFParser.Data
case 17476:
loader = new ObjectHeader(chunk);
break;
case 17478:
loader = new ObjectProperties(chunk);
return loader;
break;
case 8788:
//loader = new ObjectNames(chunk);
break;
@ -263,6 +280,7 @@ namespace NetMFAPatcher.MMFParser.Data
case 13117:
//loader = new Events(chunk);//NOT WORKING
break;
}
if (loader != null)

@ -1,12 +1,7 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace mmfparser
namespace NetMFAPatcher.MMFParser.Data
{
public abstract class DataLoader
{

@ -1,30 +1,28 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.Data
{
class Exe
public class Exe
{
public PackData PackData;
public GameData GameData;
public static Exe LatestInst;
public void ParseExe(ByteIO exeReader)
{
LatestInst = this;
Logger.Log($"Executable: {Program.GameName}\n", true, ConsoleColor.DarkRed);
Exe.LatestInst = this;
Logger.Log($"Executable: {Settings.GameName}\n", true, ConsoleColor.DarkRed);
string header1 = exeReader.ReadAscii(2);
Logger.Log("EXE Header: " + header1, true, ConsoleColor.Yellow);
if (header1 != "MZ")
string sig = exeReader.ReadAscii(2);
Logger.Log("EXE Header: " + sig, true, ConsoleColor.Yellow);
if (sig != "MZ")
{
Console.WriteLine("Invalid executable signature");
Console.ReadKey();
Environment.Exit(0);
}
exeReader.Seek(60, SeekOrigin.Begin);

@ -1,14 +1,13 @@
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using static NetMFAPatcher.mmfparser.Constants;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.Data
{
@ -17,8 +16,8 @@ namespace NetMFAPatcher.MMFParser.Data
public int RuntimeVersion;
public int RuntimeSubversion;
public int ProductBuild;
public int ProductVersion;
public Products Build;
public Constants.Products ProductVersion;
public int Build;
public ChunkList GameChunks;
public string Name;
@ -65,9 +64,11 @@ namespace NetMFAPatcher.MMFParser.Data
RuntimeVersion = exeReader.ReadUInt16(); //
RuntimeSubversion = exeReader.ReadUInt16(); //0
ProductVersion = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
ProductVersion = (Constants.Products)exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
ProductBuild = exeReader.ReadInt32(); //CTF Build
Build = (Products)RuntimeVersion;
Settings.Build=ProductBuild;
Build = ProductBuild;
GameChunks = new ChunkList(); //Reading game chunks
GameChunks.Read(exeReader);
@ -97,9 +98,9 @@ namespace NetMFAPatcher.MMFParser.Data
Logger.Log($"GameData Info:", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Version: {RuntimeVersion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Subversion: { RuntimeSubversion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { ((Products)ProductVersion).ToString()}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { ((Constants.Products)ProductVersion).ToString()}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Build: {ProductBuild}", true, ConsoleColor.DarkGreen);
Logger.Log($" {(IsUnicode ? "Unicode" : "NonUnicode")} Game", true, ConsoleColor.DarkGreen);
Logger.Log($" {(Constants.IsUnicode ? "Unicode" : "NonUnicode")} Game", true, ConsoleColor.DarkGreen);
Logger.Log($"Game Info:", true, ConsoleColor.Cyan);
Logger.Log($" Name:{Name}", true, ConsoleColor.Cyan);
Logger.Log($" Author:{Author}", true, ConsoleColor.Cyan);
@ -134,7 +135,16 @@ namespace NetMFAPatcher.MMFParser.Data
Logger.Log("Frames: ", true, ConsoleColor.Cyan);
foreach (var item in Frames)
{
Logger.Log($" Frame: {item.Name}, Size: {item.Width}x{item.Height}, Number of objects: {item.CountOfObjs}", true, ConsoleColor.Cyan);
Logger.Log($" Frame: {item.Name,25}, Size: {item.Width,4}x{item.Height,4}, Number of objects: {item.CountOfObjs,5}", true, ConsoleColor.Cyan);
var objects = item.Chunks.get_chunk<ObjectInstances>();
if (objects != null)
{
foreach (var obj in objects.Items)
{
Logger.Log($" Object: {obj.Name}", true, ConsoleColor.Green);
}
}
}

@ -1,21 +1,19 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Frame = NetMFAPatcher.mmfparser.mfaloaders.Frame;
using mmfparser;
using System.Net.NetworkInformation;
using System.Windows.Forms;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.MFALoaders;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using Controls = NetMFAPatcher.MMFParser.MFALoaders.Controls;
using Frame = NetMFAPatcher.MMFParser.MFALoaders.Frame;
namespace NetMFAPatcher.mfa
namespace NetMFAPatcher.MMFParser.Data
{
class Mfa : DataLoader
public class MFA : DataLoader
{
public static readonly string FontBankId = "ATNF";
public static readonly string ImageBankId = "AGMI";
@ -34,6 +32,8 @@ namespace NetMFAPatcher.mfa
public FontBank Fonts;
public SoundBank Sounds;
public MusicBank Music;
public AgmiBank Icons;
public AgmiBank Images;
public string Author;
@ -48,6 +48,65 @@ namespace NetMFAPatcher.mfa
public ValueList GlobalValues;
public ValueList GlobalStrings;
public Color BorderColor;
public BitDict DisplayFlags = new BitDict(new string[]
{
"MaximizedOnBoot",
"ResizeDisplay",
"FullscreenAtStart",
"AllowFullscreen",
"Heading",
"HeadingWhenMaximized",
"MenuBar",
"MenuOnBoot",
"NoMinimize",
"NoMaximize",
"NoThickFrame",
"NoCenter",
"DisableClose",
"HiddenAtStart",
"MDI"
});
public BitDict GraphicFlags = new BitDict(new string[]
{
"MultiSamples",
"SpeedIndependent",
"SoundsOverFrames",
"PlaySamplesWhenUnfocused",
"IgnoreInputOnScreensaver",
"DirectX",
"VRAM",
"EnableVisualThemes",
"VSync",
"RunWhenMinimized",
"RunWhenResizing",
"EnableDebuggerShortcuts",
"NoDebugger",
"NoSubappSharing"
});
public string HelpFile;
public int VitalizePreview;
public int InitialScore;
public int InitialLifes;
public int FrameRate;
public int BuildType;
public string BuildPath;
public string CommandLine;
public string Aboutbox;
public uint MenuSize;
public AppMenu Menu;
private int windowMenuIndex;
private int[] menuImages;
private byte[] GlobalEvents;
private int GraphicMode;
private int IcoCount;
private int QualCount;
public Controls Controls;
public List<int> IconImages;
public List<Tuple<int, string, string, int, byte[]>> Extensions;
public List<Tuple<string, int>> CustomQuals;
public List<Frame> Frames;
public override void Print()
@ -78,6 +137,91 @@ namespace NetMFAPatcher.mfa
writer.WriteAscii(MusicBankId);
//music.Write();//cum cum cum cum cum cum cum cum
writer.WriteInt32(0);//someone is using musics lol?
writer.WriteAscii(ImageBankId);
Icons.Write(writer);
writer.WriteAscii(ImageBankId);
Images.Write(writer);
writer.AutoWriteUnicode(Name);
writer.AutoWriteUnicode(Author);
writer.AutoWriteUnicode(Description);
writer.AutoWriteUnicode(Copyright);
writer.AutoWriteUnicode(Company);
writer.AutoWriteUnicode(Version);
writer.WriteInt32(WindowX);
writer.WriteInt32(WindowY);
writer.WriteColor(Color.White);
writer.WriteInt32((int) DisplayFlags.flag);
writer.WriteInt32((int) GraphicFlags.flag);
writer.WriteUInt32((uint) InitialScore);
writer.WriteUInt32((uint) InitialLifes);
writer.WriteInt32(FrameRate);
writer.WriteInt32(BuildType);
writer.AutoWriteUnicode(BuildPath);
writer.WriteInt32(0);
writer.AutoWriteUnicode(CommandLine);
writer.AutoWriteUnicode(Aboutbox);
writer.WriteInt32(0);//anaconda
writer.WriteInt32(0);//binary files are not supported because i am lazy asshole
Controls.Write(writer);
Menu = null; //cunt
if (Menu != null)
{
byte[] menuData = new byte[15]; //Menu.Generate;
writer.WriteInt32(menuData.Length);
writer.WriteBytes(menuData);
}
else
{
writer.WriteInt32(0);
}
writer.WriteInt32(windowMenuIndex);
writer.WriteInt32(menuImages.Length);
foreach (var item in menuImages)
{
writer.WriteInt32(item);
}
GlobalValues.Write(writer);
GlobalStrings.Write(writer);
writer.WriteInt32(GlobalEvents.Length);
writer.WriteBytes(GlobalEvents);
writer.WriteInt32(GraphicMode);
writer.WriteInt32(IconImages.Count);
foreach (var item in IconImages)
{
writer.WriteInt32(item);
}
//Qualifiers
writer.WriteInt32(CustomQuals.Count);
foreach (var item in CustomQuals)
{
writer.AutoWriteUnicode(item.Item1);
writer.WriteInt32(item.Item2);
}
//Extensions
foreach (var item in Extensions)
{
writer.WriteInt32(item.Item1);
writer.AutoWriteUnicode(item.Item2);
writer.AutoWriteUnicode(item.Item3);
writer.WriteInt32(item.Item4);
writer.WriteBytes(item.Item5);
writer.WriteInt32(Frames.Count);
}
writer.WriteInt32(Extensions.Count);
var startPosition = writer.Tell() + 4 * Frames.Count + 4;
//help
//how to implement write writer
@ -93,118 +237,75 @@ namespace NetMFAPatcher.mfa
MfaBuild = Reader.ReadInt32();
Product = Reader.ReadInt32();
BuildVersion = Reader.ReadInt32();
Console.WriteLine($"mfaBuild: {MfaBuild}, product: {Product}, buildVersion: {BuildVersion}");
LangId = Reader.ReadInt32();
Name = Helper.AutoReadUnicode(Reader);
Description = Helper.AutoReadUnicode(Reader);
Path = Helper.AutoReadUnicode(Reader);
Console.WriteLine($"\nMFAName: {Name}\nDescription: {Description}\nPath: {Path}");
Stamp = Reader.ReadBytes(Reader.ReadInt32());
if (Reader.ReadAscii(4) != "ATNF")
{
throw new Exception("Invalid Font Bank");
}
if (Reader.ReadAscii(4) != FontBankId) throw new Exception("Invalid Font Bank");
Fonts = new FontBank(Reader);
Fonts.Read();
Console.WriteLine("FONTS: " + Fonts.NumberOfItems);
if (Reader.ReadAscii(4) != "APMS")
{
throw new Exception("Invalid Sound Bank");
}
if (Reader.ReadAscii(4) != SoundBankId) throw new Exception("Invalid Sound Bank");
Sounds = new SoundBank(Reader);
Sounds.IsCompressed = false;
Sounds.Read();
if (Reader.ReadAscii(4) != "ASUM")
{
throw new Exception("Invalid Music Bank");
}
if (Reader.ReadAscii(4) != MusicBankId) throw new Exception("Invalid Music Bank");
Music = new MusicBank(Reader);
Music.Read();
if (Reader.ReadAscii(4) != "AGMI")
{
throw new Exception("Invalid Icon Bank");
}
var icons = new AgmiBank(Reader);
icons.Read();
if (Reader.ReadAscii(4) != "AGMI")
{
throw new Exception("Invalid Image Bank");
}
var images = new AgmiBank(Reader);
images.Read();
if (Helper.AutoReadUnicode(Reader) != Name) throw new Exception("Invalid name");
if (Reader.ReadAscii(4) != "AGMI") throw new Exception("Invalid Icon Bank");
Icons = new AgmiBank(Reader);
Icons.Read();
if (Reader.ReadAscii(4) != "AGMI") throw new Exception("Invalid Image Bank");
Images = new AgmiBank(Reader);
Images.Read();
Helper.CheckPattern(Helper.AutoReadUnicode(Reader),Name);
Author = Helper.AutoReadUnicode(Reader);
var newDesc = Helper.AutoReadUnicode(Reader);
if ( newDesc!= Description) throw new Exception("Invalid description: "+newDesc);
Helper.CheckPattern(Helper.AutoReadUnicode(Reader),Description);
Copyright = Helper.AutoReadUnicode(Reader);
Company = Helper.AutoReadUnicode(Reader);
Console.WriteLine("Company: "+Company);
Version = Helper.AutoReadUnicode(Reader);
Console.WriteLine("Version: " + Version);
WindowX = Reader.ReadInt32();
WindowY = Reader.ReadInt32();
Console.WriteLine($"Window:{WindowX}x{WindowY}");
var borderColor = Reader.ReadColor();
var displayFlags = Reader.ReadUInt32();
var graphicFlags = Reader.ReadUInt32();
var helpFile = Helper.AutoReadUnicode(Reader);
Console.WriteLine(Reader.Tell());
var vitalizePreview = Reader.ReadInt32();
var initialScore = Reader.ReadInt32();
var initialLifes = Reader.ReadInt32();
var frameRate = Reader.ReadInt32();
var buildType = Reader.ReadInt32();
var buildPath = Helper.AutoReadUnicode(Reader);
BorderColor = Reader.ReadColor();
DisplayFlags.flag = Reader.ReadUInt32();
GraphicFlags.flag = Reader.ReadUInt32();
HelpFile = Helper.AutoReadUnicode(Reader);
VitalizePreview = Reader.ReadInt32();
InitialScore = Reader.ReadInt32();
InitialLifes = Reader.ReadInt32();
FrameRate = Reader.ReadInt32();
BuildType = Reader.ReadInt32();
BuildPath = Helper.AutoReadUnicode(Reader);
//Console.WriteLine(BuildPath);
//Helper.CheckPattern(Reader.ReadInt32(),0);
Reader.ReadInt32();
var commandLine = Helper.AutoReadUnicode(Reader);
var aboutbox = Helper.AutoReadUnicode(Reader);
Console.WriteLine(aboutbox);
CommandLine = Helper.AutoReadUnicode(Reader);
Aboutbox = Helper.AutoReadUnicode(Reader);
Reader.ReadInt32();
var binCount = Reader.ReadInt32();//wtf i cant put it in loop fuck shit
for (int i = 0; i < binCount; i++)
{
Reader.ReadBytes(Reader.ReadInt32());//binaryfiles
}
var controls = new mmfparser.mfaloaders.Controls(Reader);
controls.Read();
Controls = new Controls(Reader);
Controls.Read();
var menuSize = Reader.ReadUInt32();
MenuSize = Reader.ReadUInt32();
var currentPosition = Reader.Tell();
var menu = new AppMenu(Reader);
menu.Read();
Reader.Seek(menuSize + currentPosition);
Menu = new AppMenu(Reader);
Menu.Read();
Reader.Seek(MenuSize + currentPosition);
var windowMenuIndex = Reader.ReadInt32();
int[] menuImages = new int[65535];//govnokod suka
windowMenuIndex = Reader.ReadInt32();
menuImages = new int[65535];//govnokod suka
var miCount = Reader.ReadInt32();
for (int i = 0; i < miCount; i++)
{
@ -219,33 +320,39 @@ namespace NetMFAPatcher.mfa
GlobalValues.Read();
GlobalStrings = new ValueList(Reader);
GlobalStrings.Read();
var globalEvents = Reader.ReadBytes(Reader.ReadInt32());
var graphicMode = Reader.ReadInt32();;
GlobalEvents = Reader.ReadBytes(Reader.ReadInt32());
GraphicMode = Reader.ReadInt32();;
var icoCount = Reader.ReadInt32();
for (int i = 0; i < icoCount; i++)
IcoCount = Reader.ReadInt32();
IconImages = new List<int>();
for (int i = 0; i < IcoCount; i++)
{
Reader.ReadInt32();
IconImages.Add(Reader.ReadInt32());
}
var qualCount = Reader.ReadInt32();
for (int i = 0; i < qualCount; i++)//qualifiers
//I STUCK HERE
QualCount = Reader.ReadInt32();
CustomQuals = new List<Tuple<string, int>>();
for (int i = 0; i < QualCount; i++)//qualifiers
{
var nameQ = Reader.ReadAscii(Reader.ReadInt32());
var handleQ = Reader.ReadInt32();
var name = Reader.ReadAscii(Reader.ReadInt32());
var handle = Reader.ReadInt32();
CustomQuals.Add(new Tuple<string,int>(name,handle));
}
var extCount = Reader.ReadInt32();
Extensions = new List<Tuple<int, string, string, int, byte[]>>();
for (int i = 0; i < extCount; i++)//extensions
{
var handleE = Reader.ReadInt32();
var filenameE = Helper.AutoReadUnicode(Reader);
var nameE = Helper.AutoReadUnicode(Reader);
var magicE = Reader.ReadInt32();
var subType = Reader.ReadBytes(Reader.ReadInt32());
var handle = Reader.ReadInt32();
var filename = Helper.AutoReadUnicode(Reader);
var name = Helper.AutoReadUnicode(Reader);
var magic = Reader.ReadInt32();
var data = Reader.ReadBytes(Reader.ReadInt32());
var tuple = new Tuple<int,string,string,int,byte[]>(handle,filename,name,magic,data);
Extensions.Add(tuple);
}
List<int> frameOffsets = new List<int>();
var offCount = Reader.ReadInt32();
@ -254,16 +361,17 @@ namespace NetMFAPatcher.mfa
frameOffsets.Add(Reader.ReadInt32());
}
var nextOffset = Reader.ReadInt32();
Frames = new List<Frame>();
foreach (var item in frameOffsets)
{
Reader.Seek(item);
var testframe = new Frame(Reader);
testframe.Read();
Frames.Add(testframe);
}
Reader.Seek(nextOffset);
var chunks = new ChunkList(Reader);
var chunks = new MFALoaders.ChunkList(Reader);
chunks.Read();
return;
@ -275,7 +383,7 @@ namespace NetMFAPatcher.mfa
}
public Mfa(ByteIO reader) : base(reader)
public MFA(ByteIO reader) : base(reader)
{
}

@ -1,5 +1,4 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -7,12 +6,13 @@ using System.Reflection.Emit;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.Data
{
public class PackData
{
public PackFile[] Items;
public List<PackFile> Items = new List<PackFile>();
public PackData()
{
@ -51,7 +51,13 @@ namespace NetMFAPatcher.MMFParser.Data
header = exeReader.ReadFourCc();
exeReader.Seek(offset);
for (int i = 0; i < count; i++) new PackFile().Read(exeReader);
for (int i = 0; i < count; i++)
{
var item = new PackFile();
item.Read(exeReader);
Items.Add(item);
}
Logger.Log("\nPackdata Done\n", true, ConsoleColor.Blue);
@ -60,24 +66,24 @@ namespace NetMFAPatcher.MMFParser.Data
}
public class PackFile
{
string _packFilename = "ERROR";
public string PackFilename = "ERROR";
int _bingo = 0;
byte[] _data;
public byte[] Data;
public void Read(ByteIO exeReader)
{
UInt16 len = exeReader.ReadUInt16();
_packFilename = exeReader.ReadWideString(len);
PackFilename = exeReader.ReadWideString(len);
_bingo = exeReader.ReadInt32();
_data = exeReader.ReadBytes(exeReader.ReadInt32());
Data = exeReader.ReadBytes(exeReader.ReadInt32());
Dump();
//Dump();
}
public void Dump()
public void Dump(string path = "[DEFAULT-PATH]")
{
Logger.Log($"Dumping {_packFilename}", true, ConsoleColor.DarkBlue);
string path = $"{Program.DumpPath}\\extensions\\" + _packFilename;
File.WriteAllBytes(path, _data);
Logger.Log($"Dumping {PackFilename}", true, ConsoleColor.DarkBlue);
var actualPath = path=="[DEFAULT-PATH]" ? ($"{Settings.ExtensionPath}\\{PackFilename}"):path;
File.WriteAllBytes(actualPath, Data);
}
}

@ -0,0 +1,37 @@
using System.IO;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.MMFParser.Decompiling
{
public static class MFAGenerator
{
public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\TestWriting.mfa";
public static void BuildMFA()
{
Settings.DoMFA = true;
var mfaReader = new ByteIO(TemplatePath, FileMode.Open);
var template = new MFA(mfaReader);
template.Read(); //Loading template
var gameMFA = Pame2Mfa.Translate(template, Exe.LatestInst.GameData); //Translation
var mfaWriter =
new ByteWriter(
Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Exe.LatestInst.GameData.Name}.mfa" : "out.mfa",
FileMode.Create); //New writer for new MFA
gameMFA.Write(mfaWriter); //Writing new MFA
}
public static void ReadTestMFA()
{
var mfaReader = new ByteIO(TemplatePath, FileMode.Open);
var template = new MFA(mfaReader);
template.Read();
var mfaWriter = new ByteWriter("outTest.mfa", FileMode.Create);
template.Write(mfaWriter);
}
}
}

@ -0,0 +1,68 @@

using NetMFAPatcher.MMFParser.Data;
namespace NetMFAPatcher.MMFParser.Decompiling
{
public static class Pame2Mfa
{
public static MFA Translate(MFA template, GameData game)
{
MFA mfa = template;
mfa.MfaBuild = 4;
mfa.Product = (int) game.ProductVersion;
mfa.BuildVersion = 283;
mfa.Name = game.Name;
mfa.Description = $"Decompiled with {Settings.DumperVersion}";
mfa.Path = game.EditorFilename;
//mfa.Stamp = wtf;
mfa.Fonts = game.Fonts;
mfa.Sounds = game.Sounds;
foreach (var item in mfa.Sounds.Items)
{
item.IsCompressed = false;
}
mfa.Music = game.Music;
mfa.Images.Items = game.Images.Images;
foreach (var key in mfa.Images.Items.Keys)
{
mfa.Images.Items[key].Debug = true;
}
mfa.Author = game.Author;
mfa.Copyright = game.Copyright;
mfa.Company = "CTFAN Team";
mfa.Version = "";
//TODO:Binary Files
var displaySettings = mfa.DisplayFlags;
var graphicSettings = mfa.GraphicFlags;
var flags = game.Header.Flags;
var newFlags = game.Header.NewFlags;
//TODO:Flags, no setter
mfa.WindowX = game.Header.WindowWidth;
mfa.WindowY = game.Header.WindowHeight;
mfa.BorderColor = game.Header.BorderColor;
mfa.HelpFile = "";
mfa.VitalizePreview = 0;
mfa.InitialScore = game.Header.InitialScore;
mfa.InitialLifes = game.Header.InitialLives;
mfa.FrameRate = game.Header.FrameRate;
mfa.BuildType = 0;
mfa.BuildPath = game.TargetFilename;
mfa.CommandLine = "";
mfa.Aboutbox = game.AboutText.Length > 0
? game.AboutText
: "This game was decompiled with " + Settings.DumperVersion;
return mfa;
}
}
}

@ -1,80 +1,61 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.IO;
using System.Collections;
using NetMFAPatcher.mfa;
using NetMFAPatcher.utils;
using System.Runtime.InteropServices;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.GUI;
using System.Windows.Forms;
using NetMFAPatcher.GUI;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.MMFParser.Decompiling;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher
{
class Program
internal class Program
{
//public static string path = @"H:\fnaf-world.exe";//test
//public static string path = @"D:\SteamLibrary\steamapps\common\Five Nights at Freddy's Sister Location\SisterLocation.exe";
public static string Path = ""; //TODO: Make Selectable
public static MainForm MyForm;
public static string GameName; // = Path.GetFileNameWithoutExtension(path);
public static string DumpPath; // = $"DUMP\\{GameName}";
public static bool DoMfa = false;
public static bool DumpImages = false;
public static bool DumpSounds = false;
public static bool Verbose;
public static bool LogAll = false;
public static bool UseGui = false;
[STAThread]
static void Main(string[] args)
private static void Main(string[] args)
{
string path = "";
bool verbose = false;
bool dumpImages = true;
bool dumpSounds = true;
var handle = Helper.GetConsoleWindow();
Helper.ShowWindow(handle, Helper.SW_HIDE);
//MFAGenerator.BuildMFA();
//Environment.Exit(0);
var path = "";
var verbose = false;
var dumpImages = false;
var dumpSounds = true;
if (args.Length == 0)
{
UseGui = true;
var form = new MainForm();
Application.Run(form);
Settings.UseGUI = true;
MyForm = new MainForm();
Application.Run(MyForm);
}
if (args.Length > 0)
{
path = args[0];
}
if (args.Length > 0) path = args[0];
if (args.Length > 1)
{
Boolean.TryParse(args[1], out verbose);
}
if (args.Length > 1) bool.TryParse(args[1], out verbose);
if (args.Length > 2)
{
Boolean.TryParse(args[2], out dumpImages);
}
if (args.Length > 2) bool.TryParse(args[2], out dumpImages);
if (args.Length > 3)
{
Boolean.TryParse(args[3], out dumpSounds);
}
if (args.Length > 3) bool.TryParse(args[3], out dumpSounds);
if (args.Length > 0 && (args[0] == "-h" || args[0] == "-help"))
{
Logger.Log($"DotNetCTFDumper: 0.0.5", true, ConsoleColor.Green);
Logger.Log($"Lauch Args:", true, ConsoleColor.Green);
Logger.Log($" Filename - path to your exe or mfa", true, ConsoleColor.Green);
Logger.Log($" Info - Dump debug info to console(default:true)", true, ConsoleColor.Green);
Logger.Log($" DumpImages - Dump images to 'DUMP\\[your game]\\ImageBank'(default:false)", true,
Logger.Log("DotNetCTFDumper: 0.0.5", true, ConsoleColor.Green);
Logger.Log("Lauch Args:", true, ConsoleColor.Green);
Logger.Log(" Filename - path to your exe or mfa", true, ConsoleColor.Green);
Logger.Log(" Info - Dump debug info to console(default:true)", true, ConsoleColor.Green);
Logger.Log(" DumpImages - Dump images to 'DUMP\\[your game]\\ImageBank'(default:false)", true,
ConsoleColor.Green);
Logger.Log($" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true,
Logger.Log(" DumpSounds - Dump sounds to 'DUMP\\[your game]\\SoundBank'(default:true)\n", true,
ConsoleColor.Green);
Logger.Log($"Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true,
Logger.Log("Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true,
ConsoleColor.Green);
Console.ReadKey();
Environment.Exit(0);
@ -85,38 +66,30 @@ namespace NetMFAPatcher
public static void ReadFile(string path, bool verbose = false, bool dumpImages = false, bool dumpSounds = true)
{
GameName = System.IO.Path.GetFileNameWithoutExtension(path);
DumpPath = $"DUMP\\{GameName}";
Settings.GamePath = path;
PrepareFolders();
DumpImages = dumpImages;
DumpSounds = dumpSounds;
Program.Verbose = verbose;
Settings.DumpImages = dumpImages;
Settings.DumpSounds = dumpSounds;
Settings.Verbose = verbose;
if (File.Exists(path))
{
if (path.EndsWith(".exe"))
{
DoMfa = false;
ByteIO exeReader = new ByteIO(path, FileMode.Open);
Exe currentExe = new Exe();
Settings.DoMFA = false;
var exeReader = new ByteIO(path, FileMode.OpenOrCreate);
var currentExe = new Exe();
currentExe.ParseExe(exeReader);
Logger.Log("Finished!", true, ConsoleColor.Yellow);
if (!UseGui) Console.ReadKey();
}
else if (path.EndsWith(".mfa"))
{
DoMfa = true;
Logger.Log("MFA reading is currently unstable");
Logger.Log("Are you sure?");
Console.ReadKey();
ByteIO mfaReader = new ByteIO(path, FileMode.Open);
var mfa = new Mfa(mfaReader);
mfa.Read();
Console.WriteLine("Writing");
var mfaWriter = new ByteWriter("out.mfa", FileMode.Create);
mfa.Write(mfaWriter);
Console.ReadKey();
Settings.DoMFA = true;
Logger.Log("Reading mfa");
Logger.Log("DEBUG ONLY");
MFAGenerator.ReadTestMFA();
}
else
{
@ -131,12 +104,12 @@ namespace NetMFAPatcher
public static void PrepareFolders()
{
Directory.CreateDirectory($"{DumpPath}\\CHUNKS\\OBJECTINFO");
Directory.CreateDirectory($"{DumpPath}\\CHUNKS\\FRAMES");
Directory.CreateDirectory($"{DumpPath}\\ImageBank");
Directory.CreateDirectory($"{DumpPath}\\MusicBank");
Directory.CreateDirectory($"{DumpPath}\\SoundBank");
Directory.CreateDirectory($"{DumpPath}\\extensions");
Directory.CreateDirectory($"{Settings.ImagePath}");
Directory.CreateDirectory($"{Settings.SoundPath}");
Directory.CreateDirectory($"{Settings.ChunkPath}");
Directory.CreateDirectory($"{Settings.ExtensionPath}");
}
}
}

@ -0,0 +1,40 @@
using System.IO;
using System.Runtime.Remoting.Messaging;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher
{
public static class Settings
{
public static bool DumpImages;
public static bool DumpSounds;
public static bool SaveChunks;
public static bool Verbose;
public static string GamePath;
public static string GameName => Path.GetFileNameWithoutExtension(GamePath);
public static string DumpPath => $"DUMP\\{GameName}";
public static string ImagePath=>$"{DumpPath}\\ImageBank";
public static string SoundPath=>$"{DumpPath}\\SoundBank";
public static string ChunkPath=>$"{DumpPath}\\Chunks";
public static string ExtensionPath=>$"{DumpPath}\\Extensions";
public static string AppName;
public static string Copyright;
public static string ProjectPath;
public static int Build;
public static bool DoMFA;
public static bool UseGUI;
public static string DumperVersion = "CTFAN 0.1.1 Debug";
public static byte[] EncryptionKey=>Decryption.DecryptionKey;
}
}

@ -1,10 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace NetMFAPatcher.utils
namespace NetMFAPatcher.Utils
{
public class BitDict
{
@ -34,7 +32,7 @@ namespace NetMFAPatcher.utils
public static string ToDebugString<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
{
return "{" + string.Join(",", dictionary.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}";
return string.Join(";", dictionary.Select(kv => kv.Key + "=" + kv.Value).ToArray());
}
public override string ToString()

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.utils
namespace NetMFAPatcher.Utils
{
public static class ByteFlag
{

@ -1,7 +1,7 @@
using System;
using System.Text;
using System.IO;
using System.Drawing;
using System.IO;
using System.Text;
namespace NetMFAPatcher.Utils
{
@ -130,9 +130,8 @@ namespace NetMFAPatcher.Utils
var g = ReadByte();
var b = ReadByte();
Skip(1);
Color color = Color.FromArgb(b, g, r);
return color;
return Color.FromArgb(r, g, b);
}

@ -1,7 +1,7 @@
using System;
using System.Text;
using System.IO;
using System.Drawing;
using System.IO;
using System.Text;
namespace NetMFAPatcher.Utils
{
@ -88,6 +88,16 @@ namespace NetMFAPatcher.Utils
}
}
public void WriteColor(Color color)
{
WriteInt8(color.R);
WriteInt8(color.G);
WriteInt8(color.B);
Skip(1);
}

@ -1,24 +1,27 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace NetMFAPatcher.Utils
{
public static class Decompressor
{
public static byte[] Decompress(ByteIO exeReader)
public static byte[] Decompress(ByteIO exeReader, out int decompressed)
{
Int32 decompSize = exeReader.ReadInt32();
Int32 compSize = exeReader.ReadInt32();
decompressed = decompSize;
return decompress_block(exeReader, compSize, decompSize);
}
public static ByteIO DecompressAsReader(ByteIO exeReader)
public static ByteIO DecompressAsReader(ByteIO exeReader, out int decompressed)
{
Int32 decompSize = exeReader.ReadInt32();
Int32 compSize = exeReader.ReadInt32();
byte[] compressedData = exeReader.ReadBytes(compSize);
byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
Debug.Assert(actualData.Length == decompSize);
decompressed = decompSize;
return new ByteIO(actualData);
}
@ -34,9 +37,6 @@ namespace NetMFAPatcher.Utils
return new ByteIO(decompress_block(imageData, v, decompressedSize));
}
internal static byte[] decompress_block(ByteIO data, uint compressedSize, uint decompressedSize)
{
throw new NotImplementedException();
}
}
}

@ -1,25 +1,24 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Management.Instrumentation;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.utils
namespace NetMFAPatcher.Utils
{
class Decryption
{
public static byte[] DecryptionKey;
public static byte MagicChar=54;
public static void MakeKey(string sTitle, string sCopyright,string sProject)
public static byte MagicChar = 54;
public static void MakeKey(string sTitle, string sCopyright, string sProject)
{
var rawKey = "";
rawKey += sTitle;
rawKey += sCopyright;
rawKey += sProject;
Logger.Log("Combined data "+rawKey,true,ConsoleColor.Yellow);
Logger.Log("Combined data " + rawKey, true, ConsoleColor.Yellow);
var rawKeyPtr = Marshal.StringToHGlobalAnsi(rawKey);
var ptr = Decryption.make_key_combined(rawKeyPtr, MagicChar);
@ -29,27 +28,47 @@ namespace NetMFAPatcher.utils
Marshal.FreeHGlobal(rawKeyPtr);
DecryptionKey = key;
Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}",true,ConsoleColor.Yellow);
File.WriteAllBytes($"{Program.DumpPath}\\key.bin", DecryptionKey);
Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}", true, ConsoleColor.Yellow);
File.WriteAllBytes($"{Settings.DumpPath}\\key.bin", DecryptionKey);
}
public static byte[] MakeKeyFromBytes(string data, byte magicChar = 54)
{
var rawKeyPtr = Marshal.StringToHGlobalAnsi(data);
//var bytes = Encoding.UTF8.GetBytes(data);
//var rawKeyPtr = Marshal.AllocHGlobal(bytes.Length);
//Marshal.Copy(bytes,0,rawKeyPtr,bytes.Length);
var ptr = Decryption.make_key_combined(rawKeyPtr, magicChar);
byte[] key = new byte[256];
Marshal.Copy(ptr, key, 0, 256);
Marshal.FreeHGlobal(rawKeyPtr);
return key;
}
public static byte[] DecodeMode3(byte[] chunkData, int chunkSize,int chunkId)
public static byte[] DecodeMode3(byte[] chunkData, int chunkSize, int chunkId, out int decompressed)
{
var reader = new ByteIO(chunkData);
var decompressedSize = reader.ReadUInt32();
var rawData = reader.ReadBytes((int)reader.Size());
var rawData = reader.ReadBytes((int) reader.Size());
if (chunkId % 2 != 0)
{
rawData[0] ^= (byte)(((byte)chunkId & 0xFF) ^ ((byte)chunkId >> 0x8));
rawData[0] ^= (byte) (((byte) chunkId & 0xFF) ^ ((byte) chunkId >> 0x8));
}
rawData = DecodeChunk(rawData, chunkSize);
var data = new ByteIO(rawData);
using (var data = new ByteIO(rawData))
{
var compressedSize = data.ReadUInt32();
return Decompressor.decompress_block(data, (int)compressedSize, (int)decompressedSize);
decompressed = (int) decompressedSize;
return Decompressor.decompress_block(data, (int) compressedSize, (int) decompressedSize);
}
}
public static byte[] DecodeChunk(byte[] chunkData, int chunkSize)
{
IntPtr inputChunkPtr = Marshal.AllocHGlobal(chunkData.Length);
@ -61,7 +80,7 @@ namespace NetMFAPatcher.utils
var outputChunkPtr = decode_chunk(inputChunkPtr, chunkSize, MagicChar, keyPtr);
byte[] decodedChunk = new byte[chunkSize];
Marshal.Copy(outputChunkPtr, decodedChunk,0,chunkSize);
Marshal.Copy(outputChunkPtr, decodedChunk, 0, chunkSize);
Marshal.FreeHGlobal(inputChunkPtr);
Marshal.FreeHGlobal(keyPtr);
@ -72,10 +91,22 @@ namespace NetMFAPatcher.utils
[DllImport("Decrypter-x64.dll", EntryPoint = "decode_chunk", CharSet = CharSet.Auto)]
public static extern IntPtr decode_chunk(IntPtr chunkData, int chunkSize, byte magicChar,IntPtr wrapperKey);
public static extern IntPtr decode_chunk(IntPtr chunkData, int chunkSize, byte magicChar, IntPtr wrapperKey);
[DllImport("Decrypter-x64.dll", EntryPoint = "make_key", CharSet = CharSet.Auto)]
public static extern IntPtr make_key(IntPtr cTitle, IntPtr cCopyright, IntPtr cProject, byte magicChar);
[DllImport("Decrypter-x64.dll", EntryPoint = "make_key_combined", CharSet = CharSet.Auto)]
public static extern IntPtr make_key_combined(IntPtr data, byte magicChar);
[DllImport("Decrypter-x64.dll", EntryPoint = "make_key_w_combined", CharSet = CharSet.Auto)]
public static extern IntPtr make_key_w_combined(IntPtr data, byte magicChar);
}
}

@ -1,12 +1,17 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using mmfparser;
using NetMFAPatcher.GUI;
using NetMFAPatcher.MMFParser;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
using NetMFAPatcher.MMFParser.ChunkLoaders.Objects;
using NetMFAPatcher.MMFParser.Data;
namespace NetMFAPatcher.utils
namespace NetMFAPatcher.Utils
{
static class Helper
{
@ -94,6 +99,7 @@ namespace NetMFAPatcher.utils
}
return temp;
}
public static void PrintHex(this byte[] data)
{
var blockSize = 16;
@ -114,6 +120,18 @@ namespace NetMFAPatcher.utils
}
public static byte[] GetContents(this ByteWriter wrt)
{
var buff = new byte[wrt.BaseStream.Length];
for (int i = 0; i < wrt.BaseStream.Length; i++)
{
buff.Append<byte>((byte)wrt.BaseStream.ReadByte());
}
return buff;
}
/// <summary>
/// Splits an array into several smaller arrays.
/// </summary>
@ -129,6 +147,123 @@ namespace NetMFAPatcher.utils
}
}
public static List<Color> GetColors(this byte[] bytes)
{
List<Color> colors = new List<Color>();
for (int i = 0; i < bytes.Length; i+=4)
{
var color = Color.FromArgb(bytes[i], bytes[i + 1], bytes[i + 2], bytes[i + 3]);
colors.Add(color);
}
return colors;
}
public static void CheckPattern(object source, object pattern)
{
if (source.GetType() != pattern.GetType()) throw new InvalidDataException("Data is not valid: types are different");
if (source is string)
{
if ((string)source != (string)pattern)
{
throw new InvalidDataException($"Data is not valid: {source} != {pattern}");
}
}
else
{
if (source != pattern)
{
throw new InvalidDataException($"Data is not valid: {source} != {pattern}");
}
}
}
public static void OnImageSaved(int index,int all)
{
Program.MyForm.UpdateImageBar(index,all);
}
public static void OnSoundSaved(int index,int all)
{
Program.MyForm.UpdateSoundBar(index,all);
}
private const long OneKb = 1024;
private const long OneMb = OneKb * 1024;
private const long OneGb = OneMb * 1024;
private const long OneTb = OneGb * 1024;
public static string ToPrettySize(this int value, int decimalPlaces = 0)
{
return ((long)value).ToPrettySize(decimalPlaces);
}
public static string ToPrettySize(this long value, int decimalPlaces = 0)
{
var asTb = Math.Round((double)value / OneTb, decimalPlaces);
var asGb = Math.Round((double)value / OneGb, decimalPlaces);
var asMb = Math.Round((double)value / OneMb, decimalPlaces);
var asKb = Math.Round((double)value / OneKb, decimalPlaces);
string chosenValue = asTb > 1 ? string.Format("{0} TB",asTb)
: asGb > 1 ? string.Format("{0} GB",asGb)
: asMb > 1 ? string.Format("{0} MB",asMb)
: asKb > 1 ? string.Format("{0} KB",asKb)
: string.Format("{0} B", Math.Round((double)value, decimalPlaces));
return chosenValue;
}
public static string ActualName(this ChunkList.Chunk chunk)
{
var constName = ((Constants.ChunkNames)chunk.Id).ToString();
int tempId = 0;
int.TryParse(constName,out tempId);
if (tempId != chunk.Id) return constName;
else return $"Unknown-{chunk.Id}";
}
public static ChunkNode GetChunkNode(ChunkList.Chunk chunk,string customName = "[DEFAULT-NAME]")
{
ChunkNode node = null;
if (chunk.Loader != null)
{
node = new ChunkNode(chunk.Name,chunk.Loader);
}
else
{
node = new ChunkNode(chunk.Name,chunk);
}
if (customName != "[DEFAULT-NAME]")
{
node.Text = customName;
}
return node;
}
public static Animation GetClosestAnimation(int index, Dictionary<int,Animation> animDict,int count)
{
try
{
return animDict[index];
}
catch {}
return null;
}
[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public const int SW_HIDE = 0;
public const int SW_SHOW = 5;
}
}

@ -0,0 +1,55 @@
using System.Drawing;
using System.IO;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Objects;
using NetMFAPatcher.MMFParser.Data;
namespace NetMFAPatcher.Utils
{
public class ImageDumper
{
public static void DumpImages()
{
Dump();
}
public static void Dump()
{
var rootFolder = $"{Settings.DumpPath}\\ImageBank\\Sorted";
var Bank = Exe.LatestInst.GameData.GameChunks.get_chunk<ImageBank>();
foreach (var frame in Exe.LatestInst.GameData.Frames)
{
if (frame.Objects != null)
{
var currentFramePath = rootFolder + "\\" + frame.Name;
Directory.CreateDirectory(currentFramePath);
foreach (var item in frame.Objects.Items)
{
var currentObjPath = currentFramePath + "\\" + item.Handle;
Directory.CreateDirectory(currentObjPath);
var anims = (item.FrameItem.Properties).Loader.Animations.AnimationDict;
foreach (var key in anims.Keys)
{
var anim = anims[key];
var directions = anim.DirectionDict;
foreach (var key1 in directions.Keys)
{
var dir = directions[0];
foreach (var AnimFrame in dir.Frames)
{
ImageItem img = null;
Bank.Images.TryGetValue(AnimFrame, out img);
img.Save(currentObjPath+"\\"+AnimFrame+".png");
}
}
}
}
}
}
}
}
}

@ -1,13 +1,6 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
namespace NetMFAPatcher.utils
using System;
namespace NetMFAPatcher.Utils
{
public static class ImageHelper
{
@ -38,20 +31,23 @@ namespace NetMFAPatcher.utils
{
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
int pad = GetPadding(width, 2);
int position = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
UInt16 newShort = (ushort) (data[position] | data[position + 1] << 8);
byte r = (byte) ((newShort & 31744) >> 10);
byte g = (byte) ((newShort & 992) >> 5);
byte r = (byte) ((newShort & 63488) >> 11);
byte g = (byte) ((newShort & 2016) >> 5);
byte b = (byte) ((newShort & 31));
colorArray[(y * stride) + (x * 4) + 0] = (byte) (r << 3);
colorArray[(y * stride) + (x * 4) + 1] = (byte) (g << 2);
colorArray[(y * stride) + (x * 4) + 2] = (byte) (b << 3);
r=(byte) (r << 3);
g=(byte) (g << 2);
b=(byte) (b << 3);
colorArray[(y * stride) + (x * 4) + 2] = r;
colorArray[(y * stride) + (x * 4) + 1] = g;
colorArray[(y * stride) + (x * 4) + 0] = b;
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 2;
}
@ -66,7 +62,7 @@ namespace NetMFAPatcher.utils
{
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
int pad = GetPadding(width, 2);
int position = 0;
for (int y = 0; y < height; y++)
{

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.Utils
{

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.mmfparser
namespace NetMFAPatcher.MMFParser
{
public static class Constants
{
@ -13,10 +13,10 @@ namespace NetMFAPatcher.mmfparser
public static bool IsUnicode;
public enum Products
{
Mmf1=1,
Mmf15=2,
Mmf2=3,
Cnc1=0
MMF1=1,
MMF15=2,
MMF2=3,
CNC1=0
}
public enum ValueType
@ -47,7 +47,7 @@ namespace NetMFAPatcher.mmfparser
Rtf=8,
SubApplication=9,
Ini=33,
IniPp=32,
Extension=32,
File=34,
TextEntry=35

@ -1,12 +1,12 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -19,13 +19,55 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public int InitialScore;
public int InitialLives;
public int NumberOfFrames;
public BitDict Flags = new BitDict(new string[]
{
"BorderMax",
"NoHeading",
"Panic",
"SpeedIndependent",
"Stretch",
"MusicOn",
"SoundOn",
"MenuHidden",
"MenuBar",
"Maximize",
"MultiSamples",
"FullscreenAtStart",
"FullscreenSwitch",
"Protected",
"Copyright",
"OneFile"
});
public BitDict NewFlags = new BitDict(new string[]
{
"SamplesOverFrames",
"RelocFiles",
"RunFrame",
"SamplesWhenNotFocused",
"NoMinimizeBox",
"NoMaximizeBox",
"NoThiccFrame",
"DoNotCenterFrame",
"ScreensaverAutostop",
"DisableClose",
"HiddenAtStart",
"XPVisualThemes",
"VSync",
"RunWhenMinimized",
"MDI",
"RunWhileResizing"
});
public Color BorderColor;
public int FrameRate;
public override void Read()
{
Reader = new ByteIO(Chunk.ChunkData);
Size = Reader.ReadInt32();
var flags = Reader.ReadInt16(); //raw,need convert
Flags.flag=(uint) Reader.ReadInt16();//I finally got my balls back
var newFlags = Reader.ReadInt16(); //read flags or no balls
var graphicsMode = Reader.ReadInt16(); //i am serious
var otherflags = Reader.ReadInt16(); //last chance to get balls back
@ -37,9 +79,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
controls.Read();
// controls.Print(false);
var borderColor = Reader.ReadBytes(4);
BorderColor = Reader.ReadColor();
NumberOfFrames = Reader.ReadInt32();
var frameRate = Reader.ReadInt32();
FrameRate = Reader.ReadInt32();
var windowsMenuIndex = Reader.ReadSByte();
}
@ -51,6 +93,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
Logger.Log("");
}
public override string[] GetReadableData()
{
return new string[]
{
$"Screen Resolution: {WindowWidth}x{WindowHeight}",
$"Initial Score: {InitialScore}",
$"Initial Lives: {InitialLives}",
$"Flags:;{Flags.ToString()}"
};
}
public AppHeader(ByteIO reader) : base(reader)
{
@ -92,6 +145,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
item.Print();
}
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
}
public class PlayerControl

@ -1,11 +1,10 @@
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -13,6 +12,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public class AppMenu : ChunkLoader
{
public List<AppMenuItem> Items = new List<AppMenuItem>();
public List<byte> AccelShift;
public List<short> AccelKey;
public List<short> AccelId;
public AppMenu(ByteIO reader) : base(reader)
{
}
@ -25,6 +28,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var currentPosition = Reader.Tell();
@ -37,35 +45,38 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
Reader.Seek(currentPosition + menuOffset);
Reader.Skip(4);
Load();
Load(Reader);
Reader.Seek(currentPosition + accelOffset);
for (int i = 0; i < accelSize/8; i++)
{
Reader.ReadByte();
AccelShift = new List<byte>();
AccelKey = new List<short>();
AccelId = new List<short>();
AccelShift.Add(Reader.ReadByte());;
Reader.Skip(1);
Reader.ReadInt16();
Reader.ReadInt16();
AccelKey.Add(Reader.ReadInt16());
AccelId.Add(Reader.ReadInt16());
Reader.Skip(2);
}
}
public void Load()
public void Load(ByteIO reader)
{
while(true)
{
var newItem = new AppMenuItem(Reader);
var newItem = new AppMenuItem(reader);
newItem.Read();
Items.Add(newItem);
if (newItem.Name.Contains("About")) break;
if (true)//ByteFlag.getFlag(new_item.flags,4))
if (ByteFlag.GetFlag((uint) newItem.Flags,4))
{
Load();
Load(reader);
}
if (true)//ByteFlag.getFlag(new_item.flags, 7))
if (ByteFlag.GetFlag((uint) newItem.Flags, 7))
{
break;
@ -95,6 +106,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
uint flags = (uint) Reader.ReadInt16();

@ -24,5 +24,6 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public abstract void Print(bool ext);
public abstract string[] GetReadableData();
}
}

@ -1,13 +1,16 @@
using NetMFAPatcher.mmfparser;

using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.MMFParser.MFALoaders;
using NetMFAPatcher.Utils;
using ChunkList = NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
@ -46,6 +49,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
int _bottom;
int _left;
int _right;
public ChunkList Chunks;
public FrameHeader Header;
public ObjectInstances Objects;
public override void Print(bool ext)
@ -57,33 +63,44 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
Logger.Log($"-------------------------", true, ConsoleColor.Green);
}
public override string[] GetReadableData()
{
return new string[]
{
$"Name: {Name}",
$"Size: {Width}x{Height}",
$"Objects: {CountOfObjs}"
};
}
public override void Read()
{
var frameReader = new ByteIO(Chunk.ChunkData);
var chunks = new ChunkList();
Chunks = new ChunkList();
chunks.Verbose = false;
chunks.Read(frameReader);
Chunks.Verbose = false;
Chunks.Read(frameReader);
var name = chunks.get_chunk<FrameName>();
var name = Chunks.get_chunk<FrameName>();
if (name != null) //Just to be sure
{
this.Name = name.Value;
}
var password = chunks.get_chunk<FramePassword>();
var password = Chunks.get_chunk<FramePassword>();
if (password != null) //Just to be sure
{
this.Password = password.Value;
}
var header = chunks.get_chunk<FrameHeader>();
Width = header.Width;
Height = header.Height;
Background = header.Background;
Flags = header.Flags;
var objects = chunks.get_chunk<ObjectInstances>();
if(objects!=null)
Header = Chunks.get_chunk<FrameHeader>();
Width = Header.Width;
Height = Header.Height;
Background = Header.Background;
//Flags = header.Flags;
Objects = Chunks.get_chunk<ObjectInstances>();
if(Objects!=null)
{
CountOfObjs = objects.CountOfObjects;
CountOfObjs = Objects.CountOfObjects;
}
@ -91,7 +108,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
foreach (var item in chunks.Chunks)
foreach (var item in Chunks.Chunks)
{
//Directory.CreateDirectory($"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}");
//string path = $"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}\\{chunk.name}.chunk";
@ -113,11 +131,24 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
}
class FrameHeader : ChunkLoader
public class FrameHeader : ChunkLoader
{
public int Width;
public int Height;
public int Flags;
public BitDict Flags = new BitDict(new string[]
{
"XCoefficient",
"YCoefficient",
"DoNotSaveBackground",
"Wrap",
"Visible",
"WrapHorizontally",
"WrapVertically","","","","","","","","","",
"Redraw",
"ToHide",
"ToShow"
});
public byte[] Background;
public FrameHeader(ByteIO reader) : base(reader)
{
@ -132,22 +163,33 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
return new string[]
{
$"Size: {Width}x{Height}",
$"Flags:;{Flags.ToString()}"
};
}
public override void Read()
{
Width = Reader.ReadInt32();
Height = Reader.ReadInt32();
Background = Reader.ReadBytes(4);
Flags = (int)Reader.ReadUInt32();
Flags.flag = Reader.ReadUInt32();
}
}
class ObjectInstances : ChunkLoader
public class ObjectInstances : ChunkLoader
{
public int CountOfObjects=0;
public List<ObjectInstances> Items = new List<ObjectInstances>();
public List<ObjectInstance> Items = new List<ObjectInstance>();
public ObjectInstances(ByteIO reader) : base(reader)
{
@ -162,21 +204,115 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
return new string[]
{
$"Number of objects: {CountOfObjects}"
};
}
public override void Read()
{
CountOfObjects = (int)Reader.ReadUInt32();
return;
for (int i = 0; i < CountOfObjects; i++)
{
var item = new ObjectInstances(Reader);
var item = new ObjectInstance(Reader);
item.Read();
Items.Add(item);
}
Reader.Skip(4);
}
}
public class ObjectInstance : ChunkLoader
{
public ushort Handle;
public ushort ObjectInfo;
public int X;
public int Y;
public short ParentType;
public short Layer;
public string Name;
public short ParentHandle;
public ObjectInstance(ByteIO reader) : base(reader)
{
}
public ObjectInstance(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Handle = Reader.ReadUInt16();
//if (Handle > 0) Handle -= 1;
ObjectInfo = Reader.ReadUInt16();
X = Reader.ReadInt32();
Y = Reader.ReadInt32();
ParentType = Reader.ReadInt16();
ParentHandle = Reader.ReadInt16();
Layer = Reader.ReadInt16();
Reader.Skip(2);
//-------------------------
if (FrameItem != null) Name = FrameItem.Name;
else Name = $"UNKNOWN-{Handle}";
Console.WriteLine("ObjectInfoHandle: "+Handle);
}
public ObjectInfo FrameItem
{
get
{
return Exe.LatestInst.GameData.GameChunks.get_chunk<FrameItems>().GetItemByHandle(Handle);
}
}
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
return new string[]
{
$"Name: {Name}",
$"Type:{(Constants.ObjectType)FrameItem.ObjectType} - {FrameItem.ObjectType}",
$"Position: {X,5}x{Y,5}",
$"Size: CUMxCUM"
};
}
}
class Layer : ChunkLoader
{
public Layer(ByteIO reader) : base(reader)
{
}
public Layer(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
}
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
}

@ -1,11 +1,12 @@
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.MFALoaders;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -14,6 +15,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public Dictionary<int, ObjectInfo> ItemDict = new Dictionary<int, ObjectInfo>();
public List<string> Names = new List<string>();
public int NumberOfItems;
public FrameItems(Chunk chunk) : base(chunk) { }
public FrameItems(ByteIO reader) : base(reader) { }
public override void Print(bool ext)
@ -21,21 +23,35 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public override string[] GetReadableData()
{
return new string[]
{
$"Number of items: {NumberOfItems}"
};
}
public override void Read()
{
var count = Reader.ReadInt32();
NumberOfItems = Reader.ReadInt32();
for (int i = 0; i < count; i++)
for (int i = 0; i < NumberOfItems; i++)
{
var item = new ObjectInfo(Reader);
item.Verbose = false;
item.Read();
ItemDict.Add(item.Handle, item);
Names.Add(item.Name);
//Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
Logger.Log($"Found FrameItem: '{item.Name}' with handle ({item.Handle})", true, ConsoleColor.Magenta);
}
GameData.TestItems = this;
}
public ObjectInfo GetItemByHandle(int handle)
{
ItemDict.TryGetValue(handle, out var ret);
return ret;
}
}
}

@ -1,9 +1,9 @@
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System.Collections.Generic;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Objects;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -11,7 +11,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public class ObjectInfo : ChunkLoader
{
public List<Chunk> Chunks = new List<Chunk>();
public int Properties = 0;
//public int Properties = 0;
public string Name = "ERROR";
public int Handle;
public int ObjectType;
@ -22,6 +22,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public int InkEffectValue;
public int ShaderId;
public int Items;
public ObjectProperties Properties;
public ObjectInfo(Chunk chunk) : base(chunk)
{
@ -35,6 +36,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
var infoChunks = new ChunkList();
@ -43,15 +49,23 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
foreach (var infoChunk in infoChunks.Chunks)
{
infoChunk.Verbose = false;
var loader = infoChunk.Loader;
if (loader != null)
{
Console.WriteLine($"Reading {loader.GetType().Name}");
}
if (loader is ObjectName)
{
var actualLoader = infoChunks.get_loader<ObjectName>(loader);
Name = actualLoader.Value;
}
else if (loader is ObjectHeader)
{
var actualLoader = infoChunks.get_loader<ObjectHeader>(loader);
Handle = actualLoader.Handle;
ObjectType = actualLoader.ObjectType;
@ -60,11 +74,22 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
Transparent = ByteFlag.GetFlag(inkEffect, 28);
Antialias = ByteFlag.GetFlag(inkEffect, 29);
}
else if (loader is ObjectProperties)
{
Properties = (ObjectProperties)loader;
}
}
if (Properties != null)
{
//Properties.ReadNew(ObjectType);
}
}
}
class ObjectName : StringChunk
public class ObjectName : StringChunk
{
public ObjectName(ByteIO reader) : base(reader)
{
@ -75,7 +100,50 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
}
class ObjectHeader : ChunkLoader
public class ObjectProperties : ChunkLoader
{
public bool IsCommon;
public ObjectCommon Loader;
public ObjectProperties(ByteIO reader) : base(reader)
{
}
public ObjectProperties(Chunk chunk) : base(chunk)
{
}
public void ReadNew(int ObjectType)
{
Reader.Seek(0);
//var objType = 2;//THIS IS SHITCODE
IsCommon = true;//ITS NOT DONE
if (ObjectType == 2)
{
Loader = new ObjectCommon(Reader);
Loader.Read();
}
}
public override void Read()
{
}
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
}
public class ObjectHeader : ChunkLoader
{
public Int16 Handle;
public Int16 ObjectType;
@ -95,6 +163,12 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
}
public override string[] GetReadableData()
{
return null;
}
public override void Read()
{
Handle = Reader.ReadInt16();

@ -1,16 +1,16 @@
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
class StringChunk : ChunkLoader
public class StringChunk : ChunkLoader
{
public string Value;
@ -26,6 +26,15 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
Logger.Log($"{Chunk.Name} contains: {Value}\n",true,ConsoleColor.DarkCyan);
}
public override string[] GetReadableData()
{
return new string[]
{
$"Value: {Value}"
};
}
public StringChunk(ByteIO reader) : base(reader)
{

@ -1,7 +1,7 @@
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
public class FontBank : ChunkLoader
{
@ -11,6 +11,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
Logger.Log($"FontCount:{NumberOfItems.ToString()}");
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
public override void Read()
{
NumberOfItems = Reader.ReadInt32();

@ -1,21 +1,23 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using NetMFAPatcher.GUI;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
public class ImageBank : ChunkLoader
{
Dictionary<int, ImageItem> _images = new Dictionary<int, ImageItem>();
public Dictionary<int, ImageItem> Images = new Dictionary<int, ImageItem>();
public uint NumberOfItems;
public ImageBank(ByteIO reader) : base(reader)
{
@ -29,18 +31,41 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
}
public override string[] GetReadableData()
{
return new string[]
{
$"Number of images: {NumberOfItems}"
};
}
public override void Read()
{
Reader = new ByteIO(Chunk.ChunkData);
var numberOfItems = Reader.ReadUInt32();
Console.WriteLine(@"Found {numberOfItems} images");
for (int i = 0; i < numberOfItems; i++)
Reader.Seek(0);//Reset the reader to avoid bugs when dumping more than once
NumberOfItems = Reader.ReadUInt32();
Console.WriteLine($"Found {NumberOfItems} images");
if (!Settings.DumpImages) return;
for (int i = 0; i < NumberOfItems; i++)
{
if (MainForm.BreakImages)
{
MainForm.BreakImages = false;
break;
}
var item = new ImageItem(Reader);
item.Read();
if (Program.DumpImages)
item.Save($"{Program.DumpPath}\\ImageBank\\" + item.Handle.ToString() + ".png");
Images.Add(item.Handle,item);
if (Settings.DumpImages)
{
item.Save($"{Settings.ImagePath}\\" + item.Handle.ToString() + ".png");
Console.ReadKey();
Helper.OnImageSaved(i,(int) NumberOfItems);
}
if (Exe.LatestInst.GameData.ProductBuild >= 284)
item.Handle -= 1;
@ -82,8 +107,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
byte[] _colorArray;
int _indexed;
public byte[] rawImg;
public bool IsCompressed = true;
public bool Debug = false;
public int Debug2 = 1;
public override void Read()
{
@ -92,25 +120,30 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
Load();
}
public void Load()
{
Reader.Seek(Position);
ByteIO imageReader;
if (IsCompressed)
public override void Print(bool ext)
{
imageReader = Decompressor.DecompressAsReader(Reader);
}
else
public override string[] GetReadableData()
{
imageReader = Reader;
throw new NotImplementedException();
}
public void Load()
{
Reader.Seek(Position);
ByteIO imageReader;
imageReader = Debug ? Reader : Decompressor.DecompressAsReader(Reader, out var a);
long start = imageReader.Tell();
_checksum = imageReader.ReadInt32();
_references = imageReader.ReadInt32();
Size = (int) imageReader.ReadUInt32();
if (!IsCompressed)
if (Debug)
{
imageReader = new ByteIO(imageReader.ReadBytes(Size + 20));
}
@ -126,24 +159,45 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
_actionX = imageReader.ReadInt16();
_actionY = imageReader.ReadInt16();
_transparent = imageReader.ReadBytes(4);
Logger.Log($"{Handle.ToString(),4} Size: {_width,4}x{_height,4}, flags: {Flags}");
byte[] imageData;
Logger.Log($"Loading image {Handle.ToString(),4} Size: {_width,4}x{_height,4}");
byte[] imageData = new byte[1];
if (Debug2 == 1)
{
var imgLen = imageReader.Size() - imageReader.Tell();
var data = imageReader.ReadBytes((int) imgLen);
imageReader.BaseStream.Position -= imgLen;
File.WriteAllBytes("CumImage.bin", Ionic.Zlib.DeflateStream.CompressBuffer(data));
}
if (Debug2 == 2)
{
imageData = File.ReadAllBytes("CumImage.bin");
}
if (Flags["LZX"])
{
throw new NotImplementedException();
imageData = new byte[1];
var DecompressedSize = imageReader.ReadUInt32();
imageData = Decompressor.decompress_block(imageReader, (int) (imageReader.Size() - imageReader.Tell()),
(int) DecompressedSize);
}
else
{
imageData = imageReader.ReadBytes((int) (imageReader.Size() - imageReader.Tell()));
}
int bytesRead = 0;
rawImg = imageData;
if (Flags["RLE"] || Flags["RLEW"] || Flags["RLET"])
{
}
else
{
switch (_graphicMode)
{
case 4:
@ -200,11 +254,45 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
}
}
public override void Print(bool ext)
public void Write(ByteWriter writer)
{
writer.WriteInt32(_checksum);
writer.WriteInt32(_references);
writer.WriteInt32(_colorArray.Length);
writer.WriteInt16((short) _width);
writer.WriteInt16((short) _height);
writer.WriteInt8(4);
if (Flags["Alpha"])
{
writer.WriteInt8(16);
}
else
{
writer.WriteInt8(0);
}
writer.Skip(2);
writer.WriteInt16((short) _xHotspot);
writer.WriteInt16((short) _yHotspot);
writer.WriteInt16((short) _actionX);
writer.WriteInt16((short) _actionY);
writer.WriteBytes(_transparent);
writer.Skip(1);
writer.WriteBytes(rawImg);
}
public ImageItem(ByteIO reader) : base(reader)
{
}

@ -1,8 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
public class MusicBank : ChunkLoader
{
@ -14,11 +15,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
//Someone is using this lol?
Items = new List<MusicFile>();
NumOfItems = Reader.ReadInt32();
Console.WriteLine(NumOfItems);
for (int i = 0; i < NumOfItems; i++)
{
var item = new MusicFile(Reader);
@ -46,6 +53,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
}

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using NetMFAPatcher.utils;
using NetMFAPatcher.GUI;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
public class SoundBank : ChunkLoader
{
@ -18,19 +18,39 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
}
public override string[] GetReadableData()
{
return new string[]
{
$"Number of sounds: {NumOfItems}"
};
}
public override void Read()
{
//Implementing for standalone-only because of my lazyness
if(!Settings.DoMFA) Reader.Seek(0);//Reset the reader to avoid bugs when dumping more than once
Items = new List<SoundItem>();
NumOfItems = Reader.ReadInt32();
Logger.Log("Found " + NumOfItems + " sounds");
if (!Settings.DumpSounds&&!Settings.DoMFA) return;
for (int i = 0; i < NumOfItems; i++)
{
if (MainForm.BreakSounds)
{
MainForm.BreakSounds = false;
break;
}
var item = new SoundItem(Reader);
item.IsCompressed = IsCompressed;
item.Read();
Helper.OnSoundSaved(i, NumOfItems);
Items.Add(item);
}
}
public void Write(ByteWriter writer)
@ -61,6 +81,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
}
public override string[] GetReadableData()
{
throw new NotImplementedException();
}
public override void Read()
{
}
@ -115,12 +140,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
this.Data = soundData.ReadBytes((int) soundData.Size());
if (Settings.DumpSounds)
{
Name = Helper.CleanInput(Name);
Console.WriteLine($"Dumping {Name}");
File.WriteAllBytes($"{Settings.SoundPath}\\{Name}.wav", Data);
}
//Save($"{Settings.DumpPath}\\SoundBank\\{Name}.wav");
string path = $"{Program.DumpPath}\\SoundBank\\{Name}.wav";
File.WriteAllBytes(path, Data);
}
public void Write(ByteWriter writer)
{
writer.WriteUInt32((uint)Handle);

@ -1,14 +1,14 @@
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
@ -34,13 +34,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
List<byte> colorIndexes = new List<byte>();
for (int i = 0; i < 16 * 16; i++)
{
var b = Reader.ReadByte();
var g = Reader.ReadByte();
var r = Reader.ReadByte();
var r = Reader.ReadSByte();
var g = Reader.ReadSByte();
var b = Reader.ReadSByte();
Reader.ReadByte();
colorIndexes.Add(r);
colorIndexes.Add(g);
colorIndexes.Add(b);
colorIndexes.Add((byte) r);
colorIndexes.Add((byte) g);
colorIndexes.Add((byte) b);
}
_points = new List<byte>();
@ -52,12 +52,30 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
xList.Add(colorIndexes[Reader.ReadByte()]);
}
//x_list.AddRange(points);
//points = x_list;
xList.AddRange(_points);
_points = xList;
}
for (int i = 0; i < 16*16/8; i++)
{
}
using (var bmp = new Bitmap(16, 16, PixelFormat.Format32bppArgb))
{
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0,
bmp.Width,
bmp.Height),
ImageLockMode.WriteOnly,
bmp.PixelFormat);
IntPtr pNative = bmpData.Scan0;
Marshal.Copy(_points.ToArray(), 0, pNative, _points.Count);
bmp.UnlockBits(bmpData);
bmp.Save("icon.png");
}
File.WriteAllBytes("fatcock.raw", _points.ToArray());
}
@ -65,5 +83,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Print(bool ext)
{
}
public override string[] GetReadableData()
{
return Array.Empty<string>();
}
}
}

@ -1,12 +1,9 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class ChunkList : DataLoader//This is used for MFA reading/writing
{

@ -1,14 +1,12 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class Controls : DataLoader
public class Controls : DataLoader
{
public List<PlayerControl> Items;
@ -28,17 +26,35 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new mmfparser.mfaloaders.PlayerControl(Reader);
var item = new PlayerControl(Reader);
Items.Add(item);
item.Read();
}
}
}
class PlayerControl : DataLoader
public void Write(ByteWriter writer)
{
int _controlType;
writer.WriteInt32(Items.Count);
foreach (var item in Items)
{
item.Write(writer);
}
}
}
public class PlayerControl : DataLoader
{
public int ControlType;
public int Up;
public int Down;
public int Left;
public int Right;
public int Button1;
public int Button2;
public int Button3;
public int Button4;
public PlayerControl(ByteIO reader) : base(reader)
@ -54,21 +70,34 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
_controlType = Reader.ReadInt32();
ControlType = Reader.ReadInt32();
var count = Reader.ReadInt32();
var up = Reader.ReadInt32();
var down = Reader.ReadInt32();
var left = Reader.ReadInt32();
var right = Reader.ReadInt32();
var button1 = Reader.ReadInt32();
var button2 = Reader.ReadInt32();
var button3 = Reader.ReadInt32();
var button4 = Reader.ReadInt32();
Up = Reader.ReadInt32();
Down = Reader.ReadInt32();
Left = Reader.ReadInt32();
Right = Reader.ReadInt32();
Button1 = Reader.ReadInt32();
Button2 = Reader.ReadInt32();
Button3 = Reader.ReadInt32();
Button4 = Reader.ReadInt32();
for (int i = 0; i < 8; i++)
{
Reader.ReadInt32();
}
}
public void Write(ByteWriter writer)
{
writer.WriteInt32(ControlType);
writer.WriteUInt32(16);
writer.WriteInt32(Up);
writer.WriteInt32(Down);
writer.WriteInt32(Left);
writer.WriteInt32(Right);
writer.WriteInt32(Button1);
writer.WriteInt32(Button2);
writer.WriteInt32(Button3);
writer.WriteInt32(Button4);
}

@ -1,16 +1,12 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class Frame : DataLoader
public class Frame : DataLoader
{
public string Name = "ERROR";
public int SizeX;
@ -72,12 +68,14 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
var frameitem = new FrameItem(Reader);
frameitem.Read();
frameitems.Add(frameitem);
Console.WriteLine("Frameitem:"+frameitem.Name);
//break;
}
//ПРОЧИТАЙ ЭТО
//вжух и весь код для фрейма готов
//блин не сработало
@ -90,6 +88,11 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
}
public void Write(ByteWriter Writer)
{
}
}

@ -1,17 +1,11 @@

using mmfparser;
using NetMFAPatcher.mmfparser.mfaloaders.mfachunks;
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.MMFParser.MFALoaders.mfachunks;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class FrameItem : DataLoader
public class FrameItem : DataLoader
{
public int ObjectType;
public int Handle;
@ -49,7 +43,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
{
throw new NotImplementedException("invalid icon");
}
var chunks = new mmfparser.mfaloaders.ChunkList(Reader);
var chunks = new ChunkList(Reader);
chunks.Read();
if(ObjectType>=32)//extension base
{

@ -1,13 +1,22 @@
using System;
using mmfparser;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class AgmiBank : DataLoader
public class AgmiBank : DataLoader
{
private int GraphicMode;
private int PaletteVersion;
private int PaletteEntries;
public Dictionary<int,ImageItem> Items = new Dictionary<int, ImageItem>();
private List<Color> Palette;
public override void Print()
{
throw new NotImplementedException();
@ -16,36 +25,51 @@ namespace NetMFAPatcher.MMFParser.MFALoaders
public override void Read()
{
Logger.Log("TEX READ");
var graphicMode = Reader.ReadInt32();
Logger.Log($"GraphicMode:{graphicMode}");
var paletteVersion = Reader.ReadInt16();
Logger.Log($"PaletteVersion:{paletteVersion}");
var paletteEntries = Reader.ReadInt16();
Logger.Log($"PaletteEntries:{paletteEntries}");
GraphicMode = Reader.ReadInt32();
Logger.Log($"GraphicMode:{GraphicMode}");
PaletteVersion = Reader.ReadInt16();
Logger.Log($"PaletteVersion:{PaletteVersion}");
PaletteEntries = Reader.ReadInt16();
Logger.Log($"PaletteEntries:{PaletteEntries}");
Palette = new List<Color>();//Color[256];
for (int i = 0; i < 256; i++)
{
Reader.ReadColor();
Palette.Add(Reader.ReadColor());
}
var count = Reader.ReadInt32();
Logger.Log($"Number of image items: {count.ToString()}");
for (int i = 0; i < count; i++)
{
var item = new ImageItem(Reader);
item.IsCompressed = true;
var currentPos = Reader.Tell();
item.Debug = true;
item.Read();
item.Save($"{Settings.ImagePath}\\{i}.png");
Items.Add(item.Handle,item);
}
}
public void Write(ByteWriter writer)
{
writer.WriteInt32(GraphicMode);
writer.WriteInt16((short) PaletteVersion);
writer.WriteInt16((short) PaletteEntries);
for (int i = 0; i < 256; i++)
{
writer.WriteColor(Palette[i]);
}
writer.WriteInt32(Items.Count);
foreach (var key in Items.Keys)
{
Items[key].Write(writer);
}
}
public AgmiBank(ByteIO reader) : base(reader)
{

@ -1,13 +1,8 @@
using mmfparser;
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class Layer : DataLoader
{

@ -1,15 +1,11 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class ValueList : DataLoader
public class ValueList : DataLoader
{
public List<ValueItem> Items = new List<ValueItem>();
public ValueList(ByteIO reader) : base(reader)
@ -30,13 +26,20 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
var item = new ValueItem(Reader);
item.Read();
Items.Add(item);
}
}
public void Write(ByteWriter Writer)
{
Writer.WriteInt32(Items.Count);
foreach (var item in Items)
{
item.Write(Writer);
}
}
}
class ValueItem: DataLoader
public class ValueItem: DataLoader
{
public object Value;
public string Name;
@ -67,8 +70,26 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
Value = Reader.ReadDouble();
break;
}
}
public void Write(ByteWriter Writer)
{
Writer.AutoWriteUnicode(Name);
if (Value is string)
{
Writer.WriteInt32(2);
Writer.AutoWriteUnicode((string)Value);
}
else if (Value is int)
{
Writer.WriteInt32(0);
Writer.WriteInt32((int)Value);
}
else if (Value is double || Value is float)
{
Writer.WriteInt32(1);
Writer.Write((float)Value);
}
}
}

@ -1,12 +1,6 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks
{
class Active : AnimationObject
{

@ -1,12 +1,9 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks
{
class AnimationObject:ObjectLoader
{

@ -1,12 +1,9 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks
{
class Behaviours : DataLoader
{

@ -1,13 +1,9 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks
{
class Movements : DataLoader
{

@ -1,13 +1,9 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
namespace NetMFAPatcher.MMFParser.MFALoaders.mfachunks
{
class ObjectLoader : DataLoader
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@ -0,0 +1,69 @@
@ECHO OFF
rem # set .NET version and output folder name
set net="v4, C:\Windows\Microsoft.NET\Framework\v4.0.30319"
set output=Output
rem # process arguments
set ILMergeSolution=%1ILMerge\ILMerge.exe
rem # determine programm files of x86 for 32 and 64 Platform
IF EXIST "%PROGRAMFILES(x86)%" set prorgammFiles=%PROGRAMFILES(x86)%
IF NOT EXIST "%PROGRAMFILES(x86)%" set prorgammFiles=%PROGRAMFILES%
rem # if ILMerge.exe not in the $(SolutionDir)ILMerge\
rem # then try to use installed in prorgammFiles
IF EXIST %ILMergeSolution% set ILMerge="%ILMergeSolution%"
IF NOT EXIST %ILMergeSolution% set ILMerge=%prorgammFiles%\Microsoft\ILMerge\ILMerge.exe
set target_path=%2
set target_file=%~nx2
set target_dir=%~dp2
set ConfigurationName=%3
rem # set output path and result file path
set outdir=%target_dir%%output%
set result=%outdir%\%target_file%
rem # print info
@echo Start %ConfigurationName% Merging %target_file%.
@echo Target: %target_path%
@echo target_dir: %target_dir%
@echo Config: %ConfigurationName%
rem # recreate outdir
IF EXIST "%outdir%" rmdir /S /Q "%outdir%"
md "%outdir%"
rem # run merge cmd
@echo Merging: '"%ILMerge%" /wildcards /targetplatform:%net% /out:"%result%" %target_path% "%target_dir%*.dll"'
"%ILMerge%" /wildcards /targetplatform:%net% /out:"%result%" %target_path% "%target_dir%*.dll"
rem # if succeded
IF %ErrorLevel% EQU 0 (
rem # clear real output folder and put there result assembly
IF %ConfigurationName%==Release (
del %target_dir%*.*
del %target_dir%*.dll
del %target_dir%*.pdb
del %target_dir%*.xml
del %target_dir%*.*
copy %result% %target_dir%
rmdir /S /Q %outdir%
set result=%target_path%
@echo Result: %target_file% "-> %target_path%"
) ELSE (
@echo Result: %target_file% "-> %result%" )
set status=succeded
set errlvl=0
) ELSE (
set status=failed
set errlvl=1
)
@echo Merge %status%
exit %errlvl%
Loading…
Cancel
Save