예제 #1
0
        public void LoadModule(string moduleName)
        {
            if (moduleName.Contains("\\") == false)
            {
                moduleName = "Hdd:\\" + moduleName;
            }

            if (!FileExists(moduleName))
            {
                return;
            }

            if (IsModuleLoaded(moduleName))
            {
                XboxUtils.ErrorMessage(moduleName + " is already loaded.");
                return;
            }

            try
            {
                XboxUtils.Call <uint>("xboxkrnl.exe", 409, new object[] { moduleName, 8, 0, 0 });
                XboxUtils.ConfirmMessage(moduleName + " has been loaded.");
            }
            catch (Exception)
            {
                XboxUtils.ErrorMessage("Could not load module: " + moduleName);
            }
        }
예제 #2
0
        public void UnloadModule(string moduleName)
        {
            if (!FileExists(moduleName))
            {
                return;
            }

            if (!IsModuleLoaded(moduleName))
            {
                XboxUtils.ErrorMessage(moduleName + " is not loaded.");
                return;
            }

            try
            {
                uint handle = XboxUtils.Call <uint>("xam.xex", 1102, new object[] { moduleName });
                if (handle != 0u)
                {
                    XboxUtils.WriteShort(handle + 0x40, 1);
                    XboxUtils.Call <uint>("xboxkrnl.exe", 417, new object[] { handle });
                    XboxUtils.ConfirmMessage(moduleName + " has been unloaded.");
                }
                else
                {
                    XboxUtils.ErrorMessage("Could not unload module: " + moduleName);
                }
            }
            catch (Exception)
            {
                XboxUtils.ErrorMessage("Could not unload module: " + moduleName);
            }
        }
예제 #3
0
 public bool FileExists(string filePath)
 {
     try
     {
         IXboxFile file = XboxUtils.GetFile(filePath);
         return(true);
     }
     catch (Exception)
     {
         XboxUtils.ErrorMessage(filePath + " does not exist.");
         return(false);
     }
 }
예제 #4
0
 public bool Connect()
 {
     try
     {
         XboxUtils.Connect();
         XboxUtils.ConfirmMessage("Successfully connected to console: " + XboxUtils.GetConsoleName());
         return(true);
     }
     catch (Exception exception)
     {
         XboxUtils.ErrorMessage(exception.Message);
         return(false);
     }
 }
예제 #5
0
        static void ModuleAction(ModuleCallBack moduleCallBack, string moduleName)
        {
            if (ModuleLoader.Connect())
            {
                try
                {
                    moduleCallBack(moduleName);
                }
                catch (Exception exception)
                {
                    XboxUtils.ErrorMessage("An error occured. Full message: " + exception.Message);
                }

                ModuleLoader.Disconnect();
            }
        }
예제 #6
0
        public bool Disconnect()
        {
            if (!XboxUtils.IsConnected())
            {
                return(true);
            }

            try
            {
                string consoleName = XboxUtils.GetConsoleName();
                XboxUtils.Disconnect();
                XboxUtils.ConfirmMessage("Successfully disconnected from console: " + consoleName);
                return(true);
            }
            catch (Exception exception)
            {
                XboxUtils.ErrorMessage(exception.Message);
                return(false);
            }
        }
예제 #7
0
        public bool IsModuleLoaded(string moduleName)
        {
            try
            {
                List <string> modules = XboxUtils.GetModuleNames();
                foreach (string module in modules)
                {
                    if (moduleName.Contains(module))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception exception)
            {
                XboxUtils.ErrorMessage(exception.Message);
            }

            return(false);
        }
예제 #8
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ModuleLoader.ShowHelp();
                return;
            }

            if (args.Length > 2)
            {
                XboxUtils.ErrorMessage("Maximum number of arguments exceeded. ModuleLoader -h to see the usage.");
                return;
            }

            string firstArg  = (args.Length > 0 && args[0] != null) ? args[0] : null;
            string secondArg = (args.Length > 1 && args[1] != null) ? args[1] : null;

            if (firstArg.StartsWith("-"))
            {
                switch (firstArg)
                {
                case "-h":
                    ModuleLoader.ShowHelp();
                    break;

                case "-s":
                    ModuleAction(Show, null);
                    break;

                case "-l":
                    if (secondArg != null)
                    {
                        ModuleAction(Load, secondArg);
                    }
                    else
                    {
                        XboxUtils.ErrorMessage("You need to specify an absolute module path. ModuleLoader -h to see the usage.");
                    }
                    break;

                case "-u":
                    if (secondArg != null)
                    {
                        ModuleAction(Unload, secondArg);
                    }
                    else
                    {
                        XboxUtils.ErrorMessage("You need to specify an absolute module path. ModuleLoader -h to see the usage.");
                    }
                    break;

                default:
                    XboxUtils.ErrorMessage(firstArg + " is not a valid argument. ModuleLoader -h to see the usage.");
                    break;
                }
            }
            else
            {
                if (secondArg != null)
                {
                    XboxUtils.ErrorMessage("You can not specify argument after the module path. ModuleLoader -h to see the usage.");
                }
                else
                {
                    ModuleAction(UnloadThenLoad, firstArg);
                }
            }
        }