Homebrew How to get Title ID from a CIA

DD2XAlpha

Well-Known Member
OP
Newcomer
Joined
Apr 26, 2016
Messages
48
Trophies
0
Age
26
XP
365
Country
Mexico
Hello, I am the creator of PC FBI Server and I am looking a wat to extract the ID of a CIA because I want to try something new, but I don't know how to get it, currrently if there is a solution based on C# or Python 3 please let me know. Thanks

Also if possible I want to know the game ID of a CIA (something like in Wii like [RSPE01])
 
Last edited by DD2XAlpha,

PokeNev

Well-Known Member
Member
Joined
Nov 11, 2018
Messages
336
Trophies
0
Age
26
XP
960
Country
United States
Hello, I am the creator of PC FBI Server and I am looking a wat to extract the ID of a CIA because I want to try something new, but I don't know how to get it, currrently if there is a solution based on C# or Python 3 please let me know. Thanks

Also if possible I want to know the game ID of a CIA (something like in Wii like [RSPE01])
Maybe get into programming a bit and then experiment I know you want the easy way out, but sometimes you have to do it yourself
 
  • Like
Reactions: DD2XAlpha

ThoD

GBATemp Addict (apparently), but more like "bored"
Member
Joined
Sep 8, 2017
Messages
3,631
Trophies
1
Age
27
XP
3,049
Country
Greece
If you simply are talking about the ID as an identifier for games and stuff, you should have just gone with Google or looked around the forum, not hard to find an answer. For games use this http://www.3dsdb.com/ and for homebrews/custom CIAs (eg: Forwarders) do what Amanda suggested above, simple.
 

8BitWonder

Small Homebrew Dev
Member
Joined
Jan 23, 2016
Messages
2,489
Trophies
1
Location
47 4F 54 20 45 45 4D
XP
5,350
Country
United States
Folks I think they're wanting to know how to directly extract the TID from a .CIA for an application, not just look it up and hard code it.

Information on 3DBrew outlines the location of the title ID and other .CIA content if you're interested:
https://www.3dbrew.org/wiki/CIA

Should be as easy as writing a script to look at those locations and grabbing the TID.
 
Last edited by 8BitWonder,
  • Like
Reactions: DD2XAlpha

ihaveahax

Well-Known Member
Member
Joined
Apr 20, 2015
Messages
6,069
Trophies
2
XP
7,827
Country
United States
Usually the ticket is at 0x2A40, so you could probably get away with hardcoding the offset (in practice, the contents before it don't change in size). The Title ID is stored at 0x9C relative to the ticket, so the Title ID is at 0x2ADC relative to the CIA header. https://www.3dbrew.org/wiki/Ticket

Or you can use the CIA header to get the offset of the ticket, then read the Title ID from it. Or use the Title Metadata, but both should be identical. Remember that offsets are aligned in 64-byte (0x40) blocks. https://www.3dbrew.org/wiki/CIA

The "Game ID"/Product Code is stored in the NCCH at 0x150, in the first content of most CIAs. Most game CIAs are encrypted, so don't bother unless you plan on including decryption code. https://www.3dbrew.org/wiki/NCCH#NCCH_Header
 
  • Like
Reactions: NaN and DD2XAlpha

DD2XAlpha

Well-Known Member
OP
Newcomer
Joined
Apr 26, 2016
Messages
48
Trophies
0
Age
26
XP
365
Country
Mexico
Maybe get into programming a bit and then experiment I know you want the easy way out, but sometimes you have to do it yourself

Copy the cia to your 3ds sd card. Insert it into 3ds and switch on. Goto fbi then select sd. Find your cia and the title ID will be displayed on screen.

If you simply are talking about the ID as an identifier for games and stuff, you should have just gone with Google or looked around the forum, not hard to find an answer. For games use this http://www.3dsdb.com/ and for homebrews/custom CIAs (eg: Forwarders) do what Amanda suggested above, simple.

Folks I think they're wanting to know how to directly extract the TID from a .CIA for an application, not just look it up and hard code it.

Information on 3DBrew outlines the location of the title ID and other .CIA content if you're interested:
https://www.3dbrew.org/wiki/CIA

Should be as easy as writing a script to look at those locations and grabbing the TID.

Usually the ticket is at 0x2A40, so you could probably get away with hardcoding the offset (in practice, the contents before it don't change in size). The Title ID is stored at 0x9C relative to the ticket, so the Title ID is at 0x2ADC relative to the CIA header. https://www.3dbrew.org/wiki/Ticket

Or you can use the CIA header to get the offset of the ticket, then read the Title ID from it. Or use the Title Metadata, but both should be identical. Remember that offsets are aligned in 64-byte (0x40) blocks. https://www.3dbrew.org/wiki/CIA

The "Game ID"/Product Code is stored in the NCCH at 0x150, in the first content of most CIAs. Most game CIAs are encrypted, so don't bother unless you plan on including decryption code. https://www.3dbrew.org/wiki/NCCH#NCCH_Header

Thanks everyone, I got it running a Python 2 Script that I translated to Python 3. The thing was to be able to get the TMD or ID to compare it on a XML Database saved ina folder, but everything from the computer, so when you select a CIA file it will recognize what game you selected and show it's titleID, name and region.

I used the next script (Python 3)

import os
import sys
from struct import unpack
print(sys.argv)
if not os.path.isfile(sys.argv[1]):
sys.exit(0)

cia_file = open(sys.argv[1], 'r+b')
cia_header = cia_file.read(0x20)

# Find offset for tmd
cert_offset = 0x2040
cert_size = unpack('<I', cia_header[0x08:0x0C])[0]
tik_size = unpack('<I', cia_header[0x0C:0x10])[0]
tmd_size = unpack('<I', cia_header[0x10:0x14])[0]
tmd_offset = cert_offset + cert_size + 0x30 + tik_size
print(format(tmd_offset, '08x'))

# Read titleid from tmd
cia_file.seek(tmd_offset + 0x18C)
titleid = format(unpack('>Q', cia_file.read(0x8))[0], '016x')
print('TitleID|' + titleid + "|")

cia_file.close()

This will be used for the new version of PC FBI Server that may be ready in a week or so.

Also the code is open source so it will be avaliable when I finish PC FBI Server update
 
Last edited by DD2XAlpha,

Badda

me too
Member
Joined
Feb 26, 2016
Messages
318
Trophies
0
Location
under the bridge
XP
2,402
Country
Tokelau
Sorry to wake up this old thread, but is there a way to find out my own TID from within the homebrew program? I was going through the Application Manager Service interface already, but cannot find anything suitable.
AM_GetCiaFileInfo() gets me the TID only if I have the .cia file. And AM_GetTitleList() gets me the list of all installed titles on the medium but how am I to find out which one is me?
Any help is appreciated!
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    I @ idonthave: :)