-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to recover sections from segment only binaries #29
Comments
There's also a funny side-effect of the name stripping... Ghidra shows... (!!) 1491 (!!) strings in the Strings View and all of them are empty! They are also useless as I can't jump to any of them (nOt In PrOgRaM mEmOrY). Now then, regarding the actual issue we're discussing...
Of course, I had to define
Technically, we can include the typedefs for these types too, but I wouldn't mind seeing just uints there. |
Lego Harry Potter is a different case, I think it's good to keep it here but I'm just pointing that out. Lego Harry Potter has sections but they are nameless, this issue was created for games where only segments are present (so you'd have 3 or 4 segments total instead of a bunch of unnamed sections) I also like the idea of having this plugin resolve NIDs, but one thing at a time :P the resolve nids script is currently broken but there's a PR that fixes it for the time being pspdev/psp-ghidra-scripts#15 |
I completely agree with you! This is why I believe we should probably start with the games where the sections were not merged, then move to the harder cases like Danganronpa. |
A proper issue for the suggestion I filed in issue #28, I'll copy-paste for convenience:
"Would also be cool if we could recover the NID related sections (
.lib.ent
,.lib.stub
,.rodata.sceModuleInfo
,.rodata.sceResident
and.rodata.sceNid
) so we can use the NIDresolver script on these programs too.Recovering any other section (say
.rodata
,.ctors
,.dtors
,.eh_frame
etc) would be entirely optional"Now, I gathered some info that can be useful for this task, so bear with me:
The easiest section to recover would be
.rodata.sceModuleInfo
, because it's address is set in segment's 0p_paddr
field and it always has this structure:With this info we can figure where are
.lib.ent
and.lib.stub
too, the fieldexports
points to the start.lib.ent
and the fieldexp_end
points to the end of it, similarly, the fieldimports
points to the start oflib.stub
andimp_end
points to the end of it.Strictly speaking, both
.lib.ent
andlib.stub
are surrounded by a small 4 byte section that delimits the top and bottom, these marker sections append a.top
or.btm
at the end of the respective parent sections, like so:but not sure if the top and btm section recovery is very worth.
Anyway,
.lib.ent
has the exports info andlib.stub
has the imports info, they are basically an array of the following structs:After those we are only missing
.rodata.sceResident
and.rodata.sceNid
, which would need some parsing to get:For
.rodata.sceNid
we need to parse.lib.stub
, if we sumvar_count
andfunc_count
for each element of.lib.stub
get the size (inint
s) of.rodata.sceNid
and the start of it it's the lowest value of the fieldnids
Lastly,
.rodata.sceResident
, this one has 2 parts:uint
followed by a null terminatedstring
/char
array (with padding zeros so it's 4byte aligned), the array item count is the same item count as the array for.rodata.sceNid
.lib.ent
, summingvar_count
andfunc_count
multiplying by 2 we get the size (inint
s) for this partthe start of
.rodata.sceResident
would be the lowest address in thename
field of.lib.stub
minus 4Anyway, some other sections can probably be figured out too (like
.sceStub.text
) but I guess these are the more useful ones, sorry for the long issue text :PI must also say that in the case of Danganronpa 2 the segments were kinda in order, but I guess we can't trust that to be case for every game.
The text was updated successfully, but these errors were encountered: