示例#1
0
        private static void Main(string[] args)
        {
            System.Console.Clear();

            bool IsElevated = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

            if (!IsElevated)
            {
                System.Console.WriteLine("\r\nSharpMonoInjector 2.3 wh0am1 Mod\r\n\r\nWARNING: You are running this in an unpriveleged process, try from an Elevated Command Prompt.\r\n");
                System.Console.WriteLine("\t As an alternative, right-click Game .exe and uncheck the Compatibility\r\n\t setting 'Run this program as Administrator'.\r\n\r\n");
                //System.Console.ReadKey();
                //return;
            }

            if (args.Length == 0)
            {
                PrintHelp();
                return;
            }

            CommandLineArguments cla = new CommandLineArguments(args);

            bool inject = cla.IsSwitchPresent("inject");
            bool eject  = cla.IsSwitchPresent("eject");

            if (!inject && !eject)
            {
                System.Console.WriteLine("No operation (inject/eject) specified");
                return;
            }

            Injector injector;

            if (cla.GetIntArg("-p", out int pid))
            {
                injector = new Injector(pid);
            }
            else if (cla.GetStringArg("-p", out string pname))
            {
                injector = new Injector(pname);
            }
            else
            {
                System.Console.WriteLine("No process id/name specified");
                return;
            }

            if (inject)
            {
                Inject(injector, cla);
            }
            else
            {
                Eject(injector, cla);
            }
        }
示例#2
0
        private static void Eject(Injector injector, CommandLineArguments args)
        {
            IntPtr assembly;
            string @namespace, className, methodName;

            if (args.GetIntArg("-a", out int intPtr))
            {
                assembly = (IntPtr)intPtr;
            }
            else if (args.GetLongArg("-a", out long longPtr))
            {
                assembly = (IntPtr)longPtr;
            }
            else
            {
                System.Console.WriteLine("No assembly pointer specified");
                return;
            }

            args.GetStringArg("-n", out @namespace);

            if (!args.GetStringArg("-c", out className))
            {
                System.Console.WriteLine("No class name specified");
                return;
            }

            if (!args.GetStringArg("-m", out methodName))
            {
                System.Console.WriteLine("No method name specified");
                return;
            }

            using (injector)
            {
                try
                {
                    injector.Eject(assembly, @namespace, className, methodName);
                    System.Console.WriteLine("Ejection successful");
                }
                catch (InjectorException ie)
                {
                    System.Console.WriteLine("Ejection failed: " + ie);
                }
                catch (Exception exc)
                {
                    System.Console.WriteLine("Ejection failed (unknown error): " + exc);
                }
            }
        }
示例#3
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintHelp();
                return;
            }

            CommandLineArguments cla = new CommandLineArguments(args);

            bool inject = cla.IsSwitchPresent("inject");
            bool eject  = cla.IsSwitchPresent("eject");

            if (!inject && !eject)
            {
                System.Console.WriteLine("No operation (inject/eject) specified");
                return;
            }

            Injector injector;

            if (cla.GetIntArg("-p", out int pid))
            {
                injector = new Injector(pid);
            }
            else if (cla.GetStringArg("-p", out string pname))
            {
                injector = new Injector(pname);
            }
            else
            {
                System.Console.WriteLine("No process id/name specified");
                return;
            }

            if (inject)
            {
                Inject(injector, cla);
            }
            else
            {
                Eject(injector, cla);
            }
        }