Il2CppInspector icon indicating copy to clipboard operation
Il2CppInspector copied to clipboard

Ghidra script failing to complete both with and without auto-analysis

Open ffvdgames opened this issue 3 years ago • 1 comments

I'm attempting to decompile a dll with Ghidra and I'm having some difficulty getting the script I got from the GUI to run properly. I've spent days trying and re-trying everything I can think of, and I'm pretty sure I've followed the provided tutorials properly, so the only conclusions I can come up with are either I've missed something important, the dll's encrypted/obfuscated and I don't know it, or there's something funky going on with the tool.

Game in question is SaGa Frontier Remastered, which was made with 2019.4.16f1. There are .c, .h, and what I believe are PlayStation 1 ASM files, or at least files extracted from a PS1 .bin image, packaged into the dll (globalgamemanagers.assets says Assembly-CSharp, specifically), which may be what's causing the script to fail. I doubt the dll is obfuscated/encrypted since I was able to properly generate global.c and dummy dll's and get some good information out of them, but not any real code or the not C# files I was really looking for.

When I run the script without auto-analysis, it gives me two command failures in a blank window after a couple minutes, then an unexpected error after a few more minutes that I can't see the log output of because the program becomes almost entirely unresponsive, forcing me to end it in task manager. Literally the only thing it'll let me do at that point is drag around the unexpected error window. I would assume it's a timeout error since the script from IL2CppDumper also gives me the same issue. No clue if that's a ghidra issue, a me issue, or something else weird, though.

When I run the script again with auto-analysis, it gets all the way to the IL2CPP metadata stage until it spits out an error and quits:

Traceback (most recent call last):
  File "H:\extraction tools\Il2CppInspector-2021.1\il2cpp.py", line 220, in <module>
    ProcessJSON(jsonData)
  File "H:\extraction tools\Il2CppInspector-2021.1\il2cpp.py", line 197, in ProcessJSON
    DefineField(d['virtualAddress'], d['name'], d['type'])
  File "H:\extraction tools\Il2CppInspector-2021.1\il2cpp.py", line 119, in DefineField
    SetType(addr, AsUTF8(type))
  File "H:\extraction tools\Il2CppInspector-2021.1\il2cpp.py", line 60, in SetType
    createData(addr, t)
	at ghidra.program.database.code.CodeManager.checkValidAddressRange(CodeManager.java:1945)
	at ghidra.program.database.code.CodeManager.createCodeUnit(CodeManager.java:2030)
	at ghidra.program.database.ListingDB.createData(ListingDB.java:422)
	at ghidra.program.flatapi.FlatProgramAPI.createData(FlatProgramAPI.java:1646)
	at jdk.internal.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
ghidra.program.model.util.CodeUnitInsertionException: ghidra.program.model.util.CodeUnitInsertionException: Conflicting data exists at address 182069d98 to 182069d9f

As a sanity-check, I put global-metadata.dat in the same folder as the script and that gave me the exact same error.

Here's the binary, metadata, and generated script. Hopefully these help: saga frontier remastered - dll, metadata, script.zip

ffvdgames avatar May 24 '21 07:05 ffvdgames

Update to this: I decided to run the script one more time without auto-analysis, this time just leaving it alone for a couple hours. When I came back, the script did finish running, but the user log left me some errors:

2021-05-24 23:24:57 ERROR (Swing) Timed-out waiting to run a Swing task--potential deadlock!
Threads State:
java.lang.Throwable  
2021-05-24 23:24:57 ERROR (BackgroundCommandTask) Command Failure: An unexpected error occurred while processing the command: Auto Analysis java.lang.RuntimeException: Timed-out waiting to run a Swing task--potential deadlock!
	at ghidra.util.Swing.runNow(Swing.java:177)
	at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225)
	at ghidra.framework.data.DomainObjectChangeSupport.flush(DomainObjectChangeSupport.java:143)
	at ghidra.framework.data.DomainObjectAdapter.flushPrivateEventQueue(DomainObjectAdapter.java:308)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager$AnalysisTaskWrapper.run(AutoAnalysisManager.java:709)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:788)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:667)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:632)
	at ghidra.app.plugin.core.analysis.AnalysisBackgroundCommand.applyTo(AnalysisBackgroundCommand.java:58)
	at ghidra.framework.plugintool.mgr.BackgroundCommandTask.run(BackgroundCommandTask.java:102)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.run(ToolTaskManager.java:315)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: ghidra.util.exception.UnableToSwingException: Timed-out waiting for Swing thread lock in 20 SECONDS
	at ghidra.util.Swing.waitFor(Swing.java:256)
	at ghidra.util.Swing.runNow(Swing.java:235)
	at ghidra.util.Swing.runNow(Swing.java:163)
	... 11 more
 
2021-05-24 23:25:17 ERROR (Swing) Timed-out waiting to run a Swing task--potential deadlock!
Threads State:
java.lang.Throwable  
2021-05-24 23:25:17 ERROR (SwingExceptionHandler) Error: Uncaught Exception! 
RuntimeException - Timed-out waiting to run a Swing task--potential deadlock! java.lang.RuntimeException: Timed-out waiting to run a Swing task--potential deadlock!
	at ghidra.util.Swing.runNow(Swing.java:177)
	at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225)
	at ghidra.framework.data.DomainObjectChangeSupport.flush(DomainObjectChangeSupport.java:143)
	at ghidra.framework.data.DomainObjectAdapter.flushEvents(DomainObjectAdapter.java:245)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.taskFailed(ToolTaskManager.java:451)
	at ghidra.framework.plugintool.mgr.BackgroundCommandTask.run(BackgroundCommandTask.java:145)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.run(ToolTaskManager.java:315)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: ghidra.util.exception.UnableToSwingException: Timed-out waiting for Swing thread lock in 20 SECONDS
	at ghidra.util.Swing.waitFor(Swing.java:256)
	at ghidra.util.Swing.runNow(Swing.java:235)
	at ghidra.util.Swing.runNow(Swing.java:163)
	... 7 more
 
2021-05-24 23:44:31 DEBUG (ToolTaskManager) Exec Task Auto Analysis  
2021-05-24 23:44:51 ERROR (Swing) Timed-out waiting to run a Swing task--potential deadlock!
Threads State:
java.lang.Throwable  
2021-05-24 23:44:51 ERROR (BackgroundCommandTask) Command Failure: An unexpected error occurred while processing the command: Auto Analysis java.lang.RuntimeException: Timed-out waiting to run a Swing task--potential deadlock!
	at ghidra.util.Swing.runNow(Swing.java:177)
	at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225)
	at ghidra.framework.data.DomainObjectChangeSupport.flush(DomainObjectChangeSupport.java:143)
	at ghidra.framework.data.DomainObjectAdapter.flushPrivateEventQueue(DomainObjectAdapter.java:308)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:742)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:667)
	at ghidra.app.plugin.core.analysis.AutoAnalysisManager.startAnalysis(AutoAnalysisManager.java:632)
	at ghidra.app.plugin.core.analysis.AnalysisBackgroundCommand.applyTo(AnalysisBackgroundCommand.java:58)
	at ghidra.framework.plugintool.mgr.BackgroundCommandTask.run(BackgroundCommandTask.java:102)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.run(ToolTaskManager.java:315)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: ghidra.util.exception.UnableToSwingException: Timed-out waiting for Swing thread lock in 20 SECONDS
	at ghidra.util.Swing.waitFor(Swing.java:256)
	at ghidra.util.Swing.runNow(Swing.java:235)
	at ghidra.util.Swing.runNow(Swing.java:163)
	... 10 more
 
2021-05-24 23:45:11 ERROR (Swing) Timed-out waiting to run a Swing task--potential deadlock!
Threads State:
java.lang.Throwable  
2021-05-24 23:45:11 ERROR (SwingExceptionHandler) Error: Uncaught Exception! 
RuntimeException - Timed-out waiting to run a Swing task--potential deadlock! java.lang.RuntimeException: Timed-out waiting to run a Swing task--potential deadlock!
	at ghidra.util.Swing.runNow(Swing.java:177)
	at ghidra.util.SystemUtilities.runSwingNow(SystemUtilities.java:225)
	at ghidra.framework.data.DomainObjectChangeSupport.flush(DomainObjectChangeSupport.java:143)
	at ghidra.framework.data.DomainObjectAdapter.flushEvents(DomainObjectAdapter.java:245)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.taskFailed(ToolTaskManager.java:451)
	at ghidra.framework.plugintool.mgr.BackgroundCommandTask.run(BackgroundCommandTask.java:145)
	at ghidra.framework.plugintool.mgr.ToolTaskManager.run(ToolTaskManager.java:315)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: ghidra.util.exception.UnableToSwingException: Timed-out waiting for Swing thread lock in 20 SECONDS
	at ghidra.util.Swing.waitFor(Swing.java:256)
	at ghidra.util.Swing.runNow(Swing.java:235)
	at ghidra.util.Swing.runNow(Swing.java:163)
	... 7 more

I'm assuming these are errors with how ghidra's interpreting the script? I have no clue, to be completely honest. I'm fairly certain it has nothing to do with my computer's specs, but it might have something to do with the fact that all the files are on a usb hdd? Again, I have no clue.

ffvdgames avatar May 25 '21 07:05 ffvdgames