Homebrew arm9loaderhay - my own take on a A9LH file select

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
As you may be able to tell from the title, this started as a fork from arm9select, so credits go to @FIX94 and whoever he credited. This also uses code from Decrypt9 for the password, so credits to @d0k3 and whoever I should credit too, but I have no idea who they are. You can PM me or post in the topic if you want to be credited. This is now a fork from BootCtr9 and here's the repo with releases.

https://github.com/Hayleia/arm9loaderhay/releases


Why another boot manager ?

Current boot managers are really convenient to the user. Some have a menu, others let you configure a key for each payload... But that might actually be too convenient. If you're a parent and want your kid to be able to play games without necessarily having access to GodMode9 for example, maybe you'd want them not to land there by accident just because they were pressing the L button by chance.

So how is it possible to prevent that ? Well, setting up more than one key for a payload (L+A is less likely to happen by accident than just L) or setting up a password for certain payloads maybe. Well that is possible with arm9loaderhay.
Please not that the whole purpose of this is to be less convenient than other boot managers, so if you're just looking for a way to manage your payloads, maybe that's not what you're looking for. Or maybe it is exactly what you need.


Wonderful, how do I use this ?

Like arm9select, this payload only looks at the contents of a specific folder, which is the "arm9select" folder for arm9select and the "arm9loaderhay" folder for arm9loaderhay.
Like arm9select, this folder can contain a default.bin payload and a default_bl file if the default payload needs backlight.

Now, things get different from arm9select.

In your "arm9loaderhay" folder, you can have subfolders. Each folder represents a payload that will be launched with a certain key combination.
  • The name of the folder is YXLRdulrTEBA where you replace any character with "-" to describe keypresses. The meaning of YXLRBA is obvious. The D-Pad is represented with dulr (in lowercase to avoid conflict with LR) and TE is for START and SELECT (they both start with an S so they are described with their second letter).
    For example, "----------BA" and "--L--u------" are valid names, describing "B+A" and "L+Up".
  • The folder needs an "arm9loaderhax.bin" payload, which will obviously be the payload launched when pressing the keys described by the folder's name
  • The folder can contain a file named "backlight". Its presence tells that the payload here needs backlight when launched. This is basically only useful if your arm9loaderhax supports screen init and turns backlight off (like Fix94's arm9loaderhax, see the link for arm9select at the top of this post)
  • The folder can contain a file named "password" that contains the password for the present payload. Use the same convention as for the folder's name. For example, if your password is Left,Right,L,START, write lrLT.
    Notice that any password longer than 10 characters will be trimmed down to 10.
    Also notice that any unrecognized character will mark the end or your password. "ABXYwatLR" for exemple is equivalent to "AXBY".
    The last thing to notice is that you can't use the same key twice in a row, so ABA is valid but AAB isn't.
  • The folder can contain anything else, like a file named "CtrBootManager" if you want to say that the "arm9loaderhax.bin" payload present in that folder is CtrBootManager's
So here's an example of what your SD card might look like.
Code:
SD
├── arm9loaderhax.bin
└── arm9loaderhay/
    ├── default.bin
    ├── default_bl
    ├── ----------BA/
    │   ├── arm9loaderhax.bin
    │   ├── backlight
    │   └── This_Is_CtrBootManager_On_A_B
    └── ------l--T--/
        ├── arm9loaderhax.bin
        ├── backlight
        ├── password
        └── This_Is_GodMode9_On_LEFT_SELECT


I didn't test everything though, so I am not saying it works perfectly, and I warned you, so I can't be held responsible if your 3DS bricks from using this program (even though it shouldn't happen). For example, I can't test all existing passwords and all key combinations.

(And if you don't trust me because I never released anything, you can read this. Of course, it doesn't prove my program works (and maybe it doesn't, that's the first thing I compile for a 3DS) but at least I'm not a crook doing stuff that doesn't work on purpose).
 
Last edited by Hayleia,

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
Updated it.
It now uses the ugly name in the folder name so you can just update your "arm9loaderhax.bin" payload for CtrBootManager (for example) without renaming it with an ugly name.
Doesn't need four digits at "1" for no apparent reason anymore, just put them at 0.
Also supports very limited password input, for more security, to be improved. Put a "password" file in the same folder as your payload (except default.bin) and it will wait for you to input "LEFT-RIGHT-DOWN-UP-A". Needs a way to configure the password to input.
See first post for more details.

Old version of first post in spoiler.
As you may be able to tell from the title, this is a fork from arm9select, so credits go to @FIX94 and whoever he credited.

Current boot managers (from what I've seen at least) either "only" allow you you to use one key per file or allow you to use two keys but one of them is fixed (like L+button with AuReiNand). This bothered me a bit, so I wanted to make a boot manager that allows you to use any button configuration for any payload. Well here it is.

Same as arm9select, you put all your payloads in a folder. Here, it's the "arm9loaderhay" folder, and not the "arm9select" one obviously.
Same as arm9select, payloads end in .bin, and files in _bl indicates if that payload needs backlight or not (read arm9select's doc if you don't see what I mean). I actually didn't really test that feature since all my payloads need backlight, but it should work since I didn't change anything to it...

Now, how to name payloads if they support several keys ? Well, that's where it becomes funny :P
All payloads have a name consisting of 16 binary digits.
From right to left, digits describe keys in that order : A, B, SELECT, START, RIGHT, LEFT, UP, DOWN, R, L, X, Y.
Now you may say "it makes 12 digits and you said 16". Well, I only tested this on my Old 3DS and it seems like the remaining digits have to be 1 there. Maybe this is not the case on the New 3DS (since it has more buttons), I have no idea. I'll test it later probably but for now, laziness wins.
So, for example, on my Old 3DS (while testing), I got CtrBootManager9 to boot with A+B by naming it 1111000000000011.bin, Decrypt9 to run with LEFT+SELECT by naming it 1111000000100100.bin, and AuReiNand to boot by default by naming it... default.bin -.-

I didn't test everything though, so I am not saying it works perfectly, and I warned you, so I can't be held responsible if your 3DS bricks from using this program (even though it shouldn't happen). For example, I only tested on my O3DS, not on a N3DS, even though I have one.

Changes to code in spoiler.
In main.c in payload_stage2/source/
Code:
int main()
{
  FATFS fs;
  if(f_mount(&fs, "0:", 0) == FR_OK)
  {
  //Read pad state
  u16 padInput = ~(*(u16*)0x10146000);

  //Deduce base filename
  u16 N = padInput;
  char base[35] = "/arm9loaderhay/0000000000000000.bin";
  char back[34] = "/arm9loaderhay/0000000000000000_bl";
  for (int i=0; i<16; i++) {
  base[30-i] = '0' + (N%2);
  back[30-i] = '0' + (N%2);
  N = N/2;
  }

  if (tryLoadFile(base)) {
  jumpAndTryEnableBL(back);
  } else if (tryLoadFile("/arm9loaderhay/default.bin")) {
  if(*(vu8*)CFG_BOOTENV == COLDBOOT) {
  jumpAndTryEnableBL("/arm9loaderhay/default_bl");
  } else { //dont enable backlight again on soft reset
  jump();
  }
  }
  }
  i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1<<0));
  return 0;
}

Possible future changes: the "ugly digit name" would probably be moved to a folder. Instead of running arm9loaderhay/1111000000000011.bin with A+B, you would run arm9loaderhay/1111000000000011/arm9loaderhax.bin with A+B. This way, you can update your payload without having to remember the ugly filename. And you can even put a "comment" file (like CtrBootManager.txt) in that folder to remember what payload that is.

(And if you don't trust me because I never released anything, you can read this. Of course, it doesn't prove my program works (and maybe it doesn't, that's the first thing I compile for a 3DS) but at least I'm not a crook doing stuff that doesn't work on purpose).

Can I use this hax to feed livestock?
Probably, but not with my payload :P
 
D

Deleted User

Guest
I'm using Aurora Wright's no screen init and tried this out. The backlight file doesnt do anything and the password doesn't work.
 
D

Deleted User

Guest
I'm using Aurora Wright's no screen init and tried this out. The backlight file doesnt do anything and the password doesn't work.

That would never work anyways. This program doesn't do screen init, and neither would her fork so it would never display anything.
If you're using A9Select or this fork, it's assumed you're using Fix94's fork which has screen init with backlight at 0.
 

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
And about the password, no idea why it wouldn't work. Just be aware that it is not working the same way as in Decrypt9. In Decrypt9, the goal is just to make sure you didn't land in that menu by chance. Here, the goal is to make sure no one will ever land here by chance, so of course the password isn't displayed, and actually nothing is displayed. That's also why as opposed to Decrypt9, here a mistake makes you have to start the password over. But same as decrypt9 however, don't input it too fast, take your time to release keys before pressing other ones.

And I just tried it, it does work on my Old 3DS when putting a "password" file next to any "arm9loaderhax.bin" file in their XXXXXXXXXXXXXXXX. It isn't supposed to work with the default.bin payload however. If you want that, maybe don't put a default payload and use a 0000000000000000 folder instead. I didn't try it but I don't see why it wouldn't work.
 
D

Deleted User

Guest
Could I just compile stage 1 and stage 2 of Fix94's A9LH or can someone compile for me?
 
D

Deleted User

Guest
Can you make this work with no screen init please? I'd love to use this- also in the next release can you make different passwords possible? Thanks again!
 

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
Different passwords yeah, that's planned.

But no screen init, I have no idea. That's probably really easy to do when you know what to do (like getting a .c and a .h somewhere then calling "screenInit()"...) but I don't. And guess what, there is a .c and a .h with "void screenInit()" in them in arm9select's github, but do I just have to put that at the beginning of the main ? No idea.
 
D

Deleted User

Guest
I tested the password option on O3ds and N3ds. The Old 3ds password option works but the N3ds option doesn't. Please update

--------------------- MERGED ---------------------------

Different passwords yeah, that's planned.

But no screen init, I have no idea. That's probably really easy to do when you know what to do (like getting a .c and a .h somewhere then calling "screenInit()"...) but I don't. And guess what, there is a .c and a .h with "void screenInit()" in them in arm9select's github, but do I just have to put that at the beginning of the main ? No idea.
Check AuReiNand for the screen init if you plan on adding that
 

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
I tested the password option on O3ds and N3ds. The Old 3ds password option works but the N3ds option doesn't. Please update
Done (uploaded to first post). The problem was that for some reason, the New 3DS was able to detect the same key twice in a row, which led to it saying "no" to the next key in the password...
I worked around it in the InputWait in the while (pad == 0) by adding a "&& pad != oldPad" in the condition, and obviously setting oldPad before that.
As a consequence, when we'll be able to configure passwords, they will not support the same key twice in a row.

Check AuReiNand for the screen init if you plan on adding that
I'll have a look at it, but I don't promise anything, and especially I don't promise anything anytime soon (since I had a 3 days week-end I did things, but now the routine starts over so even if I do something, it will most probably not happen tomorrow if you see what I mean).
 
  • Like
Reactions: Deleted User
D

Deleted User

Guest
Done (uploaded to first post). The problem was that for some reason, the New 3DS was able to detect the same key twice in a row, which led to it saying "no" to the next key in the password...
I worked around it in the InputWait in the while (pad == 0) by adding a "&& pad != oldPad" in the condition, and obviously setting oldPad before that.
As a consequence, when we'll be able to configure passwords, they will not support the same key twice in a row.


I'll have a look at it, but I don't promise anything, and especially I don't promise anything anytime soon (since I had a 3 days week-end I did things, but now the routine starts over so even if I do something, it will most probably not happen tomorrow if you see what I mean).
Thanks as always! Yeah I'll be back to the routine too :/
 

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
Updated it with password "configuration". That's a big word considering you just describe it in a file without any configuration menu, but at least it's better than having everyone using a hardcoded password that everyone knows.

Old first post in spoiler.
As you may be able to tell from the title, this is a fork from arm9select, so credits go to @FIX94 and whoever he credited. This also uses code from Decrypt9 for the password, so credits to @d0k3 and whoever I should credit too, but I have no idea who they are. You can PM me or post in the topic if you want to be credited.

Current boot managers (from what I've seen at least) either "only" allow you you to use one key per file or allow you to use two keys but one of them is fixed (like L+button with AuReiNand). This bothered me a bit, so I wanted to make a boot manager that allows you to use any button configuration for any payload, and that would also support password protection to avoid people booting GodMode9 and erasing all the things. Well here it is.

The magic folder is obviously the "arm9loaderhay" folder on your SD card (create it if needed). Here, you can put a default.bin payload and a default_bl file if the default payload needs backlight (same as arm9select so far).
Then, in that folder, you can have subfolders, containing a "arm9loaderhax.bin" payload (the name "arm9loaderhax.bin" allows to easily update the payload since probably all payloads are released with that name). Along with that payload, you can have a "backlight" file if the payload needs backlight, and a "password" file if the payload needs to be password protected. You can also add other files like a file named "AB_CtrBootManager" to specify that this folder is about CtrBootManager and is launched with AB.

The annoying part is the folder name. It is composed of 16 digits. From right to left, digits describe keys in that order : A, B, SELECT, START, RIGHT, LEFT, UP, DOWN, R, L, X, Y. Now you may say "it makes 12 digits and you said 16". Just put the remaining ones at 0.

So here's an example of what your SD card might look like.
Code:
SD
--| arm9loaderhax.bin
--| arm9loaderhay/
--  --| default.bin
--  --| default_bl
--  --| 0000000000000011/
--  --  --| arm9loaderhax.bin
--  --  --| backlight
--  --  --| This_Is_CtrBootManager_On_A_B
--  --| 0000000000100100/
--  --  --| arm9loaderhax.bin
--  --  --| backlight
--  --  --| password
--  --  --| This_Is_GodMode9_On_LEFT_SELECT

Now for the password, well, I didn't code it properly yet, so it's just LEFT,RIGHT,DOWN,UP,A (you may recognize this password from Decrypt9 ;)). I'll have to do something about that so the user can modify the password without compiling the whole thing again...

Changes in code are as follow (plus get the hid.c, hid.h files from Decrypt9, and maybe some others I forgot).
In arm9select/payload_stage2/source/main.c
Code:
int main()
{
  FATFS fs;
  if(f_mount(&fs, "0:", 0) == FR_OK)
  {
  //Read pad state
  u16 padInput = (~(*(u16*)0x10146000)) & 0x0FFF;
  FIL f;

  //Deduce base filename
  u16 N = padInput;
  char base[] = "/arm9loaderhay/0000000000000000/arm9loaderhax.bin";
  char back[] = "/arm9loaderhay/0000000000000000/backlight";
  char pass[] = "/arm9loaderhay/0000000000000000/password";
  for (int i=0; i<16; i++) {
  base[30-i] = '0' + (N%2);
  back[30-i] = '0' + (N%2);
  pass[30-i] = '0' + (N%2);
  N = N/2;
  }

  //Password if needed
  if (f_open(&f, pass, FA_READ | FA_OPEN_EXISTING) == FR_OK) {
  f_close(&f);
  u32 password[] = {BUTTON_LEFT, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_UP, BUTTON_A, 0};
  int n = 0;
  int miss = 0;
  while (password[n] != 0) {
  u32 pad = 0;
  while (pad == 0) pad = InputWait() & 0x0FFF;
  if (password[n] == pad) {
  n++;
  } else {
  miss++;
  n = 0;
  }
  }
  }

  if (tryLoadFile(base)) {
  jumpAndTryEnableBL(back);
  } else if (tryLoadFile("/arm9loaderhay/default.bin")) {
  if(*(vu8*)CFG_BOOTENV == COLDBOOT) {
  jumpAndTryEnableBL("/arm9loaderhay/default_bl");
  } else { //dont enable backlight again on soft reset
  jump();
  }
  }
  }
  i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1<<0));
  return 0;
}

I didn't test everything though, so I am not saying it works perfectly, and I warned you, so I can't be held responsible if your 3DS bricks from using this program (even though it shouldn't happen). For example, I only tested on my O3DS, not on a N3DS, even though I have one.

(And if you don't trust me because I never released anything, you can read this. Of course, it doesn't prove my program works (and maybe it doesn't, that's the first thing I compile for a 3DS) but at least I'm not a crook doing stuff that doesn't work on purpose).
 
D

Deleted User

Guest
As you may be able to tell from the title, this is a fork from arm9select, so credits go to @FIX94 and whoever he credited. This also uses code from Decrypt9 for the password, so credits to @d0k3 and whoever I should credit too, but I have no idea who they are. You can PM me or post in the topic if you want to be credited.

Current boot managers (from what I've seen at least) either "only" allow you you to use one key per file or allow you to use two keys but one of them is fixed (like L+button with AuReiNand). This bothered me a bit, so I wanted to make a boot manager that allows you to use any button configuration for any payload, and that would also support password protection to avoid people booting GodMode9 and erasing all the things. Well here it is.

The magic folder is obviously the "arm9loaderhay" folder on your SD card (create it if needed). Here, you can put a default.bin payload and a default_bl file if the default payload needs backlight (same as arm9select so far).
Then, in that folder, you can have subfolders, containing a "arm9loaderhax.bin" payload (the name "arm9loaderhax.bin" allows to easily update the payload since probably all payloads are released with that name). Along with that payload, you can have a "backlight" file if the payload needs backlight, and a "password" file if the payload needs to be password protected. You can also add other files like a file named "AB_CtrBootManager" to specify that this folder is about CtrBootManager and is launched with AB.

The annoying part is the folder name. It is composed of 16 digits. From right to left, digits describe keys in that order : A, B, SELECT, START, RIGHT, LEFT, UP, DOWN, R, L, X, Y. Now you may say "it makes 12 digits and you said 16". Just put the remaining ones at 0.

So here's an example of what your SD card might look like.
Code:
SD
--| arm9loaderhax.bin
--| arm9loaderhay/
--  --| default.bin
--  --| default_bl
--  --| 0000000000000011/
--  --  --| arm9loaderhax.bin
--  --  --| backlight
--  --  --| This_Is_CtrBootManager_On_A_B
--  --| 0000000000100100/
--  --  --| arm9loaderhax.bin
--  --  --| backlight
--  --  --| password
--  --  --| This_Is_GodMode9_On_LEFT_SELECT

The password file must actually be a text file containing your password. Yeah, that means you are able to set a different password for each payload. Or you can use the same one by copy-pasting the same password file in all your folders.
To describe your password, use this:
  • A,B,X,Y for the A,B,X,Y keys
  • E,T for SELECT and START (they both start with an S so they couldn't use their initials)
  • l,r,d,u for the arrow keys (in lowercase to avoid confusion with L and R)
  • L,R for the shoulders
So for example, if your password is A,B,X,Y, just write "ABXY" in your password file.
Notice that any password longer than 10 characters will be trimmed down to 10.
Also notice that any unrecognized character will mark the end or your password. "ABXYwatLR" for exemple is equivalent to "AXBY".
The last thing to notice is that you can't use the same key twice in a row, so ABA is valid but AAB isn't.
And since I did this during the night and uploaded it today in haste, it's not so heavily tested. I basically only tested it with "ABXY"...

Changes in code are as follow (plus get the hid.c, hid.h files from Decrypt9, and maybe some others I forgot).
In arm9select/payload_stage2/source/main.c
Code:
int main()
{
   FATFS fs;
   if(f_mount(&fs, "0:", 0) == FR_OK)
   {
     //Read pad state
     u16 padInput = (~(*(u16*)0x10146000)) & 0x0FFF;
     FIL f;

     //Deduce base filename
     u16 N = padInput;
     char base[] = "/arm9loaderhay/0000000000000000/arm9loaderhax.bin";
     char back[] = "/arm9loaderhay/0000000000000000/backlight";
     char pass[] = "/arm9loaderhay/0000000000000000/password";
     for (int i=0; i<16; i++) {
       base[30-i] = '0' + (N%2);
       back[30-i] = '0' + (N%2);
       pass[30-i] = '0' + (N%2);
       N = N/2;
     }

     //Password if needed
     if (f_open(&f, pass, FA_READ | FA_OPEN_EXISTING) == FR_OK) {
       //u32 password[] = {BUTTON_LEFT, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_UP, BUTTON_A, 0};

       u32 password[11]; //password can't be longer than 10, because a max is reasonably needed and no one will go over 10...
       for (int i=0; i<11; i++) password[i] = 0;
       char read[10];
       UINT pass_length;
       f_read(&f, read, 10, &pass_length);
       f_close(&f);

       //convert char like 'A' or 'B' into u32 like 0001 or 0010...
       char ch[] = "ABETrludRLXY";
       for (int i=0; i<pass_length; i++) {
         char cur = read[i];
         int index = -1;
         for (int j=0; j<12; j++) if (cur == ch[j]) index = j;
         if (index != -1) password[i] = 1<<index;
       }
  
       int n = 0;
       int miss = 0;
       u32 pad = 0;
       u32 oldPad;
       while (password[n] != 0) {
         oldPad = pad;
         while (pad == 0 || pad == oldPad) pad = InputWait() & 0x0FFF;

         if (password[n] == pad) {
           n++;
         } else {
           miss++;
           n = 0;
         }
       }
     }

     if (tryLoadFile(base)) {
       jumpAndTryEnableBL(back);
     } else if (tryLoadFile("/arm9loaderhay/default.bin")) {
       if(*(vu8*)CFG_BOOTENV == COLDBOOT) {
         jumpAndTryEnableBL("/arm9loaderhay/default_bl");
       } else { //dont enable backlight again on soft reset
         jump();
       }
     }
   }
   i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1<<0));
   return 0;
}

I didn't test everything though, so I am not saying it works perfectly, and I warned you, so I can't be held responsible if your 3DS bricks from using this program (even though it shouldn't happen). For example, I can't test all existing passwords and all key combinations.

(And if you don't trust me because I never released anything, you can read this. Of course, it doesn't prove my program works (and maybe it doesn't, that's the first thing I compile for a 3DS) but at least I'm not a crook doing stuff that doesn't work on purpose).
Nice job! You can take that cup of coffee now :) don't worry about updating it for a few days! This is great! Thanks!
 
D

Deleted User

Guest
Hey can you make this work with latest version of Decrypt9WIP please? It sends the payload to just a black screen with a red dot on the top right corner. PS: I'm using a password with it
 

Hayleia

Well-Known Member
OP
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
Hey can you make this work with latest version of Decrypt9WIP please? It sends the payload to just a black screen with a red dot on the top right corner. PS: I'm using a password with it
The 2016/04/02 one here ? https://github.com/d0k3/Decrypt9WIP/releases/tag/20160402
I didn't try all the features so I can't tell if it works perfectly but I got it to boot fine (using LEFT+SELECT as combination and YXBA as password). I mean that I see the menu and can navigate inside of it.
 
D

Deleted User

Guest
The 2016/04/02 one here ? https://github.com/d0k3/Decrypt9WIP/releases/tag/20160402
I didn't try all the features so I can't tell if it works perfectly but I got it to boot fine (using LEFT+SELECT as combination and YXBA as password). I mean that I see the menu and can navigate inside of it.
Could it just be a N3DS problem? I'll keep testing this out. Also maybe someday instead of binary folders, you could actually use the same password combinations as folder combinations! So like you could use "YBLd" folder to hold The y, b, X, and down button :)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Sonic Angel Knight @ Sonic Angel Knight: :ninja: