Skip to content

Commit 6053d7d

Browse files
committed
v1.0.2: IDA 7.4 support and bug fixes
- climacros was crashing when idat[64].exe was executed - updated built-in macros to work with IDA 7.4
1 parent 7e42346 commit 6053d7d

3 files changed

Lines changed: 63 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
22

3+
project(climacros)
4+
35
# Included file
46
list(APPEND DISABLED_SOURCES utils_impl.cpp)
57

68
set(PLUGIN_NAME climacros)
79
set(PLUGIN_SOURCES climacros.cpp ${DISABLED_SOURCES})
10+
set(PLUGIN_RUN_ARGS "-t") # Debug messages for the debugger
811

912
include($ENV{IDASDK}/ida-cmake/plugins.cmake)
1013

climacros.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ All expressions should resolve to a string.
1515
#include <algorithm>
1616
#include <regex>
1717
#include <functional>
18+
19+
#ifdef _MSC_VER
20+
#pragma warning(push)
21+
#pragma warning(disable: 4267 4244)
22+
#endif
1823
#include <ida.hpp>
1924
#include <loader.hpp>
2025
#include <kernwin.hpp>
2126
#include <expr.hpp>
2227
#include <registry.hpp>
2328
#include <diskio.hpp>
29+
#ifdef _MSC_VER
30+
#pragma warning(pop)
31+
#endif
2432

2533
#include "utils_impl.cpp"
2634

@@ -52,24 +60,24 @@ typedef qvector<macro_def_t> macros_t;
5260
// Default macros
5361
static macro_def_t DEFAULT_MACROS[] =
5462
{
55-
{"$!", "${'0x%x' % idc.here()}$", "Current cursor location (0x...)"},
56-
{"$!!", "${'%x' % idc.here()}$", "Current cursor location"},
57-
{"$>", "${'0x%x' % idc.SegEnd(idc.here())}$", "Current segment end (0x...)"},
58-
{"$>>", "${'%x' % idc.SegEnd(idc.here())}$", "Current segment end"},
59-
{"$<", "${'0x%x' % idc.SegStart(idc.here())}$", "Current segment start (0x...)"},
60-
{"$<<", "${'%x' % idc.SegStart(idc.here())}$", "Current segment start"},
61-
{"$[", "${'0x%x' % idc.SelStart()}$", "Selection start (0x...)"},
62-
{"$[[", "${'%x' % idc.SelStart()}$", "Selection start"},
63-
{"$@b", "${'0x%x' % idc.Byte(idc.here())}$", "Byte value at current cursor location (0x...)" },
64-
{"$@B", "${'%x' % idc.Byte(idc.here())}$", "Byte value at current cursor location"},
65-
{"$@d", "${'0x%x' % idc.Dword(idc.here())}$", "Dword value at current cursor location (0x...)"},
66-
{"$@D", "${'%x' % idc.Dword(idc.here())}$", "Dword value at current cursor location"},
67-
{"$@q", "${'0x%x' % idc.Qword(idc.here())}$", "Qword value at current cursor location (0x...)"},
68-
{"$@Q", "${'%x' % idc.Qword(idc.here())}$", "Qword value at current cursor location"},
69-
{"$]]", "${'%x' % idc.SelEnd()}$", "Selection end"},
70-
{"$]", "${'0x%x' % idc.SelEnd()}$", "Selection end (0x...)"},
71-
{"$#", "${'0x%x' % (idc.SelEnd() - idc.SelStart())}$", "Selection size (0x...)"},
72-
{"$##", "${'%x' % (idc.SelEnd() - idc.SelStart())}$", "Selection size"}
63+
{"$!", "${'0x%x' % idc.here()}$", "Current cursor location (0x...)"},
64+
{"$!!", "${'%x' % idc.here()}$", "Current cursor location"},
65+
{"$<", "${'0x%x' % idc.get_segm_start(idc.here())}$", "Current segment start (0x...)"},
66+
{"$>", "${'0x%x' % idc.get_segm_end(idc.here())}$", "Current segment end (0x...)"},
67+
{"$<<", "${'%x' % idc.get_segm_start(idc.here())}$", "Current segment start"},
68+
{"$>>", "${'%x' % idc.get_segm_end(idc.here())}$", "Current segment end"},
69+
{"$@b", "${'0x%x' % idc.get_wide_byte(idc.here())}$", "Byte value at current cursor location (0x...)" },
70+
{"$@B", "${'%x' % idc.get_wide_byte(idc.here())}$", "Byte value at current cursor location"},
71+
{"$@d", "${'0x%x' % idc.get_wide_dword(idc.here())}$", "Dword value at current cursor location (0x...)"},
72+
{"$@D", "${'%x' % idc.get_wide_dword(idc.here())}$", "Dword value at current cursor location"},
73+
{"$@q", "${'0x%x' % idc.get_qword(idc.here())}$", "Qword value at current cursor location (0x...)"},
74+
{"$@Q", "${'%x' % idc.get_qword(idc.here())}$", "Qword value at current cursor location"},
75+
{"$[", "${'0x%x' % idc.read_selection_start()}$", "Selection start (0x...)"},
76+
{"$]", "${'0x%x' % idc.read_selection_end()}$", "Selection end (0x...)"},
77+
{"$[[", "${'%x' % idc.read_selection_start()}$", "Selection start"},
78+
{"$]]", "${'%x' % idc.read_selection_end()}$", "Selection end"},
79+
{"$#", "${'0x%x' % (idc.read_selection_end() - idc.read_selection_start())}$", "Selection size (0x...)"},
80+
{"$##", "${'%x' % (idc.read_selection_end() - idc.read_selection_start())}$", "Selection size"}
7381
};
7482

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

114-
auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t<std::make_index_sequence<MAX_CTX>>::callbacks;
122+
static auto g_cli_execute_line_with_ctx = execute_line_with_ctx_gen_t<std::make_index_sequence<MAX_CTX>>::callbacks;
115123

116124
// Ignore UI hooks when set
117125
bool g_b_ignore_ui_notification = false;
@@ -390,6 +398,9 @@ macro_editor_t g_macro_editor;
390398
//--------------------------------------------------------------------------
391399
int idaapi init(void)
392400
{
401+
if (!is_idaq())
402+
return PLUGIN_SKIP;
403+
393404
msg("IDA Command Line Interface macros initialized\n");
394405

395406
hook_to_notification_point(HT_UI, ui_callback);

prep-cmake.bat

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@echo off
2+
3+
:: checkout the Batchography book
4+
5+
setlocal
6+
7+
if not defined IDASDK (
8+
echo IDASDK environment variable not set.
9+
echo Also make sure ida-cmake is installed in IDASDK.
10+
echo See: https://github.com/0xeb/ida-cmake
11+
goto :eof
12+
)
13+
14+
if not exist build (
15+
mkdir build
16+
pushd build
17+
cmake -A x64 -G "Visual Studio 15" ..
18+
popd
19+
)
20+
21+
if not exist build64 (
22+
mkdir build64
23+
pushd build64
24+
cmake -A x64 -DEA64=YES -G "Visual Studio 15" ..
25+
popd
26+
)
27+
28+
echo.
29+
echo All done!
30+
echo.

0 commit comments

Comments
 (0)