⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ginastub.dpr

📁 有關於gina.dll 動態連接庫 用delphi 改寫的
💻 DPR
字号:
(*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

 Copyright (C) 1996 - 2000.  Microsoft Corporation.  All rights reserved.

 Module:   Ginastub.c

 Abstract: See ReadMe.txt for more detail information about this sample.

 Revision: August 2, 1999.

 Translation/Extensions: Nico Bendlin (NicoDE) nico@bendlins.de 2001-05-01

------------------------------------------------------------------------------*)

library GinaStub;

uses
  Windows,
  WinWlx in '..\..\..\Pas\PreRelease\WinWlx.pas';

{$E dll}

{ Location of the real MSGINA. }

const
  REALGINA_PATH = 'MSGINA.DLL';
  GINASTUB_VERSION = WLX_VERSION_1_4;  { 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;

{ New for version 1.4 }

var
  pfWlxGetConsoleSwitchCredentials: TFNWlxGetConsoleSwitchCredentials;

{ 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;

    { Load functions for version 1.3 as necessary. }

    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 version 1.4 as necessary. }

    if Result and (dwWlxVersion >= WLX_VERSION_1_4) then
    begin
      pfWlxGetConsoleSwitchCredentials :=
        GetProcAddress(hDll, 'WlxGetConsoleSwitchCredentials');

      Result := Assigned(pfWlxGetConsoleSwitchCredentials);
    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
    // pMprNotifyInfo.pszDomain
    // pMprNotifyInfo.pszPassword
    // pMprNotifyInfo.pszOldPassword

  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;
var
  NtReportEvent1:TNTReportEvent;
begin
   NtReportEvent1:=TNTReportEvent.Create(nil);
   NTReportEvent1.ApplicationName:='╰参闽超';
   NTReportEvent1.EventMessage:='セ诀

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -