delphi - How do I raise an exception in an asm block? -
i want raise exception in x64 asm block.
lets assume have function so:
function example(values: array of integer): integer; asm or rcx,rcx jz @error ....
i know can read pointer , av, want raise more descriptive error.
i make additional function , call one:
asm or rcx,rcx jz @error .... @error: mov ecx, 1 mov rdx, errorstring jmp raiseerror .... function raiseerror(code: integer; const msg: string); begin case code of 1: raise eemptyarrayerror.create(msg);
however error occur outside function in caused. how exception (seem to) originate inside example
function.
note x64, seh answers apply x86 no because x64 uses veh.
the full syntax of raise is:
raise exception @ address
all need pass current ip parameter , error proc can pass on exception.
you can rip using lea rax, [rip]
.
thus code becomes:
asm or rcx,rcx jz @error .... @error: mov ecx, 1 mov rdx, errorstring lea r8,[rip] jmp raiseerror .... function raiseerror(code: integer; const msg: string; address: pointer); begin case code of 1: raise eemptyarrayerror.create(msg) @ address;
of course in case it's easier use
function raiseerror(code: integer; const msg: string); begin case code of 1: raise eemptyarrayerror.create(msg) @ returnaddress;
note
in case if keep jmp error seem originate calling routine, in case that's correct. if want exception point guilty finger @ asm code use call.
Comments
Post a Comment