Post subject: memory.registerexec + memory.setregister("pc",addr) broken
Editor, Skilled player (1202)
Joined: 9/27/2008
Posts: 1085
During a function called by memory.registerexec, attempting to move the Program Counter by memory.setregister("pc",addr) will load the first byte of the instruction before the move, and the remaining bytes of said instruction at the location after the move. The broken instruction then executes from that new location. Essentially, the main way to safely relocate the Program Counter during registerexec is to jump to an identical byte at the destination. For example, if you set a registerexec to trigger at a JMP $EF40, then move the PC to an LDA $6720, FCEUX will take the JMP, then grab the rest of the bytes for the destination, leaving us with JMP $6720. You can imagine the results. Considering what crazy antics one would have to do, needing both strong familiarity with lua and assembly, as well as deep knowledge of the game's ASM on top of that, I'm not surprised this bug has gone unnoticed for so long. Why must I think emu and not memory?
Masterjun
He/Him
Site Developer, Skilled player (1987)
Joined: 10/12/2010
Posts: 1185
Location: Germany
FatRatKnight wrote:
Why must I think emu and not memory?
Maybe because there are both emu.register...() things and memory.register...() things!
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Post subject: Typoman DIE ALREWADY
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
No one reads this anymore. Please make a ticket (if you make a patch, it'd be perfect).
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.