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
cc7e4a64
Commit
cc7e4a64
authored
Apr 18, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made magic_t data type for libmagic wrapper
parent
b2ac05ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
C.py
src/binwalk/core/C.py
+8
-2
magic.py
src/binwalk/core/magic.py
+9
-3
No files found.
src/binwalk/core/C.py
View file @
cc7e4a64
...
...
@@ -56,7 +56,9 @@ class FunctionHandler(object):
self
.
function
.
restype
=
self
.
PY2CTYPES
[
self
.
retype
]
self
.
retval_converter
=
self
.
RETVAL_CONVERTERS
[
self
.
retype
]
else
:
raise
Exception
(
"Unknown return type: '
%
s'"
%
self
.
retype
)
self
.
function
.
restype
=
self
.
retype
self
.
retval_converter
=
None
#raise Exception("Unknown return type: '%s'" % self.retype)
def
run
(
self
,
*
args
):
'''
...
...
@@ -74,7 +76,11 @@ class FunctionHandler(object):
if
isinstance
(
args
[
i
],
str
):
args
[
i
]
=
str2bytes
(
args
[
i
])
return
self
.
retval_converter
(
self
.
function
(
*
args
))
retval
=
self
.
function
(
*
args
)
if
self
.
retval_converter
is
not
None
:
retval
=
self
.
retval_converter
(
retval
)
return
retval
class
Library
(
object
):
'''
...
...
src/binwalk/core/magic.py
View file @
cc7e4a64
...
...
@@ -5,6 +5,12 @@
import
binwalk.core.C
import
binwalk.core.common
from
binwalk.core.compat
import
*
from
ctypes
import
*
class
magic_set
(
Structure
):
pass
magic_set
.
_fields_
=
[]
magic_t
=
POINTER
(
magic_set
)
class
Magic
(
object
):
'''
...
...
@@ -12,8 +18,8 @@ class Magic(object):
'''
LIBMAGIC_FUNCTIONS
=
[
binwalk
.
core
.
C
.
Function
(
name
=
"magic_open"
,
type
=
in
t
),
binwalk
.
core
.
C
.
Function
(
name
=
"magic_close"
,
type
=
None
),
binwalk
.
core
.
C
.
Function
(
name
=
"magic_open"
,
type
=
magic_
t
),
binwalk
.
core
.
C
.
Function
(
name
=
"magic_close"
,
type
=
int
),
binwalk
.
core
.
C
.
Function
(
name
=
"magic_load"
,
type
=
int
),
binwalk
.
core
.
C
.
Function
(
name
=
"magic_buffer"
,
type
=
str
),
]
...
...
@@ -37,7 +43,7 @@ class Magic(object):
binwalk
.
core
.
common
.
debug
(
"libmagic.magic_open(0x
%
X)"
%
(
self
.
MAGIC_FLAGS
|
flags
))
self
.
magic_cookie
=
self
.
libmagic
.
magic_open
(
self
.
MAGIC_FLAGS
|
flags
)
binwalk
.
core
.
common
.
debug
(
"libmagic.magic_load(
0x
%
X,
%
s)"
%
(
self
.
magic_cookie
,
self
.
magic_file
))
binwalk
.
core
.
common
.
debug
(
"libmagic.magic_load(
%
s,
%
s)"
%
(
type
(
self
.
magic_cookie
)
,
self
.
magic_file
))
self
.
libmagic
.
magic_load
(
self
.
magic_cookie
,
self
.
magic_file
)
binwalk
.
core
.
common
.
debug
(
"libmagic loaded OK!"
)
...
...
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