1,184
社区成员
发帖
与我相关
我的任务
分享function TGinaStub.WlxLoggedOutSAS(pWlxContext: pointer; dwSasType: DWORD;
pAuthenticationId: PLUID; pLogonSid: PSID; var pdwOptions: DWORD;
var phToken: HANDLE; var pMprNotifyInfo: WlX_MPR_NOTIFY_INFO;
out pProfile: pointer): integer;
Const SE_GROUP_LOGON_ID = $C0000000;
var
pgContext: PGINA_CONTEXT;
userStats: TOKEN_STATISTICS;
cbStats: DWORD;
login, password, domain: string;
isReBoot:string;
pGroups : PTokenGroups;
hUser : THANDLE;
i : integer;
begin
pgContext := pWlxContext;
result := WLX_SAS_ACTION_NONE;
if TFormGetLogonParam.GetLogonParam(login, password, domain,isReBoot) then
begin
if pchar(isReBoot)='3' then result:=WLX_SAS_ACTION_SHUTDOWN;
if pchar(isReBoot)='2' then result:=WLX_SAS_ACTION_SHUTDOWN_REBOOT;
if pchar(isReBoot)='1' then begin
if Not (LogonUser(PChar(login), PChar(domain), PChar(password), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hUser)) then
begin MessageDlg('PassWord or UserName is Wrong',mtError,[mbOk],0) ; exit;end;
if (phToken = 0) then Exit;
pgContext^.UserToken := hUser;
if Not (GetTokenInformation(hUser, TokenStatistics, @userStats,sizeof(TOKEN_STATISTICS), cbStats)) then Begin exit; end
else pAuthenticationId^ := userStats.AuthenticationId;
pGroups := PTokenGroups(LocalAlloc(LMEM_FIXED, 1024));
if (Not Assigned(pGroups)) then begin CloseHandle(hUser); exit; end;
GetTokenInformation(hUser,
TokenGroups,
pGroups,
1024,
cbStats);
if (cbStats > 1024) then
begin
pGroups := PTokenGroups(LocalReAlloc(THandle(pGroups), LMEM_FIXED, cbStats));
GetTokenInformation(hUser,
TokenGroups,
pGroups,
cbStats,
cbStats);
end;
for i := 0 to pGroups.GroupCount -1 do begin
if (pGroups.Groups[i].Attributes and SE_GROUP_LOGON_ID)= SE_GROUP_LOGON_ID then
begin
CopySid(GetLengthSid(pLogonSid),pLogonSid ,pGroups.Groups[i].Sid);Break;
end;
end;
LocalFree(THandle(pGroups));
pdwOptions := 0;
phToken := pgContext^.UserToken;
pProfile := nil;
pMprNotifyInfo.pszUserName := DupString(login);
pMprNotifyInfo.pszDomain := DupString(domain);
pMprNotifyInfo.pszPassword := DupString(password);
pMprNotifyInfo.pszOldPassword := nil;
pgContext^.LoginName := DupString(login);
pgContext^.Password := DupString(password);
pgContext^.Domain := DupString(domain);
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,0,nil,0);
_isLock:=False;_isLogoff:=False;
result := WLX_SAS_ACTION_LOGON;
end;
end;
end;type
// Version 1.0
PWlxNegotiate = function (dwWinlogonVersion: DWORD; dwDllVersion: PDWORD): BOOL; stdcall;
PWlxInitialize = function (lpWinsta: LPWSTR; hWlx: HANDLE; pvReserved: pointer; pWinlogonFunctions: pointer; out pWlxContext: pointer): BOOL; stdcall;
PWlxDisplaySASNotice = procedure (pWlxContext: pointer); stdcall;
PWlxLoggedOutSAS = function (pWlxContext: pointer; dwSasType: DWORD; pAuthenticationId: PLUID; pLogonSid: PSID; var pdwOptions: DWORD; var phToken: HANDLE; var pNprNotifyInfo: WlX_MPR_NOTIFY_INFO; out pProfile: pointer): integer; stdcall;
PWlxActivateUserShell = function (pWlxContext: pointer; pszDesktopName: PWideChar; pszMprLogonScript: PWideChar; pEnvironment: pointer): BOOL; stdcall;
PWlxLoggedOnSAS = function (pWlxContext: pointer; dwSasType: DWORD; pReserved: pointer): integer; stdcall;
PWlxDisplayLockedNotice = procedure (pWlxContext: pointer); stdcall;
PWlxWkstaLockedSAS = function (pWlxContext: pointer; dwSasType: DWORD): integer; stdcall;
PWlxIsLockOk = function (pWlxContext: pointer): BOOL; stdcall;
PWlxIsLogoffOk = function (pWlxContext: pointer): BOOL; stdcall;
PWlxLogoff = procedure (pWlxContext: pointer); stdcall;
PWlxShutdown = procedure (pWlxContext: pointer; ShutdownType: DWORD); stdcall;
// Version 1.1
PWlxScreenSaverNotify = function (pWlxContext: pointer; var pSecure: BOOL): BOOL; stdcall;
PWlxStartApplication = function (pWlxContext: pointer; pszDesktopName: PWideChar; pEnvironment: pointer; pszCmdLine: PWideChar): BOOL; stdcall;
// Version 1.3
PWlxNetworkProviderLoad = function (pWlxContext: pointer; var pNprNotifyInfo: WLX_MPR_NOTIFY_INFO): BOOL; stdcall;
PWlxDisplayStatusMessage = function (pWlxContext: pointer; hDesktop: HDESK; dwOptions: DWORD; pTitle: PWideChar; pMessage: PWideChar): BOOL; stdcall;
PWlxGetStatusMessage = function (pWlxContext: pointer; var pdwOptions: DWORD; pMessage: PWideChar; dwBufferSize: DWORD): BOOL; stdcall;
PWlxRemoveStatusMessage = function (pWlxContext: pointer): BOOL; stdcall;
// Version 1.4
PWlxGetConsoleSwitchCredentials = function (pWlxContext: pointer; pCredInfo: pointer): BOOL; stdcall;
PWlxReconnectNotify = procedure (pWlxContext: pointer); stdcall;
PWlxDisconnectNotify = procedure (pWlxContext: pointer); stdcall;
//adsdas
// PWlxUseCtrlAltDel = procedure (hWlx: HANDLE);stdcall;
// PWlxSetOption =function (hWlx: HANDLE; Option: DWORD; Value: ULONG_PTR; var OldValue: ULONG_PTR) : BOOL; stdcall;
implementation
end.