Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Question regarding pointers [Archive] - Forums

PDA

View Full Version : Question regarding pointers



Nabb
10-17-2013, 03:02 PM
Hello.

So I thought I had retrieved the account and password successfully, after I was told it will be stored as a pointer if it exceeds x letters. I tried this out and it showed to be true.

Base + 0x553A68 is the address for password. This is true when password is less than 16 characters (I have in mind), although when it isn't I would need a pointer to "Base + 0x553A68". The problem is that I don't know how to use the pointers in C#... I'd greatly appreciate any help received!

Blood
10-17-2013, 04:03 PM
Your problem is with memory reading or pointer reading ?
Because to read a pointer just do it:


String strValue = ReadString( ReadInt( POINTER ) + OFFSET_IF_EXIST);

Nabb
10-17-2013, 04:15 PM
It worked, thanks.


As stated, this pointer is null if the acc length is actually not over 16. So this was my solution:


string pass = ReadString(Tibia.Handle, ReadInt32(Tibia.Handle, base_address + password));
if (pass.Length == 0)
{
pass = ReadString(Tibia.Handle, base_address + password);
}


Does it make sense that you'd need such an approach or am I missing something? Should you really need to check both a pointer and normal address?

ottizy
10-17-2013, 04:53 PM
It's stored as a std::string. If the length of the string exceeds 16 characters it will be stored in a different location in the memory, giving you a pointer instead.

The way to determine if it has been stored in a different location is to read the length value of the string which is located +0x14 bytes from the main pointer.



string pass = "";

if (ReadInt32(Tibia.Handle, base_address + password + 0x14) <= 15)
{
pass = ReadString(Tibia.Handle, base_address + password);
}
else
{
pass = ReadString(ReadInt32(Tibia.Handle, base_address + password));
}

XtrmJash
10-17-2013, 05:15 PM
I've gotta ask, of all the values you could've read, why did you choose password and account name first?

Nabb
10-17-2013, 05:27 PM
I am working on something requiring it. Also it was the easiest of those values that I need. I also need character name and the character list. I have retrieved character name only through client title, so I guess I'm fine. But list still no success :(


@ottizy Yeah that worked, are you sure this is a safe replacement of my code though?

ottizy
10-17-2013, 05:48 PM
I am working on something requiring it. Also it was the easiest of those values that I need. I also need character name and the character list. I have retrieved character name only through client title, so I guess I'm fine. But list still no success :(


@ottizy Yeah that worked, are you sure this is a safe replacement of my code though?

Quite sure yes

Nabb
10-17-2013, 06:07 PM
Alright, thanks. I'll rely on it :) I don't need this approach on account name though right? I mean account can't exceed 16 chars?

ottizy
10-17-2013, 06:19 PM
Yes you will need this approach. I tested just to make sure and made a account with a 31 character account name :p

Nabb
10-17-2013, 06:22 PM
Alright thanks a bunch for your effort! :D



if (ReadInt32(Tibia.Handle, base_address + password + 0x14) <= 15)


What replacement should it be for account? 0x? <= ?

Farsa
10-18-2013, 11:44 AM
same thing

Nabb
10-18-2013, 11:59 AM
Should this approach of checking for pointers:


if (ReadInt32(Handle, Address + 0x14) <= 15)


Be used at all times? Can I do it when looping through Character List, to know if it's a pointer value?

Farsa
10-18-2013, 12:14 PM
yes, each string in the character list is a std::string that uses the so called "short string optimization" http://stackoverflow.com/questions/1466073/how-is-stdstring-implemented

ottizy
10-18-2013, 03:21 PM
Some of the strings that can be found are declared as const char* I believe ( = You don't have to use the std::string approach). Like names in battlelist.