Hacker News new | ask | show | jobs
by comex 4155 days ago
Not quite - what matters (normally) is the address of the symbol, not the bytes located there, since in the case of a real function those bytes would be the instructions. So this will either execute the bytes at &main as instructions (4 zero bytes, and whatever follows), or, more likely, crash due to memory protections, as described in the article.
1 comments

Yup. You can get a working program with the simple:

  const int main = 0xC3;
...which is just a return. Or you can get fancy and make it exit successfully by clearing eax first:

  const int main = 0xC3C031;