CLEO Help Question about pointers and offsets

CLEO related
Status
Not open for further replies.

Kelsi235

Active member
Joined
Jun 2, 2019
Messages
53
Reaction score
4
so I have a pointer and an offset, how do I get an actual address ?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
It depends where is the thing that you want. If the pointer leads to the first character of a string, then offset of n-size, will lead to the nth-character of that string.
For example:
C++:
#include <iostream>
using namespace std;

int main() {

    const char* str = "abc";

    int offset = 1;

    cout << "Original str = " << str[0] << endl;
    cout << "str + offset = " << (str + offset)[0] << endl;

}

Output:
Original str = a
str + offset = b



But inside game memory there is a lot of nested structures so often you do something like:
read( read( read( pointer + offset ) + offset_2 ) + offset_3 )
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
@monday
Maybe you know why i get crash ?
PHP:
{$CLEO .cs}

0000:

wait 10000

while true
wait 0

if
0AB1: @isDialogOpen 0
then
    0AB1: @GetDialogCaption 0 0@
    0AD1: "%s" 2000 0@
end

end


:isDialogOpen
{
    0.3.DL
}
0AA2: 1@ = "samp.dll"
1@ += 0x2AC9E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
0A8E: 2@ = 1@ + 0x28 //DialogOpenOffset
0A8D: 2@ = readMem 2@ sz 4 vp 0
if 2@ == 1 // Dialog open
then
    0485: dialog_open
else
    059A:  dialog closed
end
0AB2: ret 0

:GetDialogCaption
{
    0.3.DL
}
0AA2: 1@ = "samp.dll"
1@ += 0x2AC9E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x40
0A8D: 1@ = readMem 1@ sz 4 vp 0
0AB2: ret 1 1@

With cheat engine looks good
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
idk about isDialogOpen, but it looks like in GetDialogCaption you have 1 readMem that is not needed.
0x4026500 is a pointer to the string, so don't read it, return it

Code:
:GetDialogCaption
{
    0.3.DL
}
0AA2: 1@ = "samp.dll"
1@ += 0x2AC9E0
0A8D: 1@ = readMem 1@ sz 4 vp 0
1@ += 0x40
0AB2: ret 1 1@
 
Status
Not open for further replies.
Top