rst 38 arbitrary code execution (Pokémon Red/Green/Blue/Yellow 1.0 JP) via Map 250/FA (Red/Green JP)

Subscribers:
17,700
Published on ● Video Link: https://www.youtube.com/watch?v=uqXU3MMAhOc



Duration: 4:28
1,158 views
46


I found this interesting technically specific glitch with Map 250 (0xFA) while looking for improvements to dokokashira door glitch. ^^
This glitch probably won't work on VisualBoyAdvance (even ones with correct Echo RAM emulation), but does work on BGB.

In fact, there should be a whole branch of glitches whenever a rst 0x38 occurs (where in Red/Blue/Yellow exploiting the rst 0x38 probably hasn't been done yet(??), with it working different pointing to another rst 0x38 and no useful exploit being found)

It works in both my v1.0 Green and v1.1 Red (and possibly Red v1.0, Green v1.1), but you may have to adjust the pointers you call in your code if the locations are different between the versions. The code below is for Green v1.0.

The cause of this glitch is its map script A000 which points to 00A0 (rst 38). In the Japanese versions Red/Green/Blue and Yellow v1.0 (interesting v1.1, v1.2, v1.3 changed it to rst 38 like other language versions), the rst 38 is different, and is for some reason jp F080. Hence arbitrary code execution occurs at F080 (Echo RAM for D080) but there are some interesting currently unknown details that causes the glitch to fail on VisualBoyAdvance.

In this save file of the glitch requirements set up is another weird exploit, where the game freezes if you go to the continue/new game/option screen and press B, causing the game to freeze. I noticed it and it's something to do with this specific save file?
https://drive.google.com/file/d/1w0i3QPB2PRwNp0vqBxxkPL7Y9JyjU1Di/view?usp=sharing

At D080 the exploit will plant the following code,

ld b,16
ld h,7B
ld l,E4
ld a,02
ld (C0EF),a
ld (C0F0),a (set the sound bank to the valid 02, as map 0xFA's 06 will freeze the game)
ld (D2DD),a (partially set the map to Viridian City to avoid other potential glitches on choosing continue)
nop
nop
nop (gets replaced by inc e 1C later for some reason; I added these filler nops knowing this happens somewhere in advance)
nop
ld a,DB
ld (D2EE),a
call 3620 (call bank 16 7BE4 ; Hall of Fame script)
ret

The new map script (also accessed after choosing continue) will be DBA0.

At DBA0

ld a,02
ld hl,C0EF
ldi (hl),a
ldi (hl),a
ret (same fix sound bank action as before)

Map 250 corrupted my party, but I escaped with an Escape Rope after adjusting the tileset address in the expanded inventory.

Method:
1. Set up this glitch, known as LWA/mart pwner https://archives.glitchcity.info/forums/board-107/thread-7417/page-0.html - for this purpose I chose the following

i.Text pointer table =D9B2 ; at fourth NPC (the non-Cable Club lady in Celadon City at the Pokémon Center) text pointer (D9B8) must be FE).
ii.Have no FF bytes below D9B2 up until DB5D (where you'll place your code that will be copied to D080 after the glitch).
iii. Add TM50 to D2E4, the exit destination slot in the expanded inventory.

(For the above the pointer from D9B2 is in box Pokémon data, so you'll need specific box Pokémon, at the moment I don't have details sorry; but you can set this up with another arbitrary code execution to wipe out those memory regions (and add your code to DB5D)

Steps:

1. Get
i. In slot 1 , Master Ball x178 (B2)
ii. In slot 2, TM17 (B2) x 157 (D9)
iii. In slot 3, TM50 (FA) x1
iv. An Escape Rope somewhere below if you want to escape the Glitch City.

2. Swap
i Slot 1 with slot 37 (may be just below a ?????)
ii. Slot 2 with slot 38
iii. Slot 3 with slot 34 (may be the Bicycle; じてんしゃ)

3. Talk to the non-Cable Club lady to bring up the glitch mart, and close it.

4. Go through the exit of the Pokémon Center to load Map 250, which in turn loads the 00A0 pointed rst 0x38 to jump to F080 (D080) where your code should reside. Note it can be awkward to get your codes not to freeze, and this likely won't work on VBA (BGB was used in this video).




Other Videos By Evie (ChickasaurusGL) 🌺


2022-06-23Changes in the behaviour of Poké Flute (with a sleeping party) outside of battle (Generations I-III)
2022-06-20PikaPicAnimGFX arbitrary code execution (Pokémon Yellow only)
2022-06-19Hall of Fame party menu pseudo-OAM buffer (CC5B) art creation exploit (Pokémon Yellow)
2022-06-19Receiving the Cerulean City Bulbasaur happiness gift, even though we never received Pikachu (Yellow)
2022-06-19Giovanni door soft-locking (similar to Cinnabar Island Blaine Door) Dokokashira door glitch (RG JP)
2022-06-19Addendum to empty party glitch (Trainer Card flashing) (Red/Green)
2022-06-07Pokémon Green (Japan) - Reverse Badge Acquisition proof-of-concept route
2022-06-05Change Fossil/Ghost MissingNo. base stats/header to all 255 arbitrary code execution (Generation I)
2022-06-04Port of the lost Test Fight debug menu to a Pokémon Yellow save file with ws m (0x63)
2022-05-24C109 (facing direction) arbitrary code execution expanded party method (Pokémon Yellow)
2022-05-14rst 38 arbitrary code execution (Pokémon Red/Green/Blue/Yellow 1.0 JP) via Map 250/FA (Red/Green JP)
2022-05-09Calling the Game Boy DMG boot ROM code (Pokémon Yellow arbitrary code execution experiment)
2022-05-09Pokémon Remerald is such broken game
2022-05-05Party slot 7 (and up) is checked for the walking Pikachu (Pokémon Yellow)
2022-05-05Pokémon Rapphire (Half Pokémon Ruby, half Pokémon Sapphire)
2022-05-05ROM splicing - 0000-3FFF is from Tetris (Rev A) 4000-7FFF is from Dr. Mario (Rev 0) (Tetris Doctor)
2022-05-05ROM splicing - 0000-3FFF is from Dr. Mario (Rev 0) 4000-7FFF is from Tetris (Rev A) (Dr. Tetris)
2022-03-20Pokémon Yellow infrared support proof of concept: Mew with remote control (arbitrary code execution)
2022-03-20Catch any Pokémon at the Trainer House (Glitch Unown 0xA2+wrong pocket TM36) (Gold/Silver)
2022-03-06Hatch any Shiny Pokémon with glitch Pokémon 0x0611 arbitrary code execution (Pokémon Emerald)
2022-03-05Party Pokémon 82 and 81 swap for text command 0x7A arbitrary code execution (Red/Green JP)



Other Statistics

Pokémon Red and Blue Statistics For Evie (ChickasaurusGL) 🌺

Currently, Evie (ChickasaurusGL) 🌺 has 1,628,633 views for Pokémon Red and Blue across 241 videos. There's over 1 day worth of watchable video for Pokémon Red and Blue published on his channel, or 21.83% of the total watchable video on Evie (ChickasaurusGL) 🌺's YouTube channel.