I don't think this is best practice, but it should work if you put it in an include file that is included wherever the function you want to change is called:
The MyCreateFile implementation looks something like this:
#undef CreateFile HRESULT MyCreateFile(NobodyCanRememberParamListsLikeThat params) { if (InputIsNormalFile()) CreateFile(params); else
Basically, you make every CreateFile call with a MyCreateFile call, where you can decide whether you want to use your own implementation or the original one.
Disclaimer: I think doing it is ugly and I would not do it. I would prefer to search and replace all occurrences or something like that.
Maximilian
source share