GhidraJupyter / ghidra-jupyter-kotlin

MIT License
115 stars 10 forks source link

Kotlin scripts fail to run on Windows #17

Closed endrin closed 3 years ago

endrin commented 3 years ago

Attempt to use KotlinScriptProvider for running scripts on Windows ends with several errors.


First one, fatal, is that compiler doesn't see classpath. Attempt to run the provided HelloWorldScriptKt.kt stops with the following error:

ERROR Unresolved reference: ghidra (KotlinCompilerMessageCollector)
ERROR Unresolved reference: GhidraScript (KotlinCompilerMessageCollector)
ERROR Unresolved reference: Throws (KotlinCompilerMessageCollector)
ERROR 'run' overrides nothing (KotlinCompilerMessageCollector)
ERROR Unresolved reference: println (KotlinCompilerMessageCollector)
ERROR REPORT SCRIPT ERROR: .\ghidra_scripts\HelloWorldScriptKt.kt : Back-end (JVM) Internal error: Failed to generate function run

This one is caused by the fact that Linux and Windows are using different characters to separate paths in the classpath system property and the character for the current platform is available as File.pathSeparator


Second one doesn't prevent execution but is rather confusing. At the compilation stage the following error is thrown, followed by a huge traceback:

WARN: Failed to initialize native filesystem for Windows
java.lang.UnsatisfiedLinkError: 'IdeaWin64.dll' not found in '(path to temp folder was here)' among null

This one is weird and its fix feels like a pure magic for me. Found the solution for it on Stack Overflow.

Anyways, these two errors require rather minor code changes, however I didn't test if these changes break something on Linux. Could you please check the linked pull request? 🙏

fmagin commented 3 years ago

Fixes seem sane, the CI run (on Linux) also ran cleanly, and a quick check with a local 10.0.2 install also seems good. Thank you very much!