private static void ConvertPatchFile(string otherExe) { UserFeedback.Info(@"Converting RootPatch file to a patch file for '{0}'", otherExe); var rootPatchFilePath = FindRootPatchFile(); UserFeedback.Trace(@"Reading the root patch file"); var patch = Patcher.ReadPatch(rootPatchFilePath, true); UserFeedback.Trace(@"Locating the root executable file"); var rootExePath = FindExeFile(patch.FileSize, patch.Md5); UserFeedback.Trace(@"Reading the target executable"); var exe2 = File.ReadAllBytes(otherExe); UserFeedback.Trace(@"Reading root executable"); var exe1 = File.ReadAllBytes(rootExePath); var md5 = GetChecksum(exe2); UserFeedback.Trace(@"Detecting version from filename and/or md5"); string version = GetVersion(otherExe, md5); UserFeedback.Trace(@"Version: '{0}'", version); var rootMd5 = GetChecksum(exe1); Patch newPatch; if (rootMd5.Equals(md5)) { UserFeedback.Trace(@"Executable is equal; leaving patch file as-is"); newPatch = new Patch { FileSize = patch.FileSize, InterfaceDrsPosition = patch.InterfaceDrsPosition, Items = patch.Items, Md5 = patch.Md5 }; } else { UserFeedback.Trace(@"Locating comparable locations, this may take a while"); newPatch = Patcher.ConvertPatch(exe1, exe2, patch); newPatch.FileSize = exe2.Length; newPatch.Md5 = md5; } newPatch.Version = version; var patchFileName = @"AoE2Wide_" + version + @".patch"; var patchOutput = Path.Combine(Path.GetDirectoryName(otherExe), patchFileName); UserFeedback.Trace("Writing the patch file '{0}'", patchOutput); Patcher.WritePatch(newPatch, patchOutput); }
private static void AddAsmToRootPatchFile() { UserFeedback.Info(@"Locating listing file"); var lstFile = FindFile("listing file", "age2_x1*.lst", null, null); UserFeedback.Info(@"Locating RootPatch file"); var rootPatchFilePath = FindRootPatchFile(); UserFeedback.Trace(@"Reading the root patch file"); var patch = Patcher.ReadPatch(rootPatchFilePath, false); UserFeedback.Trace(@"Reading the listing file"); var asmMap = Patcher.ReadAsmMap(lstFile); UserFeedback.Trace(@"Adding Asm to the patch data"); Patcher.AddAsm(patch, asmMap); var outputRootPatchFilePath = rootPatchFilePath + "2"; UserFeedback.Trace("Writing the patch file '{0}'", outputRootPatchFilePath); Patcher.WritePatch(patch, outputRootPatchFilePath); }