Exemple #1
0
 public override void PrePatch()
 {
     Console.WriteLine("Requesting assembly");
     RPConfig.RequestAssembly("Assembly-CSharp.dll");
     Console.WriteLine("Loading assembly");
     FiddlerAssembly = AssemblyLoader.LoadAssembly(Path.Combine(AssembliesDir, "CM3D2.MaidFiddler.Hook.dll"));
 }
Exemple #2
0
        public override void Initialize()
        {
            TempConfigPath = Path.Combine(ReiPatcherDir, "ReiPatcher_temp.ini");

            Logger.Log(LogLevel.Info, $"Creating temporary configuration file to {TempConfigPath}");
            Configuration.SaveConfig(TempConfigPath);

            RPConfig.ConfigFilePath = TempConfigPath;
            RPConfig.SetConfig("ReiPatcher", "AssembliesDir", AssembliesDir);
        }
        public override void PrePatch()
        {
            if (ManagedDllExists("UnityEngine.CoreModule.dll"))
            {
                RPConfig.RequestAssembly("UnityEngine.CoreModule.dll");
                _assemblyName = "UnityEngine.CoreModule";
            }
            else if (ManagedDllExists("UnityEngine.dll"))
            {
                RPConfig.RequestAssembly("UnityEngine.dll");
                _assemblyName = "UnityEngine";
            }

            _hookAssembly = LoadAssembly("XUnity.AutoTranslator.Plugin.Core.dll");
        }
Exemple #4
0
        /// <summary>
        /// This method is called after the patcher was loaded but before actual patching commences.
        ///
        /// In this method you would usually request and assembly to patch and load external assemblies.
        /// </summary>
        public override void PrePatch()
        {
            // You can read and create properties in ReiPatcher patcher configuration by using methods in RPConfig class.
            assembly     = RPConfig.GetConfig("ExMultiGame", "Assembly");
            targetType   = RPConfig.GetConfig("ExMultiGame", "Type");
            targetMethod = RPConfig.GetConfig("ExMultiGame", "Method");

            bool isInvalidValue = IsNullOrEmpty(assembly) || IsNullOrEmpty(targetType) || IsNullOrEmpty(targetMethod);

            if (isInvalidValue)
            {
                // Calling RPConfig.GetConfig(string sec, string key) will create the property if it did not exist before.
                // Calling RPConfig.Save() will save the configuration file and thus save the created ExRPConfig section (if it did not exist before).
                RPConfig.Save();

                // Throwing an exception will stop ReiPatcher and prevent any assemblies to be patched further.
                // ALWAYS consider whether to throw an exception and stop ReiPatcher or to use CanPatch(PatcherArguments args) to make ReiPatcher only skip the faulty patcher.
                // The rule of thumb is: if other mods/patchers stronlgy rely on your mod/patch, it is better to throw an exception.
                // Moreover, end-users are more likely to notice an exception being thrown instead of just printing the error and skipping the patcher.
                throw new Exception($"Some property/properties don't have a value (or have an invalid one) in {Path.GetFileName(RPConfig.ConfigFilePath)} in ExRPConfig section! Edit the configuration file and fill in the values before using this patcher.");
            }

            // Tell ReiPatcher that Assembly-CSharp.dll needs to be patched.
            RPConfig.RequestAssembly($"{assembly}.dll");

            // Load the hook assembly.
            string path = Path.Combine(AssembliesDir, "ExMultiGame.Hook.dll");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("Missing hook dll!");
            }

            using (Stream s = File.OpenRead(path))
            {
                hookAssembly = AssemblyDefinition.ReadAssembly(s);
            }

            if (hookAssembly == null)
            {
                throw new NullReferenceException("Failed to read hook assembly!");
            }
        }
Exemple #5
0
        /// <summary>
        /// This method is called after the patcher was loaded but before actual patching commences.
        ///
        /// In this method you would usually request and assembly to patch and load external assemblies.
        /// </summary>
        public override void PrePatch()
        {
            // Tell ReiPatcher that Assembly-CSharp.dll needs to be patched.
            RPConfig.RequestAssembly("Assembly-CSharp.dll");

            // Load the hook assembly.
            string path = Path.Combine(AssembliesDir, "CM3D2.ExHelloWorld.Hook.dll");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("Missing hook dll!");
            }

            using (Stream s = File.OpenRead(path))
            {
                hookAssembly = AssemblyDefinition.ReadAssembly(s);
            }

            if (hookAssembly == null)
            {
                throw new NullReferenceException("Failed to read hook assembly!");
            }
        }
        public override void PrePatch()
        {
            RPConfig.RequestAssembly("UnityEngine.dll");

            _hookAssembly = LoadAssembly("XUnity.AutoTranslator.Plugin.Core.dll");
        }