private static void ApplyIrreversibleCode(IDataPatcherUnitBase dataPatcherUnitBase, string gameExecutableFilePath) { // TODO: should we confirm unmodified code exists? but would that affect differing versions? Debug.WriteLine("Applying irreversible modified code."); dataPatcherUnitBase.ApplyModifiedCode(gameExecutableFilePath); }
private static void ApplyReversibleCode(IDataPatcherUnitBase dataPatcherUnitBase, bool applyModified, string gameExecutableFilePath) { if (applyModified) { // If unmodified code is applied, apply modified code if (dataPatcherUnitBase.IsCodeUnmodified(gameExecutableFilePath)) { Debug.WriteLine("Applying reversible modified code."); dataPatcherUnitBase.ApplyModifiedCode(gameExecutableFilePath); } else { if (!dataPatcherUnitBase.IsCodeModified(gameExecutableFilePath)) { throw new Exception("Unknown code detected. Unable to apply modified code."); } throw new Exception("Modified code already applied."); } } else { // If modified code is applied, apply unmodified code if (dataPatcherUnitBase.IsCodeModified(gameExecutableFilePath)) { Debug.WriteLine("Applying reversible unmodified code."); dataPatcherUnitBase.ApplyUnmodifiedCode(gameExecutableFilePath); } else { if (!dataPatcherUnitBase.IsCodeUnmodified(gameExecutableFilePath)) { throw new Exception("Unknown code detected. Unable to apply unmodified code."); } throw new Exception("Unmodified code already applied."); } } }