How to call a function from a pointer

kraneq

Member
Joined
Jun 25, 2019
Messages
6
Reaction score
1
If samp.dll + 0x001 is the function for SAY

How can i call it and/or see what params it take?
C++/C#
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
Do you even read: C++/C#
dude you just have to translate it to c++, i don't know how to do that because i never used c++ but it shouldn't be too hard, honestly if you can't read cleo and you say you know c++ then you should quit programming. As far as i know Cleo is similar to c++ in many aspects.
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
as you can see in the topic the offset is not 0x001 like you said it's something else, you can see there are more offsets there depending on the samp version you are running, after you get the address for samp dll you just add the offset and do this
0AA5: call $hPROC num_params 1 pop 0 $param

it takes only one parameter which is a string,$hPROC is the address of the say function, pop 0 i don't know what it actually means.
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
i know Cleo is similar to c++ in many aspects.

The fuck are you talking about, that has to be the most retarded thing I've heard all year. Congratulations on that. CLEO and C++ are completely different languages... CLEO is a SCRIPTING language, C++ is a general purpose programming language. They aren't even nearly compiled the same, not to mention the drastically different syntax they use? Can you perform some of the same functions in CLEO that you can in C++? Sure. But the performance will suffer greatly. Every opcode performed in CLEO ends up being performed by the game's engine in result (see CRunningScript:: ProcessCommands functions)

-Mike
 
Last edited:

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
If samp.dll + 0x001 is the function for SAY

How can i call it and/or see what params it take?
C++/C#

You have a couple of options. Seeing as that you're asking very trivial questions, you should probably take a step back on learn some basics about Assembly and C++. Once you've done that, you can open the file in IDA or your favorite debugger and reverse how the function is called.

Once you have the function's calling convention reversed, you can use c++ to call the function like this
Code:
reinterpret_cast< void( CALLINGCONVENTION* )( ...params here ) >( samp_dll + 0x1 )( ... )

If I remember correctly though, Say is a THISCALL, so you will need to supply the class pointer as the first argument, followed by the rest of the necessary parameters.

See https://en.wikipedia.org/wiki/X86_calling_conventions

-Mike
 

kraneq

Member
Joined
Jun 25, 2019
Messages
6
Reaction score
1
Yea i know how to do that in c++, i was expecting c++ and c# example:
in c++ void (say*)(const char*) = (void(*(const char*))(samp.dll + offset)
but i need an example in c#: as the title says: "how-to-call-a-function-from-a-pointer" in c# more than anything, you gave me a c++ example which i know how to do in
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
Yea i know how to do that in c++, i was expecting c++ and c# example:
in c++ void (say*)(const char*) = (void(*(const char*))(samp.dll + offset)
but i need an example in c#: as the title says: "how-to-call-a-function-from-a-pointer" in c# more than anything, you gave me a c++ example which i know how to do in

Maybe you should learn how to form a question, or properly form a sentence actually.
Yea i know how to do that in c++, i was expecting c++ and c# example:

You ask for c++/c# examples and then say you know how to do it in c++?

I'm going to help you anyway.

In C#, assuming you're completely external, you will need to either create or hijack a thread and call the function from within there. You will need to inject shellcode to do this.
There are no security measures in SA:MP to prevent thread creation

Use CreateRemoteThread: https://docs.microsoft.com/en-us/wi...dsapi/nf-processthreadsapi-createremotethread
Code:
lpParameter
can probably be the address of an allocated string with your message.

-Mike
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
The fuck are you talking about, that has to be the most retarded thing I've heard all year. Congratulations on that. CLEO and C++ are completely different languages... CLEO is a SCRIPTING language, C++ is a general purpose programming language. They aren't even nearly compiled the same, not to mention the drastically different syntax they use? Can you perform some of the same functions in CLEO that you can in C++? Sure. But the performance will suffer greatly. Every opcode performed in CLEO ends up being performed by the game's engine in result (see CRunningScript:: ProcessCommands functions)

-Mike
yeah memory management for strings and the way you format strings in cleo is nothing like c++
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
The fuck are you talking about, that has to be the most retarded thing I've heard all year. Congratulations on that. CLEO and C++ are completely different languages... CLEO is a SCRIPTING language, C++ is a general purpose programming language. They aren't even nearly compiled the same, not to mention the drastically different syntax they use? Can you perform some of the same functions in CLEO that you can in C++? Sure. But the performance will suffer greatly. Every opcode performed in CLEO ends up being performed by the game's engine in result (see CRunningScript:: ProcessCommands functions)

-Mike
Also don't call the things i say retarded when you are calling cleo a scripting language, scripts don't have to be compiled but cleo does. Scripting language implies you don't have to compile your code, so please watch your tone cause i really don't appreciate it especially from someone who just talks about facts like they know something about it when they actually know jack shit.
 

belle_delphine.py

Active member
Joined
Jul 28, 2019
Messages
46
Reaction score
11
Location
Sibiu
Also don't call the things i say retarded when you are calling cleo a scripting language, scripts don't have to be compiled but cleo does. Scripting language implies you don't have to compile your code, so please watch your tone cause i really don't appreciate it especially from someone who just talks about facts like they know something about it when they actually know jack shit.
i think sb/cleo is made in c++ so you are actually right i guess, but im a script kiddie so i dont rlly care :)
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
yeah memory management for strings and the way you format strings in cleo is nothing like c++

You're right. There not, dumbass.

Also don't call the things i say retarded when you are calling cleo a scripting language, scripts don't have to be compiled but cleo does. Scripting language implies you don't have to compile your code, so please watch your tone cause i really don't appreciate it especially from someone who just talks about facts like they know something about it when they actually know jack shit.

Yet again you manage to make yourself look like a retard. Congratulations.
Yeah, CLEO is definitely not a scripting language, and oh I forgot, being 'compiled' completely makes it not a scripting language either.
xHHOukX.png


Oh I guess Lua isn't a scripting language anymore either. Silly Lua.org lying straight to my face.
qV15PYU.png


Oh and AngelScript where Script is literally a word in the language's name, isn't a scripting language either, right?

Being compiled doesn't make it NOT a scripting language you fucking doofus. You can't use CLEO to build a fucking banking system, its strictly used for GTA games (that support it). I feel like I'm losing brain cells just replying to you.
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
A script or scripting language is a computer language with a series of commands within a file that is capable of being executed without being compiled. Good examples of server-side scripting languages include Perl, PHP, and Python. The best example of a client side scripting language is JavaScript.

A scripting language is not compiled. An that's a fact, no matter what other arguments you have against it, that's the definition majority of the people goes with. And i would tend to disagree, it is in fact possible to make almost anything in cleo, actually cleo is turing complete, of course it doesn't have all the perks of modern programming languages but it does satisfy the requirements to be turing complete and that means you can write absolutely anything in it.
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
There is no point in arguing with someone like you. Do your research and come back when you have any sort of common sense. Maybe google what a scripting language is? There are compiled scripting languages, and interpreted scripting languages. How they're executed does not determine whether it is a scripting language or not. Now fuck off.
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
There is no point in arguing with someone like you. Do your research and come back when you have any sort of common sense. Maybe google what a scripting language is? There are compiled scripting languages, and interpreted scripting languages. How they're executed does not determine whether it is a scripting language or not. Now fuck off.
no, you noob, there is no such thing as a compiled scripting language.
 

kraneq

Member
Joined
Jun 25, 2019
Messages
6
Reaction score
1
Maybe you should learn how to form a question, or properly form a sentence actually.


You ask for c++/c# examples and then say you know how to do it in c++?



-Mike
yes i ask for a c# exmaple, you can't read or what's your problem?
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
whats the point of research when all he does is copy paste literal definitions from google.

yeah and you got the genius up above wanting to be literally spoon fed code, after I told him what to do this forum really hit rock bottom. You can’t help these clowns
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
used to think exact same long ago copy pasting help and went lazy not trying to understand code but it really makes sense and gets easy once you learn.. it's just matter of advancing
 
Top