Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Base address + Pointer calculating help pls

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Tue Apr 29, 2014 9:17 am    Post subject: Base address + Pointer calculating help pls Reply with quote

How do I calculate with calc.exe?
For example I have "game.exe" + 00050A68 pointing at 0038F51C
How do I get those two into one Hex? I've tried 400000 + 50A68 in calculator, but in my C# program it shows up as a completely different value than in cheat engine.. Help please
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Apr 29, 2014 4:05 pm    Post subject: Reply with quote

Use the Process class to get the base address of the the application (and modules if needed):
http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.process

As for using hex in C#, hexadecimal is represented with 0x at the start of a number like:
0x00050A68

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Wed Apr 30, 2014 8:22 am    Post subject: Reply with quote

Thanks now i get the base address, but it's not correct.. Cheat engine says its 00400000 but my program says its 964016 or something
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Apr 30, 2014 2:32 pm    Post subject: Reply with quote

Kunn wrote:
Thanks now i get the base address, but it's not correct.. Cheat engine says its 00400000 but my program says its 964016 or something


Show the code you are using otherwise there is not much we can do to help you.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Wed Apr 30, 2014 4:04 pm    Post subject: Reply with quote

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Bot.Addresses
{
    public class Version
    {

        public static void SetAddresses()
        {
            Process[] Clients = Process.GetProcessesByName("Tibianic");
            Process SelectedClient = Clients[0];
            //UInt32 BaseAddress = (UInt32)SelectedClient.MainModule.BaseAddress.ToInt32();
            uint BaseAddress = Convert.ToUInt32(SelectedClient.MainModule.BaseAddress.ToInt32());

            Player.Id = 0x05C684C + BaseAddress;
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Apr 30, 2014 6:28 pm    Post subject: Reply with quote

Quote:
uint BaseAddress = Convert.ToUInt32(SelectedClient.MainModule.BaseAddress.ToInt32());


You do not need to do all that conversion. You just need to convert it once to an int unless your code uses IntPtrs which wouldn't hurt if it did.

Anyway, you just need:
Code:

var baseAddress = SelectedClient.MainModule.BaseAddress.ToInt32();
var address = baseAddress + 0x00050A68;


From your first post you said this was pointing to something so you will need to read the value of it first if it is a pointer.

As for this line:
Code:
            Player.Id = 0x05C684C + BaseAddress;


Not sure what you are trying to do here, but that is not how to read or write memory.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Wed Apr 30, 2014 7:25 pm    Post subject: Reply with quote

Okay thats interesting. It returns the baseaddress as hex 905A4D which is actually what tibianic.exe points at in cheat engine. But when I do baseAddress + 0x00050A68 it again gets me the hex address of where it points to not the value.. It's hard to explain here but baseAddress + 0x00050A68 should equal to 168 which is the HEALTH value im looking for but instead it gives baseAddress + 0x00050A68 = 7DF51C which is the health address
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Apr 30, 2014 8:34 pm    Post subject: Reply with quote

You need to read the address to obtain its value. Doing the base+value is just going to give you the address to read, not the value.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Wed Apr 30, 2014 8:59 pm    Post subject: Reply with quote

im reading it, somehow because its a pointer it acts differently, it works with static addreses with tibianic.exe + xxxxx now, but not with pointers
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Apr 30, 2014 11:44 pm    Post subject: Reply with quote

The code you showed above is not reading anything. You are just setting some random object to a value that is not reading/writing anything to memory.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Kunn
How do I cheat?
Reputation: 0

Joined: 05 Dec 2006
Posts: 9

PostPosted: Thu May 01, 2014 6:57 am    Post subject: Reply with quote

yes thats because i've got a lot of code, wasn't posting that all here..
Now this code is returning a true value:
Code:

        public int Mana
        {
            get { return Memory.ReadInt(Addresses.Player.Mana); }
        }


//
        private void label9_Click(object sender, EventArgs e)
        {
             label9.Text = Memory.ReadInt(Addresses.Player.Mana).ToString();
        }

//

And this is where I have declared the mana address(the place you said is wrong)
Player.Mana = baseAddress + 0x01C6828;


Now this code works and returns the real value, but if the address was changed to Player.Health = baseAddress + 0x00050A68; which is a pointer it reads back the hex address of where its pointing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites