zeroKilo / XEXLoaderWV

Ghidra Loader Module for X360 XEX Files
112 stars 13 forks source link

Error importing file to project with latest version #7

Closed dontdeadopeninside closed 3 years ago

dontdeadopeninside commented 4 years ago

Error importing file: default.xex java.io.IOException: java.io.IOException: Invalid position, index: 19071377, max is: 262144 at xexloaderwv.XEXLoaderWVLoader.load(XEXLoaderWVLoader.java:57) at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:346) at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:83) at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:112) at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:401) at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351) at ghidra.util.task.TaskLauncher$1.run(TaskLauncher.java:90) at ghidra.util.task.Task.monitoredRun(Task.java:126) at ghidra.util.task.TaskRunner.lambda$startTaskThread$1(TaskRunner.java:94) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) Caused by: java.io.IOException: Invalid position, index: 19071377, max is: 262144 at ghidra.app.util.bin.ByteArrayProvider.assertValidIndex(ByteArrayProvider.java:95) at ghidra.app.util.bin.ByteArrayProvider.readBytes(ByteArrayProvider.java:108) at ghidra.app.util.bin.BinaryReader.readInt(BinaryReader.java:637) at xexloaderwv.NTHeader.(NTHeader.java:16) at xexloaderwv.XEXHeader.ProcessPEImage(XEXHeader.java:357) at xexloaderwv.XEXLoaderWVLoader.load(XEXLoaderWVLoader.java:49) ... 11 more


Build Date: 2020-Feb-12 1149 EST Ghidra Version: 9.1.2 Java Home: C:\Program Files\AdoptOpenJDK\jdk-12.0.2.10-hotspot JVM Version: AdoptOpenJDK 12.0.2 OS: Windows 10 10.0 amd64 Workstation: DESKTOP.mshome.net

zeroKilo commented 4 years ago

well all this tells is that it read some invalid size somewhere java.io.IOException: java.io.IOException: Invalid position, index: 19071377, max is: 262144 at xexloaderwv.XEXLoaderWVLoader.load(XEXLoaderWVLoader.java:57) I cant help much unless you can provide the file you tried to load

PS: have you tried to toggle the option devkit? you have to know in advance if your xex is devkit or retail, I havent found a way to detect that yet

dontdeadopeninside commented 4 years ago

default.zip This is the file I am trying to use. I have tried it with and without the devkit option selected. It should run on retails.

zeroKilo commented 4 years ago

hi, indeed this crashes, this also happens for all other encrypted xex that I have, after some debugging it seems the AES decryption fails. You can see from my commits, that I didnt changed anything related to that, so im not sure yet where to go with this, but I will look more into it as soon as I have more time

greetz

illusion0001 commented 3 years ago

Decrypting the executable before loading with xextool may be an option here.

zeroKilo commented 3 years ago

so, I thoroughly looked into this file, its a firmware update, its signed by m$ (so not dev kit), the decryption works fine, the deblocking works fine, so key is correct, but once it should decompress the blocks, the result is garbage. so maybe it uses a different compression (unlikely) or it was created wrong. in any case, this made me add more debug output about the xex header (if you run it from eclipse). I guess this can be closed, as this is kinda an invalid file as far as I see

greetz