Controlling Electron Acceleration In Underdense And Overdense Laser–Plasma Interactions To Generate X-Rays For Probing High Energy Density Material