To write a hack, you have to:
1. Load a .dll you wrote into memory.
Loading your own .dll puts as much code you need into the game's address space.
2. Find a place to hook into the game's code
You want to be able to hook into the code when a certain thing happens. For example, when you pull the trigger, when you receive a network packet, when somebody builds a unit, when somebody spends money, when the user types a command, or anything like that.
3. Add a hook into the game's code
You patch over part of the code with a "call hackfunction1()", for example. hackfunction1 generally has to run whatever commands were written over, and to ensure that variables don't accidentally get changed.
That's the main idea. From your hook, you can do anything. You can change variables, call the game's functions, send packets, add to a log, etc.
Hope that helps!