/* vim:set ts=4 sw=4: * * (C) 2008 Willem Hengeveld itsme@xs4all.nl * * IdcPerl - a perl scripting plugin for the Interactive Disassembler by hex-rays. * see http://www.xs4all.nl/~itsme/projects/idcperl * */ #include #include #include #include #undef do_open #undef do_close /* * this file defines a perl 'iolayer' named 'idamsg', * which outputs everything in the ida message log. * and adds this layer to the stdout, and stderr chain. */ #ifdef DYNAMIC_PERL #include "redefperlasdll.h" #include "perldllprocs.h" #endif #include "iolayer.h" // ida includes #include // for uchar #include // for msg() #ifdef TRACE_PERLIO #define tracemsg msg #else #define tracemsg while(0) #endif static bool g_stderrenabled= true; bool enablestderr(bool bNewState) { tracemsg("enablestderr\n"); bool bOldState= g_stderrenabled; g_stderrenabled= bNewState; return bOldState; } SSize_t PerlIOidamsg_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) { tracemsg("PerlIOidamsg_write\n"); if (!g_stderrenabled) return count; SSize_t total= 0; Size_t ofs= 0; while (ofs