This paper concerns optimal control problems for a class of sweeping processes governed by discontinuous unbounded differential inclusions that are described via normal cone mappings to controlled moving sets. Largely motivated by applications to hysteresis, we consider a general setting where moving sets are given as inverse images of closed subsets of finite-dimensional spaces under nonlinear differentiable mappings dependent on both state and control variables. Developing the method of discrete approximations and employing generalized differential tools of first-order and second-order variational analysis allow us to derive nondegenerated necessary optimality conditions for such problems in extended Euler-Lagrange and Hamiltonian forms involving the Hamiltonian maximization. The latter conditions of the Pontryagin Maximum Principle type are the first in the literature for optimal control of sweeping processes with control-dependent moving sets.