[SOLVED] sctrlKernelLoadExecVSHMs2()

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

Moderators: cheriff, TyRaNiD

Post Reply
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

[SOLVED] sctrlKernelLoadExecVSHMs2()

Post by vista200 »

Hey everyone!

This is my first post in this forum, so please be patient with me!

I'm trying to run an Homebrew from my own program, but it won't work!

I've implemented the systemctrl.h from the 3.71 M33 SDK, which has the sctrlKernelLoadExecVSHMs2()-function, but when I try to compile the code, I get this errors:

Code: Select all

$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=
390   -c -o main.o main.c
In file included from main.c:4:
./include/systemctrl.h:189: error: expected ')' before '*' token
./include/systemctrl.h:230: error: expected '=', ',', ';', 'asm' or '__attribute
__' before 'sctrlHENSetStartModuleHandler'
make: *** [main.o] Error 1
In this error messages I can't see a mistake of me, but there seem to be mistakes in D_A's code.

I took the code from here: http://forums.ps2dev.org/viewtopic.php?t=9247

main.c:

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include "./include/systemctrl.h"

PSP_MODULE_INFO&#40;"Hello World", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
sceKernelExitGame&#40;&#41;;
return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
int cbid;

cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
sceKernelRegisterExitCallback&#40;cbid&#41;;

sceKernelSleepThreadCB&#40;&#41;;

return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
int thid = 0;

thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
if&#40;thid >= 0&#41; &#123;
sceKernelStartThread&#40;thid, 0, 0&#41;;
&#125;

return thid;
&#125;

void execEboot&#40;char *target&#41;
&#123;   
   struct SceKernelLoadExecVSHParam param;
         
   memset&#40;&param, 0, sizeof&#40;param&#41;&#41;;
         
   param.key = "game";
   param.size = sizeof&#40;param&#41;;
   param.args = strlen&#40;target&#41;+1;
   param.argp = target;

   sctrlKernelLoadExecVSHMs2&#40;target, &param&#41;;   

&#125; 

int main&#40;&#41; &#123;

SetupCallbacks&#40;&#41;;
pspDebugScreenInit&#40;&#41;;
printf&#40;"Hello World"&#41;;
execEboot&#40;"ms0&#58;/PSP/GAME/PSPTube/EBOOT.PBP"&#41;;
sceKernelSleepThread&#40;&#41;;

return 0;
&#125;
and makefile:

Code: Select all

TARGET = hello
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World
PSP_FW_VERSION = 390

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
Thanks in advance,
vista200
Last edited by vista200 on Wed Mar 19, 2008 7:32 pm, edited 1 time in total.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Open your systemctrl.h file and add this after the includes:

Code: Select all

typedef struct SceModule2
&#123;
   struct SceModule   *next; // 0
   u16               attribute; // 4
   u8               version&#91;2&#93;; // 6
   char            modname&#91;27&#93;; // 8
   char            terminal; // 0x23
   char            mod_state;   // 0x24
    char            unk1;    // 0x25
   char            unk2&#91;2&#93;; // 0x26
   u32               unk3;   // 0x28
   SceUID            modid; // 0x2C
   u32               unk4; // 0x30
   SceUID            mem_id; // 0x34
   u32               mpid_text;   // 0x38
   u32               mpid_data; // 0x3C
   void *            ent_top; // 0x40
   unsigned int      ent_size; // 0x44
   void *            stub_top; // 0x48
   u32               stub_size; // 0x4C
   u32               entry_addr_; // 0x50
   u32               unk5&#91;4&#93;; // 0x54
   u32               entry_addr; // 0x64
   u32               gp_value; // 0x68
   u32               text_addr; // 0x6C
   u32               text_size; // 0x70
   u32               data_size;   // 0x74
   u32               bss_size; // 0x78
   u32               nsegment; // 0x7C
   u32               segmentaddr&#91;4&#93;; // 0x80
   u32               segmentsize&#91;4&#93;; // 0x90
&#125; SceModule2;
Image
Upgrade your PSP
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

Half way to success!

Post by vista200 »

Hey again!

Thanks for the tip! Now I can compile my project without problems, but when I try to launch a Homebrew or an official Update, nothing happens.

I've also tried in User- and Kernel-Mode.

I think, that an example would help me very much!

So please, could someone show me, how it works!? I'm getting crazy! I've searched a lot in the web and here in the forum, but i found nothing applicable for me.

I do two printfs, one before and one after the execEboot(), both show their texts, but nothing is launched. Something goes wrong here... The program doesn't even hang: I can exit it through the HOME-Button.

Thanks again!
vista200
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Paste your code again please.
Image
Upgrade your PSP
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

It works!

Post by vista200 »

Thanks, but now it works. It's like magic! But here's the code again:

main.c:

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <systemctrl.h>

PSP_MODULE_INFO&#40;"Hello World", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR &#40;0&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
sceKernelExitGame&#40;&#41;;
return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
int cbid;

cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
sceKernelRegisterExitCallback&#40;cbid&#41;;

sceKernelSleepThreadCB&#40;&#41;;

return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
int thid = 0;

thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
if&#40;thid >= 0&#41; &#123;
sceKernelStartThread&#40;thid, 0, 0&#41;;
&#125;

return thid;
&#125;

void execEboot&#40;char *target&#41;
&#123;   
   struct SceKernelLoadExecVSHParam param;
         
   memset&#40;&param, 0, sizeof&#40;param&#41;&#41;;
         
   param.key = "game";
   param.size = sizeof&#40;param&#41;;
   param.args = strlen&#40;target&#41;+1;
   param.argp = target;

   sctrlKernelLoadExecVSHMs2&#40;target, &param&#41;;   

&#125;

int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
SetupCallbacks&#40;&#41;;

printf&#40;"Hello World"&#41;;
execEboot&#40;"ms0&#58;/PSP/GAME/PSPTube/EBOOT.PBP"&#41;;

sceKernelSleepThread&#40;&#41;;

return 0;
&#125;
makefile:

Code: Select all

TARGET = hello
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World

LIBS = -lpspsystemctrl_user

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
As stated above, I don't know what happened to the code, but it works!

Thanks for the help!
vista200
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

I dont now why,

But i get ALWAYS with excute eboot codes, a compile error :


Code: Select all

main.c&#58; In function 'execEboot'&#58;
main.c&#40;92&#41; &#58; error&#58; storage size of 'param' isn't known
main.c&#40;101&#41; &#58; warning&#58; implicit declaration of function 'sctrlKernelLoadExecVSHM
s2'

Help, TY !!
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

@Question_dev, this function:
sctrlKernelLoadExecVSHM
does not exist
Image
Upgrade your PSP
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

...I now ...

But i wrote :

main.c: In function 'execEboot':
main.c(92) : error: storage size of 'param' isn't known
main.c(101) : warning: implicit declaration of function 'sctrlKernelLoadExecVSHMs2'

(s2 was on next line...)

TY
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

sorry I did not see it.
Post your code then
Image
Upgrade your PSP
Post Reply