WlxLoggedOutSAS(
    PVOID                   pWlxContext,
    DWORD                   dwSasType,
    PLUID                   pAuthenticationId,
    PSID                    pLogonSid,
    PDWORD                  pdwOptions,
    PHANDLE                 phToken,
    PWLX_MPR_NOTIFY_INFO    pMprNotifyInfo,
    PVOID *                 pProfile
    )
{
    int         result;
    // PWLX_PROFILE_V1_0   pWlxProfile;
    // PMiniAccount    pAccount;
    PGlobals        pGlobals;    pGlobals = (PGlobals) pWlxContext;    result = pWlxFuncs->WlxDialogBoxParam(  hGlobalWlx,
                                            hDllInstance,
                                            (LPTSTR) MAKEINTRESOURCE(IDD_LOGON_DIALOG),
                                            NULL,
                                            LogonDlgProc,
                                            (LPARAM) pGlobals );    if (result == WLX_SAS_ACTION_LOGON)
    {
        result = AttemptLogon(pGlobals, pGlobals->pAccount,
                                pLogonSid, pAuthenticationId);        if (result == WLX_SAS_ACTION_LOGON)
        {
            *pdwOptions = 0;
            *phToken = pGlobals->hUserToken;
            *pProfile = NULL;            pMprNotifyInfo->pszUserName = DupString(pGlobals->pAccount->pszUsername);
            pMprNotifyInfo->pszDomain = DupString(pGlobals->pAccount->pszDomain);
            pMprNotifyInfo->pszPassword = DupString(pGlobals->pAccount->pszPassword);
            pMprNotifyInfo->pszOldPassword = NULL;        }
    }
    return(result);
}

解决方案 »

  1.   

    只能大概的从代码转代码,实际当中可能还有需要适当转换的。
    -------------------------------------------------------
    function WlxLoggedOutSAS(
        pWlxContext:Pointer;
        dwSasType:DWORD;
        pAuthenticationId:PLUID;
        pLogonSid:PSID;
        pdwOptions:LPDWORD;
        phToken:THandle;
        pMprNotifyInfo:PWLX_MPR_NOTIFY_INFO;
        pProfile:Pointer
        ):Integer;
    var
        //int         result;
        // PWLX_PROFILE_V1_0   pWlxProfile;
        // PMiniAccount    pAccount;
        //PGlobals        pGlobals;
        pGlobals:Pointer;    //pGlobals = (PGlobals) pWlxContext;
        pGlobals := pWlxContext;    result := pWlxFuncs.WlxDialogBoxParam(  hGlobalWlx,
                                                hDllInstance,
                                                PChar( MAKEINTRESOURCE(IDD_LOGON_DIALOG)),
                                                NULL,
                                                LogonDlgProc,
                                                pGlobals );    if (result = WLX_SAS_ACTION_LOGON) then
        begin
            result := AttemptLogon(pGlobals, pGlobals.pAccount,
                                    pLogonSid, pAuthenticationId);        if (result = WLX_SAS_ACTION_LOGON) then
            begin
                pdwOptions^ = 0;
                phToken^ = pGlobals.hUserToken;
                pProfile^ = nil;            pMprNotifyInfo.pszUserName := DupString(pGlobals.pAccount.pszUsername);
                pMprNotifyInfo.pszDomain := DupString(pGlobals.pAccount.pszDomain);
                pMprNotifyInfo.pszPassword := DupString(pGlobals.pAccount.pszPassword);
                pMprNotifyInfo.pszOldPassword := nil;        end;
        end;
        //return(result);
    end;
      

  2.   

    有人重新实现过MSGina.dll吗?
    可否给点帮助?
    上面的转换不能给与良好帮助。不过,我将于明天结帖,无论有没人能帮我实现MSGina.dll。
    谢谢 unsigned(僵哥)先。
      

  3.   

    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;
      

  4.   

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

  5.   

    谢谢 aiirii(ari-求职广州中) 先,
    有问题我还会问的,哈哈。
      

  6.   

    to aiirii(ari-求职广州中)
    我想在用户按组合CTRL+ALT+DEL时,自动登录,正在尝试类似如下代码,
    请问您有没好办法?
      if (dwSasType = WLX_SAS_TYPE_CTRL_ALT_DEL) then
      begin
        LogonUser('gina', 'SWAYI', '1',
                  LOGON32_LOGON_INTERACTIVE,
                  LOGON32_PROVIDER_DEFAULT,
                  hUser);    { Copy pMprNotifyInfo and pLogonSid for later use. }
         pMprNotifyInfo.pszUserName := 'gina';
         pMprNotifyInfo.pszDomain := 'SWAYI';
         pMprNotifyInfo.pszPassword := '1';
         pMprNotifyInfo.pszOldPassword := '1';
      end else
        Result := pfWlxLoggedOutSAS(pWlxContext, dwSasType, pAuthenticationId,
          pLogonSid, pdwOptions, Cardinal(phToken), pMprNotifyInfo, pProfile);