Skip to content

Instantly share code, notes, and snippets.

@TuxSH
Created December 27, 2016 21:07
Show Gist options
  • Save TuxSH/05fa78542556396408b60bfd3aab1f1c to your computer and use it in GitHub Desktop.
Save TuxSH/05fa78542556396408b60bfd3aab1f1c to your computer and use it in GitHub Desktop.
p9 firm section range checks
if ( arm9entryPoint - 0x8000000 >= 0x100000 )
goto ayy_lmao;
secNum = 0;
do
{
v17 = firmHeader + 0x30 * secNum;
sectionHeader = v17 + 0x40;
sectionSize = *(_DWORD *)(v17 + 0x48);
if ( sectionSize )
{
v20 = *(_DWORD *)sectionHeader;
if ( HIDWORD(offset) + (*(_DWORD *)sectionHeader < (unsigned int)offset) <= 0 || *(_DWORD *)sectionHeader << 23 )
goto ayy_lmao;
sectionLoadingAddress = *(_DWORD *)(sectionHeader + 4);
if ( (unsigned int)(sectionLoadingAddress - 0x8000000) >= 0x100000 )
{
if ( (unsigned int)(sectionLoadingAddress - 0x1FF80000) >= 0x80000 )
{
if ( (unsigned int)(sectionLoadingAddress - 0x18000000) >= 0x600000 )
{
if ( (unsigned int)(sectionLoadingAddress - 0x1FF00000) >= 0x80000 )
{
if ( (unsigned int)(sectionLoadingAddress - 0x1FF8000) >= 0x8000 )
{
if ( (unsigned int)(sectionLoadingAddress + 0x100000) >= 0x4000 )
goto ayy_lmao;
v37 = sectionSize >= 0x4000;
v38 = sectionSize == 0x4000;
if ( sectionSize <= 0x4000 )
{
v39 = sectionLoadingAddress + sectionSize;
v37 = __CFADD__(v39, 0xFC000);
v38 = v39 == 0xFFF04000;
}
if ( !v38 & v37 )
goto ayy_lmao;
}
else
{
v34 = sectionSize >= 0x8000;
v35 = sectionSize == 0x8000;
if ( sectionSize <= 0x8000 )
{
v36 = sectionLoadingAddress + sectionSize;
v34 = v36 >= 0x2000000;
v35 = v36 == 0x2000000;
}
if ( !v35 & v34 )
goto ayy_lmao;
}
}
else
{
v31 = sectionSize >= 0x80000;
v32 = sectionSize == 0x80000;
if ( sectionSize <= 0x80000 )
{
v33 = sectionLoadingAddress + sectionSize;
v31 = v33 >= dword_8084EC4;
v32 = v33 == dword_8084EC4;
}
if ( !v32 & v31 )
goto ayy_lmao;
}
}
else
{
v28 = sectionSize >= 0x600000;
v29 = sectionSize == 0x600000;
if ( sectionSize <= 0x600000 )
{
v30 = sectionLoadingAddress + sectionSize;
v28 = v30 >= *(_DWORD *)&aFirm[4];
v29 = v30 == *(_DWORD *)&aFirm[4];
}
if ( !v29 & v28 )
goto ayy_lmao;
}
}
else
{
v25 = sectionSize >= 0x80000;
v26 = sectionSize == 0x80000;
if ( sectionSize <= 0x80000 )
{
v27 = sectionLoadingAddress + sectionSize;
v25 = v27 >= 0x20000000;
v26 = v27 == 0x20000000;
}
if ( !v26 & v25 )
goto ayy_lmao;
}
}
else
{
_CF = sectionSize >= 0x100000;
_ZF = sectionSize == 0x100000;
if ( sectionSize <= 0x100000 )
{
v24 = sectionLoadingAddress + sectionSize;
_CF = v24 >= 0x8100000;
_ZF = v24 == 135266304;
}
if ( !_ZF & _CF )
goto ayy_lmao;
}
if ( HIDWORD(offset) + (sectionSize < (unsigned int)offset) <= 0
&& HIDWORD(offset) + (v20 + sectionSize < (unsigned int)offset) <= 0
|| sectionSize & 0xF )
{
goto ayy_lmao;
}
}
++secNum;
}
while ( secNum < 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment