Hacking Official Corbenik - Another CFW for advanced users (with bytecode patches!)

Kirtai

Well-Known Member
Member
Joined
May 6, 2016
Messages
237
Trophies
0
XP
245
Country
United Kingdom
This sounds quite interesting. Thanks for releasing it.

From what's written in the features page, dare I hope it'll eventually be able to replace NTR functionality like layeredFS or have some other kind of title specific patching?
 

DjoeN

Captain Haddock!
Member
Joined
Oct 21, 2005
Messages
5,489
Trophies
0
Age
54
Location
Somewhere in this potatoland!
Website
djoen.dommel.be
XP
2,857
Country
Belgium
You need python2. It doesn't rely on anything non-standard, but you probably need >=2.7. Some stuff I use is 3.x compatibity and doesn't exist if python is <2.7 Also, I have no clue if it will build on Windows (I suspect not, since I've done all testing on Linux)

If your python2 is named python, just change the shebang in host/bytecode_asm.py.

The Makefile also automatically adds $DEVKITARM to the PATH.

Other than devkitARM, ctrulib (for loader), and python2, nothing else is required as far as I know.
Thanks, it's more the makefile in the patch folder that gives a problem with wrong path (linux)

You need python2. It doesn't rely on anything non-standard, but you probably need >=2.7. Some stuff I use is 3.x compatibity and doesn't exist if python is <2.7 Also, I have no clue if it will build on Windows (I suspect not, since I've done all testing on Linux)

If your python2 is named python, just change the shebang in host/bytecode_asm.py.

The Makefile also automatically adds $DEVKITARM to the PATH.

Other than devkitARM, ctrulib (for loader), and python2, nothing else is required as far as I know.

Thanks
Changing #!/usr/bin/env python2 to #!/usr/bin/env python in host/bytecode_asm.py fixed the problem for Windows users (like said, i have both Python2.7 and Pyuthon 3.5. but works now ;)
 
Last edited by DjoeN,

astronautlevel

Well-Known Member
Member
Joined
Jan 26, 2016
Messages
4,128
Trophies
2
Location
Maryland
Website
ataber.pw
XP
5,008
Country
United States
Changing #!/usr/bin/env python2 to #!/usr/bin/env python in host/bytecode_asm.py fixed the problem for Windows users (like said, i have both Python2.7 and Pyuthon 3.5. but works now ;)
You may want to rename your python.exe in C:\Python27 to python2.exe and rename the python.exe in C:\Users\<user>\AppData\Local\Programs\Python\Python<ver>\ to python3.exe, that way you won't have to mess with the makefile every time. It also makes building stuff like Cakes, which requires python3, easier.
 

DjoeN

Captain Haddock!
Member
Joined
Oct 21, 2005
Messages
5,489
Trophies
0
Age
54
Location
Somewhere in this potatoland!
Website
djoen.dommel.be
XP
2,857
Country
Belgium
You may want to rename your python.exe in C:\Python27 to python2.exe and rename the python.exe in C:\Users\<user>\AppData\Local\Programs\Python\Python<ver>\ to python3.exe, that way you won't have to mess with the makefile every time. It also makes building stuff like Cakes, which requires python3, easier.
seems like i done that already for python 3, just did it for python 2 :) forgot about that trick, thanks for the reminder!
 

yifan_lu

@yifanlu
Member
Joined
Apr 28, 2007
Messages
663
Trophies
0
XP
1,671
Country
United States
Nice! Yeah, this is very similar to what I had envisioned. Some additional ideas:
  • Have support for title version as a const (OP_GETVER or something). Then you can have specific patches for specific versions (and also something like "if ver == x, then here's a hard coded offset, if == y, then another hard coded offset, else ... do a lookup" such a patch might load faster too)
  • Add an abort command like OP_EXIT. This allows, for example, a patch to only work on a certain version (with OP_GETVER)
  • OP_IF, OP_ELSE (self explanatory)
  • OP_READ8, OP_READ16, OP_READ32 (allows for conditional execution based on value at memory location. or allows relative patches like "add 16 to the value at x")
  • OP_WRITE (varlen), OP_WRITE8, OP_WRITE16, OP_WRITE32 (aka allow for patching in sequence instead of all at once)
  • OP_AND (which I think you have already), OP_ADD, OP_SUB, ... (basically to allow for patching instruction offsets and stuff)
  • (Not sure if this is already done) Support multiple patch files for the same titleid

(aka, a subset of the bitcoin scripting language without the crypto stuff) I think the language should be simple enough to only handle patches but versatile enough for writing game patches. Since I think it would be really useful for that.
 
Last edited by yifan_lu,

The Catboy

GBAtemp Official Catboy™: Boywife
Member
Joined
Sep 13, 2009
Messages
27,978
Trophies
4
Location
Making a non-binary fuss
XP
39,445
Country
Antarctica
Quick question, does the x's in the options me that they are selected or does mean they are unselected and when they go blank, they are selected?
Now it's just telling me that it can't find the Native Firm .-.
 
Last edited by The Catboy,

gnmmarechal

Well-Known Member
Member
GBAtemp Patron
Joined
Jul 13, 2014
Messages
6,040
Trophies
2
Age
25
Location
https://gs2012.xyz
Website
gs2012.xyz
XP
6,001
Country
Portugal
no i removed the native folder and placed 00000052 file on firmware folder i dont undersantd i not a noob just a middle noob lol
"Corbenik is mainly intended for developers; so if you don't know your way around the 3DS, chances are this isn't for you."

If you don't know what a file without extension is, you're most certainly a noob. Not a 3DS noob either, just a noob in any kind of computer/console.

Especially because the author already told you what to do.
 
Last edited by gnmmarechal,
  • Like
Reactions: astronautlevel

laharl22

Well-Known Member
Member
Joined
Dec 19, 2014
Messages
1,767
Trophies
0
Age
38
XP
615
Country
France
"Corbenik is mainly intended for developers; so if you don't know your way around the 3DS, chances are this isn't for you."

If you don't know what a file without extension is, you're most certainly a noob. Not a 3DS noob either, just a noob in any kind of computer/console.

Especially because the author already told you what to do.
I was think native are a folder but i i know the bases u have installed some stuff on my 4 PSP my vita and my 3ds
 

gnmmarechal

Well-Known Member
Member
GBAtemp Patron
Joined
Jul 13, 2014
Messages
6,040
Trophies
2
Age
25
Location
https://gs2012.xyz
Website
gs2012.xyz
XP
6,001
Country
Portugal
I was rhink native are a folder but i i know the bases u have installed some stuff on my 4 PSP my vita and my 3ds
You clearly do not. Installing stuff on the PSP, Vita and 3DS is not a big deal. Considering tutorials are available everywhere. If you're a noob, like you are indeed, stick to "consumer-grade" stuff with plenty of documentation. Don't go around testing new stuff intended for developers.

Sent from my Nokia 3310 using Tapatalk
 

The Catboy

GBAtemp Official Catboy™: Boywife
Member
Joined
Sep 13, 2009
Messages
27,978
Trophies
4
Location
Making a non-binary fuss
XP
39,445
Country
Antarctica
I got it working on my old 3DS ^_^ I realised what I was doing wrong and stopped being stupid for 5 minutes to get it to work. I shall proceed with the testing!
I noticed launching this CFW randomly causes my icons to move around and some of my games were treated like they were just installed (having to open the present and such.)
 
Last edited by The Catboy,

The Catboy

GBAtemp Official Catboy™: Boywife
Member
Joined
Sep 13, 2009
Messages
27,978
Trophies
4
Location
Making a non-binary fuss
XP
39,445
Country
Antarctica
"Config file loaded.
FIRM load triggered.
NATIVE_FIRM
___fp
TWL_FIRM
kdn!"

halp
In the "/corbenik/firmware/" name whatever firmware you downloaded to "NATIVE" and it will work.
 
  • Like
Reactions: doggomando

chaoskagami

G̷̘̫̍̈́̊̓̈l̴̙͔̞͠i̵̳͊ţ̸̙͇͒̓c̵̬̪̯̥̳͒͌̚h̵̹̭͛̒̊̽̚
OP
Developer
Joined
Mar 26, 2016
Messages
1,365
Trophies
1
Location
↑↑↓↓←→←→BA
Website
github.com
XP
2,287
Country
United States
Okay, starting with the various issues in no specific order:

mset port soon?

No. Maybe menuhax, but I'll make no effort for mset or gateway.

I was think native are a folder but i i know the bases u have installed some stuff on my 4 PSP my vita and my 3ds

No. Native is a file. Stahp. Please.

Quick question, does the x's in the options me that they are selected or does mean they are unselected and when they go blank, they are selected?

I got it working on my old 3DS ^_^ I realised what I was doing wrong and stopped being stupid for 5 minutes to get it to work. I shall proceed with the testing!

I noticed launching this CFW randomly causes my icons to move around and some of my games were treated like they were just installed (having to open the present and such.)

X is enabled. There was a bug in stable-1 that caused everything to be enabled on first boot (because I forgot to zero memory)

That's usually caused if you boot without the Region-free HOME patch and then with. Removing the region free patch causes the HOME menu to hide foreign games again. I don't know about the icons getting moved, though. It doesn't touch anything that would cause icons to move.

"Config file loaded.

FIRM load triggered.

NATIVE_FIRM

___fp

TWL_FIRM

kdn!"

halp

In the "/corbenik/firmware/" name whatever firmware you downloaded to "NATIVE" and it will work.

He has it named correctly. __fp means 'Not encrypted, ARM9 not encrypted, loaded, fixed entry point'. Native FIRM is loaded properly here.

As an aside, FAT is not case sensitive. You could name it NaTIvE for all I care. Internally everything is lowercase.

What's happening is TWL firmware is encrypted and fails to decrypt. I had a return statement scoped wrong, so it crashes when it should be gracefully spitting an error out. Check your firmkey, otherwise for now move twl and agb out of the way until next stable.

EDIT: I'm going to stop calling them stables, but release-3 is up. Test it. Your firmkey is still incorrect for twl, but it shouldn't hang up now.

Nice! Yeah, this is very similar to what I had envisioned. Some additional ideas:

Have support for title version as a const (OP_GETVER or something). Then you can have specific patches for specific versions (and also something like "if ver == x, then here's a hard coded offset, if == y, then another hard coded offset, else ... do a lookup" such a patch might load faster too)
Add an abort command like OP_EXIT. This allows, for example, a patch to only work on a certain version (with OP_GETVER)
OP_IF, OP_ELSE (self explanatory)
OP_READ8, OP_READ16, OP_READ32 (allows for conditional execution based on value at memory location. or allows relative patches like "add 16 to the value at x")
OP_WRITE (varlen), OP_WRITE8, OP_WRITE16, OP_WRITE32 (aka allow for patching in sequence instead of all at once)
OP_AND (which I think you have already), OP_ADD, OP_SUB, ... (basically to allow for patching instruction offsets and stuff)
(Not sure if this is already done) Support multiple patch files for the same titleid

(aka, a subset of the bitcoin scripting language without the crypto stuff) I think the language should be simple enough to only handle patches but versatile enough for writing game patches. Since I think it would be really useful for that.

Senpai noticed. Yay. I'm going to go through the bullets one by one here:

* Title version - Yes, that would be a good idea. Can do.
* Technically speaking, jumping to the end of the code will behave as an exit. That could be done in the assembler.
* There's a good reason I have OP_TEST and OP_JMP. Namely, OP_IF, OP_ELSEIF, OP_ELSE introduces the concept of scoping to the VM, which is not a fast thing to deal with. Not to mention, without additional checks, jumping into the wrong scope is a bad idea. That could be part of the assembler and I could simply compile that to jmp, but then it isn't actually an "assembler" anymore. The less comparisons in the VM, the better. ;P
* Conditional execution is already in through jmp and test, basically. The best example of it is in `patch/memexec.pco`, where we loop backwards until we find a value. That said, a scratch register might be helpful, and honestly I should just implement conditional jumps and make test behave like the x86 instruction.
* I'm not sure I see the difference between OP_WRITE and those besides it being a size optimization?
* OP_AND was in because of an immediate need for it in `patch/memexec.pco` and because it doesn't require being concerned with integer sizes. Those are planned, though.
* Yeah, it's done. To clarify; loader doesn't ever touch the patches directly, because it involves too many checks and would cause the console to hang in an earlier version for about ~2mins while all the system modules loaded. Maybe my implementation was naive, but the current code works very well. Loader operates off a cache named by titleid, and any patches found for a titleid are cat'd together during boot and separated by OP_NEXT/0xFF.

(I didn't even know bitcoin HAD a scripting language. Something new every day.)
 
Last edited by chaoskagami,
  • Like
Reactions: Subtle Demise

doggomando

Member
Newcomer
Joined
Mar 20, 2016
Messages
23
Trophies
0
Age
26
XP
86
Country
Canada
He has it named correctly. __fp means 'Not encrypted, ARM9 not encrypted, loaded, fixed entry point'. Native FIRM is loaded properly here.

As an aside, FAT is not case sensitive. You could name it NaTIvE for all I care. Internally everything is lowercase.

What's happening is TWL firmware is encrypted and fails to decrypt. I had a return statement scoped wrong, so it crashes when it should be gracefully spitting an error out. Check your firmkey, otherwise for now move twl and agb out of the way until next stable.

EDIT: I'm going to stop calling them stables, but release-3 is up. Test it. Your firmkey is still incorrect for twl, but it shouldn't hang up now


Still hangs up, you know a place i could get a good firm key?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Sicklyboy @ Sicklyboy: I got this one - https://www.amazon.com/gp/product/B07DDHC5MV