| View previous topic :: View next topic |
| Author |
Message |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 6:17 pm Post subject: How to get own filename of running program? |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sun Jun 01, 2008 6:25 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 6:30 pm Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sun Jun 01, 2008 6:31 pm Post subject: |
|
|
| Yah well the first argument should be the path to the currently running file, so just look at that. |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 6:33 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 6:35 pm Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sun Jun 01, 2008 6:36 pm Post subject: |
|
|
| Oh well you are stuffed then :P |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 6:39 pm Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sun Jun 01, 2008 6:53 pm Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sun Jun 01, 2008 7:02 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
|
| Back to top |
|
 |
|