Image bank refactor + global variables/members name refactor

master
REDxEYE 5 years ago
parent 0fa315477d
commit 0609171eaf

@ -72,8 +72,9 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zlib">
<HintPath>E:\ClickTFReader-master\DUMP\fnaf-world\CHUNKS\Ionic.Zlib.dll</HintPath>
<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" />
@ -95,7 +96,6 @@
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\DebugImageBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Events.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\EventsParts.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Expressions\Expression.cs" />
@ -143,6 +143,7 @@
<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" />

@ -38,7 +38,7 @@
//
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
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.Location = new System.Drawing.Point(12, 12);
@ -115,16 +115,15 @@
this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label GameInfo;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TreeView treeView1;
#endregion
}
}

@ -14,7 +14,7 @@ namespace NetMFAPatcher.GUI
{
public partial class MainForm : Form
{
public Thread loaderThread;
public Thread LoaderThread;
public MainForm()
{
InitializeComponent();
@ -57,28 +57,28 @@ namespace NetMFAPatcher.GUI
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
var currentFrame = EXE.LatestInst.game_data.Frames[treeView1.SelectedNode.Index];
var currentFrame = Exe.LatestInst.GameData.Frames[treeView1.SelectedNode.Index];
listBox1.Items.Clear();
listBox1.Items.Add($"Size: {currentFrame.width}x{currentFrame.height}");
listBox1.Items.Add($"Size: {currentFrame.Width}x{currentFrame.Height}");
listBox1.Items.Add($"Number of objects: {currentFrame.CountOfObjs}");
}
public void AfterLoad()
{
var gameData = EXE.LatestInst.game_data;
var gameData = Exe.LatestInst.GameData;
foreach (var item in gameData.Frames)
{
treeView1.Nodes.Add(item.name);
treeView1.Nodes.Add(item.Name);
}
string toLog = "";
toLog += $"Title:{EXE.LatestInst.game_data.Name}\n";
toLog += $"Copyright:{EXE.LatestInst.game_data.Copyright}\n";
toLog += $"Editor Filename: {EXE.LatestInst.game_data.EditorFilename}\n";
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.game_data.product_build}\n";
toLog += $"Build: {EXE.LatestInst.game_data.build}\n";
toLog += $"Runtime Version: {EXE.LatestInst.game_data.runtime_version}\n";
toLog += $"Product Build: {Exe.LatestInst.GameData.ProductBuild}\n";
toLog += $"Build: {Exe.LatestInst.GameData.Build}\n";
toLog += $"Runtime Version: {Exe.LatestInst.GameData.RuntimeVersion}\n";

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@ -34,37 +33,37 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
while(true)
{
var identifier = reader.ReadAscii(4);
var identifier = Reader.ReadAscii(4);
if (identifier == Header)
{
MaxObjects = reader.ReadInt16();
MaxObjectInfo = reader.ReadInt16();
NumberOfPlayers = reader.ReadInt16();
MaxObjects = Reader.ReadInt16();
MaxObjectInfo = Reader.ReadInt16();
NumberOfPlayers = Reader.ReadInt16();
for (int i = 0; i < 17; i++)
{
NumberOfConditions.Add(reader.ReadInt16());
NumberOfConditions.Add(Reader.ReadInt16());
}
var QualifierCount = reader.ReadInt16();//should be 0, so i dont give a fuck
Quailifers = new Quailifer[QualifierCount + 1];
for (int i = 0; i < QualifierCount; i++)
var qualifierCount = Reader.ReadInt16();//should be 0, so i dont give a fuck
Quailifers = new Quailifer[qualifierCount + 1];
for (int i = 0; i < qualifierCount; i++)
{
var NewQualifier = new Quailifer(reader);
QualifiersList.Add(NewQualifier);//fucking python types
var newQualifier = new Quailifer(Reader);
QualifiersList.Add(newQualifier);//fucking python types
//THIS IS NOT DONE
}
}
else if (identifier == EventCount)
{
var size = reader.ReadInt32();
var size = Reader.ReadInt32();
}
else if (identifier == EventgroupData)
{
var size = reader.ReadInt32();
var end_position = reader.Tell() + size;
var size = Reader.ReadInt32();
var endPosition = Reader.Tell() + size;
while (true)
{
var eg = new EventGroup(reader);
var eg = new EventGroup(Reader);
eg.Read();
}
}
@ -77,10 +76,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public class Quailifer : ChunkLoader
{
public int objectInfo;
public int type;
public Quailifer qualifier;
List<int> Objects = new List<int>();
public int ObjectInfo;
public int Type;
public Quailifer Qualifier;
List<int> _objects = new List<int>();
public Quailifer(Chunk chunk) : base(chunk) { }
public Quailifer(ByteIO reader) : base(reader) { }
@ -92,9 +91,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read()
{
objectInfo = reader.ReadUInt16();
type = reader.ReadInt16();
qualifier = this;
ObjectInfo = Reader.ReadUInt16();
Type = Reader.ReadInt16();
Qualifier = this;
}
}
@ -104,9 +103,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
public int Flags;
public int IsRestricted;
public int restrictCPT;
public int identifier;
public int undo;
public int RestrictCpt;
public int Identifier;
public int Undo;
public List<Condition> Conditions = new List<Condition>();
public List<Action> Actions = new List<Action>();
@ -120,27 +119,27 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadInt16() * -1;
var NumberOfConditions = reader.ReadByte();
var NumberOfActions = reader.ReadByte();
var flags = reader.ReadUInt16();
var nop = reader.ReadInt16();
IsRestricted = reader.ReadInt32();
restrictCPT = reader.ReadInt32();
for (int i = 0; i < NumberOfConditions; i++)
var currentPosition = Reader.Tell();
var size = Reader.ReadInt16() * -1;
var numberOfConditions = Reader.ReadByte();
var numberOfActions = Reader.ReadByte();
var flags = Reader.ReadUInt16();
var nop = Reader.ReadInt16();
IsRestricted = Reader.ReadInt32();
RestrictCpt = Reader.ReadInt32();
for (int i = 0; i < numberOfConditions; i++)
{
var item = new Condition(reader);
var item = new Condition(Reader);
item.Read();
Conditions.Add(item);
}
for (int i = 0; i < NumberOfActions; i++)
for (int i = 0; i < numberOfActions; i++)
{
var item = new Action(reader);
var item = new Action(Reader);
item.Read();
Actions.Add(item);
}
reader.Seek(currentPosition + size);
Reader.Seek(currentPosition + size);
Console.WriteLine("IF:");
if (Conditions!=null)
{

@ -1,5 +1,4 @@
using mmfparser;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
@ -7,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
@ -18,11 +18,11 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int DefType;
public int NumberOfParameters;
public ObjectType ObjectType;
public int num;
public int Num;
public int ObjectInfo;
public int Identifier;
public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>();
public List<Parameter> Items = new List<Parameter>();
public Condition(ByteIO reader) : base(reader) { }
public override void Print()
{
@ -31,31 +31,31 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16();
num = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16();
Flags = reader.ReadSByte();
OtherFlags = reader.ReadSByte();
NumberOfParameters = reader.ReadByte();
DefType = reader.ReadByte();
Identifier = reader.ReadInt16();
var currentPosition = Reader.Tell();
var size = Reader.ReadUInt16();
ObjectType = (ObjectType)Reader.ReadInt16();
Num = Reader.ReadInt16();
ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = Reader.ReadInt16();
Flags = Reader.ReadSByte();
OtherFlags = Reader.ReadSByte();
NumberOfParameters = Reader.ReadByte();
DefType = Reader.ReadByte();
Identifier = Reader.ReadInt16();
for (int i = 0; i < NumberOfParameters; i++)
{
var item = new Parameter(reader);
var item = new Parameter(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}
reader.Seek(currentPosition + size);
Reader.Seek(currentPosition + size);
}
public override string ToString()
{
return $"Condition {ObjectType}-{num}-{(items.Count > 0 ? items[0].ToString() : "cock")}";
return $"Condition {ObjectType}-{Num}-{(Items.Count > 0 ? Items[0].ToString() : "cock")}";
}
}
@ -66,10 +66,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public int OtherFlags;
public int DefType;
public ObjectType ObjectType;
public int num;
public int Num;
public int ObjectInfo;
public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>();
public List<Parameter> Items = new List<Parameter>();
public Action(ByteIO reader) : base(reader) { }
public override void Print( )
{
@ -78,21 +78,21 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16();
num = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16();
Flags = reader.ReadSByte();
OtherFlags = reader.ReadSByte();
var number_of_parameters=reader.ReadByte();
DefType = reader.ReadByte();
var currentPosition = Reader.Tell();
var size = Reader.ReadUInt16();
ObjectType = (ObjectType)Reader.ReadInt16();
Num = Reader.ReadInt16();
ObjectInfo = Reader.ReadUInt16();
ObjectInfoList = Reader.ReadInt16();
Flags = Reader.ReadSByte();
OtherFlags = Reader.ReadSByte();
var numberOfParameters=Reader.ReadByte();
DefType = Reader.ReadByte();
for (int i = 0; i < DefType; i++)
{
var item = new Parameter(reader);
var item = new Parameter(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}
@ -100,7 +100,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override string ToString()
{
return $"Action {ObjectType}-{num}-{(items.Count>0?items[0].ToString():"cock")}";
return $"Action {ObjectType}-{Num}-{(Items.Count>0?Items[0].ToString():"cock")}";
}
}
@ -108,7 +108,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public class Parameter : DataLoader
{
public int Code;
public DataLoader loader;
public DataLoader Loader;
public Parameter(ByteIO reader) : base(reader) { }
@ -119,36 +119,36 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
public override void Read()
{
var current_position = reader.Tell();
var size = reader.ReadInt16();
Code = reader.ReadInt16();
var currentPosition = Reader.Tell();
var size = Reader.ReadInt16();
Code = Reader.ReadInt16();
var ActualLoader = Helper.LoadParameter(Code,reader);
this.loader = ActualLoader;
if (loader!=null)
var actualLoader = Helper.LoadParameter(Code,Reader);
this.Loader = actualLoader;
if (Loader!=null)
{
loader.Read();
Loader.Read();
}
else
{
//throw new Exception("Loader is null");
}
reader.Seek(current_position+size);
Reader.Seek(currentPosition+size);
}
public object value
public object Value
{
get
{
if (loader != null)
if (Loader != null)
{
if (loader.GetType().GetField("value") != null)
if (Loader.GetType().GetField("value") != null)
{
return loader.GetType().GetField("value").GetValue(loader);
return Loader.GetType().GetField("value").GetValue(Loader);
}
else
{
@ -160,7 +160,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
}
public override string ToString()
{
if (loader != null) return loader.ToString();
if (Loader != null) return Loader.ToString();
else return "UNK-PARAMETER";
}

@ -12,7 +12,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Expressions
class Expression : DataLoader
{
public ObjectType ObjectType;
public int num;
public int Num;
public int ObjectInfo;
public int ObjectInfoList;
public Expression(ByteIO reader) : base(reader) { }

@ -17,7 +17,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
}
public override string ToString()
{
return $"AlterableValue{Convert.ToChar(value).ToString().ToUpper()}";
return $"AlterableValue{Convert.ToChar(Value).ToString().ToUpper()}";
}
}
}

@ -10,13 +10,13 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Colour : ParameterCommon
{
public Color value;
public Color Value;
public Colour(ByteIO reader) : base(reader) { }
public override void Read()
{
var bytes = reader.ReadBytes(4);
value = Color.FromArgb(bytes[0], bytes[1], bytes[2]);
var bytes = Reader.ReadBytes(4);
Value = Color.FromArgb(bytes[0], bytes[1], bytes[2]);
}

@ -16,10 +16,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Create(ByteIO reader) : base(reader) { }
public override void Read()
{
Position = new Position(reader);
Position = new Position(Reader);
Position.Read();
ObjectInstances = reader.ReadUInt16();
ObjectInfo = reader.ReadUInt16();
ObjectInstances = Reader.ReadUInt16();
ObjectInfo = Reader.ReadUInt16();
}

@ -16,8 +16,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Every(ByteIO reader) : base(reader) { }
public override void Read()
{
Delay = reader.ReadInt32();
Compteur = reader.ReadInt32();
Delay = Reader.ReadInt32();
Compteur = Reader.ReadInt32();
}
public override string ToString()

@ -9,17 +9,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Float : ParameterCommon
{
public float value;
public float Value;
public Float(ByteIO reader) : base(reader) { }
public override void Read()
{
value = reader.ReadSingle();
Value = Reader.ReadSingle();
}
public override string ToString()
{
return $"{this.GetType().Name} value: {value}";
return $"{this.GetType().Name} value: {Value}";
}
}
}

@ -18,8 +18,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
}
public override string ToString()
{
if(value>26) return $"GlobalValue{value}";
return $"GlobalValue{Convert.ToChar(value).ToString().ToUpper()}";
if(Value>26) return $"GlobalValue{Value}";
return $"GlobalValue{Convert.ToChar(Value).ToString().ToUpper()}";
}
}
}

@ -14,7 +14,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Int(ByteIO reader) : base(reader) { }
public override void Read()
{
value = (short)reader.ReadInt32();
Value = (short)Reader.ReadInt32();
}
}

@ -15,9 +15,9 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public ParamObject(ByteIO reader) : base(reader) { }
public override void Read()
{
ObjectInfoList = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectType = reader.ReadInt16();
ObjectInfoList = Reader.ReadInt16();
ObjectInfo = Reader.ReadUInt16();
ObjectType = Reader.ReadInt16();
}
public override string ToString()
{

@ -23,16 +23,16 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Position(ByteIO reader) : base(reader) { }
public override void Read()
{
ObjectInfoParent = reader.ReadInt16();
Flags = reader.ReadUInt16();
X = reader.ReadInt16();
Y = reader.ReadInt16();
Slope = reader.ReadInt16();
Angle = reader.ReadInt16();
Direction = reader.ReadSingle();
TypeParent = reader.ReadInt16();
ObjectInfoList = reader.ReadInt16();
Layer = reader.ReadInt16();
ObjectInfoParent = Reader.ReadInt16();
Flags = Reader.ReadUInt16();
X = Reader.ReadInt16();
Y = Reader.ReadInt16();
Slope = Reader.ReadInt16();
Angle = Reader.ReadInt16();
Direction = Reader.ReadSingle();
TypeParent = Reader.ReadInt16();
ObjectInfoList = Reader.ReadInt16();
Layer = Reader.ReadInt16();
}

@ -9,20 +9,20 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Sample : ParameterCommon
{
public int handle;
public string name;
public int flags;
public int Handle;
public string Name;
public int Flags;
public Sample(ByteIO reader) : base(reader) { }
public override void Read()
{
handle = reader.ReadInt16();
flags = reader.ReadUInt16();
name = reader.ReadWideString();
Handle = Reader.ReadInt16();
Flags = Reader.ReadUInt16();
Name = Reader.ReadWideString();
}
public override string ToString()
{
return $"Sample '{name}' handle: {handle}";
return $"Sample '{Name}' handle: {Handle}";
}
}
}

@ -9,17 +9,17 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Short : ParameterCommon
{
public short value;
public short Value;
public Short(ByteIO reader) : base(reader) { }
public override void Read()
{
value = reader.ReadInt16();
Value = Reader.ReadInt16();
}
public override string ToString()
{
return $"{this.GetType().Name} value: {value}";
return $"{this.GetType().Name} value: {Value}";
}
}
}

@ -15,8 +15,8 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
public Time(ByteIO reader) : base(reader) { }
public override void Read()
{
Timer = reader.ReadInt32();
Loops = reader.ReadInt32();
Timer = Reader.ReadInt32();
Loops = Reader.ReadInt32();
}
public override string ToString()

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -18,7 +17,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read()
{
var filename = reader.ReadAscii();
var filename = Reader.ReadAscii();
//var data = reader.ReadBytes();
}
}

@ -1,5 +1,4 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
@ -12,7 +11,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class GlobalValues : ChunkLoader
{
public List<float> items = new List<float>();
public List<float> Items = new List<float>();
public GlobalValues(Chunk chunk) : base(chunk) { }
public override void Print(bool ext)
{
@ -21,15 +20,15 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read()
{
var numberOfItems = reader.ReadUInt16();
var numberOfItems = Reader.ReadUInt16();
var templist = new List<ByteIO>();
for (int i = 0; i < numberOfItems; i++)
{
templist.Add(new ByteIO(reader.ReadBytes(4)));
templist.Add(new ByteIO(Reader.ReadBytes(4)));
}
foreach (var item in templist)
{
var globalType = reader.ReadSByte();
var globalType = Reader.ReadSByte();
float newGlobal = 0f;
if((Constants.ValueType)globalType==Constants.ValueType.Float)
{
@ -43,7 +42,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
throw new Exception("unknown global type");
}
items.Add(newGlobal);
Items.Add(newGlobal);
}
@ -51,7 +50,7 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
}
public class GlobalStrings : ChunkLoader
{
public List<string> items = new List<string>();
public List<string> Items = new List<string>();
public GlobalStrings(Chunk chunk) : base(chunk) { }
public override void Print(bool ext)
{
@ -60,10 +59,10 @@ namespace NetMFAPatcher.MMFParser.ChunkLoaders
public override void Read()
{
var count = reader.ReadUInt32();
var count = Reader.ReadUInt32();
for (int i = 0; i < count; i++)
{
items.Add(reader.ReadAscii());
Items.Add(Reader.ReadAscii());
}
}

@ -1,13 +1,13 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.Utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
class ObjectNames : ChunkLoader//Fucking trash
{
@ -18,13 +18,13 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read()
{
var start = reader.Tell();
var endpos = start + chunk.size;
var start = Reader.Tell();
var endpos = start + Chunk.Size;
while(true)
{
if (reader.Tell() >= endpos+4) break;
if (Reader.Tell() >= endpos+4) break;
Console.WriteLine(reader.ReadWideString());
Console.WriteLine(Reader.ReadWideString());
}
}

@ -1,40 +1,40 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.Data
{
public class ChunkList
{
public List<Chunk> chunks = new List<Chunk>();
public bool verbose = false;
public List<Chunk> Chunks = new List<Chunk>();
public bool Verbose = false;
public List<Frame> Frames = new List<Frame>();
public void Read(ByteIO exeReader)
{
chunks.Clear();
Chunks.Clear();
while (true)
{
Chunk chunk = new Chunk(chunks.Count, this);
chunk.verbose = verbose;
Chunk chunk = new Chunk(Chunks.Count, this);
chunk.Verbose = Verbose;
chunk.Read(exeReader);
chunk.loader = LoadChunk(chunk);
chunk.Loader = LoadChunk(chunk);
if (chunk.loader != null)
if (chunk.Loader != null)
{
if (chunk.loader.verbose)
if (chunk.Loader.Verbose)
{
//chunk.loader.Print(Program.LogAll);
}
}
if (chunk.verbose)
if (chunk.Verbose)
{
chunk.Print(Program.LogAll);
if(Program.LogAll) Console.ReadKey();
@ -44,15 +44,15 @@ namespace NetMFAPatcher.MMFParser.Data
}
chunks.Add(chunk);
if (chunk.id == 8750)
Chunks.Add(chunk);
if (chunk.Id == 8750)
{
chunk.BuildKey();
}
if (chunk.id == 32639) break; //LAST chunkID
if (chunk.Id == 32639) break; //LAST chunkID
}
//Logger.Log(verbose ? $" Total Chunks Count: {chunks.Count}":"ChunkList Done", true, ConsoleColor.Blue);
@ -60,62 +60,62 @@ namespace NetMFAPatcher.MMFParser.Data
public class Chunk
{
ChunkList chunk_list;
public string name = "UNKNOWN";
int uid;
public int id = 0;
ChunkList _chunkList;
public string Name = "UNKNOWN";
int _uid;
public int Id = 0;
public ChunkLoader loader;
public byte[] chunk_data;
public ChunkFlags flag;
public int size = 0;
public int decompressed_size = 0;
public bool verbose = false;
public Chunk(int Actualuid, ChunkList actual_chunk_list)
public ChunkLoader Loader;
public byte[] ChunkData;
public ChunkFlags Flag;
public int Size = 0;
public int DecompressedSize = 0;
public bool Verbose = false;
public Chunk(int actualuid, ChunkList actualChunkList)
{
uid = Actualuid;
chunk_list = actual_chunk_list;
_uid = actualuid;
_chunkList = actualChunkList;
}
public ByteIO get_reader()
{
return new ByteIO(chunk_data);
return new ByteIO(ChunkData);
}
public void Read(ByteIO exeReader)
{
id = exeReader.ReadInt16();
name = ((ChunkNames) id).ToString();
Id = exeReader.ReadInt16();
Name = ((ChunkNames) Id).ToString();
flag = (ChunkFlags) exeReader.ReadInt16();
size = exeReader.ReadInt32();
Flag = (ChunkFlags) exeReader.ReadInt16();
Size = exeReader.ReadInt32();
switch (flag)
switch (Flag)
{
case ChunkFlags.Encrypted:
chunk_data = Decryption.DecodeChunk(exeReader.ReadBytes(size),size);
ChunkData = Decryption.DecodeChunk(exeReader.ReadBytes(Size),Size);
break;
case ChunkFlags.CompressedAndEncrypyed:
chunk_data = Decryption.DecodeMode3(exeReader.ReadBytes(size), size,id);
ChunkData = Decryption.DecodeMode3(exeReader.ReadBytes(Size), Size,Id);
break;
case ChunkFlags.Compressed:
chunk_data = Decompressor.Decompress(exeReader);
ChunkData = Decompressor.Decompress(exeReader);
break;
case ChunkFlags.NotCompressed:
chunk_data = exeReader.ReadBytes(size);
ChunkData = exeReader.ReadBytes(Size);
break;
}
if (chunk_data != null)
if (ChunkData != null)
{
decompressed_size = chunk_data.Length;
string path = $"{Program.DumpPath}\\CHUNKS\\{name}.chunk";
File.WriteAllBytes(path, chunk_data);
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)
int.TryParse(Name,out tempId);
if(tempId==Id)
{
//chunk_data.Log(true, "X2");
}
@ -126,22 +126,22 @@ namespace NetMFAPatcher.MMFParser.Data
{
if(extented)
{
Logger.Log($"Chunk: {name} ({uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {id} - 0x{id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {flag}", true, ConsoleColor.DarkCyan);
Logger.Log($" Loader: {(loader != null ? loader.GetType().Name : "Empty Loader")}", true,ConsoleColor.DarkCyan);
Logger.Log($" Size: {size} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan);
Logger.Log($"Chunk: {Name} ({_uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {Id} - 0x{Id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {Flag}", true, ConsoleColor.DarkCyan);
Logger.Log($" Loader: {(Loader != null ? Loader.GetType().Name : "Empty Loader")}", true,ConsoleColor.DarkCyan);
Logger.Log($" Size: {Size} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {DecompressedSize} B", true, ConsoleColor.DarkCyan);
Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan);
}
else
{
Logger.Log($"Chunk: {name} ({uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {id} - 0x{id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {flag}", true, ConsoleColor.DarkCyan);
Logger.Log($"Chunk: {Name} ({_uid})", true, ConsoleColor.DarkCyan);
Logger.Log($" ID: {Id} - 0x{Id.ToString("X")}", true, ConsoleColor.DarkCyan);
Logger.Log($" Decompressed Size: {DecompressedSize} B", true, ConsoleColor.DarkCyan);
Logger.Log($" Flags: {Flag}", true, ConsoleColor.DarkCyan);
Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan);
}
@ -152,16 +152,16 @@ namespace NetMFAPatcher.MMFParser.Data
string copyright = "";
string project = "";
var titleChunk = chunk_list.get_chunk<AppName>();
if (titleChunk != null) title = titleChunk.value;
var titleChunk = _chunkList.get_chunk<AppName>();
if (titleChunk != null) title = titleChunk.Value;
var copyrightChunk = chunk_list.get_chunk<Copyright>();
if (copyrightChunk != null) copyright = copyrightChunk.value;
var copyrightChunk = _chunkList.get_chunk<Copyright>();
if (copyrightChunk != null) copyright = copyrightChunk.Value;
var projectChunk = chunk_list.get_chunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.value;
var projectChunk = _chunkList.get_chunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.Value;
if (EXE.LatestInst.game_data.product_build >= 284)
if (Exe.LatestInst.GameData.ProductBuild >= 284)
{
Decryption.MakeKey(title, copyright, project);
}
@ -188,7 +188,7 @@ namespace NetMFAPatcher.MMFParser.Data
public ChunkLoader LoadChunk(Chunk chunk)
{
ChunkLoader loader = null;
switch (chunk.id)
switch (chunk.Id)
{
case 8739:
loader = new AppHeader(chunk);
@ -277,13 +277,13 @@ namespace NetMFAPatcher.MMFParser.Data
public T get_chunk<T>() where T : ChunkLoader
{
foreach (Chunk chunk in chunks)
foreach (Chunk chunk in Chunks)
{
if (chunk.loader != null)
if (chunk.Loader != null)
{
if (chunk.loader.GetType().Name == typeof(T).Name)
if (chunk.Loader.GetType().Name == typeof(T).Name)
{
return (T) chunk.loader;
return (T) chunk.Loader;
}
}
}

@ -10,18 +10,18 @@ namespace mmfparser
{
public abstract class DataLoader
{
private Chunk chunk;
public ByteIO reader;
public bool verbose = true;
private Chunk _chunk;
public ByteIO Reader;
public bool Verbose = true;
protected DataLoader(ByteIO reader)
{
this.reader = reader;
this.Reader = reader;
}
protected DataLoader(Chunk chunk)
{
this.chunk = chunk;
this.reader = chunk.get_reader();
this._chunk = chunk;
this.Reader = chunk.get_reader();
}
public abstract void Read();

@ -8,19 +8,19 @@ using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.Data
{
class EXE
class Exe
{
public PackData pack_data;
public GameData game_data;
public static EXE LatestInst;
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);
string Header1 = exeReader.ReadAscii(2);
Logger.Log("EXE Header: " + Header1, true, ConsoleColor.Yellow);
if (Header1 != "MZ")
string header1 = exeReader.ReadAscii(2);
Logger.Log("EXE Header: " + header1, true, ConsoleColor.Yellow);
if (header1 != "MZ")
{
Console.WriteLine("Invalid executable signature");
Console.ReadKey();
@ -29,35 +29,35 @@ namespace NetMFAPatcher.MMFParser.Data
exeReader.Seek(60, SeekOrigin.Begin);
UInt16 hdr_offset = exeReader.ReadUInt16();
UInt16 hdrOffset = exeReader.ReadUInt16();
exeReader.Seek(hdr_offset, SeekOrigin.Begin);
exeReader.Seek(hdrOffset, SeekOrigin.Begin);
string peHdr = exeReader.ReadAscii(2);
Logger.Log("PE Header: " + peHdr, true, ConsoleColor.Yellow);
exeReader.Skip(4);
UInt16 num_of_sections = exeReader.ReadUInt16();
UInt16 numOfSections = exeReader.ReadUInt16();
exeReader.Skip(16);
int optional_header = 28 + 68;
int data_dir = 16 * 8;
exeReader.Skip(optional_header + data_dir);
int optionalHeader = 28 + 68;
int dataDir = 16 * 8;
exeReader.Skip(optionalHeader + dataDir);
int possition = 0;
for (int i = 0; i < num_of_sections; i++)
for (int i = 0; i < numOfSections; i++)
{
var entry = exeReader.Tell();
var section_name = exeReader.ReadAscii();
var sectionName = exeReader.ReadAscii();
if (section_name == ".extra")
if (sectionName == ".extra")
{
exeReader.Seek(entry + 20);
possition = (int)exeReader.ReadUInt32();
break;
}
if (i >= num_of_sections - 1)
if (i >= numOfSections - 1)
{
exeReader.Seek(entry + 16);
uint size = exeReader.ReadUInt32();
@ -70,16 +70,16 @@ namespace NetMFAPatcher.MMFParser.Data
}
exeReader.Seek((int)possition);
UInt16 first_short = exeReader.PeekUInt16();
Logger.Log("First Short: " + first_short.ToString("X2"), true, ConsoleColor.Yellow);
UInt16 firstShort = exeReader.PeekUInt16();
Logger.Log("First Short: " + firstShort.ToString("X2"), true, ConsoleColor.Yellow);
if (first_short == 0x7777)
if (firstShort == 0x7777)
{
Logger.Log("Found PackData header!\nReading PackData header.", true, ConsoleColor.Blue);
pack_data = new PackData();
pack_data.Read(exeReader);
game_data = new GameData();
game_data.Read(exeReader);
PackData = new PackData();
PackData.Read(exeReader);
GameData = new GameData();
GameData.Read(exeReader);
Console.ForegroundColor = ConsoleColor.DarkGreen;
}
else

@ -1,30 +1,30 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.Utils;
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.Banks;
using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.Data
{
public class GameData
{
public int runtime_version;
public int runtime_subversion;
public int product_build;
public int product_version;
public Products build;
public ChunkList gameChunks;
public int RuntimeVersion;
public int RuntimeSubversion;
public int ProductBuild;
public int ProductVersion;
public Products Build;
public ChunkList GameChunks;
public string Name;
public string Author;
public string Copyright;
public string aboutText;
public string AboutText;
public string Doc;
public string EditorFilename;
@ -45,7 +45,7 @@ namespace NetMFAPatcher.MMFParser.Data
public GlobalValues GValues;
public GlobalStrings GStrings;
public static FrameItems testItems;
public static FrameItems TestItems;
//public Extensions Ext;
@ -59,72 +59,72 @@ namespace NetMFAPatcher.MMFParser.Data
string magic = exeReader.ReadAscii(4); //Reading header
//Checking for header
if (magic == Constants.UNICODE_GAME_HEADER) Constants.isUnicode = true;//PAMU
else if (magic == Constants.GAME_HEADER) Constants.isUnicode = false;//PAME
if (magic == Constants.UnicodeGameHeader) Constants.IsUnicode = true;//PAMU
else if (magic == Constants.GameHeader) Constants.IsUnicode = false;//PAME
else Logger.Log("Couldn't found any known headers", true, ConsoleColor.Red);//Header not found
runtime_version = exeReader.ReadUInt16(); //
runtime_subversion = exeReader.ReadUInt16(); //0
product_version = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
product_build = exeReader.ReadInt32(); //CTF Build
build = (Products)runtime_version;
RuntimeVersion = exeReader.ReadUInt16(); //
RuntimeSubversion = exeReader.ReadUInt16(); //0
ProductVersion = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
ProductBuild = exeReader.ReadInt32(); //CTF Build
Build = (Products)RuntimeVersion;
gameChunks = new ChunkList(); //Reading game chunks
gameChunks.Read(exeReader);
GameChunks = new ChunkList(); //Reading game chunks
GameChunks.Read(exeReader);
//Load chunks into gamedata for easier access
if (gameChunks.get_chunk<AppName>() != null) Name = gameChunks.get_chunk<AppName>().value;
if (gameChunks.get_chunk<Copyright>() != null) Copyright = gameChunks.get_chunk<Copyright>().value;
if (gameChunks.get_chunk<AppAuthor>()!=null) Author = gameChunks.get_chunk<AppAuthor>().value;
if (gameChunks.get_chunk<EditorFilename>() != null) EditorFilename = gameChunks.get_chunk<EditorFilename>().value;
if (gameChunks.get_chunk<TargetFilename>() != null) TargetFilename = gameChunks.get_chunk<TargetFilename>().value;
if (gameChunks.get_chunk<AppMenu>() != null) Menu = gameChunks.get_chunk<AppMenu>();
if (gameChunks.get_chunk<AppHeader>() != null) Header = gameChunks.get_chunk<AppHeader>();
if (gameChunks.get_chunk<SoundBank>() != null) Sounds = gameChunks.get_chunk<SoundBank>();
if (gameChunks.get_chunk<MusicBank>() != null) Music = gameChunks.get_chunk<MusicBank>();
if (gameChunks.get_chunk<FontBank>() != null) Fonts = gameChunks.get_chunk<FontBank>();
if (gameChunks.get_chunk<ImageBank>() != null) Images = gameChunks.get_chunk<ImageBank>();
if (gameChunks.get_chunk<AppIcon>() != null) Icon = gameChunks.get_chunk<AppIcon>();
if (gameChunks.get_chunk<GlobalStrings>() != null) GStrings = gameChunks.get_chunk<GlobalStrings>();
if (gameChunks.get_chunk<GlobalValues>() != null) GValues = gameChunks.get_chunk<GlobalValues>();
if (gameChunks.get_chunk<FrameItems>() != null) Frameitems = gameChunks.get_chunk<FrameItems>();
Frames = gameChunks.Frames; //Its a list, so i have to manually parse them in chunk list.
if (GameChunks.get_chunk<AppName>() != null) Name = GameChunks.get_chunk<AppName>().Value;
if (GameChunks.get_chunk<Copyright>() != null) Copyright = GameChunks.get_chunk<Copyright>().Value;
if (GameChunks.get_chunk<AppAuthor>()!=null) Author = GameChunks.get_chunk<AppAuthor>().Value;
if (GameChunks.get_chunk<EditorFilename>() != null) EditorFilename = GameChunks.get_chunk<EditorFilename>().Value;
if (GameChunks.get_chunk<TargetFilename>() != null) TargetFilename = GameChunks.get_chunk<TargetFilename>().Value;
if (GameChunks.get_chunk<AppMenu>() != null) Menu = GameChunks.get_chunk<AppMenu>();
if (GameChunks.get_chunk<AppHeader>() != null) Header = GameChunks.get_chunk<AppHeader>();
if (GameChunks.get_chunk<SoundBank>() != null) Sounds = GameChunks.get_chunk<SoundBank>();
if (GameChunks.get_chunk<MusicBank>() != null) Music = GameChunks.get_chunk<MusicBank>();
if (GameChunks.get_chunk<FontBank>() != null) Fonts = GameChunks.get_chunk<FontBank>();
if (GameChunks.get_chunk<ImageBank>() != null) Images = GameChunks.get_chunk<ImageBank>();
if (GameChunks.get_chunk<AppIcon>() != null) Icon = GameChunks.get_chunk<AppIcon>();
if (GameChunks.get_chunk<GlobalStrings>() != null) GStrings = GameChunks.get_chunk<GlobalStrings>();
if (GameChunks.get_chunk<GlobalValues>() != null) GValues = GameChunks.get_chunk<GlobalValues>();
if (GameChunks.get_chunk<FrameItems>() != null) Frameitems = GameChunks.get_chunk<FrameItems>();
Frames = GameChunks.Frames; //Its a list, so i have to manually parse them in chunk list.
Print();
}
public void Print()
{
Logger.Log($"GameData Info:", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Version: {runtime_version}", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Subversion: { runtime_subversion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { ((Products)product_version).ToString()}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Build: {product_build}", true, ConsoleColor.DarkGreen);
Logger.Log($" {(isUnicode ? "Unicode" : "NonUnicode")} Game", 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 Build: {ProductBuild}", true, ConsoleColor.DarkGreen);
Logger.Log($" {(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);
Logger.Log($" Copyright:{Copyright}", true, ConsoleColor.Cyan);
Logger.Log($" Editor Filename:{EditorFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Target Filename:{TargetFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Screen Resolution: {Header.windowWidth}x{Header.windowHeight}", true, ConsoleColor.Cyan);
Logger.Log($" Screen Resolution: {Header.WindowWidth}x{Header.WindowHeight}", true, ConsoleColor.Cyan);
Logger.Log($" Frame Count:{Header.numberOfFrames}", true, ConsoleColor.Cyan);
if (GStrings != null && GStrings.items.Count > 0)
Logger.Log($" Frame Count:{Header.NumberOfFrames}", true, ConsoleColor.Cyan);
if (GStrings != null && GStrings.Items.Count > 0)
{
Logger.Log($" Global Strings:", true, ConsoleColor.Cyan);
foreach (var item in GStrings.items)
foreach (var item in GStrings.Items)
{
Logger.Log($" {item}");
}
}
if (GValues != null && GValues.items.Count > 0)
if (GValues != null && GValues.Items.Count > 0)
{
Logger.Log($" Global Values:", true, ConsoleColor.Cyan);
foreach (var item in GValues.items)
foreach (var item in GValues.Items)
{
Logger.Log($" {item.ToString()}");
}
@ -134,7 +134,7 @@ 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}, Size: {item.Width}x{item.Height}, Number of objects: {item.CountOfObjs}", true, ConsoleColor.Cyan);
}

@ -1,53 +1,53 @@
using NetMFAPatcher.Utils;
using mmfparser.mfaloaders;
using NetMFAPatcher.chunkloaders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using System.IO;
using Frame = NetMFAPatcher.mmfparser.mfaloaders.Frame;
using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.banks;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.MFALoaders;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mfa
{
class MFA : DataLoader
class Mfa : DataLoader
{
public static readonly string FontBankID = "ATNF";
public static readonly string ImageBankID = "AGMI";
public static readonly string MusicBankID = "ASUM";
public static readonly string SoundBankID = "APMS";
public static readonly string FontBankId = "ATNF";
public static readonly string ImageBankId = "AGMI";
public static readonly string MusicBankId = "ASUM";
public static readonly string SoundBankId = "APMS";
public int mfaBuild;
public int product;
public int buildVersion;
public int langID;
public int MfaBuild;
public int Product;
public int BuildVersion;
public int LangId;
public string name;
public string description;
public string path;
public string Name;
public string Description;
public string Path;
public FontBank fonts;
public SoundBank sounds;
public MusicBank music;
public FontBank Fonts;
public SoundBank Sounds;
public MusicBank Music;
public string author;
public string copyright;
public string company;
public string version;
public string Author;
public string Copyright;
public string Company;
public string Version;
public byte[] stamp;
public byte[] Stamp;
public int windowX;
public int windowY;
public int WindowX;
public int WindowY;
public ValueList globalValues;
public ValueList globalStrings;
public ValueList GlobalValues;
public ValueList GlobalStrings;
public override void Print()
@ -61,21 +61,21 @@ namespace NetMFAPatcher.mfa
{
writer.WriteAscii("MFU2");
writer.WriteInt32(mfaBuild);
writer.WriteInt32(product);
writer.WriteInt32(buildVersion);
writer.WriteInt32(langID);
writer.AutoWriteUnicode(name);
writer.AutoWriteUnicode(description);
writer.AutoWriteUnicode(path);
writer.WriteUInt32((uint)stamp.Length);
writer.WriteBytes(stamp);
writer.WriteAscii(FontBankID);
fonts.Write(writer);
writer.WriteAscii(SoundBankID);
sounds.Write(writer);
writer.WriteAscii(MusicBankID);
writer.WriteInt32(MfaBuild);
writer.WriteInt32(Product);
writer.WriteInt32(BuildVersion);
writer.WriteInt32(LangId);
writer.AutoWriteUnicode(Name);
writer.AutoWriteUnicode(Description);
writer.AutoWriteUnicode(Path);
writer.WriteUInt32((uint)Stamp.Length);
writer.WriteBytes(Stamp);
writer.WriteAscii(FontBankId);
Fonts.Write(writer);
writer.WriteAscii(SoundBankId);
Sounds.Write(writer);
writer.WriteAscii(MusicBankId);
//music.Write();//cum cum cum cum cum cum cum cum
writer.WriteInt32(0);//someone is using musics lol?
@ -89,181 +89,181 @@ namespace NetMFAPatcher.mfa
public override void Read()
{
Logger.Log($"MFA HEADER:{reader.ReadAscii(4)}\n");
mfaBuild = reader.ReadInt32();
product = reader.ReadInt32();
buildVersion = reader.ReadInt32();
Console.WriteLine($"mfaBuild: {mfaBuild}, product: {product}, buildVersion: {buildVersion}");
langID = reader.ReadInt32();
Logger.Log($"MFA HEADER:{Reader.ReadAscii(4)}\n");
MfaBuild = Reader.ReadInt32();
Product = Reader.ReadInt32();
BuildVersion = Reader.ReadInt32();
Console.WriteLine($"mfaBuild: {MfaBuild}, product: {Product}, buildVersion: {BuildVersion}");
LangId = Reader.ReadInt32();
name = Helper.AutoReadUnicode(reader);
Name = Helper.AutoReadUnicode(Reader);
description = Helper.AutoReadUnicode(reader);
Description = Helper.AutoReadUnicode(Reader);
path = Helper.AutoReadUnicode(reader);
Console.WriteLine($"\nMFAName: {name}\nDescription: {description}\nPath: {path}");
Path = Helper.AutoReadUnicode(Reader);
Console.WriteLine($"\nMFAName: {Name}\nDescription: {Description}\nPath: {Path}");
stamp = reader.ReadBytes(reader.ReadInt32());
Stamp = Reader.ReadBytes(Reader.ReadInt32());
if (reader.ReadAscii(4) != "ATNF")
if (Reader.ReadAscii(4) != "ATNF")
{
throw new Exception("Invalid Font Bank");
}
fonts = new FontBank(reader);
fonts.Read();
Console.WriteLine("FONTS: " + fonts.numberOfItems);
Fonts = new FontBank(Reader);
Fonts.Read();
Console.WriteLine("FONTS: " + Fonts.NumberOfItems);
if (reader.ReadAscii(4) != "APMS")
if (Reader.ReadAscii(4) != "APMS")
{
throw new Exception("Invalid Sound Bank");
}
sounds = new SoundBank(reader);
sounds.isCompressed = false;
sounds.Read();
Sounds = new SoundBank(Reader);
Sounds.IsCompressed = false;
Sounds.Read();
if (reader.ReadAscii(4) != "ASUM")
if (Reader.ReadAscii(4) != "ASUM")
{
throw new Exception("Invalid Music Bank");
}
music = new MusicBank(reader);
music.Read();
Music = new MusicBank(Reader);
Music.Read();
if (reader.ReadAscii(4) != "AGMI")
if (Reader.ReadAscii(4) != "AGMI")
{
throw new Exception("Invalid Icon Bank");
}
var icons = new AGMIBank(reader);
var icons = new AgmiBank(Reader);
icons.Read();
if (reader.ReadAscii(4) != "AGMI")
if (Reader.ReadAscii(4) != "AGMI")
{
throw new Exception("Invalid Image Bank");
}
var images = new AGMIBank(reader);
var images = new AgmiBank(Reader);
images.Read();
if (Helper.AutoReadUnicode(reader) != name) throw new Exception("Invalid name");
if (Helper.AutoReadUnicode(Reader) != Name) throw new Exception("Invalid name");
author = Helper.AutoReadUnicode(reader);
Author = Helper.AutoReadUnicode(Reader);
var newDesc = Helper.AutoReadUnicode(reader);
if ( newDesc!= description) throw new Exception("Invalid description: "+newDesc);
var newDesc = Helper.AutoReadUnicode(Reader);
if ( newDesc!= Description) throw new Exception("Invalid description: "+newDesc);
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);
reader.ReadInt32();
var commandLine = Helper.AutoReadUnicode(reader);
var aboutbox = Helper.AutoReadUnicode(reader);
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);
Reader.ReadInt32();
var commandLine = Helper.AutoReadUnicode(Reader);
var aboutbox = Helper.AutoReadUnicode(Reader);
Console.WriteLine(aboutbox);
reader.ReadInt32();
var binCount = reader.ReadInt32();//wtf i cant put it in loop fuck shit
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
Reader.ReadBytes(Reader.ReadInt32());//binaryfiles
}
var controls = new mmfparser.mfaloaders.Controls(reader);
var controls = new mmfparser.mfaloaders.Controls(Reader);
controls.Read();
var menuSize = reader.ReadUInt32();
var currentPosition = reader.Tell();
var menu = new AppMenu(reader);
var menuSize = Reader.ReadUInt32();
var currentPosition = Reader.Tell();
var menu = new AppMenu(Reader);
menu.Read();
reader.Seek(menuSize + currentPosition);
Reader.Seek(menuSize + currentPosition);
var windowMenuIndex = reader.ReadInt32();
var windowMenuIndex = Reader.ReadInt32();
int[] menuImages = new int[65535];//govnokod suka
var MICount = reader.ReadInt32();
for (int i = 0; i < MICount; i++)
var miCount = Reader.ReadInt32();
for (int i = 0; i < miCount; i++)
{
var id = reader.ReadInt32();
menuImages[id] = reader.ReadInt32();
var id = Reader.ReadInt32();
menuImages[id] = Reader.ReadInt32();
}
globalValues = new ValueList(reader);
globalValues.Read();
globalStrings = new ValueList(reader);
globalStrings.Read();
var globalEvents = reader.ReadBytes(reader.ReadInt32());
var graphicMode = reader.ReadInt32();;
GlobalValues = new ValueList(Reader);
GlobalValues.Read();
GlobalStrings = new ValueList(Reader);
GlobalStrings.Read();
var globalEvents = Reader.ReadBytes(Reader.ReadInt32());
var graphicMode = Reader.ReadInt32();;
var icoCount = reader.ReadInt32();
var icoCount = Reader.ReadInt32();
for (int i = 0; i < icoCount; i++)
{
reader.ReadInt32();
Reader.ReadInt32();
}
var qualCount = reader.ReadInt32();
var qualCount = Reader.ReadInt32();
for (int i = 0; i < qualCount; i++)//qualifiers
{
var nameQ = reader.ReadAscii(reader.ReadInt32());
var handleQ = reader.ReadInt32();
var nameQ = Reader.ReadAscii(Reader.ReadInt32());
var handleQ = Reader.ReadInt32();
}
var extCount = reader.ReadInt32();
var extCount = Reader.ReadInt32();
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 handleE = Reader.ReadInt32();
var filenameE = Helper.AutoReadUnicode(Reader);
var nameE = Helper.AutoReadUnicode(Reader);
var magicE = Reader.ReadInt32();
var subType = Reader.ReadBytes(Reader.ReadInt32());
}
List<int> frameOffsets = new List<int>();
var offCount = reader.ReadInt32();
var offCount = Reader.ReadInt32();
for (int i = 0; i < offCount; i++)
{
frameOffsets.Add(reader.ReadInt32());
frameOffsets.Add(Reader.ReadInt32());
}
var nextOffset = reader.ReadInt32();
var nextOffset = Reader.ReadInt32();
foreach (var item in frameOffsets)
{
reader.Seek(item);
var testframe = new Frame(reader);
Reader.Seek(item);
var testframe = new Frame(Reader);
testframe.Read();
}
reader.Seek(nextOffset);
var chunks = new ChunkList(reader);
Reader.Seek(nextOffset);
var chunks = new ChunkList(Reader);
chunks.Read();
return;
@ -275,7 +275,7 @@ namespace NetMFAPatcher.mfa
}
public MFA(ByteIO reader) : base(reader)
public Mfa(ByteIO reader) : base(reader)
{
}

@ -12,7 +12,7 @@ namespace NetMFAPatcher.MMFParser.Data
{
public class PackData
{
public PackFile[] items;
public PackFile[] Items;
public PackData()
{
@ -23,14 +23,14 @@ namespace NetMFAPatcher.MMFParser.Data
byte[] header = exeReader.ReadBytes(8);
exeReader.Skip(8);
uint header_size = exeReader.ReadUInt32();
uint data_size = exeReader.ReadUInt32();
uint headerSize = exeReader.ReadUInt32();
uint dataSize = exeReader.ReadUInt32();
exeReader.Seek((int)(start + data_size - 32));
exeReader.Seek((int)(start + dataSize - 32));
exeReader.Skip(4);
exeReader.Seek(start + 16);
uint format_version = exeReader.ReadUInt32();
uint formatVersion = exeReader.ReadUInt32();
exeReader.Skip(8);
uint count = exeReader.ReadUInt32();
@ -48,7 +48,7 @@ namespace NetMFAPatcher.MMFParser.Data
if (!exeReader.Check(value)) break;
}
exeReader.BaseStream.Position -= 5;//wtf lol
header = exeReader.ReadFourCC();
header = exeReader.ReadFourCc();
exeReader.Seek(offset);
for (int i = 0; i < count; i++) new PackFile().Read(exeReader);
@ -60,24 +60,24 @@ namespace NetMFAPatcher.MMFParser.Data
}
public class PackFile
{
string PackFilename = "ERROR";
int bingo = 0;
byte[] data;
string _packFilename = "ERROR";
int _bingo = 0;
byte[] _data;
public void Read(ByteIO exeReader)
{
UInt16 len = exeReader.ReadUInt16();
PackFilename = exeReader.ReadWideString(len);
bingo = exeReader.ReadInt32();
data = exeReader.ReadBytes(exeReader.ReadInt32());
_packFilename = exeReader.ReadWideString(len);
_bingo = exeReader.ReadInt32();
_data = exeReader.ReadBytes(exeReader.ReadInt32());
Dump();
}
public void Dump()
{
Logger.Log($"Dumping {PackFilename}", true, ConsoleColor.DarkBlue);
string path = $"{Program.DumpPath}\\extensions\\" + PackFilename;
File.WriteAllBytes(path, data);
Logger.Log($"Dumping {_packFilename}", true, ConsoleColor.DarkBlue);
string path = $"{Program.DumpPath}\\extensions\\" + _packFilename;
File.WriteAllBytes(path, _data);
}
}

@ -1,6 +1,4 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.Utils;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.IO;
using System.Collections;
@ -15,111 +13,109 @@ namespace NetMFAPatcher
{
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 string Path = ""; //TODO: Make Selectable
public static string GameName;// = Path.GetFileNameWithoutExtension(path);
public static string DumpPath;// = $"DUMP\\{GameName}";
public static string GameName; // = Path.GetFileNameWithoutExtension(path);
public static string DumpPath; // = $"DUMP\\{GameName}";
public static bool doMFA=false;
public static bool DoMfa = false;
public static bool DumpImages = false;
public static bool DumpSounds = false;
public static bool verbose;
public static bool Verbose;
public static bool LogAll=false;
public static bool UseGUI = false;
public static bool LogAll = false;
public static bool UseGui = false;
[STAThread]
static void Main(string[] args)
{
string Path="";
bool Verbose=false;
bool DumpImages=true;
bool DumpSounds=true;
if(args.Length==0)
string path = "";
bool verbose = false;
bool dumpImages = true;
bool dumpSounds = true;
if (args.Length == 0)
{
UseGUI = true;
UseGui = true;
var form = new MainForm();
Application.Run(form);
}
if (args.Length > 0)
{
Path = args[0];
path = args[0];
}
if (args.Length > 1)
{
Boolean.TryParse(args[1],out Verbose);
Boolean.TryParse(args[1], out verbose);
}
if (args.Length > 2)
{
Boolean.TryParse(args[2],out DumpImages);
Boolean.TryParse(args[2], out dumpImages);
}
if(args.Length>3)
if (args.Length > 3)
{
Boolean.TryParse(args[3],out DumpSounds);
Boolean.TryParse(args[3], out dumpSounds);
}
if(args[0]=="-h"||args[0]=="-help")
if (args.Length > 0 && (args[0] == "-h" || args[0] == "-help"))
{
Logger.Log($"DotNetCTFDumper: 0.0.5",true,ConsoleColor.Green);
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, ConsoleColor.Green);
Logger.Log($"Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false 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,
ConsoleColor.Green);
Logger.Log($"Exaple: DotNetCTFDumper.exe E:\\SisterLocation.exe true true false true", true,
ConsoleColor.Green);
Console.ReadKey();
Environment.Exit(0);
}
if(args.Length>0) ReadFile(Path, Verbose, DumpImages, DumpSounds);
if (args.Length > 0) ReadFile(path, verbose, dumpImages, dumpSounds);
}
public static void ReadFile(string path,bool verbose=false,bool dumpImages=false,bool dumpSounds=true)
public static void ReadFile(string path, bool verbose = false, bool dumpImages = false, bool dumpSounds = true)
{
GameName = Path.GetFileNameWithoutExtension(path);
GameName = System.IO.Path.GetFileNameWithoutExtension(path);
DumpPath = $"DUMP\\{GameName}";
PrepareFolders();
DumpImages = dumpImages;
DumpSounds = dumpSounds;
Program.verbose = verbose;
Program.Verbose = verbose;
if (File.Exists(path))
{
if (path.EndsWith(".exe"))
{
doMFA = false;
DoMfa = false;
ByteIO exeReader = new ByteIO(path, FileMode.Open);
EXE currentEXE = new EXE();
currentEXE.ParseExe(exeReader);
Exe currentExe = new Exe();
currentExe.ParseExe(exeReader);
Logger.Log("Finished!", true, ConsoleColor.Yellow);
if(!UseGUI) Console.ReadKey();
if (!UseGui) Console.ReadKey();
}
else if (path.EndsWith(".mfa"))
{
doMFA = true;
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);
var mfa = new Mfa(mfaReader);
mfa.Read();
Console.WriteLine("Writing");
var MFAWriter = new ByteWriter("out.mfa",FileMode.Create);
mfa.Write(MFAWriter);
var mfaWriter = new ByteWriter("out.mfa", FileMode.Create);
mfa.Write(mfaWriter);
Console.ReadKey();
}
else
@ -129,14 +125,10 @@ namespace NetMFAPatcher
}
else
{
Logger.Log($"File '{path}' does not exist",true,ConsoleColor.Red);
Logger.Log($"File '{path}' does not exist", true, ConsoleColor.Red);
}
}
public static void PrepareFolders()
{
Directory.CreateDirectory($"{DumpPath}\\CHUNKS\\OBJECTINFO");
@ -146,7 +138,5 @@ namespace NetMFAPatcher
Directory.CreateDirectory($"{DumpPath}\\SoundBank");
Directory.CreateDirectory($"{DumpPath}\\extensions");
}
}
}

@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace NetMFAPatcher.utils
{
public class BitDict
{
private String[] Keys;
public UInt32 flag { get; set; }
public BitDict(String[] keys)
{
Keys = keys;
}
public bool this[String key]
{
get => GetFlag(key);
}
public bool GetFlag(String key)
{
Int32 pos = Array.IndexOf(Keys, key);
if (pos >= 0)
{
return (flag & ((UInt32) Math.Pow(2, pos))) != 0;
}
return false;
}
public static string ToDebugString<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
{
return "{" + string.Join(",", dictionary.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}";
}
public override string ToString()
{
Dictionary<String, bool> actualKeys = new Dictionary<string, bool>();
foreach (var key in Keys)
{
actualKeys[key] = this[key];
}
return ToDebugString(actualKeys);
}
}
}

@ -8,12 +8,11 @@ namespace NetMFAPatcher.utils
{
public static class ByteFlag
{
public static bool getFlag(int flagbyte,int pos)
public static bool GetFlag(UInt32 flagbyte, int pos)
{
var mask = Math.Pow(2, pos);
var result = flagbyte & (int)mask;
UInt32 mask = (uint) (2 << pos);
UInt32 result = flagbyte & mask;
return result == mask;
}
}
}
}

@ -36,7 +36,7 @@ namespace NetMFAPatcher.Utils
{
BaseStream.Seek(count, SeekOrigin.Current);
}
public byte[] ReadFourCC()
public byte[] ReadFourCc()
{
return Encoding.UTF8.GetBytes(ReadAscii(4));
}
@ -56,7 +56,7 @@ namespace NetMFAPatcher.Utils
return Size() - Tell() >= size;
}
public bool eof()
public bool Eof()
{
return BaseStream.Position < BaseStream.Length;
}

@ -53,7 +53,7 @@ namespace NetMFAPatcher.Utils
return Size() - Tell() >= size;
}
public bool eof()
public bool Eof()
{
return BaseStream.Position < BaseStream.Length;
}

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
namespace NetMFAPatcher.Utils
{
@ -6,37 +7,36 @@ namespace NetMFAPatcher.Utils
{
public static byte[] Decompress(ByteIO exeReader)
{
Int32 decomp_size = exeReader.ReadInt32();
Int32 comp_size = exeReader.ReadInt32();
return decompress_block(exeReader, comp_size, decomp_size);
Int32 decompSize = exeReader.ReadInt32();
Int32 compSize = exeReader.ReadInt32();
return decompress_block(exeReader, compSize, decompSize);
}
public static ByteIO DecompressAsReader(ByteIO exeReader)
{
Int32 decomp_size = exeReader.ReadInt32();
Int32 comp_size = exeReader.ReadInt32();
byte[] compressedData = exeReader.ReadBytes(comp_size);
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);
return new ByteIO(actualData);
}
public static byte[] decompress_block(ByteIO reader,int size,int decomp_size)
public static byte[] decompress_block(ByteIO reader, int size, int decompSize)
{
byte[] compressedData = reader.ReadBytes(size);
byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
return actualData;
}
public static ByteIO decompress_asReader(ByteIO image_data, int v, int decompressed_size)
public static ByteIO decompress_asReader(ByteIO imageData, int v, int decompressedSize)
{
return new ByteIO(decompress_block(image_data, v, decompressed_size));
return new ByteIO(decompress_block(imageData, v, decompressedSize));
}
internal static byte[] decompress_block(ByteIO data, uint compressed_size, uint decompressedSize)
internal static byte[] decompress_block(ByteIO data, uint compressedSize, uint decompressedSize)
{
throw new NotImplementedException();
}
}
}
}

@ -13,69 +13,69 @@ namespace NetMFAPatcher.utils
{
public static byte[] DecryptionKey;
public static byte MagicChar=54;
public static void MakeKey(string STitle, string SCopyright,string SProject)
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);
var RawKeyPTR = Marshal.StringToHGlobalAnsi(RawKey);
var rawKey = "";
rawKey += sTitle;
rawKey += sCopyright;
rawKey += sProject;
Logger.Log("Combined data "+rawKey,true,ConsoleColor.Yellow);
var rawKeyPtr = Marshal.StringToHGlobalAnsi(rawKey);
var ptr = Decryption.make_key_combined(RawKeyPTR, MagicChar);
var ptr = Decryption.make_key_combined(rawKeyPtr, MagicChar);
byte[] Key = new byte[257];
Marshal.Copy(ptr, Key, 0, 256);
Marshal.FreeHGlobal(RawKeyPTR);
byte[] key = new byte[257];
Marshal.Copy(ptr, key, 0, 256);
Marshal.FreeHGlobal(rawKeyPtr);
DecryptionKey = Key;
DecryptionKey = key;
Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}",true,ConsoleColor.Yellow);
File.WriteAllBytes($"{Program.DumpPath}\\key.bin", DecryptionKey);
}
public static byte[] DecodeMode3(byte[] ChunkData, int ChunkSize,int ChunkID)
public static byte[] DecodeMode3(byte[] chunkData, int chunkSize,int chunkId)
{
var reader = new ByteIO(ChunkData);
var DecompressedSize = reader.ReadUInt32();
var reader = new ByteIO(chunkData);
var decompressedSize = reader.ReadUInt32();
var chunkData = reader.ReadBytes((int)reader.Size());
if (ChunkID % 2 != 0)
var rawData = reader.ReadBytes((int)reader.Size());
if (chunkId % 2 != 0)
{
chunkData[0] ^= (byte)(((byte)ChunkID & 0xFF) ^ ((byte)ChunkID >> 0x8));
rawData[0] ^= (byte)(((byte)chunkId & 0xFF) ^ ((byte)chunkId >> 0x8));
}
var rawData = DecodeChunk(chunkData, ChunkSize);
rawData = DecodeChunk(rawData, chunkSize);
var data = new ByteIO(rawData);
var compressed_size = data.ReadUInt32();
var compressedSize = data.ReadUInt32();
return Decompressor.decompress_block(data, (int)compressed_size, (int)DecompressedSize);
return Decompressor.decompress_block(data, (int)compressedSize, (int)decompressedSize);
}
public static byte[] DecodeChunk(byte[] ChunkData, int ChunkSize)
public static byte[] DecodeChunk(byte[] chunkData, int chunkSize)
{
IntPtr InputChunkPtr = Marshal.AllocHGlobal(ChunkData.Length);
Marshal.Copy(ChunkData, 0, InputChunkPtr, ChunkData.Length);
IntPtr inputChunkPtr = Marshal.AllocHGlobal(chunkData.Length);
Marshal.Copy(chunkData, 0, inputChunkPtr, chunkData.Length);
IntPtr KeyPtr = Marshal.AllocHGlobal(DecryptionKey.Length);
Marshal.Copy(DecryptionKey, 0, KeyPtr, DecryptionKey.Length);
IntPtr keyPtr = Marshal.AllocHGlobal(DecryptionKey.Length);
Marshal.Copy(DecryptionKey, 0, keyPtr, DecryptionKey.Length);
var OutputChunkPtr = decode_chunk(InputChunkPtr, ChunkSize, MagicChar, KeyPtr);
var outputChunkPtr = decode_chunk(inputChunkPtr, chunkSize, MagicChar, keyPtr);
byte[] DecodedChunk = new byte[ChunkSize];
Marshal.Copy(OutputChunkPtr, DecodedChunk,0,ChunkSize);
byte[] decodedChunk = new byte[chunkSize];
Marshal.Copy(outputChunkPtr, decodedChunk,0,chunkSize);
Marshal.FreeHGlobal(InputChunkPtr);
Marshal.FreeHGlobal(KeyPtr);
Marshal.FreeHGlobal(inputChunkPtr);
Marshal.FreeHGlobal(keyPtr);
return DecodedChunk;
return decodedChunk;
}
[DllImport("Decrypter-x64.dll", EntryPoint = "decode_chunk", CharSet = CharSet.Auto)]
public static extern IntPtr decode_chunk(IntPtr chunk_data, int chunk_size, byte magic_char,IntPtr wrapper_key);
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 c_title, IntPtr c_copyright, IntPtr c_project, byte magic_char);
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 magic_char);
public static extern IntPtr make_key_combined(IntPtr data, byte magicChar);
}
}

@ -1,16 +1,12 @@
using mmfparser;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
namespace NetMFAPatcher
namespace NetMFAPatcher.utils
{
static class Helper
{
@ -31,18 +27,18 @@ namespace NetMFAPatcher
public static string Log(this byte[] bytes, bool log = true, string format = "")
{
string Temp = String.Empty;
string temp = String.Empty;
for (int i = 0; i < bytes.Length; i++)
{
var item = bytes[i];
if (i > 0)
{
Temp += " " + item.ToString(format);
temp += " " + item.ToString(format);
}
else
{
Temp += item.ToString(format);
temp += item.ToString(format);
}
}
@ -50,9 +46,9 @@ namespace NetMFAPatcher
{
Console.WriteLine(Temp);
Console.WriteLine(temp);
}
return Temp;
return temp;
}
@ -110,7 +106,7 @@ namespace NetMFAPatcher
if (b < 128 && b > 32) charAcc += Convert.ToChar(b);
else charAcc += '.';
}
var b_len = block.Count();
var bLen = block.Count();
//var accLen=

@ -5,39 +5,118 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
namespace NetMFAPatcher.utils
{
public static class ImageHelper
{
public static Color ReadPoint(byte[] data,int position)
public static (byte[], int) ReadPoint(byte[] data, int width, int height)
{
//byte b2 = binaryReader.ReadByte();
//byte b3 = binaryReader.ReadByte();
//byte b4 = binaryReader.ReadByte();
byte b2 = data[position];
byte b3 = data[position+1];
byte b4 = data[position+2];
return Color.FromArgb((int)b4, (int)b3, (int)b2);
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
int position = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
colorArray[(y * stride) + (x * 4) + 0] = data[position];
colorArray[(y * stride) + (x * 4) + 1] = data[position + 1];
colorArray[(y * stride) + (x * 4) + 2] = data[position + 2];
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 3;
}
position += pad * 3;
}
return (colorArray, position);
}
public static Color ReadSixteen(byte[] data, int position)
public static (byte[], int) ReadSixteen(byte[] data, int width, int height)
{
var newShort = (data[position] | data[position + 1] << 8);
byte r = (byte)((newShort & 31744) >> 10);
byte g = (byte)((newShort & 992) >> 5);
byte b = (byte)((newShort & 31));
return Color.FromArgb((int)b, (int)g, (int)r);
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
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 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);
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 2;
}
position += pad * 2;
}
return (colorArray, position);
}
public static int getPadding(int width, int pad = 2)
public static (byte[], int) ReadFifteen(byte[] data, int width, int height)
{
int num = pad - width * 3 % pad;
if (num == pad)
byte[] colorArray = new byte[width * height * 4];
int stride = width * 4;
int pad = GetPadding(width, 3);
int position = 0;
for (int y = 0; y < height; y++)
{
num = 0;
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 b = (byte) ((newShort & 31));
colorArray[(y * stride) + (x * 4) + 0] = (byte) (r << 3);
colorArray[(y * stride) + (x * 4) + 1] = (byte) (g << 3);
colorArray[(y * stride) + (x * 4) + 2] = (byte) (b << 3);
colorArray[(y * stride) + (x * 4) + 3] = 255;
position += 2;
}
position += pad * 2;
}
return (int)Math.Ceiling((double)((float)num / 3f));
return (colorArray, position);
}
public static byte[,] ReadAlpha(byte[] data, int width, int height, int possition)
{
int pad = GetPadding(width, 1, 4);
byte[,] alpha = new byte[width, height];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
alpha[j, i] = data[possition];
possition += 1;
}
possition += pad;
}
return alpha;
}
public static int GetPadding(int width, int pointSize, int bytes = 2)
{
int pad = bytes - ((width * pointSize) % bytes);
if (pad == bytes)
{
return 0;
}
return (int) Math.Ceiling((double) ((float) pad / (float) pointSize));
}
}
}
}

@ -9,17 +9,17 @@ namespace NetMFAPatcher.Utils
{
public static class Logger
{
static StreamWriter writer;
static StreamWriter _writer;
public static void Log(string text, bool logToScreen = true,ConsoleColor color = ConsoleColor.White)
{
if (writer == null)
if (_writer == null)
{
File.Delete("Dump.log");
writer = new StreamWriter("Dump.log", true);
writer.AutoFlush = true;
_writer = new StreamWriter("Dump.log", true);
_writer.AutoFlush = true;
}
writer.WriteLine(text);
_writer.WriteLine(text);
if (logToScreen)
{

@ -8,15 +8,15 @@ namespace NetMFAPatcher.mmfparser
{
public static class Constants
{
public static readonly string GAME_HEADER = "PAME";
public static readonly string UNICODE_GAME_HEADER = "PAMU";//"50 41 4D 55";
public static bool isUnicode;
public static readonly string GameHeader = "PAME";
public static readonly string UnicodeGameHeader = "PAMU";//"50 41 4D 55";
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
@ -44,9 +44,9 @@ namespace NetMFAPatcher.mmfparser
Score=5,
Lives = 6,
Counter=7,
RTF=8,
Rtf=8,
SubApplication=9,
INI=33,
Ini=33,
IniPp=32,
File=34,
TextEntry=35
@ -66,7 +66,7 @@ namespace NetMFAPatcher.mmfparser
GlobalEvents=8746,
FrameHandles=8747,
ExtData=8748,
Additional_Extension=8749,
AdditionalExtension=8749,
AppEditorFilename=8750,
AppTargetFilename=8751,
AppDoc=8752,
@ -83,7 +83,7 @@ namespace NetMFAPatcher.mmfparser
Copyright=8763,
GlobalValuesNames=8764,
GlobalStringNames=8765,
MVTexts=8766,
MvTexts=8766,
FrameItems2=8767,
ExeOnly=8768,
Protection=8770,
@ -109,7 +109,7 @@ namespace NetMFAPatcher.mmfparser
RandomSeed=13124,
FrameLayerEffects=13125,
BlurayFrameOptions=13126,
MVTimerBase=13127,
MvTimerBase=13127,
MosaicImageTable=13128,
FrameEffects=13129,
FrameIphoneOptions=13130,

@ -5,48 +5,49 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.mmfparser.mfaloaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class AppHeader : ChunkLoader
{
public int size;
public int windowWidth;
public int windowHeight;
public int initialScore;
public int initialLives;
public int numberOfFrames;
public int Size;
public int WindowWidth;
public int WindowHeight;
public int InitialScore;
public int InitialLives;
public int NumberOfFrames;
public override void Read()
{
reader = new ByteIO(chunk.chunk_data);
size = reader.ReadInt32();
var flags = reader.ReadInt16(); //raw,need convert
var new_flags = reader.ReadInt16(); //read flags or no balls
var graphics_mode = reader.ReadInt16(); //i am serious
var otherflags = reader.ReadInt16(); //last chance to get balls back
windowWidth = reader.ReadInt16();
windowHeight = reader.ReadInt16();
initialScore = (int) (reader.ReadUInt32() ^ 0xffffffff);
initialLives = (int) (reader.ReadUInt32() ^ 0xffffffff);
var controls = new Controls(reader);
Reader = new ByteIO(Chunk.ChunkData);
Size = Reader.ReadInt32();
var flags = Reader.ReadInt16(); //raw,need convert
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
WindowWidth = Reader.ReadInt16();
WindowHeight = Reader.ReadInt16();
InitialScore = (int) (Reader.ReadUInt32() ^ 0xffffffff);
InitialLives = (int) (Reader.ReadUInt32() ^ 0xffffffff);
var controls = new Controls(Reader);
controls.Read();
// controls.Print(false);
var borderColor = reader.ReadBytes(4);
numberOfFrames = reader.ReadInt32();
var frameRate = reader.ReadInt32();
var windowsMenuIndex = reader.ReadSByte();
var borderColor = Reader.ReadBytes(4);
NumberOfFrames = Reader.ReadInt32();
var frameRate = Reader.ReadInt32();
var windowsMenuIndex = Reader.ReadSByte();
}
public override void Print(bool ext)
{
Logger.Log($"ScreenRes: {windowWidth}x{windowHeight}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Score: {initialScore}, Lives: {initialLives}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Frame count: {numberOfFrames}", true, ConsoleColor.DarkMagenta);
Logger.Log($"ScreenRes: {WindowWidth}x{WindowHeight}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Score: {InitialScore}, Lives: {InitialLives}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Frame count: {NumberOfFrames}", true, ConsoleColor.DarkMagenta);
Logger.Log("");
}
@ -63,23 +64,22 @@ namespace NetMFAPatcher.chunkloaders
public class Controls:ChunkLoader
{
public List<PlayerControl> items;
ByteIO reader;
public List<PlayerControl> Items;
public Controls(ByteIO reader) : base(reader)
{
this.reader = reader;
this.Reader = reader;
}
public override void Read()
{
items = new List<PlayerControl>();
Items = new List<PlayerControl>();
for (int i = 0; i < 4; i++)
{
var item = new PlayerControl(reader);
items.Add(item);
var item = new PlayerControl(Reader);
Items.Add(item);
item.Read();
}
}
@ -87,7 +87,7 @@ namespace NetMFAPatcher.chunkloaders
public override void Print(bool ext)
{
Logger.Log("Controls: ",true,ConsoleColor.Yellow);
foreach (var item in items)
foreach (var item in Items)
{
item.Print();
}
@ -96,70 +96,70 @@ namespace NetMFAPatcher.chunkloaders
public class PlayerControl
{
int controlType = 0;
ByteIO reader;
Keys keys;
int _controlType = 0;
ByteIO _reader;
Keys _keys;
public PlayerControl(ByteIO reader)
{
this.reader = reader;
this._reader = reader;
}
public void Read()
{
keys = new Keys(reader);
controlType = reader.ReadInt16();
keys.Read();
_keys = new Keys(_reader);
_controlType = _reader.ReadInt16();
_keys.Read();
}
public void Print()
{
Logger.Log(" PlayerControl:", true, ConsoleColor.Yellow);
Logger.Log($" ControlType: {controlType}", true, ConsoleColor.Yellow);
keys.Print();
Logger.Log($" ControlType: {_controlType}", true, ConsoleColor.Yellow);
_keys.Print();
}
}
public class Keys
{
int up;
int down;
int left;
int right;
int button1;
int button2;
int button3;
int button4;
ByteIO reader;
int _up;
int _down;
int _left;
int _right;
int _button1;
int _button2;
int _button3;
int _button4;
ByteIO _reader;
public Keys(ByteIO reader)
{
this.reader = reader;
this._reader = reader;
}
public void Read()
{
up = reader.ReadInt16();
down = reader.ReadInt16();
left = reader.ReadInt16();
right = reader.ReadInt16();
button1 = reader.ReadInt16();
button2 = reader.ReadInt16();
button3 = reader.ReadInt16();
button4 = reader.ReadInt16();
_up = _reader.ReadInt16();
_down = _reader.ReadInt16();
_left = _reader.ReadInt16();
_right = _reader.ReadInt16();
_button1 = _reader.ReadInt16();
_button2 = _reader.ReadInt16();
_button3 = _reader.ReadInt16();
_button4 = _reader.ReadInt16();
}
public void Print()
{
Logger.Log($" Up: {up}", true, ConsoleColor.Yellow);
Logger.Log($" Down: {down}", true, ConsoleColor.Yellow);
Logger.Log($" Left: {left}", true, ConsoleColor.Yellow);
Logger.Log($" Right: {right}", true, ConsoleColor.Yellow);
Logger.Log($" Button1: {button1}", true, ConsoleColor.Yellow);
Logger.Log($" Button2: {button2}", true, ConsoleColor.Yellow);
Logger.Log($" Button3: {button3}", true, ConsoleColor.Yellow);
Logger.Log($" Button4: {button4}", true, ConsoleColor.Yellow);
Logger.Log($" Up: {_up}", true, ConsoleColor.Yellow);
Logger.Log($" Down: {_down}", true, ConsoleColor.Yellow);
Logger.Log($" Left: {_left}", true, ConsoleColor.Yellow);
Logger.Log($" Right: {_right}", true, ConsoleColor.Yellow);
Logger.Log($" Button1: {_button1}", true, ConsoleColor.Yellow);
Logger.Log($" Button2: {_button2}", true, ConsoleColor.Yellow);
Logger.Log($" Button3: {_button3}", true, ConsoleColor.Yellow);
Logger.Log($" Button4: {_button4}", true, ConsoleColor.Yellow);
}
}
}

@ -1,18 +1,18 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.utils;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class AppMenu : ChunkLoader
{
public List<AppMenuItem> items = new List<AppMenuItem>();
public List<AppMenuItem> Items = new List<AppMenuItem>();
public AppMenu(ByteIO reader) : base(reader)
{
}
@ -27,27 +27,27 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read()
{
var current_position = reader.Tell();
var header_size = reader.ReadUInt32();
var menu_offset = reader.ReadInt32();
var menu_size = reader.ReadInt32();
if (menu_size == 0) return;
var accel_offset = reader.ReadInt32();
var accel_size = reader.ReadInt32();
reader.Seek(current_position + menu_offset);
reader.Skip(4);
var currentPosition = Reader.Tell();
var headerSize = Reader.ReadUInt32();
var menuOffset = Reader.ReadInt32();
var menuSize = Reader.ReadInt32();
if (menuSize == 0) return;
var accelOffset = Reader.ReadInt32();
var accelSize = Reader.ReadInt32();
Reader.Seek(currentPosition + menuOffset);
Reader.Skip(4);
Load();
reader.Seek(current_position + accel_offset);
Reader.Seek(currentPosition + accelOffset);
for (int i = 0; i < accel_size/8; i++)
for (int i = 0; i < accelSize/8; i++)
{
reader.ReadByte();
reader.Skip(1);
reader.ReadInt16();
reader.ReadInt16();
reader.Skip(2);
Reader.ReadByte();
Reader.Skip(1);
Reader.ReadInt16();
Reader.ReadInt16();
Reader.Skip(2);
}
}
@ -55,11 +55,11 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{
while(true)
{
var new_item = new AppMenuItem(reader);
new_item.Read();
items.Add(new_item);
var newItem = new AppMenuItem(Reader);
newItem.Read();
Items.Add(newItem);
if (new_item.name.Contains("About")) break;
if (newItem.Name.Contains("About")) break;
if (true)//ByteFlag.getFlag(new_item.flags,4))
{
Load();
@ -79,10 +79,10 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
}
public class AppMenuItem : ChunkLoader
{
public string name = "";
public int flags = 0;
public int id = 0;
public string mnemonic = "";
public string Name = "";
public int Flags = 0;
public int Id = 0;
public string Mnemonic = "";
public AppMenuItem(ByteIO reader) : base(reader)
{
}
@ -97,24 +97,24 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read()
{
var flags = reader.ReadInt16();
if (!ByteFlag.getFlag(flags,4))
uint flags = (uint) Reader.ReadInt16();
if (!ByteFlag.GetFlag(flags,4))
{
id = reader.ReadInt16();
Id = Reader.ReadInt16();
}
name = reader.ReadWideString();
Name = Reader.ReadWideString();
for (int i = 0; i < name.Length; i++)
for (int i = 0; i < Name.Length; i++)
{
if(name[i]=='&')
if(Name[i]=='&')
{
mnemonic = name[i + 1].ToString().ToUpper();
Mnemonic = Name[i + 1].ToString().ToUpper();
}
name = name.Replace("&", "");
Name = Name.Replace("&", "");
}
Console.WriteLine(name);
Console.WriteLine(Name);
}
public void Load()
{

@ -1,28 +1,22 @@
using NetMFAPatcher.mfa;
using NetMFAPatcher.Utils;
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.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public abstract class ChunkLoader//:DataLoader
{
public Chunk chunk;
public ByteIO reader;
public bool verbose = false;
public Chunk Chunk;
public ByteIO Reader;
public bool Verbose = false;
protected ChunkLoader(ByteIO reader)
{
this.reader = reader;
this.Reader = reader;
}
protected ChunkLoader(Chunk chunk)
{
this.chunk = chunk;
this.reader = chunk.get_reader();
this.Chunk = chunk;
this.Reader = chunk.get_reader();
}

@ -7,8 +7,9 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
class FrameName : StringChunk
{
@ -34,52 +35,51 @@ namespace NetMFAPatcher.chunkloaders
public class Frame : ChunkLoader
{
ByteIO reader;
public string name;
public string password;
public int width;
public int height;
public byte[] background;
public int flags;
public string Name;
public string Password;
public int Width;
public int Height;
public byte[] Background;
public int Flags;
public int CountOfObjs;
int top;
int bottom;
int left;
int right;
int _top;
int _bottom;
int _left;
int _right;
public override void Print(bool ext)
{
Logger.Log($"Frame: {name}", true, ConsoleColor.Green);
Logger.Log($" Password: {(password!=null ? password : "None")}", true, ConsoleColor.Green);
Logger.Log($" Size: {width}x{height}", true, ConsoleColor.Green);
Logger.Log($"Frame: {Name}", true, ConsoleColor.Green);
Logger.Log($" Password: {(Password!=null ? Password : "None")}", true, ConsoleColor.Green);
Logger.Log($" Size: {Width}x{Height}", true, ConsoleColor.Green);
Logger.Log($" Objects: {CountOfObjs}", true, ConsoleColor.Green);
Logger.Log($"-------------------------", true, ConsoleColor.Green);
}
public override void Read()
{
var FrameReader = new ByteIO(chunk.chunk_data);
var frameReader = new ByteIO(Chunk.ChunkData);
var chunks = new ChunkList();
chunks.verbose = false;
chunks.Read(FrameReader);
chunks.Verbose = false;
chunks.Read(frameReader);
var name = chunks.get_chunk<FrameName>();
if (name != null) //Just to be sure
{
this.name = name.value;
this.Name = name.Value;
}
var password = chunks.get_chunk<FramePassword>();
if (password != null) //Just to be sure
{
this.password = password.value;
this.Password = password.Value;
}
var header = chunks.get_chunk<FrameHeader>();
width = header.width;
height = header.height;
background = header.background;
flags = header.flags;
Width = header.Width;
Height = header.Height;
Background = header.Background;
Flags = header.Flags;
var objects = chunks.get_chunk<ObjectInstances>();
if(objects!=null)
{
@ -91,7 +91,7 @@ namespace NetMFAPatcher.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";
@ -115,10 +115,10 @@ namespace NetMFAPatcher.chunkloaders
class FrameHeader : ChunkLoader
{
public int width;
public int height;
public int flags;
public byte[] background;
public int Width;
public int Height;
public int Flags;
public byte[] Background;
public FrameHeader(ByteIO reader) : base(reader)
{
}
@ -134,10 +134,10 @@ namespace NetMFAPatcher.chunkloaders
public override void Read()
{
width = reader.ReadInt32();
height = reader.ReadInt32();
background = reader.ReadBytes(4);
flags = (int)reader.ReadUInt32();
Width = Reader.ReadInt32();
Height = Reader.ReadInt32();
Background = Reader.ReadBytes(4);
Flags = (int)Reader.ReadUInt32();
@ -147,7 +147,7 @@ namespace NetMFAPatcher.chunkloaders
{
public int CountOfObjects=0;
public List<ObjectInstances> items = new List<ObjectInstances>();
public List<ObjectInstances> Items = new List<ObjectInstances>();
public ObjectInstances(ByteIO reader) : base(reader)
{
@ -165,13 +165,13 @@ namespace NetMFAPatcher.chunkloaders
public override void Read()
{
CountOfObjects = (int)reader.ReadUInt32();
CountOfObjects = (int)Reader.ReadUInt32();
return;
for (int i = 0; i < CountOfObjects; i++)
{
var item = new ObjectInstances(reader);
var item = new ObjectInstances(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}

@ -1,19 +1,19 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data;
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 static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class FrameItems : ChunkLoader
{
public Dictionary<int, ObjectInfo> ItemDict = new Dictionary<int, ObjectInfo>();
public List<string> names = new List<string>();
public List<string> Names = new List<string>();
public FrameItems(Chunk chunk) : base(chunk) { }
public FrameItems(ByteIO reader) : base(reader) { }
public override void Print(bool ext)
@ -23,18 +23,18 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Read()
{
var count = reader.ReadInt32();
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new ObjectInfo(reader);
item.verbose = false;
var item = new ObjectInfo(Reader);
item.Verbose = false;
item.Read();
ItemDict.Add(item.handle, item);
names.Add(item.name);
ItemDict.Add(item.Handle, item);
Names.Add(item.Name);
//Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
}
GameData.testItems = this;
GameData.TestItems = this;
}
}

@ -1,68 +1,69 @@
using NetMFAPatcher.chunkloaders;
using System;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System.Collections.Generic;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class ObjectInfo : ChunkLoader
{
public List<Chunk> chunks = new List<Chunk>();
public int properties = 0;
public string name = "ERROR";
public int handle;
public int objectType;
public int flags;
public bool transparent;
public bool antialias;
public int inkEffect;
public int inkEffectValue;
public int shaderId;
public int items;
public ObjectInfo(Chunk chunk) : base(chunk) { }
public ObjectInfo(ByteIO reader) : base(reader) { }
public List<Chunk> Chunks = new List<Chunk>();
public int Properties = 0;
public string Name = "ERROR";
public int Handle;
public int ObjectType;
public UInt32 Flags;
public bool Transparent;
public bool Antialias;
public int InkEffect;
public int InkEffectValue;
public int ShaderId;
public int Items;
public ObjectInfo(Chunk chunk) : base(chunk)
{
}
public ObjectInfo(ByteIO reader) : base(reader)
{
}
public override void Print(bool ext)
{
}
public override void Read()
{
var infoChunks = new ChunkList();
infoChunks.verbose = false;
infoChunks.Read(reader);
foreach (var chunk in infoChunks.chunks)
infoChunks.Verbose = false;
infoChunks.Read(Reader);
foreach (var infoChunk in infoChunks.Chunks)
{
chunk.verbose = false;
var loader = chunk.loader;
if(loader is ObjectName)
infoChunk.Verbose = false;
var loader = infoChunk.Loader;
if (loader is ObjectName)
{
var actualLoader = infoChunks.get_loader<ObjectName>(loader);
name = actualLoader.value;
Name = actualLoader.Value;
}
else if(loader is ObjectHeader)
else if (loader is ObjectHeader)
{
var actualLoader = infoChunks.get_loader<ObjectHeader>(loader);
handle = actualLoader.handle;
objectType = actualLoader.objectType;
flags = actualLoader.flags;
var inkEffect = actualLoader.inkEffect;
transparent = ByteFlag.getFlag(inkEffect, 28);
antialias = ByteFlag.getFlag(inkEffect, 29);
}
Handle = actualLoader.Handle;
ObjectType = actualLoader.ObjectType;
Flags = actualLoader.Flags;
UInt32 inkEffect = actualLoader.InkEffect;
Transparent = ByteFlag.GetFlag(inkEffect, 28);
Antialias = ByteFlag.GetFlag(inkEffect, 29);
}
}
}
}
class ObjectName : StringChunk
{
public ObjectName(ByteIO reader) : base(reader)
@ -73,13 +74,15 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{
}
}
class ObjectHeader : ChunkLoader
{
public int handle;
public int objectType;
public int flags;
public int inkEffect;
public int inkEffectParameter;
public Int16 Handle;
public Int16 ObjectType;
public UInt32 Flags;
public UInt32 InkEffect;
public UInt32 InkEffectParameter;
public ObjectHeader(ByteIO reader) : base(reader)
{
}
@ -90,18 +93,16 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
public override void Print(bool ext)
{
}
public override void Read()
{
handle = reader.ReadInt16();
objectType = reader.ReadInt16();
flags = reader.ReadUInt16();
var reserved = reader.ReadInt16();
inkEffect = (int)reader.ReadUInt32();
inkEffectParameter = (int)reader.ReadUInt32();
Handle = Reader.ReadInt16();
ObjectType = Reader.ReadInt16();
Flags = Reader.ReadUInt16();
Int16 reserved = Reader.ReadInt16();
InkEffect = Reader.ReadUInt32();
InkEffectParameter = Reader.ReadUInt32();
}
}
}
}

@ -5,24 +5,25 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
class StringChunk : ChunkLoader
{
public string value;
public string Value;
public override void Read()
{
reader = new ByteIO(chunk.chunk_data);
value = reader.ReadWideString();
Reader = new ByteIO(Chunk.ChunkData);
Value = Reader.ReadWideString();
}
public override void Print(bool ext)
{
Logger.Log($"{chunk.name} contains: {value}\n",true,ConsoleColor.DarkCyan);
Logger.Log($"{Chunk.Name} contains: {Value}\n",true,ConsoleColor.DarkCyan);
}

@ -1,194 +0,0 @@
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class DebugImageBank : ChunkLoader
{
Dictionary<int, DebugImageItem> images = new Dictionary<int, DebugImageItem>();
public DebugImageBank(ByteIO reader) : base(reader)
{
}
public DebugImageBank(Chunk chunk) : base(chunk)
{
}
public override void Print(bool ext)
{
}
public override void Read()
{
reader = new ByteIO(chunk.chunk_data);
var number_of_items = reader.ReadUInt32();
Console.WriteLine($"Found {number_of_items} images");
for (int i = 0; i < number_of_items; i++)
{
var item = new DebugImageItem(reader);
item.Read();
item.handle -= 1;
//images[item.handle] = item;
}
}
}
class DebugImageItem : ChunkLoader
{
public int handle;
int position;
int checksum;
int references;
int width;
int height;
int graphic_mode;
int x_hotspot;
int y_hotspot;
int action_x;
int action_y;
public int flags;
public int size;
//tranparent,add later
int indexed;
byte[] image;
byte[] alpha;
ByteIO image_data;
public bool isCompressed = true;
public override void Read()
{
handle = reader.ReadInt32();
position = (int)reader.Tell();
if (!Program.DumpImages) return;
Save($"{Program.DumpPath}\\ImageBank\\{handle}.png");
}
public void Save(string filename)
{
Bitmap result;
var image_data = Decompressor.DecompressAsReader(reader);
using (ByteIO binaryReader = image_data)
{
int num = 0;
byte b = 0;
short num2;
short num3;
if (true)
{
binaryReader.ReadInt32();
binaryReader.ReadInt32();
num = (int)binaryReader.ReadUInt32();
num2 = binaryReader.ReadInt16();
num3 = binaryReader.ReadInt16();
graphic_mode = binaryReader.ReadByte();
b = (byte)binaryReader.ReadSByte();
binaryReader.BaseStream.Position += 2;
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadInt16();
binaryReader.ReadByte();
binaryReader.ReadByte();
binaryReader.ReadByte();
binaryReader.ReadByte();
}
var colorSize = 3;
Bitmap bitmap = new Bitmap((int)num2, (int)num3);
Color[,] array = new Color[(int)num2, (int)num3];
int num4 = ImageHelper.getPadding((int)num2, 2);
int num5 = 0;
for (int i = 0; i < (int)num3; i++)
{
for (int j = 0; j < (int)num2; j++)
{
byte[] colorData=null;
if(graphic_mode==4)
{
colorSize = 3;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadPoint(colorData, 0);
}
else
{
colorSize = 2;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadSixteen(colorData, 0);
}
num5 += 3;
}
binaryReader.ReadBytes(num4 * 3);
num5 += num4 * 3;
}
int num6 = num - num5;
if (b == 16)
{
num4 = (num6 - (int)(num2 * num3)) / (int)num3;
for (int k = 0; k < (int)num3; k++)
{
for (int l = 0; l < (int)num2; l++)
{
byte b5 = binaryReader.ReadByte();
Color color = array[l, k];
array[l, k] = Color.FromArgb((int)b5, (int)color.R, (int)color.G, (int)color.B);
}
binaryReader.ReadBytes(num4);
}
}
for (int m = 0; m < (int)num3; m++)
{
for (int n = 0; n < (int)num2; n++)
{
bitmap.SetPixel(n, m, array[n, m]);
}
}
result = bitmap;
}
result.Save(filename);
}
public override void Print(bool ext)
{
}
public DebugImageItem(ByteIO reader) : base(reader)
{
}
public DebugImageItem(Chunk chunk) : base(chunk)
{
}
}
}

@ -1,30 +1,23 @@

using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
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.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
public class FontBank : ChunkLoader
{
public int numberOfItems;
public int NumberOfItems;
public override void Print(bool ext)
{
Logger.Log($"FontCount:{numberOfItems.ToString()}");
Logger.Log($"FontCount:{NumberOfItems.ToString()}");
}
public override void Read()
{
numberOfItems = reader.ReadInt32();
NumberOfItems = Reader.ReadInt32();
}
public void Write(ByteWriter writer)
{
writer.WriteInt32(numberOfItems);
writer.WriteInt32(NumberOfItems);
//i am testing with no fonts suck pinus haha
}

@ -1,22 +1,22 @@
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.utils;
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.Numerics;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Runtime.InteropServices;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Banks
{
public class ImageBank : ChunkLoader
{
Dictionary<int, ImageItem> images = new Dictionary<int, ImageItem>();
Dictionary<int, ImageItem> _images = new Dictionary<int, ImageItem>();
public ImageBank(ByteIO reader) : base(reader)
{
}
@ -24,212 +24,187 @@ namespace NetMFAPatcher.chunkloaders
public ImageBank(Chunk chunk) : base(chunk)
{
}
public override void Print(bool ext)
{
}
public override void Read()
{
reader = new ByteIO(chunk.chunk_data);
var number_of_items = reader.ReadUInt32();
if (!Program.DumpImages) return;
Console.WriteLine($"Found {number_of_items} images");
for (int i = 0; i < number_of_items; i++)
{
var item = new ImageItem(reader);
//item.isCompressed = false;
Reader = new ByteIO(Chunk.ChunkData);
var numberOfItems = Reader.ReadUInt32();
Console.WriteLine(@"Found {numberOfItems} images");
for (int i = 0; i < numberOfItems; i++)
{
var item = new ImageItem(Reader);
item.Read();
item.handle -= 1;
//images[item.handle] = item;
if (Program.DumpImages)
item.Save($"{Program.DumpPath}\\ImageBank\\" + item.Handle.ToString() + ".png");
if (Exe.LatestInst.GameData.ProductBuild >= 284)
item.Handle -= 1;
//images[item.handle] = item;
}
}
}
public class ImageItem : ChunkLoader
{
public int Handle;
int Position;
int _checksum;
int _references;
int _width;
int _height;
int _graphicMode;
int _xHotspot;
int _yHotspot;
int _actionX;
int _actionY;
BitDict Flags = new BitDict(new string[]
{
"RLE",
"RLEW",
"RLET",
"LZX",
"Alpha",
"ACE",
"Mac"
});
public int Size;
public int handle;
int position;
int checksum;
int references;
int width;
int height;
int graphic_mode;
int x_hotspot;
int y_hotspot;
int action_x;
int action_y;
public int flags;
public int size;
//tranparent,add later
int indexed;
byte[] image;
byte[] alpha;
ByteIO image_data;
byte[] _transparent;
byte[] _colorArray;
int _indexed;
public bool isCompressed = true;
public bool IsCompressed = true;
public override void Read()
{
handle = reader.ReadInt32();
position = (int)reader.Tell();
if (Program.DumpImages)
{
Load();
return;
}
else
{
if (isCompressed)
{
reader.Skip(8);
size = (int)reader.ReadUInt32();
reader.Skip(size + 20);
}
else
{
reader.Skip(4);
size = (int)reader.ReadUInt32();
reader.Seek(size + position);
}
}
Handle = Reader.ReadInt32();
Position = (int) Reader.Tell();
Load();
}
public void Load()
{
reader.Seek(position);
if (isCompressed)
Reader.Seek(Position);
ByteIO imageReader;
if (IsCompressed)
{
image_data = Decompressor.DecompressAsReader(reader);
imageReader = Decompressor.DecompressAsReader(Reader);
}
else
{
image_data = reader;
imageReader = Reader;
}
var start = image_data.Tell();
if (!isCompressed)
{
long start = imageReader.Tell();
_checksum = imageReader.ReadInt32();
_references = imageReader.ReadInt32();
Size = (int) imageReader.ReadUInt32();
if (!IsCompressed)
{
imageReader = new ByteIO(imageReader.ReadBytes(Size + 20));
}
checksum = image_data.ReadInt32();
references = image_data.ReadInt32();
size = (int)image_data.ReadUInt32();
if (!isCompressed)
_width = imageReader.ReadInt16();
_height = imageReader.ReadInt16();
_graphicMode = imageReader.ReadByte(); //Graphic mode is always 4 for SL
Flags.flag = imageReader.ReadByte();
imageReader.Skip(2);
_xHotspot = imageReader.ReadInt16();
_yHotspot = imageReader.ReadInt16();
_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;
if (Flags["LZX"])
{
image_data = new ByteIO(image_data.ReadBytes(size + 20));
throw new NotImplementedException();
imageData = new byte[1];
}
width = image_data.ReadInt16();
height = image_data.ReadInt16();
graphic_mode = image_data.ReadByte();//Graphic mode is always 4 for SL
flags = image_data.ReadByte();
image_data.Skip(2);
x_hotspot = image_data.ReadInt16();
y_hotspot = image_data.ReadInt16();
action_x = image_data.ReadInt16();
action_y = image_data.ReadInt16();
Logger.Log($"Size: {width}x{height}");
for (int i = 0; i < 4; i++)
else
{
image_data.ReadByte();
imageData = imageReader.ReadBytes((int) (imageReader.Size() - imageReader.Tell()));
}
//Save($"{Program.DumpPath}\\ImageBank\\" + handle.ToString() + ".png");
Save("cum.png");
return;
}
public void Save(string filename)
{
Bitmap bitmap = new Bitmap((int)width, (int)height);
Color[,] array = new Color[(int)width, (int)height];
int num4 = ImageHelper.getPadding((int)width, 2);
int num5 = 0;
using (ByteIO binaryReader = image_data)
int bytesRead = 0;
if (Flags["RLE"] || Flags["RLEW"] || Flags["RLET"])
{
}
else
{
int colorSize = 3;
for (int i = 0; i < (int)height; i++)
switch (_graphicMode)
{
for (int j = 0; j < (int)width; j++)
case 4:
{
byte[] colorData = null;
if (graphic_mode == 4)
{
colorSize = 3;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadPoint(colorData, 0);
}
else
{
colorSize = 2;
colorData = binaryReader.ReadBytes(colorSize);
array[j, i] = ImageHelper.ReadSixteen(colorData, 0);
}
num5 += 3;
(_colorArray, bytesRead) = ImageHelper.ReadPoint(imageData, _width, _height);
break;
}
binaryReader.ReadBytes(num4 * 3);
num5 += num4 * 3;
}
int num6 = size - num5;
if (flags == 16)
{
num4 = (num6 - (int)(width * height)) / (int)height;
for (int k = 0; k < (int)height; k++)
case 6:
{
for (int l = 0; l < (int)width; l++)
{
byte Calpha = binaryReader.ReadByte();
Color color = array[l, k];
array[l, k] = Color.FromArgb(Calpha, color.R, color.G, color.B);
}
binaryReader.ReadBytes(num4);
(_colorArray, bytesRead) = ImageHelper.ReadFifteen(imageData, _width, _height);
break;
}
case 7:
{
(_colorArray, bytesRead) = ImageHelper.ReadSixteen(imageData, _width, _height);
break;
}
}
for (int m = 0; m < (int)height; m++)
}
int alphaSize = Size - bytesRead;
if (Flags["Alpha"])
{
byte[,] alpha = ImageHelper.ReadAlpha(imageData, _width, _height, Size - alphaSize);
int stride = _width * 4;
for (int y = 0; y < _height; y++)
{
for (int n = 0; n < (int)width; n++)
for (int x = 0; x < _width; x++)
{
bitmap.SetPixel(n, m, array[n, m]);
_colorArray[(y * stride) + (x * 4) + 3] = alpha[x, y];
}
}
}
return;
}
public void Save(string filename)
{
using (var bmp = new Bitmap(_width, _height, PixelFormat.Format32bppArgb))
{
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0,
bmp.Width,
bmp.Height),
ImageLockMode.WriteOnly,
bmp.PixelFormat);
IntPtr pNative = bmpData.Scan0;
Marshal.Copy(_colorArray, 0, pNative, _colorArray.Length);
bmp.UnlockBits(bmpData);
bmp.Save(filename);
}
bitmap.Save(filename, ImageFormat.Png);
}
public override void Print(bool ext)
{
}
public ImageItem(ByteIO reader) : base(reader)
{
}
@ -241,7 +216,8 @@ namespace NetMFAPatcher.chunkloaders
public class TestPoint
{
public int size = 3;
public int Size = 3;
public (byte r, byte g, byte b) Read(byte[] data, int position)
{
byte r = 0;
@ -249,22 +225,16 @@ namespace NetMFAPatcher.chunkloaders
byte b = 0;
try
{
b = data[position];
g = data[position + 1];
r = data[position + 2];
}
catch
{
Console.WriteLine(position);
}
return (r, g, b);
}
}
}
}

@ -1,20 +1,14 @@
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;
using System.Collections.Generic;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
public class MusicBank : ChunkLoader
{
public int num_of_items = 0;
public int references = 0;
public List<MusicFile> items;
public int NumOfItems = 0;
public int References = 0;
public List<MusicFile> Items;
public override void Print(bool ext)
{
@ -23,13 +17,13 @@ namespace NetMFAPatcher.chunkloaders
public override void Read()
{
//Someone is using this lol?
items = new List<MusicFile>();
num_of_items = reader.ReadInt32();
for (int i = 0; i < num_of_items; i++)
Items = new List<MusicFile>();
NumOfItems = Reader.ReadInt32();
for (int i = 0; i < NumOfItems; i++)
{
var item = new MusicFile(reader);
var item = new MusicFile(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}
}
@ -44,9 +38,9 @@ namespace NetMFAPatcher.chunkloaders
public class MusicFile : ChunkLoader
{
public int handle;
public string name = "ERROR";
public byte[] data;
public int Handle;
public string Name = "ERROR";
public byte[] Data;
public override void Print(bool ext)
{

@ -1,21 +1,18 @@
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.mmfparser;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders.banks
{
public class SoundBank : ChunkLoader
{
public int num_of_items = 0;
public int references = 0;
public List<SoundItem> items;
public bool isCompressed = true;
public int NumOfItems = 0;
public int References = 0;
public List<SoundItem> Items;
public bool IsCompressed = true;
public override void Print(bool ext)
{
@ -24,22 +21,22 @@ namespace NetMFAPatcher.chunkloaders
public override void Read()
{
//Implementing for standalone-only because of my lazyness
items = new List<SoundItem>();
num_of_items = reader.ReadInt32();
Items = new List<SoundItem>();
NumOfItems = Reader.ReadInt32();
for (int i = 0; i < num_of_items; i++)
for (int i = 0; i < NumOfItems; i++)
{
var item = new SoundItem(reader);
item.isCompressed = isCompressed;
var item = new SoundItem(Reader);
item.IsCompressed = IsCompressed;
item.Read();
items.Add(item);
Items.Add(item);
}
}
public void Write(ByteWriter writer)
{
writer.WriteInt32(num_of_items);
foreach (var item in items)
writer.WriteInt32(NumOfItems);
foreach (var item in Items)
{
item.Write(writer);
}
@ -56,9 +53,9 @@ namespace NetMFAPatcher.chunkloaders
public class SoundBase : ChunkLoader
{
public int handle;
public string name = "ERROR";
public byte[] data;
public int Handle;
public string Name = "ERROR";
public byte[] Data;
public override void Print(bool ext)
{
@ -79,63 +76,63 @@ namespace NetMFAPatcher.chunkloaders
public class SoundItem : SoundBase
{
public bool compressed;
public int checksum;
public int references;
public int flags;
public bool isCompressed = true;
public bool Compressed;
public int Checksum;
public int References;
public int Flags;
public bool IsCompressed = true;
public override void Read()
{
var start = reader.Tell();
var start = Reader.Tell();
handle = (int) reader.ReadUInt32();
checksum = reader.ReadInt32();
references = reader.ReadInt32();
var decompressed_size = reader.ReadInt32();
flags = (int)reader.ReadUInt32(); //flags
var reserved = reader.ReadInt32();
var name_lenght = reader.ReadInt32();
ByteIO SoundData;
if (isCompressed) //compressed
Handle = (int) Reader.ReadUInt32();
Checksum = Reader.ReadInt32();
References = Reader.ReadInt32();
var decompressedSize = Reader.ReadInt32();
Flags = (int)Reader.ReadUInt32(); //flags
var reserved = Reader.ReadInt32();
var nameLenght = Reader.ReadInt32();
ByteIO soundData;
if (IsCompressed) //compressed
{
var size = reader.ReadInt32();
SoundData = new ByteIO(Decompressor.decompress_block(reader, size, decompressed_size));
var size = Reader.ReadInt32();
soundData = new ByteIO(Decompressor.decompress_block(Reader, size, decompressedSize));
}
else
{
SoundData = new ByteIO(reader.ReadBytes(decompressed_size));
soundData = new ByteIO(Reader.ReadBytes(decompressedSize));
}
if (isCompressed)
if (IsCompressed)
{
name = SoundData.ReadWideString(name_lenght);
Name = soundData.ReadWideString(nameLenght);
}
else
{
name = SoundData.ReadAscii(name_lenght);
Name = soundData.ReadAscii(nameLenght);
}
this.data = SoundData.ReadBytes((int) SoundData.Size());
name = Helper.CleanInput(name);
Console.WriteLine($"Dumping {name}");
this.Data = soundData.ReadBytes((int) soundData.Size());
Name = Helper.CleanInput(Name);
Console.WriteLine($"Dumping {Name}");
string path = $"{Program.DumpPath}\\SoundBank\\{name}.wav";
File.WriteAllBytes(path, data);
string path = $"{Program.DumpPath}\\SoundBank\\{Name}.wav";
File.WriteAllBytes(path, Data);
}
public void Write(ByteWriter writer)
{
writer.WriteUInt32((uint)handle);
writer.WriteInt32(checksum);
writer.WriteInt32(references);
writer.WriteInt32(data.Length+name.Length+1);
writer.WriteInt32(flags);
writer.WriteUInt32((uint)Handle);
writer.WriteInt32(Checksum);
writer.WriteInt32(References);
writer.WriteInt32(Data.Length+Name.Length+1);
writer.WriteInt32(Flags);
writer.WriteInt32(0);
writer.WriteInt32(name.Length+1);
if (isCompressed) writer.WriteUnicode(name);
else writer.WriteAscii(name);
writer.WriteBytes(data);
writer.WriteInt32(Name.Length+1);
if (IsCompressed) writer.WriteUnicode(Name);
else writer.WriteAscii(Name);
writer.WriteBytes(Data);

@ -8,13 +8,14 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class AppIcon:ChunkLoader
public class AppIcon : ChunkLoader
{
List<byte> points;
List<byte> _points;
public AppIcon(ByteIO reader) : base(reader)
@ -29,47 +30,40 @@ namespace NetMFAPatcher.chunkloaders
{
return;
Logger.Log("dumpingIcon");
reader.ReadBytes(reader.ReadInt32() - 4);
List<byte> color_indexes = new List<byte>();
for (int i = 0; i < 16*16; i++)
Reader.ReadBytes(Reader.ReadInt32() - 4);
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();
reader.ReadByte();
color_indexes.Add(r);
color_indexes.Add(g);
color_indexes.Add(b);
var b = Reader.ReadByte();
var g = Reader.ReadByte();
var r = Reader.ReadByte();
Reader.ReadByte();
colorIndexes.Add(r);
colorIndexes.Add(g);
colorIndexes.Add(b);
}
points = new List<byte>();
_points = new List<byte>();
for (int y = 0; y < 16; y++)
{
var x_list = new List<byte>();
var xList = new List<byte>();
for (int x = 0; x < 16; x++)
{
x_list.Add(color_indexes[reader.ReadByte()]);
xList.Add(colorIndexes[Reader.ReadByte()]);
}
//x_list.AddRange(points);
//points = x_list;
x_list.AddRange(points);
points = x_list;
xList.AddRange(_points);
_points = xList;
}
File.WriteAllBytes("fatcock.raw", points.ToArray());
File.WriteAllBytes("fatcock.raw", _points.ToArray());
}
public override void Print(bool ext)
{
}
}
}
}

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
{
class ChunkList : DataLoader//This is used for MFA reading/writing
{
List<DataLoader> items = new List<DataLoader>();
List<DataLoader> _items = new List<DataLoader>();
public override void Print()
{
throw new NotImplementedException();
@ -18,10 +18,10 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
var start = reader.Tell();
var start = Reader.Tell();
while(true)
{
var id = reader.ReadByte();
var id = Reader.ReadByte();
if(id==0) break;
Console.WriteLine("ChunkFound:"+id);

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
{
class Controls : DataLoader
{
public List<PlayerControl> items;
public List<PlayerControl> Items;
public Controls(ByteIO reader) : base(reader)
{
@ -24,12 +24,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
items = new List<PlayerControl>();
var count = reader.ReadInt32();
Items = new List<PlayerControl>();
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new mmfparser.mfaloaders.PlayerControl(reader);
items.Add(item);
var item = new mmfparser.mfaloaders.PlayerControl(Reader);
Items.Add(item);
item.Read();
}
}
@ -37,7 +37,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
class PlayerControl : DataLoader
{
int controlType;
int _controlType;
@ -54,19 +54,19 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
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();
_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();
for (int i = 0; i < 8; i++)
{
reader.ReadInt32();
Reader.ReadInt32();
}

@ -6,16 +6,17 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
{
class Frame : DataLoader
{
public string name = "ERROR";
public int sizeX;
public int sizeY;
public Color background;
public int maxObjects;
public string Name = "ERROR";
public int SizeX;
public int SizeY;
public Color Background;
public int MaxObjects;
public Frame(ByteIO reader) : base(reader)
{
@ -29,32 +30,32 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
var handle = reader.ReadInt32();
name = Helper.AutoReadUnicode(reader);
Console.WriteLine(name);
sizeX = reader.ReadInt32();
sizeY = reader.ReadInt32();
var background = reader.ReadColor();
var flags = reader.ReadInt32();
maxObjects = reader.ReadInt32();
var password = Helper.AutoReadUnicode(reader);
reader.Skip(4);
var lastViewedX = reader.ReadInt32();
var lastViewedY = reader.ReadInt32();
var paletteNum = reader.ReadInt32();
var handle = Reader.ReadInt32();
Name = Helper.AutoReadUnicode(Reader);
Console.WriteLine(Name);
SizeX = Reader.ReadInt32();
SizeY = Reader.ReadInt32();
var background = Reader.ReadColor();
var flags = Reader.ReadInt32();
MaxObjects = Reader.ReadInt32();
var password = Helper.AutoReadUnicode(Reader);
Reader.Skip(4);
var lastViewedX = Reader.ReadInt32();
var lastViewedY = Reader.ReadInt32();
var paletteNum = Reader.ReadInt32();
List<Color> palette = new List<Color>();
for (int i = 0; i < paletteNum; i++)
{
palette.Add(reader.ReadColor());
palette.Add(Reader.ReadColor());
}
var stampHandle = reader.ReadInt32();
var activeLayer = reader.ReadInt32();
var layersCunt = reader.ReadInt32();
var stampHandle = Reader.ReadInt32();
var activeLayer = Reader.ReadInt32();
var layersCunt = Reader.ReadInt32();
var layers = new List<Layer>();
for (int i = 0; i < layersCunt; i++)
{
var layer = new Layer(reader);
var layer = new Layer(Reader);
layer.Read();
layers.Add(layer);
@ -62,13 +63,13 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
//fadein
//fadeout
reader.Skip(2);
Reader.Skip(2);
var frameitems = new List<FrameItem>();
var frameitemsCount = reader.ReadInt32();
var frameitemsCount = Reader.ReadInt32();
for (int i = 0; i < frameitemsCount; i++)
{
var frameitem = new FrameItem(reader);
var frameitem = new FrameItem(Reader);
frameitem.Read();
frameitems.Add(frameitem);
//break;

@ -7,50 +7,51 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
{
class FrameItem : DataLoader
{
public int objectType;
public int handle;
public string name;
public bool transparent;
public int inkEffect;
public int inkEffectParameter;
public int antiAliasing;
public int flags;
public int iconType;
public int ObjectType;
public int Handle;
public string Name;
public bool Transparent;
public int InkEffect;
public int InkEffectParameter;
public int AntiAliasing;
public int Flags;
public int IconType;
public override void Print()
{
Console.WriteLine($"Name: {name}");
Console.WriteLine($"Name: {Name}");
}
public override void Read()
{
objectType = reader.ReadInt32();
handle = reader.ReadInt32();
name = Helper.AutoReadUnicode(reader);
var transparent1 = reader.ReadInt32();
ObjectType = Reader.ReadInt32();
Handle = Reader.ReadInt32();
Name = Helper.AutoReadUnicode(Reader);
var transparent1 = Reader.ReadInt32();
inkEffect = reader.ReadInt32();
inkEffectParameter = reader.ReadInt32();
antiAliasing = reader.ReadInt32();
InkEffect = Reader.ReadInt32();
InkEffectParameter = Reader.ReadInt32();
AntiAliasing = Reader.ReadInt32();
flags = reader.ReadInt32();
iconType = reader.ReadInt32();
if(iconType==1)
Flags = Reader.ReadInt32();
IconType = Reader.ReadInt32();
if(IconType==1)
{
var iconHandle = reader.ReadInt32();
var iconHandle = Reader.ReadInt32();
}
else
{
throw new NotImplementedException("invalid icon");
}
var chunks = new mmfparser.mfaloaders.ChunkList(reader);
var chunks = new mmfparser.mfaloaders.ChunkList(Reader);
chunks.Read();
if(objectType>=32)//extension base
if(ObjectType>=32)//extension base
{
//swallow some cum
@ -58,7 +59,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
else
{
var loader = new Active(reader);
var loader = new Active(Reader);
loader.Read();

@ -1,16 +1,12 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using System;
using mmfparser;
using NetMFAPatcher.MMFParser.ChunkLoaders.Banks;
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.mfaloaders
namespace NetMFAPatcher.MMFParser.MFALoaders
{
class AGMIBank : DataLoader
class AgmiBank : DataLoader
{
public override void Print()
{
@ -20,27 +16,27 @@ namespace mmfparser.mfaloaders
public override void Read()
{
Logger.Log("TEX READ");
var graphicMode = reader.ReadInt32();
var graphicMode = Reader.ReadInt32();
Logger.Log($"GraphicMode:{graphicMode}");
var paletteVersion = reader.ReadInt16();
var paletteVersion = Reader.ReadInt16();
Logger.Log($"PaletteVersion:{paletteVersion}");
var paletteEntries = reader.ReadInt16();
var paletteEntries = Reader.ReadInt16();
Logger.Log($"PaletteEntries:{paletteEntries}");
for (int i = 0; i < 256; i++)
{
reader.ReadColor();
Reader.ReadColor();
}
var count = reader.ReadInt32();
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();
var item = new ImageItem(Reader);
item.IsCompressed = true;
var currentPos = Reader.Tell();
item.Read();
@ -51,11 +47,11 @@ namespace mmfparser.mfaloaders
}
}
public AGMIBank(ByteIO reader) : base(reader)
public AgmiBank(ByteIO reader) : base(reader)
{
}
public AGMIBank(Chunk chunk) : base(chunk)
public AgmiBank(Chunk chunk) : base(chunk)
{
}
}

@ -5,15 +5,16 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
{
class Layer : DataLoader
{
public string name="ERROR";
public float xCoefficient;
public float yCoefficient;
public int flags;
public string Name="ERROR";
public float XCoefficient;
public float YCoefficient;
public int Flags;
public override void Print()
@ -23,10 +24,10 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
name = Helper.AutoReadUnicode(reader);
flags = reader.ReadInt32();
xCoefficient = reader.ReadSingle();
yCoefficient = reader.ReadSingle();
Name = Helper.AutoReadUnicode(Reader);
Flags = Reader.ReadInt32();
XCoefficient = Reader.ReadSingle();
YCoefficient = Reader.ReadSingle();

@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders
{
class ValueList : DataLoader
{
public List<ValueItem> items = new List<ValueItem>();
public List<ValueItem> Items = new List<ValueItem>();
public ValueList(ByteIO reader) : base(reader)
{
}
@ -23,12 +24,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
var count = reader.ReadInt32();
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new ValueItem(reader);
var item = new ValueItem(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}
@ -37,8 +38,8 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
}
class ValueItem: DataLoader
{
public object value;
public string name;
public object Value;
public string Name;
public ValueItem(ByteIO reader) : base(reader)
{
@ -52,18 +53,18 @@ namespace NetMFAPatcher.mmfparser.mfaloaders
public override void Read()
{
name = Helper.AutoReadUnicode(reader);
var type = reader.ReadInt32();
Name = Helper.AutoReadUnicode(Reader);
var type = Reader.ReadInt32();
switch (type)
{
case 2://string
value = Helper.AutoReadUnicode(reader);
Value = Helper.AutoReadUnicode(Reader);
break;
case 0://int
value = reader.ReadInt32();
Value = Reader.ReadInt32();
break;
case 1://double
value = reader.ReadDouble();
Value = Reader.ReadDouble();
break;
}

@ -10,18 +10,18 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{
class AnimationObject:ObjectLoader
{
List<Animation> items = new List<Animation>();
List<Animation> _items = new List<Animation>();
public override void Read()
{
base.Read();
if(reader.ReadByte()!=0)
if(Reader.ReadByte()!=0)
{
var animationCount = reader.ReadInt32();
var animationCount = Reader.ReadInt32();
for (int i = 0; i < animationCount; i++)
{
var item = new Animation(reader);
var item = new Animation(Reader);
item.Read();
items.Add(item);
_items.Add(item);
}
}
@ -31,20 +31,20 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
}
class Animation : DataLoader
{
public string name = "Animation-UNKNOWN";
public string Name = "Animation-UNKNOWN";
public override void Print()
{
Logger.Log($" Found animation: {name} ");
Logger.Log($" Found animation: {Name} ");
}
public override void Read()
{
name = reader.ReadAscii(reader.ReadInt32());
var directionCount = reader.ReadInt32();
Name = Reader.ReadAscii(Reader.ReadInt32());
var directionCount = Reader.ReadInt32();
var directions = new List<AnimationDirection>();
for (int i = 0; i < directionCount; i++)
{
var direction = new AnimationDirection(reader);
var direction = new AnimationDirection(Reader);
direction.Read();
directions.Add(direction);
}
@ -56,7 +56,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
}
class AnimationDirection : DataLoader
{
public string name = "Animation-UNKNOWN";
public string Name = "Animation-UNKNOWN";
public override void Print()
{
throw new NotImplementedException();
@ -64,11 +64,11 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read()
{
var index = reader.ReadInt32();
var minSpeed = reader.ReadInt32();
var maxSpeed= reader.ReadInt32();
var repeat= reader.ReadInt32();
var backTo= reader.ReadInt32();
var index = Reader.ReadInt32();
var minSpeed = Reader.ReadInt32();
var maxSpeed= Reader.ReadInt32();
var repeat= Reader.ReadInt32();
var backTo= Reader.ReadInt32();
var frames = new List<int>();
}

@ -10,7 +10,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{
class Behaviours : DataLoader
{
List<Behaviour> items = new List<Behaviour>();
List<Behaviour> _items = new List<Behaviour>();
public override void Print()
{
throw new NotImplementedException();
@ -18,20 +18,20 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read()
{
var count = reader.ReadInt32();
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new Behaviour(reader);
var item = new Behaviour(Reader);
item.Read();
items.Add(item);
_items.Add(item);
}
}
public Behaviours(ByteIO reader) : base(reader) { }
}
class Behaviour : DataLoader
{
public string name = "ERROR";
public ByteIO data;
public string Name = "ERROR";
public ByteIO Data;
public override void Print()
{
throw new NotImplementedException();
@ -39,8 +39,8 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read()
{
name = reader.ReadAscii(reader.ReadInt32());
data = new ByteIO(reader.ReadBytes(reader.ReadInt32()));
Name = Reader.ReadAscii(Reader.ReadInt32());
Data = new ByteIO(Reader.ReadBytes(Reader.ReadInt32()));
}
public Behaviour(ByteIO reader) : base(reader) { }

@ -5,12 +5,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetMFAPatcher.utils;
namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{
class Movements : DataLoader
{
public List<Movement> items = new List<Movement>();
public List<Movement> Items = new List<Movement>();
public override void Print()
{
throw new NotImplementedException();
@ -18,12 +19,12 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read()
{
var count = reader.ReadInt32();
var count = Reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new Movement(reader);
var item = new Movement(Reader);
item.Read();
items.Add(item);
Items.Add(item);
}
@ -33,7 +34,7 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
}
class Movement : DataLoader
{
public string name="ERROR";
public string Name="ERROR";
public override void Print()
{
@ -42,23 +43,23 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
public override void Read()
{
name = Helper.AutoReadUnicode(reader);
var extension = Helper.AutoReadUnicode(reader);
var identifier = reader.ReadInt32();
var dataSize = reader.ReadInt32();
Name = Helper.AutoReadUnicode(Reader);
var extension = Helper.AutoReadUnicode(Reader);
var identifier = Reader.ReadInt32();
var dataSize = Reader.ReadInt32();
if(extension.Length>0)
{
var newReader = new ByteIO(reader.ReadBytes(dataSize));
var newReader = new ByteIO(Reader.ReadBytes(dataSize));
}
else
{
var player = reader.ReadInt16();
var type = reader.ReadInt16();
var movingAtStart = reader.ReadByte();
reader.Skip(3);
var directionAtStart = reader.ReadInt32();
var player = Reader.ReadInt16();
var type = Reader.ReadInt16();
var movingAtStart = Reader.ReadByte();
Reader.Skip(3);
var directionAtStart = Reader.ReadInt32();
//implement types, but i am tired, fuck this shit
}

@ -11,62 +11,62 @@ namespace NetMFAPatcher.mmfparser.mfaloaders.mfachunks
{
class ObjectLoader : DataLoader
{
public int objectFlags;
public int newObjectFlags;
public Color backgroundColor;
List<short> qualifiers = new List<short>();
public ValueList values;
public ValueList strings;
public Movements movements;
public Behaviours behaviours;
public int ObjectFlags;
public int NewObjectFlags;
public Color BackgroundColor;
List<short> _qualifiers = new List<short>();
public ValueList Values;
public ValueList Strings;
public Movements Movements;
public Behaviours Behaviours;
public override void Print()
{
Logger.Log("Object Loader: ");
Logger.Log(" Values:");
foreach (var item in values.items)
foreach (var item in Values.Items)
{
Logger.Log($" Value {item.name} contains '{item.value}'");
Logger.Log($" Value {item.Name} contains '{item.Value}'");
}
Logger.Log("\n Strings:");
foreach (var item in strings.items)
foreach (var item in Strings.Items)
{
Logger.Log($" String {item.name} contains '{item.value}'");
Logger.Log($" String {item.Name} contains '{item.Value}'");
}
Logger.Log("\n Movements:");
foreach (var item in movements.items)
foreach (var item in Movements.Items)
{
Logger.Log($" Movement {item.name}");
Logger.Log($" Movement {item.Name}");
}
Logger.Log("\n");
}
public override void Read()
{
objectFlags = reader.ReadInt32();
newObjectFlags = reader.ReadInt32();
backgroundColor = reader.ReadColor();
var end = reader.Tell() + 2 * 9;
ObjectFlags = Reader.ReadInt32();
NewObjectFlags = Reader.ReadInt32();
BackgroundColor = Reader.ReadColor();
var end = Reader.Tell() + 2 * 9;
for (int i = 0; i < 9; i++)
{
var value = reader.ReadInt16();
var value = Reader.ReadInt16();
if(value==-1)
{
break;
}
qualifiers.Add(value);
_qualifiers.Add(value);
}
reader.Seek(end);
Reader.Seek(end);
values = new ValueList(reader);
values.Read();
strings = new ValueList(reader);
strings.Read();
movements = new Movements(reader);
movements.Read();
behaviours = new Behaviours(reader);
behaviours.Read();
reader.Skip(56);
Values = new ValueList(Reader);
Values.Read();
Strings = new ValueList(Reader);
Strings.Read();
Movements = new Movements(Reader);
Movements.Read();
Behaviours = new Behaviours(Reader);
Behaviours.Read();
Reader.Skip(56);
Print();

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Ionic.Zlib" version="1.9.1.5" targetFramework="net472" />
<package id="SharpZipLib" version="1.3.0" targetFramework="net472" />
</packages>
Loading…
Cancel
Save