And a way cool thing as well, you can call a buffer as a function
Code:
char *buffer = get_function_code_from_somewhere();

typedef long (*FUNCPTR)(int, int);

long compatible(int x, int y) {
    /* This function is compatible with the function pointer */
    return x + y;
}

void somecode() {
    FUNCPTR pfn = (FUNCPTR)buffer;

    (*pfn)(6, 7);
}
Just make sure your function has REAL instructions in it.

This is one way to make self-modifying code (modify the machine code in memory, and then write it back to the .exe file).