You can either
- borrow cash now convert it and enter a forward contract for the stock in ccy2 and repay your loan at maturity
- invest your cash at the domestic risk free rate and buy the stock at maturity.
If there is no arbitrage between domestic and foreign markets, the two strategy lead to you receiving the stock 100% of the time so their cost should be the same.
In the first strategy, if $D$ is the total value at time $T$ of the dividends received by a stock holder between $t$ and $T$ then you need to pay
$$
\frac{S_t}{P_2(t,T)} - D \qquad P_2(t,T) = (1+r_2)^{-1}
$$
at time $T$ in ccy2 so you need to invest
$$
P_2(t,T)(\frac{S_t}{P_2(t,T)} - D)
$$
at the risk free rate $r_2$ to get this amount at time $T$. So you need to convert
$$
X_t (S_t - P_2(t,T)D)
$$
at time $t$ in domestic ccy 1 to fund the strategy. So at time $T$ you have to repay
$$
\frac{X_t}{P_1(t,T)} (S_t - P_2(t,T)D) = X_t\frac{P_2(t,T)}{P_1(t,T)} (\frac{S_t}{P_2(t,T)} - D)
$$
in domestic ccy 1. $X(t,T)$ is the forward FX rate. So the price of your quanto forward contract at time $t$ for maturity $T$ in ccy 1 is the price of the foreign contract times the forward FX rate $X(t,T) = X_t\frac{P_2(t,T)}{P_1(t,T)}$.