Adubbz / Ghidra-Switch-Loader

Nintendo Switch loader for Ghidra
ISC License
286 stars 43 forks source link

Analysis Task: Shared Return Calls - Index 0 out of bounds for lenght 0 #52

Closed StevensND closed 10 months ago

StevensND commented 10 months ago

Since I update to Ghidra 11 I'm having this problem (which is really annoying) and I don't know what it is due to....

Screenshot

Screenshot 2

Is it my problem, SwitchLoader's problem? Could you take a look at it?.

Thanks.

Thanks.

Captura Captura2

TSRBerry commented 10 months ago

I don't see any reference to SwitchLoader in the stacktrace. Next time please, copy and paste them into your issue in a code block, that makes it a lot easier to work with them.

It definitely looks odd, could you provide more information? What binary are you analyzing? Which Switch-Loader version are you using? Was this binary analyzed using an older Ghidra version before?

StevensND commented 10 months ago

I don't see any reference to SwitchLoader in the stacktrace. Next time please, copy and paste them into your issue in a code block, that makes it a lot easier to work with them.

It definitely looks odd, could you provide more information? What binary are you analyzing? Which Switch-Loader version are you using? Was this binary analyzed using an older Ghidra version before?

Right now I'm analyzing another game. I will copy the errors into a .txt and upload it later.

I'm analyzing a main file extracted from the game. Switch-Loader version is the one compatible with Ghidra 11.0 (I just merged the changes you did and compile it by myself).

When I used Ghidra 10.4 I didn't have these issues. So could be an issue with Ghidra 11.0?. Could you give me your Switch-Loader 11.0 version compiled to test?. Thanks.

StevensND commented 10 months ago

Here's the pastebin with the errors that I'm getting.

TSRBerry commented 10 months ago

What game are you analyzing? Could you use hactool to get the SDK version of the the nca file containing the main nso that you are analyzing?

TSRBerry commented 10 months ago

Nevermind, I'm able to reproduce this when I try to analyze the main nso of "Super Mario Bros. Wonder". I'll try to figure it out, but I'm currently pretty busy, so it might take some time.

TSRBerry commented 10 months ago

This is a Ghidra issue and was fixed just 2 weeks ago: https://github.com/NationalSecurityAgency/ghidra/blob/85d276bce0bb2055c5556825afc810d3163ed15f/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/lang/protorules/HomogeneousAggregate.java#L71-L74

The current release does not check if the result is empty and tries to access index 0 unconditionally:

if (!DatatypeFilter.extractPrimitives(dt, MAX_PRIMITIVES, null, res)) {
    return false;
}
DataType base = res.get(0);

I assume the next release will contain this fix.

StevensND commented 10 months ago

What game are you analyzing? Could you use hactool to get the SDK version of the the nca file containing the main nso that you are analyzing?

It happens with all games that I analyzed using Ghidra 11.

So it seems to be a Ghidra 11 issue then?.

Then I guess I have to stay at 10.4 for now.

StevensND commented 10 months ago

Between yesterday and today Ghidra 11.0.1 was released.

I'm testing and so far during my first test the error has disappeared. I will continue testing.

TSRBerry commented 10 months ago

The fix for this is definitely part of the new release. Search for GP-4169 here: https://htmlpreview.github.io/?https://github.com/NationalSecurityAgency/ghidra/blob/Ghidra_11.0.1_build/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.html

TSRBerry commented 10 months ago

I also retested it with the updated version and don't encounter the exceptions anymore.

And I just realized you weren't even saying that you are still getting exceptions.. :sweat_smile: Imo this issue can be closed now!

MediaMoots commented 9 months ago

@TSRBerry Is the latest release compatible with 11.0.1?

MediaMoots commented 9 months ago

Nvm, i found the latest here https://github.com/StevensND/Ghidra-Switch-Loader/releases/tag/11.0.1