Fix for XenonAnalyse not working for reading wrongly the base address in certain games
This PR fix XenonAnalyse for not reading properly the base address.
As you can see when i run the without my code i get this error (at least in Battlefield 2 Modern Combat, in Sonic works fine)
When i started to look every single value that XenonAnalyse read I noticed that the base address was way shorter than the intended value
As you can see it gives me "4194304" if i make the conversion it gives me in Hex "40 0000" this is going to generate a bad value in the image.entry_point.
As you can see image.entry_point = 4194304 + 1655736 -> image.entry_point = 40 0000 + 1943B8 ->
image.entry_point = 5943B8
When you look at the dumped file from Xextools you will see this
if you pay attention the value 1943B8 partially match the Entry Point(821943B8) it is missing the Load Address instead it is loading the the stacksize, i don't know why but you can see it, so the code fix that.
this is the same program loading sonic and as you can see it is giving correctly the Load Address
The value 2181038080 -> Hex 82000000
so image.base needs to take the load address value, image.base = security->loadAdress;
if we change these values in image.entry_point = 82000000 + 1943B8 -> 821943B8, this is the correct value for Battlefield and maybe every single game not only sonic.
Huh, 0x400000 actually happens to be the base address for 32-bit Windows apps so I wonder if it's like that due to it. From a quick skimming, XEX files seem to have an XEX_HEADER_IMAGE_BASE_ADDRESS optional header, so could we get the value from there instead? This PR does that: https://github.com/hedge-dev/XenonRecomp/pull/51
Yeah, after running the nithax code the optional header gives the expected values and XenonAnalyse gives the toml file
image.base = 2181038080 -> Hex 82000000
image.entry_point = 2182693816 -> Hex 821943B8
Happy to see that my logic actually makes it to work without knowing that, because I'm a complete noob (just knows the super basic, loops, pointers), i almost give up in XenonAnalyse and i was planning to start manually writting every single jump table.
I don't know if my explanation was properly made if it is too long, i know that i have orthography errors because i don't speak english but at least i'm trying, if you have any feedback let me know.
Hey there, I merged the PR I mentioned now, if that works fine for you, I assume this PR doesn't need to merged anymore?