Skip to content

Commit ce782fe

Browse files
committed
adapt code to use latest python-binexport API
1 parent 525adf0 commit ce782fe

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def raw_diffing(p1_path: Union[Path, str], p2_path: Union[Path, str], out_diff:
299299
logging.error(f"file '{p2_path}' doesn't exist")
300300
return False
301301

302+
assert BINDIFF_BINARY is not None # for mypy
302303
cmd_line = [
303304
BINDIFF_BINARY.as_posix(),
304305
f"--primary={p1_path}",
@@ -347,8 +348,8 @@ def from_binary_files(p1_path: str, p2_path: str, diff_out: str,
347348
:return: BinDiff object representing the diff
348349
"""
349350

350-
p1 = ProgramBinExport.from_binary_file(p1_path, override=override)
351-
p2 = ProgramBinExport.from_binary_file(p2_path, override=override)
351+
p1 = ProgramBinExport.from_binary(p1_path, override=override)
352+
p2 = ProgramBinExport.from_binary(p2_path, override=override)
352353
if p1 and p2:
353354
return BinDiff.from_binexport_files(p1, p2, diff_out, override=override)
354355
else:

0 commit comments

Comments
 (0)