我正在尝试在 Linux 中进行自我修改代码。我以为它会起作用,但没有。
section .data
section .text
global _start
_start:
mov eax, 125 ;mprotect syscall number
mov ebx, _start ; *addr
mov ecx, 0x10000 ;page interval.
mov edx, 7 ; rwx permission
int 0x80
jmp modify
target:
mov eax, edx
halt:
mov ebx, 1
mov eax, 1
int 0x80
modify:
mov ebx, [new]
mov [target], ebx
jmp target
new:
mov ebx, 0
我在 ubuntu 18.04 上使用了 nasm。
INT 0x80 返回值为-22 0xffffffea
我不知道出了什么问题。