private void Extract() { if (Options.DumpInfo != null || Options.MatchInfo != null) { Console.Write("Generating Message Hashes..."); Game.GenerateMessageHashes(); ConsoleEx.WriteLineFinished(); string hashesPath = (_baseDirectory + "Hashes.ini"); In.Load(Game, hashesPath); Out.Load(Game, hashesPath); } if (Options.DumpInfo != null) { string msgsPath = Path.Combine(Options.OutputDirectory, "Messages.txt"); using (var msgsOutput = new StreamWriter(msgsPath, false)) { msgsOutput.WriteLine("// " + Game.Revision); msgsOutput.WriteLine(); msgsOutput.WriteLine("// Outgoing Messages | " + Game.OutMessages.Count.ToString("n0")); WriteMessages(msgsOutput, "Outgoing", Game.OutMessages); msgsOutput.WriteLine(); msgsOutput.WriteLine("// Incoming Messages | " + Game.InMessages.Count.ToString("n0")); WriteMessages(msgsOutput, "Incoming", Game.InMessages); Console.WriteLine("Messages Saved: " + msgsPath); } string identitiesPath = Path.Combine(Options.OutputDirectory, "Identities.ini"); using (var output = new StreamWriter(identitiesPath)) { output.WriteLine(Game.Revision); Out.Save(output); output.WriteLine(); In.Save(output); } if (Options.DumpInfo.IsDumpingImages) { var imgDirectory = Directory.CreateDirectory(Options.OutputDirectory + "\\ImageFiles"); foreach (DefineBitsLossless2Tag bitsTag in Game.Tags .Where(t => t.Kind == TagKind.DefineBitsLossless2)) { string imgPath = Path.Combine(imgDirectory.FullName, "img_" + bitsTag.Id + ".png"); Color[,] table = bitsTag.GetARGBMap(); int width = table.GetLength(0); int height = table.GetLength(1); using (var asset = new Image <Rgba32>(width, height)) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Color pixel = table[x, y]; asset[x, y] = new Rgba32(pixel.R, pixel.G, pixel.B, pixel.A); } } using (var output = new StreamWriter(imgPath)) { asset.SaveAsPng(output.BaseStream); } } } } if (Options.DumpInfo.IsDumpingBinaryData) { var binDirectory = Directory.CreateDirectory(Options.OutputDirectory + "\\BinaryDataFiles"); foreach (DefineBinaryDataTag binTag in Game.Tags .Where(t => t.Kind == TagKind.DefineBinaryData)) { string binPath = Path.Combine(binDirectory.FullName, "bin_" + binTag.Id + ".xml"); if (Options.DumpInfo.IsMergingBinaryData) { using (var binOutput = File.Open(Options.OutputDirectory + "\\binaryData.xml", FileMode.Append, FileAccess.Write)) { binOutput.Write(binTag.Data, 0, binTag.Data.Length); } } else { File.WriteAllBytes(binPath, binTag.Data); } } } if (Options.MatchInfo != null) { MatchCommand matchInfo = Options.MatchInfo; using (var previousGame = new HGame(matchInfo.PreviousGameInfo.FullName)) { Console.Write("Preparing Hash Comparison..."); previousGame.Disassemble(); previousGame.GenerateMessageHashes(); ConsoleEx.WriteLineFinished(); Console.Write("Matching Outgoing Messages..."); ReplaceHeaders(matchInfo.ClientHeadersInfo, previousGame.OutMessages, previousGame.Revision); ConsoleEx.WriteLineFinished(); Console.Write("Matching Incoming Messages..."); ReplaceHeaders(matchInfo.ServerHeadersInfo, previousGame.InMessages, previousGame.Revision); ConsoleEx.WriteLineFinished(); } } } }