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
28
XP
373
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,946
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
28
XP
373
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,946
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
28
XP
373
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,946
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
28
XP
373
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,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtu.be/IihvJBjUpNE?si=CsvoEbwzNKFf0GAm cool