Ore Deposit Identification
This is the classic description of a porphyry copper-molybdenum deposit.
What happens is that there is a magmatic intrusion (the porphyry), which then solidifies. When it solidifies, it expels acidic hydrothermal fluids which carry metals in them - most often copper (represented by chalcopyrite) but also sometimes molybdenum (represented by molybdenite).
Once the fluids hit solid rocks, they react with it, and become neutralised. The carrying capacity of the fluids diminish, and they deposit the metals into the minerals you observe. The solid rocks can be pretty much anything. It can be the porphyry itself, another porphyry that happened to be around, sedimentary rocks, or whatever.