 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
0_yami_0 Newbie cheater
Reputation: 0
Joined: 07 May 2016 Posts: 13
|
Posted: Sat May 07, 2016 1:27 am Post subject: [C#][Game Trainer] Getting the correct Base Address |
|
|
Hello !
I'm currently making a game trainer for the Resident Evil 0 HD game.
I found base addresses within Cheat Engine, so far, works perfectly, but if I want to develope a trainer in C# language with Visual Studio 2015, I don't know how to retrieve the same base address.
The format of an address is like that in CE "re0hd.exe"+009CEF24 + offset,
I tried a lot of things to retrieve the value of "re0hd.exe", nothing works.
I tried the BlackMagic dll and Process class to open/read/write a process.
Here is my code:
| Code: |
using System.Windows.Forms;
using System;
using Magic;
using System.Diagnostics;
namespace CheatEngineApp
{
public partial class Cheat : Form
{
private uint value;
private BlackMagic game;
private Process gme;
private uint baseAddress;
private uint entry;
private uint hand;
public Cheat()
{
InitializeComponent();
game = new BlackMagic();
game.OpenProcessAndThread(SProcess.GetProcessFromProcessName("re0hd.exe"));
gme = Process.GetProcessesByName("re0hd")[0];
hand = (uint)gme.Handle;
entry = (uint)gme.MainModule.EntryPointAddress;
baseAddress = (uint)gme.MainModule.BaseAddress;
}
private void button1_Click(object sender, EventArgs e)
{
uint offAdd = 0x9CEF24;
uint baseAd = baseAddress + offAdd;
uint offset = 0x44;
game.WriteUInt(baseAd + offset, value);
uint a = 0x28F45034;
uint b = baseAd;
uint c = 0x905A4D;
//MessageBox.Show(a.ToString());
//MessageBox.Show(b.ToString());
//MessageBox.Show(hand.ToString());
//MessageBox.Show(entry.ToString());
//MessageBox.Show(baseAddress.ToString());
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
value = uint.Parse(textBox1.Text);
}
}
}
|
The weird thing about CE is that, the address value without offset, for example, "re0hd.exe"+009CEF24 is 28EA5034 (different for each launch of the game), so if I substract 009CEF24 to 28EA5034 I got 284D60CC, but if I remove +009CEF24 from "re0hd.exe"+009CEF24 I got 00905A4D everytime.
Any assistance on this matter would very helpful!
Thanks in advance. |
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4709
|
Posted: Sat May 07, 2016 8:42 am Post subject: |
|
|
Google is a thing.
| 0_yami_0 wrote: | | The weird thing about CE is that, the address value without offset, for example, "re0hd.exe"+009CEF24 is 28EA5034 (different for each launch of the game), so if I substract 009CEF24 to 28EA5034 I got 284D60CC, but if I remove +009CEF24 from "re0hd.exe"+009CEF24 I got 00905A4D everytime. |
I'm not sure how you got that result. 28EA5034 - 009CEF24 = 284D6110.
Regardless, are you sure you're not looking at the address being pointed at by the pointer? _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
0_yami_0 Newbie cheater
Reputation: 0
Joined: 07 May 2016 Posts: 13
|
Posted: Sat May 07, 2016 1:50 pm Post subject: |
|
|
I don't know what do you mean by "the address being pointed at the pointer".
Within CE the base address is "re0hd.exe"+009CEF24 (28EA5034), the offset is 0x44, and so the final address is 28EA5078, if I put manualy (without BaseAddress property) the value of the final address:
| Code: |
uint value = 22;
uint address = 0x28EA5078;
game.WriteUInt(address, value);
|
or like this
| Code: |
uint value = 22;
uint baseAd = 0x28EA5034;
uint offset = 0x44;
game.WriteUInt(baseAd + offset, value);
|
the both work as I want.
It's maybe a conversion problem from intptr (Process.MainModule.BaseAddress) to uint, I tried a lot of things (.ToInt32(), .ToInt64(), (uint)baseaddress...), same results.
I realy need help about this, thanks. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat May 07, 2016 2:06 pm Post subject: |
|
|
In C# you can use the Process class to obtain the process instance. Then within that object is the modules and MainModule which will hold the base addresses and sizes of the modules.
https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx
For the processes information you are interested in MainModule. _________________
- Retired. |
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4709
|
Posted: Sat May 07, 2016 2:25 pm Post subject: |
|
|
| 0_yami_0 wrote: | | the base address is "re0hd.exe"+009CEF24 (28EA5034), the offset is 0x44, and so the final address is 28EA5078 |
Assuming you're talking about a pointer, that's incorrect. A pointer is an address whose value is another address. You need to dereference that pointer in order to see what's at that other address. Read this topic (or use google) for more information on pointers.
If you're not talking about a pointer, then you shouldn't make it seem like you are. Just write down "re0hd.exe" + 009CEF68 instead of "re0hd.exe" + 009CEF24 + 44. _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
0_yami_0 Newbie cheater
Reputation: 0
Joined: 07 May 2016 Posts: 13
|
Posted: Sun May 08, 2016 12:41 am Post subject: |
|
|
Okay, thanks guys, now it works perfectly with the following code, I didn't know that I had to read first the base address.
| Code: |
private void button1_Click(object sender, EventArgs e)
{
uint offAdd = 0x9CEF24;
uint offset = 0x44;
uint finalAd;
baseAddress = game.ReadUInt((uint)game.MainModule.BaseAddress + offAdd);
MessageBox.Show("aaa " + baseAddress.ToString("X"));
finalAd = baseAddress + offset;
MessageBox.Show("ccc "+ finalAd.ToString("X"));
game.WriteUInt(finalAd, value);
}
|
Thanks a lot. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|