[resolved] toggle usb/flash0...

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

Moderators: cheriff, TyRaNiD

Post Reply
peb
Posts: 26
Joined: Mon Mar 12, 2007 10:01 pm

[resolved] toggle usb/flash0...

Post by peb »

Hi!

In time, I make test on flash0, just for me, it's test!(Don't think I want release the hundredth HB about flash0^^) and for security I want make prx to toggle USB (flash0). So I have done this prx (I have seen Wildcard src witch I have adapted for 4.xx kernel), but I have probleme, when I run this (via an eboot), my pc detect the device but I can't open it (I see the device, but it put message like I connect my psp in USB/MS without MS^^)

So I have few questions :
1- The probleme can come of attribute of my prx? (0x1006)
2- I must add an assigment?
Last edited by peb on Mon Sep 08, 2008 7:30 pm, edited 1 time in total.
Sorry for my English, I'm french.
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <psppower.h>
#include <kubridge.h>
#include <pspusb.h>
#include <pspwlan.h>
#include <pspumd.h>
#include <pspctrl.h>
#include <pspusbstor.h>
#include <pspusbdevice.h>

PSP_MODULE_INFO&#40;"PSPRevealed", 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;

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

pspDebugScreenInit&#40;&#41;;	
SetupCallbacks&#40;&#41;;
pspDebugScreenSetTextColor&#40;0x0000FF&#41;;
	
SceCtrlData pad;

printf&#40;"PSPRevealed by RZX15.\n"&#41;;
printf&#40;"Below is a list of some of your PSP's basic information.\n\n"&#41;;

printf&#40;"Ethernet Address&#58; sceWlanGetEtherAddr&#40;8&#41;\n"&#41;;

while&#40;1&#41; &#123;
if &#40;sceWlanDevIsPowerOn&#40;&#41; == 1&#41; &#123;
printf&#40;"Your Wlan Switch is on.\n\n"&#41;;
&#125;
else &#123;
printf&#40;"Your Wlan Switch is turned off.\n\n"&#41;;
&#125;
break;
&#125;

while&#40;1&#41; &#123;
if &#40;scePowerIsLowBattery&#40;&#41; == 1&#41; &#123;
printf&#40;"Your Battery is Low.\n"&#41;;
&#125;
else &#123;
printf&#40;"Your Battery is not Low.\n"&#41;;
&#125;
break;
&#125;

while&#40;1&#41; &#123;
if &#40;scePowerIsBatteryExist&#40;&#41; == 1&#41; &#123;
printf&#40;"A Battery Exists.\n"&#41;;
&#125;
break;
&#125;

printf&#40;"Your Battery Percentage is scePowerGetBatteryLifePercent&#40;&#41;.\n"&#41;;

printf&#40;"Battery Temperature&#58; scePowerGetBatteryTemp&#40;&#41;.\n"&#41;;

printf&#40;"Battery Volt Level&#58; scePowerGetBatteryVolt&#40;&#41;.\n"&#41;;

while&#40;1&#41; &#123;
if &#40;scePowerIsBatteryCharging&#40;&#41; == 1&#41; &#123;
printf&#40;"Your Battery is Charging.\n"&#41;;
&#125;
else &#123;
printf&#40;"Your Battery is Not Charging.\n\n"&#41;;
&#125;
break;
&#125;
	
	while&#40;1&#41; &#123;
		if &#40;kuKernelGetModel&#40;&#41; == PSP_MODEL_SLIM_AND_LITE&#41; &#123;
			printf&#40;"Your PSP is a Slim.\n"&#41;;
		&#125;
		break;
	&#125;
	while&#40;1&#41; &#123;
		if &#40;kuKernelGetModel&#40;&#41; == PSP_MODEL_STANDARD&#41; &#123;
			printf&#40;"Your PSP is a Fat.\n"&#41;;
		&#125;
		break;
	&#125;

kuKernelLoadModule&#40;"flash0&#58;/kd/semawm.prx", 0, NULL&#41;;
kuKernelLoadModule&#40;"flash0&#58;/kd/usbstor.prx", 0, NULL&#41;;
kuKernelLoadModule&#40;"flash0&#58;/kd/usbstormgr.prx", 0, NULL&#41;;
kuKernelLoadModule&#40;"flash0&#58;/kd/usbstorms.prx", 0, NULL&#41;;
kuKernelLoadModule&#40;"flash0&#58;/kd/usbstorboot.prx", 0, NULL&#41;;
kuKernelLoadModule&#40;"flash0&#58;/kd/usbdevice.prx", 0, NULL&#41;;


printf&#40;"Press X to Toggle USB.\n"&#41;;
	
	while&#40;1&#41; &#123;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
			sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
			sceUsbStart&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
	    sceUsbActivate&#40;0x1c8&#41;;
		&#125;
		break;
	&#125;
	printf&#40;"When USB is Toggled, press O to Terminate.\n"&#41;;
	
	while&#40;1&#41; &#123;
		if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; &#123;
			sceUsbDeactivate&#40;0x1c8&#41;;
			sceUsbStop&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
			sceUsbStop&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
		&#125;
		break;
	&#125;
	
	printf&#40;"Press &#91;&#93; to Toggle USB &#40;FLASH0&#41;\n"&#41;;
	
	while&#40;1&#41; &#123;
		if&#40;pad.Buttons & PSP_CTRL_SQUARE&#41; &#123;
		pspUsbDeviceSetDevice&#40;0, 0, NULL&#41;;
			sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
			sceUsbStart&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
			sceUsbActivate&#40;0x1c8&#41;;
		&#125;
		break;
	&#125;
	
	printf&#40;"When USB is Toggled &#40;FLASH0&#41;, press Triangle to Terminate."&#41;;
	
	while&#40;1&#41; &#123;
		if&#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41; &#123;
			sceUsbDeactivate&#40;0x1c8&#41;;
			sceUsbStop&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
			pspUsbDeviceFinishDevice&#40;&#41;;
			sceUsbStop&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
		&#125;
		break;
	&#125;			
		
	
sceKernelSleepThread&#40;&#41;;

return 0; 

&#125;

Code: Select all

TARGET = psprevealed
OBJS = main.o 

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

LIBDIR =
LIBS = -lpspkernel -lpspdebug -lpsppower -lpspkubridge -lpspusb -lpspwlan -lpspumd -lpspctrl -lpspusbstor -lpspusbdevice
LDFLAGS =

PSP_FW_VERSION = 371

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = PSPRevealed


BUILD_PRX = 1

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
ALL the help you need. This was RZX15 work so credits go to him. Simple application but usefull source.

=D

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

Post by Pirata Nervo »

pspusbdevice.h :)
Image
Upgrade your PSP
peb
Posts: 26
Joined: Mon Mar 12, 2007 10:01 pm

Post by peb »

Oh thank you very much!!! I can see my flash0, finally!

And thank RZX15 for your good job ;)
Sorry for my English, I'm french.
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

peb wrote:Oh thank you very much!!! I can see my flash0, finally!

And thank RZX15 for your good job ;)
i would have said thanks M33 for the SDK...
peb
Posts: 26
Joined: Mon Mar 12, 2007 10:01 pm

Post by peb »

lol, thank everybody who have contributed to do this work and people that help me! (M33, RZX15 and people that I have forgotten) ;)
Sorry for my English, I'm french.
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

i'm sorry if i'm offtopic, but i wanna say...

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

Post by Pirata Nervo »

@peb, the usage IS VERY SIMPLE, you must thank m33 team only, the pspusbdevice.h files has enough comments which tell you how to use the functions. RZX15 only made usage of them.

most of the file posted is not needed for USB access
Image
Upgrade your PSP
Post Reply