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 


[SOLVED] [C++] Find program's entry point/base address.
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Aug 03, 2014 9:17 am    Post subject: Reply with quote

Check your unneeded typecasting
_________________
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
NullBy7e
Cheater
Reputation: 0

Joined: 23 Jul 2014
Posts: 47

PostPosted: Sun Aug 03, 2014 9:46 am    Post subject: Reply with quote

Code:

int addr;

   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)CSettings::base + 0x00FD1D9C, &addr, sizeof(addr), 0);
   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)addr + 0x60, &addr, sizeof(addr), 0);
   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)addr + 0xA4, &addr, sizeof(addr), 0);
   byte* cname = new byte[24];
   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)addr, &cname, sizeof(cname), 0);
   char* data;
   hexArrayToStr(cname, sizeof(cname), &data);
   cout << data;
   delete cname;
   delete data;


How about this?
I get no errors no nothing and instead of a string of 24bytes it prints an hex address.

When I enclose it in () like so, I get access violation at hexArrayToStr:

Code:

   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)(CSettings::base + 0x00FD1D9C), &addr, sizeof(addr), 0);
   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)(addr + 0x60), &addr, sizeof(addr), 0);
   ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)(addr + 0xA4), &addr, sizeof(addr), 0);
Back to top
View user's profile Send private message
NullBy7e
Cheater
Reputation: 0

Joined: 23 Jul 2014
Posts: 47

PostPosted: Mon Aug 04, 2014 4:23 am    Post subject: Reply with quote

Why is the third address thats printed not what it should be?
Is ReadProcessMemory shifting bytes or something?

Code:

int addr = 0;

   ReadProcessMemory(CSettings::phandle, (void*)(CSettings::base + 0x00FD1D9C), &addr, sizeof(addr), 0);
   printf("Addr : 0x%08X\n\n", addr);

   ReadProcessMemory(CSettings::phandle, (void*)(addr + 0x60), &addr, sizeof(addr), 0);
   printf("Addr : 0x%08X\n\n", addr);

   ReadProcessMemory(CSettings::phandle, (void*)(addr + 0xA4), &addr, sizeof(addr), 0);
   printf("Addr : 0x%08X\n\n", addr);


OUTPUT:

Code:

Addr : 0x100A81C0
Addr : 0x15427890
Addr : 0x00610053
Press any key to continue . . .



af9a187c28f50539872942b0920548ef.png
 Description:
 Filesize:  4.48 KB
 Viewed:  6742 Time(s)

af9a187c28f50539872942b0920548ef.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Aug 04, 2014 4:38 am    Post subject: Reply with quote

0x15427890+0xa4=the address of the string
you don't need to read that as a pointer, but as a string

so instead of
Code:

ReadProcessMemory(CSettings::phandle, (LPCVOID*)(DWORD*)(addr + 0xA4), &addr, sizeof(addr), 0);

do
Code:

addr=addr+0xa4

_________________
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
NullBy7e
Cheater
Reputation: 0

Joined: 23 Jul 2014
Posts: 47

PostPosted: Mon Aug 04, 2014 4:45 am    Post subject: Reply with quote

i will try but I do not understand.
I have to read the value of addr + A4 to get the final address and then I read the 24 bytes from that.
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: Mon Aug 04, 2014 7:04 pm    Post subject: Reply with quote

Addr : 0x00610053

is correct. You just need to read that last part as your string. 53 in hex is S which is what you needed.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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