Magnetic structure of solar flare regions producing hard X-ray pulsations