lab313ru / ghidra_psx_ldr

Sony Playstation PSX executables loader for GHIDRA
231 stars 31 forks source link

Incorrect segment configuration due to dubious heap initialization #51

Closed ser-pounce closed 2 years ago

ser-pounce commented 2 years ago

Vagrant Story passes 0x800401ac to InitHeap, but makes no use of system memory management and has its own separate heap.

Unfortunately 0x800401ac is right in the middle of the main exe, which occupies 0x80010000 - 0x80061fff, and due to the way psx_ldr sets up the segments the region from 0x800401a8 - 0x80061fff is configured as uninitialized when it actually contains code and data.

image

lab313ru commented 2 years ago

My loader uses templates of code generated by the psyq compiler to get correct offsets. I'll check your game binary, thanks.

ser-pounce commented 2 years ago

Thanks, let me know if you need any more info.

lab313ru commented 2 years ago

In such cases you will need to manually change segments sizes and flags.

ser-pounce commented 2 years ago

I tried that but once a segment was made uninitialised during setup I was unable to set it back to initialise it from the file. The only option was to initialise the segment to a fixed byte value, but maybe I'm missing something.

lab313ru commented 2 years ago

Now I see the problem.

lab313ru commented 2 years ago

Fixed via b9ffc67612a04211bab40c4523daf18025f9e3b7. Wait for the next release.