forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Install a bootstrap and return to application... how?
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 1:53 am    Post subject: Reply with quote

:D, thanks!
I'll try this solution yet!
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 2:28 am    Post subject: Reply with quote

Uff, I've try but when I try to load the executables from the prx I've this error:
SCE_KERNEL_ERROR_ILLEGAL_PERM_CALL
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 2:46 am    Post subject: Reply with quote

I've try to load the module of the exported function with loadstartmodule and pspSdkLoadStartModule but I've still get error 0x80020149!

Here is the stub file created: ( Execute is my function )
Code:

   .set noreorder

#include "pspstub.s"

   STUB_START "RDLib",0x40090000,0x00030005
   STUB_FUNC  0x7F3D307A,SetConfFile
   STUB_FUNC  0xB64186D0,SetUmdFile
   STUB_FUNC  0xE86CA36E,Execute
   STUB_END


Export file:
Code:

# Define the exports for the prx
PSP_BEGIN_EXPORTS

# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END

PSP_EXPORT_START(RDLib, 0, 0x4001)
PSP_EXPORT_FUNC(SetConfFile)
PSP_EXPORT_FUNC(SetUmdFile)
PSP_EXPORT_FUNC(Execute)
PSP_EXPORT_END

PSP_END_EXPORTS


Here is the prx:
Code:

PSP_MODULE_INFO("KrnlMod", 0x1007, 1, 0);

PSP_HEAP_SIZE_KB(1024);

#define printf pspDebugScreenPrintf
#define sleep(n) sceKernelDelayThread(n)

u32 orig_funcs[2];

int ExitPatched()
{
   int k1 = pspSdkSetK1(0);

   char *program = "ms0:/PSP/GAME/Xplora_v1.0/EBOOT.PBP";
   struct SceKernelLoadExecVSHParam param;

   memset(&param, 0, sizeof(param));
   param.size = sizeof(param);
   param.args = strlen(program)+1;
   param.argp = program;
   param.key = "game";

   int res = sctrlKernelLoadExecVSHMs2(program, &param);
   pspSdkSetK1(k1);
   return res;
}

int ExitPatched2()
{
   return ExitPatched();
}

void SetConfFile(int n)
{
   int k1 = pspSdkSetK1(0);
   sctrlSESetBootConfFileIndex(n);
   pspSdkSetK1(k1);
}

void SetUmdFile(char *umdfile)
{
   int k1 = pspSdkSetK1(0);
   sctrlSESetUmdFile(umdfile);
   pspSdkSetK1(k1);
}

void Execute(char* target)
{
    SceUID mod = sceKernelLoadModuleMs2(target, 0, NULL);
   
    if (mod >= 0)
    {
            mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
            if (mod < 0)
                pspDebugScreenInit();
                printf("\nError 0x%08X starting module.\n", mod);
                sleep(3000000);
    }
    else
    {
            if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
            {
                    // Ignore this error, it means the module loaded on reboot
            }
            else
            {
                pspDebugScreenInit();
                printf("\nError 0x%08X loading module.\n",  mod);
                sleep(3000000);
            }
    }
   
    return;
}

int main_thread(SceSize args, void *argp)
{
/*
    pspDebugScreenInit();
   
    char* argm = argp;

    char* arg = strtok(argm, "{");

    char arguments[4][128];
   
    int n=0;
   
    while(arg!=NULL)
    {
        sprintf(arguments[n], "%s", arg);
        arg = strtok(NULL, "{");
        n++;
    }
   
    // printf("\nArg0: %s\nArg1: %s\nArg2: %s\nArg3: %s", arguments[0], arguments[1], arguments[2], arguments[3]);
   
    // sceKernelDelayThread(3000000);
*/
   
   
    // Patcher function
    orig_funcs[0] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x05572A5F);
    orig_funcs[1] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x2AC9954B);
    sctrlHENPatchSyscall(orig_funcs[0], ExitPatched); // sceKernelExitGame
    sctrlHENPatchSyscall(orig_funcs[1], ExitPatched2); // sceKernelExitGameWithStatus
   
/*
   
    // Loader funcions
   
    sceDisplaySetHoldMode(1);
   
    SceUID mod = sceKernelLoadModuleMs2("ms0:/PSP/GAME/Filer_5.0/EBOOT.PBP", 0, NULL);
   
   
    // Starter function
   
    if (mod >= 0)
    {
            mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
            if (mod < 0)
                printf("\nError 0x%08X starting module.\n", mod);
                sleep(3000000);
    }
    else
    {
            if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
            {
                    // Ignore this error, it means the module loaded on reboot
            }
            else
            {
                printf("\nError 0x%08X loading module.\n",  mod);
                sleep(3000000);
            }
    }
*/
   
    return 0;
}



int module_start(SceSize args, void *argp)
{
    SceUID th = sceKernelCreateThread("main_thread", main_thread, 8, 4*1024, 0, NULL);

    if (th >= 0)
    {
      sceKernelStartThread(th, args, argp);
    }
    return 0;
}


int module_stop(SceSize args, void *argp)
{
    return 0;
}


Execute function:
Code:

void Execute(char* target)
{
    SceUID mod = sceKernelLoadModuleMs2(target, 0, NULL);
   
    if (mod >= 0)
    {
            mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
            if (mod < 0)
                pspDebugScreenInit();
                printf("\nError 0x%08X starting module.\n", mod);
                sleep(3000000);
    }
    else
    {
                pspDebugScreenInit();
                printf("\nError 0x%08X loading module.\n",  mod);
                sleep(3000000);
    }
}


And here is the function in the main programm:

Code:

    SceUID mod = pspSdkLoadStartModule("ms0:/krnlmod.prx", PSP_MEMORY_PARTITION_KERNEL);
    if(mod<0)
    {
        if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
            {
                    // Ignore this error, it means the module loaded on reboot
            }
        else
            {
                pspDebugScreenInit();
                printf("\n(krnlmod.prx)Errore 0x%08X loading module.\n",  mod);
                sleep(3000000);
            }
    }
   
   
    Execute("ms0:/PSP/GAME/HOMEBREW/EBOOT.PBP");
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 3:27 am    Post subject: Reply with quote

the 3rd argument in:
sceKernelLoadModuleMs2
from your execute function cannot be NULL
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 3:57 am    Post subject: Reply with quote

Code:

/**
  * Load a PBP (used for non updater pbp's) (0x141)
  *
  * @param path - The path to the module to load.
  * @param flags - Unused, always 0 .
  * @param option  - Pointer to a mod_param_t structure. Can be NULL.
  *
  * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
  */
SceUID ModuleMgrForKernel_49C5B9E1(const char *path, int flags, SceKernelLMOption *option);

?? This is the function and it says that the 3rd arg can be NULL!
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 3:59 am    Post subject: Reply with quote

try this:
Code:

SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;

memset(&option, 0, sizeof(option));
         
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;

option.position = 0;
option.access = 1;


and use &option instead of NULL
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 4:15 am    Post subject: Reply with quote

I still get error 0x80020149!
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 4:17 am    Post subject: Reply with quote

when loading the kernel prx I believe.
right? (as you are not checking anything when using the Execute function)
Edit:
this should be your Execute function:
Code:

SceUID modid;
int status;
char args[1024];
int len;

SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;

memset(&option, 0, sizeof(option));
         
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;

option.position = 0;
option.access = 1;

uid = sceKernelLoadModuleMs2(Line[0], 0, &option);
if (uid < 0)

{
   // error
}
else {
   len = build_args(args, Line[0], 0, NULL);         

   modid = sceKernelStartModule(uid, len, (void *) args, &status, NULL);



   if (modid < 0)

   {

      // error

   }
   else {
      // success
   }
}


Edit 2:
make sure you have a build_args function in your code.
Use this one(I got it from psplink's source code)
Code:

int build_args(char *args, const char *execfile, int argc, char **argv)
{
   int loc = 0;
   int i;

   strcpy(args, execfile);
   loc += strlen(execfile) + 1;

   for(i = 0; i < argc; i++)
   {
      strcpy(&args[loc], argv[i]);
      loc += strlen(argv[i]) + 1;
   }
   return loc;
}

_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 4:23 am    Post subject: Reply with quote

The error is from the execute function, when try to load the eboot.pbp!
The prx is loaded perfectly, I'm using another solution for args, but the problem is when I try to load a Eboot with the Execute function!
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 4:39 am    Post subject: Reply with quote

Have you tried what I Posted?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Sat Jul 05, 2008 8:12 am    Post subject: Reply with quote

There is a sample in the sdk of the CF 4.01 released by dark alex called bootload
that correspond what you will do:
Launching iso,psx,homebrew from a program and at end of the iso,psx,homebrew
return to the launcher
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 8:26 am    Post subject: Reply with quote

he already knows but he is trying to use loadmodule* functions which support 3.xx kernel.
the sample included in 4.0.1 m33-x is for 4.0.1 m33-x and only works on those versions
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 6:59 pm    Post subject: Reply with quote

This funcion is the same as my!
However thanks very much Pirata Nervo for your unbelievable patience... :(
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 8:47 pm    Post subject: Reply with quote

try what I posted:
Code:

int Execute(char *file)
{
   SceUID modid;
   int status;
   char args[1024];
   int len;

   SceKernelLMOption option;
   SceUID mpid = PSP_MEMORY_PARTITION_USER;

   memset(&option, 0, sizeof(option));
         
   option.size = sizeof(option);
   option.mpidtext = mpid;
   option.mpiddata = mpid;

   option.position = 0;
   option.access = 1;

   uid = sceKernelLoadModuleMs2(file, 0, &option);
   if (uid < 0)
   {
       // error
       return uid;
   }
   else {
      len = build_args(args, file, 0, NULL);         

      modid = sceKernelStartModule(uid, len, (void *) args, &status, NULL);

      if (modid < 0)
      {
         // error
         return modid;
      }
      else {
         // success
      }
}

_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 9:39 pm    Post subject: Reply with quote

Still error 0x80020149... :(
Maybe I've do a error in the export file or else because the error means
that the operation is not permitted (ILLEGAL... ), so I've think that I've do a error...
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 9:43 pm    Post subject: Reply with quote

are you trying to launch a kernel homebrew? lol
that maybe your problem.
If the homebrew you are trying to load is kernel mode you may get that error :/
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sat Jul 05, 2008 9:49 pm    Post subject: Reply with quote

No, it's a normal user hb!
I've try to build my prog as a normal Eboot ( no BUILD_PRX) and when I call the execute function the PSP crash! :(
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jul 05, 2008 9:56 pm    Post subject: Reply with quote

get the sample from 4.0.1 and edit what you need.
ps. what do you need to edit?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sun Jul 06, 2008 9:28 pm    Post subject: Reply with quote

Ok, I've tryed to edit the DAX sample and if I try to execute a file using the exported function I've error 0x80020149 ( I think it's because I cannot use the module mgr function in a exported funct ) and if I try to load with your Execute function the PSP crash before the error is completely printed!
( For example the last time that I've try to start it I've seen on the screen:
"Erro" and the PSP crash before I can see the error! Why??

EDIT:
Have you already found a solution for that I'm trying to do?
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Jul 06, 2008 9:44 pm    Post subject: Reply with quote

there should be NO problem exporting a function with load module.
which Execute function are you using, mine or yours?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sun Jul 06, 2008 9:48 pm    Post subject: Reply with quote

yours!
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Jul 06, 2008 9:53 pm    Post subject: Reply with quote

then use it like this:
int exec = Execute("path/here");
if (exec < 0) {
printf("0x%08X", exec); // prints error to the screen
sceKernelDelayTHread(100000*2); // waits 2 seconds
}
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sun Jul 06, 2008 10:19 pm    Post subject: Reply with quote

Still the same error (0x80020149)
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Jul 06, 2008 10:45 pm    Post subject: Reply with quote

I know, that was to fix the "I can't see the error" problem lol.
Which firmware are you on?
Do you have 1.50 kernel enabled?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sun Jul 06, 2008 10:59 pm    Post subject: Reply with quote

Slim with 3.90 M33-3
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Jul 06, 2008 11:04 pm    Post subject: Reply with quote

1.50 kernel enabled?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Sun Jul 06, 2008 11:08 pm    Post subject: Reply with quote

No
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Jul 07, 2008 12:19 am    Post subject: Reply with quote

you know what you need to load your prx before using the Execute function right?


anyway
Do this instead:
create a pbp.
create a prx which has the execute function. (dont export it)
load the prx from the pbp. the prx loads the path from a file written by the pbp. the prx uses the path got from the file and uses it in the execute function.
Make sure you use the apihook lib from psplink (included in the sample by cpasjuste).
just hook sceKernelExitGame instead of loading dax's driver as it is just useful for 4.xx kernel
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
darkness



Joined: 15 Jun 2008
Posts: 121

PostPosted: Mon Jul 07, 2008 1:08 am    Post subject: Reply with quote

Yes, I know, if I didn't load the prx the function isn't executed without errors!
However, I'm using the DAx function for patch the exit game function and it works great!
Anyway why I have to load the path from file? Can't I pass it as a arg? I've already do it and it works fine! ( exep the load error ).
Thanks very much, I'll try your solution!
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Jul 07, 2008 1:25 am    Post subject: Reply with quote

yeh you can pass the path but in my case as I have to pass at least 3 arguments, it's easier than passing the arguments from the pbp to the prx
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group