예제 #1
0
        private static void PatchGame(string version, string copyToFolder, bool runPeVerify)
        {
            if (!Directory.Exists(copyToFolder))
            {
                Log.Information("Creating copy to folder.");
                Directory.CreateDirectory(copyToFolder);
            }
            //+ Path-related
            var copyToPath      = Path.Combine(copyToFolder, @"Assembly-CSharp.dll");
            var originalDllPath = Path.Combine(Paths.YourDllSourcesPath, version, "Assembly-CSharp.dll");

            //+ Creating patcher
            var patcher = new AssemblyPatcher(originalDllPath, ImplicitImportSetting.OnlyCompilerGenerated, Log);

            //+ Patching assemblies
            patcher.PatchAssembly(typeof(IEModType).Assembly.Location);

            //add more lines to patch more things

            //+ End

            patcher.WriteTo(copyToPath);
            if (runPeVerify)
            {
                Console.WriteLine(
                    "Going to run PEVerify to check the IL for errors. Press ESC to cancel, or any other key to continue.");
                if (Console.ReadKey().Key != ConsoleKey.Escape)
                {
                    RunPEVerify(copyToPath);
                    //RunILSpy(copyToPath);
                    //RunILSpy(typeof (IEModType).Assembly.Location);
                }
            }
        }
예제 #2
0
        private static void PatchGame()
        {
            //+ Path-related
            var copyToPath      = Paths.YourNormalManagedFolder + @"\Assembly-CSharp.dll";
            var originalDllPath = Path.Combine(Paths.YourDllSourcesPath, "Assembly-CSharp.dll");

            //+ Creating patcher
            var patcher = new AssemblyPatcher(originalDllPath, ImplicitImportSetting.OnlyCompilerGenerated, Serilog.Log.Logger);

            //+ Patching assemblies
            patcher.PatchAssembly(typeof(IEModType).Assembly.Location);

            //add more lines to patch more things

            //+ End


            patcher.WriteTo(copyToPath);
            Console.WriteLine("Going to run PEVerify to check the IL for errors. Press ESC to cancel, or any other key to continue.");
            if (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                RunPEVerify(copyToPath);
                //RunILSpy(copyToPath);
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: v1ld/IEMod.pw
        private static void PatchGame(string version, string copyToFolder, bool runPeVerify)
        {
            if (!Directory.Exists(copyToFolder))
            {
                Log.Information("Creating copy to folder.");
                Directory.CreateDirectory(copyToFolder);
            }
            //+ Path-related
            var copyToPath      = Path.Combine(copyToFolder, @"Assembly-CSharp.dll");
            var originalDllPath = Path.Combine(RelativePaths.DllSourcesPath, version, "Assembly-CSharp.dll");

            //+ Creating patcher
            var patcher = new AssemblyPatcher(originalDllPath, Log)
            {
                EmbedHistory = true
            };

            File.Copy(typeof(NewTypeAttribute).Assembly.Location, Path.Combine(copyToFolder, "Patchwork.Attributes.dll"), true);

            //+ Patching assemblies
            patcher.PatchAssembly(typeof(IEModType).Assembly.Location);
            //add more lines to patch more things

            //+ End

            if (runPeVerify)
            {
                Console.WriteLine(
                    "Running PEVerify on the assembly to check the IL for errors. Please wait.");
            }
            patcher.WriteTo(copyToPath);
            LogFile.Flush();
            Console.WriteLine("Press any key to close.");
            Console.Read();
        }
예제 #4
0
        private static void PatchTest()
        {
            var targetPath = @"..\..\..\Patchwork.Tests.Target\bin\debug\Patchwork.Tests.Target.dll";;

            var dir = Path.GetDirectoryName(targetPath);
            var fn = Path.GetFileNameWithoutExtension(targetPath);
            var ext = Path.GetExtension(targetPath);
            var newFileName = string.Format("{0}.patched{1}", fn, ext);
            var newTarget = Path.Combine(dir, newFileName);
            File.Copy(targetPath, newTarget, true);
            var patcher = new AssemblyPatcher(newTarget, log: Log);
            var patchPath = typeof(Patchwork.Tests.Patch.TestClass).Assembly.Location;
            patcher.DebugOptions = DebugFlags.CreationOverwrites;
            patcher.PatchAssembly(patchPath);

            patcher.WriteTo(newTarget);
            Log.Information("Loading assembly into memory...");
            var loaded = Assembly.LoadFrom(newTarget);
            Log.Information("Invoking method");
            var module = loaded.GetModules()[0];
            var types = module.FindTypes((typ, o) => typ.Name.Contains("EntryPoint"), null);
            var foundType = types.Single();
            var method = foundType.GetMethod("StandardTests");
            Process.Start(@"C:\Users\lifeg_000\AppData\Local\Microsoft\VisualStudio\12.0\Extensions\bicaz2ty.1dn\ILSpy.exe", string.Format("\"{0}\"", newTarget));
            try
            {
                var ret = method.Invoke(null, null);
                Log.Information("Result: {@Result}", ret);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            Console.ReadKey();
        }
예제 #5
0
        private static void PatchGame(ILogger log)
        {
            log.Information("Creating {0}", Paths.PatchedAssemblyFolder);
            Directory.CreateDirectory(Paths.PatchedAssemblyFolder);

            log.Information("Loading original assembly {0}", Paths.OriginalAssembly);
            var patcher = new AssemblyPatcher(Paths.OriginalAssembly, log);

            patcher.EmbedHistory = false;
            patcher.UseBackup    = false;

            log.Information("Patching");
            patcher.PatchAssembly(typeof(W2PWMod.ModType).Assembly.Location);

            log.Information("Saving patched file");
            patcher.WriteTo(Paths.PatchedAssembly);
        }
예제 #6
0
        internal void Run()
        {
            if (!m_xap.IsUnpacked)
            {
                m_xap.Parse();
            }

            if (m_xap.RemoveDRM())
            {
                m_addText.Invoke("DRM file was removed.");
            }

            PrepareFilesForPatching();

            foreach (var asm in m_xap.Assemblies)
            {
                string asmName = Path.GetFileName(asm.AssemblyPath);
                string asmPath = GetInstrumentedFilePath(asmName);
                try
                {
                    AssemblyName.GetAssemblyName(asmPath);
                    m_addText.Invoke("Patching " + asm.AssemblyPath);
                    AssemblyPatcher patcher = new AssemblyPatcher(asmPath, m_hookProvider, m_deviceType, m_xap.PlatformVersion);
                    patcher.PatchAssembly();
                }
                catch (BadImageFormatException)
                {
                    m_addText.Invoke("Skipping native dll file: " + asm.AssemblyPath);
                }
            }

            m_addText.Invoke("Finished patching assemblies.");

            m_addText.Invoke("Signing dll files...");
            m_xap.ReplaceSignatures();
            m_addText.Invoke("(Done)");

            string newFileName = CreateNewXAP();

            InstallApplication(newFileName);

            RunXDEMonitor();

            m_resetButton.Invoke("run");
        }
예제 #7
0
        private static void PatchTest()
        {
            var targetPath = @"..\..\..\Patchwork.Tests.Target\bin\debug\Patchwork.Tests.Target.dll";;

            var dir         = Path.GetDirectoryName(targetPath);
            var fn          = Path.GetFileNameWithoutExtension(targetPath);
            var ext         = Path.GetExtension(targetPath);
            var newFileName = string.Format("{0}.patched{1}", fn, ext);
            var newTarget   = Path.Combine(dir, newFileName);

            File.Copy(targetPath, newTarget, true);
            var patcher   = new AssemblyPatcher(newTarget, log: Log);
            var patchPath = typeof(Patchwork.Tests.Patch.TestClass).Assembly.Location;

            patcher.DebugOptions = DebugFlags.CreationOverwrites;
            patcher.PatchAssembly(patchPath);

            patcher.WriteTo(newTarget);
            Log.Information("Loading assembly into memory...");
            var loaded = Assembly.LoadFrom(newTarget);

            Log.Information("Invoking method");
            var module    = loaded.GetModules()[0];
            var types     = module.FindTypes((typ, o) => typ.Name.Contains("EntryPoint"), null);
            var foundType = types.Single();
            var method    = foundType.GetMethod("StandardTests");

            Process.Start(@"C:\Users\lifeg_000\AppData\Local\Microsoft\VisualStudio\12.0\Extensions\bicaz2ty.1dn\ILSpy.exe", string.Format("\"{0}\"", newTarget));
            try
            {
                var ret = method.Invoke(null, null);
                Log.Information("Result: {@Result}", ret);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            Console.ReadKey();
        }