You are here

Redirecting an Env Var for an App you aren't executing.

17 posts / 0 new
Last post
digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
Redirecting an Env Var for an App you aren't executing.

Currently I'm testing a version of the SMPlayer launcher that redirects %USERPROFILE%. However, it is well known that bMPlayer creates a folder called .dvdcss in the same directory, and MPlayer is executed by SMPlayer, not SMPlayer Portable. So therefore I would also need to redirect an app I'm not executing. This would probably be only achieved by modifying SMPlayer's code, but I don't know and am not intending to learn C++. I can almost be partly sure that I can make it so that the app I do execute ends up redirecting all other executions. Hm... I'll try that....
*About 732 hours later.*
Darn, not even general redirecting works...
Oh, well, guess I'll need to try some begging over at SMPlayer.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 5 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Follows

The environment follows down the change.

SMPlayerPortable sets an environment variable and launches SMPlayer
SMPlayer inherits the environment from SMPlayer Portable. SMPlayer launches MPlayer.
MPlayer inherits the environment from SMPlayer.

Sometimes, the impossible can become possible, if you're awesome!

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
That's good to know

I thought it may work like that Thinstall topic said.
But too bad... It doesn't even support redirection...

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
Nope, set env var in your

Nope, set env var in your launcher and MPlayer will inherit it in 2 steps. You need to do nothing more, it's just going to work.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
But SMPlayer

won't inherit it.

Insert original signature here with Greasemonkey Script.

Simeon
Simeon's picture
Offline
Last seen: 9 years 6 months ago
DeveloperTranslator
Joined: 2006-09-25 15:15
Are you sure

it uses the variable you´re setting?
I have an App where I end up copying the files cause it uses variables strangely.

"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
Good question.

Good question.
Digitxp, you can use http://www.ii.uj.edu.pl/~adamczym/printEnvVars.exe to check this. Just rename it to mplayer.exe and put in the right directory.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
It works!

But I'm not sure if Mplayer will check...

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
Try the tool. If it returns

Try the tool. If it returns corrected env var value, then the problem is that MPlayer doesn't use %USERPROFILE% but i.e. CSIDL_PERSONAL. If it's so then you'll have hard time changing it from launcher. ^_^

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
What's that?

A var? Reg entry?

Insert original signature here with Greasemonkey Script.

Jimbo
Offline
Last seen: 4 years 2 months ago
Joined: 2007-12-17 05:43
a syscall

which makes it painful to alter on a per-application basis, since the value returned is global to the entire system

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
Google doesn't bite.

Google doesn't bite.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
Yes,

Google just does happen to be blocked at school (SonicWALL is now blocking educational websites!!!!).

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
http://msdn.microsoft.com/en-

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
?

It said CSIDL_Personal was to my Docs...

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
My bad, should be

My bad, should be CSIDL_PROFILE. Anyway you don't know yet if this is what MPlayer uses anyway. Go and ask on MPlayer forum or try to find it in sources.
Then use MS Detours (or another API hooking library) to catch the API call responsible for returning the path to user profile and replace it with something returns the one you want.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
If it doesn't then it's

If it doesn't then it's SMPlayer's fault, it changes the environment.
I see 3 bad solutions. Blum
-You can modify it's code, but maintenance will be painful.
-You can modify default user vars. Doesn't have to work and it's possible that in some cases (system crash, launcher process termination) you'll leave them invalid.
-AFAIR there are tools that modify other processes' environment. Find one that does it from command line and use as soon as MPlayer is launched (Can you detect it?). If there isn't one that does it, you can make one yourself, it's not that hard, especially as MPlayer is a windowed app and you can use SetWindowsHookEx to inject a dll into it. You need to write it in a compiled language though.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

Log in or register to post comments