Skip to content
Snippets Groups Projects
Commit 7c8ad0ee authored by Clark Coleman's avatar Clark Coleman
Browse files

Use IDA Pro is_dll() method as preferred way to detect shared objects.

parent 1937bc5a
No related branches found
No related tags found
No related merge requests found
Pipeline #6062 passed
......@@ -22,6 +22,7 @@
// IDA Pro headers
#include <bytes.hpp> // for get_flags(), is_code(), is_data(), is_unknown()
#include <ida.hpp> // for is_dll()
#if 0
#include <pro.h>
......@@ -157,59 +158,65 @@ void STARS_IDA_Program_t::DetermineRootFileName(void) {
string TempRootString(TempRootName);
this->SetRootFileName(TempRootString);
// Try to find ".so" or ".dll" or ".a" in file name, indicating shared object.
// This code below only works for non-renamed file, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
bool sharedObjectFlag = false;
char token[210];
std::size_t tokencount = 0;
istringstream FileNameStr(TempRootString);
this->SetSharedObjectFlag(false);
char delim = '.';
FileNameStr.getline(token, 200, delim);
while (FileNameStr.rdstate() == std::istringstream::goodbit) {
++tokencount;
if (1 < tokencount) { // Not looking for file extension before first "."
sharedObjectFlag = ((0 == strcmp(token, "so")) || (0 == strcmp(token, "dll"))
|| (0 == strcmp(token, "a")));
if (sharedObjectFlag) {
this->SetSharedObjectFlag(sharedObjectFlag);
SMP_msg("INFO: Determined shared object from file extension %s\n", token);
break;
if (::inf.is_dll()) {
this->SetSharedObjectFlag(true);
SMP_msg("INFO: Determined shard object from is_dll() in IDA Pro.\n");
}
else {
// Try to find ".so" or ".dll" or ".a" in file name, indicating shared object.
// This code below only works for non-renamed file, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
bool sharedObjectFlag = false;
char token[210];
std::size_t tokencount = 0;
istringstream FileNameStr(TempRootString);
this->SetSharedObjectFlag(false);
char delim = '.';
FileNameStr.getline(token, 200, delim);
while (FileNameStr.rdstate() == std::istringstream::goodbit) {
++tokencount;
if (1 < tokencount) { // Not looking for file extension before first "."
sharedObjectFlag = ((0 == strcmp(token, "so")) || (0 == strcmp(token, "dll"))
|| (0 == strcmp(token, "a")));
if (sharedObjectFlag) {
this->SetSharedObjectFlag(sharedObjectFlag);
SMP_msg("INFO: Determined shared object from file extension %s\n", token);
break;
}
}
FileNameStr.getline(token, 200, delim);
}
FileNameStr.getline(token, 200, delim);
}
#if 1
// See if shared object extension is at the very end, with no more "." delimiter after.
// Find file name extension.
if (!sharedObjectFlag) {
string delimiter(".");
std::size_t found = TempRootString.rfind(delimiter, TempRootString.length());
if (found != std::string::npos) { // found last instance of delimiter
string extension = TempRootString.substr(found, std::string::npos);
if (!extension.empty()) {
// This code below only works for non-renamed files, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
SMP_msg("INFO: Found extension %s\n", extension.c_str());
sharedObjectFlag = ((0 == extension.compare(".so")) || (0 == extension.compare(".dll"))
|| (0 == extension.compare(".a")));
this->SetSharedObjectFlag(sharedObjectFlag);
if (sharedObjectFlag)
SMP_msg("INFO: Determined shared object from file extension %s\n", extension.c_str());
// See if shared object extension is at the very end, with no more "." delimiter after.
// Find file name extension.
if (!sharedObjectFlag) {
string delimiter(".");
std::size_t found = TempRootString.rfind(delimiter, TempRootString.length());
if (found != std::string::npos) { // found last instance of delimiter
string extension = TempRootString.substr(found, std::string::npos);
if (!extension.empty()) {
// This code below only works for non-renamed files, e.g. STARS/IDA Pro operation,
// and not files renamed with new extensions, e.g. a.ncexe. Replace with info from
// file header soon.
SMP_msg("INFO: Found extension %s\n", extension.c_str());
sharedObjectFlag = ((0 == extension.compare(".so")) || (0 == extension.compare(".dll"))
|| (0 == extension.compare(".a")));
this->SetSharedObjectFlag(sharedObjectFlag);
if (sharedObjectFlag)
SMP_msg("INFO: Determined shared object from file extension %s\n", extension.c_str());
}
else {
SMP_msg("ERROR: Empty file name extension.\n");
}
}
else {
SMP_msg("ERROR: Empty file name extension.\n");
SMP_msg("ERROR: Could not reverse-find the dot delimiter in file name.\n");
}
}
else {
SMP_msg("ERROR: Could not reverse-find the dot delimiter in file name.\n");
}
}
#endif
}
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment