(C++) Disassembly Desynchronization by Unprotect

Created the Tuesday 06 December 2022. Updated 1 month, 3 weeks ago.


This code contains the original instructions mov eax, 0x12345678 and add eax, 0x00000004, but it also includes some "garbage" instructions (the nop instructions) between these two instructions. This breaks the normal sequence of instructions and can cause a disassembler to generate incorrect disassembly output.


            #include <stdio.h>

int main() {
    // Original instructions
    __asm__("mov eax, 0x12345678\n"
            "add eax, 0x00000004\n");

    // "Garbage" instructions that break the normal sequence of instructions

    // More original instructions
    __asm__("mov ebx, 0x87654321\n"
            "sub ebx, 0x00000004\n");

    return 0;