MSFN Forum: Bug in APP launch (environment) - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bug in APP launch (environment) Rate Topic: -----

#1 User is offline   FierceRecon 

  • Group: Members
  • Posts: 2
  • Joined: 06-February 05

Posted 14 June 2005 - 01:40 PM

If you are to create a user and start a program (cmd.exe will do), WIHU's environment is not passed to the program.

E.X.
[Environment]
HELLO=BLA

...
[Some section]
command.0 = cmd.exe
description.0 = just a test


if you don't skip user creation (e.g. you create a new user), and you type in set when the cmd window shows up, you won't see the variable HELLO there.

(simple fix - download source and)
Open wihu.c
Find:
LV_EX_ITEM *Parent;
	DWORD BlankPasswordUsage = 0;
	WIHU_USER *User;

After, add:
LPVOID env = NULL;
Find
while (Env) {
 	 WCHAR EnvData[MAX_ENVVAL_SHORT_SIZE];
 	 ExpandEnvironmentStrings(Env->Value, EnvData, MAX_ENVVAL_SHORT_SIZE);
 	 SetEnvironmentVariable(Env->Key, EnvData);
 	 Env = Env->Next;
  }
After, Add (MAKE SURE TO ADD BEFORE } else {:
  CreateEnvironmentBlock(&env, NULL, TRUE);
Find
/* Start process in new user account context */
 	 Result = CreateProcessWithLogonW(User->Name, User->Domain, User->Password, LOGON_WITH_PROFILE, NULL, ExeCmd, 0, NULL, CurDir, &sti, &pi);

REPLACE WITH:
/* Start process in new user account context */
 	 Result = CreateProcessWithLogonW(User->Name, User->Domain, User->Password, LOGON_WITH_PROFILE, NULL, ExeCmd, CREATE_UNICODE_ENVIRONMENT, env, CurDir, &sti, &pi);


Recompile source...

Hope that helps some headaches.

Limitation: Generic environment for the user is not loaded, e.g. %USERNAME% will be that of the user that wihu is being run from (use %ThisUser%)


#2 User is offline   BenjaminKalytta 

  • Developer
  • PipPipPipPip
  • Group: Members
  • Posts: 609
  • Joined: 08-June 04

Posted 15 June 2005 - 03:31 AM

Thank you FierceRecon. I fixed this now.
Also %USERNAME% may be used instead of %ThisUser% only.

Benjamin Kalytta

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy