Help, JP eShop Game as Reward - Please FIX make_cdn_cia !!

Discussion in '3DS - Homebrew Development and Emulators' started by cearp, Jan 3, 2015.

  1. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    Hi, make_cdn_cia by 3dsguy is a very useful tool, it builds cias from unencrypted files, it can create legit cias easily! :)

    BUT it has a problem, if there are more than 255 content files it wraps around, as in content number 256 will not be 256, it will be 0, it will not look for file 00000100, it will look for 00000000.
    I tried to fix the source myself, but I keep having problems.
    I fixed just a little, but: when I change the content_id in cia.h from u8 to u16 or u32, is breaks something else in the code.
    The code uses 'sizeof', and that takes into account the amount of bytes needed to create the data struct (I believe), but because I increase it from u8 to u16/u32, the size is now increased.
    I am not too sure how to fix it...

    I put it on github, I have never used it before, but it seems nice.

    https://github.com/llakssz/make_cdn_ciaFIX

    So if you are able to fix it, please please help, I think for someone clever it should not be too much work at all :) If someone can fix it I'll buy them an undumped game from eShop (Japan store only, not too expensive, I have about ¥1000 in my account), and send them the CIA :)

    Thank you!

    -- if anyone wants to help and needs files to test it with, please send me a PM
    --- if magically 10s of people want to help out then... i will decide somehow who gets the reward, it will be who comes first etc/who does it better (i am not buying 10 games!), i hope it won't be difficult to decide, but i doubt there will be a mad rush to do this (exactly why i am offering a reward) :)

    -edit, the person who has make_cdn_cia hosted on github fixed it, but the cia does not build, it gets stuck in set_cia_header()
     
  2. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    updated, I put it on github, added a reward... :)
     
  3. Uiharu

    Uiharu Member

    Newcomer
    19
    3
    Sep 24, 2014
    Switzerland
    Metal_Max_4_-_Gekkou_no_Diva_JPN has 711 content files
     
    cearp likes this.
  4. NCDyson

    NCDyson Hello Boys...

    Member
    271
    113
    Nov 9, 2009
    United States
    content_id is defined as an array of 4 u8's, from the looks of the code, it's set up this way so that the byte order(endian) can be swapped easier, but still appears to be a 32bit unsigned int.

    EDIT:
    Ah, sorry, still half asleep. guess I need some files to test it with since I haven't got any eshop games unless someone can name me a cheap one(US) with lots of content files.
     
    cearp likes this.
  5. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    haha yes, i know, i am using it to test!! :)
    but also, i could not make a cia out of all the japanese themes from cdn. recently there are too many files.
    yes you are correct, i thought it was u8 that was the problem, but, because it is an array yes.. it is effectively a u32... so i do not know what the problem is... maybe the u32->u8 code that is used to return the content_id has an error...?
    i sent you a pm with files to test.
     
  6. Bug_Checker_

    Bug_Checker_ GBAtemp Advanced Fan

    Member
    950
    444
    Jun 10, 2006
    United States
    https://github.com/ctrdev/ctrsdk/issues/1

    https://github.com/ctrdev/ctrsdk/commit/a2a9d1cffe852428676e485ae481a80a04688698

    I recall a similar educated guess awhile back :-)

    I am still unclear why it is NOT u32 ,but, this should work until +65536 files(content ids)
     
  7. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    haha what!!??
    i opened the issue just... because, just for fun, i didn't think it would get fixed. i wasn't surprised when it was closed and flagged as 'wontfix'...

    but he fixed it?!
    crazy, i'll have a look after i eat :)
     
  8. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    haha yes your guess was good, i used that to try to fix, but i'm not an expert and i was fixing it the wrong way, i missed an important function - get_tmd_content_struct()
    seeing what he did we can make it u32, but i doubt a cia can even have that many content files anyway... surely not :D

    and hmm... it loops through it all fine... but the CIA does not build, i debugged it with printf (lol) and:

    I can see the program breaks in set_cia_header(), in the for loop: (line 158)

    Also, sometimes I receive 'Segmentation fault: 11' when I run the program. I am not sure why.

    -edit, it seems ok with the latest commit... hmm i will test it more :)
     
  9. liomajor

    liomajor GBAtemp Maniac

    Member
    1,463
    1,065
    Jun 10, 2008
    United States
    It works ^^
    I compiled the last commit myself 32/64bit :)

    Thanks to llakssz
     

    Attached Files:

  10. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    yes it works although as i said i still get bus/seg errors (on mac)
    but thanks for the exe :)
     
  11. liomajor

    liomajor GBAtemp Maniac

    Member
    1,463
    1,065
    Jun 10, 2008
    United States
    No problem ^_^

    Works well and the file limit/crash is no problem anylonger on windows.

    Wish someone would fix makerom (romfs / rebuilding cxi on .13)
     
  12. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    oh - that was me on github lol (i didn't fix it, just reported it to the guy) :)
     
  13. Kazuma77

    Kazuma77 GBAtemp Advanced Fan

    Member
    735
    314
    May 11, 2008
    United States
    Thanks for the compile. Unfortunately, the 64-bit build still gives a crash when you try to build a CIA for themes. The 32-bit one works though. Of course, you actually want to decrypt the themes, but it makes a good test.
     
  14. urherenow

    urherenow GBAtemp Addict

    Member
    2,863
    832
    Mar 8, 2009
    United States
    Japan
    crashes on DLC as well...
     
  15. cearp
    OP

    cearp the ticket master

    Member
    7,405
    4,658
    May 26, 2008
    Tuvalu
    not all dlc, or, it works fine for me with dlc :) anyway, try the newest build.
     
  16. Gon Freecss

    Gon Freecss 2DS + Luma 8.1 + B9S 1.2

    Member
    142
    60
    Nov 14, 2013
    Venezuela
    Venezuela
    Thank You very much! Finally I was able to build the Super Smash Bros DLC CIA.