/// <summary> /// What the instruction should do /// </summary> protected override void _Process() { // No parameters if (!InstallHelper.IsCommunityPatchInstalled()) { PatchHelper.AddMessage("Unable to install current mod as latest Community Patch is required.\r\nGet it at http://www.oahucars-unlimited.com"); throw new Exception("Community Patch is not installed on this system."); } }
public ServerPresetBasic() { InitializeComponent(); CspVersionAutoFill.IsEnabled = PatchHelper.IsFeatureSupported(PatchHelper.FeatureTestOnline); /*if (SettingsHolder.Online.ServerPresetsFitInFewerTabs) { * WelcomeMessageTextArea.Height = 80; * }*/ }
public AcSettingsView() { InitializeComponent(); DataContext = new ViewModel(); this.AddWidthCondition(1080).Add(v => Grid.Columns = v ? 2 : 1); if (PatchHelper.IsFeatureSupported(PatchHelper.FeatureCustomGForces)) { GForcesSection.Visibility = Visibility.Collapsed; } }
public static IEnumerable <SettingEntry> DefaultScreenshotFormats() { return(new[] { new SettingEntry("JPG", ToolsStrings.AcSettings_ScreenshotFormat_Jpeg), new SettingEntry("BMP", ToolsStrings.AcSettings_ScreenshotFormat_Bmp) }.Concat(PatchHelper.IsFeatureSupported(PatchHelper.FeatureExtraScreenshotFormats) ? PatchHelper.GetConfig("data_manifest.ini")["FEATURES"].GetStrings("SUPPORTED_SCREENSHOT_FORMATS") .Select(x => new SettingEntry(x, $"{x} (added by Custom Shaders Patch)")) : new SettingEntry[0])); }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="SObject.canBePlacedHere"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_CanBePlacedHere(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { // TODO: Learn how to use ILGenerator bool stopCaring = false; int fertCategoryCounter = 0; // When we find the second -19, after the next instruction: // Place our patched section function call. If it returns true, return from the function false. var newInsns = new List <CodeInstruction>(); foreach (var insn in insns) { if (stopCaring) { newInsns.Add(insn); continue; } if (insn.opcode == OpCodes.Ldc_I4_S && (sbyte)insn.operand == -19) { newInsns.Add(insn); fertCategoryCounter++; } else if (fertCategoryCounter == 2) { newInsns.Add(insn); var branchPastOld = new CodeInstruction(OpCodes.Br, insn.operand); branchPastOld.labels.Add(gen.DefineLabel()); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_0)); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_1)); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_2)); newInsns.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <ObjectPatcher>(nameof(CanBePlacedHereLogic)))); newInsns.Add(new CodeInstruction(OpCodes.Brfalse, branchPastOld.labels[0])); newInsns.Add(new CodeInstruction(OpCodes.Ldc_I4_0)); newInsns.Add(new CodeInstruction(OpCodes.Ret)); newInsns.Add(branchPastOld); ++fertCategoryCounter; stopCaring = true; } else { newInsns.Add(insn); } } return(newInsns); }
/********* ** Private methods *********/ /// <summary>The method which transpiles <see cref="GameLocation.isTileOccupiedForPlacement"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_isTileOccupiedForPlacement(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { // TODO: Learn how to use ILGenerator bool stopCaring = false; bool foundFertCategory = false; // When we find -19, after the next instruction: // Place our patched section function call. If it returns true, return from the function true. var newInsns = new List <CodeInstruction>(); foreach (var insn in insns) { if (stopCaring) { newInsns.Add(insn); continue; } if (insn.opcode == OpCodes.Ldc_I4_S && (sbyte)insn.operand == -19) { newInsns.Add(insn); foundFertCategory = true; } else if (foundFertCategory) { newInsns.Add(insn); var branchPastOld = new CodeInstruction(OpCodes.Br, insn.operand); branchPastOld.labels.Add(gen.DefineLabel()); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_0)); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_1)); newInsns.Add(new CodeInstruction(OpCodes.Ldarg_2)); newInsns.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <GameLocationPatcher>(nameof(IsTileOccupiedForPlacementLogic)))); newInsns.Add(new CodeInstruction(OpCodes.Brfalse, branchPastOld.labels[0])); newInsns.Add(new CodeInstruction(OpCodes.Ldc_I4_1)); newInsns.Add(new CodeInstruction(OpCodes.Ret)); newInsns.Add(branchPastOld); foundFertCategory = false; stopCaring = true; } else { newInsns.Add(insn); } } return(newInsns); }
public override void Run(ModuleDefinition sourceModule, ModuleDefinition targetModule) { try { var moduleClass = FindModuleInitializer(targetModule); if (moduleClass == null) { moduleClass = new TypeDefinition("", "<Module>", TypeAttributes.Class); targetModule.Types.Add(moduleClass); } var initMethodReference = PatchHelper.ImportBootstrapMethodReference(targetModule, sourceModule); var cctor = moduleClass.Methods.FirstOrDefault(m => m.Name == ".cctor"); if (cctor == null) { cctor = new MethodDefinition( ".cctor", MethodAttributes.Static | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | MethodAttributes.Assembly, targetModule.ImportReference(typeof(void)) ); moduleClass.Methods.Add(cctor); } var ilProcessor = cctor.Body.GetILProcessor(); var callInstruction = Instruction.Create(OpCodes.Call, initMethodReference); if (cctor.Body.Instructions.Count > 0) { if (cctor.Body.Instructions.FirstOrDefault( i => i.OpCode == OpCodes.Call && i.Operand is MethodReference mr && mr.FullName == initMethodReference.FullName) == null) { ilProcessor.InsertBefore(cctor.Body.Instructions[0], callInstruction); } } else { ilProcessor.Append(callInstruction); ilProcessor.Emit(OpCodes.Ret); } OnPatchSucceeded(this, new PatchSucceededEventArgs(Name)); } catch (Exception ex) { var eventArgs = new PatchFailedEventArgs(Name, ex); OnPatchFailed(this, eventArgs); } }
public SettingsShadersPatch() { Instance = this; // Logging.Here(); PatchHelper.Reload(); KeyBindingsController = new LocalKeyBindingsController(this); /*InputBindings.Add(new InputBinding(new DelegateCommand(() => { * Model.SelectedApp?.ViewInExplorerCommand.Execute(null); * }), new KeyGesture(Key.F, ModifierKeys.Control))); * InputBindings.Add(new InputBinding(new DelegateCommand(() => { * Model.SelectedApp?.ReloadCommand.Execute(null); * }), new KeyGesture(Key.R, ModifierKeys.Control)));*/ // Logging.Here(); InitializeComponent(); DataContext = new ViewModel(); // Logging.Here(); Model.MainModel.PropertyChanged += OnModelPropertyChanged; // Logging.Here(); SetKeyboardInputs(); // Logging.Here(); UpdateConfigsTabs(); // Logging.Here(); InputBindings.AddRange(new[] { new InputBinding(Model.ShareCommand, new KeyGesture(Key.PageUp, ModifierKeys.Control)), new InputBinding(Model.ShareSectionCommand, new KeyGesture(Key.PageUp, ModifierKeys.Control | ModifierKeys.Shift)), PresetsControl != null ? new InputBinding(PresetsControl.SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)) : null }.NonNull().ToList()); // Logging.Here(); ShadersPatchEntry.InstallationStart += OnPatchInstallationStart; ShadersPatchEntry.InstallationEnd += OnPatchInstallationEnd; // Logging.Here(); if (PatchHelper.OptionPatchSupport) { PatchUpdater.Instance.PropertyChanged += OnPatchUpdaterPropertyChanged; // Logging.Here(); } // Logging.Here(); this.OnActualUnload(() => { Model?.Dispose(); if (PatchHelper.OptionPatchSupport) { PatchUpdater.Instance.PropertyChanged -= OnPatchUpdaterPropertyChanged; } Instance = null; }); // Logging.Here(); }
public async Task Sync() { var jsonPatchDocument = PatchHelper.CompareObjects(_synchronizedEntity, _presentationEntity); var temporary = await _omniaClient.UpdateTemporary(_entityMetadata, _temporaryId, jsonPatchDocument); temporary.data.ApplyTo(_synchronizedEntity); var diff = PatchHelper.CompareObjects(_presentationEntity, _synchronizedEntity); diff.ApplyTo(_presentationEntity); }
public AcSettingsSystem() { AcSettingsHolder.System.ScreenshotFormats = SystemSettings.DefaultScreenshotFormats().Concat( PatchHelper.IsFeatureSupported(PatchHelper.FeatureExtraScreenshotFormats) ? PatchHelper.GetConfig("data_manifest.ini")["FEATURES"].GetStrings("SUPPORTED_SCREENSHOT_FORMATS") .Select(x => new SettingEntry(x, $"{x} (added by Custom Shaders Patch)")) : new SettingEntry[0]).ToArray(); InitializeComponent(); DataContext = new ViewModel(); this.AddWidthCondition(1080).Add(v => Grid.Columns = v ? 2 : 1); }
private static IAcsStarter CreateStarter(Game.StartProperties properties) { var starter = AcsStarterFactory.Create(); if (SettingsHolder.Drive.PatchAcToDisableShadows && !PatchHelper.IsFeatureSupported(PatchHelper.FeatureDynamicShadowResolution) && AcShadowsPatcher.IsSupposedToWork()) { properties.SetAdditional(new AcShadowsPatcher(starter)); } return(starter); }
/********* ** Private methods *********/ /// <summary>The method which transpiles <see cref="Crop.harvest"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_Harvest(IEnumerable <CodeInstruction> instructions) { return(instructions .MethodReplacer( from: PatchHelper.RequireMethod <Game1>(nameof(Game1.createItemDebris)), to: PatchHelper.RequireMethod <CropPatcher>(nameof(Game_CreateItemDebris)) ) .MethodReplacer( from: PatchHelper.RequireMethod <Farmer>(nameof(Farmer.addItemToInventoryBool)), to: PatchHelper.RequireMethod <CropPatcher>(nameof(Farmer_AddItemToInventoryBool)) )); }
private PatchResult PatchViewModel(ICommonAssembly assembly, ICommonType viewModelBaseType, ICommonType viewModelType) { log.Info($"Loading type '{viewModelType.FullName}'..."); viewModelType.Load(1); log.Info($"Type '{viewModelType.FullName}' was loaded"); var patchingType = viewModelType.GetReflectionAttribute <PatchingViewModelAttribute>()?.PatchingType ?? applicationPatcherWpfConfiguration.DefaultViewModelPatchingType; log.Info($"View model patching type: '{patchingType}'"); return(PatchHelper.PatchApplication(viewModelPartPatchers, patcher => patcher.Patch(assembly, viewModelBaseType, viewModelType, patchingType), log)); }
private PatchResult PatchFrameworkElement(ICommonAssembly assembly, ICommonType frameworkElementType) { log.Info($"Loading type '{frameworkElementType.FullName}'..."); frameworkElementType.Load(1); log.Info($"Type '{frameworkElementType.FullName}' was loaded"); var patchingType = frameworkElementType.GetReflectionAttribute <PatchingFrameworkElementAttribute>()?.PatchingType ?? applicationPatcherWpfConfiguration.DefaultFrameworkElementPatchingType; log.Info($"Framework element patching type: '{patchingType}'"); return(PatchHelper.PatchApplication(frameworkElementPartPatchers, patcher => patcher.Patch(assembly, frameworkElementType, patchingType), log)); }
private void Patch_Tooltip_WriteIngredients(ModuleDef module, TypeDef parentType) { var parentMethods = new[] { parentType.FindMethod("BuildTech"), parentType.FindMethod("Recipe") }; foreach (var method in parentMethods) { PatchHelper.ReplaceCall(method, _tooltipFactoryWriteIngredientsOriginal, _tooltipFactoryWriteIngredientsPatch); } }
/// <summary>The method which transpiles <see cref="HoeDirt.DrawOptimized"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_DrawOptimized(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { bool foundFert = false; bool stopCaring = false; bool replaceNextLdLoc = false; // When we find the the fertilizer reference, replace the next draw with our call // Add the HoeDirt instance at the end of the argument list var newInsns = new List <CodeInstruction>(); foreach (var insn in insns) { if (stopCaring) { newInsns.Add(insn); continue; } if (insn.opcode == OpCodes.Ldfld && (insn.operand as FieldInfo).Name == "fertilizer") { newInsns.Add(insn); foundFert = true; replaceNextLdLoc = true; } else if (replaceNextLdLoc && insn.IsLdloc()) { // Instead of loading the fertilizer and looking at it // we simply stick a 1 on the stack. newInsns.Add(new CodeInstruction(OpCodes.Ldc_I4_1)); replaceNextLdLoc = false; } else if (foundFert && insn.opcode == OpCodes.Callvirt && (insn.operand as MethodInfo).Name == "Draw") { newInsns.Add(new CodeInstruction(OpCodes.Ldarg_0)); insn.opcode = OpCodes.Call; insn.operand = PatchHelper.RequireMethod <HoeDirtPatcher>(nameof(DrawMultiFertilizer)); newInsns.Add(insn); stopCaring = true; } else { newInsns.Add(insn); } } return(newInsns); }
/********* ** Private methods *********/ /// <summary>The method which transpiles <see cref="Game1.UpdateGameClock"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_UpdateGameClock(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { List <CodeInstruction> ret = new List <CodeInstruction>(); foreach (var insn in insns) { if (insn.opcode == OpCodes.Ldc_I4 && (int)insn.operand == 7000) { ret.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <Game1Patcher>(nameof(GetTimeInterval)))); continue; } ret.Add(insn); } return(ret); }
public Helper HelperPatch(PatchHelper patchHelper) { Helper helper = null; using (var con = new NpgsqlConnection(connectionString)) { con.Open(); if (patchHelper.patched_id >= 0) { using (var cmd = new NpgsqlCommand($"UPDATE helper_table SET patched_id = @patched_id", con)) { cmd.Parameters.AddWithValue("patched_id", patchHelper.patched_id); cmd.ExecuteNonQuery(); } } if (patchHelper.patched_table_id >= 0) { using (var cmd = new NpgsqlCommand($"UPDATE helper_table SET patched_table_id = @patched_table_id", con)) { cmd.Parameters.AddWithValue("patched_table_id", patchHelper.patched_table_id); cmd.ExecuteNonQuery(); } } if (patchHelper.current_user_id >= 0) { using (var cmd = new NpgsqlCommand($"UPDATE helper_table SET current_user_id = @current_user_id", con)) { cmd.Parameters.AddWithValue("current_user_id", patchHelper.current_user_id); cmd.ExecuteNonQuery(); } } using (var cmd = new NpgsqlCommand($"SELECT * FROM helper_table", con)) using (var reader = cmd.ExecuteReader()) while (reader.Read()) { helper = new Helper { helper_table_id = reader.GetInt32(0), patched_id = reader.GetIntOrDefault(1), patched_table_id = reader.GetIntOrDefault(2), current_user_id = reader.GetIntOrDefault(3) } } ; return(helper); } } }
public void ShouldPatchDataSet1709251127Diff() { string dataSetId = "D1709251127"; var diff = DataSetHelper.ReadFileContent(dataSetId, "Diff-b3a6303-781096c.diff"); FileDiff[] files = DiffParserHelper.Parse(diff, Environment.NewLine).ToArray(); FileDiff file = files[0]; string srcString = DataSetHelper.ReadFileContent(dataSetId, "Diff-b3a6303.txt"); string expectedString = DataSetHelper.ReadFileContent(dataSetId, "Diff-781096c.txt").Trim(); string patchedString = PatchHelper.Patch(srcString, file.Chunks, Environment.NewLine).Trim(); Assert.AreEqual(expectedString, patchedString); }
/********* ** Private methods *********/ /// <summary>The method which transpiles <see cref="Crop.newDay"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_NewDay(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> instructions) { instructions = instructions.ToArray(); // Copied/modified from Json Assets // TODO: Learn how to use ILGenerator try { var newInstructions = new List <CodeInstruction>(); int hookCountdown = 0; bool justHooked = false; object label = null; foreach (var instr in instructions) { // If this is the spot for our hook, inject it if (hookCountdown > 0 && --hookCountdown == 0) { newInstructions.Add(new CodeInstruction(OpCodes.Ldarg_0)); newInstructions.Add(new CodeInstruction(OpCodes.Ldfld, typeof(Crop).GetField(nameof(Crop.indexOfHarvest)))); newInstructions.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <CropPatcher>(nameof(CheckCanBeGiant)))); newInstructions.Add(new CodeInstruction(OpCodes.Brtrue_S, label)); } // The only reference to 276 is the index of the pumpkin for checking for giant crops growing if (instr.opcode == OpCodes.Ldc_I4 && (int)instr.operand == 276) { // In two instructions (after this and the next), we want our check hookCountdown = 2; justHooked = true; } // If this is the instruction after the previous check, we want to borrow the label for our own use else if (justHooked) { label = instr.operand; justHooked = false; } newInstructions.Add(instr); } return(newInstructions); } catch (Exception ex) { Log.Error($"Failed in {nameof(Transpile_NewDay)}:\n{ex}"); return(instructions); } }
/// <summary>The method which transpiles <see cref="LevelUpMenu.AddMissedProfessionChoices"/> and <see cref="LevelUpMenu.AddMissedLevelRecipes"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_AddMissedProfessionChoices_And_AddMissedLevelRecipes(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { // TODO: Learn how to use ILGenerator var newInsns = new List <CodeInstruction>(); foreach (var insn in insns) { newInsns.Add(insn); if (insn.opcode == OpCodes.Call && ((MethodInfo)insn.operand).Name.Contains("InitializeArray")) { newInsns.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <LevelUpMenuPatcher>(nameof(GetFixedArray)))); } } return(newInsns); }
/********* ** Private methods *********/ /// <summary>The method which transpiles <see cref="Crop.harvest"/>.</summary> private static IEnumerable <CodeInstruction> Transpile_Harvest(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> insns) { // TODO: Learn how to use ILGenerator var newInsns = new List <CodeInstruction>(); LocalBuilder randVar = null; Label pendingLabel = default(Label); foreach (var insn in insns) { if (insn.operand is LocalBuilder { LocalIndex: 9 } lb) { randVar = lb; } if (insn.opcode == OpCodes.Stloc_S && ((LocalBuilder)insn.operand).LocalIndex == 7 /* cropQuality, TODO: Check somehow */) { var prevInsn = newInsns[newInsns.Count - 1]; var prev2Insn = newInsns[newInsns.Count - 2]; if (prevInsn.opcode == OpCodes.Ldc_I4_1 && prev2Insn.opcode == OpCodes.Bge_Un) { pendingLabel = (Label)prev2Insn.operand; newInsns.Add(insn); newInsns.Add(new CodeInstruction(OpCodes.Ldloc_S, randVar) { labels = new List <Label>(new[] { pendingLabel }) }); newInsns.Add(new CodeInstruction(OpCodes.Ldloca_S, insn.operand)); newInsns.Add(new CodeInstruction(OpCodes.Call, PatchHelper.RequireMethod <CropPatcher>(nameof(ModifyCropQuality)))); continue; } } if (insn.labels.Contains(pendingLabel)) { Log.Trace("taking label"); insn.labels.Remove(pendingLabel); pendingLabel = default(Label); } newInsns.Add(insn); } return(newInsns); }
/// <summary>The method which transpiles <see cref="CollectionsPage.createDescription"/>.</summary> /// <returns>Returns whether to run the original method.</returns> private static IEnumerable <CodeInstruction> Transpile_CollectionsPage_CreateDescription(ILGenerator gen, MethodBase original, IEnumerable <CodeInstruction> instructions) { var newInstructions = new List <CodeInstruction>(); foreach (var instruction in instructions) { if (instruction.opcode == OpCodes.Newobj && instruction.operand is ConstructorInfo constructor && constructor.DeclaringType == typeof(CraftingRecipe) && constructor.GetParameters().Length == 2) { Log.Trace($"Found crafting recipe constructor in {original}!"); instruction.opcode = OpCodes.Call; instruction.operand = PatchHelper.RequireMethod <CraftingRecipePatcher>(nameof(RedirectedCreateRecipe)); } newInstructions.Add(instruction); } return(newInstructions); }
public static bool Patch(HarmonyInstance harmonyInstance) { var patches = new List <PatchHelper.PatchClass>(); var beCheck = new PatchHelper.PatchClass { Class = typeof(EFT.UI.PocketMapTile), PatchWithClass = typeof(ZoomFix) }; var classMethods = beCheck.Class.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); foreach (var method in classMethods) { var isPublicVirtual = method.IsPublic && method.IsVirtual; if (method.IsPrivate && !isPublicVirtual) { continue; } if (method.ReturnType.ToString() != "System.Void") { continue; } var p = method.GetParameters(); if (p.Length != 0) { continue; } var b = method.GetMethodBody(); if (b is null) { continue; } var v = b.LocalVariables; if (v.Count != 1) { continue; } if (v[0].LocalType.Name != "Texture") { continue; } beCheck.Method = method; break; } patches.Add(beCheck); return(PatchHelper.PatchMethods(harmonyInstance, patches, Extensions.GetMethodInfo(() => ZoomFix.Prefix(null)))); }
public void PatchApplication(string applicationPath, string signaturePath = null) { CheckApplicationPath(applicationPath); log.Info("Reading assembly..."); var assembly = commonAssemblyFactory.Create(applicationPath); log.Info("Assembly was readed"); if (PatchHelper.PatchApplication(patchersOnNotLoadedApplication, patcher => patcher.Patch(assembly), log) == PatchResult.Cancel) { return; } log.Info("Loading assembly..."); assembly.Load(); log.Info("Assembly was loaded"); if (assembly.TypesFromThisAssembly.Any()) { log.Debug("Types from this assembly found:", assembly.TypesFromThisAssembly.Select(type => type.FullName).OrderBy(fullName => fullName)); } else { log.Debug("Types from this assembly not found"); } if (PatchHelper.PatchApplication(patchersOnLoadedApplication, patcher => patcher.Patch(assembly), log) == PatchResult.Cancel) { return; } if (PatchHelper.PatchApplication(patchersOnPatchedApplication, patcher => patcher.Patch(assembly), log) == PatchResult.Cancel) { return; } log.Info("Application was patched"); log.Info("Save assembly..."); commonAssemblyFactory.Save(assembly, applicationPath, signaturePath); log.Info("Assembly was saved"); }
private static void OnFeatureChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!(e.NewValue is string id) || PatchHelper.IsFeatureSupported(id)) { return; } switch (d) { case ColumnDefinition element: { element.Width = new GridLength(0d); element.MinWidth = 0d; break; } case FrameworkElement element: element.Visibility = Visibility.Collapsed; break; } }
protected override void _Process() { // Parameters string bnkFilePath = _GetParameter(PatchInstructionParameter.ParameterName.bnkFile); string packedFileName = _GetParameter(PatchInstructionParameter.ParameterName.newFile); string backupFolder = InstallHelper.SlotPath; if (backupFolder == null) { const string message = "Sorry, uninstallPackedFile instruction can only be run within TDU ModAndPlay."; PatchHelper.AddMessage(message); } else { _UninstallPackedFile(bnkFilePath, packedFileName, backupFolder); } }
private void OnFileSomethingChanged(string filename) { if (IsBlocked) { return; } var directory = Path.GetDirectoryName(filename); if (directory == null) { return; } directory = FileUtils.NormalizePath(directory); if (FileUtils.IsAffectedBy(_dir, filename) || string.Equals(directory, _dir, StringComparison.OrdinalIgnoreCase)) { _busyCreateConfigs.DoDelay(() => { if ((DateTime.Now - _lastSaved).TotalSeconds < 3d) { return; } CreateConfigs(); RescanPossibleIssues(); }, 300); if (FileUtils.ArePathsEqual(filename, PatchHelper.GetManifestFilename())) { _busyUpdateVersion.DoDelay(PatchHelper.Reload, 300); } } if (FileUtils.ArePathsEqual(directory, AcRootDirectory.Instance.RequireValue)) { var name = Path.GetFileName(filename); if (string.Equals(name, "dwrite.dll", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "acs.exe", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "acs.pdb", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "changelog.txt", StringComparison.OrdinalIgnoreCase)) { RescanPossibleIssues(); } } }
public void installCspBuildAsync(int build, IJavascriptCallback callback) { ActionExtension.InvokeInMainThreadAsync(async() => { var versionInfo = PatchUpdater.Instance.Versions.FirstOrDefault(x => x.Build == build); if (versionInfo == null) { callback?.ExecuteAsync($"Version {build} is missing", null); return; } if (await PatchUpdater.Instance.InstallAsync(versionInfo, CancellationToken.None)) { callback?.ExecuteAsync(null, PatchHelper.GetInstalledBuild().As(-1)); } else { callback?.ExecuteAsync("Failed to install an update", null); } }); }
public static bool Patch(HarmonyInstance harmonyInstance) { var patches = new List <PatchHelper.PatchClass>(); var asm = AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "Assembly-CSharp"); var beCheck = new PatchHelper.PatchClass() { PatchWithClass = typeof(BattlEye) }; foreach (var _class in asm.GetTypes()) { /*if (_class.Name == "Class893") * { * Logger.Trace("properties " + _class.GetProperties().Length); * Logger.Trace("fields " + _class.GetFields().Length); * Logger.Trace("methods " + _class.GetMethods().Length); * Logger.Trace("properties " + _class.GetProperties().Length); * Logger.Trace("{0}", _class.ToJson()); * }*/ if (!IsObfuscatedClass(_class) && !IsDeobfuscatedClass(_class)) { continue; } foreach (var method in _class.GetMethods()) { if (!IsMethod(method)) { continue; } beCheck.Method = method; break; } if (beCheck.Method is null) { continue; } beCheck.Class = _class; break; } patches.Add(beCheck); return(PatchHelper.PatchMethods(harmonyInstance, patches, Extensions.GetMethodInfo(() => BattlEye.Prefix("", true)))); }