Homebrew How to retrieve icons for installed titles? [Homebrew dev. Question]

MaiconErick

Well-Known Member
OP
Member
Joined
Jan 4, 2016
Messages
140
Trophies
0
Age
27
XP
342
Country
Brazil
Hi,
I'm developing some small 3DS programs but I need some guidance on how to retrieve and display an icon of an installed title. And how to retrieve the title name as well (e.g. Pokémon Y).
I learned how to use AM_GetTitleCount/AM_GetTitleList by looking at the source of other projects on github.
 
Joined
Jan 1, 2018
Messages
7,292
Trophies
2
XP
5,910
Country
United States
Is this a program/app already installed on your 3DS? If you like to find out some of its meta information, you can check using FBI, at the Main Menu when it first loads, go to Titles and scroll down to find the app in question. This will give you Icon, Title ID, Version, Product Code, Region, and Size.

If you want to extract/decompile an app already installed on a 3DS, you will need to use GodMode9.

- In GodMode9, hover over to [A:] SYSNAND SD but do not press (A). Hold the (R) shoulder button and press (A).
- You should see some options pop up. Go to Search for titles... Scroll down the .tmd list to find your installed app.
- Press (A) > TMD file options... > Build CIA (standard). Once it is built, press (B) to go back to root.
- Go to [0:] SD CARD > gm9 > out to find your app in CIA format. Press (A) on it.
- Select CIA image options...
- Select Mount image to drive and press <A> yes. You should now be in [G:] CIA GAME IMAGE which list all the files within the mounted CIA.
- Hold the L-shoulder button and scroll down to highlight everything in yellow.
- Press A on one of the '.bin' or '.app' items you've selected. The first one/two items listed with a bunch of numbers and zeros are directories.
- You should now see on the bottom screen the option Copy to 0:/gm9/out . Select <A> yes.
- In the gm9/out folder, you should find all the extracted files from your CIA which you can now copy over to your computer to edit and rebuild.
 
Last edited by TurdPooCharger,

MaiconErick

Well-Known Member
OP
Member
Joined
Jan 4, 2016
Messages
140
Trophies
0
Age
27
XP
342
Country
Brazil
Is this a program/app already installed on your 3DS? If you like to find out some of its meta information, you can check using FBI, at the Main Menu when it first loads, go to Titles and scroll down to find the app in question. This will give you Icon, Title ID, Version, Product Code, Region, and Size.

If you want to extract/decompile an app already installed on a 3DS, you will need to use GodMode9.

- In GodMode9, hover over to [A:] SYSNAND SD but do not press (A). Hold the (R) shoulder button and press (A).
- You should see some options pop up. Go to Search for titles... Scroll down the .tmd list to find your installed app.
- Press (A) > TMD file options... > Build CIA (standard). Once it is built, press (B) to go back to root.
- Go to [0:] SD CARD > gm9 > out to find your app in CIA format. Press (A) on it.
- Select CIA image options...
- Select Mount image to drive and press <A> yes. You should now be in [G:] CIA GAME IMAGE which list all the files within the mounted CIA.
- Hold the L-shoulder button and scroll down to highlight everything in yellow.
- Press A on one of the '.bin' or '.app' items you've selected. The first one/two items listed with a bunch of numbers and zeros are directories.
- You should now see on the bottom screen the option Copy to 0:/gm9/out . Select <A> yes.
- In the gm9/out folder, you should find all the extracted files from your CIA which you can now copy over to your computer to edit and rebuild.

I'm currently developing an app like that.
I already have the apps listed in a homebrew I made by using "AM_GetTitleList".
I just need to know which function like "AM_GetTitleList" is used to display the icon and the title of a specified app. I couldn't find in the documentation.
 
Joined
Jan 1, 2018
Messages
7,292
Trophies
2
XP
5,910
Country
United States
Oh my bad. I read your first reply as in you were trying to retrieve information of an app that is already on 3DS. What you really meant is, you're looking for information on how a 3DS app (like FBI) displays information found on another 3DS app.

Edit : I am not a 3ds developer and have really primitive coding skills (ie, MATLAB scripting). However, I still would like to try to help you out. Those little icons in the CIA files of games and apps are smdh types. I was looking through the source code on how FBI displays that icon and this piece of code caught my attention.

In FBI-2.4.14.zip > core folder > util.c

Code:
Result util_get_cia_file_smdh(SMDH* smdh, Handle handle) {
    Result res = 0;

    if(smdh != NULL) {
        u32 bytesRead = 0;

        u32 header[8];
        if(R_SUCCEEDED(res = FSFILE_Read(handle, &bytesRead, 0, header, sizeof(header))) && bytesRead == sizeof(header)) {
            u32 headerSize = (header[0] + 0x3F) & ~0x3F;
            u32 certSize = (header[2] + 0x3F) & ~0x3F;
            u32 ticketSize = (header[3] + 0x3F) & ~0x3F;
            u32 tmdSize = (header[4] + 0x3F) & ~0x3F;
            u32 metaSize = (header[5] + 0x3F) & ~0x3F;
            u64 contentSize = ((header[6] | ((u64) header[7] << 32)) + 0x3F) & ~0x3F;

            if(metaSize >= 0x3AC0) {
                res = FSFILE_Read(handle, &bytesRead, headerSize + certSize + ticketSize + tmdSize + contentSize + 0x400, smdh, sizeof(SMDH));
            } else {
                res = R_FBI_BAD_DATA;
            }
        }
    } else {
        res = R_FBI_INVALID_ARGUMENT;
    }

    return res;
}

The reason why I think this piece is relevant is because there are other lines of util_get codes for file name, title ID, tmd, etc. I could not find other 'smdh' key word search that seemed relevant. Hope this can be adapted or provides a path in your search for icon display.

Edit #2: Also within that zip > ui > section > action > extractsmdh.c
 
Last edited by TurdPooCharger,

MaiconErick

Well-Known Member
OP
Member
Joined
Jan 4, 2016
Messages
140
Trophies
0
Age
27
XP
342
Country
Brazil
The listtitles.c file seems to have the resources I need, but it's hard for me too to understand it haha
 
Joined
Jan 1, 2018
Messages
7,292
Trophies
2
XP
5,910
Country
United States
How's that search going, and did you find what you're looking for? Do you happen to have the official Nintendo CTR_SDK files, or are you going by only the homebrew tool kits? I was scrolling through some of their documents in the basic framework of game design. Your last post mentions list, which is a family of functions they have in there. That caught my attention while on my research in how games' .bcma e-manuals are created.

You can find those files on that ISO site, but be forewarn it's not the complete set.
 

MaiconErick

Well-Known Member
OP
Member
Joined
Jan 4, 2016
Messages
140
Trophies
0
Age
27
XP
342
Country
Brazil
Hey, sorry I took long to reply.
I put it aside for a while.. I'm studying Korean.
Besides FBI, LumaLocale Switcher has a lot less of code and does what I want, I tried looking into the code but.. haha Couldn't understand much.
 
Last edited by MaiconErick,
General chit-chat
Help Users
  • DinohScene @ DinohScene:
    One mighty click of a button!
    +1
  • K3N1 @ K3N1:
    This Chinese bot had lv bags on sale for $20 and all I got was a box of air :(
  • DinohScene @ DinohScene:
    I'm sorry for your loss mate
  • K3N1 @ K3N1:
    They had a phone number and everything that didn't work after I made the purchase:(
  • DinohScene @ DinohScene:
    Would it help if I slept with you?
  • K3N1 @ K3N1:
    That's worth more than $20
  • K3N1 @ K3N1:
    Oh just got another box it's filled with adult toys from China my day is complete
  • DinohScene @ DinohScene:
    Nice
  • K3N1 @ K3N1:
    Incredibly small for some reason
  • DinohScene @ DinohScene:
    Hey, odd question, what is the life span of a samsung microsd in a raspi running raspi os and pihole?
  • K3N1 @ K3N1:
    Depends on use for some reason but I avoid any SD card that doesn't have a 2 year warranty
  • DinohScene @ DinohScene:
    Sounds fair, don't think I can be arsed sending a small microsd in for warranty but eh
  • K3N1 @ K3N1:
    I'd assume cards that run 24/7 with constant write transfers would fail quicker
  • K3N1 @ K3N1:
    I've had good luck with Team group SD cards cheap and comes with 5 years but void if it's ran 24/7
  • DinohScene @ DinohScene:
    I wonder how bad the microsd is that's in me dashcam
  • DinohScene @ DinohScene:
    I've had it for 8 years
  • DinohScene @ DinohScene:
    Same microsd, 140k km :x
  • K3N1 @ K3N1:
    SanDisk has their own tool for that to check life iirc
  • K3N1 @ K3N1:
    Should work on others
  • DinohScene @ DinohScene:
    Nice cheers
  • K3N1 @ K3N1:
    Can't remember if they force you to pay for those features
  • K3N1 @ K3N1:
    Silicon Power 1TB Micro SD Card U3 Nintendo-Switch, Steam Deck Compatible, SDXC microsdxc High Speed MicroSD Memory Card with Adapter https://a.co/d/2zlSFVO This guys been running fine in my SteamDeck
  • dxtsynx @ dxtsynx:
    I have a question about Medicat if anyone can answer.. My windows install is corrupt and wont boot. Does Medicat allow you to run DISM online or do an inlace upgrade? Trying to do some sort of repair install or recovery without a fresh installation
  • SylverReZ @ SylverReZ:
    @K3N1, Nice.
    SylverReZ @ SylverReZ: @K3N1, Nice.