detect access via usb

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

Moderators: cheriff, TyRaNiD

Post Reply
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

detect access via usb

Post by phobox »

hello everybody!
I wanted to know how to know ( =) ) when data is tranferring over usb during an usb-pc connection.

in other words, do you remember the bar that goes to the left and to the right on the vsh when usb connection to memory stick is active? ok, how can i detect that event? how can i know that there is "something happening" at the usb port?

i think maybe is easier to look at the memory stick led, and detect when it is flashing, but how to do this?
would this work when flashes and umd are toggled via usb as well?

thanks very much!
Ciao! from Italy
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Just run a timer thread and check the amount of data transferred at regular intervals. If its increasing then its transferring.

Unless you're trying to monitor another apps USB connection...then I dunno.
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

how do u check the data being transfered from the psp?
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

thanks, but how can i "check the amount of data transferred"
Ciao! from Italy
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

phobox wrote:thanks, but how can i "check the amount of data transferred"
I had some sample code showing how to read the bytes transferred. Can't seem to find it. Its only applicable if YOUR app started the USB.
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

Torch wrote:
phobox wrote:thanks, but how can i "check the amount of data transferred"
I had some sample code showing how to read the bytes transferred. Can't seem to find it. Its only applicable if YOUR app started the USB.
yes my app DID start usb.
I wrote a working usb utility, now i want to add the possibility to know if data is tranferring over osb...

where did you get that sample code?
Ciao! from Italy
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

phobox wrote:
Torch wrote:
phobox wrote:thanks, but how can i "check the amount of data transferred"
I had some sample code showing how to read the bytes transferred. Can't seem to find it. Its only applicable if YOUR app started the USB.
yes my app DID start usb.
I wrote a working usb utility, now i want to add the possibility to know if data is tranferring over osb...

where did you get that sample code?
I dunno :S
Ask Hellcat or Cory1492. Both of their apps show the bytes transferred.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

???
I've never added bytes transfer to USB before... in fact, I was curious to see how this topic turned out. If I had to guess and start somewhere, I'd look for a function I could hook so I could monitor len/size info before dispatching to the original function.

Maybe Torch meant jas0nuk?
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

cory1492 wrote:???
I've never added bytes transfer to USB before... in fact, I was curious to see how this topic turned out. If I had to guess and start somewhere, I'd look for a function I could hook so I could monitor len/size info before dispatching to the original function.

Maybe Torch meant jas0nuk?
Oh... Its definitely in Hellcats EPBM.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

I guess hooking sceIoRead to msstor0: could work, but the vsh probably uses another approach, I bet they use one of these functions with unkown prototype:

Code: Select all

0x16173D42	sceUSB_Stor_Ms_driver_16173D42
0x18EB011A	sceUSB_Stor_Ms_driver_18EB011A
0x4B10A7F5	sceUsbstorMsRegisterEventFlag
0x56AA41EA	sceUSB_Stor_Ms_driver_56AA41EA
0x762F7FDF	sceUsbstorMsNotifyEventDone
0x9569F268	sceUsbstorMsSetVSHInfo
0x9C029B16	sceUSB_Stor_Ms_driver_9C029B16
0xABE9F2C7	sceUsbstorMsGetApInfo
0xFF0C3873	sceUsbstorMsUnregisterEventFlag
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

I remember doing this, including counting the ammount of data transfered, im my old pandora menu....

I hooked somewhere in the IoRead/IoWrite functions of the driver IIRC, set a flag to tell my other functions about a transfer in progress and counted the bytes in a global variable....

The solution I puzzled together wasn't all that nice (I'd guess there are way better ways to do it) but it worked pretty nicely :)

I'm not at home ATM, but when I am, I can see to dig out the code that did it....
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

hellcat, news?
thanks
bye
Ciao! from Italy
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

Here's some good, old, well known xD USB code snipped, that I had modified a while back for checking USB access and counting the ammount of data.

Not too nice, but does the job.

http://pb.area-42.net/?show=22
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

you wrote that PspIoDrv *FindDriver(char *drvname) is a 1.50 specific function.

I think it is that because of u32 text_addr = *(mod+27);
and
u32 *(* GetDevice)(char *) = (void *)(text_addr+0x16D4);

how to obtain those values?
Ciao! from Italy
Post Reply