Skip to content

Commit f303f26

Browse files
committed
Now supports loading all Cheat Trainer/GoldHEN formats (*.json, *.shn, *.mc4),
with MC4 formats supporting reading only. Added display interface languages: Korean, Italian.
1 parent 05b0710 commit f303f26

16 files changed

+1302
-217
lines changed

PS4CheaterNeo/Main.cs

Lines changed: 292 additions & 120 deletions
Large diffs are not rendered by default.

PS4CheaterNeo/NewAddress.Designer.cs

Lines changed: 50 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PS4CheaterNeo/NewAddress.cs

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@ public NewAddress(Main mainForm, Section addrSection, Section baseSection, ulong
4343
OnBox = new TextBox();
4444
OffBox = new TextBox();
4545

46-
OnLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
4746
OnLabel.AutoSize = true;
47+
OnLabel.Dock = DockStyle.Fill;
4848
OnLabel.Margin = AddressLabel.Margin;
4949
OnLabel.Name = "OnLabel";
5050
OnLabel.TabIndex = 1;
5151
OnLabel.Text = "On";
52+
OnLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
5253

5354
OffLabel.AutoSize = true;
54-
OffLabel.Dock = DockStyle.Right;
55+
OffLabel.Dock = DockStyle.Fill;
5556
OffLabel.ForeColor = ForeColor;
5657
OffLabel.Margin = ValueLabel.Margin;
5758
OffLabel.Name = "OffLabel";
5859
OffLabel.Text = "Off";
60+
OffLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
5961

6062
OnBox.BackColor = BackColor;
6163
OnBox.ForeColor = ForeColor;
@@ -160,6 +162,7 @@ public void ApplyUI(LanguageJson langJson)
160162
DescriptionLabel.ForeColor = ForeColor;
161163
LockBox.ForeColor = ForeColor;
162164
PointerBox.ForeColor = ForeColor;
165+
OnOffBox.ForeColor = ForeColor;
163166

164167
AddressBox.ForeColor = ForeColor;
165168
AddressBox.BackColor = BackColor;
@@ -209,12 +212,12 @@ private void SaveBtn_Click(object sender, EventArgs e)
209212
CheatType = (ScanType)((ComboItem)(ScanTypeBox.SelectedItem)).Value;
210213
ScanTool.ValueStringToULong(CheatType, ValueBox.Text);
211214
Value = ValueBox.Text;
212-
OnValue = OnBox.Text;
213-
OffValue = OffBox.Text;
215+
OnValue = string.IsNullOrWhiteSpace(OnBox.Text) ? null : OnBox.Text;
216+
OffValue = string.IsNullOrWhiteSpace(OffBox.Text) ? null : OffBox.Text;
214217
IsLock = LockBox.Checked;
215218
Descriptioin = DescriptionBox.Text;
216219

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

219222
DialogResult = DialogResult.OK;
220223
Close();
@@ -320,24 +323,26 @@ private void SetOffsetBoxs(bool isAdd)
320323
{
321324
TextBox textBox = new TextBox
322325
{
323-
Text = "0",
324-
Location = AddOffsetBtn.Location,
326+
Text = "0",
327+
Location = AddOffsetBtn.Location,
325328
ForeColor = ForeColor,
326329
BackColor = BackColor,
327-
Dock = DockStyle.Fill,
328-
Margin = new Padding(3)
330+
Dock = DockStyle.Fill,
331+
Margin = new Padding(3)
329332
};
330333

331-
Label label = new Label
334+
TextBox label = new TextBox
332335
{
333-
Text = "",
334-
Location = DelOffsetBtn.Location,
335-
ForeColor = ForeColor,
336-
BackColor = BackColor,
337-
Dock = DockStyle.Fill,
338-
Margin = new Padding(3)
339-
};
340-
336+
Text = "",
337+
Location = DelOffsetBtn.Location,
338+
ForeColor = ForeColor,
339+
BackColor = BackColor,
340+
Dock = DockStyle.Fill,
341+
Margin = new Padding(3, 6, 3, 3),
342+
ReadOnly = true,
343+
BorderStyle = BorderStyle.None,
344+
};
345+
PointerOffsets.Add(0);
341346
TableLayoutBottomBox.RowCount += 1;
342347
TableLayoutBottomBox.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
343348
TableLayoutBottomBox.Controls.Add(textBox, 0, TableLayoutBottomBox.Controls.Count);
@@ -351,6 +356,7 @@ private void SetOffsetBoxs(bool isAdd)
351356
{
352357
if (TableLayoutBottomBox.Controls.Count == 0) return;
353358

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

368374
var newCheatType = (ScanType)((ComboItem)(ScanTypeBox.SelectedItem)).Value;
369-
if (newCheatType == ScanType.String_) return;
370-
else if (CheatType == ScanType.Hex && ValueBox.Text.Length > 32)
375+
if (CheatType == ScanType.Hex && ValueBox.Text.Length > 16)
371376
{
372377
ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription());
373378
return;
374379
}
380+
else if (newCheatType == ScanType.String_) return;
375381

376382
try
377383
{
378384
var newValue = ScanTool.ValueStringToULong(CheatType, ValueBox.Text);
379385
if (newValue == 0) return;
380386

381-
if (newCheatType == ScanType.Byte_ && newValue > byte.MaxValue) return;
382-
else if (newCheatType == ScanType.Bytes_2 && newValue > UInt16.MaxValue) return;
383-
else if (newCheatType == ScanType.Bytes_4 && newValue > UInt32.MaxValue) return;
387+
if (newCheatType == ScanType.Byte_ && newValue > byte.MaxValue ||
388+
newCheatType == ScanType.Bytes_2 && newValue > UInt16.MaxValue ||
389+
newCheatType == ScanType.Bytes_4 && newValue > UInt32.MaxValue ||
390+
newCheatType == ScanType.Float_ && newValue > float.MaxValue)
391+
{
392+
ScanTypeBox.SelectedIndex = ScanTypeBox.FindStringExact(CheatType.GetDescription());
393+
return;
394+
}
384395

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

388399
Value = newValue.ToString();
389400
ValueBox.Text = newText;
401+
402+
//var newOnValue = ScanTool.ValueStringToULong(CheatType, OnBox.Text);
403+
//var newOnText = ScanTool.ULongToString(newCheatType, newOnValue);
404+
//OnValue = newOnValue.ToString();
405+
//OnBox.Text = newOnText;
406+
407+
//var newOffValue = ScanTool.ValueStringToULong(CheatType, OffBox.Text);
408+
//var newOffText = ScanTool.ULongToString(newCheatType, newOffValue);
409+
//OffValue = newOffValue.ToString();
410+
//OffBox.Text = newOffText;
390411
}
391412
catch (Exception ex)
392413
{
@@ -417,26 +438,30 @@ private void RefreshPointerChecker_Tick(object sender, EventArgs e)
417438

418439
if (BaseSection == null) break;
419440

420-
if (TableLayoutBottomBox.Controls.Count > PointerOffsets.Count) PointerOffsets.Add(address);
421-
else PointerOffsets[idx] = address;
441+
PointerOffsets[idx] = address;
422442

423443
if (idx != TableLayoutBottomBox.Controls.Count - 1)
424444
{
425445
if (AddrSection == null || AddrSection.SID == 0) AddrSection = mainForm.sectionTool.GetSection(mainForm.sectionTool.GetSectionID((ulong)(address + baseAddress)));
426446
byte[] nextAddress = PS4Tool.ReadMemory(AddrSection.PID, (ulong)(address + baseAddress), 8);
427447
baseAddress = BitConverter.ToInt64(nextAddress, 0);
428-
TableLayoutBottomLabel.Controls[idx].Text = baseAddress.ToString("X");
448+
TableLayoutBottomLabel.Controls[idx].Text = string.Format("=> {0:X2} +", baseAddress);
429449
}
430450
else
431451
{
432452
if (address == 0 && baseAddress == 0) continue;
433-
byte[] data = PS4Tool.ReadMemory(BaseSection.PID, (ulong)(address + baseAddress), ScanTool.ScanTypeLengthDict[CheatType]);
434-
TableLayoutBottomLabel.Controls[idx].Text = ScanTool.BytesToString(CheatType, data);
453+
int length = 0;
454+
if (CheatType != ScanType.Hex) length = ScanTool.ScanTypeLengthDict[CheatType];
455+
else if (ValueBox.Text.Length > 1) length = ValueBox.Text.Length / 2;
456+
else length = 8;
457+
byte[] data = PS4Tool.ReadMemory(BaseSection.PID, (ulong)(address + baseAddress), length);
458+
string value = ScanTool.BytesToString(CheatType, data);
459+
TableLayoutBottomLabel.Controls[idx].Text = string.Format("=> {0}", value);
435460
AddressBox.Text = (address + baseAddress).ToString("X");
436461
if (!ValueBox.Enabled || changedCheatType)
437462
{
438463
ValueBox.Enabled = true;
439-
ValueBox.Text = TableLayoutBottomLabel.Controls[idx].Text;
464+
ValueBox.Text = value;
440465
}
441466
}
442467
}

PS4CheaterNeo/PS4CheaterNeo.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<Reference Include="System.Configuration" />
7272
<Reference Include="System.Core" />
7373
<Reference Include="System.Runtime.Serialization" />
74+
<Reference Include="System.Web" />
7475
<Reference Include="System.Xml.Linq" />
7576
<Reference Include="System.Data.DataSetExtensions" />
7677
<Reference Include="Microsoft.CSharp" />
@@ -83,6 +84,7 @@
8384
</ItemGroup>
8485
<ItemGroup>
8586
<Compile Include="common\CheatJson.cs" />
87+
<Compile Include="common\CheatTrainer.cs" />
8688
<Compile Include="common\CollapsibleSplitContainer.cs">
8789
<SubType>Component</SubType>
8890
</Compile>
@@ -181,6 +183,12 @@
181183
<DependentUpon>SendPayload.cs</DependentUpon>
182184
<SubType>Designer</SubType>
183185
</EmbeddedResource>
186+
<None Include="languages\LanguageFile_Italian.json">
187+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
188+
</None>
189+
<None Include="languages\LanguageFile_Korean.json">
190+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
191+
</None>
184192
<None Include="languages\LanguageFile_English.json">
185193
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
186194
</None>

PS4CheaterNeo/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.2.1")]
36-
[assembly: AssemblyFileVersion("1.0.2.1")]
35+
[assembly: AssemblyVersion("1.0.2.2")]
36+
[assembly: AssemblyFileVersion("1.0.2.2")]

PS4CheaterNeo/Query.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,18 @@ private void ProcessesBox_SelectedIndexChanged(object sender, EventArgs e)
298298

299299
ComboItem process = (ComboItem)ProcessesBox.SelectedItem;
300300
sectionTool.InitSections((int)process.Value, (string)process.Text);
301-
mainForm.ProcessPid = (int)process.Value;
302-
mainForm.ProcessName = (string)process.Text;
301+
if (mainForm.GameID != null)
302+
{
303+
mainForm.ProcessPid = (int)process.Value;
304+
mainForm.ProcessName = (string)process.Text;
305+
}
306+
else mainForm.InitSections((string)process.Text);
303307

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

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

0 commit comments

Comments
 (0)