summaryrefslogtreecommitdiff
path: root/library/PlugLoad-linux.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2012-02-28 03:37:56 +0100
committerPetr Mrázek2012-02-28 03:37:56 +0100
commit731472a4781f091ae313bd39d512207e920db10c (patch)
tree25242218ca8f641ef4b36c6d6f46b4ad6cfb1f62 /library/PlugLoad-linux.cpp
parentf8721c88b57b22842a2d0ecf60f58b31d151b600 (diff)
downloaddfhack-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.cpp44
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