flat assembler
Message board for the users of flat assembler.
Index
> Main > Changing code |
Author |
|
JohnFound 16 Feb 2015, 17:33
Simply learn and actively use the named constants...
Code: Name = 4 ...and data structures: Code: struc MyStruc { .field1 dd ? .field2 dd ? } |
|||
16 Feb 2015, 17:33 |
|
l4m2 17 Feb 2015, 08:48
JohnFound wrote: Simply learn and actively use the named constants... |
|||
17 Feb 2015, 08:48 |
|
Bargest 17 Feb 2015, 10:12
Quote: Sometimes it goes usually that we change a number in the code so that In this code you can use eax, because it will be modified anyway by the second mov command (if you don't use ah, of course). In general you should not modify your code in run-time, because memory containing code should be write-protected for security reasons. It's MUCH better to use different register and/or variables to store needed offsets: Code: mov [offset_var], eax ... mov eax, [offset_var] ; offset_var is in DATA section ; or in stack, in this case use addressing from esp/ebp mov al, [ebx + eax] |
|||
17 Feb 2015, 10:12 |
|
l4m2 17 Feb 2015, 10:45
Bargest wrote:
I just want to say that these code are in two proc and ah will be used as well as that the latter code will be ran in a loop while the former is run only once. |
|||
17 Feb 2015, 10:45 |
|
Bargest 17 Feb 2015, 10:59
In this case you can reserve one register for storing offset or load the offset from variable every time. Modifying code in run-rime is very bad practice.
Also it can be possible to store direct address in ebx without need to add anything every time. |
|||
17 Feb 2015, 10:59 |
|
l4m2 17 Feb 2015, 11:31
Bargest wrote: In this case you can reserve one register for storing offset or load the offset from variable every time. Modifying code in run-rime is very bad practice. I also know that I can use ebx to store the address but you should know that if it's not allowed to modify the code I would rather use c. Besides you should not see only the scene but also code like mul eax,[ebx],? or worse int ? and for good understanding I did it [/code] |
|||
17 Feb 2015, 11:31 |
|
revolution 17 Feb 2015, 11:51
Some AVs will panic if a program changes its own code. Self modifying code is an old school trick used by much malware.
SMC can also cause some serious performance problems if you don't take care to respect the CPU caching and internal buffers. |
|||
17 Feb 2015, 11:51 |
|
baldr 20 Feb 2015, 18:50
revolution,
Methink, caching is OK with SMC, it's prefetching and speculative execution that get in the way. |
|||
20 Feb 2015, 18:50 |
|
l_inc 20 Feb 2015, 19:43
baldr
You're right except that it happened before Pentium Pro or even Pentium. Since then x86 is very strict about coherence of all the involved buffers, which includes flushing the pipeline in case self-modification happens near the current eip. So now it's just a significant performance penalty. _________________ Faith is a superposition of knowledge and fallacy |
|||
20 Feb 2015, 19:43 |
|
l4m2 24 Feb 2015, 12:56
In fact,
Code: shr ecx, a:? Code: push ecx mov cl,[a] shr dword[ecx],cl pop ecx |
|||
24 Feb 2015, 12:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.