mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge branch 'GP-5444_ryanmkurtz_pyghidra-lock' into patch
(Closes #7536)
This commit is contained in:
commit
5a8c2fbfa6
3 changed files with 13 additions and 9 deletions
|
@ -306,6 +306,10 @@ import pdb # imports Python's pdb
|
|||
import pdb_ # imports Ghidra's pdb
|
||||
```
|
||||
## Change History
|
||||
__2.0.2:__
|
||||
* [`pyghidra.open_program()`](#pyghidraopen_program) now properly throws an exception if the project
|
||||
exists and is locked.
|
||||
|
||||
__2.0.1:__
|
||||
* PyGhidra now respects the `application.settingsdir` property set in Ghidra's `launch.properties`
|
||||
file.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
__version__ = "2.0.1"
|
||||
__version__ = "2.0.2"
|
||||
|
||||
# stub for documentation and typing
|
||||
# this is mostly to hide the function parameter
|
||||
|
|
|
@ -85,7 +85,7 @@ def _setup_project(
|
|||
) -> Tuple["GhidraProject", "Program"]:
|
||||
from ghidra.base.project import GhidraProject
|
||||
from java.lang import ClassLoader # type:ignore @UnresolvedImport
|
||||
from java.io import IOException # type:ignore @UnresolvedImport
|
||||
from ghidra.framework.model import ProjectLocator # type:ignore @UnresolvedImport
|
||||
if binary_path is not None:
|
||||
binary_path = Path(binary_path)
|
||||
if project_location:
|
||||
|
@ -95,7 +95,6 @@ def _setup_project(
|
|||
if not project_name:
|
||||
project_name = f"{binary_path.name}_ghidra"
|
||||
project_location /= project_name
|
||||
project_location.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
if isinstance(loader, str):
|
||||
from java.lang import ClassNotFoundException # type:ignore @UnresolvedImport
|
||||
|
@ -113,13 +112,14 @@ def _setup_project(
|
|||
|
||||
# Open/Create project
|
||||
program: "Program" = None
|
||||
try:
|
||||
if ProjectLocator(project_location, project_name).exists():
|
||||
project = GhidraProject.openProject(project_location, project_name, True)
|
||||
else:
|
||||
project_location.mkdir(exist_ok=True, parents=True)
|
||||
project = GhidraProject.createProject(project_location, project_name, False)
|
||||
if binary_path is not None:
|
||||
if project.getRootFolder().getFile(binary_path.name):
|
||||
program = project.openProgram("/", binary_path.name, False)
|
||||
except IOException:
|
||||
project = GhidraProject.createProject(project_location, project_name, False)
|
||||
|
||||
# NOTE: GhidraProject.importProgram behaves differently when a loader is provided
|
||||
# loaderClass may not be null so we must use the correct method override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue