Homebrew Question How to find offsets for IPS / exeFS patches?

lingi

New Member
OP
Newbie
Joined
Dec 7, 2020
Messages
1
Trophies
0
Age
26
XP
37
Country
United States
I am trying to create an exeFS patch for Dark Souls Remastered. I extracted main from the NCAs and then converted it to an ELF with nx2elf.

The problem is, this ELF file is different from the ELF file produced by nsnsotool, hactool, or Ghidra. Which one of these produces the correct file? And do I need to add 0x100 to account for the NSO header?
 

Draxzelex

Well-Known Member
Member
Joined
Aug 6, 2017
Messages
16,639
Trophies
1
Age
27
Location
New York City
XP
11,221
Country
United States
I am trying to create an exeFS patch for Dark Souls Remastered. I extracted main from the NCAs and then converted it to an ELF with nx2elf.

The problem is, this ELF file is different from the ELF file produced by nsnsotool, hactool, or Ghidra. Which one of these produces the correct file? And do I need to add 0x100 to account for the NSO header?
First, you can't bump your threads. Secondly, the first ELF file seems appropriate.
 

masagrator

The patches guy
Member
Joined
Oct 14, 2018
Messages
4,646
Trophies
2
XP
7,692
Country
Poland
You don't need to convert them to elf (even you shouldn't because some info won't be parsed by standard elf loader). If you are using Ghidra, download ghidra switch loader.
And with main loaded via ghidra switch loader you need to get last 4 bytes of offset and add 0x100, this will be offset to use within ips32
 
Last edited by masagrator,
  • Like
Reactions: 8BitWonder

thethiny

Well-Known Member
Member
Joined
Jun 18, 2009
Messages
137
Trophies
0
XP
252
Country
United States
You don't need to convert them to elf (even you shouldn't because some info won't be parsed by standard elf loader). If you are using Ghidra, download ghidra switch loader.
And with main loaded via ghidra switch loader you need to get last 4 bytes of offset and add 0x100, this will be offset to use within ips32
Hi, sorry to bump a relatively old thread, but I cannot run Ghidra due to multiple JDK & Gradle issues, and also I don't know how to use it at all, as I'm an IDA person. I'm trying to create a pchtxt / ips patch for super mario odyssey, but I noticed that the nso header is actually 0x101 in length, and not 0x100, which is making me confused. I'm using Nintendo Switch Loader for IDA currently. I am wondering how to get the address from IDA into an IPS patch. I know about adding 100 to the offset, but I'm not sure it's the right thing, since I'm intentionally writing bad opcodes and yet the game is still booting. Example: IDA shows that at 0x710020976C there's a function called ShopItem::getPrice(int), and if I create an IPS patch / IPSwitch pchtxt at addresses 0020976C, or 0020986C, or 0020966C, the game still functions normally as if no adjustments were made. I have no way of verifying (in Yuzu) that the patch applied other than the UI showing a ✔ next to it. Any insight on this as I'm currently trying to make a simple mod just to understand how switch mods work.

my current pchtxt file:
pchtxt said:
@nsobid-B424BE150A8E7D78701CBE7A439D9EBF00000000

@flag print_values
@flag offset_shift 0x100

// Free Shop Items @ 710020976C
@enabled
0020966C 000080D2
00209670 C0035FD6
0020976C 000080D2
00209770 C0035FD6
0020986C 000080D2
00209870 C0035FD6
 
  • Like
Reactions: Imancol

Imancol

Otak Productions
Member
Joined
Jun 29, 2017
Messages
1,149
Trophies
0
XP
1,715
Country
Colombia
Hi, sorry to bump a relatively old thread, but I cannot run Ghidra due to multiple JDK & Gradle issues, and also I don't know how to use it at all, as I'm an IDA person. I'm trying to create a pchtxt / ips patch for super mario odyssey, but I noticed that the nso header is actually 0x101 in length, and not 0x100, which is making me confused. I'm using Nintendo Switch Loader for IDA currently. I am wondering how to get the address from IDA into an IPS patch. I know about adding 100 to the offset, but I'm not sure it's the right thing, since I'm intentionally writing bad opcodes and yet the game is still booting. Example: IDA shows that at 0x710020976C there's a function called ShopItem::getPrice(int), and if I create an IPS patch / IPSwitch pchtxt at addresses 0020976C, or 0020986C, or 0020966C, the game still functions normally as if no adjustments were made. I have no way of verifying (in Yuzu) that the patch applied other than the UI showing a ✔ next to it. Any insight on this as I'm currently trying to make a simple mod just to understand how switch mods work.

my current pchtxt file:
I love IDA, for its intuitive interface and the most precise search. But it hurts that the module is so outdated. I am also interested in knowing how to build Main.
 

masagrator

The patches guy
Member
Joined
Oct 14, 2018
Messages
4,646
Trophies
2
XP
7,692
Country
Poland
but I noticed that the nso header is actually 0x101 in length,
This is wrong. This happens if you are using main decompressed with tool not designed to use its output in disassembler. For example nsnsotool. Use main compressed directly or decompress it with hactool.
I don't know how pchtxt patches are working, so can't help with that.
 

thethiny

Well-Known Member
Member
Joined
Jun 18, 2009
Messages
137
Trophies
0
XP
252
Country
United States
This is wrong. This happens if you are using main decompressed with tool not designed to use its output in disassembler. For example nsnsotool. Use main compressed directly or decompress it with hactool.
I don't know how pchtxt patches are working, so can't help with that.
Yes I am using nsnsotool. Thank you I will use hactool now.
edit: been trying for a while now and cant figure out how to decompress the main using hactool. I extracted everythjing and everything is working but the main is compressed. Can u give me example on how t odecompress using hactool?
 
Last edited by thethiny,

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
7,228
Trophies
1
XP
8,763
Country
United Kingdom
Yes I am using nsnsotool. Thank you I will use hactool now.
edit: been trying for a while now and cant figure out how to decompress the main using hactool. I extracted everythjing and everything is working but the main is compressed. Can u give me example on how t odecompress using hactool?
Not in front of my computer, but looks like it should be something like:

hactool -x -t nso0 --uncompressed=main.uncompressed main
 
  • Like
Reactions: thethiny
General chit-chat
Help Users
    Veho @ Veho: I'm guessing the second one.