Skip to content

Commit

Permalink
Now supports loading all Cheat Trainer/GoldHEN formats (*.json, *.shn…
Browse files Browse the repository at this point in the history
…, *.mc4),

with MC4 formats supporting reading only.

Added display interface languages: Korean, Italian.
  • Loading branch information
avan06 committed Feb 10, 2024
1 parent 05b0710 commit f303f26
Show file tree
Hide file tree
Showing 16 changed files with 1,302 additions and 217 deletions.
412 changes: 292 additions & 120 deletions PS4CheaterNeo/Main.cs

Large diffs are not rendered by default.

95 changes: 50 additions & 45 deletions PS4CheaterNeo/NewAddress.Designer.cs

Large diffs are not rendered by default.

83 changes: 54 additions & 29 deletions PS4CheaterNeo/NewAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ public NewAddress(Main mainForm, Section addrSection, Section baseSection, ulong
OnBox = new TextBox();
OffBox = new TextBox();

OnLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
OnLabel.AutoSize = true;
OnLabel.Dock = DockStyle.Fill;
OnLabel.Margin = AddressLabel.Margin;
OnLabel.Name = "OnLabel";
OnLabel.TabIndex = 1;
OnLabel.Text = "On";
OnLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;

OffLabel.AutoSize = true;
OffLabel.Dock = DockStyle.Right;
OffLabel.Dock = DockStyle.Fill;
OffLabel.ForeColor = ForeColor;
OffLabel.Margin = ValueLabel.Margin;
OffLabel.Name = "OffLabel";
OffLabel.Text = "Off";
OffLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;

OnBox.BackColor = BackColor;
OnBox.ForeColor = ForeColor;
Expand Down Expand Up @@ -160,6 +162,7 @@ public void ApplyUI(LanguageJson langJson)
DescriptionLabel.ForeColor = ForeColor;
LockBox.ForeColor = ForeColor;
PointerBox.ForeColor = ForeColor;
OnOffBox.ForeColor = ForeColor;

AddressBox.ForeColor = ForeColor;
AddressBox.BackColor = BackColor;
Expand Down Expand Up @@ -209,12 +212,12 @@ private void SaveBtn_Click(object sender, EventArgs e)
CheatType = (ScanType)((ComboItem)(ScanTypeBox.SelectedItem)).Value;
ScanTool.ValueStringToULong(CheatType, ValueBox.Text);
Value = ValueBox.Text;
OnValue = OnBox.Text;
OffValue = OffBox.Text;
OnValue = string.IsNullOrWhiteSpace(OnBox.Text) ? null : OnBox.Text;
OffValue = string.IsNullOrWhiteSpace(OffBox.Text) ? null : OffBox.Text;
IsLock = LockBox.Checked;
Descriptioin = DescriptionBox.Text;

if (!AddressBox.ReadOnly) mainForm.AddToCheatGrid(AddrSection, (uint)(Address - AddrSection.Start), CheatType, Value, IsLock, Descriptioin, PointerOffsets);
if (!AddressBox.ReadOnly) mainForm.AddToCheatGrid(AddrSection, (uint)(Address - AddrSection.Start), CheatType, Value, IsLock, Descriptioin, PointerOffsets, null, -1, true, OnValue, OffValue);

DialogResult = DialogResult.OK;
Close();
Expand Down Expand Up @@ -320,24 +323,26 @@ private void SetOffsetBoxs(bool isAdd)
{
TextBox textBox = new TextBox
{
Text = "0",
Location = AddOffsetBtn.Location,
Text = "0",
Location = AddOffsetBtn.Location,
ForeColor = ForeColor,
BackColor = BackColor,
Dock = DockStyle.Fill,
Margin = new Padding(3)
Dock = DockStyle.Fill,
Margin = new Padding(3)
};

Label label = new Label
TextBox label = new TextBox
{
Text = "",
Location = DelOffsetBtn.Location,
ForeColor = ForeColor,
BackColor = BackColor,
Dock = DockStyle.Fill,
Margin = new Padding(3)
};

Text = "",
Location = DelOffsetBtn.Location,
ForeColor = ForeColor,
BackColor = BackColor,
Dock = DockStyle.Fill,
Margin = new Padding(3, 6, 3, 3),
ReadOnly = true,
BorderStyle = BorderStyle.None,
};
PointerOffsets.Add(0);
TableLayoutBottomBox.RowCount += 1;
TableLayoutBottomBox.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
TableLayoutBottomBox.Controls.Add(textBox, 0, TableLayoutBottomBox.Controls.Count);
Expand All @@ -351,6 +356,7 @@ private void SetOffsetBoxs(bool isAdd)
{
if (TableLayoutBottomBox.Controls.Count == 0) return;

PointerOffsets.RemoveAt(PointerOffsets.Count - 1);
Height -= TableLayoutBottomBox.Controls[TableLayoutBottomBox.Controls.Count - 1].Height;
TableLayoutBottomBox.Controls.RemoveAt(TableLayoutBottomBox.Controls.Count - 1);
TableLayoutBottomBox.RowCount -= 1;
Expand All @@ -366,27 +372,42 @@ private void ScanTypeBox_SelectedIndexChanged(object sender, EventArgs e)
if (IsPointer || PointerOffsets != null) return;

var newCheatType = (ScanType)((ComboItem)(ScanTypeBox.SelectedItem)).Value;
if (newCheatType == ScanType.String_) return;
else if (CheatType == ScanType.Hex && ValueBox.Text.Length > 32)
if (CheatType == ScanType.Hex && ValueBox.Text.Length > 16)
{
ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription());
return;
}
else if (newCheatType == ScanType.String_) return;

try
{
var newValue = ScanTool.ValueStringToULong(CheatType, ValueBox.Text);
if (newValue == 0) return;

if (newCheatType == ScanType.Byte_ && newValue > byte.MaxValue) return;
else if (newCheatType == ScanType.Bytes_2 && newValue > UInt16.MaxValue) return;
else if (newCheatType == ScanType.Bytes_4 && newValue > UInt32.MaxValue) return;
if (newCheatType == ScanType.Byte_ && newValue > byte.MaxValue ||
newCheatType == ScanType.Bytes_2 && newValue > UInt16.MaxValue ||
newCheatType == ScanType.Bytes_4 && newValue > UInt32.MaxValue ||
newCheatType == ScanType.Float_ && newValue > float.MaxValue)
{
ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription());
return;
}

var newText = ScanTool.ULongToString(newCheatType, newValue);
if (newText == "0") return;

Value = newValue.ToString();
ValueBox.Text = newText;

//var newOnValue = ScanTool.ValueStringToULong(CheatType, OnBox.Text);
//var newOnText = ScanTool.ULongToString(newCheatType, newOnValue);
//OnValue = newOnValue.ToString();
//OnBox.Text = newOnText;

//var newOffValue = ScanTool.ValueStringToULong(CheatType, OffBox.Text);
//var newOffText = ScanTool.ULongToString(newCheatType, newOffValue);
//OffValue = newOffValue.ToString();
//OffBox.Text = newOffText;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -417,26 +438,30 @@ private void RefreshPointerChecker_Tick(object sender, EventArgs e)

if (BaseSection == null) break;

if (TableLayoutBottomBox.Controls.Count > PointerOffsets.Count) PointerOffsets.Add(address);
else PointerOffsets[idx] = address;
PointerOffsets[idx] = address;

if (idx != TableLayoutBottomBox.Controls.Count - 1)
{
if (AddrSection == null || AddrSection.SID == 0) AddrSection = mainForm.sectionTool.GetSection(mainForm.sectionTool.GetSectionID((ulong)(address + baseAddress)));
byte[] nextAddress = PS4Tool.ReadMemory(AddrSection.PID, (ulong)(address + baseAddress), 8);
baseAddress = BitConverter.ToInt64(nextAddress, 0);
TableLayoutBottomLabel.Controls[idx].Text = baseAddress.ToString("X");
TableLayoutBottomLabel.Controls[idx].Text = string.Format("=> {0:X2} +", baseAddress);
}
else
{
if (address == 0 && baseAddress == 0) continue;
byte[] data = PS4Tool.ReadMemory(BaseSection.PID, (ulong)(address + baseAddress), ScanTool.ScanTypeLengthDict[CheatType]);
TableLayoutBottomLabel.Controls[idx].Text = ScanTool.BytesToString(CheatType, data);
int length = 0;
if (CheatType != ScanType.Hex) length = ScanTool.ScanTypeLengthDict[CheatType];
else if (ValueBox.Text.Length > 1) length = ValueBox.Text.Length / 2;
else length = 8;
byte[] data = PS4Tool.ReadMemory(BaseSection.PID, (ulong)(address + baseAddress), length);
string value = ScanTool.BytesToString(CheatType, data);
TableLayoutBottomLabel.Controls[idx].Text = string.Format("=> {0}", value);
AddressBox.Text = (address + baseAddress).ToString("X");
if (!ValueBox.Enabled || changedCheatType)
{
ValueBox.Enabled = true;
ValueBox.Text = TableLayoutBottomLabel.Controls[idx].Text;
ValueBox.Text = value;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions PS4CheaterNeo/PS4CheaterNeo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -83,6 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="common\CheatJson.cs" />
<Compile Include="common\CheatTrainer.cs" />
<Compile Include="common\CollapsibleSplitContainer.cs">
<SubType>Component</SubType>
</Compile>
Expand Down Expand Up @@ -181,6 +183,12 @@
<DependentUpon>SendPayload.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="languages\LanguageFile_Italian.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="languages\LanguageFile_Korean.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="languages\LanguageFile_English.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
4 changes: 2 additions & 2 deletions PS4CheaterNeo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.1")]
[assembly: AssemblyFileVersion("1.0.2.1")]
[assembly: AssemblyVersion("1.0.2.2")]
[assembly: AssemblyFileVersion("1.0.2.2")]
9 changes: 7 additions & 2 deletions PS4CheaterNeo/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,18 @@ private void ProcessesBox_SelectedIndexChanged(object sender, EventArgs e)

ComboItem process = (ComboItem)ProcessesBox.SelectedItem;
sectionTool.InitSections((int)process.Value, (string)process.Text);
mainForm.ProcessPid = (int)process.Value;
mainForm.ProcessName = (string)process.Text;
if (mainForm.GameID != null)
{
mainForm.ProcessPid = (int)process.Value;
mainForm.ProcessName = (string)process.Text;
}
else mainForm.InitSections((string)process.Text);

Section[] sections = sectionTool.GetSectionSortByAddr();
for (int sectionIdx = 0; sectionIdx < sections.Length; sectionIdx++)
{
Section section = sections[sectionIdx];
section.SN = sectionIdx;
if ((IsFilterBox.Checked && section.IsFilter) || (IsFilterSizeBox.Checked && section.IsFilterSize)) continue;

string start = String.Format("{0:X9}", section.Start);
Expand Down
Loading

0 comments on commit f303f26

Please sign in to comment.