If you want to mod an already existing game then use riivolution. We used to rely on trucha sign bug to replace files in the game's filesystem with other files of the same or equal size. riivolution gets past the limitations of this bug (the bug is patched anyway).
If you want to code your own...