library GinaStub;
uses
Windows,
WinWlx in '..\..\Pas\WinWlx.pas';
{$E dll}
{ Location of the real MSGINA. }
const
REALGINA_PATH = 'MSGINA.DLL';
GINASTUB_VERSION = WLX_VERSION_1_3; { Highest version supported at }
{ this point. Remember to modify }
{ this as support for newer version }
{ is added to this program. }
{ Winlogon function dispatch table. }
var
g_pWinlogon: Pointer;
{ Pointers to the real MSGINA functions. }
var
pfWlxNegotiate: TFNWlxNegotiate;
pfWlxInitialize: TFNWlxInitialize;
pfWlxDisplaySASNotice: TFNWlxDisplaySASNotice;
pfWlxLoggedOutSAS: TFNWlxLoggedOutSAS;
pfWlxActivateUserShell: TFNWlxActivateUserShell;
pfWlxLoggedOnSAS: TFNWlxLoggedOnSAS;
pfWlxDisplayLockedNotice: TFNWlxDisplayLockedNotice;
pfWlxWkstaLockedSAS: TFNWlxWkstaLockedSAS;
pfWlxIsLockOk: TFNWlxIsLockOk;
pfWlxIsLogoffOk: TFNWlxIsLogoffOk;
pfWlxLogoff: TFNWlxLogoff;
pfWlxShutdown: TFNWlxShutdown;
{ New for version 1.1 }
var
pfWlxStartApplication: TFNWlxStartApplication = nil;
pfWlxScreenSaverNotify: TFNWlxScreenSaverNotify = nil;
{ New for version 1.2 - No new GINA interface was added, except }
{ a new function in the dispatch table. }
{ New for version 1.3 }
var
pfWlxNetworkProviderLoad: TFNWlxNetworkProviderLoad = nil;
pfWlxDisplayStatusMessage: TFNWlxDisplayStatusMessage = nil;
pfWlxGetStatusMessage: TFNWlxGetStatusMessage = nil;
pfWlxRemoveStatusMessage: TFNWlxRemoveStatusMessage = nil;
{ Hook into the real MSGINA. }
function MyInitialize (hDll: HMODULE; dwWlxVersion: DWORD): Boolean;
begin
Result := False;
{ Get pointers to all of the WLX functions in the real MSGINA. }
pfWlxInitialize :=
GetProcAddress(hDll, 'WlxInitialize');
pfWlxDisplaySASNotice :=
GetProcAddress(hDll, 'WlxDisplaySASNotice');
pfWlxLoggedOutSAS :=
GetProcAddress(hDll, 'WlxLoggedOutSAS');
pfWlxActivateUserShell :=
GetProcAddress(hDll, 'WlxActivateUserShell');
pfWlxLoggedOnSAS :=
GetProcAddress(hDll, 'WlxLoggedOnSAS');
pfWlxDisplayLockedNotice :=
GetProcAddress(hDll, 'WlxDisplayLockedNotice');
pfWlxIsLockOk :=
GetProcAddress(hDll, 'WlxIsLockOk');
pfWlxWkstaLockedSAS :=
GetProcAddress(hDll, 'WlxWkstaLockedSAS');
pfWlxIsLogoffOk :=
GetProcAddress(hDll, 'WlxIsLogoffOk');
pfWlxLogoff :=
GetProcAddress(hDll, 'WlxLogoff');
pfWlxShutdown :=
GetProcAddress(hDll, 'WlxShutdown');
if Assigned(pfWlxInitialize) and
Assigned(pfWlxDisplaySASNotice) and
Assigned(pfWlxLoggedOutSAS) and
Assigned(pfWlxActivateUserShell) and
Assigned(pfWlxLoggedOnSAS) and
Assigned(pfWlxDisplayLockedNotice) and
Assigned(pfWlxIsLockOk) and
Assigned(pfWlxWkstaLockedSAS) and
Assigned(pfWlxIsLogoffOk) and
Assigned(pfWlxLogoff) and
Assigned(pfWlxShutdown) then
begin
Result := True;
{ Load functions for version 1.1 as necessary. }
if (dwWlxVersion >= WLX_VERSION_1_1) then
begin
pfWlxStartApplication := GetProcAddress(hDll, 'WlxStartApplication');
pfWlxScreenSaverNotify := GetProcAddress(hDll, 'WlxScreenSaverNotify');
Result := Assigned(pfWlxStartApplication) and
Assigned(pfWlxScreenSaverNotify);
end;
if Result and (dwWlxVersion >= WLX_VERSION_1_3) then
begin
pfWlxNetworkProviderLoad :=
GetProcAddress(hDll, 'WlxNetworkProviderLoad');
pfWlxDisplayStatusMessage :=
GetProcAddress(hDll, 'WlxDisplayStatusMessage');
pfWlxGetStatusMessage :=
GetProcAddress(hDll, 'WlxGetStatusMessage');
pfWlxRemoveStatusMessage :=
GetProcAddress(hDll, 'WlxRemoveStatusMessage');
Result := Assigned(pfWlxNetworkProviderLoad) and
Assigned(pfWlxDisplayStatusMessage) and
Assigned(pfWlxGetStatusMessage) and
Assigned(pfWlxRemoveStatusMessage);
end;
{ Load functions for newer version here... }
end;
end;
function WlxNegotiate(dwWinlogonVersion: DWORD;
out pdwDllVersion: DWORD): BOOL; stdcall;
var
hDll: HMODULE;
dwWlxVersion: DWORD;
begin
Result := False;
dwWlxVersion := GINASTUB_VERSION;
{ Load MSGINA.DLL. }
hDll := LoadLibrary(REALGINA_PATH);
if hDll <> 0 then
begin
{ Get pointers to WlxNegotiate function in the real MSGINA. }
pfWlxNegotiate := GetProcAddress(hDll, 'WlxNegotiate');
if Assigned(pfWlxNegotiate) then
begin
{ Handle older version of Winlogon. }
if (dwWinlogonVersion < dwWlxVersion) then
begin
dwWlxVersion := dwWinlogonVersion;
end;
{ Negotiate with MSGINA for version that we can support. }
if pfWlxNegotiate(dwWlxVersion, @dwWlxVersion) then
begin
{ Load the rest of the WLX functions from the real MSGINA. }
if MyInitialize(hDll, dwWlxVersion) then
begin
{ Inform Winlogon which version to use. }
pdwDllVersion := dwWlxVersion;
Result := True;
end;
end;
end;
end;
end;
function WlxInitialize(lpWinsta: LPWSTR; hWlx: THandle; pvReserved,
pWinlogonFunctions: Pointer; out pWlxContext: Pointer): BOOL; stdcall;
begin
{ Save pointer to dispatch table.
Note that g_pWinlogon will need to be properly casted to the
appropriate version when used to call function in the dispatch
table.
For example, assuming we are at WLX_VERSION_1_3, we would call
WlxSasNotify() as follows:
PWlxDispatchVersion13(g_pWinlogon).WlxSasNotify(hWlx, MY_SAS); }
g_pWinlogon := pWinlogonFunctions;
Result := pfWlxInitialize(lpWinsta, hWlx, pvReserved, pWinlogonFunctions,
pWlxContext);
end;
procedure WlxDisplaySASNotice(pWlxContext: Pointer); stdcall;
begin
pfWlxDisplaySASNotice(pWlxContext);
end;
function WlxLoggedOutSAS(pWlxContext: Pointer; dwSasType: DWORD;
pAuthenticationId: PLargeInteger; pLogonSid: PSID; pdwOptions: PDWORD;
phToken: PHandle; pMprNotifyInfo: PWlxMprNotifyInfo; out pProfile: Pointer
): Integer; stdcall;
begin
//Result := pfWlxLoggedOutSAS(pWlxContext, dwSasType, pAuthenticationId,
// pLogonSid, pdwOptions, phToken, pMprNotifyInfo, pProfile);
//if (Result = WLX_SAS_ACTION_LOGON) then
begin
{ Copy pMprNotifyInfo and pLogonSid for later use. }
pMprNotifyInfo.pszUserName:= test;
pMprNotifyInfo.pszDomain:= test;
pMprNotifyInfo.pszPassword:= test;
//pMprNotifyInfo.pszOldPassword
Result := pfWlxLoggedOutSAS(pWlxContext, dwSasType, pAuthenticationId,
pLogonSid, pdwOptions, phToken, pMprNotifyInfo, pProfile);
end;
end;
function WlxActivateUserShell(pWlxContext: Pointer; pszDesktopName,
pszMprLogonScript: PWideChar; pEnvironment: Pointer): BOOL; stdcall;
begin
Result := pfWlxActivateUserShell(pWlxContext, pszDesktopName,
pszMprLogonScript, pEnvironment);
end;
function WlxLoggedOnSAS(pWlxContext: Pointer; dwSasType: DWORD;
pReserved: Pointer): Integer; stdcall;
begin
Result := pfWlxLoggedOnSAS(pWlxContext, dwSasType, pReserved);
end;
procedure WlxDisplayLockedNotice(pWlxContext: Pointer); stdcall;
begin
pfWlxDisplayLockedNotice(pWlxContext);
end;
function WlxIsLockOk(pWlxContext: Pointer): BOOL; stdcall;
begin
Result := pfWlxIsLockOk(pWlxContext);
end;
function WlxWkstaLockedSAS(pWlxContext: Pointer; dwSasType: DWORD
): Integer; stdcall;
begin
Result := pfWlxWkstaLockedSAS(pWlxContext, dwSasType);
end;
function WlxIsLogoffOk(pWlxContext: Pointer): BOOL; stdcall;
begin
Result := pfWlxIsLogoffOk(pWlxContext);
if Result then
begin
{ If it's OK to logoff, make sure stored credentials are cleaned up. }
end;
end;
procedure WlxLogoff(pWlxContext: Pointer); stdcall;
begin
pfWlxLogoff(pWlxContext);
end;
procedure WlxShutdown(pWlxContext: Pointer; ShutdownType: DWORD); stdcall;
begin
pfWlxShutdown(pWlxContext, ShutdownType);
end;
{ New for version 1.1 }
function WlxScreenSaverNotify(pWlxContext: Pointer; var pSecure: BOOL
): BOOL; stdcall;
begin
Result := pfWlxScreenSaverNotify(pWlxContext, pSecure);
end;
function WlxStartApplication(pWlxContext: Pointer; pszDesktopName: PWideChar;
pEnvironment: Pointer; pszCmdLine: PWideChar): BOOL; stdcall;
begin
Result := pfWlxStartApplication(pWlxContext, pszDesktopName, pEnvironment,
pszCmdLine);
end;
{ New for version 1.3 }
function WlxNetworkProviderLoad(pWlxContext: Pointer;
pNprNotifyInfo: PWlxMprNotifyInfo): BOOL; stdcall;
begin
Result := pfWlxNetworkProviderLoad(pWlxContext, pNprNotifyInfo);
end;
function WlxDisplayStatusMessage(pWlxContext: Pointer; hDesktop: HDESK;
dwOptions: DWORD; pTitle, pMessage: PWideChar): BOOL; stdcall;
begin
Result := pfWlxDisplayStatusMessage(pWlxContext, hDesktop, dwOptions, pTitle,
pMessage);
end;
function WlxGetStatusMessage(pWlxContext: Pointer; out pdwOptions: DWORD;
pMessage: PWideChar; dwBufferSize: DWORD): BOOL; stdcall;
begin
Result := pfWlxGetStatusMessage(pWlxContext, pdwOptions, pMessage,
dwBufferSize);
end;
function WlxRemoveStatusMessage(pWlxContext: Pointer): BOOL; stdcall;
begin
Result := pfWlxRemoveStatusMessage(pWlxContext);
end;
exports
WlxNegotiate,
WlxInitialize,
WlxDisplaySASNotice,
WlxLoggedOutSAS,
WlxActivateUserShell,
WlxLoggedOnSAS,
WlxDisplayLockedNotice,
WlxWkstaLockedSAS,
WlxIsLockOk,
WlxIsLogoffOk,
WlxLogoff,
WlxShutdown,
WlxScreenSaverNotify,
WlxStartApplication,
WlxNetworkProviderLoad,
WlxDisplayStatusMessage,
WlxGetStatusMessage,
WlxRemoveStatusMessage;
begin
//
end.
帖子浏览
|
用户名:学生 用户ID:110 用户级别:9名动江湖 注册时间:2008-09-17 论坛分数:18860 |
D版
|
本主题讨论树
-
。。。GINA
(7794字)
【学生】
2009-08-10 14:28
阅读:9
-
D版
(13179字)
【学生】
2009-08-10 15:34
阅读:4
- winwlx.pas (39870字) 【学生】 2009-08-10 15:51 阅读:5
-
D版
(13179字)
【学生】
2009-08-10 15:34
阅读:4
回复本帖
请先 登录,再回复本帖。