New project structure, some bug fixes

master
1987kostya 5 years ago
parent f18c39974d
commit 85d81098b0

@ -88,40 +88,41 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="mmfparser\chunkloaders\AppMenu.cs" /> <Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" />
<Compile Include="mmfparser\chunkloaders\banks\DebugImageBank.cs" /> <Compile Include="MMFParser\ChunkLoaders\banks\DebugImageBank.cs" />
<Compile Include="mmfparser\chunkloaders\ObjectInfo.cs" /> <Compile Include="MMFParser\ChunkLoaders\ObjectInfo.cs" />
<Compile Include="mmfparser\chunkloaders\FrameItems.cs" /> <Compile Include="MMFParser\ChunkLoaders\FrameItems.cs" />
<Compile Include="mmfparser\DataLoader.cs" /> <Compile Include="MMFParser\ChunkLoaders\ObjectNames.cs" />
<Compile Include="mmfparser\mfaloaders\ChunkList.cs" /> <Compile Include="MMFParser\Data\DataLoader.cs" />
<Compile Include="mmfparser\mfaloaders\Frame.cs" /> <Compile Include="MMFParser\MFALoaders\ChunkList.cs" />
<Compile Include="mmfparser\mfaloaders\FrameItem.cs" /> <Compile Include="MMFParser\MFALoaders\Frame.cs" />
<Compile Include="mmfparser\mfaloaders\Layer.cs" /> <Compile Include="MMFParser\MFALoaders\FrameItem.cs" />
<Compile Include="mmfparser\mfaloaders\mfachunks\Active.cs" /> <Compile Include="MMFParser\MFALoaders\Layer.cs" />
<Compile Include="mmfparser\mfaloaders\mfachunks\AnimationObject.cs" /> <Compile Include="MMFParser\MFALoaders\mfachunks\Active.cs" />
<Compile Include="mmfparser\mfaloaders\mfachunks\Behaviours.cs" /> <Compile Include="MMFParser\MFALoaders\mfachunks\AnimationObject.cs" />
<Compile Include="mmfparser\mfaloaders\mfachunks\Movements.cs" /> <Compile Include="MMFParser\MFALoaders\mfachunks\Behaviours.cs" />
<Compile Include="mmfparser\mfaloaders\mfachunks\ObjectLoader.cs" /> <Compile Include="MMFParser\MFALoaders\mfachunks\Movements.cs" />
<Compile Include="mmfparser\mfaloaders\ValueList.cs" /> <Compile Include="MMFParser\MFALoaders\mfachunks\ObjectLoader.cs" />
<Compile Include="mmfparser\mfaloaders\Controls.cs" /> <Compile Include="MMFParser\MFALoaders\ValueList.cs" />
<Compile Include="mmfparser\mfaloaders\ImageBank.cs" /> <Compile Include="MMFParser\MFALoaders\Controls.cs" />
<Compile Include="mmfparser\MFA.cs" /> <Compile Include="MMFParser\MFALoaders\ImageBank.cs" />
<Compile Include="mmfparser\chunkloaders\AppHeader.cs" /> <Compile Include="MMFParser\Data\MFA.cs" />
<Compile Include="mmfparser\chunkloaders\ChunkLoader.cs" /> <Compile Include="MMFParser\ChunkLoaders\AppHeader.cs" />
<Compile Include="mmfparser\chunkloaders\banks\FontBank.cs" /> <Compile Include="MMFParser\ChunkLoaders\ChunkLoader.cs" />
<Compile Include="mmfparser\chunkloaders\Frame.cs" /> <Compile Include="MMFParser\ChunkLoaders\banks\FontBank.cs" />
<Compile Include="mmfparser\chunkloaders\banks\ImageBank.cs" /> <Compile Include="MMFParser\ChunkLoaders\Frame.cs" />
<Compile Include="mmfparser\chunkloaders\banks\MusicBank.cs" /> <Compile Include="MMFParser\ChunkLoaders\banks\ImageBank.cs" />
<Compile Include="mmfparser\chunkloaders\banks\SoundBank.cs" /> <Compile Include="MMFParser\ChunkLoaders\banks\MusicBank.cs" />
<Compile Include="mmfparser\chunkloaders\StringChunk.cs" /> <Compile Include="MMFParser\ChunkLoaders\banks\SoundBank.cs" />
<Compile Include="mmfparser\chunkloaders\yves.cs" /> <Compile Include="MMFParser\ChunkLoaders\StringChunk.cs" />
<Compile Include="mmfparser\Constants.cs" /> <Compile Include="MMFParser\ChunkLoaders\yves.cs" />
<Compile Include="MMFParser\Constants.cs" />
<Compile Include="utils\ByteFlag.cs" /> <Compile Include="utils\ByteFlag.cs" />
<Compile Include="utils\ByteWriter.cs" /> <Compile Include="utils\ByteWriter.cs" />
<Compile Include="utils\Helper.cs" /> <Compile Include="utils\Helper.cs" />
<Compile Include="mmfparser\ChunkList.cs" /> <Compile Include="MMFParser\Data\ChunkList.cs" />
<Compile Include="mmfparser\GameData.cs" /> <Compile Include="MMFParser\Data\GameData.cs" />
<Compile Include="mmfparser\PackData.cs" /> <Compile Include="MMFParser\Data\PackData.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils\ByteIO.cs" /> <Compile Include="utils\ByteIO.cs" />

@ -0,0 +1,34 @@
using NetMFAPatcher.chunkloaders;
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 NetMFAPatcher.mmfparser.chunkloaders
{
class ObjectNames : ChunkLoader//Fucking trash
{
public override void Print(bool ext)
{
}
public override void Read()
{
var start = reader.Tell();
var endpos = start + chunk.size;
while(true)
{
if (reader.Tell() >= endpos+4) break;
Console.WriteLine(reader.ReadWideString());
}
}
public ObjectNames(ByteIO reader) : base(reader) { }
public ObjectNames(Chunk chunk) : base(chunk) { }
}
}

@ -1,4 +1,5 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.utils; using NetMFAPatcher.utils;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
@ -6,12 +7,12 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using static NetMFAPatcher.mmfparser.Constants; using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.mmfparser namespace NetMFAPatcher.MMFParser.Data
{ {
public class ChunkList public class ChunkList
{ {
public List<Chunk> chunks = new List<Chunk>(); public List<Chunk> chunks = new List<Chunk>();
public bool verbose = true; public bool verbose = false;
public void Read(ByteIO exeReader) public void Read(ByteIO exeReader)
{ {
@ -26,8 +27,17 @@ namespace NetMFAPatcher.mmfparser
{ {
if (chunk.loader.verbose) if (chunk.loader.verbose)
{ {
chunk.loader.Print(); chunk.loader.Print(Program.LogAll);
} }
}
if (chunk.verbose)
{
chunk.Print(Program.LogAll);
if(Program.LogAll) Console.ReadKey();
} }
chunks.Add(chunk); chunks.Add(chunk);
@ -35,15 +45,12 @@ namespace NetMFAPatcher.mmfparser
{ {
chunk.BuildKey(); chunk.BuildKey();
} }
if (chunk.id == 13108)
{
}
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); //Logger.Log(verbose ? $" Total Chunks Count: {chunks.Count}":"ChunkList Done", true, ConsoleColor.Blue);
} }
public class Chunk public class Chunk
@ -56,9 +63,9 @@ namespace NetMFAPatcher.mmfparser
public ChunkLoader loader; public ChunkLoader loader;
public byte[] chunk_data; public byte[] chunk_data;
public ChunkFlags flag; public ChunkFlags flag;
int size = 0; public int size = 0;
int decompressed_size = 0; public int decompressed_size = 0;
bool verbose = true; public bool verbose = false;
public Chunk(int Actualuid, ChunkList actual_chunk_list) public Chunk(int Actualuid, ChunkList actual_chunk_list)
{ {
@ -86,7 +93,6 @@ namespace NetMFAPatcher.mmfparser
chunk_data = Decryption.DecodeChunk(exeReader.ReadBytes(size),size,54); chunk_data = Decryption.DecodeChunk(exeReader.ReadBytes(size),size,54);
break; break;
case ChunkFlags.CompressedAndEncrypyed: case ChunkFlags.CompressedAndEncrypyed:
//exeReader.ReadBytes(size);
chunk_data = Decryption.DecodeMode3(exeReader.ReadBytes(size), size,id, 54); chunk_data = Decryption.DecodeMode3(exeReader.ReadBytes(size), size,id, 54);
break; break;
case ChunkFlags.Compressed: case ChunkFlags.Compressed:
@ -103,10 +109,11 @@ namespace NetMFAPatcher.mmfparser
string path = $"{Program.DumpPath}\\CHUNKS\\{name}.chunk"; string path = $"{Program.DumpPath}\\CHUNKS\\{name}.chunk";
File.WriteAllBytes(path, chunk_data); File.WriteAllBytes(path, chunk_data);
} }
if(verbose) int tempId=0;
int.TryParse(name,out tempId);
if(tempId==id)
{ {
//Print(false); chunk_data.Log(true, "X2");
} }
} }
@ -123,6 +130,7 @@ namespace NetMFAPatcher.mmfparser
Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan); Logger.Log($" Decompressed Size: {decompressed_size} B", true, ConsoleColor.DarkCyan);
Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan); Logger.Log("---------------------------------------------", true, ConsoleColor.DarkCyan);
} }
else else
{ {
@ -136,13 +144,28 @@ namespace NetMFAPatcher.mmfparser
} }
public void BuildKey() public void BuildKey()
{ {
string title = ""; string title = "Five Nights at Candy's 3";
string copyright = ""; string copyright = "";
string project = ""; string project = @"C:\Users\Emil\Desktop\Five Nights at Candy's 3\Five Nights At Candy's 3.mfa";
title = "Sister Location";//chunk_list.get_chunk<AppName>().value;
copyright = "Scott Cawthon";//chunk_list.get_chunk<Copyright>().value; var titleChunk = chunk_list.get_chunk<AppName>();
project = @"C:\Users\Scott\Desktop\FNAF 5\FNaF 5-157.mfa";//chunk_list.get_chunk<EditorFilename>().value; if (titleChunk != null) title = titleChunk.value;
Decryption.MakeKey(title,copyright,project,54);
var copyrightChunk = chunk_list.get_chunk<Copyright>();
if (copyrightChunk != null) copyright = copyrightChunk.value;
var projectChunk = chunk_list.get_chunk<EditorFilename>();
if (projectChunk != null) project = projectChunk.value;
if (Program.game_data.product_build > 284)
{
Decryption.MakeKey(title, copyright, project, 54);
}
else
{
Decryption.MakeKey(project, title, copyright, 54);
}
Logger.Log("New Key!"); Logger.Log("New Key!");
@ -184,6 +207,9 @@ namespace NetMFAPatcher.mmfparser
case 8752: case 8752:
loader = new AppDoc(chunk); loader = new AppDoc(chunk);
break; break;
case 8745://
loader = new FrameItems(chunk);
break;
case 8757: case 8757:
loader = new AppIcon(chunk); loader = new AppIcon(chunk);
break; break;
@ -205,12 +231,25 @@ namespace NetMFAPatcher.mmfparser
case 13108: case 13108:
loader = new FrameHeader(chunk); loader = new FrameHeader(chunk);
break; break;
case 13112:
loader = new ObjectInstances(chunk);
break;
case 26214: case 26214:
loader = new ImageBank(chunk); loader = new ImageBank(chunk);
break; break;
case 26216: case 26216:
loader = new SoundBank(chunk); loader = new SoundBank(chunk);
break; break;
case 17477:
loader = new ObjectName(chunk);
break;
case 17476:
loader = new ObjectHeader(chunk);
break;
case 8788:
loader = new ObjectNames(chunk);
break;
} }
if (loader != null) if (loader != null)
@ -236,5 +275,10 @@ namespace NetMFAPatcher.mmfparser
return null; //I hope this wont happen return null; //I hope this wont happen
} }
public T get_loader<T>(ChunkLoader loader) where T : ChunkLoader
{
return (T)loader;
}
} }
} }

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.mmfparser.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace mmfparser namespace mmfparser
{ {

@ -1,4 +1,5 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -7,7 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.mmfparser.Constants; using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.mmfparser namespace NetMFAPatcher.MMFParser.Data
{ {
public class GameData public class GameData
{ {
@ -38,7 +39,7 @@ namespace NetMFAPatcher.mmfparser
Print(); Print();
Logger.Log("Press any key to continue",true,ConsoleColor.Magenta); Logger.Log("Press any key to continue",true,ConsoleColor.Magenta);
Console.ReadKey(); //Console.ReadKey();
gameChunks = new ChunkList(); gameChunks = new ChunkList();
gameChunks.Read(exeReader); gameChunks.Read(exeReader);

@ -59,6 +59,7 @@ namespace NetMFAPatcher.mfa
description = reader.ReadAscii(reader.ReadInt32()); description = reader.ReadAscii(reader.ReadInt32());
path = reader.ReadAscii(reader.ReadInt32()); path = reader.ReadAscii(reader.ReadInt32());
stamp = reader.ReadBytes(reader.ReadInt32()); stamp = reader.ReadBytes(reader.ReadInt32());
Console.WriteLine(path);
@ -85,9 +86,15 @@ namespace NetMFAPatcher.mfa
} }
var music = new MusicBank(reader); var music = new MusicBank(reader);
music.Read(); music.Read();
//Images&Icons are not implemented
reader.Seek(1191182);//hardcoded offset //if (reader.ReadAscii(4) != "AGMI")
//{
// throw new Exception("Invalid Icon Bank");
//}
//var icons = new AGMIBank(reader);
//icons.Read();
reader.Seek(17710);//hardcoded offset
reader.ReadInt32();//checkDefault reader.ReadInt32();//checkDefault
author = reader.ReadAscii(reader.ReadInt32()); author = reader.ReadAscii(reader.ReadInt32());

@ -8,7 +8,7 @@ using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NetMFAPatcher.mmfparser namespace NetMFAPatcher.MMFParser.Data
{ {
public class PackData public class PackData
{ {

@ -7,6 +7,7 @@ using System.Collections;
using NetMFAPatcher.mfa; using NetMFAPatcher.mfa;
using NetMFAPatcher.utils; using NetMFAPatcher.utils;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using NetMFAPatcher.MMFParser.Data;
namespace NetMFAPatcher namespace NetMFAPatcher
{ {
@ -26,6 +27,8 @@ namespace NetMFAPatcher
public static bool DumpSounds = false; public static bool DumpSounds = false;
public static bool verbose; public static bool verbose;
public static bool LogAll=false;
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
@ -43,7 +46,7 @@ namespace NetMFAPatcher
{ {
ByteIO mfaReader = new ByteIO(@"E:\DotNetCTF\Tests\mmftest.mfa", FileMode.Open); ByteIO mfaReader = new ByteIO(@"E:\anaconda-mode3\Application.mfa", FileMode.Open);
var mfa = new MFA(mfaReader); var mfa = new MFA(mfaReader);
mfa.Read(); mfa.Read();

@ -11,40 +11,39 @@ namespace NetMFAPatcher.utils
class Decryption class Decryption
{ {
public static byte[] key; public static byte[] key;
public static string storedName;
public static string storedCopyright;
public static string storedPath;
public static void MakeKey(string STitle, string SCopyright,string SProject, byte MagicChar) public static void MakeKey(string STitle, string SCopyright,string SProject, byte MagicChar)
{ {
storedName = STitle;
storedCopyright = SCopyright;
storedPath = SProject;
byte[] nameBytes = Encoding.ASCII.GetBytes(STitle); byte[] nameBytes = Encoding.ASCII.GetBytes(STitle);
var name = Marshal.AllocHGlobal(STitle.Length); var name = Marshal.StringToHGlobalAnsi(STitle);//Marshal.AllocHGlobal(STitle.Length);
Marshal.Copy(nameBytes, 0, name, STitle.Length); Marshal.Copy(nameBytes, 0, name, STitle.Length);
byte[] copyrightBytes = Encoding.ASCII.GetBytes(SCopyright); byte[] copyrightBytes = Encoding.ASCII.GetBytes(SCopyright);
var copyright = Marshal.AllocHGlobal(SCopyright.Length); var copyright = Marshal.StringToHGlobalAnsi(SCopyright);
Marshal.Copy(copyrightBytes, 0, copyright, SCopyright.Length); Marshal.Copy(copyrightBytes, 0, copyright, SCopyright.Length);
byte[] filenameBytes = Encoding.ASCII.GetBytes(SProject); byte[] filenameBytes = Encoding.ASCII.GetBytes(SProject);
var pathfilename = Marshal.AllocHGlobal(SProject.Length); var pathfilename = Marshal.StringToHGlobalAnsi(SProject);
Marshal.Copy(filenameBytes, 0, pathfilename, SProject.Length); Marshal.Copy(filenameBytes, 0, pathfilename, SProject.Length);
var ptr = Decryption.make_key(name, copyright, pathfilename, MagicChar); var ptr = Decryption.make_key(name, copyright, pathfilename, MagicChar);
byte[] Key = new byte[257]; byte[] Key = new byte[257];
Marshal.Copy(ptr, Key, 0, 257); Marshal.Copy(ptr, Key, 0, 256);
Marshal.FreeHGlobal(name); Marshal.FreeHGlobal(name);
Marshal.FreeHGlobal(copyright); Marshal.FreeHGlobal(copyright);
Marshal.FreeHGlobal(pathfilename); Marshal.FreeHGlobal(pathfilename);
key = Key; key = Key;
//some hardcoded checks for SL //key.Log(true, "X2");
if (Console.ReadKey().Key==ConsoleKey.N)
{
if(key[73] == 0xB2)
{
return;
}
MakeKey("Sister Location", "Scott Cawthon", @"C:\Users\Scott\Desktop\FNAF 5\FNaF 5-157.mfa", 54);
}
} }
@ -54,7 +53,10 @@ namespace NetMFAPatcher.utils
var DecompressedSize = reader.ReadUInt32(); var DecompressedSize = reader.ReadUInt32();
var chunkData = reader.ReadBytes((int)reader.Size()); var chunkData = reader.ReadBytes((int)reader.Size());
if (ChunkID % 2 != 0)
{
chunkData[0] ^= (byte)(((byte)ChunkID & 0xFF) ^ ((byte)ChunkID >> 0x8)); chunkData[0] ^= (byte)(((byte)ChunkID & 0xFF) ^ ((byte)ChunkID >> 0x8));
}
var data = new ByteIO(DecodeChunk(chunkData,ChunkSize,MagicChar)); var data = new ByteIO(DecodeChunk(chunkData,ChunkSize,MagicChar));
var compressed_size = data.ReadUInt32(); var compressed_size = data.ReadUInt32();
@ -62,13 +64,11 @@ namespace NetMFAPatcher.utils
} }
public static byte[] DecodeChunk(byte[] ChunkData, int ChunkSize,byte MagicChar) public static byte[] DecodeChunk(byte[] ChunkData, int ChunkSize,byte MagicChar)
{ {
//Console.WriteLine("Decoding: "+ChunkData.Log(false,"X2"));
IntPtr InputChunkPtr = Marshal.AllocHGlobal(ChunkSize); IntPtr InputChunkPtr = Marshal.AllocHGlobal(ChunkSize);
Marshal.Copy(ChunkData, 0, InputChunkPtr, ChunkSize-4); Marshal.Copy(ChunkData, 0, InputChunkPtr, ChunkSize-4);
var OutputChunkPtr = decode_chunk(InputChunkPtr, ChunkSize, MagicChar); var OutputChunkPtr = decode_chunk(InputChunkPtr, ChunkSize, MagicChar);
byte[] DecodedChunk = new byte[ChunkSize]; byte[] DecodedChunk = new byte[ChunkSize];
Marshal.Copy(OutputChunkPtr, DecodedChunk,0,ChunkSize); Marshal.Copy(OutputChunkPtr, DecodedChunk,0,ChunkSize);
//Console.WriteLine("Result: " + DecodedChunk.Log(false, "X2"));
return DecodedChunk; return DecodedChunk;

@ -1,4 +1,5 @@
using System; using NetMFAPatcher.chunkloaders;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -9,21 +10,7 @@ namespace NetMFAPatcher
{ {
static class Helper static class Helper
{ {
public static byte[] ToBytes(this string str)
{
return Encoding.ASCII.GetBytes(str);
}
public static int getPadding(int width, int pad=2)
{
int num = pad - width * 3 % pad;
if(num==pad)
{
num = 0;
}
return (int)Math.Ceiling((double)((float)num/3f));
}
public static string CleanInput(string strIn) public static string CleanInput(string strIn)
{ {
try try
@ -37,18 +24,7 @@ namespace NetMFAPatcher
return String.Empty; return String.Empty;
} }
} }
public static string GetString(this byte[] bytes)
{
string str = "";
for (int i = 0; i < bytes.Length; i++)
{
str += Convert.ToChar(bytes[i]);
}
return str;
}
public static string Log(this byte[] bytes, bool log = true, string format = "") public static string Log(this byte[] bytes, bool log = true, string format = "")
{ {
string Temp = String.Empty; string Temp = String.Empty;
@ -77,5 +53,6 @@ namespace NetMFAPatcher
} }
} }
} }

@ -30,5 +30,14 @@ namespace NetMFAPatcher.utils
return Color.FromArgb((int)b, (int)g, (int)r); return Color.FromArgb((int)b, (int)g, (int)r);
} }
public static int getPadding(int width, int pad = 2)
{
int num = pad - width * 3 % pad;
if (num == pad)
{
num = 0;
}
return (int)Math.Ceiling((double)((float)num / 3f));
}
} }
} }

@ -94,16 +94,6 @@ namespace NetMFAPatcher.mmfparser
Sounds=26216, Sounds=26216,
Musics=26217, Musics=26217,
Last=32639 Last=32639
} }
} }
} }

@ -5,6 +5,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.mfaloaders;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -32,7 +34,7 @@ namespace NetMFAPatcher.chunkloaders
initialLives = (int) (reader.ReadUInt32() ^ 0xffffffff); initialLives = (int) (reader.ReadUInt32() ^ 0xffffffff);
var controls = new Controls(reader); var controls = new Controls(reader);
controls.Read(); controls.Read();
controls.Print(); controls.Print(false);
var borderColor = reader.ReadBytes(4); var borderColor = reader.ReadBytes(4);
numberOfFrames = reader.ReadInt32(); numberOfFrames = reader.ReadInt32();
@ -40,7 +42,7 @@ namespace NetMFAPatcher.chunkloaders
var windowsMenuIndex = reader.ReadSByte(); var windowsMenuIndex = reader.ReadSByte();
} }
public override void Print() public override void Print(bool ext)
{ {
Logger.Log($"ScreenRes: {windowWidth}x{windowHeight}", true, ConsoleColor.DarkMagenta); Logger.Log($"ScreenRes: {windowWidth}x{windowHeight}", true, ConsoleColor.DarkMagenta);
Logger.Log($"Score: {initialScore}, Lives: {initialLives}", true, ConsoleColor.DarkMagenta); Logger.Log($"Score: {initialScore}, Lives: {initialLives}", true, ConsoleColor.DarkMagenta);
@ -53,7 +55,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AppHeader(ChunkList.Chunk chunk) : base(chunk) public AppHeader(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -82,7 +84,7 @@ namespace NetMFAPatcher.chunkloaders
} }
} }
public override void Print() public override void Print(bool ext)
{ {
Logger.Log("Controls: ",true,ConsoleColor.Yellow); Logger.Log("Controls: ",true,ConsoleColor.Yellow);
foreach (var item in items) foreach (var item in items)

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
@ -16,12 +17,12 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
} }
public AppMenu(ChunkList.Chunk chunk) : base(chunk) public AppMenu(Chunk chunk) : base(chunk)
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
throw new NotImplementedException();
} }
public override void Read() public override void Read()
@ -87,10 +88,10 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
} }
public AppMenuItem(ChunkList.Chunk chunk) : base(chunk) public AppMenuItem(Chunk chunk) : base(chunk)
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.mmfparser.ChunkList; using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -29,6 +29,6 @@ namespace NetMFAPatcher.chunkloaders
public abstract void Read(); public abstract void Read();
public abstract void Print(); public abstract void Print(bool ext);
} }
} }

@ -1,4 +1,5 @@
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -40,17 +41,19 @@ namespace NetMFAPatcher.chunkloaders
public int height; public int height;
public byte[] background; public byte[] background;
public int flags; public int flags;
public int CountOfObjs;
int top; int top;
int bottom; int bottom;
int left; int left;
int right; int right;
public override void Print() public override void Print(bool ext)
{ {
Logger.Log($"Frame: {name}", true, ConsoleColor.Green); Logger.Log($"Frame: {name}", true, ConsoleColor.Green);
Logger.Log($" Password: {(password!=null ? password : "None")}", true, ConsoleColor.Green); Logger.Log($" Password: {(password!=null ? password : "None")}", true, ConsoleColor.Green);
Logger.Log($" Size: {width}x{height}", true, ConsoleColor.Green); Logger.Log($" Size: {width}x{height}", true, ConsoleColor.Green);
Logger.Log($" Objects: {CountOfObjs}", true, ConsoleColor.Green);
Logger.Log($"-------------------------", true, ConsoleColor.Green); Logger.Log($"-------------------------", true, ConsoleColor.Green);
} }
@ -77,6 +80,12 @@ namespace NetMFAPatcher.chunkloaders
height = header.height; height = header.height;
background = header.background; background = header.background;
flags = header.flags; flags = header.flags;
var objects = chunks.get_chunk<ObjectInstances>();
if(objects!=null)
{
CountOfObjs = objects.CountOfObjects;
}
@ -85,9 +94,9 @@ namespace NetMFAPatcher.chunkloaders
foreach (var item in chunks.chunks) foreach (var item in chunks.chunks)
{ {
Directory.CreateDirectory($"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}"); //Directory.CreateDirectory($"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}");
string path = $"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}\\{chunk.name}.chunk"; //string path = $"{Program.DumpPath}\\CHUNKS\\FRAMES\\{this.name}\\{chunk.name}.chunk";
File.WriteAllBytes(path, item.chunk_data); //File.WriteAllBytes(path, item.chunk_data);
} }
@ -119,7 +128,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
} }
@ -137,8 +146,9 @@ namespace NetMFAPatcher.chunkloaders
} }
class ObjectInstances : ChunkLoader class ObjectInstances : ChunkLoader
{ {
public int width;
public int height; public int CountOfObjects;
public List<ObjectInstances> items = new List<ObjectInstances>();
public ObjectInstances(ByteIO reader) : base(reader) public ObjectInstances(ByteIO reader) : base(reader)
{ {
@ -148,13 +158,22 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
} }
public override void Read() public override void Read()
{ {
return;
CountOfObjects = (int)reader.ReadUInt32();
for (int i = 0; i < CountOfObjects; i++)
{
var item = new ObjectInstances(reader);
item.Read();
items.Add(item);
}

@ -5,20 +5,35 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
class FrameItems : ChunkLoader class FrameItems : ChunkLoader
{ {
public FrameItems(ChunkList.Chunk chunk) : base(chunk) { } public Dictionary<int, ObjectInfo> itemDict = new Dictionary<int, ObjectInfo>();
public List<string> names = new List<string>();
public FrameItems(Chunk chunk) : base(chunk) { }
public FrameItems(ByteIO reader) : base(reader) { } public FrameItems(ByteIO reader) : base(reader) { }
public override void Print() public override void Print(bool ext)
{ {
} }
public override void Read() public override void Read()
{ {
Console.WriteLine("Reading FrameItems");
var count = reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var item = new ObjectInfo(reader);
item.verbose = false;
item.Read();
itemDict.Add(item.handle, item);
names.Add(item.name);
Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
}
} }
} }

@ -1,24 +1,106 @@
using NetMFAPatcher.chunkloaders; using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils; using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using static NetMFAPatcher.MMFParser.Data.ChunkList;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.mmfparser.chunkloaders namespace NetMFAPatcher.mmfparser.chunkloaders
{ {
class ObjectInfo : ChunkLoader class ObjectInfo : ChunkLoader
{ {
public ObjectInfo(ChunkList.Chunk chunk) : base(chunk) { } 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 ObjectInfo(ByteIO reader) : base(reader) { }
public override void Print() public override void Print(bool ext)
{ {
} }
public override void Read() public override void Read()
{ {
var infoChunks = new ChunkList();
infoChunks.verbose = false;
infoChunks.Read(reader);
foreach (var chunk in infoChunks.chunks)
{
chunk.verbose = false;
var loader = chunk.loader;
if(loader is ObjectName)
{
var actualLoader = infoChunks.get_loader<ObjectName>(loader);
name = actualLoader.value;
}
else if(loader is ObjectHeader)
{
var actualLoader = infoChunks.get_loader<ObjectHeader>(loader);
handle = actualLoader.handle;
objectType = actualLoader.objectType;
flags = actualLoader.flags;
var inkEffect = actualLoader.inkEffect;
transparent = ByteFlag.getFlag(inkEffect, 28);
antialias = ByteFlag.getFlag(inkEffect, 29);
}
}
}
}
class ObjectName : StringChunk
{
public ObjectName(ByteIO reader) : base(reader)
{
}
public ObjectName(Chunk chunk) : base(chunk)
{
}
}
class ObjectHeader : ChunkLoader
{
public int handle;
public int objectType;
public int flags;
public int inkEffect;
public int inkEffectParameter;
public ObjectHeader(ByteIO reader) : base(reader)
{
}
public ObjectHeader(Chunk chunk) : base(chunk)
{
}
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();
} }
} }

@ -5,6 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -19,7 +20,7 @@ namespace NetMFAPatcher.chunkloaders
value = reader.ReadWideString(); value = reader.ReadWideString();
} }
public override void Print() 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);
} }
@ -29,7 +30,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public StringChunk(ChunkList.Chunk chunk) : base(chunk) public StringChunk(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -40,7 +41,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AppName(ChunkList.Chunk chunk) : base(chunk) public AppName(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -51,7 +52,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AppAuthor(ChunkList.Chunk chunk) : base(chunk) public AppAuthor(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -62,7 +63,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public ExtPath(ChunkList.Chunk chunk) : base(chunk) public ExtPath(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -73,7 +74,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public EditorFilename(ChunkList.Chunk chunk) : base(chunk) public EditorFilename(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -84,7 +85,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public TargetFilename(ChunkList.Chunk chunk) : base(chunk) public TargetFilename(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -95,7 +96,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AppDoc(ChunkList.Chunk chunk) : base(chunk) public AppDoc(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -106,7 +107,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AboutText(ChunkList.Chunk chunk) : base(chunk) public AboutText(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -117,7 +118,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public Copyright(ChunkList.Chunk chunk) : base(chunk) public Copyright(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -128,7 +129,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public DemoFilePath(ChunkList.Chunk chunk) : base(chunk) public DemoFilePath(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -10,6 +10,7 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -20,10 +21,10 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public DebugImageBank(ChunkList.Chunk chunk) : base(chunk) public DebugImageBank(Chunk chunk) : base(chunk)
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
} }
@ -113,7 +114,7 @@ namespace NetMFAPatcher.chunkloaders
var colorSize = 3; var colorSize = 3;
Bitmap bitmap = new Bitmap((int)num2, (int)num3); Bitmap bitmap = new Bitmap((int)num2, (int)num3);
Color[,] array = new Color[(int)num2, (int)num3]; Color[,] array = new Color[(int)num2, (int)num3];
int num4 = Helper.getPadding((int)num2, 2); int num4 = ImageHelper.getPadding((int)num2, 2);
int num5 = 0; int num5 = 0;
for (int i = 0; i < (int)num3; i++) for (int i = 0; i < (int)num3; i++)
{ {
@ -176,7 +177,7 @@ namespace NetMFAPatcher.chunkloaders
public override void Print() public override void Print(bool ext)
{ {
} }
@ -184,7 +185,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public DebugImageItem(ChunkList.Chunk chunk) : base(chunk) public DebugImageItem(Chunk chunk) : base(chunk)
{ {
} }

@ -6,13 +6,14 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
class FontBank : ChunkLoader class FontBank : ChunkLoader
{ {
int numberOfItems; int numberOfItems;
public override void Print() public override void Print(bool ext)
{ {
Logger.Log($"FontCount:{numberOfItems.ToString()}"); Logger.Log($"FontCount:{numberOfItems.ToString()}");
} }
@ -30,7 +31,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public FontBank(ChunkList.Chunk chunk) : base(chunk) public FontBank(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -10,6 +10,7 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -20,10 +21,10 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public ImageBank(ChunkList.Chunk chunk) : base(chunk) public ImageBank(Chunk chunk) : base(chunk)
{ {
} }
public override void Print() public override void Print(bool ext)
{ {
} }
@ -205,7 +206,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
Bitmap bitmap = new Bitmap((int)width, (int)height); Bitmap bitmap = new Bitmap((int)width, (int)height);
Color[,] array = new Color[(int)width, (int)height]; Color[,] array = new Color[(int)width, (int)height];
int num4 = Helper.getPadding((int)width, 2); int num4 = ImageHelper.getPadding((int)width, 2);
int num5 = 0; int num5 = 0;
using (ByteIO binaryReader = image_data) using (ByteIO binaryReader = image_data)
{ {
@ -264,7 +265,7 @@ namespace NetMFAPatcher.chunkloaders
public override void Print() public override void Print(bool ext)
{ {
} }
@ -272,7 +273,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public ImageItem(ChunkList.Chunk chunk) : base(chunk) public ImageItem(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -15,7 +16,7 @@ namespace NetMFAPatcher.chunkloaders
public int references = 0; public int references = 0;
public List<MusicFile> items; public List<MusicFile> items;
public override void Print() public override void Print(bool ext)
{ {
} }
@ -36,7 +37,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public MusicBank(ChunkList.Chunk chunk) : base(chunk) public MusicBank(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -47,7 +48,7 @@ namespace NetMFAPatcher.chunkloaders
public string name = "ERROR"; public string name = "ERROR";
public byte[] data; public byte[] data;
public override void Print() public override void Print(bool ext)
{ {
} }
@ -59,7 +60,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public MusicFile(ChunkList.Chunk chunk) : base(chunk) public MusicFile(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NetMFAPatcher.mmfparser; using NetMFAPatcher.mmfparser;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -16,7 +17,7 @@ namespace NetMFAPatcher.chunkloaders
public List<SoundItem> items; public List<SoundItem> items;
public bool isCompressed = true; public bool isCompressed = true;
public override void Print() public override void Print(bool ext)
{ {
} }
@ -39,7 +40,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public SoundBank(ChunkList.Chunk chunk) : base(chunk) public SoundBank(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -50,7 +51,7 @@ namespace NetMFAPatcher.chunkloaders
public string name = "ERROR"; public string name = "ERROR";
public byte[] data; public byte[] data;
public override void Print() public override void Print(bool ext)
{ {
} }
@ -62,7 +63,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public SoundBase(ChunkList.Chunk chunk) : base(chunk) public SoundBase(Chunk chunk) : base(chunk)
{ {
} }
} }
@ -118,7 +119,7 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public SoundItem(ChunkList.Chunk chunk) : base(chunk) public SoundItem(Chunk chunk) : base(chunk)
{ {
} }
} }

@ -8,6 +8,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders namespace NetMFAPatcher.chunkloaders
{ {
@ -20,12 +21,13 @@ namespace NetMFAPatcher.chunkloaders
{ {
} }
public AppIcon(ChunkList.Chunk chunk) : base(chunk) public AppIcon(Chunk chunk) : base(chunk)
{ {
} }
public override void Read() public override void Read()
{ {
return;
Logger.Log("dumpingIcon"); Logger.Log("dumpingIcon");
reader.ReadBytes(reader.ReadInt32() - 4); reader.ReadBytes(reader.ReadInt32() - 4);
List<byte> color_indexes = new List<byte>(); List<byte> color_indexes = new List<byte>();
@ -65,7 +67,7 @@ namespace NetMFAPatcher.chunkloaders
} }
public override void Print() public override void Print(bool ext)
{ {
} }

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace mmfparser.mfaloaders namespace mmfparser.mfaloaders
{ {
@ -36,11 +37,14 @@ namespace mmfparser.mfaloaders
Logger.Log($"Number of image items: {count.ToString()}"); Logger.Log($"Number of image items: {count.ToString()}");
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Console.WriteLine("READING IMAGE: " + reader.Tell());
var item = new ImageItem(reader); var item = new ImageItem(reader);
item.Read(); item.Read();
} }
} }
@ -48,7 +52,7 @@ namespace mmfparser.mfaloaders
{ {
} }
public AGMIBank(ChunkList.Chunk chunk) : base(chunk) public AGMIBank(Chunk chunk) : base(chunk)
{ {
} }
} }

Loading…
Cancel
Save