Пример #1
0
        public bool patchAssembly(String installPath)
        {
            if (installPath == null)
            {
                return(false);
            }

            //"weave" the assembly
            Console.WriteLine("------------------------------");
            Console.WriteLine("ModLoader Hooks:");
            ScrollsFilter.Log();
            Console.WriteLine("------------------------------");

            if (!weaveAssembly(installPath + "Assembly-CSharp.dll"))
            {
                return(false);
            }
            Console.WriteLine("Weaved Assembly");

            /*
             * add init hack
             */

            try {
                //load assembly
                Hooks.loadBaseAssembly(installPath + "Assembly-CSharp.dll");
                //load self
                Hooks.loadInjectAssembly(installPath + "ScrollsModLoader.dll");
            } catch (Exception exp) {
                //something must be gone horribly wrong if it crashes here
                Console.WriteLine(exp);
                return(false);
            }

            //add hooks
            if (!Hooks.hookStaticVoidMethodAtEnd("App.Awake", "ModLoader.Init"))
            {
                return(false);
            }

            try {
                //save assembly
                Console.WriteLine("Write back patched bytecode...");
                Hooks.savePatchedAssembly();

                Console.WriteLine("Platform specific patches...");
                Platform.PlatformPatches(installPath);
            } catch (Exception exp) {
                //also very unlikely, but for safety
                Console.WriteLine(exp);
                return(false);
            }

            return(true);
        }
Пример #2
0
        public bool safeModePatchAssembly()
        {
            String installPath = Platform.getGlobalScrollsInstallPath();

            if (installPath == null)
            {
                return(false);
            }

            try {
                //load assembly
                Hooks.loadBaseAssembly(installPath + "Assembly-CSharp.dll");
                //load self
                Hooks.loadInjectAssembly(installPath + "ScrollsModLoader.dll");
            } catch (Exception exp) {
                //something must be gone horribly wrong if it crashes here
                Console.WriteLine(exp);
                return(false);
            }

            if (!Hooks.hookStaticVoidMethodAtEnd("App.Awake", "Patcher.safeLaunch"))
            {
                return(false);
            }

            try {
                //save assembly
                Hooks.savePatchedAssembly();

                Platform.PlatformPatches(installPath);
            } catch (Exception exp) {
                //also very unlikely, but for safety
                Console.WriteLine(exp);
                return(false);
            }

            return(true);
        }