flat assembler
Message board for the users of flat assembler.
Index
> Tutorials and Examples > get size of function |
Author |
|
revolution 17 Mar 2014, 07:16
If you store the function length before the function entry point then you can simplify the code to something like this:
Code: dd func1.size func1: push ebp mov ebp,esp invoke printf,msg,0 add esp,8 mov esp,ebp pop ebp ret .size = $ - func1 get_func_size: mov eax,[esp+4] mov eax,[eax-4] ret Code: mov eax,[func1-4] ;get the size of func1 Code: start: invoke printf,msg,dword[func1-4] add esp, 8 invoke getch invoke exit |
|||
17 Mar 2014, 07:16 |
|
taeyun 17 Mar 2014, 07:32
revolution wrote: If you store the function length before the function entry point then you can simplify the code to something like this: good idea thanks I wonder if you have an idea on how to insert or remove(flexible size) to function. and get flexible size. will you let me know if you know? _________________ influenced by elements(Euclid) rules for the direction of the mind(Descartes) |
|||
17 Mar 2014, 07:32 |
|
revolution 17 Mar 2014, 07:41
What do you mean by "flexible size"?
|
|||
17 Mar 2014, 07:41 |
|
taeyun 17 Mar 2014, 07:57
revolution wrote: What do you mean by "flexible size"? I would like to modify function on runtime It may change function's size the flexible size I mentioned is size of the function which is modifiable. (function which may change its content) thanks for your replying anyway~! _________________ influenced by elements(Euclid) rules for the direction of the mind(Descartes) |
|||
17 Mar 2014, 07:57 |
|
revolution 17 Mar 2014, 08:06
Do you mean to self modifying code (SMC)?
Anyhow, if you lengthen/shrink the function then you can adjust the .size value stored in memory also. Of course your code section must be writeable. BTW: SMC generally performs very poorly on a caching CPU. Just saying. |
|||
17 Mar 2014, 08:06 |
|
taeyun 17 Mar 2014, 09:00
revolution wrote: Do you mean to self modifying code (SMC)? thanks for your reply if I want to lengthen 1 instruction, then do I need to get the instruction's size and recalculate the size? I wonder how can I get the instruction's size ? thanks _________________ influenced by elements(Euclid) rules for the direction of the mind(Descartes) |
|||
17 Mar 2014, 09:00 |
|
baldr 17 Mar 2014, 12:03
taeyun wrote: I wonder how can I get the instruction's size ? Modifying the code in binary form is a non-trivial task at least. Are you familiar with disassembling? |
|||
17 Mar 2014, 12:03 |
|
cod3b453 17 Mar 2014, 17:26
If you're only writing code ("modification" is still possible if you write the same code with different values over the top.), you could even invoke/include FASM to do the instruction encoding for you; the output would tell you the size, avoiding the need for a "compatible" disassembler.
|
|||
17 Mar 2014, 17:26 |
|
taeyun 17 Mar 2014, 18:36
what about to use script language such as ruby.
To make a 'opcode and size table.txt' and refer them to modifying and recalculate size of function? would it be complicate? |
|||
17 Mar 2014, 18:36 |
|
taeyun 17 Mar 2014, 18:38
baldr wrote:
I wonder how 'length disassembler' works. maybe it refer some table?(opcode and size table) _________________ influenced by elements(Euclid) rules for the direction of the mind(Descartes) |
|||
17 Mar 2014, 18:38 |
|
m3ntal 18 Mar 2014, 00:35
Quote: store the function length before the function entry point Quote: you don't even need a separate function to get the size taeyun: Why are you interested in self-modifiable code? What are you trying to load and execute? I'd love to see examples of dynamic recompilation, especially converting to/from ARM and I32. Who can convert ARM instructions like ldr to/from I32? I have a native ARM assembler partially working in bare metal but am not prepared to post. |
|||
18 Mar 2014, 00:35 |
|
typedef 24 Aug 2014, 07:55
m3ntal wrote: I have a native ARM assembler partially working in bare metal but am not prepared to post. |
|||
24 Aug 2014, 07:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.