Esempio n. 1
0
 /// <summary>
 /// Sets up the print function shorthands.
 /// </summary>
 private static void SetuplibReloadedBindings()
 {
     Bindings.PrintError   += delegate(string message) { LoaderConsole.PrintFormattedMessage(message, LoaderConsole.PrintErrorMessage); };
     Bindings.PrintWarning += delegate(string message) { LoaderConsole.PrintFormattedMessage(message, LoaderConsole.PrintWarningMessage); };
     Bindings.PrintInfo    += delegate(string message) { LoaderConsole.PrintFormattedMessage(message, LoaderConsole.PrintInfoMessage); };
     Bindings.PrintText    += delegate(string message) { LoaderConsole.PrintFormattedMessage(message, LoaderConsole.PrintMessage); };
 }
Esempio n. 2
0
        /// <summary>
        /// Retrieves the game instance we are going to be hacking as a ReloadedProcess
        /// </summary>
        private static void GetGameProcess(string[] originalArguments)
        {
            // Fast return if soft reboot (game process killed and restarted itself)
            if (_gameProcess != null)
            {
                return;
            }

            // Attach if specified by the user.
            if (_attachTargetName != null)
            {
                // Grab current already running game.
                _gameProcess = ReloadedProcess.GetProcessByName(_attachTargetName);

                // Check if gameProcess successfully returned.
                if (_gameProcess == null && !_autoAttach)
                {
                    LoaderConsole.PrintFormattedMessage("Error: An active running game instance was not found.", LoaderConsole.PrintErrorMessage);
                    Console.ReadLine();
                    Shutdown(null, null);
                }

                // Wait for new process with autoattach if not found.
                if (_autoAttach && _gameProcess == null)
                {
                    Bindings.PrintWarning("Process not running. Waiting in Auto-Attach Mode.");
                    do
                    {
                        _gameProcess = ReloadedProcess.GetProcessByName(_attachTargetName); Thread.Sleep(2);
                    }while (_gameProcess == null);
                }
            }

            // Otherwise start process suspended in Reloaded, hook it, exploit it and resume the intended way.
            else
            {
                _gameProcess = new ReloadedProcess($"{Path.Combine(_gameConfig.GameDirectory, _gameConfig.ExecutableLocation)}", _gameConfig.CommandLineArgs.Split(' '));

                // The process handle is 0 if the process failed to initialize.
                if ((int)_gameProcess.ProcessHandle == 0)
                {
                    // libReloaded will already print the error message.
                    Console.ReadLine();
                    Shutdown(null, null);
                }

                // Check if the game should run normally to toggle the shim.
                CheckSteamHack(originalArguments);
            }

            // Set binding for target process for memory IO
            Bindings.TargetProcess = _gameProcess;

            // Obtain the process start time.
            if (_gameProcess != null)
            {
                _processStartTime = _gameProcess.GetProcessFromReloadedProcess().StartTime;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes Zone Information from dynamic link libraries downloaded from the internet such
        /// that certain users of Microsoft Windows would not be denied loading of our own arbitrary code.
        /// </summary>
        /// <remarks>
        /// Only affects files downloaded via very specific certain outdated programs such as
        /// Internet Explorer
        /// </remarks>
        public static void UnblockDlls()
        {
            // Print Info Message about Unlocking DLLs
            LoaderConsole.PrintFormattedMessage("Removing Zone Identifiers from Files (DLL Unlocking)", LoaderConsole.PrintInfoMessage);

            // Search all DLLs under loader directories.
            // Normally I'd restrict this to mod directories, but the loader's own libraries might also be worth checking.
            string[] dllFiles = Directory.GetFiles(LoaderPaths.GetModLoaderDirectory(), "*.dll", SearchOption.AllDirectories);

            // Unblock new file.
            foreach (string dllFile in dllFiles)
            {
                FileUnblocker.Unblock(dllFile);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Prints the Reloaded Logo banner,
        /// </summary>
        private static void PrintBannerDefault()
        {
            // Print empty line (spacing)
            LoaderConsole.PrintMessage("");

            // Reloaded Banner Stylesheet
            Formatter[] reloadedFormatter =
            {
                new Formatter(@"MMMMMMMMMMMMNmyyyyyyyyyyyy-:yy`           /syyyyyyyyo.     `/     :yyyyyyyyyys: /yyyyyyyyyyyy`+yyyyyyyyyyo.", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMMMM   MNMMhodmhmo:::::::.:hh.          /hho:::::/yhy`   `sh/    :hh+:::::/yhh./hh/:::::::::`ohy::::::/yhy", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMMMM   :+MMo-hh/./.....   :hh.          +hh       /hh`  `ohhh/   :hh.      -hh-/hh-......`   ohy       +hh", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMMMM  MMMMm--dddddddddh   /dd.          odd       +dd`  sdy-dd/  :dd.      :dd-+dddddddddo   sdh       odd", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMoyMMMMMMd/ :NN:          +NN.          sNN`      oNN``dNd::+NNs /NN-      :NN:oNN`          yNm       sNN", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMN.m   :dMMh+hhhhhhhhhhhh::hhhhhhhhhhhh./hhhhhhhhhhhy.yhhhhhhhhho:hhhhhhhhhhhh./hhhhhhhhhhhh`ohhhhhhhhhhhy", LoaderConsole.Colours.TextColor),
                new Formatter(@"MMM/h     :ssso+++++++++++.-++++++++++++` :+++++++++/.:+/      `++/++++++++++/- -++++++++++++`:++++++++++:.", LoaderConsole.Colours.TextColor)
            };

            // Reloaded Text to Print
            string reloadedBannerText =
                @"                   ./oyo:`
          -/   `/yNMd/`
       .sms` /hMMMh-
     -hMM/ /mMMMm:
    sMMM/.dMMMMs
  `dMMMs-NMMMMo
  yMMMMoNMMMM {0}
 -MMMMMMMMMMM {1}
 yMMMMMMMNmmM {2}
 dMMMMMy.   - {3}
/MMMMMy   /hm {4}
mMMMMMy     y {5}
MMMMMMMh/::+m {6}
mMNMMMMMMMMMMMm.Nh
+M`sMMMMMMMMN+`/:
 s` -hMMMMM+
      .omMMMm+.
         -odMMMms/-`
            `:+ydmNMNdy+:`";

            // Write formatted line.
            Console.WriteLineFormatted(reloadedBannerText, LoaderConsole.Colours.ColorRed, reloadedFormatter);

            // Print empty line (spacing)
            LoaderConsole.PrintMessage("");
        }
Esempio n. 5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            #if DEBUG
            Debugger.Launch();
            #endif

            // Find Assemblies Manually if necessary (Deprecate app.config)
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyFinder.CurrentDomain_AssemblyResolve;

            /* - Initialization - */
            IgnoreSquirrel();
            ParseArguments(args);

            LoaderConsole.Initialize();
            SetuplibReloadedBindings();
            Banner.Execute();
            Controllers.PrintControllerOrder();
            DllUnlocker.UnblockDlls();          // Removes Zone Information which may prevent DLL injection if DLL was downloaded from e.g. Internet Explorer
            LoaderServer.SetupServer();

            /* - Boot up Reloaded Assembler, Get the Game Process running/attached and with mods running. - */
            Assembler.Assemble(new string[] { "use32", "nop eax" }); // Startup Assembler (So a running instance/open handle does not bother devs working on mods)
            GetGameProcess(args);
            InjectMods(args);

            // Resume game after injection if we are NOT in attach mode.
            if (_attachTargetName == null)
            {
                _gameProcess.ResumeAllThreads();
            }

            // Stay alive in the background
            AppDomain.CurrentDomain.ProcessExit += Shutdown;
            Console.CancelKeyPress += Shutdown;

            // Wait infinitely.
            while (true)
            {
                Console.ReadLine();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Displays a warning about how to use the mod loader.
        /// </summary>
        public static void DisplayWarning()
        {
            // Print
            LoaderConsole.PrintFormattedMessage("No game to launch has been specified.", LoaderConsole.PrintErrorMessage);
            LoaderConsole.PrintInfoMessage
            (
                "\nCommand Line Reloaded Mod Loader Usage Instructions:\n" +
                "Reloaded-Loader.exe <Arguments>\n\n" +

                "Arguments List:\n" +
                $"{Strings.Common.LoaderSettingConfig} <GAME_CONFIGURATION_PATH> | Specifies the game configuration to run.\n" +
                $"{Strings.Common.LoaderSettingAttach} <EXECUTABLE_NAME> | Attaches to an already running game/executable.\n\n" +
                $"{Strings.Common.LoaderSettingSteamShim} | If this is set to true; the loader will not reattach.\n\n" +
                $"{Strings.Common.LoaderSettingAutoAttach} | Waits until the game executable spawns then attaches to it. This is a flag you specify WITH {Strings.Common.LoaderSettingAttach}\n\n" +

                "Examples:\n" +
                $"Reloaded-Loader.exe {Strings.Common.LoaderSettingConfig} D:/Reloaded/Reloaded-Config/Games/Sonic-Heroes\n" +
                $"Reloaded-Loader.exe {Strings.Common.LoaderSettingConfig} D:/Reloaded/Reloaded-Config/Games/Sonic-Heroes {Strings.Common.LoaderSettingAttach} Tsonic_win_custom.exe\n\n"
            );
            Console.ReadLine();
            Environment.Exit(0);
        }
Esempio n. 7
0
        /*
         *  -----------------------------------
         *  No Plugins: Default Method Handlers
         *  -----------------------------------
         */

        /// <summary>
        /// Prints a random message to the console window.
        /// </summary>
        /// <param name="message"></param>
        private static void PrintRandomMessageDefault(string message)
        {
            // Print the message.
            LoaderConsole.PrintMessageCenter(message, LoaderConsole.PrintMessage);
            LoaderConsole.PrintMessage("");
        }