Skip to content

Commit

Permalink
v1.0.2: IDA 7.4 support and bug fixes
Browse files Browse the repository at this point in the history
- climacros was crashing when idat[64].exe was executed
- updated built-in macros to work with IDA 7.4
  • Loading branch information
0xeb committed Dec 27, 2019
1 parent 7e42346 commit 6053d7d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
49 changes: 30 additions & 19 deletions climacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ All expressions should resolve to a string.
#include <algorithm>
#include <regex>
#include <functional>

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4267 4244)
#endif
#include <ida.hpp>
#include <loader.hpp>
#include <kernwin.hpp>
#include <expr.hpp>
#include <registry.hpp>
#include <diskio.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include "utils_impl.cpp"

Expand Down Expand Up @@ -52,24 +60,24 @@ typedef qvector<macro_def_t> 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"}
};

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -111,7 +119,7 @@ template <size_t... indices> struct execute_line_with_ctx_gen_t<std::index_seque
static constexpr bool (idaapi *callbacks[])(const char *) = { execute_line<indices>... };
};

auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t<std::make_index_sequence<MAX_CTX>>::callbacks;
static auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t<std::make_index_sequence<MAX_CTX>>::callbacks;

// Ignore UI hooks when set
bool g_b_ignore_ui_notification = false;
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 30 additions & 0 deletions prep-cmake.bat
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 6053d7d

Please sign in to comment.