From: notaz Date: Fri, 20 Mar 2015 01:56:31 +0000 (+0200) Subject: plugin: new simple findptr plugin X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3682b4b1df7390d2c504528e920ef8ff40f47b0c;p=ia32rtools.git plugin: new simple findptr plugin --- 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"; //-------------------------------------------------------------------------- //