There's a description of techniques in "Windows Programming for Experts" by Jeffrey Richter. But if you don't want to buy it (I recommend it though), here's a quick synopsis.

You get the address of the function. At this address you grab the first few bytes and replace them by a jump instruction to your code. Your code then executes. At the end you execute the bytes you took away and jump back to the next address.