public static void UploadPatch(Patches.PatchInfo info) { string hostFile = AppDomain.CurrentDomain.BaseDirectory + "\\host.txt"; if (File.Exists(hostFile)) { BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (sender, args) => { Log.W("Uploading " + info.name + "..."); Uri uri = new Uri(File.ReadAllText(hostFile).Trim()); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.ExpectContinue = false; client.Timeout = TimeSpan.FromHours(1); List<Patches.PatchInfo.PFile> files = new List<Patches.PatchInfo.PFile>(); foreach (KeyValuePair<string, Patches.PatchInfo.PFile> file in info.files) { files.Add(file.Value); } var content = new StringContent(JsonConvert.SerializeObject(new object[] { new KeyValuePair<string, string>("name", info.name), new KeyValuePair<string, string>("parent", info.parentName), new KeyValuePair<string, string>("created", ToEpochTime(info.creationTime).ToString()), new KeyValuePair<string, List<Patches.PatchInfo.PFile>> ("files", files), new KeyValuePair<string, List<string>> ("new", info.newFiles), new KeyValuePair<string, List<string>> ("modified", info.modifiedFiles), new KeyValuePair<string, List<string>> ("deleted", info.deletedFiles) }), Encoding.UTF8, "application/json"); //Console.WriteLine(content.ReadAsStringAsync().Result); HttpResponseMessage response = client.PostAsync(uri, content).Result; if (response.IsSuccessStatusCode) { Console.WriteLine(response.Content.ReadAsStringAsync().Result); Log.W("Done Uploading " + info.name + "..."); } else { //Console.WriteLine(response.Content.ReadAsStringAsync().Result); Log.W("Done Uploading " + info.name + "... ERROR!"); } }; bw.RunWorkerAsync(); } else { Log.W("Please create a file named host.txt next to the executable containing the url you want to post the data to."); } }
public static void LoadPatches() { if (!File.Exists(Program.PatchFile)) { MessageBox.Show("No Patch ("+Program.PatchFile+") file. Failing miserably."); Application.Exit(); return; } string patchList = File.ReadAllText(Program.PatchFile); LoadedPatches = JsonConvert.DeserializeObject<MagicPatches.Patches>(patchList); LoadedPatches.PatchList = LoadedPatches.PatchList.OrderBy(patch => patch.title).ToList(); }
private void Form1_Load(object sender, EventArgs e) { Log.PatchList = lstPatches; Log.AddButton = btnAdd; Log.ProgressBar = proBar; Log.RTB = rtbLogs; Log.W("Duh herro..."); patches = new Patches(); lstPatches.DataSource = patches.List; PatchNotes.AutoUpdate = false; PatchNotes.OnLoaded = UpdateNotes; PatchNotes.Load(); }
public static void Init(string directory, string settingsJson) { ModDirectory = directory; try { ModSettings = JsonConvert.DeserializeObject <Settings>(settingsJson); } catch (Exception ex) { Logger.Error(ex); ModSettings = new Settings(); } HarmonyInstance.DEBUG = ModSettings.debug; var harmony = HarmonyInstance.Create(ModId); harmony.PatchAll(Assembly.GetExecutingAssembly()); Patches.Apply(harmony); }
private void SmoothPatches(Polygon vertices, float smoothAmount) { for (var i = 0; i < vertices.Vertices.Count; i++) { var point = vertices.Vertices[i]; var prev = vertices.GetPreviousVertex(point); var next = vertices.GetNextVertex(point); var smoothed = Vector2.SmoothVertex(point, prev, next, smoothAmount); var affected = Patches.Where(p => p.Shape.Vertices.Contains(point)).ToList(); foreach (var patch in affected) { patch.Shape.ReplaceVertex(point, smoothed); } vertices.Vertices[i] = smoothed; } }
public override void Draw() { Patches.Clear(); UISys.Skin().DrawBox((int)WidX, (int)WidY, (int)WidW, (int)WidH); UISys.Skin().DrawBoxText((int)(WidX + WidW / 2 - UISys.Skin().SmallFont.Width(Name) / 2), (int)WidY + 8, Name); int oy = Scroll.Current; int dy = 30 - oy; sy = -1; ey = -1; foreach (var i in ItemRoot.Sub) { dy = DrawItem(i, dy); } Scroll.Max = (dy + oy); Scroll.ViewH = (ey - sy); Scroll.Rebuild(); }
public void InitLogger() { SeriLogger.Information("Patching Log Methods..."); // RocketMod Harmony.Patch(ReflectionHelper.FindMethod <RocketLogger, string, bool>("Log"), ReflectionHelper.FindHMethod <LogPatches>("Patch_Log1")); Harmony.Patch(ReflectionHelper.FindMethod <RocketLogger, string, ConsoleColor>("Log"), ReflectionHelper.FindHMethod <LogPatches>("Patch_Log2")); Harmony.Patch(ReflectionHelper.FindMethod <RocketLogger, string>("LogWarning"), ReflectionHelper.FindHMethod <LogPatches>("Patch_LogWarning")); Harmony.Patch(ReflectionHelper.FindMethod <RocketLogger, string>("LogError"), ReflectionHelper.FindHMethod <LogPatches>("Patch_LogError1")); Harmony.Patch(ReflectionHelper.FindMethod <RocketLogger, Exception, string>("LogError"), ReflectionHelper.FindHMethod <LogPatches>("Patch_LogError2")); // CommandWindow Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, object>("Log"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_Log")); Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, string, object[]>("LogFormat"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_LogFormat")); Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, object>("LogWarning"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_LogWarning")); Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, string, object[]>("LogWarningFormat"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_LogWarningFormat")); Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, object>("LogError"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_LogError")); Harmony.Patch(ReflectionHelper.FindMethod <CommandWindow, string, object[]>("LogErrorFormat"), ReflectionHelper.FindHMethod <LogPatches>("Patch_U_LogErrorFormat")); // UnturnedLog Harmony.Patch(ReflectionHelper.FindMethod <string>("info", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_info")); Harmony.Patch(ReflectionHelper.FindMethod <string>("warn", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_warn")); Harmony.Patch(ReflectionHelper.FindMethod <string>("error", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_error")); Harmony.Patch(ReflectionHelper.FindMethod <Exception>("exception", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_exception1")); Harmony.Patch(ReflectionHelper.FindMethod <Exception, string, object[]>("exception", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_exception2")); Harmony.Patch(ReflectionHelper.FindMethod <object>("info", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_object_info")); Harmony.Patch(ReflectionHelper.FindMethod <object>("warn", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_object_warn")); Harmony.Patch(ReflectionHelper.FindMethod <object>("error", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_object_error")); Harmony.Patch(ReflectionHelper.FindMethod <string, object[]>("info", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_format_info")); Harmony.Patch(ReflectionHelper.FindMethod <string, object[]>("warn", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_format_warn")); Harmony.Patch(ReflectionHelper.FindMethod <string, object[]>("error", typeof(UnturnedLog)), ReflectionHelper.FindHMethod <LogPatches>("Patch_UL_format_error")); foreach (var m in Harmony.GetPatchedMethods()) { Patches p = Harmony.GetPatchInfo(m); foreach (Patch pinfo in p.Prefixes.Where(x => x.owner == "RocketLog")) { LogPatches.PatcheNames.Add($"{m.DeclaringType.FullName}.{m.Name}_Patch{pinfo.index + 1}"); } } SeriLogger.Information($"Patched {LogPatches.PatcheNames.Count} methods."); }
private static object CreateOldPatches(Assembly oldAssembly, Patches newPatches) { if (newPatches == null) { return(null); } var oldPatchesType = oldAssembly.GetType("Harmony.Patches"); var oldPatchType = oldAssembly.GetType("Harmony.Patch"); // Patches(Patch[] prefixes, Patch[] postfixes, Patch[] transpilers) var oldPatches = Activator.CreateInstance(oldPatchesType, new object[] { CreateOldPatchArray(oldPatchType, newPatches.Prefixes), CreateOldPatchArray(oldPatchType, newPatches.Postfixes), CreateOldPatchArray(oldPatchType, newPatches.Transpilers) }); return(oldPatches); }
public YAMLNode ExportYAML(IExportContainer container) { YAMLMappingNode node = new YAMLMappingNode(); node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion)); node.Add(PatchesName, Patches.ExportYAML(container)); node.Add(DetailPrototypesName, DetailPrototypes.ExportYAML(container)); node.Add(PatchCountName, PatchCount); node.Add(PatchSamplesName, PatchSamples); node.Add(RandomRotationsName, RandomRotations.ExportYAML(container)); node.Add(WavingGrassTintName, WavingGrassTint.ExportYAML(container)); node.Add(WavingGrassStrengthName, WavingGrassStrength); node.Add(WavingGrassAmountName, WavingGrassAmount); node.Add(WavingGrassSpeedName, WavingGrassSpeed); node.Add(TreeInstancesName, TreeInstances.ExportYAML(container)); node.Add(TreePrototypesName, TreePrototypes.ExportYAML(container)); node.Add(PreloadTextureAtlasDataName, PreloadTextureAtlasData.ExportYAML(container)); return(node); }
public static void UnpatchMethod(MethodInfo method) { foreach (MethodBase methodBase in Harmony.GetAllPatchedMethods()) { Patches infos = Harmony.GetPatchInfo(methodBase); var allPatches = infos.Prefixes.Concat(infos.Postfixes, infos.Transpilers, infos.Finalizers); if (!allPatches.Any(patch => patch.PatchMethod == method)) { continue; } Modbase.Harmony.Unpatch(methodBase, method); return; } Warn("Failed to locate method to unpatch"); }
public YAMLNode ExportYAML(IExportContainer container) { #warning TODO: values acording to read version (current 2017.3.0f3) YAMLMappingNode node = new YAMLMappingNode(); node.AddSerializedVersion(GetSerializedVersion(container.Version)); node.Add("m_Patches", Patches.ExportYAML(container)); node.Add("m_DetailPrototypes", DetailPrototypes.ExportYAML(container)); node.Add("m_PatchCount", PatchCount); node.Add("m_PatchSamples", PatchSamples); node.Add("m_RandomRotations", RandomRotations.ExportYAML(container)); node.Add("WavingGrassTint", WavingGrassTint.ExportYAML(container)); node.Add("m_WavingGrassStrength", WavingGrassStrength); node.Add("m_WavingGrassAmount", WavingGrassAmount); node.Add("m_WavingGrassSpeed", WavingGrassSpeed); node.Add("m_TreeInstances", TreeInstances.ExportYAML(container)); node.Add("m_TreePrototypes", TreePrototypes.ExportYAML(container)); node.Add("m_PreloadTextureAtlasData", PreloadTextureAtlasData.ExportYAML(container)); return(node); }
public void Initialize() { IReadOnlyList <PatchFile> patchFiles; if (Module.InTheMiddleOfInteractiveRebase()) { Patches.DataSource = patchFiles = Module.GetInteractiveRebasePatchFiles(); } else { Patches.DataSource = patchFiles = Module.GetRebasePatchFiles(); } if (patchFiles.Any()) { int rowsInView = Patches.DisplayedRowCount(false); Patches.FirstDisplayedScrollingRowIndex = Math.Max(0, patchFiles.TakeWhile(pf => !pf.IsNext).Count() - (rowsInView / 2)); } }
private static Pattern <Patches> SwapSplitRectangles(Pattern <Patches> pattern) { var rowCount = pattern.RowCount; var columnCount = pattern.ColumnCount; var values = new Patches[rowCount, columnCount]; for (int row = 0; row < rowCount; ++row) { for (int column = 0; column < columnCount; ++column) { values[row, column] = Resources.SwapSplitRectanglesPatchMapper.Map(pattern.Values[row, column]); } } var swappedPattern = new Pattern <Patches>(values); return(swappedPattern); }
public override void Load() { Patches.Add(new PatchItem { Title = "Test Item", Info = "This is a test item", Selected = true, }); Patches.Add(new PatchItem { Title = "Test Item 2", Info = "This is another test item", Selected = false, }); Patches[0].CommandArgumets.Add(new PatchArgument <string> { Name = "MieMie", }); }
public static void Init(string modDir, string settings) { Log("Starting up"); harmony = HarmonyInstance.Create("ca.gnivler.BattleTech.Z_JK_AppearanceDates"); harmony.PatchAll(Assembly.GetExecutingAssembly()); // read settings try { ModSettings = JsonConvert.DeserializeObject <Settings>(settings); ModSettings.modDirectory = modDir; } catch (Exception) { ModSettings = new Settings(); } Patches.Init(); //File.WriteAllText(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + "settings.json", JSON.ToNiceJSON(ModSettings, new JSONParameters())); }
private void RefreshListOfPatchOwners(string modId, bool reset = true) { if (reset || _modIdsToColor == null) { _modIdsToColor = new Dictionary <string, string>(); } foreach (Patch patch in Harmony.GetAllPatchedMethods().SelectMany(method => { Patches patches = Harmony.GetPatchInfo(method); return(patches.Prefixes.Concat(patches.Transpilers).Concat(patches.Postfixes)); })) { if (!_modIdsToColor.ContainsKey(patch.owner)) { _modIdsToColor[patch.owner] = ColorUtility.ToHtmlStringRGBA(UnityEngine.Random.ColorHSV(0f, 1f, 0.25f, 1f, 0.75f, 1f)); } } }
void Start() { CarController = GetComponent <RCC_CarControllerV3>(); CarController.canControl = false; patch_script = GameObject.Find("Game").GetComponent <Patches>(); collider_driver = transform.FindChild("controller").FindChild("collider_driver"); collider_stop = collider_driver.FindChild("collider_stop"); collider_racer = collider_driver.FindChild("collider_racer"); if (collider_stop) { col_stop_script = collider_stop.GetComponent <Trigger>(); } collider_right_ob = collider_racer.FindChild("collider_right").transform; collider_left_ob = collider_racer.FindChild("collider_left").transform; col_right_script = collider_right_ob.GetComponent <Trigger>(); col_left_script = collider_left_ob.GetComponent <Trigger>(); vehicle_sc = GetComponent <Vehicle>(); Invoke("LateStart", 0.001f); rigid = GetComponent <Rigidbody>(); }
/// <summary> /// Translate this instance to a Json object. /// </summary> public RavenJObject ToJson() { var ret = new RavenJObject { { "Key", Key }, { "Method", Method }, { "Patches", new RavenJArray(Patches.Select(x => x.ToJson())) }, { "Metadata", Metadata }, { "AdditionalData", AdditionalData } }; if (Etag != null) { ret.Add("Etag", Etag.ToString()); } if (PatchesIfMissing != null && PatchesIfMissing.Length > 0) { ret.Add("PatchesIfMissing", new RavenJArray(PatchesIfMissing.Select(x => x.ToJson()))); } return(ret); }
/// <summary> /// Adds a candidate patch. /// </summary> /// <param name="patch">The patch from PLib to add.</param> public void AddPatch(object patch) { if (patch == null) { throw new ArgumentNullException("patch"); } string ver = Traverse.Create(patch).GetProperty <string>("MyVersion"); if (ver == null) { #if DEBUG LogPatchWarning("Invalid patch provided to AddPatch!"); #endif } else if (!Patches.ContainsKey(ver)) { LogPatchDebug("Candidate version {0} from {1}".F(ver, patch.GetType(). Assembly.GetName()?.Name)); Patches.Add(ver, patch); } }
/// <summary> /// Create a new instance of this class /// </summary> public PatchVersionSelectionViewModel(Window parentWindow, UserControl control) : base(parentWindow) { Patches patches = new Patches(); AllPatches = patches.GetPatches(); IProgressCommand downloadPatchesCommand = new DownloadAllPatchesCommand(settingManager); ProgressBarDialog dialog = new ProgressBarDialog(); if (dialog.DataContext is ProgressBarDialogViewModel progressViewModel) { downloadPatchesCommand.ProgressChanged += (sender, data) => { progressViewModel.UpdateProgress(data.CurrentWorkload, data.TotalWorkload); }; downloadPatchesCommand.Executed += (sender, data) => { progressViewModel.UpdateProgress(100, 100); }; } DownloadAllPatches = new MultiCommand(new List <ICommand>() { downloadPatchesCommand, new OpenCustomPopupWindowCommand(currentWindow, FontAwesomeIcon.Hourglass, "Downloading all patches", dialog, false, null) }); object dockArea = control.FindName("DP_InnerDock"); object controllerDock = control.FindName("IC_PatchSelectionControl"); if (dockArea is DockPanel panel && controllerDock is ItemsControl controller) { panelToUse = panel; OpenLaunchGameCommand = new OpenLaunchUserControlToPanel( panelToUse, new LaunchGameUserControl(parentWindow), controller ); } }
public static void ProfilePatch() { var go = new HarmonyMethod(typeof(H_HarmonyPatches), nameof(Prefix)); var biff = new HarmonyMethod(typeof(H_HarmonyPatches), nameof(Postfix)); var patches = Harmony.GetAllPatchedMethods().ToList(); foreach (var mode in patches) { Patches patchInfo = Harmony.GetPatchInfo(mode); foreach (var fix in patchInfo.Prefixes) { try { if (Analyzer.harmony.Id != fix.owner && Analyzer.perfharmony.Id != fix.owner && !PatchedPres.Contains(fix)) { PatchedPres.Add(fix); Analyzer.harmony.Patch(fix.PatchMethod, go, biff); } } catch (Exception) { } } foreach (var fix in patchInfo.Postfixes) { try { if (Analyzer.harmony.Id != fix.owner && Analyzer.perfharmony.Id != fix.owner && !PatchedPosts.Contains(fix)) { PatchedPosts.Add(fix); Analyzer.harmony.Patch(fix.PatchMethod, go, biff); } } catch (Exception) { } } } }
private static void PatchTypePatchesFull(Type type, HarmonyMethod pre, HarmonyMethod post, bool display = true) { try { foreach (var method in AccessTools.GetDeclaredMethods(type)) { Patches patches = Harmony.GetPatchInfo(method); if (patches == null) { continue; } foreach (Patch patch in patches.Prefixes) { PatchMethodFull(patch.PatchMethod, pre, post, display); } foreach (Patch patch in patches.Postfixes) { PatchMethodFull(patch.PatchMethod, pre, post, display); } foreach (Patch patch in patches.Transpilers) { PatchMethodFull(patch.PatchMethod, pre, post, display); } } if (display) { Notify($"Sucessfully Patched the methods patching {type.FullName}"); } } catch (Exception e) { if (display) { Error($"patching {type.FullName} failed, {e.Message}"); } } }
public TownGeometry GetTownGeometry(TownOptions options) { var geometry = new TownGeometry(); var buildingShapes = new List <Polygon> (); foreach (var patch in Patches.Where(p => p.Area != null)) { buildingShapes.AddRange(patch.Area.GetGeometry()); } var buildingPlacer = new BuildingPlacer(buildingShapes); var buildings = buildingPlacer.PopulateBuildings(); geometry.Buildings.AddRange(buildings); if (options.Walls) { geometry.Walls.AddRange(CityWall.GetEdges().Union(Castle.Wall.GetEdges()).Distinct()); geometry.Towers.AddRange(CityWall.Towers.Union(Castle.Wall.Towers)); geometry.Gates.AddRange(CityWall.Gates.Union(Castle.Wall.Gates)); } else { var castleWall = CityWall.GetEdges().Union(Castle.Wall.GetEdges()).Distinct().SelectMany(e => new [] { e.A, e.B }).Where(w => Castle.Patch.Shape.Vertices.Contains(w)).ToList(); var towers = CityWall.Towers.Union(Castle.Wall.Towers).Intersect(castleWall); var gates = CityWall.Gates.Union(Castle.Wall.Gates).Intersect(castleWall); geometry.Walls.AddRange(Edge.FromPointList(castleWall)); geometry.Towers.AddRange(towers); geometry.Gates.AddRange(gates); } geometry.Roads.AddRange(Roads); geometry.Roads.AddRange(Streets); geometry.Overlay.AddRange(Patches); geometry.Water.AddRange(Patches.Where(p => p.Water).Select(p => p.Shape)); geometry.WaterBorder = new Polygon(WaterBorder); return(geometry); }
public static void PatchMethodPatches(MethodInfo method, HarmonyMethod pre, HarmonyMethod post, bool display = true) { Patches patches = Harmony.GetPatchInfo(method); if (patches == null) { return; } foreach (Patch patch in patches.Prefixes) { PatchMethodFull(patch.PatchMethod, pre, post, display); } foreach (Patch patch in patches.Postfixes) { PatchMethodFull(patch.PatchMethod, pre, post, display); } foreach (Patch patch in patches.Transpilers) { PatchMethodFull(patch.PatchMethod, pre, post, display); } }
private void _ClientPatcherToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "EXE Files (*.exe)|*.exe|All Files (*.*)|*.*", InitialDirectory = Config.HglDir + "\\SP_x64" }; if (openFileDialog.ShowDialog(this) != DialogResult.OK) { return; } FileStream clientFile; try { clientFile = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.ReadWrite); } catch (Exception) { return; } Patches clientPatcher = new Patches(FileTools.StreamToByteArray(clientFile)); if (clientPatcher.ApplyHardcorePatch()) { FileStream fileOut = new FileStream(openFileDialog.FileName + ".patched.exe", FileMode.Create); fileOut.Write(clientPatcher.Buffer, 0, clientPatcher.Buffer.Length); fileOut.Dispose(); MessageBox.Show("Hardcore patch applied!"); } else { MessageBox.Show("Failed to apply Hardcore patch!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } clientFile.Dispose(); }
internal void CheckApplied() { bool notInstalled = false; bool installed = false; IList <StatusReportItem> verified = Patches.Verify(Destination, PatchExclusions).ToList(); foreach (StatusReportItem result in verified) { // don't log these results, because Verify considers being out of date to be an error if (result.Severity > StatusReportItem.SeverityCode.Warning) { // errors indicate patch needs work notInstalled = true; } else if (result.Flags.HasFlag(StatusReportItem.StatusFlags.ConfigurationUpToDate)) { // patch is installed installed = true; } // Note: ignore not applicable / excluded } if (!verified.Any()) { Status = StatusCodes.NotApplicable; } else if (installed && notInstalled) { Status = StatusCodes.ResetRequired; } else if (installed) { Status = StatusCodes.UpToDate; } else { Status = StatusCodes.OutOfDate; } }
void ConvertPatch(JArray patchBase) { foreach (var p in patchBase) { foreach (var prop in p) { var property = prop as JProperty; if (property != null) { var v = property.Value as JArray; if (v != null) { int address; if (Int32.TryParse(property.Name, out address)) { Patches.Add(new PatchObject() { address = address, patchData = v.Select(x => (byte)x).ToList() }); } else { throw new Exception($"invalid address: {property.Name}"); } } else { throw new Exception($"invalid patch property value: {property.Value.ToString()}"); } } else { throw new Exception($"invalid patch property: {prop.ToString()}"); } } } }
public static void UnPatch(Harmony harmony) { foreach (MethodBase original in harmony.GetPatchedMethods().ToList()) { bool num = original.HasMethodBody(); Patches patchInfo2 = Harmony.GetPatchInfo(original); if (num) { patchInfo2.Postfixes.DoIf(IDCheck, delegate(Patch patchInfo) { harmony.Unpatch(original, patchInfo.PatchMethod); }); patchInfo2.Prefixes.DoIf(IDCheck, delegate(Patch patchInfo) { harmony.Unpatch(original, patchInfo.PatchMethod); }); } patchInfo2.Transpilers.DoIf(IDCheck, delegate(Patch patchInfo) { harmony.Unpatch(original, patchInfo.PatchMethod); }); if (num) { patchInfo2.Finalizers.DoIf(IDCheck, delegate(Patch patchInfo) { harmony.Unpatch(original, patchInfo.PatchMethod); }); } } bool IDCheck(Patch patchInfo) { if (harmony.Id != null) { return(patchInfo.owner == harmony.Id); } return(true); } }
internal static void PrintHarmonyInfo(MethodBase method) { Patches patches = Harmony.GetPatchInfo(method); if (patches is null) { Log($"{method.Name} is not patched"); } Log("all owners: " + string.Join(", ", patches.Owners)); Log("============================="); foreach (Patch patch in patches.Postfixes.Concat(patches.Prefixes).Concat(patches.Transpilers)) { Log("index: " + patch.index); Log("owner: " + patch.owner); Log("patch method: " + patch.PatchMethod.Name); Log("priority: " + patch.priority); Log("before: " + string.Join(", ", patch.before)); Log("after: " + string.Join(", ", patch.after)); Log("============================="); } }
private static void Unpatch(HarmonyInstance harmony, MethodBase b, string id, bool pre = true, bool post = true, bool trans = true, string onlyUnpatch = null) { //FileLog.Log($"checking to unpatch: {b.FullName()}"); Patches pa = harmony.GetPatchInfo(b); if (pa == null) { //FileLog.Log("no patch attached"); return; } if (pre) { UnpatchCheckList(harmony, b, id, pa.Prefixes, onlyUnpatch); } if (post) { UnpatchCheckList(harmony, b, id, pa.Postfixes, onlyUnpatch); } if (trans) { UnpatchCheckList(harmony, b, id, pa.Transpilers, onlyUnpatch); } }
} //Update public void FindNearPoint(int _build) { Patches temp_patch_script = GameObject.Find("Game").GetComponent <Patches>(); if (_build == 1) { point_man = temp_patch_script.point_man; } else if (_build == 2) { point_man = temp_patch_script.point_man_build; } if (point_man.Count > 0) { ClassPointMan temp_point; ClassPointMan temp_near_point = null; float temp_distance_big = 1000; float temp_distance; for (var i = 0; i < point_man.Count; i++) { temp_point = point_man[i]; temp_distance = Vector3.Distance(temp_point._position, transform.position); if (temp_distance < temp_distance_big) { temp_distance_big = temp_distance; temp_near_point = temp_point; } }//for if (temp_near_point != null) { GetPoint(temp_near_point); } //temp_near_point } //Count } //FindNearPoint
public static bool Load(UnityModManager.ModEntry modEntry) { Main.Logger = modEntry.Logger; Main.settings = UnityModManager.ModSettings.Load <Main.Settings>(modEntry); HarmonyInstance harmonyInstance = HarmonyInstance.Create(modEntry.Info.Id); harmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); MethodInfo method = typeof(ActorMenu).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic); Patches patchInfo = harmonyInstance.GetPatchInfo(method); ReadOnlyCollection <Patch> readOnlyCollection = (patchInfo != null) ? patchInfo.Postfixes : null; if (readOnlyCollection == null || readOnlyCollection.Count == 0) { HarmonyMethod harmonyMethod = new HarmonyMethod(typeof(ActorMenu_Awake_Patch), "Postfix", new Type[] { typeof(ActorMenu) }); harmonyInstance.Patch(method, null, harmonyMethod, null); } modEntry.OnToggle = new Func <UnityModManager.ModEntry, bool, bool>(Main.OnToggle); modEntry.OnGUI = new Action <UnityModManager.ModEntry>(Main.OnGUI); modEntry.OnSaveGUI = new Action <UnityModManager.ModEntry>(Main.OnSaveGUI); return(true); }
public static ISkyrimMod GetOrAddPatch(string EspName, bool forLVLI = false) { if (!(EspName.Contains(Patcher.PatcherSuffix) || EspName.Contains(Patcher.PatcherLLSuffix))) { var suffix = forLVLI ? Patcher.PatcherLLSuffix : Patcher.PatcherSuffix; EspName = EspName.Replace(".esp", "") + suffix; } ModKey modKey = ModKey.FromNameAndExtension(EspName); if (Patches.ContainsKey(modKey.FileName)) { return(Patches.GetValueOrDefault(modKey.FileName)); } ISkyrimMod patch = new SkyrimMod(modKey, SkyrimRelease.SkyrimSE); Patches.TryAdd(modKey.FileName, patch); Cache.Add(patch); //var x = ModListing<ISkyrimModGetter>.CreateEnabled(patch.ModKey); //State.LoadOrder.Add((IModListing<ISkyrimModGetter>)x, State.LoadOrder.Count - 2); return(patch); }
// Update is called once per frame void Update() { int guiTime = (int)(Time.time - startTime); int minutes = guiTime / 60; int seconds = guiTime % 60; int fraction = (guiTime * 100) % 100; int passTime = 10; // in seconds //if (seconds % passTime == 0 && seconds != 0){ // c = "ON"; // patch.agePatch(); //} // bool patchState = false; //if (seconds % passTime == 0){ // if (minutes == 0){ // c = "ON"; // patchState = patch.agePatch(); // } // else if(minutes == 1 && seconds == 1){ // c = "ON"; // patch.agePatch(); // } //} //else if (seconds % passTime != 0){ // if (minutes != 0) // { // c = "ON"; // patch.agePatch(); // } // //else if(minutes == 1 && seconds == 1){ // // c = "ON"; // // patch.agePatch(); // //} //} //else c = "OFF"; ps = GameObject.Find("mcam").transform.position; if (Input.GetKeyDown("r")) { foreach(Patches patchd in pinstance){ patchd.RemPatch(); } pinstance = new List<Patches>(); } if (Input.GetKeyDown("e")) { Patches patch = new Patches((int)ps.x, (int)ps.z, 1, 1); pinstance.Add(patch); count++; } if (Input.GetKeyDown("f")) { Patches patch = new Patches((int)ps.x, (int)ps.z, 10, 10); pinstance.Add(patch); count++; } if (Input.GetKeyDown("c")){ foreach(Patches patchd in pinstance){ patchd.agePatch(); } } if (Input.GetKeyDown("x")){ foreach(Patches patchd in pinstance){ patchd.DeagePatch(); } } }
private void _HardcoreModex64DX9ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "Exectuable Files (*.exe)|*.exe|All Files (*.*)|*.*", InitialDirectory = Config.HglDir }; if (openFileDialog.ShowDialog(this) != DialogResult.OK || !openFileDialog.FileName.EndsWith("exe")) return; Patches hglexe = new Patches(File.ReadAllBytes(openFileDialog.FileName)); try { hglexe.ApplyHardcorePatch(); File.WriteAllBytes(openFileDialog.FileName.Insert(openFileDialog.FileName.Length - 4, "-patched"), hglexe.Buffer); MessageBox.Show("Patch successfully applied!"); } catch (Exception ex) { ExceptionLogger.LogException(ex, false); MessageBox.Show("Problem Applying Patch. :("); } }
private void _ClientPatcherToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "EXE Files (*.exe)|*.exe|All Files (*.*)|*.*", InitialDirectory = Config.HglDir + "\\SP_x64" }; if (openFileDialog.ShowDialog(this) != DialogResult.OK) return; FileStream clientFile; try { clientFile = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.ReadWrite); } catch (Exception) { return; } Patches clientPatcher = new Patches(FileTools.StreamToByteArray(clientFile)); if (clientPatcher.ApplyHardcorePatch()) { FileStream fileOut = new FileStream(openFileDialog.FileName + ".patched.exe", FileMode.Create); fileOut.Write(clientPatcher.Buffer, 0, clientPatcher.Buffer.Length); fileOut.Dispose(); MessageBox.Show("Hardcore patch applied!"); } else { MessageBox.Show("Failed to apply Hardcore patch!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } clientFile.Dispose(); }
private void Patches_Load(object sender, EventArgs e) { _patches = new Patches(); StatusTextBox.Text = "No Process Attached."; foreach (DictionaryEntry patch in _patches.AvailablePatches) { AvailablePatchesListBox.Items.Add(patch.Key); } }