Skip to contentSkip to conversation

SMC article

DISCUSSION Maciej Hrebien 1 participant 2 messages Aug 6, 2004 – Aug 12, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi Karsten,

long time ago i had briefly looked at your SMC article placed at linuxassembly.org but yesterday i opened it once again (by accident) and read it more careful ;) The code is quite tricky i admire but i have one small suggestion: you write only about .bss, placing the code in and execute in it. It gives the illusion that SMC technique can only be used in .bss. I think you should consider writing something about un-mprotect-ing .text and doing SMC on it just to avoid this kind of illusion. Let me illustrate what i mean:

.set PAGE_SZ, 4096
.set PROT_RD, 1
.set PROT_WR, 2
.set PROT_EX, 4

.text

.globl _start
_start:

        mov     $125,%eax         # change protection of code seg...
        mov     $_start,%ebx
        mov     $PAGE_SZ,%ecx
        and     $~(PAGE_SZ-1),%ebx
        mov     $(PROT_RD|PROT_WR|PROT_EX),%edx
        int     $0x80
hello:
        mov     $4,%eax           # write some text...
        mov     $1,%ebx
        mov     $msg,%ecx
        mov     $msglen,%edx
        int     $0x80
        mov     $exit,%esi        # change our "hello" a little bit...
        mov     $hello,%edi
        mov     $(end-exit),%ecx
        rep     movsb

jmp hello # and print it again... ;)
exit:

        mov     $1,%eax
        xor     %ebx,%ebx
        int     $0x80

end:
msg: .ascii "hello :)\n"
msglen = .- msg
.end

Please consider my suggestion in your future update(s) of the article. With regards,

Signature · 1 line
Maciej Hrebien

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 4 lines · Daniel R. Blair

Do you have the URL of the original article? I would really like to read it.. I am not sure exactly what SMC is.. but, if you could share, I'd be much appreciative.

SMC stands for Self-Modifying Code and the article is at:
http://linuxassembly.org/articles/smc.html

Signature · 1 line
Maciej Hrebien