Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPStaticAnalyzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
SMPStaticAnalyzer
Commits
7c8ad0ee
Commit
7c8ad0ee
authored
5 years ago
by
Clark Coleman
Browse files
Options
Downloads
Patches
Plain Diff
Use IDA Pro is_dll() method as preferred way to detect shared objects.
parent
1937bc5a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#6062
passed
5 years ago
Stage: clean
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/idapro/STARSIDAProgram.cpp
+51
-44
51 additions, 44 deletions
src/interfaces/idapro/STARSIDAProgram.cpp
with
51 additions
and
44 deletions
src/interfaces/idapro/STARSIDAProgram.cpp
+
51
−
44
View file @
7c8ad0ee
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment