How to load decrypted modules ?

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

Moderators: cheriff, TyRaNiD

Post Reply
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

How to load decrypted modules ?

Post by johnmph »

Hello, i have decrypted a module with decrypter sample of PSPSDK.

I have try to load it with sceKernelLoadModule but it doesn't work, why ?

Is there a function to load decrypted module (ELF) ?

Thanks.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

when it sets user mode, make sure you are in kernel mode.
Lego of my Ago!
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

Agoln wrote:when it sets user mode, make sure you are in kernel mode.
I am in user mode with kernel memory access and pspSdkInstallNoDeviceCheckPatch(); is called in _init function.

It's works with encrypted module but i have a SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE error with decrypted module.
PspPet
Posts: 210
Joined: Wed Mar 30, 2005 2:13 am
Contact:

Post by PspPet »

> Is there a function to load decrypted module (ELF) ?
The system can be tricked (along the lines of what you are trying to do)
Kernel memory module flag (0x1000) AND kernel thread required for most of this loading trickery.
http://forums.ps2dev.org/viewtopic.php?p=16537
(look for "LoadModule tips and tricks")

In general most PRXs must be loaded from a kernel thread. You can use them later from a user thread.
This can cause unrelated problems (BTW: I believe it is the root cause of DHCP not working), and the library entries can be tricky.

Which PRX are you loading, and what are you doing special ? (ie. there may be more specific advice)
----
FWIW:
The official system wants support libraries to be encrypted (for obvious reasons).
IMHO, if you already have the encrypted ELF file (ie. the PRX), you can load it directly. If you want to tweek the ELF file, you can load it first, then party on the loaded memory image. No need for "pspSdkInstallNoDeviceCheckPatch"
[ie. if trying to tweek a loadable PRX library, I suggest changing the library directly instead of changing the entire system]
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well I can probably guess why it is failing, you are trying to load a plain text kernel module which by default will not work. You can load plain text user modules such as pspnet but the kernel will refuse anything with the 0x1000 attribute which is born out if you install a kprintf handler.

As psppet says there is probably littlle real reason why you can't just load the original encrypted form, though if you really really really have to do it then (seeing as I am in a good mood) call pspSdkInstallNoPlainModuleCheckPatch in kernel mode to disable the check.
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

PspPet wrote:> Is there a function to load decrypted module (ELF) ?
The system can be tricked (along the lines of what you are trying to do)
Kernel memory module flag (0x1000) AND kernel thread required for most of this loading trickery.
http://forums.ps2dev.org/viewtopic.php?p=16537
(look for "LoadModule tips and tricks")

In general most PRXs must be loaded from a kernel thread. You can use them later from a user thread.
This can cause unrelated problems (BTW: I believe it is the root cause of DHCP not working), and the library entries can be tricky.

Which PRX are you loading, and what are you doing special ? (ie. there may be more specific advice)
----
FWIW:
The official system wants support libraries to be encrypted (for obvious reasons).
IMHO, if you already have the encrypted ELF file (ie. the PRX), you can load it directly. If you want to tweek the ELF file, you can load it first, then party on the loaded memory image. No need for "pspSdkInstallNoDeviceCheckPatch"
[ie. if trying to tweek a loadable PRX library, I suggest changing the library directly instead of changing the entire system]
In your tricks, you says :

"You can load encrypted files from the MS, but that leads to potential copyright problems.
Trying to load unencrypted PRX files fails [can't load a "PLAIN" module]"

Could the new function pspSdkInstallNoPlainModuleCheckPatch() of the PSPSDK solve the problem?

I have modify PRXdecrypt sample :

/* Check if we managed to decrypt the file */
if(*(unsigned short *)(check+0x5a) & 1)
{
/* Set decrypt buffer pointer */
*(unsigned int*)(check+0x24) = (unsigned int) g_decrypt_buf;
sceKernelCheckExecFile(g_data, check);
//output = g_decrypt_buf;
output = g_data;
}
else
output = g_data;

for writing g_data buffer instead g_decrypt_buf (decompressed but not decrypted) and i have noted only chnnlsv.prx (VSH module) module is not encrypted.

I think we can load decrypted modules but they must be compressed (PSP format) because chnnlsv.prx is in flash0 and he can be loaded.

"if you already have the encrypted ELF file (ie. the PRX), you can load it directly. If you want to tweek the ELF file, you can load it first, then party on the loaded memory image"

I will try that, thanks for your help.
Last edited by johnmph on Tue Aug 09, 2005 5:11 am, edited 1 time in total.
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

TyRaNiD wrote:Well I can probably guess why it is failing, you are trying to load a plain text kernel module which by default will not work. You can load plain text user modules such as pspnet but the kernel will refuse anything with the 0x1000 attribute which is born out if you install a kprintf handler.

As psppet says there is probably littlle real reason why you can't just load the original encrypted form, though if you really really really have to do it then (seeing as I am in a good mood) call pspSdkInstallNoPlainModuleCheckPatch in kernel mode to disable the check.
I had not seen your post message, i have used pspSdkInstallNoPlainModuleCheckPatch but i have a black screen and the psp shutdown.

I will try to load encrypted module and then modify functions in memory if i found address where loaded module is stored.

Thanks
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

"for writing g_data buffer instead g_decrypt_buf (decompressed but not decrypted) and i have noted only chnnlsv.prx (VSH module) module is not encrypted."

I made an error, i think that chnnlsv.prx is encrypted but not compressed.
Post Reply