Hacking Finding memory boundaries quickly

BullyWiiPlaza

Nintendo Hacking <3
OP
Member
Joined
Aug 2, 2014
Messages
1,932
Trophies
0
XP
2,502
Country
Germany
As you guys know it can be annoying to freeze if you access a bad memory range and you don't know how big the App MEM2 region is? Wrong! This can be prevented quite easily by tracking down the boundaries with the OSEffectriveToPhysical() function. I'll just leave this JGecko U Java code here for anyone who is enlightened by this binary search implementation :P

Code:
private static int getMemoryBoundary(int startingAddress, int lastAddress, boolean convergeDownwards) throws IOException
{
    int middle = (lastAddress - startingAddress) / 2 + startingAddress;
    int physicalAddress = CoreInit.getEffectiveToPhysical(middle);

    while (true)
    {
        // Is it mapped?
        if ((physicalAddress != 0 && convergeDownwards)
                || (physicalAddress == 0 && !convergeDownwards))
        {
            lastAddress = middle;

        } else
        {
            startingAddress = middle;
        }

        int previousMiddle = middle;
        middle = (lastAddress - startingAddress) / 2 + startingAddress;

        // The middle does no longer update, algorithm terminates
        if (previousMiddle == middle)
        {
            break;
        }

        physicalAddress = CoreInit.getEffectiveToPhysical(middle);
    }

    return middle;
}
For Mario Kart 8 for example the output of this code...
Code:
Connector.getInstance().connect("192.168.178.35");

int boundary = getMemoryBoundary(0x10000000, 0x50000000, false);
System.out.println("Upper Bound: " + Integer.toHexString(boundary).toUpperCase());
boundary = getMemoryBoundary(0x01800000, 0x10000000, true);
System.out.println("Lower Bound: " + Integer.toHexString(boundary).toUpperCase());

Connector.getInstance().closeConnection();
... is the following:
Code:
Upper Bound: 4E11FFFF
Lower Bound: E17FFFF
Indeed, these are the last readable address boundaries. It took 29 iterations to find the first one so it's not too slow (about 2 seconds).

This is how NWPlayer123 did it but it's not very efficient how it seems.

Note:
This will be a feature in Gecko U so just in case you're worried that this is too nerdy and hard for you to make use of, you're pretty much covered.
 
Last edited by BullyWiiPlaza,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • _Ruri_ @ _Ruri_:
    @K3Nv3, Hm, true
  • K3Nv3 @ K3Nv3:
    Still technically useless today
  • Skelletonike @ Skelletonike:
    Portugal is proudly the oldest country in Europe when it comes to borders
  • Skelletonike @ Skelletonike:
    Now it's a shit hole.
  • Skelletonike @ Skelletonike:
    Portugal had half the world and just let it all go.
  • _Ruri_ @ _Ruri_:
    Portugal is one of the few western countries that interacted with Japan in the old times. How did it happen?
  • Skelletonike @ Skelletonike:
    All because the king ran away to Brasil, cowardly bastard. Our first king went to war even in his 70s.
  • Xdqwerty @ Xdqwerty:
    @Skelletonike, why did i read that as portugal half life?
  • Skelletonike @ Skelletonike:
    We were the first western country to reach Japan
  • _Ruri_ @ _Ruri_:
    @Xdqwerty, Omfg same lmao
    +1
  • Skelletonike @ Skelletonike:
    I had a typo
  • _Ruri_ @ _Ruri_:
    @Skelletonike, Damn, how did it happen?
  • _Ruri_ @ _Ruri_:
    Not the typo lol
  • Skelletonike @ Skelletonike:
    Portugal and Spain started the discovery ages.
  • Skelletonike @ Skelletonike:
    We were really good at navigating and wanted to create a sea route to India. Which we successfully created.
  • _Ruri_ @ _Ruri_:
    @Skelletonike, Ohh, true, you're right. Makes sense they also found Japan along the way. So it would have been either Portugal or Spain?
  • Skelletonike @ Skelletonike:
    While trying to get it we did have a lot of happy accidents like Brasil, Japan and many others.
  • _Ruri_ @ _Ruri_:
    Yeah, makes sense. Thank you.
  • Skelletonike @ Skelletonike:
    Yeah, Portugal already had an idea of the route so we split the world in half with Spain.
  • Skelletonike @ Skelletonike:
    Spain could use one side, we could use the other.
  • Skelletonike @ Skelletonike:
    That's how Spain got to America (Brasil was kinda kept as a secret for a while iirc)
  • _Ruri_ @ _Ruri_:
    Portugal's history is pretty interesting. Ngl I would have never thought it was this interesting.
  • Skelletonike @ Skelletonike:
    The first Japanese dictionary was created by a Portuguese priest
  • Skelletonike @ Skelletonike:
    We had a lot of missionaries ofc, mostly Jesuit.
  • Xdqwerty @ Xdqwerty:
    @_Ruri_, Speaking of half life my grandma doesnt allow me to play it nor any other fps game
    Xdqwerty @ Xdqwerty: @_Ruri_, Speaking of half life my grandma doesnt allow me to play it nor any other fps game