Fix default Sleigh discovery on Windows

This commit is contained in:
pancake committed 2026-09-22 13:10:59 +08:00
1 parent ebd12d2536
commit 11a688481d
3 files changed
+17 -6

No files matched your search

+7 -1
View File
@@ -96,11 +96,17 @@ First, make sure you have the latest version of radare2 for Windows, which can b
Then run the following command from the radare2/bin/ directory to find out the `R2_USER_PLUGINS` path:
```
$ r2 -hh
$ r2 -H R2_USER_PLUGINS
```
Now, download the [latest r2ghidra release](https://github.com/radareorg/r2ghidra/releases) for Windows and copy the dll file in the `R2_USER_PLUGINS` directory.
Also download the matching `r2ghidra_sleigh-<version>.zip` and extract its files into
`R2_USER_PLUGINS\r2ghidra_sleigh` (the `.ldefs` files must be directly inside that directory).
The plugin finds this directory automatically, then checks `dir.plugins\r2ghidra_sleigh`
for a system installation. `SLEIGHHOME` and `e r2ghidra.sleighhome=...` remain available
for custom locations.
You should now be able to do `pdg` while in radare2 to invoke the r2ghidra decompile command.
## Building
+3 -2
View File
@@ -10,9 +10,10 @@ iwr -OutFile r2ghidra_sleigh-${V}.zip https://github.com/radareorg/r2ghidra/rele
# python -m wget https://github.com/radareorg/r2ghidra/releases/download/${V}/r2ghidra_sleigh-${V}.zip
echo "Expanding blobs"
Expand-Archive -Force -Path r2ghidra-${V}-w64.zip
Expand-Archive -Force -Path r2ghidra_sleigh-${V}.zip
Expand-Archive -Force -Path r2ghidra_sleigh-${V}.zip -DestinationPath .
echo "Installing plugin"
New-Item -ItemType Directory -Force -Path "$R2_USER_PLUGINS" | Out-Null
Remove-Item "${R2_USER_PLUGINS}\core_r2ghidra.dll"
Move-Item -Path r2ghidra-${V}-w64\core_r2ghidra.dll -Force -Destination "${R2_USER_PLUGINS}\core_r2ghidra.dll"
Remove-Item "${R2_USER_PLUGINS}\r2ghidra_sleigh"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "${R2_USER_PLUGINS}\r2ghidra_sleigh"
Move-Item -Path r2ghidra_sleigh-${V} -Force -Destination "${R2_USER_PLUGINS}\r2ghidra_sleigh"
+7 -3
View File
@@ -430,7 +430,7 @@ std::string SleighAsm::getSleighHome(RConfig * R_NULLABLE cfg) {
}
free (ev);
char *path = r_xdg_datadir ("plugins/r2ghidra_sleigh");
char *path = r_xdg_datadir (R_JOIN_2_PATHS ("plugins", "r2ghidra_sleigh"));
if (r_file_is_directory (path)) {
if (cfg) {
r_config_set (cfg, varname, path);
@@ -439,13 +439,17 @@ std::string SleighAsm::getSleighHome(RConfig * R_NULLABLE cfg) {
free (path);
return res;
}
free ((void *)path);
path = strdup (R2_PREFIX "/lib/radare2/" R2_VERSION "/r2ghidra_sleigh");
free (path);
const char *plugdir = cfg? r_config_get (cfg, "dir.plugins"): nullptr;
path = R_STR_ISNOTEMPTY (plugdir)
? r_file_new (plugdir, "r2ghidra_sleigh", nullptr)
: r_str_r2_prefix (R_JOIN_2_PATHS (R2_PLUGINS, "r2ghidra_sleigh"));
if (r_file_is_directory (path)) {
if (cfg) {
r_config_set (cfg, varname, path);
}
std::string res (path);
free (path);
return res;
} else {
#ifdef R2GHIDRA_SLEIGHHOME_DEFAULT