Skip to content

Commit e5a763e

Browse files
authored
Merge branch 'main' into main
2 parents 23177a6 + b25fc89 commit e5a763e

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Python wrapper to manipulate bindiff files"
88
authors = [{ name = "Robin David", email = "[email protected]" }]
99
license = { text = "Apache Software License (Apache License, Version 2)" }
1010
readme = { file = "README.md", content-type = "text/markdown" }
11-
version = '0.3.1'
11+
version = '0.3.2'
1212
requires-python = ">=3.9"
1313
dependencies = [
1414
"python-magic; os_name!='nt'",

src/bindiff/__main__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
help="BinDiff differ directory",
4343
)
4444
@click.option("-o", "--output", type=click.Path(), default=None, help="Output file matching")
45-
@click.argument("primary", type=click.Path(exists=True), metavar="<primary file>")
46-
@click.argument("secondary", type=click.Path(exists=True), metavar="<secondary file>")
47-
def main(ida_path: str, bindiff_path: str, output: str, primary: str, secondary: str) -> None:
45+
@click.argument("primary", type=click.Path(exists=True, path_type=Path), metavar="<primary file>")
46+
@click.argument("secondary", type=click.Path(exists=True, path_type=Path), metavar="<secondary file>")
47+
def main(ida_path: str, bindiff_path: str, output: str, primary: Path, secondary: Path) -> None:
4848
"""
4949
bindiffer is a very simple utility to diff two binary files using BinDiff
5050
in command line. The two input files can be either binary files (in which
@@ -79,9 +79,6 @@ def main(ida_path: str, bindiff_path: str, output: str, primary: str, secondary:
7979
logging.error("Output file name is too long (%s).", output)
8080
exit(1)
8181

82-
primary = Path(primary)
83-
secondary = Path(secondary)
84-
8582
if not (primary.suffix == ".BinExport" and secondary.suffix == ".BinExport"):
8683
for file in [primary, secondary]:
8784
mime_type = magic.from_file(file, mime=True)
@@ -95,11 +92,11 @@ def main(ida_path: str, bindiff_path: str, output: str, primary: str, secondary:
9592

9693
# Export each binary separately (and then diff to be able to print it)
9794
logging.info(f"export primary: {primary}.BinExport")
98-
ProgramBinExport.from_binary_file(primary, open_export=False, override=True)
95+
ProgramBinExport.generate(primary, override=True)
9996
primary = Path(str(primary) + ".BinExport")
10097

10198
logging.info(f"export secondary: {secondary}.BinExport")
102-
ProgramBinExport.from_binary_file(secondary, open_export=False, override=True)
99+
ProgramBinExport.generate(secondary, override=True)
103100
secondary = Path(str(secondary) + ".BinExport")
104101

105102
logging.info("start diffing")

src/bindiff/bindiff.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def iter_function_matches(
134134
matches = []
135135
for match in self.primary_functions_match.values():
136136
if match.address1 not in self.primary:
137-
logging.error(f"missing primary function match at '{hex(match.address1)}'")
137+
logging.error(f"missing primary function match at: {match.address1:#08x}")
138138
elif match.address2 not in self.secondary:
139-
logging.error(f"missing secondary function match at '{hex(match.address1)}'")
139+
logging.error(f"missing secondary function match at: {match.address1:#08x}")
140140
else:
141141
matches.append(
142142
(self.primary[match.address1], self.secondary[match.address2], match)
@@ -305,7 +305,8 @@ def raw_diffing(p1_path: Union[Path, str], p2_path: Union[Path, str], out_diff:
305305
if not f2.exists():
306306
logging.error(f"file '{p2_path}' doesn't exist")
307307
return False
308-
308+
309+
assert BINDIFF_BINARY is not None # for mypy
309310
cmd_line = [
310311
BINDIFF_BINARY.as_posix(),
311312
f"--primary={p1_path}",
@@ -355,8 +356,8 @@ def from_binary_files(
355356
:return: BinDiff object representing the diff
356357
"""
357358

358-
p1 = ProgramBinExport.from_binary_file(p1_path, override=override)
359-
p2 = ProgramBinExport.from_binary_file(p2_path, override=override)
359+
p1 = ProgramBinExport.from_binary(p1_path, override=override)
360+
p2 = ProgramBinExport.from_binary(p2_path, override=override)
360361
if p1 and p2:
361362
return BinDiff.from_binexport_files(p1, p2, diff_out, override=override)
362363
else:

0 commit comments

Comments
 (0)