diff --git a/CMakeLists.txt b/CMakeLists.txt index 51bfd16..24201b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(climacros) + # Included file list(APPEND DISABLED_SOURCES utils_impl.cpp) set(PLUGIN_NAME climacros) set(PLUGIN_SOURCES climacros.cpp ${DISABLED_SOURCES}) +set(PLUGIN_RUN_ARGS "-t") # Debug messages for the debugger include($ENV{IDASDK}/ida-cmake/plugins.cmake) diff --git a/climacros.cpp b/climacros.cpp index a398fa9..e2da57f 100644 --- a/climacros.cpp +++ b/climacros.cpp @@ -15,12 +15,20 @@ All expressions should resolve to a string. #include #include #include + +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable: 4267 4244) +#endif #include #include #include #include #include #include +#ifdef _MSC_VER + #pragma warning(pop) +#endif #include "utils_impl.cpp" @@ -52,24 +60,24 @@ typedef qvector macros_t; // Default macros static macro_def_t DEFAULT_MACROS[] = { - {"$!", "${'0x%x' % idc.here()}$", "Current cursor location (0x...)"}, - {"$!!", "${'%x' % idc.here()}$", "Current cursor location"}, - {"$>", "${'0x%x' % idc.SegEnd(idc.here())}$", "Current segment end (0x...)"}, - {"$>>", "${'%x' % idc.SegEnd(idc.here())}$", "Current segment end"}, - {"$<", "${'0x%x' % idc.SegStart(idc.here())}$", "Current segment start (0x...)"}, - {"$<<", "${'%x' % idc.SegStart(idc.here())}$", "Current segment start"}, - {"$[", "${'0x%x' % idc.SelStart()}$", "Selection start (0x...)"}, - {"$[[", "${'%x' % idc.SelStart()}$", "Selection start"}, - {"$@b", "${'0x%x' % idc.Byte(idc.here())}$", "Byte value at current cursor location (0x...)" }, - {"$@B", "${'%x' % idc.Byte(idc.here())}$", "Byte value at current cursor location"}, - {"$@d", "${'0x%x' % idc.Dword(idc.here())}$", "Dword value at current cursor location (0x...)"}, - {"$@D", "${'%x' % idc.Dword(idc.here())}$", "Dword value at current cursor location"}, - {"$@q", "${'0x%x' % idc.Qword(idc.here())}$", "Qword value at current cursor location (0x...)"}, - {"$@Q", "${'%x' % idc.Qword(idc.here())}$", "Qword value at current cursor location"}, - {"$]]", "${'%x' % idc.SelEnd()}$", "Selection end"}, - {"$]", "${'0x%x' % idc.SelEnd()}$", "Selection end (0x...)"}, - {"$#", "${'0x%x' % (idc.SelEnd() - idc.SelStart())}$", "Selection size (0x...)"}, - {"$##", "${'%x' % (idc.SelEnd() - idc.SelStart())}$", "Selection size"} + {"$!", "${'0x%x' % idc.here()}$", "Current cursor location (0x...)"}, + {"$!!", "${'%x' % idc.here()}$", "Current cursor location"}, + {"$<", "${'0x%x' % idc.get_segm_start(idc.here())}$", "Current segment start (0x...)"}, + {"$>", "${'0x%x' % idc.get_segm_end(idc.here())}$", "Current segment end (0x...)"}, + {"$<<", "${'%x' % idc.get_segm_start(idc.here())}$", "Current segment start"}, + {"$>>", "${'%x' % idc.get_segm_end(idc.here())}$", "Current segment end"}, + {"$@b", "${'0x%x' % idc.get_wide_byte(idc.here())}$", "Byte value at current cursor location (0x...)" }, + {"$@B", "${'%x' % idc.get_wide_byte(idc.here())}$", "Byte value at current cursor location"}, + {"$@d", "${'0x%x' % idc.get_wide_dword(idc.here())}$", "Dword value at current cursor location (0x...)"}, + {"$@D", "${'%x' % idc.get_wide_dword(idc.here())}$", "Dword value at current cursor location"}, + {"$@q", "${'0x%x' % idc.get_qword(idc.here())}$", "Qword value at current cursor location (0x...)"}, + {"$@Q", "${'%x' % idc.get_qword(idc.here())}$", "Qword value at current cursor location"}, + {"$[", "${'0x%x' % idc.read_selection_start()}$", "Selection start (0x...)"}, + {"$]", "${'0x%x' % idc.read_selection_end()}$", "Selection end (0x...)"}, + {"$[[", "${'%x' % idc.read_selection_start()}$", "Selection start"}, + {"$]]", "${'%x' % idc.read_selection_end()}$", "Selection end"}, + {"$#", "${'0x%x' % (idc.read_selection_end() - idc.read_selection_start())}$", "Selection size (0x...)"}, + {"$##", "${'%x' % (idc.read_selection_end() - idc.read_selection_start())}$", "Selection size"} }; //------------------------------------------------------------------------- @@ -111,7 +119,7 @@ template struct execute_line_with_ctx_gen_t... }; }; -auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t>::callbacks; +static auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t>::callbacks; // Ignore UI hooks when set bool g_b_ignore_ui_notification = false; @@ -390,6 +398,9 @@ macro_editor_t g_macro_editor; //-------------------------------------------------------------------------- int idaapi init(void) { + if (!is_idaq()) + return PLUGIN_SKIP; + msg("IDA Command Line Interface macros initialized\n"); hook_to_notification_point(HT_UI, ui_callback); diff --git a/prep-cmake.bat b/prep-cmake.bat new file mode 100644 index 0000000..13f54d0 --- /dev/null +++ b/prep-cmake.bat @@ -0,0 +1,30 @@ +@echo off + +:: checkout the Batchography book + +setlocal + +if not defined IDASDK ( + echo IDASDK environment variable not set. + echo Also make sure ida-cmake is installed in IDASDK. + echo See: https://github.com/0xeb/ida-cmake + goto :eof +) + +if not exist build ( + mkdir build + pushd build + cmake -A x64 -G "Visual Studio 15" .. + popd +) + +if not exist build64 ( + mkdir build64 + pushd build64 + cmake -A x64 -DEA64=YES -G "Visual Studio 15" .. + popd +) + +echo. +echo All done! +echo. \ No newline at end of file