forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get own filename of running program?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 6:17 pm    Post subject: How to get own filename of running program? Reply with quote

How do I get the filename of my current running program.

Suppose my module is flash0:/vsh/modules/torch.prx, then from inside torch.prx how can I detect its filename. Suppose I rename it to something.prx, it should be able to find its filename as something.prx.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jun 01, 2008 6:25 pm    Post subject: Reply with quote

Best you can do is assume it was passed to the process in its arguments, so with classic main functions it will be argv[0] or with the PSP native entry point it will be the first string on argp.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 6:30 pm    Post subject: Reply with quote

Actually I've made a replacment vshmain.prx which asks for a password with a pretty GUI, and then launches vshmain_real.prx.
I'm proud to say that I'm sure its the best password protection thingie available at present. I'll release it in 10 mins after i complete the readme.

I also wanted to protect recovery, so i recompiled it to launch recovery_real.prx instead.

I want to avoid compiling it twice and editing the path each time. So I though if I could just have a single file that i'll copy to both vshmain.prx and recovery.prx, and it'll autodetect its own name and will launch vshmain_real.prx or recovery_real.prx correspondingly.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jun 01, 2008 6:31 pm    Post subject: Reply with quote

Yah well the first argument should be the path to the currently running file, so just look at that.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 6:33 pm    Post subject: Reply with quote

TyRaNiD wrote:
Yah well the first argument should be the path to the currently running file, so just look at that.


Thats the problem, it isnt. On coldboot the vshmain.prx gets 0 parameters.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 6:35 pm    Post subject: Reply with quote

With 0 parameters I don't know whether its recovery, or vshmain.
All future calls to vshmain have like 256-1024 character big parameters.

I'm forwarding all parameters to the real vshmain.prx so that the xmb error messages and stuff are shown.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jun 01, 2008 6:36 pm    Post subject: Reply with quote

Oh well you are stuffed then :P
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 6:39 pm    Post subject: Reply with quote

Isn't there some convoluted way?
Like getting the moduleid or something of the current app, then searching through the list of loaded modules? The list of loaded modules contains the filesnames doesnt it? Or are those just the names defined by module_info?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jun 01, 2008 6:53 pm    Post subject: Reply with quote

I don't think the module list contains filenames, I could be wrong though, it has been a while. The PSP doesn't need them so it doesn't save them at all.

Does the recovery prx get started with a path? If so could you not just use the logic that if you have a path it is recovery else it is vshmain?
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 7:02 pm    Post subject: Reply with quote

TyRaNiD wrote:
I don't think the module list contains filenames, I could be wrong though, it has been a while. The PSP doesn't need them so it doesn't save them at all.

Does the recovery prx get started with a path? If so could you not just use the logic that if you have a path it is recovery else it is vshmain?


Silly me. I completely forgot to check if recovery was started with any parameters... Will check and see.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Jun 01, 2008 7:37 pm    Post subject: Reply with quote

Here's my app:
http://forums.qj.net/f-psp-development-forum-11/t-release-lockdown-v10-finally-a-proper-passkey-protection-140848.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group