Hacking [WIP] (S)NESInject: A ROM injector tool for Loadiine

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
No network required, just feed the program an NES/SNES VC ELF file and an NES/SNES ROM, and it figures out the rest. If the ROM is too big, it'll refuse to do anything with it.

Source is included, along with a pre-compiled, static-linked Windows build (should work on XP too). It should compile and run on any OS with a C compiler, though.

To use the program, first use Hykem's rpl2elf to convert your VC RPX into an ELF file:
Code:
rpl2elf vc-file.rpx vc-file.elf


Next, use the injector program:
Code:
snesinject <input VC ELF> <NES or SNES ROM> <output VC ELF>

(Don't actually use <> when running the program.)


After that, use makerpl64 from the Wii U SDK to convert your ELF back to an RPX:
Code:
makerpl64 -f -z8 -old -s xxxx.elf

Then you should be good to go with testing it on your Wii U using Loadiine.

Edit 1: I found a way of getting the ROM offset easier, so I'll try to make an update soon that won't require Super Metroid.

Edit 2: v0.2 is now out. You should be able to use any SNES VC ELF that supports 4MB games (Super Metroid is apparently 3, but it works fine for me; guess I got lucky with it not crashing?). I'm not sure if I'll bother adding support for ELFs that use base ROMs smaller than 4MB, but we'll see if there's enough demand.

Edit 3: v0.3 is now out. It supports both SNES and NES ROMs of nearly any size. I highly suggest using this build over 0.2, but 0.2 is included for legacy purposes.
 

Attachments

  • snesinject-0.2.zip
    62.1 KB · Views: 508
  • snesinject-0.3.zip
    62.8 KB · Views: 958
Last edited by daxtsu,

Sumea

Disco Ninja Frog
Member
Joined
Aug 16, 2008
Messages
1,589
Trophies
1
Age
32
Location
Turku
XP
946
Country
Finland
Great stuff. Really like this, would love to see same for N64 and so on.

Still; great good stuff.
 

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
Great stuff. Really like this, would love to see same for N64 and so on.

Still; great good stuff.

As far as I understand, you can already just replace the loose files for N64, can't you? The only ones that are really lacking easy tools are SNES, NES (before this tool came), and GBA. Loadiine should make N64 and NDS easy.
 

Sumea

Disco Ninja Frog
Member
Joined
Aug 16, 2008
Messages
1,589
Trophies
1
Age
32
Location
Turku
XP
946
Country
Finland
As far as I understand, you can already just replace the loose files for N64, can't you? The only ones that are really lacking easy tools are SNES, NES (before this tool came), and GBA. Loadiine should make N64 and NDS easy.
OK. I do not have dumps of any of them since my Wii U which I have few bought games on is not the same one that I have in FW 5.3.2, and I have not found any... other means to find VC games yet. I want to be in the inside know how club but oh well.
 

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
OK. I do not have dumps of any of them since my Wii U which I have few bought games on is not the same one that I have in FW 5.3.2, and I have not found any... other means to find VC games yet. I want to be in the inside know how club but oh well.

I don't have an N64 dump to confirm it myself, but from browsing the injection thread, it looks like they're just files that you can replace. It's only SNES and NES that are locked up in the RPX, while GBA is in alldata.bin, sadly.

On an unrelated note, I'll work on a size option so it'll "just work" with NES ROMs and base SNES games that are smaller than 4MB. NES ROM ELFs on the Wii U VC follow the same format as the SNES ones, so it's trivial to add support for it (they also use iNES-format dumps from the internet, lol).
 

Sumea

Disco Ninja Frog
Member
Joined
Aug 16, 2008
Messages
1,589
Trophies
1
Age
32
Location
Turku
XP
946
Country
Finland
Fun stuff. Yeah that is nice, injecting something like translated final fantasy or so on would be fun. And if you get GBA working at one point, mother 3 or something like that.
 

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
It probably won't be me who gets GBA working, alldata.bin is encrypted or something, and reverse-engineering is hardly my forte.
 
D

Deleted User

Guest
So can we use this with an existing setup? I have a Earthworm Jim that's set up already. If I convert the RPX to ELF and then attempt to add a Secret of Mana rom, I get the warning that it's smaller and will pad and then create an RPX from the ELF, but loading from Loadiine causes a system error.
 

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
So can we use this with an existing setup? I have a Earthworm Jim that's set up already. If I convert the RPX to ELF and then attempt to add a Secret of Mana rom, I get the warning that it's smaller and will pad and then create an RPX from the ELF, but loading from Loadiine causes a system error.

If Earthworm Jim isn't a 4MB base (it doesn't appear to be, judging by the size of the game on the internet, it's 3MBytes), it won't work right for you. This program pretty much assumes you have a 4MB base game right now (Donkey Kong Country, and maybe a few others). I plan on changing that in a day or so. If you can't wait, you can recompile it to only use 3MB (change line 7, ROM_SIZE, to 3 * 1024 *1024 instead of 4 * 1024 * 1024).

There's no reliable way to detect how large the ROM is in the VC ELF, unfortunately.
 

VinsCool

Persona Secretiva Felineus
Global Moderator
Joined
Jan 7, 2014
Messages
14,600
Trophies
4
Location
Another World
Website
www.gbatemp.net
XP
25,207
Country
Canada
If Earthworm Jim isn't a 4MB base (it doesn't appear to be, judging by the size of the game on the internet, it's 3MBytes), it won't work right for you. This program pretty much assumes you have a 4MB base game right now (Donkey Kong Country, and maybe a few others). I plan on changing that in a day or so. If you can't wait, you can recompile it to only use 3MB (change line 7, ROM_SIZE, to 3 * 1024 *1024 instead of 4 * 1024 * 1024).

There's no reliable way to detect how large the ROM is in the VC ELF, unfortunately.
How about adding a function to ask user what size is the base rom?
 

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
Loadiine gives me a white screen on a few snes roms.

What game are you using as a base, and what games did you try with it? If you're not using a game with a 4MB base (Donkey Kong Country or possibly a couple others, like mentioned above), you'll get crashes/freezes/unexpected behaviour since the program will end up overwriting other stuff in the ELF, and not just the ROM.
 
Last edited by daxtsu,

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
i messaged normmatt about the alldata.bin file, see if he can work his magic, he said he will take a look (but no promises, so please don't bug him about it :P )
figured with M2 making the sega 3DS VC emulators and the wiiu GBA emulator the formatting/encryption may be similar enough for him to figure it out seeing as he figured out the 3DS sega VC encryption
Edit 3: v0.3 to-do list: dynamic sizing so NES ROMs (and smaller SNES games) work.
you should be able to get that info from the WUP header, at 0xE it appears to store the rom size
40=4MB
20=2MB
10=1MB
08=512kb
04=256kb
02=128kb
01=64kb
00=32kb
....that should be good for injecting into any NES/SNES game and detecting the size automatically

oh and as an added bonus, 0x01 will let you detect if its a snes game or a NES game automatically
, 01 for snes, 00 for nes
 
Last edited by gamesquest1,

daxtsu

Well-Known Member
OP
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
i messaged normmatt about the alldata.bin file, see if he can work his magic, he said he will take a look (but no promises, so please don't bug him about it :P )
figured with M2 making the sega 3DS VC emulators and the wiiu GBA emulator the formatting/encryption may be similar enough for him to figure it out seeing as he figured out the 3DS sega VC encryption

you should be able to get that info from the WUP header, at 0xE it appears to store the rom size
40=4MB
20=2MB
10=1MB
08=512kb
04=256kb
02=128kb
01=64kb
00=32kb
....that should be good for injecting into any NES/SNES game and detecting the size automatically

oh and as an added bonus, 0x01 will let you detect if its a snes game or a NES game automatically
, 01 for snes, 00 for nes

By WUP header, you mean in the area where it says "WUP-XXXX"? Interesting, if so.
 

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
By WUP header, you mean in the area where it says "WUP-XXXX"? Interesting, if so.
yeah you would probably have to do some sort of detection as the game id part (WUP-XXXX) part shifts depending on if its a nes or snes rom too, but the wup header itself is always the same length.....to have a better look at the header you can download the amiibo classics game from the eshop, it has a bunch of roms you can look at to compare headers
 
  • Like
Reactions: daxtsu

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: Hello @realtimesave.