Re: Arbitrary code execution in Gold/Silver UE using the Coin Case
Posted by: ISSOtm
Date: 2017-11-10 20:06:11
Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.
You can join Glitch City Research Institute to ask questions or discuss current developments.
You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.
Any x Any
Any x 03
Full Restore x 01
Paralyz Heal x 13
Energypowder x 38
TM22 x 01
Any x Any
Poké Ball x 46
Rage Cany Bar x 44
Great Ball x 34
TM10 x Any
INC BC
LD C, 01
DEC C
DEC C
LD A, C
LD H, d5
LD BC, ...
DEC B
LD L, 72
INC L
INC B; LD [HL+], A
RET
As I've seen only matches between US memory addresses and european ones (as well as codes working in both) I'm interested in knowing exactly what is shifted, because I honestly didn't know that :???:
VC + SRAM exec = VC freaks the hell out, crashes, then erases your save next boot. Source: ISSOtm's testing.
As I've seen only matches between US memory addresses and european ones (as well as codes working in both) I'm interested in knowing exactly what is shifted, because I honestly didn't know that :???:
Give Lucky Egg to first Pokémon ($da2b):
Any x Any
Any x 3 INC BC
Poké Ball x 38 DEC B; LD H, da
TM27 x 3 INC BC
Fresh Water x 43 LD HL, 2b
Great Ball x 22 INC B; LD D, 7c
Revival Herb x 03 INC BC
Repel x 20 INC D; INC D
Energy Root x 34 LD A, D; LD [HL+], A
TM10 x Any RET
ld de, MailDataEnd
ld hl, TempStorage
ld c, length
.loop
ld a, [de]
dec de
ld [hld], a
dec c
jr nz, .loop
inc hl
jp [hl]
The mail might be stored in SRAM, but can't you make a setup that copies mail data into WRAM and executes it ?
For extra easiness, copy backwards.
ld de, MailDataEnd
ld hl, TempStorage
ld c, length
.loop
ld a, [de]
dec de
ld [hld], a
dec c
jr nz, .loop
inc hl
jp [hl]
The OAM DMA thing of Crystal_ (and your version, Couldntthinkofaname) works in french and italian games, once adapted for character issues.
I've used codes to edit several points in WRAM before in french or italian games (Trainer ID, Items, Pokémon, etc.) using exactly the same addresses than english games, so maybe the whole WRAM is exactly the same in english and european games, and you can use OAM DMA the same way in both too, but things in other part of the memory are different.
The mail might be stored in SRAM, but can't you make a setup that copies mail data into WRAM and executes it ?
For extra easiness, copy backwards.
ld de, MailDataEnd
ld hl, TempStorage
ld c, length
.loop
ld a, [de]
dec de
ld [hld], a
dec c
jr nz, .loop
inc hl
jp [hl]
Need to unlock SRAM and find mail data there first, but should be possible.
You'd also need a large enough space of temp data to store your code without destroying everything.
Had the same idea, but didn't bother to code it so far. Might look into it a bit more.
$DB4A to $DB54 = First Pokemon Name OT
$DB55 to $DB5F = Second Pokemon Name OT
$DB60 to $DB6A = Third Pokemon Name OT
$DB6B to $DB75 = Fourth Pokemon Name OT
$DB76 to $DB80 = Fifth Pokemon Name OT
$DB81 to $DB8B = Sixth Pokemon Name OT
$DB8C to $DB96 = First Pokemon Name
$DB97 to $DBA1 = Second Pokemon Name
$DBA2 to $DBAC = Third Pokemon Name
$DBAD to $DBB7 = Fourth Pokemon Name
$DBB8 to $DBC2 = Fifth Pokemon Name
$DBC3 to $DBCD = Sixth Pokemon Name
wNamingScreenDestinationPointer:: dw ; c5d0
wNamingScreenType:: ds 1 ; c5d4