From: a.c.kirk@x400.icl.co.uk
Subject: Re: GINA question
Date: Fri, 16 Jan 1998 12:03:47 -0600
Message-ID: <884971567.186318856@dejanews.com>
Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode
Organization: Deja News Posting Service
Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news-was.dfn.de!news-kar1.dfn.de!newsfeed.nacamar.de!news-peer.sprintlink.net!news.sprintlink.net!Sprint!newsfeed.internetmci.com!207.207.0.25!nntp.texas.net!nntp2.dejanews.com!grunt.dejanews.com!not-for-mail
X-Article-Creation-Date: Fri Jan 16 17:26:08 1998 GMT
X-Authenticated-Sender: a.c.kirk@x400.icl.co.uk
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) via <B>Spaghetti Proxy Server</B> 2.0
X-Originating-IP-Addr: 194.176.222.98 ()
Lines: 102


>Any idea what I'm doing wrong here?  I figure it could be one of two
>things:
>1. I'm doing something wrong.  The SID I'm returning is wrong, the
>token is bad, or my LogonUser failed.  But, comparing my returned
>values to those returned by msgina's WlxLoggedOutSAS doesn't reveal
>any obvious problems.
>2. msgina.dll's WlxLoggedOutSAS sets some global state variables that
>WlxActivateUserShell expects to see.  When I substitute my code for
>msgina's, those globals never get set and all hell breaks loose.  But
>this would seem to be a pretty perverse thing to for Microsoft to do,
>and you would think that whoever wrote GinaStub would point this out
>(since it means that the stub method won't work in all cases).

Mark,

Its the 2nd of your options and yes it is extremely anti-social !
Sadly you will have to write your own WlxActivateUserShell function.

Something on the lines of the code below should do the trick but I
wouldn't swear on it coz I've just quickly extracted it from an old
project of mine and having removed some extraneous code to make it
clearer I can't guarantee it still works ! It will give you an idea
though.

Good Luck
Andy Kirk
ICL Software Technologies Ltd

#define WINLOGON_APP	TEXT("Winlogon")
#define USERINIT		TEXT("Userinit")
#define USERINIT_DEFAULT	TEXT("Userinit.exe")


BOOL
WINAPI
WlxActivateUserShell(
	PVOID	pWlxContext,
	PWSTR	pszDesktop,
	PWSTR	pszMprLogonScript,
	PVOID	pEnvironment
				)
{
	LPWSTR			pszScan;
	STARTUPINFO 		si;
	PROCESS_INFORMATION 	pi;

	BOOL	response;
	WCHAR	szUserinit[256];

	//Identify and launch all programs identified by
	//SOFTWARE\Microsoft\Windows NT\Current Version\Winlogon\USERINIT

	GetProfileString(
		WINLOGON_APP,
		USERINIT,
		USERINIT_DEFAULT,
		szText,
		256);

	pszScan = wcstok(szUserinit, TEXT(","));

	while (pszScan)
	{
		ZeroMemory(&si, sizeof(si));
		si.cb = sizeof(STARTUPINFO);
		si.lpTitle = pszScan;
		si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
		si.dwFlags = 0;
		si.wShowWindow = SW_SHOW;
		si.lpReserved2 = NULL;
		si.cbReserved2 = 0;
		si.lpDesktop = pszDesktop;

		//Impersonate the user logging on - g_UserToken is the token
                //handle returned by LogonUser

		ImpersonateLoggedOnUser(g_UserToken);

		if (CreateProcessAsUser(
                        g_UserToken,            // Token to run as
			NULL,                   // App name
			pszScan,                // Command Line
			NULL,                   // Process SD
			NULL,                   // Thread SD
			FALSE,                  // No inherit
			CREATE_UNICODE_ENVIRONMENT,
			pEnvironment,
			NULL,
			&si,
			&pi))
		{
			CloseHandle(pi.hProcess);
			CloseHandle(pi.hThread);
		}
		RevertToSelf();
		pszScan = wcstok(NULL,TEXT(","));
	}
}

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
