Ejemplo n.º 1
0
        private void btnSaveCheatTable_OnClick()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog()
            {
                AddExtension = true,
                DefaultExt   = "PECheatTable",
                Filter       = "PlayEngine cheat tables|*.PECheatTable",
                FilterIndex  = 0,
                SupportMultiDottedExtensions = true,
                Title         = "Save cheat table",
                ValidateNames = true
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                var cheatTable = new CheatTableFile();
                foreach (CheatInformation cheatInformation in listViewSavedResults.Objects)
                {
                    if (cheatInformation.memorySection == null) // simple
                    {
                        SimpleCheatEntry simpleCheatEntry = new SimpleCheatEntry()
                        {
                            description = cheatInformation.description,
                            address     = cheatInformation.address,
                            valueType   = cheatInformation.valueType
                        };
                        cheatTable.cheatEntries.Add(simpleCheatEntry);
                    }
                    else
                    {
                        ComplexCheatEntry complexCheatEntry = new ComplexCheatEntry()
                        {
                            description   = cheatInformation.description,
                            sectionIndex  = cheatInformation.memorySection.index,
                            sectionOffset = cheatInformation.sectionOffset,
                            valueType     = cheatInformation.valueType
                        };
                        cheatTable.cheatEntries.Add(complexCheatEntry);
                    }
                }
                cheatTable.playEngineVersion = CheatTableFile.getAssemblyVersion();
                cheatTable.targetProcess     = (String)uiToolStrip_ProcessManager_cmbBoxActiveProcess.SelectedItem;
                cheatTable.cusaId            = Memory.CUSAInfo.getId();
                cheatTable.cusaVersion       = Memory.CUSAInfo.getVersionStr();
                cheatTable.saveToFile(saveFileDialog.FileName);
            }
        }
Ejemplo n.º 2
0
        private void btnLoadCheatTable_OnClick()
        {
            if (currentScanStatus != Memory.ScanStatus.CantScan)
            {
                MessageBox.Show("Cannot load a cheat table while the payload is not injected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                AddExtension    = false,
                CheckFileExists = true,
                CheckPathExists = true,
                FileName        = Memory.CUSAInfo.getVersionStr(),
                DefaultExt      = "PECheatTable",
                Filter          = "PlayEngine cheat tables|*.PECheatTable|PS4Cheater cheat tables|*.cht",
                FilterIndex     = 0,
                Multiselect     = false,
                ShowReadOnly    = false,
                SupportMultiDottedExtensions = true,
                Title         = "Select a cheat table to load",
                ValidateNames = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                CheatTableFile cheatTable = null;
                try {
                    if (openFileDialog.SafeFileName.EndsWith(".cht"))
                    {
                        String newFileName = openFileDialog.FileName.Replace(".cht", ".PECheatTable");
                        cheatTable = CheatTableFile.updateOldFormat(openFileDialog.FileName);
                        cheatTable.saveToFile(newFileName);
                    }
                    else
                    {
                        cheatTable = CheatTableFile.loadFromFile(openFileDialog.FileName);
                        if (cheatTable.playEngineVersion.Major > CheatTableFile.getAssemblyVersion().Major ||
                            cheatTable.playEngineVersion.Minor > CheatTableFile.getAssemblyVersion().Minor)
                        {
                            MessageBox.Show("Selected cheat table requires a higher version of PlayEngine!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.ToString(), "Exception occured while loading cheat table", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (!uiToolStrip_ProcessManager_cmbBoxActiveProcess.Items.Contains(cheatTable.targetProcess))
                {
                    MessageBox.Show("Cheat table process is not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                uiToolStrip_ProcessManager_cmbBoxActiveProcess.SelectedItem = cheatTable.targetProcess;

                if (cheatTable.targetProcess == "eboot.bin")
                {
                    String _Id  = Memory.CUSAInfo.getId();
                    String _Ver = Memory.CUSAInfo.getVersionStr();
                    if (_Id != cheatTable.cusaId)
                    {
                        MessageBox.Show("CUSA ids do not match, loading anyway...\r\n" +
                                        $"Active CUSA id: {_Id}/Cheat table CUSA id: {cheatTable.cusaId}", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    if (_Ver != cheatTable.cusaVersion)
                    {
                        MessageBox.Show("CUSA versions do not match, loading anyway...\r\n" +
                                        $"Active CUSA version: v{_Ver}/Cheat table CUSA version: v{cheatTable.cusaVersion}.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                foreach (ICheatEntry cheatEntry in cheatTable.cheatEntries)
                {
                    if (cheatEntry.isSimple())
                    {
                        var _cheatEntry = (SimpleCheatEntry)cheatEntry;
                        saveResult(_cheatEntry.description, null, 0, _cheatEntry.valueType, null, _cheatEntry.address);
                    }
                    else
                    {
                        var _cheatEntry   = (ComplexCheatEntry)cheatEntry;
                        var memorySection = Memory.ActiveProcess.info.listProcessMemorySections.First(s => s.index == _cheatEntry.sectionIndex);
                        saveResult(_cheatEntry.description, memorySection, _cheatEntry.sectionOffset, _cheatEntry.valueType, null);
                    }
                }
            }
        }