Как ранее уже обсуждалось на форуме что недостаточно просто заменить функцию WlxLogonOutSas а еще надо и заменить функцию WlxActivateUserShel. Но к сожалению это не дает желаемого результата для входа в систему. У меня очень большая просьба помоч советом или информацией что я делаю не так очень надо пожалуйста. Ниже прифожу коды этих двух функций.
function WlxLoggedOutSAS(pWlxContext: Pointer; dwSasType: DWORD;
pAuthenticationId: PLargeInteger; pLogonSid: PSID; pdwOptions: PDWORD;
phToken: PHandle; pMprNotifyInfo: PWlxMprNotifyInfo; out pProfile: Pointer
): Integer; stdcall;
var
Context: PGinaContext;
UserStats: TTOKEN_STATISTICS;//TTokenStatistics;
StatsSize: DWORD;
pGroups:PTokenGroups;
i:Integer;
begin
Result := WLX_SAS_ACTION_NONE;
Context := PGinaContext(pWlxContext);
if (phToken <> nil) then
begin
{ Attempt to log on the user: guest, domain: earth
with password: secret. }
if LogonUser('Volodymyr Yelchev', 'YELCHEV', '*******',{ LOGON32_LOGON_UNLOCK} LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT, phToken^) then
begin
{ Check the user token. }
if (phToken^ <> 0) then
begin
{ Save the user token in the GINA context }
Context^.UserToken := phToken^;
{ Pass back null profile and options. }
pdwOptions^ := 0;
pProfile := nil;
{ Get the authenticationid from the user token. }
if GetTokenInformation(phToken^, TokenStatistics, Pointer(@UserStats),
SizeOf(TTOKEN_STATISTICS{TTokenStatistics}), StatsSize) then
begin
pAuthenticationId^ := Int64(UserStats.AuthenticationId);
ShowMessage(IntTOStr(Int64(UserStats.AuthenticationId)));
ShowMessage('pLogonSid='+IntTOStr(Integer(pLogonSid)));
//pGroups:=nil;
HLOCAL(pGroups):= LocalAlloc(LMEM_FIXED, 1024);
if (pGroups=nil) Then
Begin
CloseHandle(phToken^);
Result := WLX_SAS_ACTION_NONE;
exit;
End;
GetTokenInformation(phToken^,TokenGroups, pGroups,1024,StatsSize);
if (StatsSize > 1024) Then
Begin
HLOCAL(pGroups):=LocalReAlloc(HLOCAL(pGroups),LMEM_FIXED,StatsSize);
GetTokenInformation(phToken^,TokenGroups, pGroups,1024,StatsSize);
End;
for i:= 0 to (pGroups^.GroupCount)-1 do
Begin
ShowMessage(IntToStr(pGroups^.Groups[i].Attributes));
if ((pGroups^.Groups[i].Attributes and SE_GROUP_LOGON_ID) = SE_GROUP_LOGON_ID) Then
Begin
if IsValidSid(pGroups^.Groups[i].Sid) Then
Begin
if CopySid(GetLengthSid(pGroups^.Groups[i].Sid),
pLogonSid,
pGroups^.Groups[i].Sid ) Then
Begin
if IsValidSid(pGroups^.Groups[i].Sid) Then
Begin
ShowMessage('We have found something!!!!!');
break;
End;
End
Else ShowMessage('Copy Sid Error');
End
Else ShowMessage('SID Error');
End;
End;
LocalFree(HLOCAL(pGroups));
{ Pass back multiple provider information. }
pMprNotifyInfo.pszUserName := DupString('Volodymyr Yelchev');
pMprNotifyInfo.pszDomain := DupString('YELCHEV');
pMprNotifyInfo.pszPassword := DupString('*******');
pMprNotifyInfo.pszOldPassword := nil;
Result := WLX_SAS_ACTION_LOGON;
end
else
Begin
ShowMessage('Error GetTokenInformation');
End;
end;
end;
end;
end;
function WlxActivateUserShell(pWlxContext: Pointer; pszDesktopName,
pszMprLogonScript: PWideChar; pEnvironment: Pointer): BOOL; stdcall;
var
Context: PGinaContext;
SI: TStartupInfo;
PI: TProcessInformation;
szText:array[0..Max_Path] of char;
cmdCommand:Pchar;
begin
{Result := pfWlxActivateUserShell(pWlxContext, pszDesktopName,
pszMprLogonScript, pEnvironment);}
Context := pWlxContext;
GetProfileString(WINLOGON_APP, USERINIT, USERINIT_DEFAULT, szText, MAX_PATH);
{ Setup TStartupInfo to pass to CreateProcessAsUser. }
ShowMessage('aplication name '+szText);
cmdCommand:=DupPString(@szText);
ShowMessage('aplication name cmdCommand '+cmdCommand);
FillChar(SI,SizeOf(TStartupInfo),0);
SI.cb := SizeOf(TStartupInfo);
SI.lpReserved := nil;
SI.lpTitle :=cmdCommand;
SI.dwX := 0;
SI.dwY := 0;
SI.dwXSize := 0;
SI.dwYSize := 0;
SI.dwFlags := 0;
SI.wShowWindow := SW_SHOW;
SI.lpReserved2 := nil;
SI.cbReserved2 := 0;
SI.lpDesktop := pszDesktopName;
ShowMessage('Desktop '+pszDesktopName);
{ Create the process for Userinit.exe. }
ImpersonateLoggedOnUser(Context^.UserToken);
Result := CreateProcessAsUser(Context^.UserToken, nil,cmdCommand, nil,
nil, False, CREATE_UNICODE_ENVIRONMENT, pEnvironment, nil, SI, PI);
if Result Then
Begin
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
ShowMessage('We have run userinit.exe');
End
Else ShowMessage('I cant run userinit.exe'+' = '+inttostr(GetLastError));
RevertToSelf;
{ Release the memory winlogon allocated for the environment. }
//VirtualFree(pEnvironment, 0, MEM_RELEASE);
end;
С уважением Владимир.