vsariola / sointu

Fork of 4klang that can target 386, amd64 and WebAssembly. Tools run on Windows, Mac & Linux
MIT License
239 stars 15 forks source link

Possible restore bug in `su_load_gmdls` #130

Closed mrange closed 4 months ago

mrange commented 5 months ago

Hi.

Big fan of the sound and size of sointu. I thought I noticed one possible issue in su_load_gmdls.

In my version it does

mov     ebx, su_sample_table

but AFAICT it doesn't restore ebx.

In certain configs this fails for me as calling code don't expect rbx to be modified.

When I removed that row and instead

push    ebx

does this:

push    su_sample_table

it seems to resolve the issue for me.

So I have a workaround so it's not a big issue for me.

vsariola commented 5 months ago

Oops. I need to read more carefully what the 32-bit calling convention says. Thanks for reporting!

vsariola commented 5 months ago

Pushad / Popad is also only two bytes (uncompressed) so that might also work

vsariola commented 4 months ago

Should be fixed. Please test and report if this continues to be an issue.

vsariola commented 4 months ago

I push most of the arguments to ReadFile first so we can use only eax (which is free to trash) for the su_sample_table pointer; this way I don't have to trust OpenFile not touching anything if its implementation changes. Only the return value of OpenFile is pushed after its called.

mrange commented 4 months ago

Hi. I will make a try to see if it works. Thanks.