From: Christoph Egger Date: Tue, 10 Mar 2015 16:25:59 +0000 (+0100) Subject: Add SWIG bindings for the guile interpreter X-Git-Tag: v0.1~53 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=fc58083a9eee8534fe3f67ddd3c020c87cd42a5f;p=frida%2Ffrida.git Add SWIG bindings for the guile interpreter --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e5c9ea..3a4b943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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(SWIG REQUIRED) +INCLUDE(${SWIG_USE_FILE}) #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) +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 @@ -62,7 +82,6 @@ ADD_EXECUTABLE(frida src/main.cxx ${frida_SOURCES} ${frida_HEADERS_MOC}) 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}) diff --git a/src/bindings/Guile.cxx b/src/bindings/Guile.cxx index 2552e7d..57d32bd 100644 --- a/src/bindings/Guile.cxx +++ b/src/bindings/Guile.cxx @@ -18,6 +18,10 @@ GuileInterpreter::GuileInterpreter() { (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(); diff --git a/src/bindings/guile/frida.i b/src/bindings/guile/frida.i new file mode 100644 index 0000000..03069b9 --- /dev/null +++ b/src/bindings/guile/frida.i @@ -0,0 +1,34 @@ +%module frida + +%rename("%(utitle)s") ""; + +%include +%include +%include +%include + +%{ +#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; +} + +%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; diff --git a/src/core/InformationManager.cxx b/src/core/InformationManager.cxx index fd0715b..bee2a9e 100644 --- a/src/core/InformationManager.cxx +++ b/src/core/InformationManager.cxx @@ -10,9 +10,13 @@ #include +InformationManager* current_information_manager; + InformationManager::InformationManager() : logger(log4cxx::Logger::getLogger("InformationManager")) -{} +{ + current_information_manager = this; +} InformationManager::~InformationManager() { for (auto b : blocks)