Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
Commits on Source (1)
......@@ -173,10 +173,11 @@ set<string> ZST_NetworkLocBlacklist;
set<string> ZST_SystemCallNumericWhitelist;
#if (IDA_SDK_VERSION < 700)
void IDAP_run(int);
void idaapi IDAP_run(int);
#else
bool IDAP_run(std::size_t);
bool idaapi IDAP_run(std::size_t);
#endif
void IDAP_term(void);
// Functions for diagnosing and/or fixing problems in the IDA database.
void FixupIDB(void); // Driver for all other fixing functions.
......@@ -233,12 +234,23 @@ bool STARS_custom_ana(STARS_ea_t CurrentAddr) {
}
} // end of STARS_custom_ana()
#if (IDA_SDK_VERSION > 749)
struct STARS_plugmod_t : public plugmod_t {
bool idaapi run(std::size_t arg) {
return IDAP_run(arg);
}
~STARS_plugmod_t() { IDAP_term(); }
};
static STARS_plugmod_t *PluginModuleStruct;
#endif
#if (IDA_SDK_VERSION < 700)
static int idaapi idp_callback(void *, int event_id, va_list va) {
#else
static ssize_t idaapi idp_callback(void *, int event_id, va_list va) {
#endif
bool success = 0;
#if STARS_REMOVE_LOCK_PREFIX
if (event_id == processor_t::custom_ana) {
STARS_ea_t CurrentAddr = cmd.ea;
......@@ -281,8 +293,10 @@ static ssize_t idaapi idp_callback(void *, int event_id, va_list va) {
}
#if (IDA_SDK_VERSION < 700)
IDAP_run(0);
#else
bool success = IDAP_run(0);
#elif (IDA_SDK_VERSION < 750)
success = IDAP_run(0);
#else
success = PluginModuleStruct->run(0);
#endif
#if STARS_REMOVE_LOCK_PREFIX
SMP_msg("INFO: Calls to STARS_custom_ana: %lu \n", CustomAnaCallCount);
......@@ -292,20 +306,27 @@ static ssize_t idaapi idp_callback(void *, int event_id, va_list va) {
// qexit(0);
}
return 0; // did not process any event
return (ssize_t)success;
} // end of idp_callback()
void IDAP_term(void) {
SMP_msg("Entering IDAP_term.\n");
#if (IDA_SDK_VERSION < 700)
::unhook_from_notification_point(HT_IDP, idp_callback, nullptr);
#else
// auto_empty_finally is now hooked to HT_IDB instead of HT_IDP
::unhook_from_notification_point(HT_IDB, idp_callback, nullptr);
#endif
SMP_msg("Exiting IDAP_term.\n");
return;
} // end of IDAP_term()
#if (IDA_SDK_VERSION < 750)
int IDAP_init(void) {
#else
struct STARS_plugmod_t : public plugmod_t {
bool run(std::size_t arg) {
return IDAP_run(arg);
}
};
static STARS_plugmod_t PluginModuleStruct;
plugmod_t *IDAP_init(void) {
static plugmod_t * idaapi IDAP_init(void) {
PluginModuleStruct = new STARS_plugmod_t;
#endif
......@@ -314,14 +335,8 @@ plugmod_t *IDAP_init(void) {
global_STARS_program = new STARS_IDA_Program_t;
#if 0 // We are now calling from the SMP.idc script.
// Skip this plugin if it was not specified by the user on the
// command line.
if (get_plugin_options("SMPStaticAnalyzer") == nullptr) {
SMP_msg("IDAP_init point 2.\n");
return PLUGIN_SKIP;
}
#endif
SMP_msg("IDAP_init entered.\n");
// Ensure correct working environment.
if (ph.id != PLFM_386 && ph.id != PLFM_ARM && ph.id != PLFM_MIPS)
{
......@@ -342,27 +357,18 @@ plugmod_t *IDAP_init(void) {
#ifdef STARS_IRDB_INTERFACE
SMPLogFile = nullptr;
#endif
SMP_msg("Exiting IDAP_init.\n");
#if (IDA_SDK_VERSION < 750)
return PLUGIN_KEEP;
#else
return &PluginModuleStruct;
return PluginModuleStruct;
#endif
} // end of IDAP_init
void IDAP_term(void) {
#if (IDA_SDK_VERSION < 700)
unhook_from_notification_point(HT_IDP, idp_callback, nullptr);
#else
// auto_empty_finally is now hooked to HT_IDB instead of HT_IDP
unhook_from_notification_point(HT_IDB, idp_callback, nullptr);
#endif
return;
}
#if (IDA_SDK_VERSION < 700)
void IDAP_run(int arg) {
#else
bool IDAP_run(std::size_t arg) {
bool idaapi IDAP_run(std::size_t arg) {
#endif
FILE *AnnotFile = nullptr;
FILE *InfoAnnotFile = nullptr;
......@@ -407,7 +413,7 @@ bool IDAP_run(std::size_t arg) {
if (SMP_is_64bit()) {
global_STARS_program->Set64BitBinary();
const auto pt = (ph.id == PLFM_386) ? ptX86_64 :
(ph.id == PLFM_ARM) ? ptARM64 :
(ph.id == PLFM_ARM) ? ptARM64 :
throw invalid_argument("Unknown machine type");
global_STARS_program->SetProcessorType(pt);
SMP_msg("INFO: 64-bit binary detected.\n");
......@@ -415,8 +421,8 @@ bool IDAP_run(std::size_t arg) {
else {
global_STARS_program->Set32BitBinary();
const auto pt = (ph.id == PLFM_386) ? ptX86_32 :
(ph.id == PLFM_ARM) ? ptARM :
(ph.id == PLFM_MIPS) ? ptMIPS :
(ph.id == PLFM_ARM) ? ptARM :
(ph.id == PLFM_MIPS) ? ptMIPS :
throw invalid_argument("Unknown machine type");
global_STARS_program->SetProcessorType(pt);
SMP_msg("INFO: 32-bit binary detected.\n");
......@@ -672,11 +678,17 @@ bool IDAP_run(std::size_t arg) {
delete CurrProg;
stringstream sout;
STARS_Instruction_t::DumpCreationStats(sout);
STARS_op_t::DumpCreationStats(sout);
STARS_op_t::DumpCreationStats(sout);
SMP_msg("Interface stats: \n %s", sout.str().c_str());
SMP_msg("INFO: Deleted CurrProg. Returning to IDA Pro.\n");
#if (IDA_SDK_VERSION > 749)
SMP_msg("Deleting PluginModuleStruct and exiting IDAP_run.\n");
delete PluginModuleStruct;
#endif
delete global_STARS_program;
delete global_stars_interface;
#if (IDA_SDK_VERSION < 700)
return;
#else
......@@ -711,10 +723,19 @@ char IDAP_hotkey[] = "Alt-J";
plugin_t PLUGIN = {
IDP_INTERFACE_VERSION,
#if (IDA_SDK_VERSION < 750)
PLUGIN_PROC | PLUGIN_MOD,
#else
PLUGIN_MULTI | PLUGIN_PROC | PLUGIN_MOD,
#endif
IDAP_init,
#if (IDA_SDK_VERSION < 750)
IDAP_term,
IDAP_run,
#else
nullptr, // term() is called from plugmod_t destructor
nullptr, // run() is called from plugmod_t
#endif
IDAP_comment,
IDAP_help,
IDAP_name,
......