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); } }
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); } }
public bool FileExists(string filePath) { try { IXboxFile file = XboxUtils.GetFile(filePath); return(true); } catch (Exception) { XboxUtils.ErrorMessage(filePath + " does not exist."); return(false); } }
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); } }
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(); } }
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); } }
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); }
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); } } }