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-depend
binwalk
Commits
14eda44c
Commit
14eda44c
authored
11 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added binwalk.common.core.debug function
parent
9a5a7237
master
…
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.1
v2.0.1
v2.0.0
python27
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
C.py
src/binwalk/core/C.py
+4
-3
common.py
src/binwalk/core/common.py
+11
-0
magic.py
src/binwalk/core/magic.py
+6
-1
No files found.
src/binwalk/core/C.py
View file @
14eda44c
...
...
@@ -22,8 +22,8 @@ class FunctionHandler(object):
'''
PY2CTYPES
=
{
bytes
:
ctypes
.
c_char_p
,
str
:
ctypes
.
c_char_p
,
int
:
ctypes
.
c_int
,
str
:
ctypes
.
c_char_p
,
int
:
ctypes
.
c_int
,
float
:
ctypes
.
c_float
,
bool
:
ctypes
.
c_int
,
None
:
ctypes
.
c_int
,
...
...
@@ -47,8 +47,9 @@ class FunctionHandler(object):
Returns None.
'''
self
.
name
=
function
.
name
self
.
retype
=
function
.
type
self
.
function
=
getattr
(
library
,
function
.
name
)
self
.
function
=
getattr
(
library
,
self
.
name
)
if
has_key
(
self
.
PY2CTYPES
,
self
.
retype
):
self
.
function
.
restype
=
self
.
PY2CTYPES
[
self
.
retype
]
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/common.py
View file @
14eda44c
...
...
@@ -3,6 +3,7 @@
import
io
import
os
import
re
import
sys
import
ast
import
hashlib
import
operator
as
op
...
...
@@ -14,6 +15,16 @@ if has_key(__builtins__, 'BLOCK_FILE_PARENT_CLASS'):
else
:
BLOCK_FILE_PARENT_CLASS
=
io
.
FileIO
def
debug
(
msg
):
'''
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
'''
# The __debug__ value is a bit backwards; by default it is set to True, but
# then set to False if the Python interpreter is run with the -O option.
if
not
__debug__
:
sys
.
stderr
.
write
(
"DEBUG: "
+
msg
+
"
\n
"
)
sys
.
stderr
.
flush
()
def
file_md5
(
file_name
):
'''
Generate an MD5 hash of the specified file.
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/magic.py
View file @
14eda44c
import
binwalk.core.C
import
binwalk.core.common
from
binwalk.core.compat
import
*
class
Magic
(
object
):
...
...
@@ -26,11 +27,15 @@ class Magic(object):
self
.
magic_file
=
str2bytes
(
magic_file
)
else
:
self
.
magic_file
=
None
self
.
libmagic
=
binwalk
.
core
.
C
.
Library
(
"magic"
,
self
.
LIBMAGIC_FUNCTIONS
)
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
))
self
.
libmagic
.
magic_load
(
self
.
magic_cookie
,
self
.
magic_file
)
binwalk
.
core
.
common
.
debug
(
"libmagic loaded OK!"
)
def
close
(
self
):
if
self
.
magic_cookie
:
...
...
This diff is collapsed.
Click to expand it.
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