Hacking [Release][v.1.5.1] Sky Army Knife - a Sky3DS Template Tool

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
I dont know what I did wrong...
I have the latest v1.4.2 quick fix and using the latest template0413.txt

ROM I'm trying to generate template is Super.Smash.Bros.USA.READNFO.3DS-BigBlueBox.3ds

I have my private header with the my own Unique ID. I copied the Unique ID in to the text box, leaving the EEPROM ID and the Cart ID untouched.
I then check the Auto-Detect Unknown ID, the field automatically populated for me.

Then I click on Generate Template!, but I got an error:
UnknownID contains illegal character! UnknownID is not correctly formatted!

I thought Unknown ID is automatically detected from the base template and also should be accurately populated to the field?
For some users (for a currently unknown reason) the detector copies 15 bytes instead of 16. To fix the problem, use Auto-detect, find the matching line in the base, select and copy the line, uncheck Auto-detect and paste it in.
 
  • Like
Reactions: Megaben99

Oishikatta

Well-Known Member
Member
Joined
Oct 30, 2014
Messages
971
Trophies
0
XP
603
Country
United States
For some users (for a currently unknown reason) the detector copies 15 bytes instead of 16. To fix the problem, use Auto-detect, find the matching line in the base, select and copy the line, uncheck Auto-detect and paste it in.


Are you still planning to release the source?

I'd be happy to suggest (via PR) a couple small fixes for things like the auto-detect and the randomization.

The exact cause of the auto-detect returning 15 bytes instead of 16 is that it's currently defined as
Code:
BaseTemplate.Substring(165, 47)

The reason that doesn't always work is that sky's templates have inconsistent spacing - some template entries have spaces at the end of each line after the SHA1.
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
Are you still planning to release the source?

I'd be happy to suggest (via PR) a couple small fixes for things like the auto-detect and the randomization.

The exact cause of the auto-detect returning 15 bytes instead of 16 is that it's currently defined as
Code:
BaseTemplate.Substring(165, 47)

The reason that doesn't always work is that sky's templates have inconsistent spacing - some template entries have spaces at the end of each line after the SHA1.
The source will be released once it's cleaned up (if you have a look at it, there's *a lot* of obsolete code in there - it has to be put in the header/c files, but it's a neverending race between cleaning up and updating). I'm assuming you've used Reflector on my binary hence you can see some of it. Sky really pisses me off with their inconsistent templates, they've been a thorn in my side ever since I started coding SAK which is why I'm considering incorporating a template importer instead of using raw templates. Anywho, I'll have to sort it out, I figured that might be the problem. Thing is, I can't directly copy the whole line into the textbox or it'll crash, it doesn't accept whitesigns. I'll have to add a "buffer string" and trim them. :P
 

Oishikatta

Well-Known Member
Member
Joined
Oct 30, 2014
Messages
971
Trophies
0
XP
603
Country
United States
The source will be released once it's cleaned up (if you have a look at it, there's *a lot* of obsolete code in there - it has to be put in the header/c files, but it's a neverending race between cleaning up and updating). I'm assuming you've used Refractor on my binary hence you can see some of it. Sky really pisses me off with their inconsistent templates, they've been a thorn in my side ever since I started coding SAK which is why I'm considering incorporating a template importer instead of using raw templates. Anywho, I'll have to sort it out, I figured that might be the problem. Thing is, I can't directly copy the whole line into the textbox or it'll crash, it doesn't accept whitesigns. I'll have to add a "buffer string" and trim them. :P


The simplest quick fix for I think would be to check the length after trimming the result from the Substring with 165, and if it's 45 then do the Substring again with 167 and use that instead.
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
The simplest quick fix for I think would be to check the length after trimming the result from the Substring with 165, and if it's 45 then do the Substring again with 167 and use that instead.
I actually did check that a couple versions back and your explanation for the error doesn't seem right. If that were the case, I'd have a '\n' and a '\r' in front of the copied UnknownID string (from the previous line) and I don't. I'll work this error out though, I can always just copy the whole line with StreamReader, it's not a big deal nor a priority right now.
 

Oishikatta

Well-Known Member
Member
Joined
Oct 30, 2014
Messages
971
Trophies
0
XP
603
Country
United States
I actually did check that a couple versions back and your explanation for the error doesn't seem right. If that were the case, I'd have a '\n' and a '\r' in front of the copied UnknownID string (from the previous line) and I don't. I'll work this error out though, I can always just copy the whole line with StreamReader, it's not a big deal nor a priority right now.


Test case:

-Trim the template
Code:
import sys
 
for line in sys.stdin:
    print(line.strip())
Code:
trim.py < template0324.txt > trimmed-template.txt

Input template is 2151905 bytes, output template is 2148725 bytes. Resulting template fixes the issue in SAK 1.4.2. The reason you don't have a \n\r in front of UnknownID is that they're not allowed in a non-multiline textbox.

The entry I had the issue with is CTR-P-BFGE.
 
D

Deleted-19228

Guest
Dumped my own copy of SSB US today and noticed a mystery byte that's not listed 0x81
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
Sneak Peek: Little update on the features in the upcoming 1.5 release:
ROM Trimmer in SAK.png
  • Built-in ROM trimmer tool - now you can safely trim your ROM's in SAK with just a few clicks, thus saving precious disk space. Keep in mind that trimming CARD-2 games may cause undesirable side effects and is not recommended.
  • Random Number Generator has been re-coded to use a System::Environment::TickCount seed. What this means are superior randomized Unique ID's.
  • Bugfixes for some minor annoyances like the Unknown ID bug.
  • (Hopefully) more code clean-up depending on how much spare time I'll have.
Stay tuned! Update will be out in a few days. ;)
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
Update: Sky Army Knife v.1.5 is live, now with a brand-new feature, a ROM trimmer!

:arrow: Sky Army Knife v.1.5

Change Log: Added ROM Trimming functionality, Unknown ID detection bug fixed (well-spotted, Oishikatta), improved Random Number Generator

WARNING: ROM trimming functionality operates under the assumption that the user knows what he/she is doing and comes with no guarantees. The trimmer will automatically select all the NCCH partitions declared in NCSD. You have the option to opt out of any partitions you deem unnecessary, but keep in mind that this process is irreversible and may cause undesirable operation of related functions. The NCCH partitions are as follows:
  1. NCCH[0] = Game Data
  2. NCCH[1] = eManual
  3. NCCH[2] = Download Play Child Container
  4. NCCH[3] - NCCH[5] = Currently Unknown
  5. NCCH[6] = New3DS Update Data
  6. NCCH[7] = 3DS Update Data
If you are unsure of what you're deleting, proceed with using the default selection. If you are willing to take the risk for a few additional MB's of saved space, uncheck partitions at will. The trimmer automatically detects if it's trimming a CARD-2 game and will add 10MB's of padding to the trimmed ROM for NAND Saving when necessary. This functionality is new and can be considered BETA. All of the values are displayed as declared in the NCSD header and may not reflect the ROM's actual contents if it was previously trimmed - please use this utility with clean dumps only! Always retain the original, complete, clean dumps of your games on your hard drive! During trimming the program may appear unresponsive and the progress bar may freeze - this is normal and occurs due to handling large amounts of data. Please be patient and allow the trimmer to complete the operation!

Take care and enjoy!
 

koim

Well-Known Member
Member
Joined
Apr 16, 2015
Messages
179
Trophies
0
Age
42
XP
1,415
Country
France
had a slight bug when trying to generate a template for fantasy life EUR
sky.jpg


As you can see, auto-detect unkown ID did not work out well and trimmed the last byte.
nothing my dear friend copy paste can't fix, but I thought it was still worth reporting as I did not have that problem with the other games I tried so far.
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
had a slight bug when trying to generate a template for fantasy life EUR
View attachment 18211

As you can see, auto-detect unkown ID did not work out well and trimmed the last byte.
nothing my dear friend copy paste can't fix, but I thought it was still worth reporting as I did not have that problem with the other games I tried so far.
Ugh, what fresh horrors did Team Sky cook up in their template there, I wonder... I'm *this* close from removing all the spaces from the template just to be safe. :angry: Check the SHA1 line in the template. If there's a space after it, remove it.
 

koim

Well-Known Member
Member
Joined
Apr 16, 2015
Messages
179
Trophies
0
Age
42
XP
1,415
Country
France
did a few more tests with the original template file and noticed the look up box for the base template had the last two bytes trimmed as well. so I went through the fantasy life template and yes, there was a few unwanted spaces at the end of some lines (not the sha1 one though). once those were removed, the problem disappeared :bow:

had the same problem with another game, cleaning up unwanted spaces in the base template worked as well. the games that worked seamlessly did not have those unwanted spaces in their base template... so it's definitely a problem with sky3ds template file
 
  • Like
Reactions: Foxi4

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
did a few more tests with the original template file and noticed the look up box for the base template had the last two bytes trimmed as well. so I went through the fantasy life template and yes, there was a few unwanted spaces at the end of some lines (not the sha1 one though). once those were removed, the problem disappeared :bow:

had the same problem with another game, cleaning up unwanted spaces in the base template worked as well. the games that worked seamlessly did not have those unwanted spaces in their base template... so it's definitely a problem with sky3ds template file
I'll have to make more provisions for "Team Sky being idiots" then, thanks for the report. ;) I was planning to change the File I/O for text files anyways and start reading them line-by-line since address-based reads are so unreliable due to Team Sky's inconsistency. As for the last two bytes missing, it's to be expected - if there are too many characters in one place, there'll be too little at the end. Nothing to worry about though as SAK calculates the CRC values on the fly and doesn't need them from the base.
 

Foxi4

Endless Trash
OP
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
I converted some roms to eeprom no. If I trim them using this tool, might I lose the save files?
You will, so I suggest dumping your saves, trimming clean ROMs, converting the trimmed versions and re-uploading the saves. Trimming anything other than a clean ROM is a gamble and SAK will remove anything that's beyond the bounds of the selected NCCH's, so your save will be treated as padding.
 
  • Like
Reactions: RoDryBones

Site & Scene News

Popular threads in this forum

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