Exemplo n.º 1
0
int puts(const char* str) {
    void* stdio = 0;
    int (*real_puts)(const char*);
    int result;

    /* Dynamically load the real libc. */
    stdio = dlopen("libc.so.6", RTLD_LAZY);

    if (stdio) {

        /* Locate the real puts function. */
        real_puts = dlsym(stdio, "puts");

        if (dlerror()) {
            printf("Failed to load symbol puts from libc.\n");
            result = -1;
        } else {
            /* Instrument whatever intercession you like here. */
            real_puts("Intercepted: ");
            result = real_puts(str);
        }

        /* Clean up. */
        dlclose(stdio);

    } else {
        fprintf(stderr, "Failed to open underlying libc.\n");
        result = -1;
    }

    return result;
}
Exemplo n.º 2
0
int puts(const char* str)
{
	printf("Arerere");

	real_puts =dlsym(RTLD_NEXT, "puts");
	return real_puts(str);

}