Esempio n. 1
0
static int load_util(int module)
{
#ifdef UTILITY_AV_AVCODEC_PATH
	SceUID ret;
#endif

	dbg_printf("Loading 0x%08X\n", module);

	if (isImported(sceUtilityLoadModule))
		return sceUtilityLoadModule(module);

	else if (module <= PSP_MODULE_NET_SSL && isImported(sceUtilityLoadNetModule))
		return sceUtilityLoadNetModule(module + PSP_NET_MODULE_COMMON - PSP_MODULE_NET_COMMON);

	else if (module == PSP_MODULE_USB_PSPCM && isImported(sceUtilityLoadUsbModule))
		return sceUtilityLoadUsbModule(PSP_USB_MODULE_PSPCM);

	else if (module <= PSP_MODULE_USB_GPS && isImported(sceUtilityLoadUsbModule))
		return sceUtilityLoadUsbModule(module + PSP_USB_MODULE_MIC - PSP_MODULE_USB_MIC);

	else if (module <= PSP_MODULE_AV_G729 && isImported(sceUtilityLoadAvModule))
		return sceUtilityLoadAvModule(module + PSP_MODULE_AV_AVCODEC - PSP_AV_MODULE_AVCODEC);

	else
#ifdef UTILITY_AV_AVCODEC_PATH
	if (module == PSP_MODULE_AV_AVCODEC) {
		ret = sceKernelLoadModule(UTILITY_AV_AVCODEC_PATH, 0, NULL);
		return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL);
	} else
#endif
#ifdef UTILITY_AV_SASCORE_PATH
	if (module == PSP_MODULE_AV_SASCORE) {
		ret = sceKernelLoadModule(UTILITY_AV_SASCORE_PATH, 0, NULL);
		return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL);
	} else
#endif
#ifdef UTILITY_AV_ATRAC3PLUS_PATH
	if (module == PSP_MODULE_AV_ATRAC3PLUS) {
		ret = sceKernelLoadModule(UTILITY_AV_ATRAC3PLUS_PATH, 0, NULL);
		return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL);
	} else
#endif
#ifdef UTILITY_AV_MPEGBASE_PATH
	if (module == PSP_MODULE_AV_MPEGBASE) {
		ret = sceKernelLoadModule(UTILITY_AV_MPEGBASE_PATH, 0, NULL);
		return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL);
	} else
#endif
		return SCE_KERNEL_ERROR_ERROR;
}
Esempio n. 2
0
int loadStartModule(char *module)
{
	SceUID modID = sceKernelLoadModule(module, 0, NULL);
	if(modID >= 0)
		sceKernelStartModule(modID, strlen(module)+1, module, NULL, NULL);
	return modID;
}
Esempio n. 3
0
static int pgeLuaRequireDep(const char *module)
{	
	char modpath[256];
	char cwdpath[256];
	
	strcpy(cwdpath, initpath);
	strcat(cwdpath, "/");
	
	strcpy(modpath, initpath);
	
	strcat(modpath, "/modules/");
	strcat(modpath, module);
	strcat(modpath, ".prx");
	
	int ret = sceKernelLoadModule(modpath, 0, NULL);
	
	if(ret < 0 && ret != (int)0x80020139)
	{
		printf("Error: 0x%08X\n", ret);
		return 0;
	}

	int fd;
	
	ret = sceKernelStartModule(ret, strlen(initpath) + 1, (void *)cwdpath, &fd, NULL);
	
	if(ret < 0 && ret != (int)0x8002012E)
	{
		printf("Error2: 0x%08X\n", ret);
		return 0;
	}
	
	return 1;
}
Esempio n. 4
0
/**
 * Loads and starts a module
 * @param path Path to module to be loaded and started
 */
void LoadStartModule(char *path)
{
    SceUID mod;
	
    mod = kuKernelLoadModule(path, 0, NULL);
	mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
}
Esempio n. 5
0
//Load a PSP audio module
bool Mp3PspStream::loadStartAudioModule(const char *modname, int partition){
	DEBUG_ENTER_FUNC();

    SceKernelLMOption option;
    SceUID modid;

    memset(&option, 0, sizeof(option));
    option.size = sizeof(option);
    option.mpidtext = partition;
    option.mpiddata = partition;
    option.position = 0;
    option.access = 1;

    modid = sceKernelLoadModule(modname, 0, &option);
    if (modid < 0) {
		PSP_ERROR("Failed to load module %s. Got error 0x%x\n", modname, modid);
        return false;
	}

    int ret = sceKernelStartModule(modid, 0, NULL, NULL, NULL);
	if (ret < 0) {
		PSP_ERROR("Failed to start module %s. Got error 0x%x\n", modname, ret);
        return false;
	}
	return true;
}
Esempio n. 6
0
int main (int argc, char **argv)
{
  int res, status;

  SetupCallbacks ();
  pspDebugScreenInit ();
  
  printf ("Loading modules... ");
  modid = load_module ("hidmouse.prx", 0, 0);
  if (modid < 0) {
    printf ("failed with 0x%08X\n", modid);
    return -1;
  }

  printf ("OK\n");
  printf ("Starting modules... ");

  res = sceKernelStartModule (modid, 0, NULL, &status, NULL);
  if (res < 0) {
    printf ("failed with 0x%08X\n", res);
    return -1;
  }

  if (status) {
    printf ("failed with status = 0x%08X\n", status);
    return -1;
  }

  printf ("OK\n");
  return 0;
}
Esempio n. 7
0
/**
 * mode: 0 - OFW mode, 1 - CFW mode
 */
void start_reboot(int mode)
{
	int modid, ret;
	int delay = 0;
	char modpath[80];

	sprintf(modpath, "rebootex.prx");
	modid = kuKernelLoadModule(modpath, 0, 0);

	if (modid >= 0) {
		ret = sceKernelStartModule(modid, sizeof(mode), &mode, 0, NULL);

		if (ret < 0) {
			printf("start module error 0x%08x\n", ret);
			delay = 5000000;
		}
	} else {
		printf("load module error 0x%08x\n", modid);
		delay = 5000000;
	}

	cleanup_exit();
	sceKernelDelayThread(delay);
	sceKernelExitGame();
}
Esempio n. 8
0
int launchUmdImage()
{
	int modid = sceKernelLoadModuleForLoadExecVSHDisc( umd_executable[executable], 0, NULL );
	log( "load %s modid %08x\n", umd_executable[executable], modid );
	if ( modid >= 0 )
	{
		int status, len = strlen( umd_executable[executable] ) + 1;
		modid = sceKernelStartModule( modid, len, ( void * )umd_executable[executable], &status, NULL );
		log( "start ret %08x\n", modid );
	}
	return modid;
}
Esempio n. 9
0
int
psp_irkeyb_init()
{
  if (! psp_irda_is_kbd_mode()) return 0;

  loc_psp_irkeyb_mode = 0;

#ifdef PSPFW30X
  /* Load irda PRX for CFW >= 3.80 */
  u32 mod_id = sceKernelLoadModule("flash0:/kd/irda.prx", 0, NULL);
  sceKernelStartModule(mod_id, 0, NULL, NULL, NULL);
#endif

  int ret = pspIrKeybInit( "./pspirkeyb.ini", KERNELMODE );

  if( ret == PSP_IRKBD_RESULT_OK ) {
    pspIrKeybOutputMode( PSP_IRKBD_OUTPUT_MODE_VT100 );
    loc_psp_irkeyb_mode = 1;
    return 0;

  } else {
    switch( ret )
    {
      case PSP_IRKBD_RESULT_CANT_OPEN_DEVICE:
          fprintf(stdout,  "error: can't open device\n" );
          break;
      case PSP_IRKBD_RESULT_CANT_OPEN_MAPFILE:
          fprintf(stdout,  "error: can't open mapfile\n" );
          break;
      case PSP_IRKBD_RESULT_MAPFILE_MAXDEPTHLEVEL:
          fprintf(stdout,  "error: mapfile max include level reached - recursion?\n" );
          break;
      case PSP_IRKBD_RESULT_CANT_OPEN_MAPFILE_INCLUDE:
          fprintf(stdout,  "error: can't open include in mapfile\n" );
          break;
      case PSP_IRKBD_RESULT_CANT_SET_BAUDTATE:
          fprintf(stdout,  "error: can't set baudrate - you need kernel support\n" );
          break; 
      case PSP_IRKBD_RESULT_CONFIG_FILE_NOT_FOUND:
          fprintf(stdout,  "error: can't read config file\n" );
          break; 
      case PSP_IRKBD_RESULT_UNKNOW_KEYBOARD:
          fprintf(stdout,  "error: unknown keyboard\n" );
          break;
      case PSP_IRKBD_RESULT_FAILED:
      default:
          fprintf(stdout,  "error: init failed\n" );
          break;
    }
  }
  return 1;
}
Esempio n. 10
0
int main_thread(SceSize args, void *argp)
{
	char *argv0;
	char prx_path[256];
	char *path;
	SceUID modid;
	int ret;

	pspDebugScreenInit();
	sceDisplayWaitVblankStart();

	pspSdkInstallNoDeviceCheckPatch();
	pspSdkInstallNoPlainModuleCheckPatch();
	pspSdkInstallKernelLoadModulePatch();

	argv0 = (char*) argp;
	path = strrchr(argv0, '/');
	if(path != NULL)
	{
		memcpy(prx_path, argv0, path - argv0 + 1);
		prx_path[path - argv0 + 1] = 0;
		strcat(prx_path, "psplink.prx");
	}
	else
	{
		/* Well try for a default */
		strcpy(prx_path, "ms0:/psplink.prx");
	}

	/* Start mymodule.prx and dump its information */
	printf("PSPLink Bootstrap TyRaNiD (c) 2k5 Version %s\n", PSPLINK_VERSION);
	modid = load_module(prx_path, 0, 0);
	if(modid >= 0)
	{
		int status;

		printf("Starting psplink module\n");
		ret = sceKernelStartModule(modid, args, argp, &status, NULL);
		printf("Done\n");
	}
	else
	{
		printf("Error loading psplink module %08X\n", modid);
	}

	/* Let's bug out */
	sceKernelExitDeleteThread(0);

	return 0;
}
Esempio n. 11
0
void _main(SceSize args, void *argp)
{
	static SceUID modid;
	static int retVal, status;
	static SceKernelLMOption option;
	extern u8 *payload;
	extern u32 size_payload;
	extern u32 size_payload_uncomp;
	u8 *buffer;
	SceUID bufferBlock;
	
	pspDebugScreenInit();
    	pspDebugScreenClear();
	pspDebugInstallKprintfHandler(NULL);
	//pspDebugInstallErrorHandler(NULL);
	pspSdkInstallNoPlainModuleCheckPatch();

	memset(&option, 0, sizeof(option));
	option.size = sizeof(option);
	option.mpidtext = 1;
	option.mpiddata = 1;
	option.position = 0;
	option.access = 1;
	bufferBlock = sceKernelAllocPartitionMemory(2, "PSPPackerBuffer", PSP_SMEM_High, size_payload_uncomp, NULL);
	if (bufferBlock < 0) {
		printf("allocpartitionmemory failed with 0x%08X\n", bufferBlock);
		goto exit;
	}
	buffer = sceKernelGetBlockHeadAddr(bufferBlock);
	retVal = sceKernelGzipDecompress(buffer, size_payload_uncomp, (u8*)&payload, 0);
	if (retVal < 0) {
		printf("sceKernelGzipDecompress failed with 0x%08X\n", retVal);
		goto exit;
	}
	
	modid = sceKernelLoadModuleBufferUsbWlan(size_payload, buffer, 0, &option);
	retVal = sceKernelFreePartitionMemory(bufferBlock);
	if (retVal < 0)
		printf("Error freeing decompress buffer (0x%08X)\n", retVal);
		
	if(modid > 0)
		retVal = sceKernelStartModule(modid, 0, NULL, &status, NULL);

exit:
	/* Let's bug out */
	//sceKernelSelfStopUnloadModule(0, 0, NULL);
	//return 0;
	sceKernelExitDeleteThread(0);
}
Esempio n. 12
0
int install_in_cfw(void)
{
	//installer load result
	int result = 0;

	//load installer module
	SceUID mod = sceKernelLoadModule(installerpath, 0, NULL);

	//installer loaded
	if (mod >= 0) {
		//start installer
		result = sceKernelStartModule(mod, strlen(installerpath) + 1, installerpath, NULL, NULL);
	}

	return 0;
}
Esempio n. 13
0
SceUID LPP_UtilsLoadStartModule(const char *filename)
{
    SceUID r = kuKernelLoadModule(filename, 0, null);
    if(r <= 0) return 0;

    int status;

    int res = sceKernelStartModule(r, 0, null, &status, null);

    if(res < 0)
    {
        return 0;
    }

    return (r);
}
Esempio n. 14
0
//Load a module:
SceUID LoadStartAudioModules(char *modname, int partition){
    SceKernelLMOption option;
    SceUID modid;

    memset(&option, 0, sizeof(option));
    option.size = sizeof(option);
    option.mpidtext = partition;
    option.mpiddata = partition;
    option.position = 0;
    option.access = 1;

    modid = sceKernelLoadModule(modname, 0, &option);
    if (modid < 0)
        return modid;

    return sceKernelStartModule(modid, 0, NULL, NULL, NULL);
}
Esempio n. 15
0
File: main.c Progetto: AlanDrake/ags
int launcher_thread(SceSize args, void *argp)
{
	int status = 0;

	// Unload the launcher
	SceModule2* mod = (SceModule2*)sceKernelFindModuleByName("launcher");
    int result = sceKernelStopModule(mod->modid, 0, NULL, &status, NULL);
	result = sceKernelUnloadModule(mod->modid);
	
	// Load the game engine
	SceUID modid = sceKernelLoadModule(exefile, 0, NULL);
	sceKernelStartModule(modid, paramlength, parameters, &status, NULL);
	
	// Unload this module
	sceKernelSelfStopUnloadModule(1, 0, NULL);
	
	return 0;
}
Esempio n. 16
0
bool loadFontModule() {
	checkpointNext("Init");
	if (RUNNING_ON_EMULATOR) {
		return true;
	}
	SceUID fontModule = sceKernelLoadModule("libfont.prx", 0, NULL);
	if (fontModule <= 0) {
		printf("TEST ERROR: Unable to load libfont.prx\n");
		return false;
	}

	int status = -1;
	int result = sceKernelStartModule(fontModule, 0, NULL, &status, NULL);
	if (result != fontModule || status != 0) {
		printf("TEST ERROR: libfont.prx startup failed (%08x, %08x)\n", result, status);
		return false;
	}
	return true;
}
Esempio n. 17
0
int _main(SceSize args, void *argp)
{
	char path[1024];
	char *slash;

	do
	{
		pspDebugScreenInit();
		pspDebugScreenPrintf("PSPLink Bootstrap TyRaNiD (c) 2k7 Version %s\n", PSPLINK_VERSION);
		strcpy(path, argp);
		slash = strrchr(path, '/');
		if(slash == NULL)
		{
			pspDebugScreenPrintf("Could not find last slash\n");
			break;
		}
		slash++;
		*slash = 0;
		strcat(path, MODULE);

		SceUID mod = sceKernelLoadModule(path, 0, NULL);
		if (mod < 0)
		{
			pspDebugScreenPrintf("Error 0x%08X loading module %s.\n", mod, path);
			break;
		}

		mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
		if (mod < 0)
		{
			pspDebugScreenPrintf("Error 0x%08X starting module %s.\n", mod, path);
			break;
		}

		sceKernelSelfStopUnloadModule(1, 0, NULL);
	}
	while(0);

	sceKernelDelayThread(2000000);
	sceKernelExitGame();

	return 0;
}
/*
Subroutine sceHttpStorage_bridge_04EF00F8 - Address 0x00000438 
Exported in sceHttpStorage_bridge
*/
u32 sceHttpStorage_bridge_04EF00F8(int a0) {
	u8 buf[16];
	int res = 0x80000023;
	s32 oldk1 = pspShiftK1();
	//0x47C
	if ((((a0 + 8) | a0) & (oldk1 << 11)) >= 0) {
		res = sceKernelSearchModuleByName("sceChkreg");//scekernelfindmodulebyname?
		//0x4A4
		if ((u32) res != 0x8002012E) { //SCE_ERROR_KERNEL_UNKNOWN_MODULE
			//0x4AC
			if (res >= 0) {
				res = sceChkreg_driver_59F8491D((char *) a0);
				goto end;
			}
			pspSetK1(oldk1);
			return res;
		}
		res = sceKernelLoadModule("flash0:/kd/chkreg.prx");
		//0x52C
		if (res == 0) {
			res = sceKernelStartModule(res, 0, 0, buf, 0);
			//0x540
			if (res < 0) {
				goto end;
			}
			res = sceChkreg_driver_59F8491D((char *) a0);
			end:
			//0x4D0
			if (res >= 0) {
				sceKernelStopModule(res, 0, 0, 0, 0);
				res = sceKernelUnloadModule(res);
				pspSetK1(oldk1);
				return (res < 0) ? res : sceKernelUnloadModule(res);
			}
			pspSetK1(oldk1);
			return res;
		}
		pspSetK1(oldk1);
		return res;
	}
	pspSetK1(oldk1);
	return res;
}
Esempio n. 19
0
SceUID pspSdkLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[])
{
	SceKernelLMOption option;
	SceUID modid = 0;
	int retVal = 0, mresult;
	char args[MAX_ARGS];
	int  argpos = 0;
	int  i;

	memset(args, 0, MAX_ARGS);
	strcpy(args, filename);
	argpos += strlen(args) + 1;
	for(i = 0; (i < argc) && (argpos < MAX_ARGS); i++)
	{
		int len;

		snprintf(&args[argpos], MAX_ARGS-argpos, "%s", argv[i]);
		len = strlen(&args[argpos]);
		argpos += len + 1;
	}

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

	retVal = sceKernelLoadModule(filename, 0, &option);
	if(retVal < 0){
		return retVal;
	}

	modid = retVal;

	retVal = sceKernelStartModule(modid, argpos, args, &mresult, NULL);
	if(retVal < 0){
		return retVal;
	}

	return modid;
}
Esempio n. 20
0
File: font.c Progetto: rnbpsp/pmc
int load(SceSize args, void *argp){
	int stat,modid;
	if(sceKernelStartModule(modid=sceKernelLoadModule("flash0:/vsh/module/libfont_hv.prx",0,NULL),0,NULL,&stat,NULL)<0)return -__LINE__;
	int errorCode;
	InitParam initParams = {NULL,4,NULL,myMalloc,myFree,NULL,NULL,NULL,NULL,NULL,NULL};
	void* libID = sceFontNewLib(&initParams, &errorCode);if(errorCode)return  -__LINE__;
	void* fontID = sceFontOpen(libID, FONT(BOLD), FILE, &errorCode);if(errorCode)return -__LINE__;
	memset((void*)0x44000000,0,4*512*16);

	//print build date
	printchar(fontID, __DATE__" "__TIME__);//on vram
	sceIoWrite(2,__DATE__" "__TIME__,11+1+8);//on cout

	if(sceFontClose(fontID)) return  -__LINE__;
	if(sceFontDoneLib(libID)) return  -__LINE__;

	sceKernelStopModule(modid,0,NULL,&stat,NULL);
	sceKernelUnloadModule(modid);
	sceKernelSelfStopUnloadModule(1,0,NULL);
	return 0;
}
Esempio n. 21
0
static SceUID load_start_usbdevice(void)
{
    SceUID modid = -1;
    int ret;
    const char *mod = "flash0:/kd/_usbdevice.prx";

    modid = sceKernelLoadModule(mod, 0, NULL);

    if (modid < 0) {
        return -1;
    }

    ret = sceKernelStartModule(modid, 0, NULL, NULL, NULL);

    if (ret < 0) {
        printk("%s: sceKernelStartModule -> 0x%08X\n", __func__, ret);
        sceKernelUnloadModule(modid);

        return -1;
    }

    return modid;
}
Esempio n. 22
0
int main(int argc, char *argv[])
{
    SceCtrlData pad;
    u32 buttonsold = 0;
    int kernelmode = 0;       /* only 0 works for now - some keyboards need baud change */
    const char *config_file = NULL; /* this will force ms0:/seplugins/pspirkeyb.ini */

	SetupCallbacks();

    pspDebugScreenInit();
    printf("PSP Irda Keyboard test - ASCii input \n");

	if (sceKernelDevkitVersion() >= 0x03080010)
	{
        /* Load irda PRX for CFW >= 3.80 - Thanks, ZX81! */
        u32 mod_id = sceKernelLoadModule("flash0:/kd/irda.prx", 0, NULL);
        sceKernelStartModule(mod_id, 0, NULL, NULL, NULL);
	}

    if( pspIrKeybInit( config_file, kernelmode ) != 0 )
    {
        printf( "error: can't inialize the keyboard\n" );
        printf( "       check keyboard type/map in ms0:/seplugins/pspirkeyb.ini\n" );
    }
    else
    {
        unsigned char termchar = 'X';
        unsigned char buffer[255];
        int i, length=0;

        printf("\npress %c on keyboard or any PSP button to exit\n", termchar );

        /* setup output method to ASCii */
        pspIrKeybOutputMode( PSP_IRKBD_OUTPUT_MODE_ASCII );

        while(1) {
            length = 0;
            /* non blocking read */
            if( pspIrKeybReadinput(buffer, &length) >= 0 )
            {
                for( i=0; i < length; i++ )
                    printf( "%c", buffer[i] );
                if( length == 1 && buffer[0] == termchar )
                    break;
            }
            else
            {
                sceKernelDelayThread(10*1000);
                sceCtrlReadBufferPositive(&pad, 1);
                if (pad.Buttons != buttonsold)
                    break;
            }
        }

        /* bye keyboard */
        pspIrKeybFinish();
    }

    printf( "\n bye... (PRESS psp button to quit)\n" );

    buttonsold = 0;
    while (1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if (pad.Buttons != buttonsold) {
            /* Exit */
            sceKernelExitGame();
        }
    }

	return 0;
}
Esempio n. 23
0
int main_thread(SceSize args, void *argp)
{
	#ifdef DEBUG
	pspDebugScreenInit();
	printf("Free Memory: %u KB\n",sceKernelTotalFreeMemSize()/1024);
	#else
	initGraphics();
	loadTheme();
	background = loadImageFromMemory(images[BACKGROUND].data, images[BACKGROUND].hdr.size);
	sceKernelFreePartitionMemory(images[BACKGROUND].blockid);
	images[BACKGROUND].blockid = -1;
	mask = loadImageFromMemory(images[MASK].data, images[MASK].hdr.size);
	sceKernelFreePartitionMemory(images[MASK].blockid);
	images[MASK].blockid = -1;
	#endif

	int firstUse = 0;
	int recovery = 0;
	int bytesRead = 0;
	Config cfg;
	char input[11];

	if ((args == 9) && (strcmp(argp, "recovery") == 0))
	{
		recovery = 1;
	}

	SceUID fp;
	fp = sceIoOpen("flash0:/buttons.ini", PSP_O_RDONLY, 0777);

	if (fp < 0)
	{
		#ifdef DEBUG
		printf("\nflash0:/buttons.ini could not be opned. Assuming first usage.");
		#endif
		firstUse = 1;
	}
	else
	{
		bytesRead = sceIoRead(fp, &cfg, sizeof(cfg));
		sceIoClose(fp);

		if(bytesRead != sizeof(cfg))
		{
			firstUse = 1;
		}
	}

	if (firstUse)
	{
		setPassword();
	}
	else if (((args == 0) || (recovery != 0)) || !(cfg.onlyBoot))
	{
		int len;
main_password:
		#ifndef DEBUG
		footer_pressselect = loadImageFromMemory(images[FOOTER_PRESSSELECT].data, images[FOOTER_PRESSSELECT].hdr.size);
		title_password = loadImageFromMemory(images[TITLE_PASSWORD].data, images[TITLE_PASSWORD].hdr.size);
		#endif
		while(1)
		{
			selectEnabled = 1;

			#ifdef DEBUG
			printf("\nPress START to accept.\nPress SELECT to change password.\nEnter password: "******"\nPassword OK.");
				#else
				int temp;
				blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y);
				blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y);
				blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y);
				msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size);
				blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y);
				freeImage(msg_passwordok);
				for(temp = 0; temp < len; temp++)
				{
					blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y);
				}
				sceDisplayWaitVblankStart();
				flipScreen();
				#endif
				sceKernelDelayThread(1000*1000);
				break;
			}
			else
			{
				#ifdef DEBUG
				printf("\nIncorrect password.");
				#else
				int temp;
				blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y);
				blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y);
				blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y);
				msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size);
				blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y);
				freeImage(msg_passwordincorrect);
				for(temp = 0; temp < len; temp++)
				{
					blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y);
				}
				sceDisplayWaitVblankStart();
				flipScreen();
				#endif
				sceKernelDelayThread(3000*1000);
			}
		}
		#ifndef DEBUG
		freeImage(footer_pressselect);
		freeImage(title_password);
		#endif

		if(len == -1)
		{
			#ifndef DEBUG
			footer_changemode = loadImageFromMemory(images[FOOTER_CHANGEMODE].data, images[FOOTER_CHANGEMODE].hdr.size);
			title_oldpassword = loadImageFromMemory(images[TITLE_OLDPASSWORD].data, images[TITLE_OLDPASSWORD].hdr.size);
			#endif
			while(1)
			{
				#ifdef DEBUG
				printf("\nChange password mode.\nEnter old password: "******"\nPassword OK.");
					#else
					int temp;
					blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y);
					blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y);
					blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y);
					msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size);
					blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y);
					freeImage(msg_passwordok);
					for(temp = 0; temp < len; temp++)
					{
						blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y);
					}
					sceDisplayWaitVblankStart();
					flipScreen();
					#endif
					sceKernelDelayThread(3000*1000);
					break;
				}
				else
				{
					#ifdef DEBUG
					printf("\nIncorrect password.");
					#else
					int temp;
					blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y);
					blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y);
					blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y);
					msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size);
					blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y);
					freeImage(msg_passwordincorrect);
					for(temp = 0; temp < len; temp++)
					{
						blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y);
					}
					sceDisplayWaitVblankStart();
					flipScreen();
					#endif
					sceKernelDelayThread(3000*1000);
				}
			}
			#ifndef DEBUG
			freeImage(footer_changemode);
			freeImage(title_oldpassword);
			#endif
			if(len == -1)
			{
				goto main_password;
			}
			selectEnabled = 0;
			setPassword();
		}
	}

	#ifndef DEBUG
	freeImage(background);
	freeImage(mask);
	sceGuTerm();
	int i;
	for (i = 0; i < NUMFILES; i++)
	{
		if (images[i].blockid != -1)
		{
			sceKernelFreePartitionMemory(images[i].blockid);
		}
	}
	#endif

	__psp_free_heap();
	#ifdef DEBUG
	printf("\n__psp_free_heap(): %u KB\n",sceKernelTotalFreeMemSize()/1024);
	sceKernelDelayThread(3000*1000);
	#endif

	#ifdef DEBUG
	printf("\nLoading loader.prx");
	#endif

	SceUID mod = sceKernelLoadModule("flash0:/loader.prx", 0, NULL);

	if (mod & 0x80000000)
	{
		#ifdef DEBUG
		printf("\nLoadModule failed 0x%x", mod);
		#endif
	}
	else
	{
		SceUID startmod;
		startmod = sceKernelStartModule(mod, args, argp, NULL, NULL);

		if (mod != startmod)
		{
			#ifdef DEBUG
			printf("\nStartModule failed 0x%x", startmod);
			#endif
		}
	}

	return sceKernelExitDeleteThread(0);
}
Esempio n. 24
0
/**
 * Initialize Networking Components for Adhocctl Emulator
 * @param adhoc_id Game Product Code
 * @param server_ip Server IP
 * @return 0 on success or... -1
 */
int _initNetwork(const SceNetAdhocctlAdhocId * adhoc_id, const char * server_ip)
{
	// WLAN Switch Check
	if(sceWlanGetSwitchState() == 1)
	{
		// Initialize Access Point Control
		if(sceNetApctlInit(0x1800, 0x30) == 0)
		{
			// Attempt Counter
			int attemptmax = 10;
			
			// Attempt Number
			int attempt = 0;
			
			// Attempt Connection Setup
			for(; attempt < attemptmax; attempt++)
			{
				// Start Connection
				if(sceNetApctlConnect(_hotspot) == 0)
				{
					// Wait for Connection
					int statebefore = 0;
					int state = 0; while(state != 4)
					{
						// Query State
						int getstate = sceNetApctlGetState(&state);
						
						// Log State Change
						if(statebefore != state) printk("New Connection State: %d\n", state);					
						
						// Query Success
						if(getstate == 0 && state != 4)
						{
							// Wait for Retry
							sceKernelDelayThread(1000000);
						}
						
						// Query Error
						else break;
						
						// Save Before State
						statebefore = state;
					}
					
					// Connected
					if(state == 4)
					{
						// Create Friend Finder Socket
						int socket = sceNetInetSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
						
						// Created Socket
						if(socket > 0)
						{
							// Enable Port Re-use
							sceNetInetSetsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &_one, sizeof(_one));
							sceNetInetSetsockopt(socket, SOL_SOCKET, SO_REUSEPORT, &_one, sizeof(_one));
							
							// Apply Receive Timeout Settings to Socket
							// uint32_t timeout = ADHOCCTL_RECV_TIMEOUT;
							// sceNetInetSetsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
							
							// Server IP
							uint32_t ip = 0;
							
							// Initialize DNS Resolver
							if(sceNetResolverInit() == 0)
							{
								// Create DNS Resolver
								unsigned char rbuf[512]; int rid = 0;
								if(sceNetResolverCreate(&rid, rbuf, sizeof(rbuf)) == 0)
								{
									// Resolve Domain
									if(sceNetResolverStartNtoA(rid, server_ip, &ip, 500000, 2) != 0)
									{
										// Attempt IP Conversion
										sceNetInetInetAton(server_ip, &ip);
									}
									
									// Delete DNS Resolver
									sceNetResolverDelete(rid);
								}
								
								// Shutdown DNS Resolver
								sceNetResolverTerm();
							}
							
							// Prepare Server Address
							SceNetInetSockaddrIn addr;
							addr.sin_len = sizeof(addr);
							addr.sin_family = AF_INET;
							addr.sin_addr = ip;
							addr.sin_port = sceNetHtons(ADHOCCTL_METAPORT);
							
							// Connect to Server
							if(sceNetInetConnect(socket, (SceNetInetSockaddr *)&addr, sizeof(addr)) == 0)
							{
								// Save Meta Socket
								_metasocket = socket;
								
								// Save Product Code
								_product_code = *adhoc_id;
								
								// Clear Event Handler
								memset(_event_handler, 0, sizeof(_event_handler[0]) * ADHOCCTL_MAX_HANDLER);
								memset(_event_args, 0, sizeof(_event_args[0]) * ADHOCCTL_MAX_HANDLER);
								
								// Clear Internal Control Status
								memset(&_parameter, 0, sizeof(_parameter));
								
								// Read PSP Player Name
								sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, (char *)_parameter.nickname.data, ADHOCCTL_NICKNAME_LEN);
								
								// Read Adhoc Channel
								sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL, &_parameter.channel);
								
								// Fake Channel Number 1 on Automatic Channel
								if(_parameter.channel == 0) _parameter.channel = 1;
								
								// Read PSP MAC Address
								sceWlanGetEtherAddr((void *)&_parameter.bssid.mac_addr.data);
								
								// Prepare Login Packet
								SceNetAdhocctlLoginPacketC2S packet;
								
								// Set Packet Opcode
								packet.base.opcode = OPCODE_LOGIN;
								
								// Set MAC Address
								packet.mac = _parameter.bssid.mac_addr;
								
								// Set Nickname
								packet.name = _parameter.nickname;
								
								// Set Game Product ID
								memcpy(packet.game.data, adhoc_id->data, ADHOCCTL_ADHOCID_LEN);
								
								// Acquire Network Layer Lock
								_acquireNetworkLock();
								
								// Send Login Packet
								sceNetInetSend(_metasocket, &packet, sizeof(packet), INET_MSG_DONTWAIT);
								
								// Free Network Layer Lock
								_freeNetworkLock();
								
								// Load UPNP Library
								_upnp_uid = sceKernelLoadModule("ms0:/kd/pspnet_miniupnc.prx", 0, NULL);
								
								// Start UPNP Library
								int status = 0; sceKernelStartModule(_upnp_uid, 0, NULL, &status, NULL);
								
								// Return Success
								return 0;
							}
							
							// Delete Socket
							sceNetInetClose(socket);
						}
						
						// Close Hotspot Connection
						sceNetApctlDisconnect();
					}
				}
			}
			
			// Terminate Access Point Control
			sceNetApctlTerm();	
		}
	}
	
	// Generic Error
	return -1;
}
Esempio n. 25
0
void load_utils()
{
	int ret;
	int module;
	unsigned i;

	if (isImported(sceUtilityLoadModule)) {
		// Load modules in order
		if (!globals->isEmu || sceNetIsImported)
			for(i = 0; i < sizeof(netModules) / sizeof(int); i++) {
				ret = sceUtilityLoadModule(netModules[i]);
				if (ret < 0)
					dbg_printf("%s: Loading 0x%08X failed 0x%08X\n",
						__func__, netModules[i], ret);
			}

		for(i = 0; i < sizeof(modules) / sizeof(int); i++) {
			ret = sceUtilityLoadModule(modules[i]);
			if (ret < 0)
				dbg_printf("%s: Loading 0x%08X failed 0x%08X\n",
					__func__, modules[i], ret);
		}

		ret = sceUtilityLoadModule(PSP_MODULE_AV_MP3);
		if (ret < 0)
			dbg_printf("%s: Loading 0x%08X failed 0x%08X\n",
				__func__, PSP_MODULE_AV_MP3, ret);
	} else {
		if (isImported(sceUtilityLoadNetModule))
			for (module = 1; module <= 7; module++) {
				ret = sceUtilityLoadNetModule(module);
				if (ret < 0)
					dbg_printf("%s: Loading net module %d failed 0x%08X\n",
						__func__, module, ret);
			}

		if (isImported(sceUtilityLoadUsbModule))
			for (module = 1; module <= 5; module++) {
				ret = sceUtilityLoadUsbModule(module);
				if (ret < 0)
					dbg_printf("%s: Loading USB module %d failed 0x%08X\n",
						__func__, module, ret);
			}

		if (isImported(sceUtilityLoadAvModule))
			for (module = 1; module <= 7; module++) {
				ret = sceUtilityLoadAvModule(module);
				dbg_printf("%s: Loading AV module %d failed 0x%08X\n",
					__func__, module, ret);
			}
		else {
#ifdef UTILITY_AV_AVCODEC_PATH
			avcodec_modid = sceKernelLoadModule(UTILITY_AV_AVCODEC_PATH, 0, NULL);
			sceKernelStartModule(avcodec_modid, 0, NULL, NULL, NULL);
#endif
#ifdef UTILITY_AV_SASCORE_PATH
			sascore_modid = sceKernelLoadModule(UTILITY_AV_SASCORE_PATH, 0, NULL);
			sceKernelStartModule(sascore_modid, 0, NULL, NULL, NULL);
#endif
#ifdef UTILITY_AV_ATRAC3PLUS_PATH
			atrac3plus_modid = sceKernelLoadModule(UTILITY_AV_ATRAC3PLUS_PATH, 0, NULL);
			sceKernelStartModule(atrac3plus_modid, 0, NULL, NULL, NULL);
#endif
#ifdef UTILITY_AV_MPEGBASE_PATH
			mpegbase_modid = sceKernelLoadModule(UTILITY_AV_MPEGBASE_PATH, 0, NULL);
			sceKernelStartModule(mpegbase_modid, 0, NULL, NULL, NULL);
#endif
		}
	}
}
Esempio n. 26
0
int main() 
{
	int devkit, size;
	SceUID kpspident;
	SceUID mod;

	(void)size_ipl_block_large;

	CHS_ScreenInit();///|pspDebugScreenInit();
	CHS_ScreenSetTextColor(WHITE);///|pspDebugScreenSetTextColor(WHITE);
	devkit = sceKernelDevkitVersion();

	if(devkit != DEVKIT_VER ) {
		ErrorExit(5000,"FW错误!\n");///|ErrorExit(5000,"FW ERROR!\n");
	}

	kpspident = pspSdkLoadStartModule("kpspident.prx", PSP_MEMORY_PARTITION_KERNEL);

	if (kpspident < 0) {
		ErrorExit(5000, "kpspident.prx 加载失败\n");///|ErrorExit(5000, "kpspident.prx loaded failed\n");
	}

	model = kuKernelGetModel();

	if(!(model == 0 || model == 1) || is_ta88v3()) {
		ErrorExit(5000,"此安装程序不支持此模式。\n");///|ErrorExit(5000,"This installer does not support this model.\n");
	}

	if( model == 0 ) {
		memcpy( ipl_block_large , ipl_block_01g, 0x4000);
	}

	//load module
	mod = sceKernelLoadModule("ipl_update.prx", 0, NULL);

	if (mod < 0) {
		ErrorExit(5000,"无法加载ipl_update.prx!\n");///|ErrorExit(5000,"Could not load ipl_update.prx!\n");
	}

	mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);

	if (mod < 0) {
		ErrorExit(5000,"无法启动模块!\n");///|ErrorExit(5000,"Could not start module!\n");
	}

	size = pspIplUpdateGetIpl(orig_ipl);

	if(size < 0) {
		ErrorExit(5000,"无法获得 ipl!\n");///|ErrorExit(5000,"Failed to get ipl!\n");
	}

	printf("\n自定义ipl Flasher 为"VERSION_STR"。\n\n\n");///|printf("\nCustom ipl Flasher for "VERSION_STR".\n\n\n");

	int ipl_type = 0;

	if( size == 0x24000 ) {
		printf("安装自定义ipl\n");///|printf("Custom ipl is installed\n");
		size -= 0x4000;
		memmove( ipl_block_large + 0x4000 , orig_ipl + 0x4000 , size);
		ipl_type = 1;
	} else if( size == 0x20000 ) {
		printf("原ipl \n");///|printf("Raw ipl \n");
		memmove( ipl_block_large + 0x4000, orig_ipl, size);
	} else {
		printf("ipl 大小;%08X\n", size);///|printf("ipl size;%08X\n", size);
		ErrorExit(5000,"未知 ipl!\n");///|ErrorExit(5000,"Unknown ipl!\n");
	}

	printf(" 按X键");///|printf(" Press X to ");

	if( ipl_type ) {
		printf("重新");///|printf("Re");
	}

	printf("安装CIPL\n");///|printf("install CIPL\n");

	if( ipl_type ) {
		printf(" 按O键擦除CIPL和还原原IPL\n");///|printf(" Press O to Erase CIPL and Restore Raw IPL\n");
	}

	printf(" 按R键取消\n\n");///|printf(" Press R to cancel\n\n");
    
	while (1) {
        SceCtrlData pad;
        sceCtrlReadBufferPositive(&pad, 1);

		if (pad.Buttons & PSP_CTRL_CROSS) {
			flash_ipl( size );
			break; 
		} else if ( (pad.Buttons & PSP_CTRL_CIRCLE) && ipl_type ) {		
			printf("Flashing IPL...");

			if(pspIplUpdateClearIpl() < 0) {
				ErrorExit(5000,"无法清除 ipl!\n");///|ErrorExit(5000,"Failed to clear ipl!\n");
			}

			if (pspIplUpdateSetIpl( ipl_block_large + 0x4000 , size ) < 0) {
				ErrorExit(5000,"无法写入 ipl!\n");///|ErrorExit(5000,"Failed to write ipl!\n");
			}

			printf("完成。\n");///|printf("Done.\n");
			break; 
		} else if (pad.Buttons & PSP_CTRL_RTRIGGER) {
			ErrorExit(2000,"用户取消。\n");///|ErrorExit(2000,"Cancelled by user.\n");
		}

		sceKernelDelayThread(10000);
	}

	ErrorExit(5000,"\n安装完成。 5秒内重新启动...\n");///|ErrorExit(5000,"\nInstall complete. Restarting in 5 seconds...\n");

	return 0;
}