MS Detours[1] makes this easy in win32 processes. Stuff like this is useful for reverse engineers when prototyping hacks, security research, hooking kernel-level calls for e.g. packet filtering or AV, etc. Note that your run-of-the-mill antivirus will detect this, hacking processes in production is much harder.
Here's an article describing how to do it by hand the naive way, they use minesweeper as the target: [2]
Here's an article describing how to do it by hand the naive way, they use minesweeper as the target: [2]
[1] http://research.microsoft.com/en-us/projects/detours/ [2] http://uninformed.org/?v=1&a=7