<<< Previous |  |

# Doing it in C

| Unix was not designed to stop people from doing stupid things, because that would also stop them from doing clever things.
| Doug Gwyn

In the language of evil I declared the code generated by gcc to be unsuitable for a virus. And then rewrote the whole thing in assembly. A less drastic solution is to use inline assembly to correct only what's really necessary.

## System calls

Compare with In doubt use force.

Source - do_syscall.

    int do_syscall(int number, ...)
    {
      __asm__(
        "push  %ebx           ;"
        "mov   0x1C(%ebp),%edi;"
        "mov   0x18(%ebp),%esi;"
        "mov   0x14(%ebp),%edx;"
        "mov   0x10(%ebp),%ecx;"
        "mov   0x0C(%ebp),%ebx;"
        "mov   0x08(%ebp),%eax;"
        "int   $0x80          ;"
        "pop   %ebx           "
      );
    }

<<< Previous | Home |
Additional code segments |  |