Skip to content

Commit

Permalink
don't save ghidra proj in bin dir
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Aug 3, 2024
1 parent 84d6271 commit 8833fdc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/patcherex2/components/binary_analyzers/ghidra.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import tempfile

from .binary_analyzer import BinaryAnalyzer

Expand All @@ -9,8 +10,11 @@ class Ghidra(BinaryAnalyzer):
def __init__(self, binary_path: str, **kwargs):
import pyhidra

self.ctx = pyhidra.open_program(binary_path)
self.flatapi = self.ctx.__enter__()
self.temp_proj_dir_ctx = tempfile.TemporaryDirectory()
self.temp_proj_dir = self.temp_proj_dir_ctx.__enter__()

self.pyhidra_ctx = pyhidra.open_program(binary_path, self.temp_proj_dir)
self.flatapi = self.pyhidra_ctx.__enter__()
self.currentProgram = self.flatapi.getCurrentProgram()

import ghidra
Expand All @@ -20,7 +24,8 @@ def __init__(self, binary_path: str, **kwargs):
self.bbm = self.ghidra.program.model.block.BasicBlockModel(self.currentProgram)

def shutdown(self):
self.ctx.__exit__(None, None, None)
self.pyhidra_ctx.__exit__(None, None, None)
self.temp_proj_dir_ctx.__exit__(None, None, None)

def normalize_addr(self, addr):
addr = addr.getOffset()
Expand Down

0 comments on commit 8833fdc

Please sign in to comment.