How to change .code segment at runtime?

I want to write a program that can change the code segment itself. For example, consider this assembly code:

Regular code:

i1: mov eax,0
i2: mov eax,0X01

the resulting code that I want to make at runtime the same code:

i1: mov eax,0
i": // some modifing instructions that when are excuted they change the i2 and/or add or remove some instruction such i3
i2: jmp 0x32
i3: mov ebx,0x67 

you see what i2changes after executing the statement (s) i". i"required to change its shipping code instructions.

Now my questions are:

  • How to change a code segment? Or How to access a code segment memory area?
  • Do we allow changing the same code segment there (Not another program to which it does not have access)?
  • How can we solve the problems caused by resizing code segments?
  • ! , .

.

+3
1

16- v86 codeegment:

i1: inc bx         ; 43h = opcode of "INC BX"
    mov al,4Bh     ; 4Bh = opcode of "DEC BX"
    mov cs:[i1],al

0

All Articles