@@ -102,50 +102,11 @@ PyGhidra 3.0.0 (compatible with Ghidra 12.0 and later) introduces many new Pytho
102102methods with the goal of making the most common Ghidra tasks quick and easy, such as opening a
103103project, getting a program, and running a GhidraScript. Legacy API functions such as
104104` pyghidra.open_program() ` and ` pyghidra_run_script() ` have been deprecated in favor of the new
105- methods. Below is an example program that showcases some of the new API functionality. See the
106- PyGhidra library README for more information.
107- ``` python
108- import os, jpype, pyghidra
109- pyghidra.start()
110-
111- # Open/create a project
112- with pyghidra.open_project(os.environ[" GHIDRA_PROJECT_DIR" ], " ExampleProject" , create = True ) as project:
113-
114- # Walk a Ghidra release zip file, load every decompiler binary, and save them to the project
115- with pyghidra.open_filesystem(f " { os.environ[' DOWNLOADS_DIR' ]} /ghidra_11.4_PUBLIC_20250620.zip " ) as fs:
116- loader = pyghidra.program_loader().project(project)
117- for f in fs.files(lambda f : " os/" in f.path and f.name.startswith(" decompile" )):
118- loader = loader.source(f.getFSRL()).projectFolderPath(" /" + f.parentFile.name)
119- with loader.load() as load_results:
120- load_results.save(pyghidra.monitor())
121-
122- # Analyze the windows decompiler program for a maximum of 10 seconds
123- with pyghidra.program_context(project, " /win_x86_64/decompile.exe" ) as program:
124- analysis_props = pyghidra.analysis_properties(program)
125- with pyghidra.transaction(program):
126- analysis_props.setBoolean(" Non-Returning Functions - Discovered" , False )
127- analysis_log = pyghidra.analyze(program, pyghidra.monitor(10 ))
128- program.save(" Analyzed" , pyghidra.monitor())
129-
130- # Walk the project and set a property in each decompiler program
131- def set_property (domain_file , program ):
132- with pyghidra.transaction(program):
133- program_info = pyghidra.program_info(program)
134- program_info.setString(" PyGhidra Property" , " Set by PyGhidra!" )
135- program.save(" Setting property" , pyghidra.monitor())
136- pyghidra.walk_programs(project, set_property, program_filter = lambda f , p : p.name.startswith(" decompile" ))
137-
138- # Load some bytes as a new program
139- ByteArrayCls = jpype.JArray(jpype.JByte)
140- my_bytes = ByteArrayCls(b " \xaa\xbb\xcc\xdd\xee\xff " )
141- loader = pyghidra.program_loader().project(project).source(my_bytes).name(" my_bytes" )
142- loader = loader.loaders(" BinaryLoader" ).language(" DATA:LE:64:default" )
143- with loader.load() as load_results:
144- load_results.save(pyghidra.monitor())
145-
146- # Run a GhidraScript
147- pyghidra.ghidra_script(f " { os.environ[' GHIDRA_SCRIPTS_DIR' ]} /HelloWorldScript.java " , project)
148- ```
105+ methods, which are outlined at https://pypi.org/project/pyghidra .
106+
107+ The default Python scripting engine has been changed in Ghidra 12.0 from Jython to PyGhidra.
108+ Existing Jython scripts will need to include the ` # @runtime Jython ` script header in order to
109+ continue running within the Jython environment.
149110
150111## Z3 Concolic Emulation and Symbolic Summary
151112We've added an experimental Z3-based symbolic emulator, which runs as an "auxiliary" domain to the
0 commit comments