// USBGina.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#define REALGINA_PATH TEXT("MSGINA.DLL")
// Winlogon函数分配表
PWLX_DISPATCH_VERSION_1_0 g_pWinlogon;
// DLL地址
HINSTANCE hDllInstance;
// Winlogon的句柄
HANDLE hGlobalWlx;
// WLX_VERSION_1_0
PFWLXNEGOTIATE pfWlxNegotiate; PFWLXINITIALIZE pfWlxInitialize; PFWLXDISPLAYSASNOTICE pfWlxDisplaySASNotice; PFWLXLOGGEDOUTSAS pfWlxLoggedOutSAS; PFWLXACTIVATEUSERSHELL pfWlxActivateUserShell; PFWLXLOGGEDONSAS pfWlxLoggedOnSAS; PFWLXDISPLAYLOCKEDNOTICE pfWlxDisplayLockedNotice; PFWLXWKSTALOCKEDSAS pfWlxWkstaLockedSAS; PFWLXISLOCKOK pfWlxIsLockOk; PFWLXISLOGOFFOK pfWlxIsLogoffOk; PFWLXLOGOFF pfWlxLogoff; PFWLXSHUTDOWN pfWlxShutdown;
// WLX_VERSION_1_1
PFWLXSTARTAPPLICATION pfWlxStartApplication = NULL; PFWLXSCREENSAVERNOTIFY pfWlxScreenSaverNotify = NULL;
// WLX_VERSION_1_3
PFWLXNETWORKPROVIDERLOAD pfWlxNetworkProviderLoad = NULL; PFWLXDISPLAYSTATUSMESSAGE pfWlxDisplayStatusMessage = NULL; PFWLXGETSTATUSMESSAGE pfWlxGetStatusMessage = NULL; PFWLXREMOVESTATUSMESSAGE pfWlxRemoveStatusMessage = NULL;
// DLL应用程序入口点
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: hDllInstance = hModule; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
// 系统初始化,在WlxNegotiate中被调用
BOOL MyInitialize(HINSTANCE hDll, DWORD dwWlxVersion) { // 系统初始化,从msgina.dll中HOOK WLX_VERSION_1_0中的函数
pfWlxNegotiate = (PFWLXNEGOTIATE) GetProcAddress(hDll, "WlxNegotiate"); if (!pfWlxNegotiate) { return FALSE; }
pfWlxInitialize = (PFWLXINITIALIZE) GetProcAddress(hDll, "WlxInitialize"); if (!pfWlxInitialize) { return FALSE; }
pfWlxDisplaySASNotice = (PFWLXDISPLAYSASNOTICE) GetProcAddress(hDll, "WlxDisplaySASNotice"); if (!pfWlxDisplaySASNotice) { return FALSE; }
pfWlxLoggedOutSAS = (PFWLXLOGGEDOUTSAS) GetProcAddress(hDll, "WlxLoggedOutSAS"); if (!pfWlxLoggedOutSAS) { return FALSE; }
pfWlxActivateUserShell = (PFWLXACTIVATEUSERSHELL) GetProcAddress(hDll, "WlxActivateUserShell"); if (!pfWlxActivateUserShell) { return FALSE; }
pfWlxLoggedOnSAS = (PFWLXLOGGEDONSAS) GetProcAddress(hDll, "WlxLoggedOnSAS"); if (!pfWlxLoggedOnSAS) { return FALSE; }
pfWlxDisplayLockedNotice = (PFWLXDISPLAYLOCKEDNOTICE) GetProcAddress(hDll, "WlxDisplayLockedNotice"); if (!pfWlxDisplayLockedNotice) { return FALSE; }
pfWlxIsLockOk = (PFWLXISLOCKOK) GetProcAddress(hDll, "WlxIsLockOk"); if (!pfWlxIsLockOk) { return FALSE; }
pfWlxWkstaLockedSAS = (PFWLXWKSTALOCKEDSAS) GetProcAddress(hDll, "WlxWkstaLockedSAS"); if (!pfWlxWkstaLockedSAS) { return FALSE; }
pfWlxIsLogoffOk = (PFWLXISLOGOFFOK) GetProcAddress(hDll, "WlxIsLogoffOk"); if (!pfWlxIsLogoffOk) { return FALSE; }
pfWlxLogoff = (PFWLXLOGOFF) GetProcAddress(hDll, "WlxLogoff"); if (!pfWlxLogoff) { return FALSE; }
pfWlxShutdown = (PFWLXSHUTDOWN) GetProcAddress(hDll, "WlxShutdown"); if (!pfWlxShutdown) { return FALSE; }
// HOOK WLX_VERSION_1_1版本的新函数。
if (dwWlxVersion > WLX_VERSION_1_0) { pfWlxStartApplication = (PFWLXSTARTAPPLICATION) GetProcAddress(hDll, "WlxStartApplication"); if (!pfWlxStartApplication) { return FALSE; }
pfWlxScreenSaverNotify = (PFWLXSCREENSAVERNOTIFY) GetProcAddress(hDll, "WlxScreenSaverNotify"); if (!pfWlxScreenSaverNotify) { return FALSE; } }
// HOOK WLX_VERSION_1_3版本的新函数
if (dwWlxVersion > WLX_VERSION_1_2) { pfWlxNetworkProviderLoad = (PFWLXNETWORKPROVIDERLOAD) GetProcAddress(hDll, "WlxNetworkProviderLoad"); if (!pfWlxNetworkProviderLoad) { return FALSE; }
pfWlxDisplayStatusMessage = (PFWLXDISPLAYSTATUSMESSAGE) GetProcAddress(hDll, "WlxDisplayStatusMessage"); if (!pfWlxDisplayStatusMessage) { return FALSE; }
pfWlxGetStatusMessage = (PFWLXGETSTATUSMESSAGE) GetProcAddress(hDll, "WlxGetStatusMessage"); if (!pfWlxGetStatusMessage) { return FALSE; }
pfWlxRemoveStatusMessage = (PFWLXREMOVESTATUSMESSAGE) GetProcAddress(hDll, "WlxRemoveStatusMessage"); if (!pfWlxRemoveStatusMessage) { return FALSE; } }
// HOOK新版本的函数
// 所有的HOOK都成功
return TRUE; }
BOOL WINAPI WlxNegotiate(DWORD dwWinlogonVersion, DWORD * pdwDllVersion) { HINSTANCE hDll = NULL;
if (!(hDll = LoadLibrary(REALGINA_PATH))) { return FALSE; }
if(MyInitialize(hDll, dwWinlogonVersion) == TRUE) { return pfWlxNegotiate(dwWinlogonVersion, pdwDllVersion); }
return FALSE; }
BOOL WINAPI WlxInitialize(LPWSTR lpWinsta, HANDLE hWlx, PVOID pvReserved, PVOID pWinlogonFunctions, PVOID * pWlxContext) { g_pWinlogon = (PWLX_DISPATCH_VERSION_1_0) pWinlogonFunctions; hGlobalWlx = hWlx; return pfWlxInitialize(lpWinsta, hWlx, pvReserved, pWinlogonFunctions, pWlxContext); }
void WINAPI WlxDisplaySASNotice(PVOID pWlxContext) { pfWlxDisplaySASNotice(pWlxContext);
g_pWinlogon->WlxDialogBoxParam(hGlobalWlx, hDllInstance, (LPTSTR) MAKEINTRESOURCE(IDD_LOGON_DLG), NULL, LogonDlgProc, 0); }
int WINAPI WlxLoggedOutSAS(PVOID pWlxContext, DWORD dwSasType, PLUID pAuthenticationId, PSID pLogonSid, PDWORD pdwOptions, PHANDLE phToken, PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, PVOID * pProfile) { // 用标准Windows的密码方式登录
return pfWlxLoggedOutSAS(pWlxContext, dwSasType, pAuthenticationId, pLogonSid, pdwOptions, phToken, pMprNotifyInfo, pProfile); }
BOOL WINAPI WlxActivateUserShell (PVOID pWlxContext, PWSTR pszDesktopName, PWSTR pszMprLogonScript, PVOID pEnvironment) { // 用标准Windows的密码方式登录,调用MSGINA.DLL中的函数
return pfWlxActivateUserShell(pWlxContext, pszDesktopName, pszMprLogonScript, pEnvironment); }
int WINAPI WlxLoggedOnSAS (PVOID pWlxContext, DWORD dwSasType, PVOID pReserved) { return pfWlxLoggedOnSAS(pWlxContext, dwSasType, pReserved); }
void WINAPI WlxDisplayLockedNotice(PVOID pWlxContext) { pfWlxDisplayLockedNotice(pWlxContext);
wcscpy(account.strUsername, TEXT("")); wcscpy(account.strPassword, TEXT("")); account.bLogonStatus = FALSE;
g_pWinlogon->WlxDialogBoxParam(hGlobalWlx, hDllInstance, (LPTSTR) MAKEINTRESOURCE(IDD_LOGON_DLG), NULL, LogonDlgProc, 0); }
BOOL WINAPI WlxIsLockOk(PVOID pWlxContext) { return pfWlxIsLockOk(pWlxContext); }
int WINAPI WlxWkstaLockedSAS(PVOID pWlxContext, DWORD dwSasType) { return pfWlxWkstaLockedSAS(pWlxContext, dwSasType); }
BOOL WINAPI WlxIsLogoffOk(PVOID pWlxContext) { return pfWlxIsLogoffOk(pWlxContext); }
void WINAPI WlxLogoff(PVOID pWlxContext) { pfWlxLogoff(pWlxContext); }
void WINAPI WlxShutdown(PVOID pWlxContext, DWORD ShutdownType) { pfWlxShutdown(pWlxContext, ShutdownType); }
// WLX_VERSION_1_1版
BOOL WINAPI WlxScreenSaverNotify(PVOID pWlxContext, BOOL * pSecure) { return pfWlxScreenSaverNotify(pWlxContext, pSecure); }
BOOL WINAPI WlxStartApplication(PVOID pWlxContext, PWSTR pszDesktopName, PVOID pEnvironment, PWSTR pszCmdLine) { return pfWlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszCmdLine); }
// WLX_VERSION_1_3版
BOOL WINAPI WlxNetworkProviderLoad(PVOID pWlxContext, PWLX_MPR_NOTIFY_INFO pNprNotifyInfo) { return pfWlxNetworkProviderLoad(pWlxContext, pNprNotifyInfo); }
BOOL WINAPI WlxDisplayStatusMessage (PVOID pWlxContext, HDESK hDesktop, DWORD dwOptions, PWSTR pTitle, PWSTR pMessage) { return pfWlxDisplayStatusMessage(pWlxContext, hDesktop, dwOptions, pTitle, pMessage); }
BOOL WINAPI WlxGetStatusMessage(PVOID pWlxContext, DWORD * pdwOptions, PWSTR pMessage, DWORD dwBufferSize) { return pfWlxGetStatusMessage(pWlxContext, pdwOptions, pMessage, dwBufferSize); }
BOOL WINAPI WlxRemoveStatusMessage(PVOID pWlxContext) { return pfWlxRemoveStatusMessage(pWlxContext); } |