socram8888 / tonyhax

PS1 savegame exploit
Do What The F*ck You Want To Public License
436 stars 25 forks source link

Redundant ExitCriticalSection? #149

Closed alex-free closed 10 months ago

alex-free commented 1 year ago

https://github.com/socram8888/tonyhax/blob/62b4213b43d4d7648b5d5547d0693c6e17057da9/loader/secondary.c#L254 does ExitCriticalSection(), but at https://github.com/socram8888/tonyhax/blob/62b4213b43d4d7648b5d5547d0693c6e17057da9/loader/bios.c#L73 it is said that the SetConf function already does this. I tried removing this in my fork and it works as expected.

socram8888 commented 1 year ago

Hmmm I'll check when I have some time if SetConf indeed reenables the interrupts, because it doesn't say so in the no$psx documentation (https://problemkaputt.de/psx-spx.htm)

alex-free commented 1 year ago

Hmmm I'll check when I have some time if SetConf indeed reenables the interrupts, because it doesn't say so in the no$psx documentation (https://problemkaputt.de/psx-spx.htm)

Cool. I just also noticed that since you call setconf in the bios_reinitialize() function as well, the proceeding exitcriticalsection() in that function after the setconf() may also be redundant.

socram8888 commented 10 months ago

I've checked and I can confirm the ExitCriticalSection is indeed issued by the SetConf call.

I've removed the one in the secondary.c file in 15290674f817aad0278a0f5829a1b04a77172f58.

The one in bios_reinitialize must stay however, since FakeEnqueueCdIntr skips the execution of the entire nested function which performs the CD initialization and also reactivation of the interrupts.