From 97771e366a520c0a0956892e1accb42d388aab67 Mon Sep 17 00:00:00 2001 From: 1987kostya Date: Thu, 24 Dec 2020 14:34:52 +0600 Subject: [PATCH] Removed useless files --- DotNetCTFDumper/GUI/MainConsole.cs | 2 +- DotNetCTFDumper/Program.cs | 6 +- ImageBank.cs | 226 -------------------- TestDecompressor/App.config | 6 - TestDecompressor/Program.cs | 71 ------ TestDecompressor/Properties/AssemblyInfo.cs | 36 ---- TestDecompressor/TestDecompressor.csproj | 53 ----- 7 files changed, 6 insertions(+), 394 deletions(-) delete mode 100644 ImageBank.cs delete mode 100644 TestDecompressor/App.config delete mode 100644 TestDecompressor/Program.cs delete mode 100644 TestDecompressor/Properties/AssemblyInfo.cs delete mode 100644 TestDecompressor/TestDecompressor.csproj diff --git a/DotNetCTFDumper/GUI/MainConsole.cs b/DotNetCTFDumper/GUI/MainConsole.cs index c45e391..ced1d0c 100644 --- a/DotNetCTFDumper/GUI/MainConsole.cs +++ b/DotNetCTFDumper/GUI/MainConsole.cs @@ -31,7 +31,7 @@ namespace DotNetCTFDumper.GUI { setLineFormat(1,1); textBox1.SelectionStart = textBox1.Text.Length; - // scroll it automatically + textBox1.ScrollToCaret(); } diff --git a/DotNetCTFDumper/Program.cs b/DotNetCTFDumper/Program.cs index a426dcc..68456c2 100644 --- a/DotNetCTFDumper/Program.cs +++ b/DotNetCTFDumper/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Runtime.InteropServices; @@ -89,8 +90,11 @@ namespace DotNetCTFDumper var exeReader = new ByteReader(path, FileMode.Open); var currentExe = new Exe(); Exe.Instance = currentExe; + var stopWatch = new Stopwatch(); + stopWatch.Start(); currentExe.ParseExe(exeReader); - Logger.Log("Finished!", true, ConsoleColor.Yellow); + stopWatch.Stop(); + Logger.Log("Finished in "+stopWatch.Elapsed.ToString("g"), true, ConsoleColor.Yellow); return; if (File.Exists(path)) { diff --git a/ImageBank.cs b/ImageBank.cs deleted file mode 100644 index 2256dbd..0000000 --- a/ImageBank.cs +++ /dev/null @@ -1,226 +0,0 @@ -using NetMFAPatcher.Utils; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -namespace NetMFAPatcher.Chunks -{ - class ImageBank:ChunkLoader - { - public override void Print() - { - - } - - public override void Read() - { - reader = new ByteIO(chunk.chunk_data); - var number_of_items = reader.ReadUInt32(); - Console.WriteLine("Total images: "+number_of_items); - Console.WriteLine("OnImageBankStart: " + reader.Tell()); - for (int i = 0; i < number_of_items; i++) - { - var item = new ImageItem(); - item.reader = reader; - item.Read(); - item.Save(i.ToString()+".raw"); - - - - - } - - } - } - class ImageItem:ChunkLoader - { - - 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; - //tranparent,add later - int indexed; - byte[] image; - byte[] alpha; - private int currentSize; - private byte[] currentImage; - private byte[] curPoints; - private int currentN; - - public void ReadRGB(byte[] data,int width,int heigth,TestPoint pointClass) - { - var n = 0; - var i = 0; - List points = new List(); - var pad = GetPadding(width, 3); - for (int y = 0; y < heigth; y++) - { - for (int x = 0; x < width; x++) - { - points.AddRange(pointClass.Read(data, n)); - n += 3;//pointClass.size; - i += 1; - } - n += 3;//(int)pad + pointClass.size; - - } - curPoints = points.ToArray(); - currentN = n; - } - public void ReadAlpha(byte[] data, int width, int heigth, int position) - { - - var n = 0; - var i = 0; - List points = new List(); - var pad = GetPadding(width, 1, 4); - for (int y = 0; y < heigth; y++) - { - for (int x = 0; x < heigth; x++) - { - points[i] = data[n + position]; - n++; - i++; - - } - n += (int)pad; - } - curPoints = points.ToArray(); - - - - } - - public double GetPadding(int width,int classSize,int bytes=2) - { - var pad = bytes - ((width * classSize) % bytes); - if (pad == bytes) pad = 0; - var padding = Math.Ceiling((float)(pad / classSize)); - return padding;//Correct - - } - - - - - - public override void Read() - { - handle = reader.ReadInt32(); - position = (int)reader.Tell(); - Load(); - - - } - public void Load() - { - - - reader.Seek(position); - - - - var decompressedImg = Decompressor.Decompress(reader); - var image_data = new ByteIO(decompressedImg); - var start = image_data.Tell(); - checksum = image_data.ReadInt32(); - references = image_data.ReadInt32(); - var size = image_data.ReadUInt32(); - width = image_data.ReadInt16(); - height = image_data.ReadInt16(); - graphic_mode = image_data.ReadByte();//Graphic mode is always 4 for SL - var flags = image_data.ReadSByte(); - 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++) - { - image_data.ReadByte(); - //transparence - - } - int alpha_size=0; - byte[] data; - if (false)//lzx flag - { - var decompressed_size = image_data.ReadUInt32(); - image_data = Decompressor.decompress_asReader(image_data, (int)(image_data.Size() - image_data.Tell()), (int)decompressed_size); - } - else - { - //image_data = image_data.ReadBytes(-1) - data = image_data.ReadBytes((int)reader.Size()); - var curPoint = new TestPoint(); - ReadRGB(data,width,height,curPoint); - var image = curPoints; - var image_size = currentN; - this.image = image; - alpha_size = (int)(size - image_size); - - } - var pad = (alpha_size - width * height) / height; - //ReadAlpha(data, width, height, (int)(size - alpha_size)); - //alpha = curPoints; - - - - } - public void Save(string filename) - { - - File.WriteAllBytes(filename,image); - - } - - public override void Print() - { - - } - } - - public class TestPoint - { - public int size = 3; - public byte[] Read(byte[]data,int position) - { - byte r=0; - byte g=0; - byte b=0; - try - { - - - b = data[position]; - g = data[position + 1]; - r = data[position + 2]; - } - catch - { - - Console.WriteLine(position); - } - return (new List() { r, g, b }).ToArray(); - } - - - } - - -} diff --git a/TestDecompressor/App.config b/TestDecompressor/App.config deleted file mode 100644 index 56efbc7..0000000 --- a/TestDecompressor/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TestDecompressor/Program.cs b/TestDecompressor/Program.cs deleted file mode 100644 index 58bbb43..0000000 --- a/TestDecompressor/Program.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using System.IO; -using System.IO.Compression; - -namespace TestDecompressor -{ - - - public class Program - { - static string directoryPath = @"c:\temp"; - public static void Main() - { - - DirectoryInfo directorySelected = new DirectoryInfo(directoryPath); - Compress(directorySelected); - - foreach (FileInfo fileToDecompress in directorySelected.GetFiles("*.chunk")) - { - Decompress(fileToDecompress); - } - Console.ReadKey(); - } - - public static void Compress(DirectoryInfo directorySelected) - { - - foreach (FileInfo file in directorySelected.GetFiles("*.xml")) - using (FileStream originalFileStream = file.OpenRead()) - { - if ((File.GetAttributes(file.FullName) & FileAttributes.Hidden) - != FileAttributes.Hidden & file.Extension != ".cmp") - { - using (FileStream compressedFileStream = File.Create(file.FullName + ".cmp")) - { - using (DeflateStream compressionStream = new DeflateStream(compressedFileStream, CompressionMode.Compress)) - { - originalFileStream.CopyTo(compressionStream); - } - } - - FileInfo info = new FileInfo(directoryPath + "\\" + file.Name + ".cmp"); - Console.WriteLine("Compressed {0} from {1} to {2} bytes.", file.Name, file.Length, info.Length); - } - } - } - - public static void Decompress(FileInfo fileToDecompress) - { - using (FileStream originalFileStream = fileToDecompress.OpenRead()) - { - string currentFileName = fileToDecompress.FullName; - string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length); - - using (FileStream decompressedFileStream = File.Create(newFileName)) - { - using (DeflateStream decompressionStream = new DeflateStream(originalFileStream, CompressionMode.Decompress)) - { - decompressionStream.CopyTo(decompressedFileStream); - Console.WriteLine("Decompressed: {0}", fileToDecompress.Name); - } - } - } - } - } -} diff --git a/TestDecompressor/Properties/AssemblyInfo.cs b/TestDecompressor/Properties/AssemblyInfo.cs deleted file mode 100644 index 59ed31a..0000000 --- a/TestDecompressor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Общие сведения об этой сборке предоставляются следующим набором -// набора атрибутов. Измените значения этих атрибутов для изменения сведений, -// связанные с этой сборкой. -[assembly: AssemblyTitle("TestDecompressor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TestDecompressor")] -[assembly: AssemblyCopyright("Copyright © 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми -// для компонентов COM. Если необходимо обратиться к типу в этой сборке через -// из модели COM задайте для атрибута ComVisible этого типа значение true. -[assembly: ComVisible(false)] - -// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM -[assembly: Guid("3d4c851a-8c6b-4898-a766-b1364937f695")] - -// Сведения о версии сборки состоят из указанных ниже четырех значений: -// -// Основной номер версии -// Дополнительный номер версии -// Номер сборки -// Номер редакции -// -// Можно задать все значения или принять номера сборки и редакции по умолчанию -// используя "*", как показано ниже: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TestDecompressor/TestDecompressor.csproj b/TestDecompressor/TestDecompressor.csproj deleted file mode 100644 index 0f38647..0000000 --- a/TestDecompressor/TestDecompressor.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - - Debug - AnyCPU - {3D4C851A-8C6B-4898-A766-B1364937F695} - Exe - TestDecompressor - TestDecompressor - v4.7.2 - 512 - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - \ No newline at end of file