| View previous topic :: View next topic |
| Author |
Message |
argie Newbie cheater
Reputation: 0
Joined: 23 Sep 2012 Posts: 21
|
Posted: Sat Feb 01, 2014 12:18 pm Post subject: C# 'Green' Static Address Help |
|
|
Hi.
I am using the source from: forum. cheatengine. org / viewtopic.php?t=530375
I usually do my "hacks" by pointers scans of 'whites' and then input the offsets but in this rare case I got the working 'green' static address from the few scans.
game+00FF8C75
I completely understand what is going on in Globals.cs, but I do not know how to input this address into the globals for trainer to read and write to game.exe process.
I even went far out to search for pointers of the address where game+00FF8C75 leads but there are none.
All I have is game+00FF8C75 and address where that leads.
Can you please help me on how to input this into the trainer? That address is a 4byte value changer. So for example if everything worked perfectly I would use it like Metal or Energy "Set" value. Initial value is 0.
Thanks in advance,
Regards.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Feb 01, 2014 2:28 pm Post subject: |
|
|
When Cheat Engine displays something like 'game.exe' or 'SomeDLL.dll' in the address calculation it means to use the base address of that module.
In C# you can get that information using the Process class.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx
To get a list of processes that match the games name:
| Code: | | var procs = Process.GetProcessesByName("the proc name"); |
(Keep in mind when you use this call, do not include .exe in the name!)
To get the main executables base address, you can use
| Code: | | procs[0].MainModule.BaseAddress |
For base addresses of DLLs, you will want to enumerate the ProcessModule list of the process and locate the one you need, then use the BaseAddress.
_________________
- Retired. |
|
| Back to top |
|
 |
argie Newbie cheater
Reputation: 0
Joined: 23 Sep 2012 Posts: 21
|
Posted: Sun Feb 02, 2014 8:30 am Post subject: |
|
|
Thank you for reply.
I included the process class and did some more work and now I am left with address: sc2.exe+45EF7F0 which also is always the same (static) and it's starting value is 0.
Now I am not sure how to implement it here:
public static int iTestValue_Address = Addr.ToDec("????????"); // Start Address for Value
public static int[] iTestValue_Offset = { 0x??, 0x?? }; // Offset
In some other case if it was a white pointer I would set 045EF7F0 in Addr.ToDec and add appropriate number of pointer levels into offset.
But how to implement this static address? I'm sorry this is kinda noobish question but I really don't know how to implement it in C#.
Solution is to be able (in winform texbox) set the value, press the button and that value is written to the address above.
Thanks.
|
|
| Back to top |
|
 |
Polynomial Grandmaster Cheater
Reputation: 5
Joined: 17 Feb 2008 Posts: 524 Location: Inside the Intel CET shadow stack
|
Posted: Sun Feb 02, 2014 1:44 pm Post subject: |
|
|
A static address doesn't change its offset from the module base address, so it should be as simple as adding 0x45EF7F0 to procs[0].MainModule.BaseAddress as Wiccaan mentioned above.
I'd do something like this...
| Code: | const int MineralsAddress = 0x045EF7F0;
var procs = Process.GetProcessesByName("sc2.exe");
if (procs.Length != 1)
{
MessageBox.Show("Game not running or multiple copies running.");
return;
}
var sc2proc = procs[0];
var rights = Native.PROCESS_VM_OPERATION | Native.PROCESS_VM_READ | Native.PROCESS_VM_WRITE;
var hProc = Native.OpenProcess(rights, false sc2proc.Id);
try
{
if (hProc == 0)
{
MessageBox.Show("Couldn't open process handle.");
return;
}
var targetAddr = sc2proc.MainModule.BaseAddress + MineralsAddress;
byte[] data = BitConverter.GetBytes((int)9999999);
int br = 0;
if (!Native.WriteProcessMemory(sc2proc.Handle, targetAddr, data, 4, out br) || br != 4)
{
MessageBox.Show("Write operation failed.");
return;
}
}
finally
{
Native.CloseHandle(hProc);
} |
_________________
It's not fun unless every exploit mitigation is enabled.
Please do not reply to my posts with LLM-generated slop; I consider it to be an insult to my time. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Feb 03, 2014 12:35 am Post subject: |
|
|
There is typically no need to call native API (OpenProcess / CloseHandle) with C# as you are already given a fully qualified handle exposed via the Process class.
| Code: |
var sc2proc = procs[0];
var handle = sc2proc.Handle; // You can use this instead.
|
_________________
- Retired. |
|
| Back to top |
|
 |
argie Newbie cheater
Reputation: 0
Joined: 23 Sep 2012 Posts: 21
|
Posted: Mon Feb 03, 2014 5:21 am Post subject: |
|
|
Again, thanks for replies.
I already have a process running or not checker in my project but I created a new one just to test out the results.
Here is the code: paste2. org / JU1tj942
Errors:
| Code: | | Every Native. = The name 'Native' does not exist in the current context |
I tried with just the handle as Wiccann suggested, same errors.
I already have a process running checker and pretty much everything else, I just didn't know how to implement a no pointer static into the Globals.cs. I am working from a project here:
mediafire. com / ?wj7wegaspmdn0gx
Thanks.
|
|
| Back to top |
|
 |
Polynomial Grandmaster Cheater
Reputation: 5
Joined: 17 Feb 2008 Posts: 524 Location: Inside the Intel CET shadow stack
|
Posted: Mon Feb 03, 2014 4:23 pm Post subject: |
|
|
Well, yeah, of course Native doesn't exist. You're meant to create a class called Native and populate it with your API pinvoke definitions.
_________________
It's not fun unless every exploit mitigation is enabled.
Please do not reply to my posts with LLM-generated slop; I consider it to be an insult to my time. |
|
| Back to top |
|
 |
argie Newbie cheater
Reputation: 0
Joined: 23 Sep 2012 Posts: 21
|
Posted: Tue Feb 04, 2014 4:09 am Post subject: |
|
|
Yeah I figured it's a new class or something, I just thought you have lookied into the project file where almost all is defined with the exception of the Globals.cs correction.
Note that Globals.cs has tons of definitions, this is just the one for this static.
| Code: | Globals.cs:
public static int iMineralsValue_Address = Addr.ToDec("045EF7F0");
public static int[] iMineralsValue_Offset = { 0x00 };Address |
| Code: | MainForm.cs:
private void hSet_Mineral_Click(object sender, EventArgs e)
{
if (oMemory.ReadProcess != null)
{
if ((hMineral_Input.Text != "") && (Addr.IsNumeric(hMineral_Input.Text) == true))
{
oMemory.PointerWrite((IntPtr)Globals.iMineralsValue_Address,
BitConverter.GetBytes((float)Convert.ToInt32(hMineral_Input.Text)), // ignore the float... it doesn't work anyway.
Globals.iMineralsValue_Offset,
out Globals.iWrittenBytes);
}
else
MessageBox.Show("Error: Value is either not present or not a number.");
}
} |
Basically this is the buttonclick that sets the value from the textbox. But whatever I do, it won't work... Whole code is in the mediafire link in the post above.
Thanks again for your help.
|
|
| Back to top |
|
 |
Polynomial Grandmaster Cheater
Reputation: 5
Joined: 17 Feb 2008 Posts: 524 Location: Inside the Intel CET shadow stack
|
Posted: Tue Feb 04, 2014 3:04 pm Post subject: |
|
|
As we've pointed out, you need to get the base address of the main process module and add it to iMineralsValue_Address.
_________________
It's not fun unless every exploit mitigation is enabled.
Please do not reply to my posts with LLM-generated slop; I consider it to be an insult to my time. |
|
| Back to top |
|
 |
argie Newbie cheater
Reputation: 0
Joined: 23 Sep 2012 Posts: 21
|
Posted: Wed Feb 05, 2014 8:09 am Post subject: |
|
|
Ah I found it =)
Works great! Thanks for all help!
|
|
| Back to top |
|
 |
|