sceImpose_driver prevents kernel mode plugin from loading

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

sceImpose_driver prevents kernel mode plugin from loading

Post by Raphael »

I have a kernel mode prx plugin for custom firmwares, it works perfectly fine but as soon as I add a sceImposeGetParam(PSP_IMPOSE_MUTE) call the plugin fails loading. I first assumed it was due to the import stub being wrong and linking the user mode version of the function, but that wasn't the case. I also checked the NID in the stubs and it's ok.
Anyone got any idea what might be the cause?

Here's the makefile just in case:

BUILD_PLUGIN = 1

NOLIBM = 1

# Use only kernel libraries
USE_KERNEL_LIBS = 1

INCDIR =
CFLAGS = -Os -G0 -Wall -nostdlib -fno-builtin-printf -fno-builtin-log2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspumd_driver -lpsphprm_driver -lpsppower_driver

# Use the kernel's small inbuilt libc
USE_KERNEL_LIBC = 1
CFLAGS += -DNOLIBM
OBJS += minimath.o


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Are you setting the k1 register around the function call Raph?

Code: Select all

u32 k1 = pspSdkSetK1&#40;0&#41;;
int value = sceImposeGetParam&#40;PSP_IMPOSE_MUTE&#41;;
pspSdkSetK1&#40;k1&#41;;
Worth a shot :)
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Just tried it and I was sure that would be it, because I just didn't think of that simple thing. But unfortunately, that didn't help :/ Thanks anyway
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

What error do you get? Also, post the exports.
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

and imports... a prxtool -f yourprx would be usefull also what firmware you are using, altough according to silversping nid lists it seems that nid didn't get touched on 3.71
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

PSPLink tells me 0x80020139 when loading the prx, which resolves to "exclusiveload" - whatever that means. When I try to load the .elf directly, it says SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED (0x800200D9) - though that's probably because it's not inside a prx.

I'm on 3.52-M33 so the NIDs shouldn't be a problem either. As said, everything works fine until I just add the single function from sceImpose_driver.

Code: Select all

$ prxtool -o prxtool.txt -f motion_drv.prx
PRXTool v1.1 &#58; &#40;c&#41; TyRaNiD 2k6
Built&#58; Dec 30 2007 11&#58;47&#58;47
Loaded PRX motion_drv.prx successfully
Module information

Name&#58;    motion_driver
Attrib&#58;  1006
Version&#58; 1.0
GP&#58;      0000CE00

Exports&#58;
Export 0, Name syslib, Functions 3, Variables 1, flags 80000000
Functions&#58;
0xD632ACDB &#91;0x00000614&#93; - module_start
0xCEE8593C &#91;0x000005D8&#93; - module_stop
0x2F064FA6 &#91;0x0000059C&#93; - module_reboot_before
Variables&#58;
0xF01D73A7 &#91;0x00003860&#93; - module_info
Export 1, Name motion_driver, Functions 15, Variables 0, flags 40010000
Functions&#58;
0xEB4A30BC &#91;0x00000338&#93; - motion_driver_EB4A30BC
0x50FA90AC &#91;0x00000344&#93; - motion_driver_50FA90AC
0xA33941D6 &#91;0x00000358&#93; - motion_driver_A33941D6
0x4B7C4DEC &#91;0x00000570&#93; - motion_driver_4B7C4DEC
0x9523DD23 &#91;0x00000368&#93; - motion_driver_9523DD23
0xEE6B06A6 &#91;0x000003A4&#93; - motion_driver_EE6B06A6
0x597EC13C &#91;0x000003DC&#93; - motion_driver_597EC13C
0x02194114 &#91;0x00000418&#93; - motion_driver_02194114
0x714826B3 &#91;0x0000045C&#93; - motion_driver_714826B3
0x42109DA9 &#91;0x00000490&#93; - motion_driver_42109DA9
0xE97D21B8 &#91;0x000004B0&#93; - motion_driver_E97D21B8
0xE0480016 &#91;0x000004D0&#93; - motion_driver_E0480016
0x991F7996 &#91;0x000004F4&#93; - motion_driver_991F7996
0x3935F08D &#91;0x00000500&#93; - motion_driver_3935F08D
0xC3CF0383 &#91;0x00000540&#93; - motion_driver_C3CF0383

Imports&#58;
Import 0, Name sceCodec_driver, Functions 14, Variables 0, flags 00010011
Functions&#58;
0x02133959 &#91;0x000034E0&#93; - sceCodec_driver_02133959
0x20C61103 &#91;0x000034E8&#93; - sceCodec_driver_20C61103
0x261C6EE8 &#91;0x000034F0&#93; - sceCodec_driver_261C6EE8
0x28A49CCA &#91;0x000034F8&#93; - sceCodec_driver_28A49CCA
0x3064C53D &#91;0x00003500&#93; - sceCodec_driver_3064C53D
0x31B2E41E &#91;0x00003508&#93; - sceCodec_driver_31B2E41E
0x359C2B9F &#91;0x00003510&#93; - sceCodec_driver_359C2B9F
0x40D5C897 &#91;0x00003518&#93; - sceCodec_driver_40D5C897
0x6D945509 &#91;0x00003520&#93; - sceCodec_driver_6D945509
0x856E7487 &#91;0x00003528&#93; - sceCodec_driver_856E7487
0xBD8E0977 &#91;0x00003530&#93; - sceCodec_driver_BD8E0977
0xC513C747 &#91;0x00003538&#93; - sceCodec_driver_C513C747
0xDFBCACF3 &#91;0x00003540&#93; - sceCodec_driver_DFBCACF3
0xEEB91526 &#91;0x00003548&#93; - sceCodec_driver_EEB91526
Import 1, Name sceUmd, Functions 4, Variables 0, flags 00090000
Functions&#58;
0x46EBB729 &#91;0x00003550&#93; - sceUmd_46EBB729
0x8EF08FCE &#91;0x00003558&#93; - sceUmd_8EF08FCE
0xC6183D47 &#91;0x00003560&#93; - sceUmd_C6183D47
0xE83742BA &#91;0x00003568&#93; - sceUmd_E83742BA
Import 2, Name sceHprm_driver, Functions 4, Variables 0, flags 00010000
Functions&#58;
0x1C5BC5A0 &#91;0x00003570&#93; - sceHprm_driver_1C5BC5A0
0x588845DA &#91;0x00003578&#93; - sceHprm_driver_588845DA
0x208DB1BD &#91;0x00003580&#93; - sceHprm_driver_208DB1BD
0x7E69EDA4 &#91;0x00003588&#93; - sceHprm_driver_7E69EDA4
Import 3, Name scePower_driver, Functions 2, Variables 0, flags 00010000
Functions&#58;
0xEFD3C963 &#91;0x00003590&#93; - scePower_driver_EFD3C963
0x04B7766E &#91;0x00003598&#93; - scePower_driver_04B7766E
Import 4, Name sceDisplay_driver, Functions 1, Variables 0, flags 00010000
Functions&#58;
0x289D82FE &#91;0x000035A0&#93; - sceDisplay_driver_289D82FE
Import 5, Name sceCtrl_driver, Functions 4, Variables 0, flags 00010000
Functions&#58;
0x3A622550 &#91;0x000035A8&#93; - sceCtrl_driver_3A622550
0xC152080A &#91;0x000035B0&#93; - sceCtrl_driver_C152080A
0x1F803938 &#91;0x000035B8&#93; - sceCtrl_driver_1F803938
0x60B81F86 &#91;0x000035C0&#93; - sceCtrl_driver_60B81F86
Import 6, Name IoFileMgrForKernel, Functions 4, Variables 0, flags 00010000
Functions&#58;
0x810C4BC3 &#91;0x000035C8&#93; - IoFileMgrForKernel_810C4BC3
0x109F50BC &#91;0x000035D0&#93; - IoFileMgrForKernel_109F50BC
0x6A638D83 &#91;0x000035D8&#93; - IoFileMgrForKernel_6A638D83
0x42EC03AC &#91;0x000035E0&#93; - IoFileMgrForKernel_42EC03AC
Import 7, Name StdioForKernel, Functions 1, Variables 0, flags 00010000
Functions&#58;
0xCAB439DF &#91;0x000035E8&#93; - StdioForKernel_CAB439DF
Import 8, Name sceSysreg_driver, Functions 2, Variables 0, flags 00010000
Functions&#58;
0x7FD7A631 &#91;0x000035F0&#93; - sceSysreg_driver_7FD7A631
0xBB823481 &#91;0x000035F8&#93; - sceSysreg_driver_BB823481
Import 9, Name UtilsForKernel, Functions 3, Variables 0, flags 00090000
Functions&#58;
0xB435DEC5 &#91;0x00003600&#93; - UtilsForKernel_B435DEC5
0x3EE30821 &#91;0x00003608&#93; - UtilsForKernel_3EE30821
0x920F104A &#91;0x00003610&#93; - UtilsForKernel_920F104A
Import 10, Name sceSyscon_driver, Functions 3, Variables 0, flags 00010000
Functions&#58;
0xBBFB70C0 &#91;0x00003618&#93; - sceSyscon_driver_BBFB70C0
0x805180D1 &#91;0x00003620&#93; - sceSyscon_driver_805180D1
0x44439604 &#91;0x00003628&#93; - sceSyscon_driver_44439604
Import 11, Name InterruptManagerForKernel, Functions 6, Variables 0, flags 00010
000
Functions&#58;
0x092968F4 &#91;0x00003630&#93; - InterruptManagerForKernel_092968F4
0x5F10D406 &#91;0x00003638&#93; - InterruptManagerForKernel_5F10D406
0x58DD8978 &#91;0x00003640&#93; - InterruptManagerForKernel_58DD8978
0xF987B1F0 &#91;0x00003648&#93; - InterruptManagerForKernel_F987B1F0
0x4D6E7305 &#91;0x00003650&#93; - InterruptManagerForKernel_4D6E7305
0xD774BA45 &#91;0x00003658&#93; - InterruptManagerForKernel_D774BA45
Import 12, Name ThreadManForKernel, Functions 5, Variables 0, flags 00010000
Functions&#58;
0xE81CAF8F &#91;0x00003660&#93; - ThreadManForKernel_E81CAF8F
0xCEADEB47 &#91;0x00003668&#93; - ThreadManForKernel_CEADEB47
0x446D8DE6 &#91;0x00003670&#93; - ThreadManForKernel_446D8DE6
0x9FA03CD3 &#91;0x00003678&#93; - ThreadManForKernel_9FA03CD3
0xF475845D &#91;0x00003680&#93; - ThreadManForKernel_F475845D
Import 13, Name SysclibForKernel, Functions 7, Variables 0, flags 00010000
Functions&#58;
0x87F8D2DA &#91;0x00003688&#93; - SysclibForKernel_87F8D2DA
0xC0AB8932 &#91;0x00003690&#93; - SysclibForKernel_C0AB8932
0xEC6F1CF2 &#91;0x00003698&#93; - SysclibForKernel_EC6F1CF2
0xB1DC2AE8 &#91;0x000036A0&#93; - SysclibForKernel_B1DC2AE8
0x52DF196C &#91;0x000036A8&#93; - SysclibForKernel_52DF196C
0x10F3BB61 &#91;0x000036B0&#93; - SysclibForKernel_10F3BB61
0x7661E728 &#91;0x000036B8&#93; - SysclibForKernel_7661E728
Import 14, Name sceImpose_driver, Functions 1, Variables 0, flags 00010000
Functions&#58;
0x531C9778 &#91;0x000036C0&#93; - sceImpose_driver_531C9778
Import 15, Name InitForKernel, Functions 4, Variables 0, flags 00090000
Functions&#58;
0x27932388 &#91;0x000036C8&#93; - InitForKernel_27932388
0x7233B5BC &#91;0x000036D0&#93; - InitForKernel_7233B5BC
0x7A2333AD &#91;0x000036D8&#93; - InitForKernel_7A2333AD
0xA6E71B93 &#91;0x000036E0&#93; - InitForKernel_A6E71B93
Done
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

Did you try the module in vsh?

I assume most exported NIDs for impose_driver work only w/vshmain running.
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Maybe you should try to build other impose library, and using 00010011 as flags.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

KickinAezz wrote:Did you try the module in vsh?

I assume most exported NIDs for impose_driver work only w/vshmain running.
Yes, that's where I tried it first, but it doesn't load neither in VSH nor in game nor from PSPLink.
moonlight wrote:Maybe you should try to build other impose library, and using 00010011 as flags.
Funnily enough, the stub had 0x00010011 as flags first and I changed that to 0x00010000 seeing how most other kernel libs had that (or 0x00090000) as flags. What is the meaning of the 0011 anyway?
Still that didn't change the behaviour :/

EDIT: It seems I found the solution - sceImpose_driver needs to be flagged 0x00090000. Can't really explain why though
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Well that number 0011 was only the version. I once had a problem with not setting the version, but I think it was in an export when trying to imitate a sce prx rather than in a import. The imitated prx wouldn't work with the incorrect version.

I also can't understand why it works now with that flag. That flag is for the delayed imports, and impose is always loaded :/
ahman
Posts: 22
Joined: Wed May 31, 2006 10:57 am

Post by ahman »

The reason why the delayed import worked was 'cos the impose.prx hasn't been loaded when the plugin is started. It's CFW plugin which loads at around mediasync.prx (way before impose.prx) is loaded IIRC. :P
Post Reply