feat(templates): remove etc/drivers from gm.dls to optimize size

This commit is contained in:
vsariola 2021-03-19 18:46:22 +02:00
parent 38c0cea40f
commit 0f34674d7f

View File

@ -9,16 +9,12 @@
sub rsp, 40 ; Win64 ABI requires "shadow space" + space for one parameter. sub rsp, 40 ; Win64 ABI requires "shadow space" + space for one parameter.
mov rdx, qword su_sample_table mov rdx, qword su_sample_table
mov rcx, qword su_gmdls_path1 mov rcx, qword su_gmdls_path1
su_gmdls_pathloop: xor r8,r8 ; OF_READ
xor r8,r8 ; OF_READ push rdx ; &ofstruct, blatantly reuse the sample table
push rdx ; &ofstruct, blatantly reuse the sample table push rcx
push rcx call OpenFile ; eax = OpenFile(path,&ofstruct,OF_READ)
call OpenFile ; eax = OpenFile(path,&ofstruct,OF_READ) pop rcx
pop rcx pop rdx
add rcx, su_gmdls_path2 - su_gmdls_path1 ; if we ever get to third, then crash
pop rdx
cmp eax, -1 ; ecx == INVALID?
je su_gmdls_pathloop
movsxd rcx, eax movsxd rcx, eax
mov qword [rsp+32], 0 mov qword [rsp+32], 0
mov r9, rdx mov r9, rdx
@ -27,20 +23,15 @@
add rsp, 40 ; shadow space, as required by Win64 ABI add rsp, 40 ; shadow space, as required by Win64 ABI
ret ret
{{else}} {{else}}
mov edx, su_sample_table mov ebx, su_sample_table
mov ecx, su_gmdls_path1 push 0 ; OF_READ
su_gmdls_pathloop: push ebx ; &ofstruct, blatantly reuse the sample table
push 0 ; OF_READ push su_gmdls_path1 ; path
push edx ; &ofstruct, blatantly reuse the sample table call _OpenFile@12 ; eax = OpenFile(path,&ofstruct,OF_READ) // should not touch ebx according to calling convention
push ecx ; path
call _OpenFile@12 ; eax = OpenFile(path,&ofstruct,OF_READ)
add ecx, su_gmdls_path2 - su_gmdls_path1 ; if we ever get to third, then crash
cmp eax, -1 ; eax == INVALID?
je su_gmdls_pathloop
push 0 ; NULL push 0 ; NULL
push edx ; &bytes_read, reusing sample table again; it does not matter that the first four bytes are trashed push ebx ; &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 3440660 ; number of bytes to read
push edx ; here we actually pass the sample table to readfile push ebx ; here we actually pass the sample table to readfile
push eax ; handle to file push eax ; handle to file
call _ReadFile@20 ; Readfile(handle,&su_sample_table,SAMPLE_TABLE_SIZE,&bytes_read,NULL) call _ReadFile@20 ; Readfile(handle,&su_sample_table,SAMPLE_TABLE_SIZE,&bytes_read,NULL)
ret ret
@ -50,8 +41,6 @@ extern _ReadFile@20 ; requires windows
{{.Data "su_gmdls_path1"}} {{.Data "su_gmdls_path1"}}
db 'drivers/gm.dls',0 db 'drivers/gm.dls',0
su_gmdls_path2:
db 'drivers/etc/gm.dls',0
{{end}} {{end}}
{{.SectBss "susamtable"}} {{.SectBss "susamtable"}}