EDIT: I have misread your problem, so I will modify my solution for the general case!
I think you would benefit greatly from a change in perspective. As this is a calculus problem, you want to think of convenient way to represent the triangle. So let's use a Cartesian plane to our advantage. If we place the base on the $x$ axis we have the following picture:

Notice that for a given $y \, (0 \leq y \leq h)$ the width of the rectangle is given by $x_2 - x_1$, where
$$y = \frac{h}{p} x_1$$
$$y = \frac{h}{b - p} (b - x_2)$$
This means the area of the inscribed rectangle is now $(x_2 - x_1)y$. Let's use the equations above to solve for the width as a function of $y$:
$$x_2 - x_1 = b - \frac{b}{h} y$$
Now we can rewrite the area as a one-variable function of $y$
$$A(y) = y(x_2 - x_1) = by - \frac{b}{h} y^2$$
We can now take derivatives and find our critical points for the area function. But before that, I'd like to showcase a calculus free solution. Note that $A(y)$ represents a downward facing parabola with roots at $y = 0$ and $y = h$. We know that the vertex (where $A(y)$ achieves the maximum) is located at the midpoint of the roots. So now we have the critical values of this system:
$$ y^* = \frac{0 + h}{2} = \frac{h}{2} \implies w^* = b - \frac{b}{h} \frac{h}{2} = \frac{b}{2}$$
Now we can calculate the maximum area: $$A_{\mathrm{max}} = w^* y^* = \frac{bh}{4}$$
Which is indeed half the area of the triangle.
If you prefer calculus, we can calculate the first and second derivatives of $A(y)$:
$$\frac{dA}{dy} = -\frac{2b}{h} y + b$$
$$\frac{d^2A}{dy^2} = -\frac{2b}{h}$$
We can set the first derivative to zero and solve the resulting linear equation:
$$\frac{dA}{dy} = 0 \implies y = \frac{h}{2}$$
Therefore $y^* = h/2$ is the critical value. This critical value is guaranteed to correspond to a maximum of $A(y)$ since the second derivative is negative for all $y$. Now simply calculate $w^*$ and $A_\mathrm{max}$ in the same manner as above.
I hope this helps. Sorry for any confusion from my earlier solution.