Hacking [Release] cagen: Stupid script to speed up .cia generation

  • Thread starter mmn
  • Start date
  • Views 13,257
  • Replies 48
  • Likes 14

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
CIA Auto Generator

Download latest version

Please note: You can technically use this for xorpad generation on 9.x, but you have to replace the launcher.dat file and ncchinfo_gen.py with suitable replacements.

CIA Auto Generator is a Windows only script that was thrown together to speed up the generation of .cia files from .3ds files. It requires Queno138's CIA conversion kit, and it doesn't come with slot0x25KeyX.bin.

All it does is automatically follow all of the steps laid out by Queno138 in his guide. Even the unneccessary copying. It works out of the box, just put cagen.exe in the root directory of Queno138's kit and drag a .3ds file onto it.

Instructions
  • Download and extract Queno138's CIA conversion kit.
  • Make sure python is installed and in your PATH.
  • Make sure slot0x25KeyX.bin is in both the "Step 1" and "For 3DS SD Card" folders.
  • Download cagen.exe (or compile from source). Put it in the root directory of the conversion kit. The default name of that directory is "CIA".
  • Copy the .3ds file you want to convert to the root directory of the conversion kit. You may name it whatever you want except rom.3ds.
  • Drag the .3ds file onto cagen.exe to start the process.
You can download the .exe here
The source is here. But don't look at it. It's really poorly-written.

Changes
v0.3.0 - 2015-01-25:
  • Clean up everything that isn't the .cia, for real this time
  • Remove unnecessary copying
  • Option to keep misc. things that aren't xorpads
  • Warn user that their rom will be deleted if it's named "rom.3ds"
v0.2.2 - 2015-01-18:
  • Rename Launcher.dat.backup to Launcher.dat when everything is finished
v0.2.1 - 2015-01-18:
  • Add (y/n) option for those who don't want xorpads to be deleted
v0.2.0 - 2014-12-23:
The process is now entirely automated, other than the steps needed to generate xorpads.
  • Optionally automatically detect 3DS SD Card to copy necessary files (thanks Smiths!)
  • Menu system with failsafe options if the card can't be detected
  • Delete xorpads and other files from 3DS SD Card after finishing the process
Please let me know if you have any problems. My 3DS is on firmware 9.2.0, so I have no way of testing the xorpad step and install.cia generation. It should work though, as I tested it with dummy files.

v0.1.2 - 2014-12-22:
  • Switch to Windows API functions instead of system() calls
  • Add "Continue?" prompt when an operation fails
v0.1.1 - 2014-12-21:
  • Initial release
 

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
The process is exactly the same as before, it just requires fewer individual steps that you have complete yourself. So, it will work on exactly the same files as before.
 
  • Like
Reactions: Margen67

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
If your eshop rom is a) in .3ds format and b) can be converted to .cia using this guide, then yes.
I don't know enough about eshop roms to determine whether either of those points are often true.
 

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
Technically yes, I could add batch functionality to cagen or someone could write a trivial script that runs cagen multiple times.
But, practically, there's a step in the process that requires you to copy files to an SD card, put that in your 3DS and run a program, after which you then have to copy files back from the SD card. So the usefulness of doing a batch is questionable.
 
  • Like
Reactions: Margen67

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
That might be true, but, as far as I know, new xorpads need to be generated for each .3ds file that you want to convert to .cia. This means copying at least ncchinfo.bin to an SD card, running NCCH Decryptor on a physical 3DS, and copying the resulting xorpads for use during generation of the final .cia file. For every rom.
 

Smiths

AKAIO Person of Interest TAGS ARE THE BEST
Developer
Joined
Feb 24, 2003
Messages
1,461
Trophies
2
Location
The land of Dairy Queen
Website
www.gamergeddon.com
XP
2,179
Country
United States
surprised you went full out C++ on this. You could throw in something (I made a batch file for this process that is very similar to your code btw... just.. batch :) )that detects the 3DS sd card.

I put the SD card in my reader, and the batch file looks for a file on the drive roots of E-G (since that's where USB et al begin on my PC) that indicates it's a 3DS main SD card.

So it starts, prompts to put the card in an SD-slot/adapter if it isn't there, rescans, then does the other stuff with copying, etc... copies the rom to the sd card leaving a prompt on the screen saying "put card back in when 3ds is done its garbage and hit enter"... then detects card again, copies xorpads, etc...

Scripting is fun.
 

Kylecito

eats warnings for breakfast
Member
Joined
May 6, 2009
Messages
356
Trophies
0
XP
874
Country
Cote d'Ivoire
Really wish there was any way to speed up the 3DS part of this tedious process... Anyone up for emulating the AES engine on the 3DS? :P
 
  • Like
Reactions: Margen67

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
surprised you went full out C++ on this. You could throw in something (I made a batch file for this process that is very similar to your code btw... just.. batch :) )that detects the 3DS sd card.

Well, I've been working with C++ for school all quarter, so it's actually easier for me to just throw something together in C++ than it is in, say, python. It's certainly easier for me than a batch file, as I've never worked with those.

As for detecting the SD card, that's a great idea that I didn't have :D. I'll work on adding that.



Try naming the rom something other than "rom.3ds". It's supposed to do that part automatically, so something's going wrong there. I'll take a look at it.
 

Smiths

AKAIO Person of Interest TAGS ARE THE BEST
Developer
Joined
Feb 24, 2003
Messages
1,461
Trophies
2
Location
The land of Dairy Queen
Website
www.gamergeddon.com
XP
2,179
Country
United States
Well, I've been working with C++ for school all quarter, so it's actually easier for me to just throw something together in C++ than it is in, say, python. It's certainly easier for me than a batch file, as I've never worked with those.

As for detecting the SD card, that's a great idea that I didn't have :D. I'll work on adding that.

automation is the soul of programming. remember: the goal is to replace real employees with shell scripts because of your abilities. preferably people you don't like.
 

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,744
Trophies
2
XP
8,593
Country
Tuvalu
So we still have to decrypt the rom?

What about eshop dumps?

if you want to dump eshop, do not convert to 3ds and then convert to cia form that, eshop is basically in cia already, keep it neat :)
Well, I've been working with C++ for school all quarter, so it's actually easier for me to just throw something together in C++ than it is in, say, python. It's certainly easier for me than a batch file, as I've never worked with those.
trust me (if you want!) - i used c++ for years and never touched scripting stuff like python, bash, etc. - until recently. and i'm happy i worked in python now. but if you can use c++, python will be fine. it's really simple and easy to use, relative to c++, very powerful too :) give it a try if you want to make more things, it will save time, etc :)
 
  • Like
Reactions: Margen67

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
Thanks for the tip, cearp. Maybe I'll give python a spin for another project.

I've updated cagen to v0.2.0 with automatic detection of the 3DS SD Card, thanks to Smiths. It also cleans up after itself better now.

It seems quite a bit more useful, now that the only manual step is xorpad generation.
 

Smiths

AKAIO Person of Interest TAGS ARE THE BEST
Developer
Joined
Feb 24, 2003
Messages
1,461
Trophies
2
Location
The land of Dairy Queen
Website
www.gamergeddon.com
XP
2,179
Country
United States
Awesome work btw. Glad to give ideas.

I also realized I use the gateway launcher.dat by default (which is what my SD card detection looks for on each drive) and like to keep that after all is done. I'm pretty anal retentive when I batch stuff... you shoulda seen the AKAIO build scripts.

So I do the whole process and copy over the launcher.dat for CIA making, copying the existing launcher to launcher_Gw.dat temporarily. Then when all is said and done and a CIA is made on the PC, I copy the CIA over to the SD and also rename my Gateway Launcher back to launcher.dat.
It's a 100% "for Smiths" routine since other people don't even have the Gateway, etc... but that's 99% of the code I write :)
 

mmn

Well-Known Member
OP
Member
Joined
Dec 22, 2014
Messages
200
Trophies
0
XP
288
Country
United States
Haha, yeah.
My script looks for the "Nintendo 3DS" folder on all removable drives and confirms that it has found the correct drive. When it then proceeds to copy files, if there's already a Launcher.dat it'll get renamed to Launcher.dat.autobackup. If there's already both Launcher.dat and Launcher.dat.autobackup, the renaming step will fail and wait for the go-ahead to continue or quit (which happens when any step fails).

I had to draw this little diagram to get the auto-detection menu straight in my head :wacko:
0bzTDwn.png
 
  • Like
Reactions: Margen67 and Smiths

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Sicklyboy @ Sicklyboy:
    Mobile app is such absolute dogshit, I haven't used it in SO long
  • K3Nv2 @ K3Nv2:
    Yeah mobile versions better people don't think about how apps are just shrunken down websites
  • K3Nv2 @ K3Nv2:
    Could be the phone connection etc I've mostly been fine with the app
  • K3Nv2 @ K3Nv2:
    Regardless fuck bezos
    +1
  • Sicklyboy @ Sicklyboy:
    Agreed. Crazy how both seeking a job at Amazon, and subsequently quitting Amazon, are both some of the best decisions I've ever made
  • K3Nv2 @ K3Nv2:
    Did someone loose a leg? You're fired
  • K3Nv2 @ K3Nv2:
    Ffs 55gb patch for hogwarts legacy
  • SylverReZ @ SylverReZ:
    @K3Nv2, Teslas are prob running Windows XP to this day.
  • Sicklyboy @ Sicklyboy:
    sometimes I wonder where I went wrong and why I'm so dissatisfied with my life
  • Sicklyboy @ Sicklyboy:
    Then I find myself arguing with someone on reddit about how blatantly wrong their understanding of the USB Power Delivery specification is.
  • Sicklyboy @ Sicklyboy:
    At 1 AM.
  • Sicklyboy @ Sicklyboy:
    Where did I go wrong, again? 😕
  • SylverReZ @ SylverReZ:
    @Sicklyboy, What do you mean?
  • K3Nv2 @ K3Nv2:
    @Sicklyboy, always blame women
  • Veho @ Veho:
    Blame woke.
  • SylverReZ @ SylverReZ:
    Blame society.
  • K3Nv2 @ K3Nv2:
    Woke isn't part of society they woke up from it
    +1
  • Veho @ Veho:
    *spends years yelling "wake up sheeple"
    *acts shocked when they actually wake up
  • Veho @ Veho:
    Make up your mind.
  • K3Nv2 @ K3Nv2:
    You mean the government doesn't care? :(
  • Veho @ Veho:
    I have no idea what you're talking about.
  • K3Nv2 @ K3Nv2:
    The government
    SylverReZ @ SylverReZ: https://www.youtube.com/clip/Ugkx4pNi-wvHyf8vhDN0x06Wf8J7aIgx_Hdp