Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void InjectGSCFile()
        {
            if (MainWindow.Window.IsInGame())
            {
                SetStatus("You must be in pre-game lobby before injecting any GSC files.");
                XtraMessageBox.Show(this, "You must be in pre-game lobby before injecting any GSC files.", "Not In Lobby", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!File.Exists(TextBoxLocalFile.Text))
            {
                SetStatus("The file you specified doesn't exist on your computer, choose another file.");
                XtraMessageBox.Show(this, "The file you specified doesn't exist on your computer, choose another file.", "File Doesn't Exist", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SetStatus("Read to inject.");
            if (ComboBoxInstallPath.SelectedIndex == -1)
            {
                SetStatus("You must specify a GSC file path for this file to be injected to.");
                XtraMessageBox.Show(this, "You must specify a GSC file path for this file to be injected to.", "No GSC Path", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            MainWindow.Window.ClearGscMods();
            MainWindow.Window.LastUsedGscFiles.Clear();

            string gameType    = RadioButtonMP.Checked ? "MP" : "ZM";
            string localFile   = TextBoxLocalFile.Text;
            string installPath = ComboBoxInstallPath.GetItemText(ComboBoxInstallPath.SelectedItem);

            GscData.FileItem gscFileData = MainWindow.GetGscFileData(MainWindow.ConsoleType, gameType, installPath);

            MainWindow.Window.LastUsedGscFiles.Add(installPath);

            byte[] gscFile = File.ReadAllBytes(localFile);

            SetStatus($"Injecting GSC file '{Path.GetFileName(localFile)}'...");

            if (MainWindow.ConsoleType.Equals("PS3"))
            {
                MainWindow.PS3.Extension.WriteUInt32(gscFileData.Pointer, 0x51000000); // Overwrite script pointer
                MainWindow.PS3.Extension.WriteBytes(0x51000000, gscFile);              // Write compiled script buffer to free memory location
            }
            else if (MainWindow.ConsoleType.Equals("XBOX"))
            {
                MainWindow.Xbox.WriteUInt32(gscFileData.Pointer, 0x40300000);
                MainWindow.Xbox.WriteByte(0x40300000, gscFile);
            }

            MainWindow.Window.LastInjectedGameType = gameType;

            if (MainWindow.ConsoleType.Equals("PS3"))
            {
                MainWindow.Window.NotifyMessagePS3("^2GSC File Injected", $"{Path.GetFileName(localFile)} to {installPath}", "party_ready");
            }

            XtraMessageBox.Show(this, $"Injected File: {localFile}\nTime: {DateTime.Now:H:mm:ss}", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 2
0
        /// <summary>
        /// Restores all the custom gsc pointers to their correct buffers
        /// </summary>
        public void ClearGscMods()
        {
            try
            {
                if (IsInGame())
                {
                    SetStatus($"You must be in pre-game lobby before clearing GSC files.");
                    XtraMessageBox.Show(this, "You must be in pre-game lobby before clearing GSC files.", "Can't Inject", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                foreach (string gscFile in LastUsedGscFiles)
                {
                    GscData.FileItem gscFileData = GetGscFileData(ConsoleType, LastInjectedGameType, gscFile);

                    if (ConsoleType.Equals("PS3"))
                    {
                        PS3.Extension.WriteUInt32(gscFileData.Pointer, gscFileData.Buffer);
                    }
                    else if (ConsoleType.Equals("XBOX"))
                    {
                        Xbox.WriteUInt32(gscFileData.Pointer, gscFileData.Buffer);
                    }
                }

                if (ConsoleType.Equals("PS3"))
                {
                    NotifyMessagePS3("^2Cleared GSC Mods", "Successfully cleared all mods", "party_ready");
                }

                SetStatus($"All GSC files have been restored.");
                XtraMessageBox.Show(this, "All GSC files have been restored.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                SetStatus($"Unable to clear GSC files. Error: " + ex.Message, ex);
                XtraMessageBox.Show(this, "Unable to clear GSC files.\n\nMessage:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Injects the specified GSC mods to the their correct game locations
        /// </summary>
        /// <param name="modItem"></param>
        private void InjectModItem(ModsData.ModItem modItem)
        {
            try
            {
                if (IsInGame())
                {
                    SetStatus($"You must be in pre-game lobby before injecting mods.");
                    XtraMessageBox.Show(this, "You must be in pre-game lobby before injecting mods.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                ClearGscMods();
                LastUsedGscFiles.Clear();

                modItem.DownloadInstallFiles();

                // Free Memory Offsets
                uint freeMemoryOffset;

                if (ConsoleType.Equals("PS3"))
                {
                    freeMemoryOffset = 0x51000000;
                }
                else
                {
                    freeMemoryOffset = 0x40300000;
                }

                foreach (string installFilePath in modItem.InstallPaths)
                {
                    foreach (string localFilePath in Directory.GetFiles(modItem.GetDownloadDataPath(), "*.*", SearchOption.AllDirectories))
                    {
                        string installFileName = Path.GetFileName(installFilePath);

                        if (string.Equals(installFileName, Path.GetFileName(localFilePath), StringComparison.CurrentCultureIgnoreCase))
                        {
                            GscData.FileItem gscFileData = GetGscFileData(ConsoleType, modItem.GameType, installFilePath);

                            LastUsedGscFiles.Add(installFilePath);

                            byte[] gscFile = File.ReadAllBytes(localFilePath);

                            SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injecting GSC file: {installFileName} ...");

                            if (ConsoleType.Equals("PS3"))
                            {
                                PS3.Extension.WriteUInt32(gscFileData.Pointer, 0x51000000); // Overwrite script pointer
                                PS3.Extension.WriteBytes(0x51000000, gscFile);              // Write compiled script buffer to free memory location
                            }
                            else if (ConsoleType.Equals("XBOX"))
                            {
                                Xbox.WriteUInt32(gscFileData.Pointer, 0x40300000);
                                Xbox.WriteByte(0x40300000, gscFile);
                            }

                            /* TESTS FOR INJECTING MUTIPLE GSC FILES aZaZ..
                             * if (ConsoleType.Equals("PS3"))
                             * {
                             *  freeMemoryOffset = GET_ALIGNED_DWORD(freeMemoryOffset + 1);
                             *
                             *  PS3.Extension.WriteUInt32(gscFileData.Pointer, freeMemoryOffset); // Overwrite script pointer
                             *  PS3.Extension.WriteBytes(freeMemoryOffset, new byte[gscFile.Length + 1]);
                             *  PS3.Extension.WriteBytes(freeMemoryOffset, gscFile); // Write compiled script buffer to free memory location
                             *
                             *  freeMemoryOffset += (uint)(gscFile.Length + 1);
                             * }
                             * else if (ConsoleType.Equals("XBOX"))
                             * {
                             *  freeMemoryOffset = GET_ALIGNED_DWORD(freeMemoryOffset + 1);
                             *
                             *  XBOX.SetMemory(gscFileData.Pointer, BitConverter.GetBytes(freeMemoryOffset).Reverse().ToArray());
                             *  XBOX.SetMemory(freeMemoryOffset, new byte[gscFile.Length + 1]);
                             *  XBOX.SetMemory(freeMemoryOffset, gscFile);
                             *
                             *
                             *  freeMemoryOffset += (uint)(gscFile.Length + 1);
                             * }
                             *
                             *
                             * Xbox.WriteUInt32(gscFileData.Pointer, freeMemoryOffset);
                             */

                            SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injected GSC file: {installFileName}");
                            MenuItemClearGscMods.Enabled = true;
                        }
                    }
                }

                LastInjectedGameType = modItem.GameType;

                SettingsData.UpdateInstalledMod(modItem.GameType, modItem.Id);
                SaveSettingsData();

                if (ConsoleType.Equals("PS3"))
                {
                    NotifyMessagePS3("^2Injected GSC Mods", $"{modItem.Name} v{modItem.Version} by {modItem.CreatedBy}", "party_ready");
                }

                SetStatus($"{modItem.Name} v{modItem.Version} ({modItem.GetGameType()}) - Injected all GSC files.");

                XtraMessageBox.Show(this, $"Injected Mods: {modItem.Name}\nTime: {DateTime.Now:H:mm:ss}", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                SetStatus($"Unable to inject GSC files. Error: {ex.Message}", ex);
                XtraMessageBox.Show(this, $"There was a problem injecting gsc files. Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }