[RESOLVED] Who can explain how to load functions by NID ?
[RESOLVED] Who can explain how to load functions by NID ?
Hi everybody,
all is in this title, Who can do it ?
I think iit's very important to know how to do it, because when I see the pspsdk and the number of function that appears in list of NID, I think it's very pity.
thx,
all is in this title, Who can do it ?
I think iit's very important to know how to do it, because when I see the pspsdk and the number of function that appears in list of NID, I think it's very pity.
thx,
Last edited by racine_20 on Wed Aug 02, 2006 5:06 pm, edited 1 time in total.
This should work. Thanks to moonlight for helping me with it a while back.
This is an example and uses the function scePower_0442D852
In this example, it is called asreboot(0) because the function only seems to work that way, but obviously you would change the contents of the brackets to whatever arguments you would be sending.
I think there is a more efficient way of doing this but for me it works :)
Regards
Code: Select all
// From PspPet's PSARDUMPER
static u32 FindProc(const char* szMod, const char* szLib, u32 nid)
{
SceModule* modP = sceKernelFindModuleByName(szMod);
if (modP == NULL)
{
printf("Failed to find mod '%s'\n", szMod);
return 0;
}
SceLibraryEntryTable* entP = (SceLibraryEntryTable*)modP->ent_top;
while ((u32)entP < ((u32)modP->ent_top + modP->ent_size))
{
if (entP->libname != NULL && strcmp(entP->libname, szLib) == 0)
{
// found lib
int i;
int count = entP->stubcount + entP->vstubcount;
u32* nidtable = (u32*)entP->entrytable;
for (i = 0; i < count; i++)
{
if (nidtable[i] == nid)
{
u32 procAddr = nidtable[count+i];
// printf("entry found: '%s' '%s' = $%x\n", szMod, szLib, (int)procAddr);
return procAddr;
}
}
printf("Found mod '%s' and lib '%s' but not nid=$%x\n", szMod, szLib, nid);
return 0;
}
entP++;
}
printf("Found mod '%s' but not lib '%s'\n", szMod, szLib);
return 0;
}
static void my_function(void)
{
int (* power) (int);
reboot = (void *)FindProc("scePower_Service", "scePower_driver", 0x0442D852);
if (!reboot)
{
sceKernelExitGame();
}
else
{
reboot(0);
}
}
In this example, it is called asreboot(0) because the function only seems to work that way, but obviously you would change the contents of the brackets to whatever arguments you would be sending.
I think there is a more efficient way of doing this but for me it works :)
Regards
Hi jas0nuk,
Thx for the answer, She look like great and easy.
But, when I look your example with "scePower_Service", I can see that
,appears 3 args, const char* szMod (scePower_Service), const char* szLib (scePower_driver) , u32 nid (0x0442D852).
I can understand 2nd and 3th args but not the 1st, where you can find this ?
So, for example, I need "sceUtilityDeleteNetParam" with NID 0x9ce50172.
I guess that function need 1 arg who's will the number of config to delete.
How to comunicate to this function this number ?? :) damn
If you can do it, you'll be the best ;)
thxxx
Thx for the answer, She look like great and easy.
But, when I look your example with "scePower_Service", I can see that
Code: Select all
reboot = (void *)FindProc("scePower_Service", "scePower_driver", 0x0442D852);
I can understand 2nd and 3th args but not the 1st, where you can find this ?
So, for example, I need "sceUtilityDeleteNetParam" with NID 0x9ce50172.
I guess that function need 1 arg who's will the number of config to delete.
How to comunicate to this function this number ?? :) damn
If you can do it, you'll be the best ;)
thxxx
Code: Select all
reboot = (void *)FindProc("sceUtility_driver", "sceUtility_netparam_internal", 0x9CE50172);
http://pspdev.ofcode.com/api2.0/index.php is another useful resource for this sort of thing.
danzel>
jas0nuk>
I suppose that the function can use as it :
How give "num_profil" to the function ?
I don't understand very much your line, sorry I'm bad ;)
Thx for all jas0nuk
lol ! not for me .... nobody functions is explains, just the name, but also help in many case.http://pspdev.ofcode.com/api2.0/index.php is another useful resource for this sort of thing.
jas0nuk>
I suppose that the function can use as it :
Code: Select all
int ret;
int num_profil = 1;
ret = sceUtilityDeleteNetParam( num_profil );
fprint( "function return : %i",ret);
I don't understand very much your line, sorry I'm bad ;)
Thx for all jas0nuk
I'm not sure what you're asking... but if you want to send an argument to the function, you could just call it as...
after using the line I showed you before
Code: Select all
reboot(num_profil);
I'm back again :) !
I try your sample, it's appear correctly when I compile it, but when I execute it, he crash on line in FindProc :
when I call it by :
And finish to black screen/shutdown.
Damn, I smelled come the end of it, but not.
Are you an idea about this problem ?
( PS : good luck for 0x89 Jas0nuk )
I try your sample, it's appear correctly when I compile it, but when I execute it, he crash on line in FindProc :
Code: Select all
SceModule* modP = sceKernelFindModuleByName(szMod);
Code: Select all
DeleteNetParam = (void *)FindProc("sceUtility_driver", "sceUtility_netparam_internal", 0x9CE50172);
Damn, I smelled come the end of it, but not.
Are you an idea about this problem ?
( PS : good luck for 0x89 Jas0nuk )
This is a sample of my code
I think I was in kernel mode, but I haven't enought knowledge about kernel mode, so ... .
Code: Select all
// *** MODULE INITIALISATION ***
PSP_MODULE_INFO("TestWifi",0x1000,1,1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(32);
//*** CallBack section *******
// ........
// ************************
static u32 FindProc(const char* szMod, const char* szLib, u32 nid)
{
//*********** BLACKSCREEN HERE *****************
SceModule* modP = sceKernelFindModuleByName(szMod);
if (modP == NULL)
{
pspDebugScreenPrintf("Failed to find mod '%i'\n", szMod);
return NULL;
}
SceLibraryEntryTable* entP = (SceLibraryEntryTable*)modP->ent_top;
while ((u32)entP < ((u32)modP->ent_top + modP->ent_size))
{
if (entP->libname != NULL && strcmp(entP->libname, szLib) == 0)
{
// found lib
int i;
int count = entP->stubcount + entP->vstubcount;
u32* nidtable = (u32*)entP->entrytable;
for (i = 0; i < count; i++)
{
if (nidtable[i] == nid)
{
u32 procAddr = nidtable[count+i];
// printf("entry found: '%s' '%s' = $%x\n", szMod, szLib, (int)procAddr);
return procAddr;
}
}
pspDebugScreenPrintf("Found mod '%s' and lib '%s' but not nid=$%x\n", szMod, szLib, nid);
return NULL;
}
entP++;
}
pspDebugScreenPrintf("Found mod '%s' but not lib '%s'\n", szMod, szLib);
return NULL;
}
int sceUtilityDeleteNetParam(int NetParam)
{
int (*DeleteNetParam) (int);
DeleteNetParam = (void *)FindProc("sceUtility_driver", "sceUtility_netparam_internal", 0x9CE50172);
if (DeleteNetParam <> NULL )
if(sceUtilityCheckNetParam(NetParam) != 0) pspDebugScreenPrintf("Profil %i inexistant\n",NetParam);
else return DeleteNetParam(NetParam);
return -1;
}
maybe error on sceUtility_driver
try this :)
try this :)
Code: Select all
...
DeleteNetParam = (void *)FindProc("sceUtility_Driver", "sceUtility_netparam_internal", 0x9CE50172);
...
PSP hardware hack
http://0okm.blogspot.com/
http://0okm.blogspot.com/
noracine_20 wrote:Damn !! TyRaNiD have the good answer, I'm not running in kernel mode my thread ....
humm ... How could be it ?? Simply change the attribute of sceKernelCreateThread ?
your code in kernel mode
but PrxName is wrong :P
try this to test :)
Code: Select all
#include <pspkernel.h>
#include <pspsdk.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
PSP_MODULE_INFO("FindProc", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
#define printf pspDebugScreenPrintf
/*** This function from PspPet PSARDUMPER ***/
static u32 FindProc(const char* szMod, const char* szLib, u32 nid)
{
SceModule* modP = sceKernelFindModuleByName(szMod);
if (modP == NULL)
{
printf("Failed to find mod '%s'\n", szMod);
return 0;
}
SceLibraryEntryTable* entP = (SceLibraryEntryTable*)modP->ent_top;
while ((u32)entP < ((u32)modP->ent_top + modP->ent_size))
{
if (entP->libname != NULL && strcmp(entP->libname, szLib) == 0)
{
// found lib
int i;
int count = entP->stubcount + entP->vstubcount;
u32* nidtable = (u32*)entP->entrytable;
for (i = 0; i < count; i++)
{
if (nidtable[i] == nid)
{
u32 procAddr = nidtable[count+i];
printf("entry found:\n '%s' '%s' = $%x\n", szMod, szLib, (int)procAddr);
return procAddr;
}
}
printf("Found mod '%s' and lib '%s' but not nid=$%x\n", szMod, szLib, nid);
return 0;
}
entP++;
}
printf("Found mod '%s' but not lib '%s'\n", szMod, szLib);
return 0;
}
int main(void)
{
pspDebugScreenInit();
pspDebugScreenPrintf("\n");
pspDebugScreenPrintf(" press [SQUARE] to Find sceUtility_driver_9CE50172\n");
pspDebugScreenPrintf(" press [CIRCLE] to Find sceUtility_Driver_9CE50172\n");
pspDebugScreenPrintf(" press [CROSS] to EXIT\n\n");
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(0);
while (1)
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_SQUARE)
{
pspDebugScreenPrintf(" sceUtility_driver_9CE50172 : 0x%.8X\n\n", FindProc("sceUtility_driver", "sceUtility_netparam_internal", 0x9CE50172));
sceDisplayWaitVblankStart();
sceKernelDelayThread(500 * 1000);
}
if (pad.Buttons & PSP_CTRL_CIRCLE)
{
pspDebugScreenPrintf(" sceUtility_Driver_9CE50172 : 0x%.8X\n\n", FindProc("sceUtility_Driver", "sceUtility_netparam_internal", 0x9CE50172));
sceDisplayWaitVblankStart();
sceKernelDelayThread(500 * 1000);
}
if (pad.Buttons & PSP_CTRL_CROSS)
{
sceKernelExitGame();
}
}
return 0;
}
PSP hardware hack
http://0okm.blogspot.com/
http://0okm.blogspot.com/
Of course the real question is why dont you create a new file called something like netparam.S (note the capitalisation) and put into it:
Link that with your code and jobs a good un...
Code: Select all
.set noreorder
#include "pspstub.s"
STUB_START "sceUtility_netparam_internal",0x40010000,0x00040005
STUB_FUNC 0x072DEBF2,sceUtilityCreateNetParam
STUB_FUNC 0x9CE50172,sceUtilityDeleteNetParam
STUB_FUNC 0xFB0C4840,sceUtilityCopyNetParam
STUB_FUNC 0xFC4516F3,sceUtilitySetNetParam
STUB_END
I don't ask anymore, but, how to link this in your main.c ?
I tryed (note the capitalisation ;) ) :
and launch the makefile, he warm me about netparam.S and a lot of stuff invalid preprocessing directive.
Maybe my makefile is bad, maybe I mistake a line, I don't know anymore.
Can you give me a tips again :). I know I know, I bored you :)
thx a lot for all ;)
I tryed (note the capitalisation ;) ) :
Code: Select all
#include "netparam.S"
..
int sceUtilityDeleteNetParam(int);
..
int main(void){
..
pspDebugScreenPrintf("Code retour : %i",sceUtilityDeleteNetParam(2));
..
}
Maybe my makefile is bad, maybe I mistake a line, I don't know anymore.
Can you give me a tips again :). I know I know, I bored you :)
thx a lot for all ;)
Well if you are using a standard Makefile from PSPSDK then just add to the 'OBJS =' line netparam.o, if you are not using a standard makefile then you are probably on your own. You only need to assemble the file with something like psp-gcc -I/usr/local/pspdev/psp/sdk/include -c -o netparam.o netparam.S and link in the object.
Ohhh my god !!! TyRaNID you are sooo good !!
This code run correctly and I can delete a net parameters finally.
well, I post my sample for turn the post to [RESOLVE] and do it.
MAIN.C :
NETPARAM.S :
MAKEFILE :
A little last question, where you got the values for STUB_START and what mean this 0x40010000 and 0x00040005
For continue, I search for use sceUtilitySetNetParam and other
Thx to TyRaNID and jas0nuk
This code run correctly and I can delete a net parameters finally.
well, I post my sample for turn the post to [RESOLVE] and do it.
MAIN.C :
Code: Select all
// *** MODULE INITIALISATION ***
PSP_MODULE_INFO("SampleSySCallNID",0x1000,1,1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(32); /* smaller stack for kernel thread */
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
pspSdkInetTerm();
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
pspDebugScreenInit();
return thid;
}
/*------------------------------------------------------------------------------*/
int sceUtilityDeleteNetParam(int);
int main(void)
{
SetupCallbacks();
int err = pspSdkLoadInetModules();
if (err != 0) {
pspDebugScreenPrintf("pspSdkLoadInetModules failed with %x\n", err);
sceKernelDelayThread(5*1000000); // 5 sec to read error
return 1;
}
// print available connections
pspDebugScreenPrintf("available connections:\n");
int i;
for (i = 1; i < 100; i++) // skip the 0th connection
{
if (sceUtilityCheckNetParam(i) != 0) break; // no more
char name[64];
sceUtilityGetNetParam(i, 0, (netData*) name);
pspDebugScreenPrintf("%i: %s\n", i, name);
}
pspDebugScreenPrintf("Test effacement derniere config de connection:\n");
pspDebugScreenPrintf("Code retour effacement : %i",sceUtilityDeleteNetParam(--i));
sceKernelExitGame();
return 0;
}
Code: Select all
.set noreorder
#include "pspstub.s"
STUB_START "sceUtility_netparam_internal",0x40010000,0x00040005
STUB_FUNC 0x072DEBF2,sceUtilityCreateNetParam
STUB_FUNC 0x9CE50172,sceUtilityDeleteNetParam
STUB_FUNC 0xFB0C4840,sceUtilityCopyNetParam
STUB_FUNC 0xFC4516F3,sceUtilitySetNetParam
STUB_END
Code: Select all
PSPSDK = $(shell psp-config --pspsdk-path)
PSPLIBSDIR = $(PSPSDK)/..
TARGET = SampleSySCallNID
OBJS = main.o netparam.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS = -lpspdebug -lpspsdk -lpspwlan -lpspnet_apctl -lpspnet_resolver -lc -lpspnet_inet -lpspnet
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = SampleSySCallNID
include $(PSPSDK)/lib/build.mak
For continue, I search for use sceUtilitySetNetParam and other
Thx to TyRaNID and jas0nuk