flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Furs 16 Dec 2022, 14:17
Code: call a Code: call [ExitProcess] You might ask why is the indirection needed? Because you don't know where the system library will be loaded. It's not fixed relative to your code. So the OS has an "import address table" that is a list of addresses for such functions that gets filled in when the library gets loaded. What the executable stores is info about the function, such as its name (ExitProcess). It then looks it up and fills the value at [ExitProcess] with its actual address, so you can call it in code. So "ExitProcess" itself does not point to the system code, it points to the import address in your binary. It's the qword value obtained from where it points to that points to the system code. If you wanted something similar with "a" you'd do e.g.: Code: lea rax, [a] mov [MyIndirectVar], rax ... call [MyIndirectVar] ... MyIndirectVar dq 0 |
|||
![]() |
|
songjiangshan 16 Dec 2022, 14:25
thanks.
but why can't we just do this: ;lea rax, [a] ;call qword [rax] while we can do this: ;mov rax, ExitProcess ;call qword [rax] Furs wrote:
|
|||
![]() |
|
songjiangshan 16 Dec 2022, 14:39
@Furs
thanks, be figured out: ;this works fine ;call a ;this works too ;lea rax, [a] ;mov [MyIndirectVar], rax ;lea rax, [MyIndirectVar] ;call qword [MyIndirectVar] ; this works three ;lea rax, [a] ;mov [MyIndirectVar], rax ;lea rax, [MyIndirectVar] ;call qword [rax] ;this do not work: ;lea rax, [a] ;call qword [rax] |
|||
![]() |
|
AsmGuru62 16 Dec 2022, 17:29
There are very useful macro statements in the file "win64...inc".
There is macro 'invoke' which will solve your calls properly. You also using your own function prologue/epilogue -- there are macro proc/endp which take care of local variables and stack alignment. Why not use those? |
|||
![]() |
|
Furs 17 Dec 2022, 18:51
songjiangshan wrote: @Furs Code: ExitProcess dq actual_address_to_the_function_after_runtime_load |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.