plugin: new simple findptr plugin
authornotaz <notasas@gmail.com>
Fri, 20 Mar 2015 01:56:31 +0000 (03:56 +0200)
committernotaz <notasas@gmail.com>
Fri, 20 Mar 2015 01:56:31 +0000 (03:56 +0200)
ida/findptr/Makefile [new file with mode: 0644]
ida/findptr/findptr.cpp [new file with mode: 0644]
ida/saveasm/Makefile [moved from plugin/Makefile with 92% similarity]
ida/saveasm/saveasm.cpp [moved from plugin/saveasm.cpp with 99% similarity]

diff --git a/ida/findptr/Makefile b/ida/findptr/Makefile
new file mode 100644 (file)
index 0000000..32d48e5
--- /dev/null
@@ -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 (file)
index 0000000..d38d88d
--- /dev/null
@@ -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 <ida.hpp>
+#include <idp.hpp>
+#include <bytes.hpp>
+#include <loader.hpp>
+#include <kernwin.hpp>
+
+//--------------------------------------------------------------------------
+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
similarity index 92%
rename from plugin/Makefile
rename to ida/saveasm/Makefile
index 233638f..2cf912c 100644 (file)
@@ -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__
similarity index 99%
rename from plugin/saveasm.cpp
rename to ida/saveasm/saveasm.cpp
index bfe7e36..5be0dda 100644 (file)
@@ -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";
 
 //--------------------------------------------------------------------------
 //