All pastes #11192 Raw Edit

Anonymous

public text v1 · immutable
#11192 ·published 2005-05-07 23:34 UTC
rendered paste body
npc.so
#include <stdio.h>
int constructor() __attribute__((constructor));
int destructor() __attribute__((destructor));
void some_function();
int constructor()
{
    printf("%s\n","Sup library");
}

int destructor()
{
    printf("%s\n","bye library");
}

void some_function()
{
    printf("%s\n","yo");
}
  GNU nano 1.3.6                 File: main.cpp                                         

#include <dlfcn.h>
#include <stdio.h>

main.c
int main()
{
    void *lib_handle = dlopen("./npc.so",RTLD_LAZY);
    void (*funcd)()=NULL;
    if (lib_handle==NULL)
    {
        printf("%s\n","well shit");
    }
    funcd=(void (*)())dlsym(lib_handle,"some_function");
    if (funcd!=NULL) funcd();
    dlclose(lib_handle);
    return 0;
}