fix(templates): avoid clobbering ebx in su_load_gmdls

Fixes #130
This commit is contained in:
5684185+vsariola@users.noreply.github.com 2024-02-16 20:06:28 +02:00
parent c08a319eb7
commit 6d3c65e11d
2 changed files with 13 additions and 7 deletions

View File

@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Dbgain unit, which allows defining the gain in decibels (-40 dB to +40dB)
### Fixed
- 32-bit su_load_gmdls clobbered ebx, even though __stdcall demands it to be not
touched
## v0.3.0
### Added
- Scroll bars to menus, shown when a menu is too long to fit.

View File

@ -23,15 +23,17 @@
add rsp, 40 ; shadow space, as required by Win64 ABI
ret
{{else}}
mov ebx, su_sample_table
push 0 ; OF_READ
push ebx ; &ofstruct, blatantly reuse the sample table
push su_gmdls_path1 ; path
call dword [__imp__OpenFile@12]; eax = OpenFile(path,&ofstruct,OF_READ) // should not touch ebx according to calling convention
mov eax, su_sample_table
; these are the arguments for ReadFile
push 0 ; NULL
push ebx ; &bytes_read, reusing sample table again; it does not matter that the first four bytes are trashed
push eax ; &bytes_read, reusing sample table again; it does not matter that the first four bytes are trashed
push 3440660 ; number of bytes to read
push ebx ; here we actually pass the sample table to readfile
push eax ; here we actually pass the sample table to readfile
; these are for OpenFile
push 0 ; OF_READ
push eax ; &ofstruct, blatantly reuse the sample table
push su_gmdls_path1 ; path
call dword [__imp__OpenFile@12]; eax = OpenFile(path,&ofstruct,OF_READ)
push eax ; handle to file
call dword [__imp__ReadFile@20] ; Readfile(handle,&su_sample_table,SAMPLE_TABLE_SIZE,&bytes_read,NULL)
ret