Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Ghidra/Getting Started.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Pre-requisites
Download and install [Ghidra](https://ghidra-sre.org/)
Download and install [Ghidra](https://ghidra-sre.org/).
They have an installation guide and some additional depdendencies themselves (Java runtime).

Afterwards, ensure that you can **launch PyGhidra.**

# Getting started with a new project
`File -> New Project` or press `Ctrl+N`<br>
`Non-Shared Project` is fine, then click `Next >>`<br>
Expand Down Expand Up @@ -38,15 +40,16 @@ Note that after each patch, you'll have to re-import, re-analyze, and re-run any
<p align="center"><img src=".\images\Project Window Multi.png"></p>

# Script dependency installation:
We use [..\ida\ffxiv_idarename.py](../ida/ffxiv_idarename.py) to apply data.yml. The same script works for both IDA and Ghidra, howver it's slightly more complicated in Ghidra as it uses an embedded version of jython.
We use [..\ida\ffxiv_idarename.py](../ida/ffxiv_idarename.py) to apply data.yml. The same script works for both IDA and Ghidra, howver it's slightly more complicated in Ghidra as we need to add dependencies to the PyGhidra environment manually.

- Install a copy of [Python 3](https://www.python.org/downloads/).<br>
Note: it has to be major version 3, so something like [Python 3.14.3](https://www.python.org/downloads/release/python-3143/) works.<br>

- Install a copy of [Python 2](https://www.python.org/downloads/).<br>
Note: it has to be major version 2, so something like [Python 2.7.18](https://www.python.org/downloads/release/python-2718/) works.<br>
- Check your PyGhidra log for "virtual environment" and copy the path. It should be something similar to this:<br>
`/home/user/.config/ghidra/ghidra_VERSION/venv`

- Execute the following:<br>
`python.exe -m pip install -t <YourGhidraFolder\>\Ghidra\Features\Jython\lib\Lib\site-packages pyyaml==5.4.1 anytree==2.8.0`<br>
Note: this must be run from Python 2. If you have multiple versions installed, you may need to qualify the path like:<br>
`c:\Python27\python.exe -m pip install -t <YourGhidraFolder\>\Ghidra\Features\Jython\lib\Lib\site-packages pyyaml==5.4.1 anytree==2.8.0`
- Execute the following, using the venv path from the log:<br>
`.../venv/bin/python -m pip install pyyaml==6.0.3 anytree==2.13.0`

- Open the Script Manager <p align="center"><img src=".\images\Open Script Manager.png"></p>

Expand Down
5 changes: 1 addition & 4 deletions ida/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ This could be either Python2 or Python3.
Additionally, you will need to place "idauser.cfg" from this repository in "%AppData%\Hex-Rays\IDA Pro\". IDA doesn't allow you to use certain characters in names and this config changes that.

#### Ghidra dependency installation:
This is slightly more complicated as Ghidra uses an embedded version of Jython.
- Install a copy of Python2 from https://www.python.org/downloads/
- Execute the following `python.exe -m pip install -t \<YourGhidraFolder\>\Ghidra\Features\Jython\lib\Lib\site-packages pyyaml==5.4.1 anytree==2.8.0`
- Add `FFXIVClientStructs\ida` as a script directory.
See [Getting Started](../Ghidra/Getting%20Started.md) for information on how to set up PyGhidra.

## ffxiv_sigmaker.py
> [!WARNING]
Expand Down
13 changes: 12 additions & 1 deletion ida/ffxiv_idarename.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# current exe version: 2020.12.29.0000.0000
# @category __UserScripts
# @menupath Tools.Scripts.ffxiv_idarename
# @runtime Jython
# @runtime PyGhidra

from __future__ import print_function
import os
Expand Down Expand Up @@ -330,6 +330,17 @@ def format_func_name(self, ea, current_func_name, proposed_func_name, class_name
except ImportError:
print("Warning: Unable to load Ghidra")
else:

# Selftest and hackfix for int / long overload conflicts in current year.
try:
toAddr(0x140000000)
except OverflowError:
import jpype.types

toAddrOrig = toAddr
def toAddr(ea):
return toAddrOrig(jpype.types.JLong(ea))

# noinspection PyUnresolvedReferences
class GhidraApi(BaseApi):
@property
Expand Down
11 changes: 6 additions & 5 deletions ida/ffxiv_structimporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @category __UserScripts
# @menupath Tools.Scripts.ffxiv_structimport
# @runtime Jython
# @runtime PyGhidra

from yaml import load

Expand Down Expand Up @@ -707,6 +707,7 @@ def should_update_virt_func(self):
from ghidra.program.model.listing import *
from ghidra.program.model.symbol import SourceType
from ghidra.app.util import SymbolPathParser
from java.util import ArrayList

except ImportError:
print("Warning: Unable to load Ghidra")
Expand Down Expand Up @@ -816,13 +817,13 @@ def get_func_by_name(self, name):
return funcs.first if not funcs.size() == 0 else None

def create_memberfunc_args(self, member_func):
# type: (DefinedStructMemFunc) -> list[ParameterImpl]
arg_vars = []
# type: (DefinedStructMemFunc) -> ArrayList
arg_vars = ArrayList()
for param in member_func.parameters:
dt = self.get_datatype(param.type)
if not dt:
return []
arg_vars.append(ParameterImpl(param.name, dt, currentProgram))
return ArrayList()
arg_vars.add(ParameterImpl(param.name, dt, currentProgram))
return arg_vars

@property
Expand Down