Cuyler36 / Ghidra-GameCube-Loader

A Nintendo GameCube binary loader for Ghidra
Apache License 2.0
248 stars 37 forks source link

Loading Korean SMG with Korean MAP causes unintended load behavior. #76

Open break-core opened 1 year ago

break-core commented 1 year ago

Issue

I am trying to load the Korean version of Super Mario Galaxy (Super Mario Wii - Galaxy Adventure) into Ghidra, as well as loading in the Korean symbol map obtained from the NVIDIA Shield port of SMG. However, when loading it into Ghidra, I face the issue of having every symbol be incorrectly named.

Basically, when a function is loaded, the symbol loader will incorrectly assume that the function is some sort of namespace, and that there is a function inside of this namespace called "4". I would assume that this is because the function is incorrectly read (somehow), with the "4" to the left of the symbol being treated as the actual function rather than what is past the "4" in the actual map.

Repro

  1. Get a copy of the Korean version of SMG's DOL
  2. Get the Korean release symbol map (https://tcrf.net/Super_Mario_Galaxy/Chinese_NVIDIA_Shield_Port#Symbol_Maps)
  3. Have the latest version of the Ghidra Gamecube Loader installed (on Ghidra 10.3.2 at the time of writing this issue)
  4. Load the DOL in with Ghidra and then when prompted for a symbol map, load in the Korean release map.
  5. Check the "Namespaces" dropdown, and then navigate into a random function. You should see the bug appear.

Who does this effect?

Anyone who wishes to disassemble/decompile the Korean version of Super Mario Galaxy (which is the version used in popular SMG decomp projects like Petari) with Ghidra. Because all of the symbols are messed up, it is hard to navigate around.

Update

I have found a solution to this, but it is incredibly tedious. Basically, you need to remove all of the 4 numbers in front of the symbol. I have no idea why this works, despite the fact that other symbol maps do the exact opposite but eh, I'm not complaining.

vabold commented 10 months ago

Big Brain Academy: Wii Degree has the same problem. (USA, RevoYawaraka_US.SMAP)

hippietrail commented 1 month ago

Which character set / code page / encoding are they using for Korean? I can't remember for Korean, but some languages have some encodings which assign letters where ASCII assigns symbols.