Hello how should i use the this pointer if it is a function param as void *this
-
Well the reversed class looks something like it:
struct random_class {
char \*something; void \_\_thiscall classfunction (void \*this);
};
So i wanna hook it like this
void (__thiscall* classfunction)(void *this );
void __thiscall myclassfunction(void *this )
{
return classfunction(this->something);
}But i get 8 errors it says syntax error : missing ';' before 'this' Did i use it correctly or wrongly i didnt find on google any function that uses param as void*this???
-
Well the reversed class looks something like it:
struct random_class {
char \*something; void \_\_thiscall classfunction (void \*this);
};
So i wanna hook it like this
void (__thiscall* classfunction)(void *this );
void __thiscall myclassfunction(void *this )
{
return classfunction(this->something);
}But i get 8 errors it says syntax error : missing ';' before 'this' Did i use it correctly or wrongly i didnt find on google any function that uses param as void*this???
Try calling your parameter sonething other than "this". this has a special meaning (meaning: a pointer to this object) in C++.
-
Try calling your parameter sonething other than "this". this has a special meaning (meaning: a pointer to this object) in C++.
hi I don't understand Completely what you say,but the word "this" is the key word of C/C++. so it isn't declare as a variable. as follow,there is a example.I hope it is help for you. #include "stdafx.h" typedef void classfunction (void *w); struct random_class { char *something; classfunction *myfunction; }; classfunction * myclassfunction(void *w ) { return ((struct random_class *)w)->myfunction; } void printfAint(void *w) { printf("%d\n",*(int*)w); } int main(int argc, char* argv[]) { int i=10,j=20; random_class r; r.myfunction=printfAint; r.myfunction(&i); r.myfunction(&j); return 0; }
-
Well the reversed class looks something like it:
struct random_class {
char \*something; void \_\_thiscall classfunction (void \*this);
};
So i wanna hook it like this
void (__thiscall* classfunction)(void *this );
void __thiscall myclassfunction(void *this )
{
return classfunction(this->something);
}But i get 8 errors it says syntax error : missing ';' before 'this' Did i use it correctly or wrongly i didnt find on google any function that uses param as void*this???
The calling convention __thiscall[^] is for member functions. You can't apply it to regular global functions as you're attempting. Also, for member functions
__thiscall
is assumed and in general including it adds little but clutter.Steve
-
The calling convention __thiscall[^] is for member functions. You can't apply it to regular global functions as you're attempting. Also, for member functions
__thiscall
is assumed and in general including it adds little but clutter.Steve
-
hi I don't understand Completely what you say,but the word "this" is the key word of C/C++. so it isn't declare as a variable. as follow,there is a example.I hope it is help for you. #include "stdafx.h" typedef void classfunction (void *w); struct random_class { char *something; classfunction *myfunction; }; classfunction * myclassfunction(void *w ) { return ((struct random_class *)w)->myfunction; } void printfAint(void *w) { printf("%d\n",*(int*)w); } int main(int argc, char* argv[]) { int i=10,j=20; random_class r; r.myfunction=printfAint; r.myfunction(&i); r.myfunction(&j); return 0; }
zhq00001 wrote:
the word "this" is the key word of C/C++. so it isn't declare as a variable
In your first example it is, its declared as a parameter which is a variable:
void (__thiscall* classfunction)(void *this );
void __thiscall myclassfunction(void *this )
{
return classfunction(this->something);
}I'm saying try changing it to:
void (__thiscall* classfunction)(void *pParam );
void __thiscall myclassfunction(void *pParam )
{
return classfunction(pParam->something);
}