How to change vsh/module attibut

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

Moderators: cheriff, TyRaNiD

Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

How to change vsh/module attibut

Post by Alree »

Hi !

Does anyone know how to remove a *.prx file into flash0:/vsh/module directory.
until 3.71m33 this directory is Hidden and in ReadOnly mode

I just want to be able to delete/replace some files in this folder but... that's doesn't work.

ex:

I juste make a dummy.txt file inside vsh/module via Windows
With sceIoRemove I can't remove this file...

sceIoRemove return no error ...

Any idea ? flash0 is already assigned with 0777 attribut
it's possible to replace vshmain.prx and paf.prx via an eboot in kernel mode ?
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

Use sceIoChstat to change the file attributes,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

thanks but that's doesn't work...

so I can't remove or replace file in flash0:/vsh/module directory

sceIoRemove("flash0:/vsh/module/paf.prx")
sceIoOpen('flash0:/vsh/module/paf.prx", PSP_O_RDONLY, 0777);
return error...

So if I can't remove or open it's impossible to me to write a new one.
I just want to finish a Theme Flasher who can flash paf.prx and vshmain.prx

So if I want to copy a dummy file in flash0:/vsh/module/ dummy file go in vsh/podule ! WTF ?

i'm in PSP1004 FAT 3.80M33-5 with Kernel 1.50
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

sceIoChstat does work because I'm using it for exactly the same reason in my own theme flasher,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

so when and how you use it..
just before deleting file doesn't work.
juste before replacing file or write in... doesn't work
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

You need to use SceIoStat and sceIoChstat before sceIoRemove
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

... *cry*

ok I just try to make a fonction

Code: Select all

void Remove_file(char * Delfile)
{
int file_exist,test_del;;
file_exist = sceIoOpen(Delfile, PSP_O_RDONLY, 0777);
	if (file_exist>=0){
		SceIoStat stat;
		memset(&stat, 0, sizeof(SceIoStat));
		sceIoGetstat(Delfile, &stat);
		stat.st_attr &= ~0x0F;
		sceIoChstat(Delfile, &stat, 3);
		test_del = sceIoRemove(Delfile);
			if &#40;test_del<0&#41;&#123;
				pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
				printf&#40;"%s - Cannot delete file\n", Delfile&#41;;
			&#125;
			else &#123;
				pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
				printf&#40;"%s - File Deleted OK\n", Delfile&#41;;
			&#125;
	&#125;
	else &#123;
	pspDebugScreenSetTextColor&#40;0x00303030&#41;;
	printf&#40;"%s - File not found or already Deleted\n", Delfile&#41;;
	&#125;
&#125;
but

Code: Select all

Remove_file&#40;"flash0&#58;/vsh/module/vshmain.prx"&#41;;
Remove_file&#40;"flash0&#58;/vsh/module/paf.prx"&#41;;
return "File not found or Already Deleted"

I've try without the file_exist test but same way... the PRX was not deleted...

any idea ?
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

This works for me...

Code: Select all

SceIoStat stats;
sceIoChstat&#40; file_path, &stats,  0x0003&#41;;
sceIoRemove&#40;file_path&#41;;
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

just try with

Code: Select all

void Remove_file&#40;char * Delfile&#41;
&#123;
int test_del;;
		SceIoStat stat;
		sceIoChstat&#40;Delfile, &stat,  0x0003&#41;; 
		test_del = sceIoRemove&#40;Delfile&#41;;
			if &#40;test_del<0&#41;&#123;
				pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
				printf&#40;"%s - Cannot delete file\n", Delfile&#41;;
			&#125;
			else &#123;
				pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
				printf&#40;"%s - File Deleted OK\n", Delfile&#41;;
			&#125;

&#125;
but ...
flash0:/vsh/module/vshmain.prx - Cannot delete file...
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

Have you unassigned and assigned flash0 ?

Also what mode is your app in ?
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

Flash0 is unassign and re-assigned without error

Code: Select all

if &#40;sceIoUnassign&#40;"flash0&#58;"&#41; < 0&#41;
	printf&#40;"F0unassign&#58; Error | "&#41;;
if &#40;sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41; < 0&#41;
	&#123;
		printf&#40;"F0assign&#58; Error\n"&#41;;
	&#125;
and i'm in

Code: Select all

PSP_MODULE_INFO&#40;"flash", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
tested in 0x0800 too
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

This is what I have,

Code: Select all

PSP_MODULE_INFO&#40;"Write2Flash380", 0x800, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
PSP_HEAP_SIZE_MAX&#40;&#41;;
Also using the code I posted before seems to work fine and has been tested on 3.80m33-x and 3.90m33-x
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

no way for me.
I don't understand...
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

Try closing the file after you have checked that it exists,

Then do the attribute change and delete,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

i hav by-pass this fonction.
Eboot not check if file exist, just check if file sceIoRemove return no error.

Code: Select all

void Remove_file&#40;char * Delfile&#41;
&#123;
int test_del;;
		SceIoStat stat;
		sceIoChstat&#40;Delfile, &stat, 0x0003&#41;;
		test_del = sceIoRemove&#40;Delfile&#41;;
			if &#40;test_del<0&#41;&#123;
				pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
				printf&#40;"%s - Cannot delete file\n", Delfile&#41;;
			&#125;
			else &#123;
				pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
				printf&#40;"%s - File Deleted OK\n", Delfile&#41;;
			&#125;

&#125;
i'll try to install 3.90M33 ... sniff i love my 3.80...

[edit]
Same way in 3.90M33-2 k1.50v2
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

tested on my second PSP FAT just passed on 3.90M33-2 too...
cannot delete file...
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

I just did a few tests with the code and it seems I'm also now getting strange results,

I created 4 read only txt files and tried to delete one and it would not delete until I tried to delete the 2nd time,


But I can then delete any of the other read only files in one go,

Seems strange to me so I will try to work it out,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

and could you copy file into vsh/module or files go in vsh/podule like on my psp ?

that's really strange. M33 be hard-protected...
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

It's wierd because the theme flashing works fine well it seems to be but when in the file browser (another feature of the app) I sometimes get wierd results using my file copy, file paste and delete features,

It's strange, lol

I'm going to have to take a look at it again when I'm not so sleepy,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

all other flashing procedure works fine.
but not in this F*** directory...
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

I will PM you a link to my app if you want so you can see what I mean,

Its strange how it deletes it on the 2nd attempt when in the file browser,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

thanks and i'll try with IRShell too when go!messenger installation finished -_-
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

PM has been sent,
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

Tested, and that's work on your app... but I don't understand why only in your app
Gh0st-UPMS
Posts: 23
Joined: Sun Feb 17, 2008 12:32 am

Post by Gh0st-UPMS »

Alree wrote:Tested, and that's work on your app... but I don't understand why only in your app
Try this code, works for me.

Code: Select all

PSP_MODULE_INFO&#40;"Your App Name", 0x800, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
PSP_HEAP_SIZE_KB&#40;21000&#41;;

void ReassignFlash0&#40;&#41; 
&#123;
	int flash0_unassign, flash0_assign;
	
  flash0_unassign = sceIoUnassign&#40;"flash0&#58;"&#41;;
  flash0_assign = sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
	
	if&#40;flash0_unassign < 0&#41;&#123;
			pspDebugScreenClear&#40;&#41;;
			printf&#40;"  Error&#58; Unassigning Flash0\n"&#41;;
			sceKernelDelayThread&#40;500000&#41;;
			sceKernelExitGame&#40;&#41;;
		&#125;
	else if&#40;flash0_assign < 0&#41;&#123;
			pspDebugScreenClear&#40;&#41;;
			printf&#40;"  Error&#58; Assigning Flash0\n"&#41;;
			sceKernelDelayThread&#40;500000&#41;;
			sceKernelExitGame&#40;&#41;;
		&#125;
		else&#123;
				printf&#40;"  Flash assigned\n"&#41;;
			&#125;
&#125;

void removeStatus&#40;const char *file&#41;
&#123;
	int fileDelete;
	
	SceIoStat stat;
	memset&#40;&stat, 0, sizeof&#40;SceIoStat&#41;&#41;;
	sceIoGetstat&#40;file, &stat&#41;;
	stat.st_attr &= ~0xFF;
	sceIoChstat&#40;file, &stat, 3&#41;;//Hidden Stat
	sceIoChstat&#40;file, &stat, 4&#41;;//Archive Stat
	sceIoChstat&#40;file, &stat, 6&#41;;//Read Only Stat
	
	fileDelete = sceIoRemove&#40;file&#41;;
	if&#40;fileDelete < 0&#41;&#123;
		sceKernelDelayThread&#40;300000&#41;;
		printf&#40;"%s&#58; Deleted unsuccessful", file&#41;;
	&#125;
	else &#123;
		sceKernelDelayThread&#40;300000&#41;;
		printf&#40;"%s&#58; was deleted successfully", file&#41;;
	&#125;
&#125;
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

Just tested the code and it works perfectly,

Thanks Gh0st-UPMS
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

Just tested, same way...

I have flashed a dummy.txt file in flash0:/vsh/module but Cannot delete

Code: Select all

PSP_MODULE_INFO&#40;"fnof", 0x800, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
PSP_HEAP_SIZE_KB&#40;21000&#41;; 


int main&#40;void&#41; 
&#123; 
   pspDebugScreenInit&#40;&#41;; 
pspDebugScreenClear&#40;&#41;;
pspDebugScreenSetTextColor&#40;0x00FFFFFF&#41;;
   int flash0_unassign, flash0_assign;
   
  flash0_unassign = sceIoUnassign&#40;"flash0&#58;"&#41;;
  flash0_assign = sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
   
   if&#40;flash0_unassign < 0&#41;&#123;
         pspDebugScreenClear&#40;&#41;;
         printf&#40;"  Error&#58; Unassigning Flash0\n"&#41;;
         sceKernelDelayThread&#40;500000&#41;;
         sceKernelExitGame&#40;&#41;;
      &#125;
   else if&#40;flash0_assign < 0&#41;&#123;
         pspDebugScreenClear&#40;&#41;;
         printf&#40;"  Error&#58; Assigning Flash0\n"&#41;;
         sceKernelDelayThread&#40;500000&#41;;
         sceKernelExitGame&#40;&#41;;
      &#125;
      else&#123;
            printf&#40;"  Flash assigned\n"&#41;;
         &#125; 
printf&#40;"\n\nFlashage en Cours...\n"&#41;; 
sceKernelDelayThread&#40;100*1000&#41;; 
Remove_file&#40;"flash0&#58;/vsh/module/dummy.txt"&#41;;
sceKernelDelayThread&#40;1000*10000&#41;; 
pspDebugScreenSetTextColor&#40;0x00FFFFFF&#41;;
printf&#40;"Operation terminee"&#41;;
return 0;
&#125;

void Remove_file&#40;char * Delfile&#41;
&#123;
//int file_exist;
int test_del;;
//file_exist = sceIoOpen&#40;Delfile, PSP_O_RDONLY, 0777&#41;;
//	if &#40;file_exist>=0&#41;&#123;
   SceIoStat stat;
   memset&#40;&stat, 0, sizeof&#40;SceIoStat&#41;&#41;;
   sceIoGetstat&#40;Delfile, &stat&#41;;
   stat.st_attr &= ~0xFF;
   sceIoChstat&#40;Delfile, &stat, 3&#41;;//Hidden Stat
   sceIoChstat&#40;Delfile, &stat, 4&#41;;//Archive Stat
   sceIoChstat&#40;Delfile, &stat, 6&#41;;//Read Only Stat 
		test_del = sceIoRemove&#40;Delfile&#41;;
			if &#40;test_del<0&#41;&#123;
				pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
				printf&#40;"%s - Cannot delete file\n", Delfile&#41;;
			&#125;
			else &#123;
				pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
				printf&#40;"%s - File Deleted OK\n", Delfile&#41;;
			&#125;
//	&#125;
//	else &#123;
//	pspDebugScreenSetTextColor&#40;0x00303030&#41;;
//	printf&#40;"%s - File not found or already Deleted\n", Delfile&#41;;
//	&#125;
&#125;
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

@Alree - This worked fine for me,

Code: Select all

SceIoStat stats;
memset&#40; &stats, 0, sizeof&#40;SceIoStat&#41;&#41;;
sceIoGetstat&#40; file_path, &stats&#41;;
stats.st_attr &= ~0x0F;    // This line is differant from the example given by Gh0st-UPMS
sceIoChstat&#40; file_path, &stats,  3&#41;;
sceIoChstat&#40; file_path, &stats,  4&#41;;
sceIoChstat&#40; file_path, &stats,  6&#41;;
sceIoRemove&#40; file_path&#41;;
Alree
Posts: 33
Joined: Tue Feb 26, 2008 10:50 pm

Post by Alree »

well ...

Code: Select all

  
#include <pspkernel.h> 
#include <pspctrl.h>
#include <pspsdk.h>
#include <pspiofilemgr.h> 
#include <stdlib.h> 
#include <string.h> 
#include <stdio.h> 
#include <pspgu.h> 
#include <psputils.h>
//#include <stdarg.h>
#include <pspmoduleinfo.h>

#define printf pspDebugScreenPrintf 

PSP_MODULE_INFO&#40;"fnof", 0x800, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
PSP_HEAP_SIZE_KB&#40;21000&#41;; 


void Remove_file&#40;char * Delfile&#41;
&#123;
int test_del;;
SceIoStat stats;
sceIoGetstat&#40; Delfile, &stats&#41;;
stats.st_attr &= ~0x0F;    // This line is differant from the example given by Gh0st-UPMS
sceIoChstat&#40; Delfile, &stats,  3&#41;;
sceIoChstat&#40; Delfile, &stats,  4&#41;;
sceIoChstat&#40; Delfile, &stats,  6&#41;;
		test_del = sceIoRemove&#40;Delfile&#41;;
			if &#40;test_del<0&#41;&#123;
				pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
				printf&#40;"%s - Cannot delete file\n", Delfile&#41;;
			&#125;
			else &#123;
				pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
				printf&#40;"%s - File Deleted OK\n", Delfile&#41;;
			&#125;

&#125;

int main&#40;void&#41; 
&#123; 
pspDebugScreenInit&#40;&#41;; 
pspDebugScreenClear&#40;&#41;;
pspDebugScreenSetTextColor&#40;0x00FFFFFF&#41;;

   int flash0_unassign, flash0_assign;
   
  flash0_unassign = sceIoUnassign&#40;"flash0&#58;"&#41;;
  flash0_assign = sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
   
   if&#40;flash0_unassign < 0&#41;&#123;
         pspDebugScreenClear&#40;&#41;;
         pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
         printf&#40;"Error&#58; Unassigning Flash0\n"&#41;;
         sceKernelDelayThread&#40;500000&#41;;
         sceKernelExitGame&#40;&#41;;
      &#125;
   else if&#40;flash0_assign < 0&#41;&#123;
         pspDebugScreenClear&#40;&#41;;
           pspDebugScreenSetTextColor&#40;0x000000FF&#41;;
         printf&#40;"Error&#58; Assigning Flash0\n"&#41;;
         sceKernelDelayThread&#40;500000&#41;;
         sceKernelExitGame&#40;&#41;;
      &#125;
      else&#123;
           pspDebugScreenSetTextColor&#40;0x0000FF00&#41;;
		   printf&#40;"Flash assigned\n"&#41;;
         &#125;
pspDebugScreenSetTextColor&#40;0x00FFFFFF&#41;;		 
printf&#40;"\n\nFlashage en Cours...\n"&#41;; 
sceKernelDelayThread&#40;100*1000&#41;; 
Remove_file&#40;"flash0&#58;/vsh/module/dummy.txt"&#41;;
sceKernelDelayThread&#40;1000*10000&#41;; 
pspDebugScreenSetTextColor&#40;0x00FFFFFF&#41;;
printf&#40;"Operation terminee"&#41;;
return 0;
&#125;
any suggestion that's doesn't work ?
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

Alree wrote:Tested, and that's work on your app... but I don't understand why only in your app
So it's maybe a SDK or compiler problem, try to update PSPSDK.
Post Reply