d0k3 / Decrypt9WIP

Multipurpose content dumper and decryptor for the Nintendo 3DS
GNU General Public License v2.0
404 stars 59 forks source link

Hyrule Warriors Legends DLC fails to dump to CIA. #164

Closed MortoQueiba closed 7 years ago

MortoQueiba commented 7 years ago

Hyrule Warriors Legends (0017ea00)

Process:

Content Decryptor Options > CIA Builder Options... > CIA Builder (SysNAND/decr.) Directory: /title/0004008c/0017ea00

The following log is given:

Building CIA from ID 0004008C0017EA00 Fetching TMD... Searching for proper ticket... Found ticket, injecting... Console unique info found, wiping... Writing CIA stub (15936 byte)... Injecting content id 00000029 (92 kB)... Decrypting content id 00000029 (SD)... Decrypting content id 00000029 (NCCH)... Code / Crypto: CTR-M-BZHE-00 / Standard Decrypt ExHdr/ExeFS/RomFS (0kB/14kB/0MB) Verify ExHdr/ExeFS/RomFS: -/OK/OK Injecting content id 00000001 (20 kB)... Content not found 0x Generated / 1x failed CIA Builder (SysNAND/decr.): failed!

GodMode9 fails as well with a similar report:

ID 0004008C0017EA00.00000001 Insert content failed

Edit: This issue also occurs with Fire Emblem Fates: Birthright DLC, but not with Fire Emblem Awakening DLC.

ghost commented 7 years ago

Issue #156 references this. Go take a look and see if that is any help.

MortoQueiba commented 7 years ago

I don't believe they are the same issue. It appears that in my case a file that doesn't exist (00000001.app) is attempting to be injected. #156's problem stems from a large number of files (HWL doesn't have nearly as many).

d0k3 commented 7 years ago

You are correct in this not being the same issue as https://github.com/d0k3/Decrypt9WIP/issues/156

Now, is this solvable? Maybe not / not properly. Let me explain. The TMD file contains what amounts to a list of contents in the DLC. So, the TMD says, there is a content 00000000, 00000001, 00000002, ... in there. The TMD also contains additional info, and a signature, and we need to reuse it when building a CIA.

Now, in your case, and in case of many other DLC, one (/more?) of the contents listed in the TMD is simply missing. I can only guess that this may happen when one part of a DLC is not released yet(?).

Problem is, if we build that CIA with that TMD, we have to (1) leave the missing content out (= CIA not installable), (2) add a dummy content (= CIA not installable) or (3) rebuild the TMD (installable, but unsure if it works, also breaks sigs).

I might try something later, I hope you can test then.

Committee commented 7 years ago

http://imgur.com/DCgpqKd http://imgur.com/B6DNI7x http://imgur.com/NczUgVd

FWIW I was able to dump it (decrypted).

Logfile:

http://pastebin.com/SJcKPHVn

d0k3 commented 7 years ago

Okay, so... the decrypted option worked? Is it also installable?

I just finished a fix for GM9, take a look here: https://transfer.sh/Sf2Pe/godmode9-20170312-130905.zip Maybe also give this a try? Legit won't work, ofc.

EDIT: I also feel the need to point out, the reason why this issue happens is because you don't have all DLC (that is listed in the TMD) on your system. DLC was never intended to be distributed as CIA, so a partial install is fine over CDN. A CIA, on the other hand, must contain all contents listed in the TMD.

Committee commented 7 years ago

Installable and playable.

Possible OP is missing one dlc since based on his log I did not encounter the same issue at that point on my end (from my log)

MortoQueiba commented 7 years ago

After checking the option to Purchase DLC I can confirm that I do own and have downloaded all DLC for HWL. Maybe it's because I purchased it all through the "Legends of Hyrule Pack (Nintendo 3DS)" option? According to the shop, this pack is 8 blocks large while the individual packs total to 12. Over the course of testing, I have deleted and re-downloaded the DLC several times to make sure that I have everything. As far as I can tell, I do.

The fix reports "Incomplete DLC (missing: 14)" anyways.

I don't have all of the DLC for Fates: Birthright, though. That I know.

d0k3 commented 7 years ago

To put it into the words of a buddy of mine, DLC is weird. In your case, that "Legends of Hyrule Pack" may encompass multiple DLC, but still be listed as a separate entry. Meaning: no legit (purchased) setup would actually contain all DLC. Also, keep in mind that DLC was never meant to be installable via CIA (it's in the name, DLCs are for downloads).

If you want to find out what's missing for you, a quick hint. The first content (when mounted as CIA) contains a list of expected content in the RomFS.

Now, that CIA you just build... Does it install, and, more importantly, does it work? (best to check for availability of all of your DLC)

Also, you already knew, but this is not legit anymore, cause we can't make it legit with the stuff we need to change. Needs CFW to use / install.

MortoQueiba commented 7 years ago

FBI does not even give an option to install, unfortunately.

d0k3 commented 7 years ago

Okay, looks like FBI doesn't like the somewhat elegant fix I implemented earlier. Try this one instead: https://transfer.sh/WNcGT/godmode9-20170313-004649.zip This should work.

MortoQueiba commented 7 years ago

The install option now appears, but installation hangs immediately upon starting. Also, if it helps, there is no icon, no title or description, no 'Nintendo', and region is unknown.

d0k3 commented 7 years ago

Okay, third times the charm: https://transfer.sh/jY1Mb/godmode9-20170313-211743.zip

This should solve it, let me know if it works for you. Also, this took far longer than it should have -_-.

MortoQueiba commented 7 years ago

Building CIAs seems to fluxuate between not being recognized by FBI and giving an invalid cert error (my luma is up to date and so is FBI).

d0k3 commented 7 years ago

So... you get differing outputs when building that CIA? Meaning, the file is different when building it mutliple times? If so, can you check this in a hex editor and tell me what differences you get? What was the output from GM9 (did the number of missing contents match earlier attempts)?

EDIT: You can also extract and check the cert via this batch script: https://github.com/d0k3/3DS-Tools-Collection/blob/master/Commandline%20Tools/ctrtool_unpack_CIA.bat (needs ctrtool, ofc)

The cert should be identical over every CIA.

MortoQueiba commented 7 years ago

I was, but after reinstalling the DLC to make sure it wasn't corrupted it now consistantly fails to be identified even by Godmode9. (No option to mount the .CIA). I think smething may have borked: http://imgur.com/hfxxksp

Edit: Last build was a goof on my end. GM9 recognizes it, but FBI still does not.

Edit 2: The certs are identical in all instances.

Edit 3: I'm still finding my way around the .CIA format, but it looks like TMD.bin is mixed in with some random data (which also affects the size given in Header.bin.): http://imgur.com/gUmnvVQ Meta.bin actually starts a ways down from here.

d0k3 commented 7 years ago

Alright... you did use the third test build I provided, right? This one: https://transfer.sh/jY1Mb/godmode9-20170313-211743.zip

Now... could you perhaps provide me with the TMD? I'd need (a) the unaltered TMD from the title directory, (b) the TMD extracted from the borked CIA. And, don't worry, there is nothing identifying or even copyrighted in a TMD file.

MortoQueiba commented 7 years ago

https://www.mediafire.com/?r8545r8gxl5or64

d0k3 commented 7 years ago

Okay, well, I had a minor typo (one symbol missing, but still... consequences) in my code. This one should do the trick and will hopefully close this issue: https://transfer.sh/9pKh4/godmode9-20170314-230106.zip

MortoQueiba commented 7 years ago

There's no cosmetic information in FBI, but it all works as far as I can tell. Tested it on Fates: Birthright (which I don't have all DLC for) and that worked as well. It's up to you if you want cosmetic info on FBI, but I consider the issue closed. Nice work and thanks!

d0k3 commented 7 years ago

Metadata is not possible. This is generated from a file in ExeFS ("icon") in the CXI. As DLC doesn't even have a CXI, I don't have the data to create this, nothing that can be done about it.

d0k3 commented 7 years ago

Okay, I'll need your help one more time... cause I also want to fix this in D9WIP: https://transfer.sh/B7AJV/decrypt9wip-20170315-120723.zip

The resulting CIA will be a little different from what you get in GM9, but should be recognized and be installable in FBI regardless.

MortoQueiba commented 7 years ago

For HWL, the cia is built successfully, but FBI reports:

Failed to install CIA file. Result code: 0xD8E08025 Level Permanent (27) Summary: Invalid argument (7) Module: AM (32) Desc: Invalid NCCH (37)

Fates: Birthright gives a "CIA Stub has Bad Size" error. It has content IDs up to $8E, so it may be Issue #156.

d0k3 commented 7 years ago

Okay, Well... the D9 code is not easily adapted for this. So, I figured I'll just leave it as is instead of putting a half-assed workaround in that would cause more problems than good in the long run.

Use of GM9, over D9, is encouraged for this kind of stuff anyways.

Closing this now, and thanks a ton to you for all the testing you did!