I'm still trying work out the fine details for fixing corrupt data myself, since I had it happen on Alpha Sapphire, but if you look up the instructions on this site for decrypting a Powersaves backup for viewing in PKHeX, you can at the very least recover your data. Reinjecting it is what I can't seem to do without it freezing, and hopefully someone like SciresM will have some information on that.
To make the keystream file, you'll need to delete your corrupted save (hold Up + B + X when the game is booting) then get to the main menu (you don't have to start a new game. One the professor shows up, you can quit).
Before you delete your corrupted save, though, make sure to back it up with Powersaves. Yes, unfortunately you'll need to buy Powersaves (RAM2Sav is nothing like Powersaves, FYI), but it's much cheaper than buying a Gateway (which can't be used on 9.3 or 9.4, for the record).
When told to XOR the files, make sure you use the Pokemon Save Decrypter that has been posted on this site. Regular XOR tools won't work.
Then you should be able to open your Y save in PKHeX. Start a new game on Y and get to the point where you can save. Do so, and then you can start injecting stuff. As I said before, though, injecting a corrupted save, even if you've successfully got it in PKHeX, is currently beyond me. I'm sure it's possible with some tweaking, but I don't know what needs tweaking. Hopefully this can be figured out so there's a fairly reliable method to recover corrupted saves in the future.
RAM2Sav allows you to edit the RAM values (changes what's currently stored temporarily, essentially), then when you save the game, the changes are written back to the game (since the RAM is in the 3DS, not the game - if you reset without saving, the changes are gone, since the RAM will be cleared).
Powersaves is currently the most reliable backup method (or Cyber Gadget, if you have a Japanese game).
Doing what I described, you can actually open up both save files next to each other and copy everything manually over. However, to make your new save identical to your corrupted one, it will take a lot of time and effort. It is doable, however. Just a pain in the ass.