Skip to content

Commit

Permalink
Fix *Iron Man 2* not booting
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 26, 2024
1 parent 0ae5e0e commit 55aac0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion retail/bootloaderi/include/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

//extern bool cardReadFound; // patch_arm9.c

#define patchOffsetCacheFileVersion 108 // Change when new functions are being patched, some offsets removed,
#define patchOffsetCacheFileVersion 109 // Change when new functions are being patched, some offsets removed,
// the offset order changed, and/or the function signatures changed (not added)

typedef struct patchOffsetCacheContents {
Expand Down
15 changes: 15 additions & 0 deletions retail/bootloaderi/source/arm7/find_arm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static const u32 relocateValidateSignature[1] = {0x400010C};
static const u32 swiHaltSignature1[1] = {0xE59FC004};
static const u32 swiHaltSignature2[1] = {0xE59FC000};
static const u16 swiHaltCmpSignature[1] = {0x2800};
static const u16 swiHaltMovSignature[1] = {0x200C};
static const u32 swiHaltConstSignature[1] = {0x4000004};
static const u32 swiHaltConstSignatureAlt[1] = {0x4000208};

Expand Down Expand Up @@ -365,6 +366,20 @@ u16* findSwiHaltThumbOffset(const tNDSHeader* ndsHeader, const module_params_t*
(u32)findOffsetThumb((u16*)vAddrOfRelocSrc, 0x200,
swiHaltCmpSignature, 1
);
if (!findOffsetBackwardsThumb((u16*)swiHaltOffset, 0x20, swiHaltMovSignature, 1)) {
const u32 oldOffset = swiHaltOffset;
const u16 cmpBak = *(u16*)swiHaltOffset;
*(u16*)oldOffset = 0; // Avoid re-searching for wrong offset

swiHaltOffset =
(u32)findOffsetThumb((u16*)vAddrOfRelocSrc, 0x200,
swiHaltCmpSignature, 1
);
*(u16*)oldOffset = cmpBak;
// if (!findOffsetBackwardsThumb((u16*)swiHaltOffset, 0x20, swiHaltMovSignature, 1)) {
// swiHaltOffset = 0;
// }
}
}
if (!swiHaltOffset) {
u32 dispStatAddr = (u32)findOffset(
Expand Down

0 comments on commit 55aac0d

Please sign in to comment.