You don't need to map the HID shared memory right aways, only when the game asks for it. Basically, it will call CreateAppletResource on the HID service, this will return an IAppletResourceInterface. Then it calls GetSharedMemoryHandle on the IAppletResource interface to get the handle for the HID shared memory. After that, it uses svcMapSharedMemory into a memory region on the process address space. The game can then read inside the HID mapped address to read input data.
About your problem with nn::am::g_Interfaces, no I don't remember having such a problem.
Also we have a discord if you want to join. Link is on the readme of the github page .
Thanks for your response. I think I forgot something to initialize but I don't know what.
Here is the last opcodes executed for Puyo puyo, it loads offset 72 (decimal) from nn::am::g_Interfaces. Zelda ends in a similar manner, but in fonction nn::am::GetSelfController(), with a different offset in structure g_Inerfaces. I don't think I have any more problems in my interpreter, but I really think I'm forgetting something to init.
Loading on the rom is done in the same way than you:
- rtld @0x8000000
- empty page for args after rtld
- page rounded up to next 0x1000
- no guard pages between nso
- execution starting at 0x8000000
Only TSL page and Main stack are not mapped like you (I don't think it will change anything).
Do I need to load anything else before giving the control to rtld?
[FUNCTION _ZN2nn2am23GetApplicationFunctionsEv]
Executing 0x196603c8 inst 0xf81e0ff3 STR X19, [X31, #-32]!
mmu::write64 @0x19e4fcf0[aka stack pid 00] value=0x1a80a
X31=0x19e4fcf0
Executing 0x196603cc inst 0xa9017bfd STP X29, X30, [X31, #16]
mmu::write64 @0x19e4fd00[aka stack pid 00] value=0x19e4fd20
mmu::write64 @0x19e4fd08[aka stack pid 00] value=0x196c354c
Executing 0x196603d0 inst 0x910043fd ADD X29, X31, #16
X29=0x19e4fd00
Executing 0x196603d4 inst 0xd0002fe8 ADRP X8, 6283264
X8=0x19c5e000
Executing 0x196603d8 inst 0xf942c908 LDR X8, [X8, #1424]
Symbol : _ZN2nn2am12g_InterfacesE
mmu::read64 @0x19c5e590 value=0x19c3b8e8
X8=0x19c3b8e8
Executing 0x196603dc inst 0xf9402513 LDR X19, [X8, #72]
mmu::read64 @0x19c3b930 value=0x0
X19=0x0
Executing 0x196603e0 inst 0xb4000133 CBZ X19, 36
Executing 0x19660404 inst 0xa9417bfd LDP X29, X30, [X31, #16]
mmu::read64 @0x19e4fd00[aka stack pid 00] value=0x19e4fd20
mmu::read64 @0x19e4fd08[aka stack pid 00] value=0x196c354c
X29=0x19e4fd20
Executing 0x19660408 inst 0xaa1303e0 MOV X0, X19
X0=0x0
Executing 0x1966040c inst 0xf84207f3 LDR X19, [X31], #32
mmu::read64 @0x19e4fcf0[aka stack pid 00] value=0x1a80a
X19=0x1a80a X31=0x19e4fd10
Executing 0x19660410 inst 0xd65f03c0 RET X30
Executing 0x196c354c inst 0xf9400008 LDR X8, [X0]