]> git.siccegge.de Git - frida/frida.git/commitdiff
Add SWIG bindings for the guile interpreter
authorChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 16:25:59 +0000 (17:25 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Tue, 10 Mar 2015 16:25:59 +0000 (17:25 +0100)
CMakeLists.txt
src/bindings/Guile.cxx
src/bindings/guile/frida.i [new file with mode: 0644]
src/core/InformationManager.cxx

index 5e5c9eac9d42cda6789ef6055c2ada4fa49815a4..3a4b943d6b81843f11f29a88e53a285d939c2aae 100644 (file)
@@ -14,6 +14,8 @@ find_package(LLVM REQUIRED)
 find_package(PkgConfig)
 pkg_check_modules(LOG4CXX REQUIRED liblog4cxx)
 pkg_check_modules(GUILE REQUIRED guile-2.0)
 find_package(PkgConfig)
 pkg_check_modules(LOG4CXX REQUIRED liblog4cxx)
 pkg_check_modules(GUILE REQUIRED guile-2.0)
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
 
 #add_compile_options(${LOG4CXX_CFLAGS})
 add_definitions(${LOG4CXX_CFLAGS})
 
 #add_compile_options(${LOG4CXX_CFLAGS})
 add_definitions(${LOG4CXX_CFLAGS})
@@ -26,6 +28,24 @@ add_definitions(-DQT_NO_KEYWORDS)
 separate_arguments(LLVM_LDFLAGS)
 separate_arguments(LLVM_LIBS)
 
 separate_arguments(LLVM_LDFLAGS)
 separate_arguments(LLVM_LIBS)
 
+INCLUDE_DIRECTORIES("src")
+
+#####################
+# Language Bindings #
+#####################
+
+SET(CMAKE_SWIG_FLAGS -Linkage passive)
+#FIND_PACKAGE(PythonLibs)
+#INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+SET_SOURCE_FILES_PROPERTIES(src/bindings/guile/frida.i PROPERTIES CPLUSPLUS ON)
+SWIG_ADD_MODULE(frida-guile guile src/bindings/guile/frida.i)
+SWIG_LINK_LIBRARIES(frida-guile)
+
+
+#################
+# Main Programm #
+#################
+
 SET(frida_SOURCES
   src/bindings/Guile.cxx
   src/core/InformationManager.cxx
 SET(frida_SOURCES
   src/bindings/Guile.cxx
   src/core/InformationManager.cxx
@@ -62,7 +82,6 @@ ADD_EXECUTABLE(frida src/main.cxx ${frida_SOURCES} ${frida_HEADERS_MOC})
 ADD_DEFINITIONS(${QT_DEFINITIONS})
 
 qt5_use_modules(frida Widgets)
 ADD_DEFINITIONS(${QT_DEFINITIONS})
 
 qt5_use_modules(frida Widgets)
-INCLUDE_DIRECTORIES("src")
 
 TARGET_LINK_LIBRARIES(frida ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
 
 
 TARGET_LINK_LIBRARIES(frida ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
 
index 2552e7d215ab8b97e85edfc77a372a7fe13f6e2e..57d32bdd8009d02cd8fe2fad1762cf08bb5cfbbc 100644 (file)
@@ -18,6 +18,10 @@ GuileInterpreter::GuileInterpreter() {
                           (SCM (*)(void *))scm_c_eval_string,
                           (void*)"(spawn-server)",
                           handler, NULL);
                           (SCM (*)(void *))scm_c_eval_string,
                           (void*)"(spawn-server)",
                           handler, NULL);
+       scm_internal_catch(SCM_BOOL_T,
+                          (SCM (*)(void *))scm_c_eval_string,
+                          (void*)"(load-extension \"libfrida-guile\" \"scm_init_frida_module\")",
+                          handler, NULL);
 
        guile_output_port = scm_open_output_string();
        guile_error_port = scm_open_output_string();
 
        guile_output_port = scm_open_output_string();
        guile_error_port = scm_open_output_string();
diff --git a/src/bindings/guile/frida.i b/src/bindings/guile/frida.i
new file mode 100644 (file)
index 0000000..03069b9
--- /dev/null
@@ -0,0 +1,34 @@
+%module frida
+
+%rename("%(utitle)s") "";
+
+%include <cpointer.i>
+%include <stdint.i>
+%include <std_string.i>
+%include <std_map.i>
+
+%{
+#include "core/Function.hxx"
+#include "core/BasicBlock.hxx"
+#include "core/InformationManager.hxx"
+#include "disassembler/Disassembler.hxx"
+
+       extern InformationManager* current_information_manager;
+%}
+
+namespace std {
+       %template(map_uint64t_BasicBlock) map<unsigned long long, BasicBlock*>;
+}
+
+%inline %{
+       BasicBlock* deref(BasicBlock** x) {
+       return *x;
+    }
+%}
+
+%include "core/Function.hxx"
+%include "core/BasicBlock.hxx"
+%include "core/InformationManager.hxx"
+%include "disassembler/Disassembler.hxx"
+
+extern InformationManager* current_information_manager;
index fd0715b851adfe927601fe50aa0bc5ef9e552485..bee2a9eef9c9cbdd6e9ec66be681160f27fda9b5 100644 (file)
 
 #include <QTemporaryFile>
 
 
 #include <QTemporaryFile>
 
+InformationManager* current_information_manager;
+
 InformationManager::InformationManager()
        : logger(log4cxx::Logger::getLogger("InformationManager"))
 InformationManager::InformationManager()
        : logger(log4cxx::Logger::getLogger("InformationManager"))
-{}
+{
+       current_information_manager = this;
+}
 
 InformationManager::~InformationManager() {
        for (auto b : blocks)
 
 InformationManager::~InformationManager() {
        for (auto b : blocks)