Пример #1
0
 private void AttachToProcess()
 {
     //EAC check
     if (CheckForEAC())
     {
         //EAC is running, cannot attach, return.
         MessageBox.Show("EAC is running");
         return;
     }
     try
     {
         p = Process.GetProcessesByName("MCC-Win64-Shipping")[0];
         MCCMemory.OpenProcess(p.Id);
         attachToProcessToolStripMenuItem.Text = "Detach from process";
         attached = true;
         RP       = new RuntimePatcher(MCCMemory, this);
     }
     catch
     {
         try
         {
             p = Process.GetProcessesByName("MCCWinStore-Win64-Shipping")[0];
             MCCMemory.OpenProcess(p.Id);
             attachToProcessToolStripMenuItem.Text = "Detach from process";
             attached = true;
             RP       = new RuntimePatcher(MCCMemory, this);
         }
         catch
         {
             MessageBox.Show("\nMake sure MCC is running");
             //this.Close();
         }
     }
 }
Пример #2
0
        public void Initialize(IManager manager)
        {
            InitializeSettings();

            PrefabInitializer = new PrefabInitializer();
            PrefabInitializer.HookUpEvent();

            try
            {
                RuntimePatcher.AutoPatch();
            }
            catch (Exception e)
            {
                Log.Error("Failed to initialize mix-ins. Mods will still be loaded, but may not function correctly.");
                Log.Exception(e);
            }

            try
            {
                RuntimePatcher.RunTranspilers();
            }
            catch (Exception e)
            {
                Log.Error("Failed to initialize one or more transpilers. Mods will still be loaded, but may not function correctly.");
                Log.Exception(e);
            }

            SceneManager.sceneLoaded += InitializeTerminal;
        }
Пример #3
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(gameObject);

            Logger = LogManager.GetForCurrentAssembly();

            Instance = this;

            Manager = manager;

            Config = new Config();

            RegisterExportedTypes();
            CreateSettingsMenu();

            try
            {
                RuntimePatcher.AutoPatch();
                RuntimePatcher.RunTranspilers();
            }
            catch (Exception e)
            {
                Logger.Error("Failed to initialize harmony. Mods will still be loaded, but may not function correctly.");
                Logger.Exception(e);
            }
        }
Пример #4
0
        public void Initialize(IManager manager)
        {
            Instance = this;
            Manager  = manager;

            Logger = LogManager.GetForCurrentAssembly();

            Config = gameObject.AddComponent <ConfigurationLogic>();

            RuntimePatcher.AutoPatch();
        }
Пример #5
0
        public static void Main(string[] args)
        {
            RuntimePatcher.Initialize();
            StartupContext startupArgs = null;

            try
            {
                startupArgs = new StartupContext(args);
                try
                {
                    NzbDroneLogger.Register(startupArgs, false, true);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("NLog Exception: " + ex.ToString());
                    throw;
                }
                Bootstrap.Start(startupArgs, new ConsoleAlerts());
            }
            catch (SonarrStartupException ex)
            {
                System.Console.WriteLine("");
                System.Console.WriteLine("");
                Logger.Fatal(ex, "EPIC FAIL!");
                Exit(ExitCodes.NonRecoverableFailure, startupArgs);
            }
            catch (SocketException ex)
            {
                System.Console.WriteLine("");
                System.Console.WriteLine("");
                Logger.Fatal(ex.Message + ". This can happen if another instance of Sonarr is already running another application is using the same port (default: 8989) or the user has insufficient permissions");
                Exit(ExitCodes.RecoverableFailure, startupArgs);
            }
            catch (RemoteAccessException ex)
            {
                System.Console.WriteLine("");
                System.Console.WriteLine("");
                Logger.Fatal(ex, "EPIC FAIL!");
                Exit(ExitCodes.Normal, startupArgs);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("");
                System.Console.WriteLine("");
                Logger.Fatal(ex, "EPIC FAIL!");
                System.Console.WriteLine("EPIC FAIL! " + ex.ToString());
                Exit(ExitCodes.UnknownFailure, startupArgs);
            }

            Logger.Info("Exiting main.");

            Exit(ExitCodes.Normal, startupArgs);
        }
Пример #6
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);

            Instance = this;
            Manager  = manager;
            Logger   = LogManager.GetForCurrentAssembly();
            Config   = gameObject.AddComponent <ConfigurationLogic>();

            RuntimePatcher.AutoPatch();

            CreateSettingsMenu();
        }
Пример #7
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);

            Instance = this;
            Manager  = manager;
            Logger   = LogManager.GetForCurrentAssembly();

            RuntimePatcher.AutoPatch();

            //Initialized.Subscribe(OnMainMenuInitialized);
            CreateSettingsMenu();
        }
Пример #8
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);

            Instance        = this;
            Manager         = manager;
            Logger          = LogManager.GetForCurrentAssembly();
            StartParameters = ApplicationArguments.Parse();

            RuntimePatcher.AutoPatch();

            Initialized.Subscribe(OnMainMenuInitialized);
        }
Пример #9
0
        public static void Start()
        {
            CultureInfo english = new CultureInfo("en-US");

            Thread.CurrentThread.CurrentCulture   = english;
            Thread.CurrentThread.CurrentUICulture = english;

            CultureInfo.CurrentCulture   = english;
            CultureInfo.CurrentUICulture = english;

            Styles.ApplyAll();

            RuntimePatcher.AutoPatch();

            new Eto.Forms.Application(Platform.Detect).Run(new MainWindow());
        }
Пример #10
0
        public void Start()
        {
            try
            {
                RuntimePatcher.AutoPatch();

                Plugin.Init();
                Events.Managers.GameManagerLoaded.Subscribe(OnGameManagerLoaded);

                EventSubscriber.SubscribeAll();
            }
            catch (Exception e)
            {
                Plugin.Log.Exception(e);
            }
        }
Пример #11
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);

            Instance = this;
            Manager  = manager;

            Logger = LogManager.GetForCurrentAssembly();

            Logger.Info("NoEditorNumberLimits loaded");
            Logger.Info(":atprtsd:");
            Logger.Info("ps: i totally did this with no help");
            Logger.Info("pps: i can confirm ;)");
            Logger.Info("\t\t- Plasmawario, 2020");

            RuntimePatcher.AutoPatch();
        }
Пример #12
0
        static void PatchClient(UserSettings settings, SuspendedProcess process, ClientVersion clientVersion, IPAddress serverIPAddress, int serverPort)
        {
            if (settings.ShouldRedirectClient && serverIPAddress == null)
            {
                throw new ArgumentNullException("serverIPAddress", "Server IP address must be specified when redirecting the client");
            }

            if (settings.ShouldRedirectClient && serverPort <= 0)
            {
                throw new ArgumentOutOfRangeException("Server port number must be greater than zero when redirecting the client");
            }

            using (var stream = new ProcessMemoryStream(process.ProcessId))
                using (var patcher = new RuntimePatcher(clientVersion, stream, leaveOpen: true))
                {
                    // Apply server hostname/port patch
                    if (settings.ShouldRedirectClient && clientVersion.ServerHostnamePatchAddress > 0 && clientVersion.ServerPortPatchAddress > 0)
                    {
                        Debug.WriteLine("Applying server redirect patch...");
                        patcher.ApplyServerHostnamePatch(serverIPAddress);
                        patcher.ApplyServerPortPatch(serverPort);
                    }

                    // Apply intro video patch
                    if (settings.ShouldSkipIntro && clientVersion.IntroVideoPatchAddress > 0)
                    {
                        Debug.WriteLine("Applying intro video patch...");
                        patcher.ApplySkipIntroVideoPatch();
                    }

                    // Apply multiple instances patch
                    if (settings.ShouldAllowMultipleInstances && clientVersion.MultipleInstancePatchAddress > 0)
                    {
                        Debug.WriteLine("Applying multiple instance patch...");
                        patcher.ApplyMultipleInstancesPatch();
                    }

                    // Apply hide walls patch
                    if (settings.ShouldHideWalls && clientVersion.HideWallsPatchAddress > 0)
                    {
                        Debug.WriteLine("Applying hide walls patch...");
                        patcher.ApplyHideWallsPatch();
                    }
                }
        }
Пример #13
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);
            Instance = this;
            Manager  = manager;

            Flags.SubscribeEvents();

            Logger = LogManager.GetForCurrentAssembly();
            Config = gameObject.AddComponent <ConfigurationLogic>();

            Config.OnChanged += OnConfigChanged;

            OnConfigChanged(Config);

            CreateSettingsMenu();

            RuntimePatcher.AutoPatch();
        }
Пример #14
0
        public void Initialize(IManager manager)
        {
            Instance = this;
            Manager  = manager;

            Data = new FileSystem();

            Logger = LogManager.GetForCurrentAssembly();

            Loader = new TextureLoader(Data);

            Modifier = new ResourceModificator(Loader);

            RuntimePatcher.AutoPatch();

            Events.Level.PostLoad.Subscribe(LevelPostLoad);

            CreateMenus();
        }
Пример #15
0
        public void Initialize(IManager manager)
        {
            Instance = this;
            Manager  = manager;

            Logger     = LogManager.GetForCurrentAssembly();
            FileSystem = new FileSystem();

            Dumper = new Dumper(FileSystem);

            Config            = gameObject.AddComponent <ConfigurationLogic>();
            Config.OnChanged += OnConfigChanged;

            CreateSettingsMenu();

            OnConfigChanged(Config);

            RuntimePatcher.AutoPatch();
        }
Пример #16
0
        public void Initialize(IManager manager)
        {
            DontDestroyOnLoad(this);

            Instance = this;
            Manager  = manager;
            Logger   = LogManager.GetForCurrentAssembly();
            Config   = gameObject.AddComponent <ConfigurationLogic>();

            TrackNodeColors = TrackNodeColors.FromSettings("SplineColors.json");
            TrackNodeColors.OnFileReloaded += ReloadTrackNodeColors;

            RuntimePatcher.AutoPatch();

            CreateSettingsMenu();

            foreach (var mesh in Resources.FindObjectsOfTypeAll <Mesh>())
            {
                Logger.Error($"Mesh: {mesh.name}");
            }
        }
Пример #17
0
        public void Initialize(IManager manager)
        {
            Instance = this;
            Manager  = manager;

            Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);

            Config      = gameObject.AddComponent <ConfigurationLogic>();
            Variables   = gameObject.AddComponent <VariablesLogic>();
            SoundPlayer = gameObject.AddComponent <SoundPlayerLogic>();
            LevelEditor = gameObject.AddComponent <LevelEditorLogic>();
            Logger      = LogManager.GetForCurrentAssembly();

            MusicTrack.Info.Register();
            MusicChoice.Info.Register();

            DirectoryEx.CreateIfDoesNotExist("EditorMusic/");

            CreateSettingsMenu();

            RuntimePatcher.AutoPatch();
        }
Пример #18
0
 public void Initialize(IManager manager) => RuntimePatcher.AutoPatch();
Пример #19
0
        private static void ExecuteImpl()
        {
            ProgressBar progressBar;
            MethodDef   cctor;

            progressBar = new ProgressBar(_unpacker.Context.MethodHandles.Length);
            RuntimePatcher.PatchAll();
            // Patch CLR和JIT
            _unpacker.MethodDumper.Hook();
            // 先Hook,再进行其它步骤,防止Hook被绕过
            _unpacker.PreInitialize();
            cctor = FindStaticConstructor(_unpacker.Context.ModuleDef);
            if (_unpacker.Context.Settings.DumpBeforeStaticConstructor)
            {
                // 要脱壳的文件DUMP时机太后
                // 比如DNG加壳的程序套了层TMD,程序完全跑起来之后才DUMP的主程序
                // 这时要先读取元数据流
                _unpacker.Context.DumpedModuleDef = ModuleDefMD.Load(DumpModule());
                // Dump元数据流和.NET资源
            }
            if (cctor == null)
            {
                Logger.Instance.LogError("WARNING: Not fount any static constructor!");
            }
            else
            {
                // 先运行静态构造器初始化运行时(如果不存在,就是其它静态构造器)再Dump才能得到正确数据(比如元数据流和.NET资源)
                _unpacker.Context.Module.ResolveMethod(cctor.MDToken.ToInt32()).Invoke(null, null);
                _unpacker.PostInitialize();
            }
            if (!_unpacker.Context.Settings.DumpBeforeStaticConstructor)
            {
                _unpacker.Context.DumpedModuleDef = ModuleDefMD.Load(DumpModule());
                // Dump元数据流和.NET资源
            }
            for (int i = 0; i < _unpacker.Context.MethodHandles.Length; i++)
            {
                uint oldDumpCount;

                progressBar.Current = i + 1;
                if (_unpacker.Context.MethodHandles[i] == null)
                {
                    continue;
                }
                oldDumpCount = _unpacker.MethodDumper.DumpCount;
                if (!_unpacker.NeedDecryptMethod(i))
                {
                    continue;
                }
                try {
                    _unpacker.MethodDumper.SetTargetMethod(i);
                    _unpacker.CallJit(i);
                    _unpacker.MethodDumper.SetIdle();
                    if (_unpacker.MethodDumper.DumpCount != oldDumpCount + 1)
                    {
                        throw new Exception("Failed to dump current method.");
                    }
                }
                catch (Exception ex) {
                    _unpacker.MethodDumper.SetIdle();
                    Logger.Instance.LogError("Exception: 0x" + (0x06000001 + i).ToString("X8") + " " + _unpacker.Context.ModuleDef.ResolveMethod((uint)i + 1).ToString());
                    Logger.Instance.LogException(ex);
                    Logger.Instance.LogNewLine();
                    Logger.Instance.LogNewLine();
                }
            }
            _unpacker.MethodDumper.Unhook();
            RuntimePatcher.RestoreAll();
            if (!_unpacker.Context.Settings.PreserveRuntime)
            {
                Logger.Instance.LogInfo("Removing runtime type");
                _unpacker.RemoveRuntime();
            }
            FillNullSignatures(_unpacker.Context.DumpedModuleDef);
        }