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++] Finding Address from pointer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kewun
Cheater
Reputation: 0

Joined: 18 Sep 2016
Posts: 30

PostPosted: Sun Feb 19, 2017 2:29 pm    Post subject: [C++] Finding Address from pointer Reply with quote

http://imgur.com/a/Ln6xB

Im trying to find a address of pointer, then change its value to 9999, but it just changes other address's value and crashes my game
how do i properly calculate or fix this?

Code:

#include "stdafx.h"
#include <Windows.h>
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
   if (dwAttached == DLL_PROCESS_ATTACH) {
      LONG pointer = 0x002231BC;
      LONG offset = 0x3C8;
      LONG address;
      address = (pointer + offset);
      *(DWORD*)(address) = 9999;
      Sleep(200);
   }
   return 1;
}
Back to top
View user's profile Send private message
Kewun
Cheater
Reputation: 0

Joined: 18 Sep 2016
Posts: 30

PostPosted: Mon Feb 20, 2017 1:43 pm    Post subject: Reply with quote

bump
Back to top
View user's profile Send private message
Viloresi
Expert Cheater
Reputation: 0

Joined: 02 Feb 2017
Posts: 117

PostPosted: Mon Feb 20, 2017 4:07 pm    Post subject: Reply with quote

You have to sum the offset to the address pointed by the pointer... In that code you are adding the offset to the pointer which doesn't make sense, please read here.
Code:
http://www.cplusplus.com/doc/tutorial/pointers/
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 338

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

PostPosted: Mon Feb 20, 2017 4:50 pm    Post subject: Reply with quote

http://forum.cheatengine.org/viewtopic.php?t=422516
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Kewun
Cheater
Reputation: 0

Joined: 18 Sep 2016
Posts: 30

PostPosted: Wed Feb 22, 2017 8:18 am    Post subject: Reply with quote

Viloresi wrote:
You have to sum the offset to the address pointed by the pointer... In that code you are adding the offset to the pointer which doesn't make sense, please read here.
Code:
http://www.cplusplus.com/doc/tutorial/pointers/


didnt understand anything D:
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 136

Joined: 25 Jan 2006
Posts: 7134
Location: 127.0.0.1

PostPosted: Thu Mar 02, 2017 3:33 am    Post subject: Reply with quote

Kewun wrote:
Viloresi wrote:
You have to sum the offset to the address pointed by the pointer... In that code you are adding the offset to the pointer which doesn't make sense, please read here.
Code:
http://www.cplusplus.com/doc/tutorial/pointers/


didnt understand anything D:


You are going to have to keep reading and learning the basics of the language if you plan to compile anything and make use of the language at all. Search around for some other similar tutorials on the same topic that may have a better approach to helping you learn such as videos or different visual examples if that is something you learn better from.

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

Joined: 18 Sep 2016
Posts: 30

PostPosted: Thu Mar 02, 2017 6:40 am    Post subject: Reply with quote

yeah but im a type of person who learns from examples..
Back to top
View user's profile Send private message
Viloresi
Expert Cheater
Reputation: 0

Joined: 02 Feb 2017
Posts: 117

PostPosted: Thu Mar 02, 2017 8:38 am    Post subject: Reply with quote

Kewun wrote:
yeah but im a type of person who learns from examples..


Code:

#include "stdafx.h"
#include <Windows.h>
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
   if (dwAttached == DLL_PROCESS_ATTACH) {
      LONG pointer = 0x002231BC;
      LONG offset = 0x3C8;
      LONG address;
      address = ((DWORD*)(pointer) + offset);
      (DWORD*)(address) = 9999;
      Sleep(200);
   }
   return 1;
}



I've just corrected your code, remember that this is not optimized (for example the dword cast is pointless)
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