Um ... are we talking about FF7Music here? Well...
Basically, FF7 uses an *incredibly crap* method of decoding midis. It loads the midi itself, decodes it into various 'messages' (messages like 'play this note', 'use this instrument', etc.) itself, then streams these messages through to WinMM (Windows MultiMedia, the /old/ non-DirectX way of doing audio), WinMM then passes them onto the sound card drivers.
This is really, really bad because Windows has functions builtin to play MIDI files, including all that decoding into messages rubbish ... so why not use them? No reason - they just didn't.
Anyway - what FF7Music does is put a DLL in the FF7 folder called WinMM.DLL. So when FF7 tries to load the WinMM code, it gets my library rather than than version in Windows\System. My code then examines the messages that are going through and hopefully works out what song it is from those (by looking at which instruments it uses and notes it's playing...). Once you've got that, well, it's easy to play an MP3 instead or something. The problem, of course, is that because you're almost emulating a part of Windows, doing anything slightly wrong tends to cause crashes all over the place (not in Windows, it's not that bad, but in FF7). Also, it's not guaranteed to actually identify the song correctly, too.