Ported from sacredK with module-relative addresses, hooks by exported name and a SHA-256 check of the six game modules (Community Patch 2.65.1). Borderless windowed at monitor size replaces exclusive fullscreen, whose focus loss during loading made the game quit and crash on exit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.6 KiB
PowerShell
32 lines
1.6 KiB
PowerShell
# Decompile from the persistent Ghidra project (ghidra/sacred2.gpr).
|
|
# .\tools\decompile.ps1 s2logic.dll 0x10123450 0x10123a80 [-Out file.c] [-ReadOnly]
|
|
# .\tools\decompile.ps1 orcSystem.dll "?logMessage@Log@Orc@@UAEXABVString@2@W4LogMessageLevel@2@@Z"
|
|
# Addresses are VAs at the module's preferred base (as Ghidra shows them);
|
|
# an argument that is not a number is looked up as a (decorated) symbol name.
|
|
# Prints the C to stdout (and keeps it in -Out, default ghidra\last.c).
|
|
# Without -ReadOnly, functions created for vtable-only methods are saved.
|
|
[CmdletBinding(PositionalBinding = $false)]
|
|
param(
|
|
[Parameter(Mandatory, Position = 0)][string]$Module,
|
|
[Parameter(Mandatory, ValueFromRemainingArguments)][string[]]$Addresses,
|
|
[string]$Out = "",
|
|
[switch]$ReadOnly
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path $PSScriptRoot
|
|
if (-not $Out) { $Out = Join-Path $root "ghidra\last.c" }
|
|
$ghidra = if ($env:GHIDRA_INSTALL_DIR) { $env:GHIDRA_INSTALL_DIR } else { "E:\Coding\Ghidra\ghidra_12.1.4_PUBLIC" }
|
|
if (-not $env:JAVA_HOME) { $env:JAVA_HOME = "C:\Program Files\Java\jdk-21" }
|
|
|
|
$arguments = @(
|
|
(Join-Path $root "ghidra"), "sacred2",
|
|
"-process", $Module, "-noanalysis",
|
|
"-scriptPath", (Join-Path $PSScriptRoot "ghidra"),
|
|
"-postScript", "Decompile.java", $Out
|
|
) + $Addresses
|
|
if ($ReadOnly) { $arguments += "-readOnly" }
|
|
|
|
& (Join-Path $ghidra "support\analyzeHeadless.bat") @arguments *> (Join-Path $root "ghidra\decompile.out")
|
|
if ($LASTEXITCODE -ne 0) { Get-Content (Join-Path $root "ghidra\decompile.out") -Tail 30; exit $LASTEXITCODE }
|
|
Get-Content $Out
|