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 


C# Pointer

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 2:45 am    Post subject: C# Pointer Reply with quote

Hi guys, long time no see.

I am trying to create a memory editor(trainer, whatever you want to call it) for a game. I got some pointers in CE but I can't get them to work in C#; I spent hours reading all the posts about this, still nothing working.

My pointer in CE:


What C# returns for my iteration over the offsets(You'll understand from code).


Basically, the very single thing that works there is getting the game's base address, after that, it's either broken or my math sucks.

Code:
Code:

            Process p = (from proc in Process.GetProcesses() where proc.ProcessName.ToLower() == "game" select proc).SingleOrDefault();

            IntPtr processBaseAddress = p.Modules[0].BaseAddress;
            Console.WriteLine(processBaseAddress.ToString("X"));
            Int64 baseAddress = processBaseAddress.ToInt64() + 0x01C4DFA0;
            Console.WriteLine(baseAddress.ToString("X"));
            byte[] btBuffer = new byte[4];
            IntPtr lpOutStorage = IntPtr.Zero;
            Int32[] offsetList = new Int32[] { 0x38, 0x20, 0x28, 0x1e0 };

           

            ReadProcessMemory(p.Handle, new IntPtr(baseAddress), btBuffer, (uint)btBuffer.Length, ref lpOutStorage);

            for (UInt32 x = 0; x < (offsetList.Length - 1); x++)
            {
                baseAddress = BitConverter.ToInt32(btBuffer, 0) + offsetList[x];
                ReadProcessMemory(p.Handle, new IntPtr(baseAddress), btBuffer, (uint)btBuffer.Length, ref lpOutStorage);
                Console.WriteLine(baseAddress.ToString("X"));
            }

            baseAddress = BitConverter.ToInt32(btBuffer, 0) + offsetList[offsetList.Length - 1];
            Console.WriteLine(baseAddress.ToString("X"));

            float result = 0.0f;
            byte[] btResult = new byte[Marshal.SizeOf(result)];
            ReadProcessMemory(p.Handle, new IntPtr(baseAddress), btResult, (uint)btResult.Length, ref lpOutStorage);
            result = BitConverter.ToSingle(btResult, 0);
            Console.WriteLine("Final: " + result);
            Console.ReadKey();


Any help is appreciated. Thank you.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Tue Nov 17, 2015 3:17 am    Post subject: Reply with quote

there is probably more wrong, but the main thing i see is thst you're reading pointers as 4 byte values, while the target is 64 bit
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 3:32 am    Post subject: Reply with quote

That's the main thing that came across my mind. All the examples were declaring everything as Int32, doing so, my code would throw an exception because my addresses are too long(I suppose). So, I just tried to change some things to Int64 to make it at least run with no errors.

I am new to memory editing(more exactly I am doing this for like 1-2 days). Last time I used CE was during AQ times(old times) and I just knew how to scan for a value and change it.

Now I am trying to create this app while also trying to learn more things about memory editing and C#.

EDIT: Lol, took me a few tries to realize that the game I mentioned above was the reason I could not post my message.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Nov 17, 2015 1:53 pm    Post subject: Reply with quote

Like DarkByte said, since this is 64bit addresses you need to use 64bit data types. You also need to make sure that you are compiling for 64bit code to ensure that things like IntPtr are defaulting to the proper size.

Other things need to be adjusted properly too such as:
Code:
byte[] btBuffer = new byte[4];


This should be 8 bytes for 64bit instead of 4.

These should not be using ToInt32:
Code:
baseAddress = BitConverter.ToInt32(btBuffer, 0) + offsetList[x];

baseAddress = BitConverter.ToInt32(btBuffer, 0) + offsetList[offsetList.Length - 1];

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 2:35 pm    Post subject: Reply with quote

I'll try changing it to 64 bits. Didn't know that 64 bits is using 8 bytes instead of 4, though it's obvious. I'll try a few changes hoping I won't run into too many errors.

Thank you very much.

Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Nov 17, 2015 2:49 pm    Post subject: Reply with quote

xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 2:59 pm    Post subject: Reply with quote

atom0s wrote:
xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).


Yeah, I saw tons of posts about memory, almost identical(that's how I set up my starting code).

We could get a Guild Wars 2 Section. Nobody could make better hacks for that than CE members. Or is hacking not a part of CE anymore?

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Nov 17, 2015 3:23 pm    Post subject: Reply with quote

xyo wrote:
atom0s wrote:
xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).


Yeah, I saw tons of posts about memory, almost identical(that's how I set up my starting code).

We could get a Guild Wars 2 Section. Nobody could make better hacks for that than CE members. Or is hacking not a part of CE anymore?


Multiplayer hacking is completely gone from CEF now. A while back there were some legal issues revolving around a popular section that used to be here (Moople) which resulted in DarkByte just blocking multiplayer hacking posts altogether to avoid future problems with other publishers.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 3:34 pm    Post subject: Reply with quote

atom0s wrote:
xyo wrote:
atom0s wrote:
xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).


Yeah, I saw tons of posts about memory, almost identical(that's how I set up my starting code).

We could get a Guild Wars 2 Section. Nobody could make better hacks for that than CE members. Or is hacking not a part of CE anymore?


Multiplayer hacking is completely gone from CEF now. A while back there were some legal issues revolving around a popular section that used to be here (Moople) which resulted in DarkByte just blocking multiplayer hacking posts altogether to avoid future problems with other publishers.


Sounds fair. Anyway, the game I was was making my app for(GW2) just released a new update a few hours ago and all the addresses I wanted to modify are now not writable. Guess I have to move to functions editing rather than value editing.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 5:13 pm    Post subject: Reply with quote

Shrooms wrote:
xyo wrote:
atom0s wrote:
xyo wrote:
atom0s wrote:
xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).


Yeah, I saw tons of posts about memory, almost identical(that's how I set up my starting code).

We could get a Guild Wars 2 Section. Nobody could make better hacks for that than CE members. Or is hacking not a part of CE anymore?


Multiplayer hacking is completely gone from CEF now. A while back there were some legal issues revolving around a popular section that used to be here (Moople) which resulted in DarkByte just blocking multiplayer hacking posts altogether to avoid future problems with other publishers.


Sounds fair. Anyway, the game I was was making my app for(GW2) just released a new update a few hours ago and all the addresses I wanted to modify are now not writable. Guess I have to move to functions editing rather than value editing.


hacking guild wars 2 after my app, tyvm


I don't really remember even seeing your name these days while browsing the forums for answers.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
xyo
Grandmaster Cheater
Reputation: 0

Joined: 25 Jul 2009
Posts: 957
Location: Romania

PostPosted: Tue Nov 17, 2015 6:01 pm    Post subject: Reply with quote

Shrooms wrote:
xyo wrote:
Shrooms wrote:
xyo wrote:
atom0s wrote:
xyo wrote:
atom0s wrote:
xyo wrote:
Off topic: what's mostly happening on CE forum nowadays? I haven't been here for years.


Not a whole lot. Things have quieted down a lot over the last few years. Lot of the older crowed has disappeared. Some occasional pop-ins from people here and there but nothing too major.

The programming section has basically become a section that has the same ~3 questions asked over and over (mainly how to get a base address).


Yeah, I saw tons of posts about memory, almost identical(that's how I set up my starting code).

We could get a Guild Wars 2 Section. Nobody could make better hacks for that than CE members. Or is hacking not a part of CE anymore?


Multiplayer hacking is completely gone from CEF now. A while back there were some legal issues revolving around a popular section that used to be here (Moople) which resulted in DarkByte just blocking multiplayer hacking posts altogether to avoid future problems with other publishers.


Sounds fair. Anyway, the game I was was making my app for(GW2) just released a new update a few hours ago and all the addresses I wanted to modify are now not writable. Guess I have to move to functions editing rather than value editing.


hacking guild wars 2 after my app, tyvm


I don't really remember even seeing your name these days while browsing the forums for answers.


??? cause i dont answer???


I said I did not use any of your apps/examples or whatever you want to call them.

_________________
Banned by Dark Byte at Mon Jun 16, 2009 12:00 pm. Expires: Wed Oct 23, 2018 12:00 pm
Reason: Deleting AQW Section
Back to top
View user's profile Send private message Yahoo Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Nov 17, 2015 8:05 pm    Post subject: Reply with quote

Given that you disclosed the name of the game this is for.. and its multiplayer, going to lock this now since it goes against the rules.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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