Search code examples
assemblyida

How can I add assembler instructions between disassembled code in IDA/Olly?


I disassembled file into IDA/OllyDbg. How can I add some instructions in disassembled code? If I double-click on instruction, I can change it, but I want add instruction between exists instructions. Can anybody help me?


Solution

  • it is not possible to add new instructions in the middle without destroying old instruction

    the only proper way to add instruction is to detour to an empty place from existing instruction and jump back.

    existing instruction

    401023 xxxxxxx
    401028 xxxxxxx
    
    new instuctions placed at an empty area
    
    404023  yyyyy 
    .......zzzzz
    ..........cccccccccc
    restore old instruction destroyed by detoru jmp
    ...... jmp 401028
    

    now at 401023 you assemble jmp 404023 destroying one instruction
    at 404023 you add all other instruction you want to add
    at the end you restore the destroyed instruction at 401023 and jmp back to 401028