Advertising (This ad goes away for registered users. You can Login or Register)

Network support for Everybody's Golf et al.

This is the development forum of the half-byte loader project. For general Half Byte Loader questions, visit the Half Byte Loader forum.
Forum rules
This forum is for HBL Development discussions ONLY. For User support or HBL general discussions, go to viewforum.php?f=3 . Messages that are not development related will be deleted.
Post Reply
JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Network support for Everybody's Golf et al.

Post by JJS » Mon Sep 27, 2010 3:47 pm

This is a repost of the thread from advancedpsp.tk, but I tried to update it with the results of the further discussion. This thread was originally reposted by wizarddoctor on h4ck.fi.st. Thank you for that, I wouldn't have wanted to retype this all.

The situation:

The golf games load network modules for adhoc mode. Everybody's Golf is an old game and therefore doesn't use sceUtilityLoadModule to do this, but loads the files manually via sceKernelLoadModule. The network modules are user mode modules and kernel modules. HBL can unload the user modules, but the kernel modules remain in memory (sceNet_Service and sceNetAdhocAuth_Service).
Because of this the utility module PSP_MODULE_NET_COMMON cannot be loaded by HBL and network functions are broken for homebrew started through it.


What I tried:

- Unload the network modules with sceUtilityUnloadModule. This doesn't work, the function returns the error code indicating that the utility was not loaded.

- Unload the kernel modules through PSPLink. After that network functions work like normal. I think custom firmware allows homebrew to unload kernel modules with sceKernelUnloadModule, but OFW doesn't. So this is not very helpful.

- Not unload the sceNet module and hope that the other utility modules (PSP_MODULE_NET_INET etc) reuse the common module in memory.
Turns out they don't. The kernel doesn't resolve imports from sceNet and sceNet_Library. Instead the stubs for sceNet and sceNet_lib are filled with this:

Code: Select all

0x0883299C: 0x0000054C 'L...' - syscall    0x15
0x088329A0: 0x00000000 '....' - nop
I guess it means that the call is not resolved. Calling sceNetInetInit() return a "library not linked yet" error (0x8002013A).

- Not unload the sceNet module and resolve the imports of the other network modules through HBL.
This seems possible, but the problem is that the version of sceNet_Library loaded by the golf game is not the one from the firmware, but from the UMD (apparently loaded from "umd0:/PSP_GAME/USRDIR/module/module/pspnet.prx").
It is an ancient version that only has 8 exports for sceNet and 96 for sceNet_lib (5.50 has 14 and 133 exports). Because of that not all functions can be resolved. Calling sceNetInetInit() crashes in sceNetInet_Library, looks like a NULL pointer. But I don't expect this to work because of the missing exports anyway.


What seems promising:

Unload the sceNet module and load the firmwares version from "flash0:/kd/pspnet.prx". This is possible on CFW when using sceKernelLoadModule, but OFW forbids loading the module from flash. So it has to be loaded through HBL, but I have not tried this yet. For this the module must be copied from flash0 to the memory stick and must be decrypted.

Resolving the stubs of sceNet_lib requires the imports from
- sceKernelLibrary. It is loaded to user memory and therefore all exports are known, but they are not yet resolvable through HBL. The easiest way to add this user mode library is to create a fake utility module id for it and then handle it like the other user mode utility modules. The other option is to add a special case for libraries that are neither utility modules nor kernel modules exporting syscalls.
- sceNetIfhandle. This one is kernel mode and not all syscalls can be resolved from the imports of Everybody's Golf. Maybe a problem, this could make the network functions unstable on firmwares without perfect syscall estimation.
Advertising

wololo
Site Admin
Posts: 3619
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Network support for Everybody's Golf et al.

Post by wololo » Sun Oct 03, 2010 2:36 am

(just a quick note: I deleted a bunch of messages that were unrelated to the thread. This is the dev forum, nothing else but technical discussions regarding the issue is allowed. Nothing personal.)
Advertising
If you need US PSN Codes, this technique is what I recommend.

Looking for guest bloggers and news hunters here at wololo.net, PM me!

JJS
Big Beholder
Posts: 1416
Joined: Mon Sep 27, 2010 2:18 pm
Contact:

Re: Network support for Everybody's Golf et al.

Post by JJS » Thu Oct 07, 2010 9:57 pm

Small upate on this. I tried to load the decrypted pspnet.prx module through HBL and (expectedly) it doesn't quite work for pretty much the same reasons official games don't load. So I will try to adapt the loader and the reloction code to handle multiple program sections. Interestingly the ELF also doesn't contain any entries in the section table, probably the module info is just indicated the way YAPSPD says (physical address field of the first program section contains the offset to the module info). Not sure where the relocation info is stored though.

Also a question: When they talk in the relocation section of YAPSPD about the relocation base address as the address of the program header they mean the virtual address of the respective program section, don't they?

wololo
Site Admin
Posts: 3619
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Network support for Everybody's Golf et al.

Post by wololo » Fri Oct 08, 2010 1:56 am

JJS wrote: Also a question: When they talk in the relocation section of YAPSPD about the relocation base address as the address of the program header they mean the virtual address of the respective program section, don't they?
This is pretty old in my mind so I am not sure of what I know about this, but I remember that whenever I was in trouble for relocation I would look at the source code for prxtools, which has relocation code, and I assume it does the right thing.
If you need US PSN Codes, this technique is what I recommend.

Looking for guest bloggers and news hunters here at wololo.net, PM me!

coyotebean
Guru
Posts: 96
Joined: Mon Sep 27, 2010 3:22 pm

Re: Network support for Everybody's Golf et al.

Post by coyotebean » Fri Oct 08, 2010 4:56 am

Take a loot at this note. I hope you can understand since I am too lazy to document it. Also you can study prxtool source code on how to decode the (packed) relocation table used by official prx.

Code: Select all

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
                 
00000000          7F 45 4C 46 01 01 01 00 00 00 00 00 00 00 00 00
00000010          xFFA0 08 00 01 00 00 00 0x000002AC  0x00000034
00000020          0x00000000  0x10A23001  x0034 x0020 x0003 x0000
00000030          x0000 x0000
                 
Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
                 
00000030                      0x00000001  0x000000A0  0x00000000   
00000040          0x80000830  0x000008D8  0x000008D8  0x00000005 
00000050          0x00000010
= .text + .sceStub.text
+ .lib.ent.top  + .lib.ent  + .lib.ent.btm
+ .lib.stub.top + .lib.stub + .lib.stub.btm
+ .rodata.sceModuleInfo
+ .rodata.sceResident
+ .rodata.sceNid
+ .rodata

00000050                      0x00000001  0x00000980  0x000008E0
00000060          0x00000000  0x00000050  0x00000050  0x00000006 
00000070          0x00000010
= .data

00000070                      0x700000A1  0x000009D0  0x00000000
00000080          0x00000000  0x00000134  0x00000000  0x00000000 
00000090          0x00000010
= .rel.txt + .rel.lib.ent + .rel.stub.ent
+ .rel.rodata.sceModuleInfo
+ .rel.rodata.sceResident
+ .rel.data

00000090                      0x00000000  0x00000000  0x00000000 
                 
Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
                 
000000A0 00000000 D0 FF BD 27 00 00 03 3C 24 00 B1 AF 00 00 71 24  .text
000000B0 00000010 04 00 22 8E 28 00 B2 AF 21 90 20 02 20 00 B0 AF  
...
00000740 000006A0 06 00 20 11 02 01 43 35 00 00 A8 A3 BD 01 00 0C  
00000750 000006B0 01 00 A7 A3 21 20 00 00 2D 18 44 00 10 00 BF 8F  
00000760 000006C0 21 10 60 00 08 00 E0 03 20 00 BD 27
0000076C 000006CC                                     08 00 E0 03
00000770 000006D0 00 00 00 00 08 00 E0 03 00 00 00 00 08 00 E0 03
00000780 000006E0 00 00 00 00 08 00 E0 03 00 00 00 00 08 00 E0 03
00000790 000006F0 00 00 00 00
00000794 000006F4             08 00 E0 03 00 00 00 00 08 00 E0 03
000007A0 00000700 00 00 00 00 08 00 E0 03 00 00 00 00
000007AC 0000070C                                     08 00 E0 03
000007B0 00000710 00 00 00 00 08 00 E0 03 00 00 00 00
000007BC 0000071C                                     00 00 00 00

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.ent.top

000007C0 00000720 0x00000000                                     

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.ent

000007C0 00000724             00 00 00 00 00 00 00 80 04 02 02 00
000007D0 00000730 0C 08 00 00 2C 08 00 00 11 00 01 00 04 00 0C 00
000007E0 00000740 40 08 00 00

  0724:0x00000000,0x80000000,0x04,0x02,0x0002,0x0000080C                 ""                  ,2 vars,0x0002 @ 0x0000080C
  0734:0x0000082C,0x00010011,0x04,0x00,0x000C,0x00000840                 "sceClockgen_driver",0 vars,0x000C @ 0x00000840

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.ent.btm

000007E0 00000744             00 00 00 00                        

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.stub.top

000007E0 00000748                         00 00 00 00            

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.stub

000007E0 0000074C                                     C8 07 00 00
000007F0 00000750 11 00 01 00 06 00 05 00 A0 08 00 00 CC 06 00 00
00000800 00000760 00 00 00 00 E0 07 00 00 11 00 01 00 05 00 02 00
00000810 00000770 C0 08 00 00 0C 07 00 00 FC 07 00 00 11 00 01 00
00000820 00000780 05 00 03 00 B4 08 00 00 F4 06 00 00

  074C:0x000007C8,0x00010011,0x06,0x00,0x0005,0x000008A0,0x000006CC      "ThreadManForKernel"  ,0x0005 @ 0x000008A0 -> 0x000006CC
  0760:0x00000000
  0764:0x000007E0,0x00010011,0x05,0x00,0x0002,0x000008C0,0x0000070C      "sceSysEventForKernel",0x0002 @ 0x000008C0 -> 0x0000070C
  0778:0x000007FC,0x00010011,0x05,0x00,0x0003,0x000008B4,0x000006F4      "sceI2c_driver"       ,0x0003 @ 0x000008B4 -> 0x000006F4

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .lib.stub.btm

00000820 0000078C                                     00 00 00 00
                 
Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .rodata.sceModuleInfo
                 
00000830 00000790 07 10 08 01 73 63 65 43 6C 6F 63 6B 67 65 6E 5F  ....sceClockgen_  
00000840 000007A0 44 72 69 76 65 72 00 00 00 00 00 00 00 00 00 00  Driver..........

00000850 000007B0 40 80 00 00

00000854 000007B4             0x00000724  0x00000744 			   (.lib.ent)

0000085C 000007BC                                     0x0000074C   (.lib.stub)
00000860 000007C0 0x0000078C
                 
Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .rodata.sceResident
                 
00000864 000007C4             00 00 00 00 
00000868 000007C8                         54 68 72 65 61 64 4D 61          ThreadMa
00000870 000007D0 6E 46 6F 72 4B 65 72 6E 65 6C 00 00              nForKernel..

00000870 000007DC                                     00 00 00 00
00000880 000007E0 73 63 65 53 79 73 45 76 65 6E 74 46 6F 72 4B 65  sceSysEventForKe
00000890 000007F0 72 6E 65 6C 00 00 00 00                          rnel....

00000898 000007F8                         00 00 00 00
0000089C 000007FC                                     73 63 65 49              sceI
000008A0 00000800 32 63 5F 64 72 69 76 65 72 00 00 00              2c_driver...

000008AC 0000080C                                     DB AC 32 D6  (0x0002+0x02 syslib exports)
000008B0 00000810 A6 4F 06 2F A7 73 1D F0 06 75 B9 11 AC 02 00 00
000008C0 00000820 18 03 00 00 90 07 00 00 D4 08 00 00

000008CC 0000082C                                     73 63 65 43              sceC
000008D0 00000830 6C 6F 63 6B 67 65 6E 5F 64 72 69 76 65 72 00 00  lockgen_driver..

000008E0 00000840 9D 2E 51 18 5D 0F 16 29 A6 67 A6 35 9D B4 F9 36  (0x000C+0x00 sceClockgen_driver exports)
000008F0 00000850 46 1A 3D 3C E1 E7 98 44 6F 2F F8 7F B4 89 DC 90
00000900 00000860 CE 0E C3 AC 02 31 AF C9 FB 44 79 D3 83 F2 E5 DB
00000910 00000870 4C 04 00 00 90 03 00 00 30 04 00 00 E4 03 00 00
00000920 00000880 D4 04 00 00 40 04 00 00 F4 04 00 00 B4 04 00 00
00000930 00000890 74 04 00 00 F8 00 00 00 00 00 00 00 14 05 00 00

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .rodata.sceNid

00000940 000008A0 C9 D2 DC 0D 0F 10 30 6B 1F B1 11 B0 C6 98 D0 B7
00000950 000008B0 BE 0F 17 F8 6F 79 BA 8A A3 BE 3C 9F 02 15 DF C7
00000960 000008C0 B5 4B 9E CD CD FD D3 D7

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .rodata

00000968 000008C8                         53 63 65 43 6C 6F 63 6B          SceClock
00000970 000008D0 67 65 6E 00                                      gen.
00000974 000008D4             10 00 02 06
00000978 000008D8                         00 00 00 00 00 00 00 00
                 
Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .data

00000980 000008E0 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
00000990 000008F0 40 00 00 00 C8 08 00 00 00 FF FF 00 34 05 00 00
000009A0 00000900 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000009B0 00000910 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000009C0 00000920 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Offset(h)         00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  .rel.XXX

000009D0 tag      00 00 
000009D2 part1s         03
000009D3 part2s            03
000009D4 block1               06 00 11 09 01 00
000009DA block2                                 06 04 05 07 06 02
000009E0 pos      41 00 1A 00 00 00 2B 04 34 1E 34 32 44 22 1A 14
000009F0          00 00 2B 02 2B 30 34 06 2B 02 34 10 1A 04 00 00
00000A00          2B 02 34 04 44 24 2B 06 44 04 44 06 44 28 1A 04
00000A10          00 00 2B 02 44 10 34 0C 12 04 C8 08 23 02 34 06
00000A20          1A 04 10 00 2B 02 34 06 1A FE 00 00 2B 04 2B 02
00000A30          34 04 1A 12 00 00 2B 02 34 14 2B 04 34 06 2B 06
00000A40          34 04 1A FE 10 00 2B 04 34 12 12 04 C8 08 23 02
00000A50          34 06 1A 04 10 00 2B 04 34 04 1A FE 00 00 2B 04
00000A60          1A 0E 00 00 2B 02 34 08 2B 06 34 04 1A FE 10 00
00000A70          2B 04 1A 0C 04 00 2B 06 1A 02 08 00 2B 04 1A 02
00000A80          00 00 2B 02 34 22 44 0C 34 0A 34 10 34 10 34 10
00000A90          1A 20 00 00 2B 04 34 18 34 06 1A 0E 00 00 2B F6
00000AA0          34 02 44 04 34 06 2B 02 44 02 1A 08 00 00 2B 08
00000AB0          34 0A 2B 0A 34 18 2B 04 34 02 34 2E 53 42 53 02
00000AC0          53 06 53 06 53 0C 53 0A 53 F2 53 FE 53 18 53 FE
00000AD0          53 F8 53 FE 5B 20 53 02 53 02 53 02 53 02 53 2E
00000AE0          53 02 53 02 53 02 53 24 53 02 53 02 53 02 53 02
00000AF0          53 02 53 02 53 02 53 02 53 02 53 02 53 02 49 01
00000B00          53 00 53 04                                    
GBASP x1, GBM x2, NDSL x2, PSP 100X x3, PSP 200X x6, PSP 300X x5, PSP Go x4, Wii x1

Post Reply

Return to “Half Byte Loader Development”