Beispiel #1
0
        public void PatchMod(ModuleDefinition module, string filePath, string className, string methodName)
        {
            AssemblyDefinition originalDll = CecilHelper.GetAssembly(filePath);

            if (Injector.IsPatched(originalDll))
            {
                ModLogger.WriteLine(ConsoleColor.Red, module.Name + " already patched.");
                return;
            }

            this.MakeBackup(filePath);
            this.SaveModule(module, filePath);

            string tempDllPath = GetTempPathForFile(filePath);

            if (this.TempForFileExists(filePath))
            {
                File.Delete(tempDllPath);
            }
            File.Move(filePath, tempDllPath);

            AssemblyDefinition unityGameDll = CecilHelper.GetAssembly(tempDllPath);

            Injector.Inject(ref unityGameDll, className, methodName);
            Injector.InjectPatchedSign(ref unityGameDll);
            unityGameDll.Write(filePath);

            File.Delete(tempDllPath);
        }
Beispiel #2
0
        public void PatchMod(string filePath)
        {
            string tempDllPath = GetTempPathForFile(filePath);

            if (this.TempForFileExists(filePath))
            {
                File.Delete(tempDllPath);
            }
            File.Move(filePath, tempDllPath);

            AssemblyDefinition unityGameDll = CecilHelper.GetAssembly(tempDllPath);

            Injector.Inject(unityGameDll, filePath);

            File.Delete(tempDllPath);
        }