Switch homebrew team 2168-0002 releases dedbae xci2nsp: A smarter, faster XCI to NSP converter

Find xci2nsp releases here: https://gitlab.com/roothorick/dedbae/tags/

A pretty minor release for 2168, but don't ever say we hoard our creations!

This is an XCI to NSP converter that's smarter and faster than 4nxci.

  • A single, self-contained executable with no dependencies worth mentioning.
  • Reads and writes the game exe/assets -- the part that actually takes more than a few seconds -- only once, without decrypting/re-encrypting. No interstitial files. This is as fast as I can make it; the bottleneck is the throughput of your HDD.
  • Handles all known XCI/gamecard formats.
  • Produces output NSPs with the human-readable game name, title ID, and version ID in hex (much more readable than CDNSP's decimal translation).
  • Identifies and extracts embedded updates as a separate NSP.
  • No fake tickets, no recrypting with titlekey crypto, no cruft in your ticketdb. Only the update NSPs have tickets, and they're real, official tickets.

Use

An x86-64 Windows binary is provided; for non-Windows (note: little endian CPU required) you'll need to build it yourself (see below), and if you bought a Switch but your main computer doesn't have a 64bit processor you need to re-evaluate your life choices.

Place your keyfile in the correct location (this works a bit differently from most tools! See below). Put xci2nsp.exe just anywhere. Run it from the command line with file names as arguments. NSPs will be saved to the current working directory irrespective of the XCI's location.

Alternately, just drag-and-drop XCI files on top of the exe. In this case the NSPs will be saved to the same directory as the XCIs. You can select and drag multiple at once and it will batch-convert them in sequence.

When installing the produced NSPs, Tinfoil will print a warning about failing to install the ticket. This is normal; there is no ticket to install.

Keyfile location

I'm very tired of every tool expecting keys to be in a different place under a different name, usually in the current working directory so you have a dozen copies laying all around your system. So, I'm taking a step towards standardizing that by copying hactool's search paths.
You'll need your keyfile to be "~/.switch/prod.keys" (Linux) or "C:\Users\<username>\.switch\prod.keys" (Windows), unless you have a weird setup that moves the home dir/user profile dir, in which case I expect you to already know what you're doing.

I really would like current and future tools to either do the same, or adopt a different standard location for all apps to go to.

Known issues

  • File permissions related problems are handled poorly and may produce cryptic errors.
  • Disk space is not checked. If you're not paying attention, you may get most of the way through a conversion only to get a "No space left on device" error.
  • The output file names are deliberately ASCII only, to avoid a bug in Horizon. Non-ASCII characters are translated using a C++ version of Unidecode, which doesn't handle Japanese very well. Names composed mainly of kanji will be badly bastardized. (If you've used CDNSP in the past you may be familiar with what this looks like.)
  • On Windows, xci2nsp may fail to open XCI files if their filename contains "wide" characters (e.g. Japanese alphabets). Filenames with such characters tend to cause problems with a lot of things, so you really should just rename them.
  • If an English translation for a game was added in an update (e.g. Taiko), and the update is embedded in the XCI, the base game NSP's filename will have the game's name in the original language (e.g. Japanese), but the update NSP's filename will have the English name.

Building from source

If you're cloning the repository, note that there are two submodules; you will need to specify --recursive.

Dependencies are basically nonexistent; just the standard GNU toolchain and libc/libstdc++. On Windows you will need MinGW-W64 and MSYS2. Extract/clone wherever, cd into the dir and make. The binary will be copied into the bin/ folder.

OSX will probably not work without a special build environment as GCC extensions are in use. Either way, I don't intend to support OSX; don't have the hardware, don't want the hardware, and really really don't want to mess around with hackintosh.

Why?

When I first started working on this, 4nxci wasn't correctly handling a number of common cases resulting in NSPs that didn't work correctly. In addition, it was re-encrypting with titlekey crypto, something that really isn't necessary, correction: 4n informed me it was just a fake ticket to work around a bug in early Tinfoil, it still left extra cruft on the system in the form of fake tickets in the ticketdb. I think his current version has resolved most of those issues, but I've been using this instead for a while, and it is better, so I should share.

I'll fix any issues people run into, and make updates if we discover XCIs that change things up too much to not work. Beyond that, though, I'm moving on to something considerably more exciting. Expect Big Things from 2168 soon.

Changelog

1.0.0-1: libgcc and libstdc++ are now statically linked in the Windows build. There actually are no meaningful runtime dependencies now.
 

Attachments

  • 2168.png
    2168.png
    9.7 KB · Views: 3,299
Last edited by roothorick,

HiD

Well-Known Member
Newcomer
Joined
Sep 25, 2016
Messages
98
Trophies
0
XP
863
Country
Canada
The XML is irrelevant and not actually used for anything. That part of the verification IIRC is about checking that an eShop rip is "proper". Obviously that whole concept doesn't apply here ;)

Current 4NXCI goes the extra mile to avoid the need for an extra signature patch that isn't in Hekate specifically for whatever reason; everything else has it. Due to how dedbae xci2nsp works internally, implementing that workaround is quite a bit more complex than it would be normally. I think it'd be better to just have that patch anyway, and I intend to look into why it never made it into Hekate.
I’d love to know why the extra sig patch is not in Hekate and if it can be added. I you get to know why, and have it added to Hekate, please let me know! :) It’s the last step for me to be able to directly install XCI from the file itself in dOPUS.
 
Last edited by HiD,

ColaBeldy

Member
Newcomer
Joined
May 24, 2018
Messages
7
Trophies
0
Age
36
XP
110
Country
Russia
The tool didn't work for me. I've tried to convert Broken Sword 5 and the result doesn't (the game crashes on start) work while 4nxci did the job flawlessly
 

HiD

Well-Known Member
Newcomer
Joined
Sep 25, 2016
Messages
98
Trophies
0
XP
863
Country
Canada
The tool didn't work for me. I've tried to convert Broken Sword 5 and the result doesn't (the game crashes on start) work while 4nxci did the job flawlessly
if you are using hekate, it might be because you are missing a sig patch. Try running the installed game with reinX.
 

kokotas

Active Member
Newcomer
Joined
Oct 7, 2008
Messages
26
Trophies
0
XP
428
Country
Greece
Tried converting dead cells xci and checked the nsp file on xci explorer. It deosn't show anything for the Game Infos category while the one made on 4nxci populates it normally. Dunno if that's how it's supposed to be, just FYI.
 

FightingPolygon

Well-Known Member
Member
Joined
Jun 8, 2016
Messages
99
Trophies
0
Age
21
XP
451
Country
United States
It won't let me create a .switch folder because it has a dot in it can I not change where the program looks for the prod.keys?
 

Draxzelex

Well-Known Member
Member
Joined
Aug 6, 2017
Messages
17,127
Trophies
1
Age
27
Location
New York City
XP
11,428
Country
United States
It won't let me create a .switch folder because it has a dot in it can I not change where the program looks for the prod.keys?

Follow the instructions below
  • Step 1: Open Command Prompt in Windows. Open Run window [Windows key + R] and type cmd and hit Enter. or Press Windows Key + X and Open Command Prompt.
  • Step 2: Now navigate to the path in which you want to create folder name starting with dot(.)
  • Step 3: Now type mkdir<space>.FolderName
example mkdir .switch

windows thinks its an exe otherwise
 

Nazosan

Well-Known Member
Member
Joined
May 12, 2009
Messages
526
Trophies
0
XP
863
Country
United States
Honestly the program should just create that folder if it doesn't see it. As it's a Windows binary it's well known that it will be run within Windows who's stock file manager in all relevant versions has problems with file/foldernames starting with a dot. You can tell users to use a command console, but the console isn't for everyone. Don't get me wrong, I personally am extremely familiar with the CLI (heck, I started using computers in the late MS-DOS/early Windows 3.x days) and, in fact, used a Cygwin mintty console to do this (I admit I never tried cmd's own md -- I just assumed Windows wouldn't allow it at all and never tried) but it would A. make things a lot easier for everyone (especially in light of the fact that you're trying to force a switch to a standard it should be facilitated as much as possible) and B. it would solve the problem for those who just don't really know how to do such things. Though IMO A alone is worth it.

I still don't get why it can't just be in the same folder though. While the filename hasn't been very standardized, it has generally been standard for the file to just be in the same folder. If it were a 1GB file or something I'd understand being bothered by having a ton of copies of it, but it's just a few kilobytes uncompressed. And if you actually have so many things using this file that it is becoming a big deal you could of course just do symbolic links... (I don't know how much they take up in the file tables, but I'm sure it's significantly less and that's reserved area anyway isn't it?) The program itself is much bigger and the author has proven that a few kilobytes don't matter by statically linking the libraries it uses (and honestly I support that decision because frankly I'm sick to death of installing library after library after library. I'm sure I have this one installed already, but this is getting old. I'd rather the programs were just a bit bigger but simply just worked out of the box.) For me the main problem is that it needs to be standardized exactly what filename is used. Everything has a different filename and that's what bothers me most. I never had a problem with it being in the same folder, but I definitely had a problem with it being named 500 different things. And lo and behold, this one too is named differently from what so many others use... Basically:
standards.png

It could always accept multiple locations.


Anyway, I tried converting Flashback. I haven't had time to test it yet, but I don't think it worked. XCI-Explorer says just under 650MB is in use within the 2GB ROM (so that still seems a bit suspiciously small -- is there no ROM size in between? I would have thought there would be a 1GB ROM specifically, but I'm no expert) but the NSP this produced is right under 250MB in size. Seems suspiciously small to me. I'll admit though that I just can't test it right now (nowhere near to my Switch.) Later when I can I'll test more of the stuff I had troubles with before and see how that goes.
 
Last edited by Nazosan,

blahblah

Well-Known Member
Member
Joined
May 16, 2018
Messages
1,136
Trophies
0
Age
32
XP
1,440
Country
United States
I don't think either of us want forks, but I am ready and willing to drop a zero effort modification of this app to enable 'key.txt in working dir' (did it already, took more time to compile than anything else ofc) if you don't relent and allow for both a standardized location (though, for the love of god, put it in AppData) as well as the working dir. No reason we can't have both.
 
Last edited by blahblah,

Nazosan

Well-Known Member
Member
Joined
May 12, 2009
Messages
526
Trophies
0
XP
863
Country
United States
+1 for that -- especially the AppData part. Hidden (dot) folders in the user's folder is standard for Linux, but in Windows we use AppData (and don't use dot folders) for the equivalent. If we're talking about standards this already goes against standards.

I'm all for setting standards, but it has to be done right or it just creates something exactly like the XKCD image above.
 
Last edited by Nazosan,

blahblah

Well-Known Member
Member
Joined
May 16, 2018
Messages
1,136
Trophies
0
Age
32
XP
1,440
Country
United States
+1 for that -- especially the AppData part. Hidden (dot) folders in the user's folder is standard for Linux, but in Windows we use AppData (and don't use dot folders) for the equivalent. If we're talking about standards this already goes against standards.

I'm all for setting standards, but it has to be done right.

It's impossibly clear - from the garbage loonix build chain, to dot folders, to the failure of the author to issue a working 1.0 binary for Windows - that the author is a Linux dude who has zero respect for Windows (and, by doing so, for the overwhelming majority of humans/effectively their entire user base).
 
Last edited by blahblah,

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
7,294
Trophies
1
XP
9,404
Country
United Kingdom
Anyway, I tried converting Flashback. I haven't had time to test it yet, but I don't think it worked. XCI-Explorer says just under 650MB is in use within the 2GB ROM (so that still seems a bit suspiciously small -- is there no ROM size in between? I would have thought there would be a 1GB ROM specifically, but I'm no expert) but the NSP this produced is right under 250MB in size. Seems suspiciously small to me. I'll admit though that I just can't test it right now (nowhere near to my Switch.) Later when I can I'll test more of the stuff I had troubles with before and see how that goes.
Yeah Flashback is tiny, your output is the right size (it actually runs the SNES rom in an emulator, with optional enhancements overlaid). I guess there isn't a 1gb cart size.
 

Nazosan

Well-Known Member
Member
Joined
May 12, 2009
Messages
526
Trophies
0
XP
863
Country
United States
Oh. I presumed even stuff like that would show up as a separate NSP. So it's just game updates that are split?
 

Nazosan

Well-Known Member
Member
Joined
May 12, 2009
Messages
526
Trophies
0
XP
863
Country
United States
Ok. Then, allowing for that maybe there are no problems after all.

And yeah, I was impressed with how fast this was.
 
General chit-chat
Help Users
    KennieDaMeanie @ KennieDaMeanie: Taste buds are a bitch imagine vomit tasting like the same food you just ate everyone would be...