Note: I could be completely wrong about this, so keep that in mind.
So I recently decided to try messing with PKHeX and EdiZon. What happened was that I made a Python script to generate an Atmosphere cheat code that injects a given EK8 file into Box 1 Slot 1 of the PC. It kind of worked, except I noticed that the Pokemon's Sp Def stat was glitched (with a question mark and 2 digits). I saved the game, dumped the save, and opened it with PKHeX. Upon viewing the glitched Pokemon in PKHeX, it didn't show anything different. But if I export the glitched Pokemon as an EK8 again, only the last 2 bytes are different from the original EK8 used to make the cheat code.
This leads me to believe that there could be a bug with how PKHeX handles saving EK8 files. Also, I noticed that the last 0x10 bytes of the PK8 file have the actual (calculated) stats shown in-game. I believe this may have something to do with the issue.
Edit: If anyone wants the RAM offset for Box 1 Slot 1 in Sword, it's HEAP + 0x004293D8B0 (at least for me)