Skip to content

Instantly share code, notes, and snippets.

@agelastic
Last active February 23, 2016 16:42
Show Gist options
  • Save agelastic/0bf61260e21c2bccf531 to your computer and use it in GitHub Desktop.
Save agelastic/0bf61260e21c2bccf531 to your computer and use it in GitHub Desktop.
Compiling HexRaysCodeXplorer for 32-bit IDA 6.8 OSX
diff --git a/src/HexRaysCodeXplorer/CodeXplorer.cpp b/src/HexRaysCodeXplorer/CodeXplorer.cpp
index 5be7ce9..6f4b1f1 100644
--- a/src/HexRaysCodeXplorer/CodeXplorer.cpp
+++ b/src/HexRaysCodeXplorer/CodeXplorer.cpp
@@ -23,6 +23,7 @@ along with this program. If not, see
==============================================================================
*/
+#include <stdlib.h>
#include "Common.h"
#include "CtreeGraphBuilder.h"
#include "ObjectExplorer.h"
@@ -436,7 +437,7 @@ static bool idaapi rename_simple_expr(void *ud)
}
postfixes.insert(pair<qstring, int>(rvar_name, 2));
- itoa(postfixes[rvar_name]++, pstx_buf, 10);
+ sprintf(pstx_buf, "%d",postfixes[rvar_name]++);
new_name = rvar_name + "_" + pstx_buf;
to_rename[&(*lvars)[e->x->v.idx]] = new_name;
roots[rvar_name].push_back(new_name);
@@ -470,14 +471,14 @@ static bool idaapi show_offset_in_windbg_format(void *ud) {
get_root_filename(module_name, 255);
for (int i = 0; i < 255; i++)
if (module_name[i] == '.') { module_name[i] = 0; break; }
- itoa(offset, _offset, 16);
+ sprintf(_offset, "%x", offset);
result.cat_sprnt("%s+0x%s", module_name, _offset);
qstring title {0};
title.cat_sprnt("0x%X", vu.item.i->ea);
show_string_in_custom_view(&vu, title, result);
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
msg(result.c_str());
#else
OpenClipboard(0);
diff --git a/src/HexRaysCodeXplorer/Common.h b/src/HexRaysCodeXplorer/Common.h
index a5af1be..d1052c1 100644
--- a/src/HexRaysCodeXplorer/Common.h
+++ b/src/HexRaysCodeXplorer/Common.h
@@ -27,14 +27,14 @@
#pragma once
-#ifndef __LINUX__
+#if !defined (__LINUX__) && !defined (__MAC__)
#pragma warning (disable: 4996 4800 )
#else
#pragma GCC diagnostic ignored "-fpermissive"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
-#ifndef __LINUX__
+#if !defined (__LINUX__) && !defined (__MAC__)
#include <windows.h>
#include <tchar.h>
#else
diff --git a/src/HexRaysCodeXplorer/CtreeExtractor.cpp b/src/HexRaysCodeXplorer/CtreeExtractor.cpp
index 44f6cd5..25482fb 100644
--- a/src/HexRaysCodeXplorer/CtreeExtractor.cpp
+++ b/src/HexRaysCodeXplorer/CtreeExtractor.cpp
@@ -29,7 +29,7 @@
#include "Utility.h"
#include "Debug.h"
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
@@ -430,7 +430,7 @@ bool idaapi show_citem_custom_view(void *ud, qstring ctree_item, qstring item_na
simpleline_place_t s2(ctree_item.size());
si->cv = create_custom_viewer("Ctree Item View: ", NULL, &s1, &s2, &s1, 0, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_NOLINES);
- set_custom_viewer_handlers(si->cv, NULL, si);
+ set_custom_viewer_handlers(si->cv, NULL, NULL, NULL, NULL, NULL, NULL, si);
open_tform(form, FORM_ONTOP | FORM_RESTORE);
return false;
diff --git a/src/HexRaysCodeXplorer/Debug.cpp b/src/HexRaysCodeXplorer/Debug.cpp
index 2d068a8..4e8bbf1 100644
--- a/src/HexRaysCodeXplorer/Debug.cpp
+++ b/src/HexRaysCodeXplorer/Debug.cpp
@@ -29,7 +29,7 @@
#define OUTPUT_FILE "codexplorer_output.txt"
#define ERROR_FILE "codexplorer_error.txt"
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
diff --git a/src/HexRaysCodeXplorer/Linux.h b/src/HexRaysCodeXplorer/Linux.h
index 75ed625..463fb21 100644
--- a/src/HexRaysCodeXplorer/Linux.h
+++ b/src/HexRaysCodeXplorer/Linux.h
@@ -24,7 +24,7 @@
#pragma once
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
#pragma GCC diagnostic ignored "-fpermissive"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
diff --git a/src/HexRaysCodeXplorer/ObjectExplorer.cpp b/src/HexRaysCodeXplorer/ObjectExplorer.cpp
index a0ff26e..1725c4a 100644
--- a/src/HexRaysCodeXplorer/ObjectExplorer.cpp
+++ b/src/HexRaysCodeXplorer/ObjectExplorer.cpp
@@ -30,7 +30,7 @@
#include "Debug.h"
-#ifndef __LINUX__
+#if !defined (__LINUX__) && !defined (__MAC__)
#include <tchar.h>
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -51,7 +51,7 @@ void free_vtable_lists() {
// VTBL code parsing
//---------------------------------------------------------------------------
-const char* get_text_disasm(ea_t ea) {
+const char * get_text_disasm(ea_t ea) {
static char disasm_buff[MAXSTR];
disasm_buff[0] = disasm_buff[MAXSTR - 1] = 0;
@@ -455,8 +455,7 @@ static bool idaapi show_vtbl_xrefs_window_cb(void *ud)
simpleline_place_t s2(si->sv.size() - 1);
si->cv = create_custom_viewer("", NULL, &s1, &s2, &s1, 0, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_STATUSBAR);
- set_custom_viewer_handler(si->cv, CVH_DBLCLICK, ct_vtbl_xrefs_window_dblclick);
-
+ set_custom_viewer_handlers(si->cv, NULL, NULL, NULL, ct_vtbl_xrefs_window_dblclick, NULL, NULL, si);
open_tform(form, FORM_ONTOP | FORM_RESTORE);
return true;
@@ -619,14 +618,7 @@ void object_explorer_form_init()
simpleline_place_t s2(si->sv.size() - 1);
si->cv = create_custom_viewer("", NULL, &s1, &s2, &s1, 0, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_STATUSBAR);
-
- //custom_viewer_handlers_t cvh = custom_viewer_handlers_t(ct_object_explorer_keyboard, ct_object_explorer_popup, NULL, ct_object_explorer_click);
- custom_viewer_handlers_t cvh = custom_viewer_handlers_t();
- cvh.keyboard = ct_object_explorer_keyboard;
- cvh.popup = ct_object_explorer_popup;
- cvh.dblclick = ct_object_explorer_dblclick;
- set_custom_viewer_handlers(si->cv, &cvh, si);
-
+ set_custom_viewer_handlers(si->cv, ct_object_explorer_keyboard, ct_object_explorer_popup, NULL, ct_object_explorer_dblclick, NULL, NULL, si);
hook_to_notification_point(HT_UI, ui_object_explorer_callback, si);
open_tform(form, FORM_TAB | FORM_MENU | FORM_RESTORE);
}
diff --git a/src/HexRaysCodeXplorer/ObjectFormatMSVC.cpp b/src/HexRaysCodeXplorer/ObjectFormatMSVC.cpp
index 97ae565..f1ad7e1 100644
--- a/src/HexRaysCodeXplorer/ObjectFormatMSVC.cpp
+++ b/src/HexRaysCodeXplorer/ObjectFormatMSVC.cpp
@@ -28,7 +28,7 @@ along with this program. If not, see
#include "Utility.h"
-#ifndef __LINUX__
+#if !defined (__LINUX__) && !defined (__MAC__)
#include <tchar.h>
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
diff --git a/src/HexRaysCodeXplorer/TypeExtractor.cpp b/src/HexRaysCodeXplorer/TypeExtractor.cpp
index 3a41edb..7bef6e7 100644
--- a/src/HexRaysCodeXplorer/TypeExtractor.cpp
+++ b/src/HexRaysCodeXplorer/TypeExtractor.cpp
@@ -31,7 +31,7 @@
#include "Debug.h"
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
diff --git a/src/HexRaysCodeXplorer/TypeReconstructor.cpp b/src/HexRaysCodeXplorer/TypeReconstructor.cpp
index 006ec10..6826732 100644
--- a/src/HexRaysCodeXplorer/TypeReconstructor.cpp
+++ b/src/HexRaysCodeXplorer/TypeReconstructor.cpp
@@ -28,7 +28,7 @@
#include "Debug.h"
-#ifndef __LINUX__
+#if !defined (__LINUX__) && !defined (__MAC__)
#include <tchar.h>
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
diff --git a/src/HexRaysCodeXplorer/Utility.cpp b/src/HexRaysCodeXplorer/Utility.cpp
index 2716910..04afb20 100644
--- a/src/HexRaysCodeXplorer/Utility.cpp
+++ b/src/HexRaysCodeXplorer/Utility.cpp
@@ -28,7 +28,7 @@
#include "Debug.h"
-#ifdef __LINUX__
+#if defined (__LINUX__) || defined (__MAC__)
#include "Linux.h"
#endif
@@ -54,7 +54,7 @@ bool idaapi show_string_in_custom_view(void *ud, qstring title, qstring str)
simpleline_place_t s2(si->sv.size());
si->cv = create_custom_viewer(title.c_str(), NULL, &s1, &s2, &s1, NULL, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_NOLINES);
- set_custom_viewer_handlers(si->cv, NULL, si);
+ set_custom_viewer_handlers(si->cv, NULL, NULL, NULL, NULL, NULL, NULL, si);
open_tform(form, FORM_ONTOP | FORM_RESTORE);
return false;
diff --git a/src/HexRaysCodeXplorer/makefile b/src/HexRaysCodeXplorer/makefile
index 1518acc..06884ee 100644
--- a/src/HexRaysCodeXplorer/makefile
+++ b/src/HexRaysCodeXplorer/makefile
@@ -1,9 +1,10 @@
-CC=g++
+CC=g++-5
LD=ld
+IDA_DIR=/Applications/IDA\ Pro\ 6.8/IDA\ binaries
#CFLAGS=-D__LINUX__ -DUSE_DANGEROUS_FUNCTIONS -D__PLUGIN__ -D__X64__ -std=c++11
#CFLAGS=-m32 -fPIC -D__LINUX__ -DUSE_DANGEROUS_FUNCTIONS -D__PLUGIN__ -D__EA64__ -std=c++11
-CFLAGS=-m32 -fPIC -D__LINUX__ -DUSE_DANGEROUS_FUNCTIONS -D__PLUGIN__ -std=c++11
+CFLAGS=-m32 -fPIC -D__MAC__ -DUSE_DANGEROUS_FUNCTIONS -D__PLUGIN__ -std=c++11
LDFLAGS=-shared -m32
@@ -11,11 +12,11 @@ LDFLAGS=-shared -m32
#LIBS= -lida64 -lpro -lc -lpthread -ldl
LIBS= -lida -lpro -lc -lpthread -ldl
-LIBDIR=-L./ -L$(IDA_DIR) -L/usr/lib/i386-linux-gnu/
+LIBDIR=-L./ -L$(IDA_DIR)
SRCDIR=./
HEXRAYS_SDK=$(IDA_DIR)/plugins/hexrays_sdk
SRC=$(SRCDIR)CodeXplorer.cpp \
- $(SRCDIR)GraphBuilder.cpp \
+ $(SRCDIR)CtreeGraphBuilder.cpp \
$(SRCDIR)ObjectExplorer.cpp \
$(SRCDIR)TypeReconstructor.cpp \
$(SRCDIR)CtreeExtractor.cpp \
@@ -31,18 +32,18 @@ INCLUDES=-I$(IDA_SDK)/include -I$(HEXRAYS_SDK)/include
#DEFINE=__X64__ -D__LINUX__
#DEFINE=__EA64__ -D__LINUX__
-all: HexRaysCodeXplorer.plx
+all: HexRaysCodeXplorer.pmc
-HexRaysCodeXplorer.plx: $(OBJS)
+HexRaysCodeXplorer.pmc: $(OBJS)
#ln -f -s $(IDA_SDK)/lib/x64_linux_gcc_64/pro.a libpro.a
- ln -f -s $(IDA_SDK)/lib/x86_linux_gcc_32/pro.a libpro.a
- $(CC) $(LDFLAGS) $(LIBDIR) -o HexRaysCodeXplorer.plx $(OBJS) $(LIBS)
+ ln -f -s $(IDA_SDK)/lib/x86_mac_gcc_32/pro.a libpro.a
+ $(CC) $(LDFLAGS) $(LIBDIR) -o HexRaysCodeXplorer.pmc $(OBJS) $(LIBS)
%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
- rm -f $(OBJS) HexRaysCodeXplorer.plx
+ rm -f $(OBJS) HexRaysCodeXplorer.pmc
install:
- cp -f HexRaysCodeXplorer.plx $(IDA_DIR)/plugins
+ cp -f HexRaysCodeXplorer.pmc $(IDA_DIR)/plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment