public MeshBoundary(string name1, PatchType type1, string neighbourPatch1) { Faces = new List<List<int>>(); Name = name1; Type = type1; NeighbourPatch = neighbourPatch1; }
public MeshBoundary(string name1, PatchType type1, string neighbourPatch1, IEnumerable<int> faces1) { Faces = new List<List<int>>(); Name = name1; Type = type1; NeighbourPatch = neighbourPatch1; Faces.Add(new List<int>(faces1)); }
protected override void Setup() { if (TypeLayout.NativePointerSize == 4) { NativePatchType = PatchType.I4; } else { NativePatchType = PatchType.I8; } }
private static byte GetPatchTypeSize(PatchType patchType) { switch (patchType) { case PatchType.I32: return(32); case PatchType.I64: return(64); } throw new CompilerException($"unknown patch type: {patchType}"); }
public Patch(string owner, PatchType type, int index, int multiplyer, int config) { this.weeds = true; this.status = 0; this.lastUpdate = Environment.TickCount; this.ownerName = owner; this.patchType = type; this.index = index; this.multiplyer = multiplyer; this.configId = config; }
private static bool Patch(string filepath, PatchType type, IOffset offsets) { switch (type) { case PatchType.Farclip: return(ApplyPatch(filepath, offsets.SetFarclipPattern.Clone())); default: return(false); } }
public void PatchConstructor <TClass>( Type[] parameters, PatchType patchType, string prefixMethodName = default, string postfixMethodName = default) where TClass : class { var m = AccessTools.Constructor(typeof(TClass), parameters); this.PatchMethod <TClass>(m, patchType, prefixMethodName, postfixMethodName); }
protected override void Initialize() { if (TypeLayout.NativePointerSize == 4) { NativePatchType = PatchType.I32; } else { NativePatchType = PatchType.I64; } }
private static byte GetPatchTypeSize(PatchType patchType) { switch (patchType) { case PatchType.I4: return(32); case PatchType.I8: return(64); default: throw new CompilerException("unknown patch type: " + patchType.ToString()); } }
public Patch(string owner, PatchType type, int index, int configId, int[] configArray, long timeToGrow, int crop, int multiplyer) { this.ownerName = owner; this.patchType = type; this.index = index; this.configId = configId; this.configArray = configArray; this.timeToGrow = timeToGrow; this.multiplyer = multiplyer; this.weeds = true; this.status = 0; }
/// <summary> /// 打补丁 /// </summary> /// <param name="type">两种打补丁的方式:精准(指定位置替换)、通用(特征码替换)</param> /// <returns></returns> public bool Patch(PatchType type) { if (type == PatchType.Accurate) { AccuratePatch(); } else { CommonPatch(); } return(true); }
public void PatchMethod <TClass>( string methodName, Type[] parameters, PatchType patchType, Type[] generics = null, string prefixMethodName = default, string postfixMethodName = default) where TClass : class { var m = AccessTools.Method(typeof(TClass), methodName, parameters, generics); this.PatchMethod <TClass>(m, patchType, prefixMethodName, postfixMethodName); }
public void PatchMethod( Type classType, string methodName, Type[] parameters, PatchType patchType, Type[] generics = null, string prefixMethodName = default, string postfixMethodName = default) { var m = AccessTools.Method(classType, methodName, parameters, generics); this.PatchMethod(classType, m, patchType, prefixMethodName, postfixMethodName); }
/********* ** Public Methods *********/ /// <summary>Constructs an instance.</summary> /// <param name="patchType">The type of patch the method is.</param> /// <param name="type">The type that contains the method to patch.</param> /// <param name="methodName">The name of the method to patch; otherwise, <see langword="null"/> to patch a constructor.</param> /// <param name="parameterTypes">The types of parameters of the method to patch.</param> public PatchAttribute(PatchType patchType, Type type, string methodName, Type[] parameterTypes = null) { PatchType = patchType; if (methodName == null) { OriginalMethod = AccessTools.Constructor(type, parameterTypes) ?? throw new MissingMethodException($"Couldn't find constructor '{type.FullName}({string.Join(", ", (parameterTypes ?? new Type[0]).Select(parameterType => parameterType.Name))})'"); } else { OriginalMethod = AccessTools.Method(type, methodName, parameterTypes) ?? throw new MissingMethodException($"Couldn't find method '{type.FullName}.{methodName}({string.Join(", ", (parameterTypes ?? new Type[0]).Select(parameterType => parameterType.Name))})'"); } }
/// <summary> /// Initializes a new instance of LinkRequest. /// </summary> /// <param name="linkType">Type of the link.</param> /// <param name="patchType">Type of the patch.</param> /// <param name="patchSymbol">The patch symbol.</param> /// <param name="patchOffset">The patch offset.</param> /// <param name="referenceSymbol">The reference symbol.</param> /// <param name="referenceOffset">The reference offset.</param> /// public LinkRequest(LinkType linkType, PatchType patchType, LinkerSymbol patchSymbol, int patchOffset, LinkerSymbol referenceSymbol, int referenceOffset) { Debug.Assert(patchSymbol != null); Debug.Assert(referenceSymbol != null); LinkType = linkType; PatchType = patchType; PatchSymbol = patchSymbol; PatchOffset = patchOffset; ReferenceSymbol = referenceSymbol; ReferenceOffset = referenceOffset; }
/********* ** Protected methods *********/ /// <summary>Construct an instance.</summary> /// <param name="logName">A unique name for this patch shown in log messages.</param> /// <param name="type">The patch type.</param> /// <param name="contentPack">The content pack which requested the patch.</param> /// <param name="assetName">The normalized asset name to intercept.</param> /// <param name="conditions">The conditions which determine whether this patch should be applied.</param> /// <param name="normalizeAssetName">Normalize an asset name.</param> /// <param name="fromAsset">The normalized asset key from which to load the local asset (if applicable), including tokens.</param> protected Patch(string logName, PatchType type, ManagedContentPack contentPack, IManagedTokenString assetName, IEnumerable <Condition> conditions, Func <string, string> normalizeAssetName, IManagedTokenString fromAsset = null) { this.LogName = logName; this.Type = type; this.ContentPack = contentPack; this.ManagedRawTargetAsset = assetName; this.Conditions = conditions.ToArray(); this.NormalizeAssetNameImpl = normalizeAssetName; this.PrivateContext = new LocalContext(scope: this.ContentPack.Manifest.UniqueID); this.ManagedRawFromAsset = fromAsset; this.Contextuals .Add(this.Conditions) .Add(assetName); }
/// <summary> /// c.根据补丁信息,安装补丁 /// 两种打补丁的方式:精准(指定位置替换)、通用(特征码替换) /// </summary> /// <param name="type">两种打补丁的方式:精准(指定位置替换)、通用(特征码替换)</param> /// <returns></returns> public bool Patch(PatchType type = PatchType.Accurate) { // 首先验证文件修改器是否没问题 foreach (FileHexEditor editor in editors) { if (type == PatchType.Accurate && editor.FileModifyInfo == null) { throw new Exception("补丁安装失败,原因:文件修改器初始化失败!"); } if (type == PatchType.Common && editor.FileCommonModifyInfo == null) { throw new Exception("补丁安装失败,原因:特征码修改器初始化失败!"); } } // 再备份所有文件 foreach (FileHexEditor editor in editors) { editor.Backup(); } // 打补丁! List <FileHexEditor> done = new List <FileHexEditor>(); // 已经打上补丁的 try { foreach (FileHexEditor editor in editors) { bool success = editor.Patch(type); if (!success) { editor.Restore(); } else { done.Add(editor); } } } catch (Exception ex) { // 恢复所有已经打上补丁的文件 foreach (FileHexEditor editor in done) { editor.Restore(); } throw ex; } return(true); }
private static RelocationType ConvertType(PatchType patchType, LinkType linkType, MachineType machineType) { if (machineType == MachineType.Intel386) { if (linkType == LinkType.AbsoluteAddress) { return(RelocationType.R_386_32); } else if (linkType == LinkType.RelativeOffset) { return(RelocationType.R_386_PC32); } } return(RelocationType.R_386_NONE); }
/// <summary> /// Re-evaluate the type of the patch, sets the Type. /// </summary> private void EvaluateType() { long negspan = (long)(StartOffset - EndOffset); if (StartOffset == EndOffset && EndMove == _patchdata.Length) { Type = PatchType.Insert; } else if (_patchdata.Length == 0 && negspan == EndMove) { Type = PatchType.Delete; } else { Type = PatchType.Replace; } }
public DolPatch(String path, UInt32 start, UInt32 end, Int32 offset) : this(path) { var tmp = default(UInt32); if (start > end) { tmp = end; end = start; start = tmp; } if (this.GetFileAddress((UInt32)(start + offset)) == 0 || this.GetFileAddress((UInt32)(end + offset)) == 0) { throw new Exception("addr out of memory boundaries"); } this.StartAddress = start; this.EndAddress = end; this.Offset = offset; this._PatchType = PatchType.ScrollCode; }
public PatchDescriptor(MethodInfo method, PatchAttribute attr) { patchMethod = method; patchAttribute = attr; if (patchAttribute is ReplaceAttribute) { patchType = PatchType.Replace; } else if (patchAttribute is PreHookAttribute) { patchType = PatchType.PreHook; } else if (patchAttribute is PostHookAttribute) { patchType = PatchType.PostHook; } else { throw new ArgumentException("Unknown PatchAttribute! " + attr, "attr"); } }
public static bool PatchEdiabas(StringBuilder sr, PatchType patchType, int adapterType, string dirName, BluetoothDeviceInfo devInfo, WlanInterface wlanIface, string pin) { try { sr.AppendFormat(Resources.Strings.PatchDirectory, dirName); if (!PatchFiles(sr, dirName)) { return(false); } string configFile = Path.Combine(dirName, ConfigFileName); if (!UpdateConfigFile(configFile, adapterType, devInfo, wlanIface, pin)) { sr.Append("\r\n"); sr.Append(Resources.Strings.PatchConfigUpdateFailed); return(false); } sr.Append("\r\n"); sr.Append(Resources.Strings.PatchConfigUpdateOk); switch (patchType) { case PatchType.Istad: sr.Append("\r\n"); sr.Append(Resources.Strings.PatchInstadInfo); break; case PatchType.VasPc: sr.Append("\r\n"); sr.Append(Resources.Strings.PatchVaspcInfo); break; } } catch (Exception) { sr.Append("\r\n"); sr.Append(Resources.Strings.PatchConfigUpdateFailed); return(false); } return(true); }
private void button5_Click(object sender, EventArgs e) { PatchType PatchType = (PatchType)cbDataFormat.SelectedIndex; int PatchSize = PatchManager.PatchTypeLength(PatchType); if (PatchSize == 0) { if (!Common.ReadNumeric(textBox2.Text, ref PatchSize)) { return; } if (PatchSize < 0) { return; } } uint addr = 0; if (Common.ReadHex(txAddress.Text, ref addr)) { Patch DataPatch = new Patch(); DataPatch.DisplayAs = PatchType; DataPatch.Name = string.Format("Patched {0}", PatchType); DataPatch.Module = ""; DataPatch.Offset = addr; // TODO: Read original memory at this location DataPatch.Original = Nops(PatchSize); DataPatch.Patched = Nops(PatchSize); patchMan.Data.Add(DataPatch); RefreshPatches(); } }
public FileHeader(byte[] b, int offset) { buf = b; startOffset = offset; changeType = ChangeType.MODIFY; // unless otherwise designated patchType = PatchType.UNIFIED; }
/// <summary> /// パッチの種類を設定する /// </summary> /// <param name="gameType">ゲームの種類</param> private static void SetPatchType(GameType gameType) { switch (gameType) { case GameType.Unknown: // 不明 _patchType = PatchType.Unknown; AppendLog("PatchType: Unknown\n\n"); break; case GameType.CrusaderKings: _patchType = PatchType.CrusaderKings; AppendLog("PatchType: Crusader Kings\n\n"); break; case GameType.EuropaUniversalis2: _patchType = PatchType.EuropaUniversalis2; AppendLog("PatchType: Europa Universalis 2\n\n"); break; case GameType.ForTheGlory: _patchType = PatchType.ForTheGlory; AppendLog("PatchType: For the Glory\n\n"); break; case GameType.Victoria: _patchType = PatchType.Victoria; AppendLog("PatchType: Victoria\n\n"); break; case GameType.HeartsOfIron: _patchType = PatchType.HeartsOfIron; AppendLog("PatchType: Hearts of Iron\n\n"); break; case GameType.HeartsOfIron2: _patchType = PatchType.HeartsOfIron2; AppendLog("PatchType: Hearts of Iron 2\n\n"); break; case GameType.ArsenalOfDemocracy: _patchType = PatchType.ArsenalOfDemocracy; AppendLog("PatchType: Arsenal of Democracy\n\n"); break; case GameType.DarkestHour: _patchType = PatchType.DarkestHour; AppendLog("PatchType: Darkest Hour\n\n"); break; default: _patchType = PatchType.Unknown; AppendLog("PatchType: Unknown\n\n"); break; } }
/// <summary> /// バージョンを判別する /// </summary> /// <returns>判別に成功すればtrueを返す</returns> private static bool IdentifyGameVersion() { switch (_patchType) { case PatchType.HeartsOfIron2: case PatchType.ArsenalOfDemocracy: case PatchType.DarkestHour: break; default: // バージョン判別の必要ないゲームでは何もせずに戻る return true; } AppendLog("ScanBinary - 特定バイナリを探す\n"); AppendLog(" \"%XX バージョン文字列\"を探します\n"); byte[] pattern; List<uint> l; uint offset; switch (_patchType) { case PatchType.HeartsOfIron2: // Doomsday Armageddon v X.X pattern = new byte[] { 0x44, 0x6F, 0x6F, 0x6D, 0x73, 0x64, 0x61, 0x79, 0x20, 0x41, 0x72, 0x6D, 0x61, 0x67, 0x65, 0x64, 0x64, 0x6F, 0x6E, 0x20, 0x76, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { // Iron Cross Armageddon X.XX pattern = new byte[] { 0x49, 0x72, 0x6F, 0x6E, 0x20, 0x43, 0x72, 0x6F, 0x73, 0x73, 0x20, 0x41, 0x72, 0x6D, 0x61, 0x67, 0x65, 0x64, 0x64, 0x6F, 0x6E, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { return false; } offset = l[0] + (uint) pattern.Length; _gameVersion = (_data[offset] - '0') * 100 + (_data[offset + 2] - '0') * 10 + (_data[offset + 3] - '0'); } else { offset = l[0] + (uint) pattern.Length; _gameVersion = (_data[offset] - '0') * 100 + (_data[offset + 2] - '0') * 10; } break; case PatchType.ArsenalOfDemocracy: // Arsenal of Democracy X.XX pattern = new byte[] { 0x41, 0x72, 0x73, 0x65, 0x6E, 0x61, 0x6C, 0x20, 0x6F, 0x66, 0x20, 0x44, 0x65, 0x6D, 0x6F, 0x63, 0x72, 0x61, 0x63, 0x79, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { // Arsenal Of Democracy v X.XX pattern = new byte[] { 0x41, 0x72, 0x73, 0x65, 0x6E, 0x61, 0x6C, 0x20, 0x4F, 0x66, 0x20, 0x44, 0x65, 0x6D, 0x6F, 0x63, 0x72, 0x61, 0x63, 0x79, 0x20, 0x76, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { return false; } } offset = l[0] + (uint) pattern.Length; _gameVersion = (_data[offset] - '0') * 100 + (_data[offset + 2] - '0') * 10 + (_data[offset + 3] - '0'); break; case PatchType.DarkestHour: // Darkest Hour v X.XX pattern = new byte[] { 0x44, 0x61, 0x72, 0x6B, 0x65, 0x73, 0x74, 0x20, 0x48, 0x6F, 0x75, 0x72, 0x20, 0x76, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { return false; } offset = l[0] + (uint) pattern.Length; _gameVersion = (_data[offset] - '0') * 100 + (_data[offset + 2] - '0') * 10 + (_data[offset + 3] - '0'); break; default: // Doomsday Armageddon v X.X pattern = new byte[] { 0x44, 0x6F, 0x6F, 0x6D, 0x73, 0x64, 0x61, 0x79, 0x20, 0x41, 0x72, 0x6D, 0x61, 0x67, 0x65, 0x64, 0x64, 0x6F, 0x6E, 0x20, 0x76, 0x20 }; l = BinaryScan(_data, pattern, 0, (uint) _fileSize); if (l.Count == 0) { return false; } offset = l[0] + (uint) pattern.Length; _gameVersion = (_data[offset] - '0') * 100 + (_data[offset + 2] - '0') * 10; break; } AppendLog("ScanBinary passed\n\n"); switch (_patchType) { case PatchType.HeartsOfIron2: if (_gameVersion < 110) { _patchType = PatchType.IronCrossHoI2; AppendLog("PatchType: Iron Cross / Hearts of Iron 2\n\n"); } else if (_gameVersion <= 120) { _patchType = PatchType.HeartsOfIron212; AppendLog("PatchType: Hearts of Iron 2 1.2\n\n"); } else { _patchType = PatchType.HeartsOfIron2; AppendLog("PatchType: Hearts of Iron 2\n\n"); } break; case PatchType.ArsenalOfDemocracy: if (_gameVersion <= 104) { _patchType = PatchType.ArsenalOfDemocracy104; AppendLog("PatchType: Arsenal of Democracy 1.04\n\n"); } else if (_gameVersion <= 107) { _patchType = PatchType.ArsenalOfDemocracy107; AppendLog("PatchType: Arsenal of Democracy 1.07\n\n"); } else if (_gameVersion <= 109) { _patchType = PatchType.ArsenalOfDemocracy109; AppendLog("PatchType: Arsenal of Democracy 1.09\n\n"); } else { _patchType = PatchType.ArsenalOfDemocracy; AppendLog("PatchType: Arsenal of Democracy\n\n"); } break; case PatchType.DarkestHour: if (_gameVersion <= 102) { _patchType = PatchType.DarkestHour102; AppendLog("PatchType: Darkest Hour 1.02\n\n"); } else { _patchType = PatchType.DarkestHour; AppendLog("PatchType: Darkest Hour\n\n"); } break; } return true; }