UEFI Stack Order
Posted: Sun Jan 01, 2023 4:45 pm
I am learning UEFI (in assembly language). I have been able to clear the screen, print some stuff and exit successfully. However, I have issues with calling LocateHandle. I suspect the problem is with the way I am handling the stack and so I want to use this opportunity to understand how the stack should be.
What order should things be in when calling UEFI functions? Should I have the 5th, 6th, and 7th parameters on the stack before the shadow space or vice versa? For example should I have this
Or should I have this
If neither of these is correct, then what is the correct way to do it?
What order should things be in when calling UEFI functions? Should I have the 5th, 6th, and 7th parameters on the stack before the shadow space or vice versa? For example should I have this
Code: Select all
; UEFI parameters go on the stack in reverse order
push PARAM_7 ; Push parameter 7
push PARAM_6 ; Push parameter 6
push PARAM_5 ; Push parameter 5
sub rsp, 32 ; Required shadow space
call UEFI_function ; Call the function
Code: Select all
sub rsp, 32 ; Make shadow space
; Remaining parameters go on the stack in reverse order
push PARAM_7 ; Push parameter 7
push PARAM_6 ; Push parameter 6
push PARAM_5 ; Push parameter 5
call UEFI_function ; Call the function