X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fbindings%2FGuile.cxx;h=d4295c475411d2ae939c1dc0925c5f955938c200;hp=57d32bdd8009d02cd8fe2fad1762cf08bb5cfbbc;hb=25c5224fd78d69d669d4f2722ffd2f512a65834e;hpb=fc58083a9eee8534fe3f67ddd3c020c87cd42a5f diff --git a/src/bindings/Guile.cxx b/src/bindings/Guile.cxx index 57d32bd..d4295c4 100644 --- a/src/bindings/Guile.cxx +++ b/src/bindings/Guile.cxx @@ -1,4 +1,6 @@ #include "Guile.hxx" +#include "Config.hxx" +#include "core/Settings.hxx" namespace { SCM handler (void*, SCM tag, SCM throw_args) { @@ -7,26 +9,27 @@ namespace { } } -GuileInterpreter::GuileInterpreter() { +GuileInterpreter::GuileInterpreter() + : logger(log4cxx::Logger::getLogger("bindings.Guile")) { + + QString socketpath = Settings::get()->getRuntimeDirectory()->canonicalPath() + + "/frida." + QString::number(QCoreApplication::applicationPid(), 16) + ".geiser.sock"; + scm_init_guile(); - scm_internal_catch(SCM_BOOL_T, - (SCM (*)(void *))scm_c_eval_string, - (void*)"(use-modules (system repl server))", - handler, NULL); - scm_internal_catch(SCM_BOOL_T, - (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); + SCM scm_socketpath = scm_from_locale_string(socketpath.toStdString().c_str()); + scm_c_use_module("system repl server"); + SCM socket = scm_call_2(scm_c_public_ref("system repl server", "make-unix-domain-server-socket"), + scm_from_locale_keyword("path"), scm_socketpath); + scm_call_1(scm_c_public_ref("system repl server", "spawn-server"), socket); + scm_c_load_extension("libguile-frida-binding", + "scm_init_frida_module"); guile_output_port = scm_open_output_string(); guile_error_port = scm_open_output_string(); scm_set_current_output_port(guile_output_port); scm_set_current_error_port(guile_error_port); + LOG4CXX_INFO(logger, "Initializing GUILE finished"); } int GuileInterpreter::evaluate(const std::string& command, @@ -54,3 +57,13 @@ int GuileInterpreter::evaluate(const std::string& command, return 0; } + +int GuileInterpreter::loadFile(const std::string& filename, + std::ostream& stdout, + std::ostream& stderr, + std::string& result) { + LOG4CXX_INFO(logger, "Loading file \"" << filename << "\""); + scm_c_primitive_load(filename.c_str()); + LOG4CXX_INFO(logger, "Finished file \"" << filename << "\""); + return 0; +}