I want to code a function called "CSys::Printf" using LD_Preload, but I think it would not be so easy, as in C you can't have "::" in function name, that would be needed to match the original function name.
A piece of the code used to hook would be like this:
int CSys::Printf(const char *format, ...) {
void *handle;
char *error;
if (conprint == NULL) {
handle = dlopen("dedicated.so", RTLD_LAZY);
if (!handle) {
fputs(dlerror(), stderr);
exit(1);
}
conprint = (int (*)(const char *format, ...))dlsym(handle, "CSys::Printf");
if ((error = dlerror()) != NULL) {
fprintf(stderr, "%s\n", error);
exit(1);
}
printf("*HOOK CSys::Printf OK*");
}
Well, this should work at hooking any function except this case, where the compiler won't accept the "::" on function name.
What should I do?
Thanks!