Je me souviens de "protections" de logiciels qui utilisaient cette particularité.
une instruction venait modifier une adresse de saut quelques octets plus loin (très près) ce qui en temps normal n'avait pas d'effet puisque cette adresse de saut avait déjà été décodée par le prefetch du processeur...
en cas de tentative de debug et d'execution pas par pas de ce morceau de code, le prefetch ne se fait pas, l'adresse de saut se modifie ... et on ne comprends plus rien :-)
x86 example code
code_starts_here:
mov eax, ahead
mov [eax], 0x9090
ahead:
jmp near to_the_end
; Some other code
to_the_end:
_This self-modifying program will overwrite the jmp to_the_end with two NOPs (which is encoded as 0x9090). The jump jmp near to_the_end is assembled into two bytes of machine code, so the two NOPs will just overwrite this jump and nothing else. (That is, the jump is replaced with a do-nothing-code.)
Because the machine code of the jump is already read into the PIQ, and probably also already executed by the processor (superscalar processors execute several instructions at once, but they "pretend" that they don't because of the need for backward compatibility), the change of the code will not have any change of the execution flow.
_
[^] # Re: Pour comparer les performances
Posté par PLuG . En réponse à la dépêche Kalray un processeur massivement parallèle très impressionnant : Qu’il est loin le temps de mon ZX81. Évalué à 8.
Je me souviens de "protections" de logiciels qui utilisaient cette particularité.
une instruction venait modifier une adresse de saut quelques octets plus loin (très près) ce qui en temps normal n'avait pas d'effet puisque cette adresse de saut avait déjà été décodée par le prefetch du processeur...
en cas de tentative de debug et d'execution pas par pas de ce morceau de code, le prefetch ne se fait pas, l'adresse de saut se modifie ... et on ne comprends plus rien :-)
mais je vois que même wikipedia en parle : http://en.wikipedia.org/wiki/Prefetch_input_queue
citation:
x86 example code
code_starts_here:
mov eax, ahead
mov [eax], 0x9090
ahead:
jmp near to_the_end
; Some other code
to_the_end:
_This self-modifying program will overwrite the jmp to_the_end with two NOPs (which is encoded as 0x9090). The jump jmp near to_the_end is assembled into two bytes of machine code, so the two NOPs will just overwrite this jump and nothing else. (That is, the jump is replaced with a do-nothing-code.)
Because the machine code of the jump is already read into the PIQ, and probably also already executed by the processor (superscalar processors execute several instructions at once, but they "pretend" that they don't because of the need for backward compatibility), the change of the code will not have any change of the execution flow.
_