diff options
| author | Petr Mrázek | 2012-02-28 03:37:56 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-02-28 03:37:56 +0100 |
| commit | 731472a4781f091ae313bd39d512207e920db10c (patch) | |
| tree | 25242218ca8f641ef4b36c6d6f46b4ad6cfb1f62 /library/PlugLoad-linux.cpp | |
| parent | f8721c88b57b22842a2d0ecf60f58b31d151b600 (diff) | |
| download | dfhack-731472a4781f091ae313bd39d512207e920db10c.tar.gz dfhack-731472a4781f091ae313bd39d512207e920db10c.tar.bz2 dfhack-731472a4781f091ae313bd39d512207e920db10c.tar.xz | |
Add eggy hooks (linux only for now)
Diffstat (limited to 'library/PlugLoad-linux.cpp')
| -rw-r--r-- | library/PlugLoad-linux.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/library/PlugLoad-linux.cpp b/library/PlugLoad-linux.cpp new file mode 100644 index 00000000..aaf7b2c3 --- /dev/null +++ b/library/PlugLoad-linux.cpp @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <dlfcn.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <sys/shm.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <vector> +#include <string> +#include <map> + +#include "DFHack.h" +#include "Core.h" +#include "Hooks.h" +#include <iostream> + +/* + * Plugin loading functions + */ +namespace DFHack +{ + DFLibrary * OpenPlugin (const char * filename) + { + dlerror(); + DFLibrary * ret = (DFLibrary *) dlopen(filename, RTLD_NOW); + if(!ret) + { + std::cerr << dlerror() << std::endl; + } + return ret; + } + void * LookupPlugin (DFLibrary * plugin ,const char * function) + { + return (DFLibrary *) dlsym((void *)plugin, function); + } + void ClosePlugin (DFLibrary * plugin) + { + dlclose((void *) plugin); + } +}
\ No newline at end of file |
