Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
binwalk
Commits
e6916e06
Commit
e6916e06
authored
Jul 28, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated idb.py to properly handle segmented IDB data
parent
3550ce17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
7 deletions
+33
-7
idb.py
src/binwalk/core/idb.py
+33
-7
No files found.
src/binwalk/core/idb.py
View file @
e6916e06
...
@@ -69,15 +69,41 @@ class IDBFileIO(io.FileIO):
...
@@ -69,15 +69,41 @@ class IDBFileIO(io.FileIO):
return
super
(
IDBFileIO
,
self
)
.
read
(
n
)
return
super
(
IDBFileIO
,
self
)
.
read
(
n
)
else
:
else
:
data
=
''
data
=
''
start_n
=
n
read_count
=
0
start_idb_pos
=
self
.
idb_pos
filler_count
=
0
# Loop to read n bytes of data across IDB segments, filling
# segment gaps with NULL bytes.
while
n
and
self
.
idb_pos
<=
self
.
idb_end
:
while
n
and
self
.
idb_pos
<=
self
.
idb_end
:
# This generally assumes 8-bit bytes
segment
=
idaapi
.
getseg
(
self
.
idb_pos
)
data
+=
chr
(
idc
.
Byte
(
self
.
idb_pos
))
self
.
idb_pos
+=
1
if
not
segment
:
n
-=
1
filler_count
+=
1
self
.
idb_pos
+=
1
n
-=
1
else
:
if
filler_count
:
data
+=
"
\x00
"
*
filler_count
filler_count
=
0
if
(
self
.
idb_pos
+
n
)
>
segment
.
endEA
:
read_count
=
segment
.
endEA
-
self
.
idb_pos
else
:
read_count
=
n
try
:
data
+=
idc
.
GetManyBytes
(
self
.
idb_pos
,
read_count
)
except
TypeError
as
e
:
# This happens when trying to read from uninitialized segments (e.g., .bss)
data
+=
"
\x00
"
*
read_count
n
-=
read_count
self
.
idb_pos
+=
read_count
if
filler_count
:
data
+=
"
\x00
"
*
filler_count
filler_count
=
0
return
data
return
data
def
write
(
self
,
data
):
def
write
(
self
,
data
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment