From 3682b4b1df7390d2c504528e920ef8ff40f47b0c Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 20 Mar 2015 03:56:31 +0200 Subject: [PATCH] plugin: new simple findptr plugin --- ida/findptr/Makefile | 19 ++++++ ida/findptr/findptr.cpp | 93 +++++++++++++++++++++++++++++ {plugin => ida/saveasm}/Makefile | 2 +- {plugin => ida/saveasm}/saveasm.cpp | 4 +- 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 ida/findptr/Makefile create mode 100644 ida/findptr/findptr.cpp rename {plugin => ida/saveasm}/Makefile (92%) rename {plugin => ida/saveasm}/saveasm.cpp (99%) diff --git a/ida/findptr/Makefile b/ida/findptr/Makefile new file mode 100644 index 0000000..32d48e5 --- /dev/null +++ b/ida/findptr/Makefile @@ -0,0 +1,19 @@ +CROSS_COMPILE = i586-mingw32msvc- +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +IDASDK = $(wildcard ../idasdk*) + +CFLAGS += -Wall -Wno-sign-compare -fno-strict-aliasing +CFLAGS += -I$(IDASDK)/include/ -D__IDP__ -D__PLUGIN__ -D__NT__ +LDLIBS += $(IDASDK)/lib/x86_win_gcc_32/ida.a +ifndef DEBUG +CFLAGS += -O2 +endif + +all: findptr.plw + +%.plw: %.cpp + $(CXX) -shared -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS) + +clean: + $(RM) findptr.plw diff --git a/ida/findptr/findptr.cpp b/ida/findptr/findptr.cpp new file mode 100644 index 0000000..d38d88d --- /dev/null +++ b/ida/findptr/findptr.cpp @@ -0,0 +1,93 @@ +/* + * ia32rtools + * (C) notaz, 2015 + * + * This work is licensed under the terms of 3-clause BSD license. + * See COPYING file in the top-level directory. + */ + +#define NO_OBSOLETE_FUNCS +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------- +static int idaapi init(void) +{ + return PLUGIN_OK; +} + +//-------------------------------------------------------------------------- +static void idaapi term(void) +{ +} + +//-------------------------------------------------------------------------- + +static void idaapi run(int /*arg*/) +{ + bool found = false; + flags_t ea_flags; + uint32 val; + ea_t ea; + + ea = get_screen_ea(); + // msg("range: %x/%x-%x\n", ea, inf.minEA, inf.maxEA); + + ea = next_unknown(ea, inf.maxEA); + for (; ea != BADADDR; ea = next_unknown(ea, inf.maxEA)) + { + segment_t *seg = getseg(ea); + if (!seg) + break; + if (seg->type != SEG_DATA) + continue; + + ea_flags = getFlags(ea); + if (!hasValue(ea_flags)) + continue; + val = get_long(ea); + if (inf.minEA <= val && val < inf.maxEA) { + found = 1; + break; + } + } + + if (found) { + // msg("%x: jmp\n", ea); + jumpto(ea); + } + else + msg("end reached.\n"); +} + +//-------------------------------------------------------------------------- + +static const char comment[] = "Find next pointer-like data"; +static const char help[] = "Find next pointer-like data\n"; +static const char wanted_name[] = "Find next ptr-like"; +static const char wanted_hotkey[] = "Shift-N"; + +//-------------------------------------------------------------------------- +// +// PLUGIN DESCRIPTION BLOCK +// +//-------------------------------------------------------------------------- +plugin_t PLUGIN = +{ + IDP_INTERFACE_VERSION, + 0, // plugin flags + init, // initialize + term, // terminate. this pointer may be NULL. + run, // invoke plugin + comment, // long comment about the plugin + // it could appear in the status line + // or as a hint + help, // multiline help about the plugin + wanted_name, // the preferred short name of the plugin + wanted_hotkey // the preferred hotkey to run the plugin +}; + +// vim:ts=2:shiftwidth=2:expandtab diff --git a/plugin/Makefile b/ida/saveasm/Makefile similarity index 92% rename from plugin/Makefile rename to ida/saveasm/Makefile index 233638f..2cf912c 100644 --- a/plugin/Makefile +++ b/ida/saveasm/Makefile @@ -1,7 +1,7 @@ CROSS_COMPILE = i586-mingw32msvc- CC = $(CROSS_COMPILE)gcc CXX = $(CROSS_COMPILE)g++ -IDASDK = $(wildcard idasdk*) +IDASDK = $(wildcard ../idasdk*) CFLAGS += -Wall -Wno-sign-compare -fno-strict-aliasing CFLAGS += -I$(IDASDK)/include/ -D__IDP__ -D__PLUGIN__ -D__NT__ diff --git a/plugin/saveasm.cpp b/ida/saveasm/saveasm.cpp similarity index 99% rename from plugin/saveasm.cpp rename to ida/saveasm/saveasm.cpp index bfe7e36..5be0dda 100644 --- a/plugin/saveasm.cpp +++ b/ida/saveasm/saveasm.cpp @@ -726,10 +726,10 @@ pass: //-------------------------------------------------------------------------- -static const char comment[] = "Generate disassembly lines for one address"; +static const char comment[] = "Generate disassembly for nasm"; static const char help[] = "Generate asm file\n"; static const char wanted_name[] = "Save asm"; -static const char wanted_hotkey[] = "Ctrl-F6"; +static const char wanted_hotkey[] = "Shift-S"; //-------------------------------------------------------------------------- // -- 2.39.2