From 706d1e5ff56421a08e243d8802b83f1af4b4819b Mon Sep 17 00:00:00 2001
From: clc5q <clc5q@git.zephyr-software.com>
Date: Wed, 3 Jun 2015 22:00:08 +0000
Subject: [PATCH] SConstruct __EA64__ fix and tag_remove() fix for IDA 6.8.

Former-commit-id: f5967eba83d5cf7ecf63bb4eb0f773b961a02eed
---
 SConstruct                               |  2 +-
 src/drivers/idapro/SMPStaticAnalyzer.cpp | 18 ++++--------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/SConstruct b/SConstruct
index 08d2cb61..aaeced78 100644
--- a/SConstruct
+++ b/SConstruct
@@ -37,7 +37,7 @@ else:
 	STARS_CCFLAGS=" -O3"
 
 if int(argenv['do_64bit_analysis']) == 1:
-	STARS_CCFLAGS+=" -DEA64"
+	STARS_CCFLAGS+=" -D__EA64__"
 
 
 Export('argenv', 'STARS_CCFLAGS')
diff --git a/src/drivers/idapro/SMPStaticAnalyzer.cpp b/src/drivers/idapro/SMPStaticAnalyzer.cpp
index 37306284..633624cf 100644
--- a/src/drivers/idapro/SMPStaticAnalyzer.cpp
+++ b/src/drivers/idapro/SMPStaticAnalyzer.cpp
@@ -43,6 +43,8 @@
 #include <ida.hpp>
 #include <ua.hpp>
 #include <bytes.hpp>
+#include <loader.hpp>
+#include <nalt.hpp>
 
 #include "interfaces/STARSTypes.h"
 #include "interfaces/STARSIDATypes.h"
@@ -287,19 +289,6 @@ int IDAP_init(void) {
 		error("Processor must be x86.");
  		return PLUGIN_SKIP;
 	}
-#if 0 // too early to detect 64-bit; moved to IDAP_run()
-	if (inf.is_64bit()) {
-		STARS_ISA_Bitwidth = 64;
-		STARS_ISA_dtyp = dt_qword;
-		SMP_msg("INFO: 64-bit binary detected.\n");
-	}
-	else {
-		STARS_ISA_Bitwidth = 32;
-		STARS_ISA_dtyp = dt_dword;
-		SMP_msg("INFO: 32-bit binary detected.\n");
-	}
-	STARS_ISA_Bytewidth = (STARS_ISA_Bitwidth / 8);
-#endif
 
 	hook_to_notification_point(HT_IDP, idp_callback, NULL);
 #ifdef STARS_IRDB_INTERFACE
@@ -354,6 +343,7 @@ void IDAP_run(int arg) {
 	}
 
 	global_STARS_program->InitData();
+
 	global_STARS_program->DetermineRootFileName();
 	if (!(global_STARS_program->OpenFiles())) {
 		SMP_msg("FATAL ERROR: At least one file could not be opened.\n");
@@ -1470,7 +1460,7 @@ void FindOrphanedCode(STARS_Segment_t *CurrSeg, FILE *AnnotFile, FILE *InfoAnnot
 				bool IDAsuccess = SMP_generate_disasm_line(addr, disasm, sizeof(disasm) - 1);
 				if (IDAsuccess) {
 					// Remove interactive color-coding tags.
-					STARS_ssize_t StringLen = SMP_tag_remove(disasm, disasm, 0);
+					STARS_ssize_t StringLen = SMP_tag_remove(disasm, disasm, sizeof(disasm) - 1);
 					if (-1 >= StringLen) {
 						SMP_msg("ERROR: tag_remove failed at addr %lx \n", (unsigned long) addr);
 					}
-- 
GitLab