If it's commercial or copyrighted, then it's probably illegal to do so anyway. And you need program source code to modify a program.
If it's Open-Source software (Like Linux) - then you have the right to obtain the source code - just go to the programs website and look for or ask about it.
However - if you don't know about source code - then you may not know how to modify a program anyway?
Or maybe you mean something quite different?