sraab2004
asked on
disable ctrl+alt+del
Iwant delphi code to disable ctrl+alt+del and alt+F4 and any method used to close running programms for all windows(include win 2000) .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi .... to disable Ctrl_Alt_Del isn't possible (on WinNT based systems) unless you replace the Windows GINA. Take a look at http://geocities.yahoo.com.br/armlessjohn/Hidden_Resources.html, there is a couple of good source codes to help you to program this ...
it is possible, knightmad, check my link above ;-)
DragonSlayer: I did checked it : ) Last year, I wrote a couple of sources related to this subject (disabling Alt+Tab, Win Keys, Ctrl+Esc and so forth) and, except for Ctrl+Alt+del thing, the code I wrote was borrowed from that site you posted the link : ) , all I did was to convert the source from C++ to Delphi. And, although you can detect Ctrl+Alt+Del using a LowLevel keyboard hook, you cannot avoid that the Task Manager being shown, unless you turn on that registry key, having that annoying message ; )
So, I borrowed (again) some code from Jedi's site and adapted it to really disable the Ctrl+Alt+Del thing, having no message (well, it still have an annoting flickering, but it is acceptable)
Both source code and binaries are avaliable in that link I posted, because this is one of the most Frequent Asked Questions here in EE : ) We both were in a question like this months ago, and we answered exactly the same things there lol
sraab2004: take a look at these links, they are PAQ annd may help : )
https://www.experts-exchange.com/questions/20728852/Disable-Alt-Tab.html
https://www.experts-exchange.com/questions/20598492/Keyboard-hook-or-MSGina-dll.html
So, I borrowed (again) some code from Jedi's site and adapted it to really disable the Ctrl+Alt+Del thing, having no message (well, it still have an annoting flickering, but it is acceptable)
Both source code and binaries are avaliable in that link I posted, because this is one of the most Frequent Asked Questions here in EE : ) We both were in a question like this months ago, and we answered exactly the same things there lol
sraab2004: take a look at these links, they are PAQ annd may help : )
https://www.experts-exchange.com/questions/20728852/Disable-Alt-Tab.html
https://www.experts-exchange.com/questions/20598492/Keyboard-hook-or-MSGina-dll.html
yup... deja vu all the time ;-)
wonder why some of the people who post questions never do a search first? Hmm...
wonder why some of the people who post questions never do a search first? Hmm...
/************************* ********** ********** ********** *******/
// Filename: Main.c
// Author : sima huapeng
// Time : 2002-10-13
// GINA : Graphical Identification and Authentication
// SAS : Secure Attention Sequence
/************************* ********** ********** ********** *******/
//10/13
// 实现自&# 23450; 041;gina&# 25509; 475;ᦁ 2;设 计&# 19982;winl ogon.exe&# 30340; 132;ߛ 4;
// 开发原&# 29702;A 306;߶ 1;赖 Microsoft& #40664; 5748;į 40;gina dll:msgina.dll, 312;ੑ 2;dllÈ 13;
// 导入msgina.dll 导&# 20986; 340;৶ 9;口 ,&# 22312; 412;dll 0340;ë 48;出 ;接& #21475; 0013;ʌ 92;保 ;持& #22823; 7096;Ñ 98;接 ;
// 口与msgina.dll 操&# 20316; 340;ߌ 8;致 性&# 65292; 913;ࡢ 4;WlxLogge dOnSAS 509;ࡣ 5;的 响&# 24212;A 292;߳ 1;
// 系统在&# 30331;& 470;ৎ 4;功 的&# 29366; 577;ߍ 9;, 根&# 25454;# 774;ಾ 2;, 去&# 23450; 159;ࡪ 2;响 应Ct rl+Alt+Del .
// 在启动&# 21518;A 292;১ 3;CTRL_ALT _DEL,Ŀ 95;统 ;会& #35843; 9992;WlxLo ggedOnSAS& #65281;
// 将这个DL L拷& #21040;sys tem32İ 46;录 ;下& #65292; 4182;ß 12;注 ;册& #34920; 0013;Ó 52;入 ;:
// \HKEY_LOCAL_MACHINE\Softwa re\Microso ft\Windows NT\CurrentVersion\Winlogon
// 加一个Gi naDLL, 867;ࣁ 1;RegSZ, 内容为&# 20320; 340;dll 1517;ʌ 92;如 ;:'myGina. dll'.
// 重起机&# 22120;A 292;౿ 5;统 就&# 20250; 351;ஷ 2;你 的dl l,GINA 487;ߣ 7;实 现&# 24456; 810;ߏ 6;西 ,&# 20540; 471;ం 0;究 !
// 按下CTRL+ALT+D EL屏 幕&# 20250;& 378;ߌ 8;下 ,&# 37027; 159;ࢰ 0;为 屏&# 24149; 174;Winsta 0转& #21040;Des ktop!
// 必须要&# 29992;unic ode,ࣳ 4;果 改&# 20102; 518;࡫ 1;动 不&# 20102;A 292;෿ 1;将 msgina.dll 拷&# 36125; 104;߰ 0;的 dll,ࠧ 7;启 动&# 65281;
//10/15
// 为了保&# 25252; 412;Gina&# 65292; 412;ఴ 3;序 在&# 36864; 986;ਲ 2;, 应&# 26816; 979;૤ 0;册 表
//10/16
// 暂时使&# 29992; 880;ࠧ 6;表 通&# 20449;
#define UNICODE
#include <windows.h>
#include <Winwlx.h>
#include <dbt.h>
#include "main.h"
#include "resource.h"
#define _DEBUG //是否记 录&# 26085; 535;
#define ID_TIMER 32767
HINSTANCE myHandle = NULL;
HANDLE hGlobalWlx = NULL;
HANDLE hf = NULL;
PVOID g_pWinlogon = NULL;
void WriteInfo(const char * buf); //日志纪 录
void LockWS(void); //锁定系 统
BOOL SetRegFlag(void); //加入注 册&# 34920;
BOOL GetUsbFlag(void); //读取USBĘ 40;息 ;,如 果&# 25104; 151;࠵ 7;将 消&# 24687; 797;߮ 1;
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 向外输&# 20986; 085;ক 5;信 息
void WriteInfo(const char * buf)
{
#ifdef _DEBUG
DWORD dwRt;
int i = 0;
if (hf != INVALID_HANDLE_VALUE){
while (TRUE){
if (!buf[i])
break;
else
i++;
}
i++;
WriteFile(hf, buf, i, &dwRt, NULL);
}
#endif
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 锁定系&# 32479;
void LockWS(void)
{
HINSTANCE hlib = LoadLibrary(L"user32.dll") ;
if( hlib != NULL ) {
typedef BOOL (*LWS)(VOID);
LWS fnLockWorkStation = (LWS) GetProcAddress(hlib,"LockW orkStation ");
if( fnLockWorkStation != NULL ) fnLockWorkStation();
FreeLibrary(hlib);
}
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 读取标&# 24535; 301;
BOOL GetUsbFlag(void)
{
HKEY hKey = NULL;
DWORD mSubKey;
DWORD mType = REG_DWORD;
DWORD dwLen = sizeof(DWORD)+4;
DWORD mRegValue;
BOOL bRet = FALSE;
if ( RegCreateKeyEx( HKEY_LOCAL_MACHINE,
L"Software\\Lanseal\\PAK",
0, L"", 0, KEY_ALL_ACCESS, NULL,
&hKey, &mRegValue ) == ERROR_SUCCESS )
{
if ( RegQueryValueEx( hKey, L"FLAG",
NULL, &mType,
(LPBYTE)&mSubKey, &dwLen) == ERROR_SUCCESS )
{
if (mSubKey > 0)
{
mRegValue = 0;
if (RegSetValueEx(hKey, L"FLAG",
0L, REG_DWORD,
(LPBYTE)&mRegValue, sizeof(DWORD) ) == ERROR_SUCCESS)
bRet = TRUE;
}
}
}
RegCloseKey(hKey);
return bRet;
};
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 加入注&# 20876;" 920;
BOOL SetRegFlag(void)
{
HKEY hKey = NULL;
UCHAR szBuf[80];
BOOL bRet = TRUE;
if (RegCreateKey(HKEY_LOCAL_M ACHINE,
TEXT("\\Software\\Microsof t\\Windows NT\\CurrentVersion\\Winlog on"), &hKey))
{
bRet=FALSE;
};
strcpy(szBuf, "%SystemRoot%\\System32\\l sGina.dll" );
if (RegSetValueEx(hKey, // subkey handle
TEXT("ginadll"), // value name
0, // must be zero
REG_EXPAND_SZ, // value type
(LPBYTE) szBuf, // pointer to value data
strlen(szBuf) + 1)) // length of value data
{
bRet=FALSE;
}
RegCloseKey(hKey);
return bRet;
};
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 主函数&# 30340; 837;ࡣ 5;
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
)
{
switch (fdwReason){
case DLL_PROCESS_ATTACH:
hf = CreateFile(L"c:\\gina.txt" , GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE _WRITE, NULL, CREATE_ALWAYS, 0, NULL);
WriteInfo("start 1.3 \r\n"); // 显示加&# 36733; 340;୭ 6;本
myHandle = hinstDLL;
if (LoadMsGina()){
WriteInfo("Init gina ok \r\n");
}
else
WriteInfo("Init gina false \r\n");
break;
case DLL_PROCESS_DETACH:
ReleaseMsGina();
WriteInfo("release gina ok \r\n");
if (hf != INVALID_HANDLE_VALUE){
CloseHandle(hf);
}
break;
}
return TRUE;
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 用户登&# 38470; 104;ࡃ 1;后 ,Wi nlogon.exe 调&# 29992;# 813;࠲ 9;数 启&# 21160; 992;৒ 3;外 壳&# 31243; 207;
BOOL WINAPI WlxActivateUserShell (
PVOID pWlxContext,
PWSTR pszDesktopName,
PWSTR pszMprLogonScript,
PVOID pEnvironment)
{
WriteInfo("WlxActivateUser Shell \r\n");
LockWS(); // 登陆成&# 21151; 518;ᦁ 2;开 始&# 39564;# 777;ไ 3;份
return prcWlxActivateUserShell (
pWlxContext,
pszDesktopName,
pszMprLogonScript,
pEnvironment);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 当没有&# 20219; 309;ஷ 2;户 登&# 38470; 102;ᦁ 2;Winlogon .exe฀ 3;用 该&# 20989; 968;ਹ 4;示 一&# 20123; 552;ట 4;信 息
// 可以根&# 25454; 992;৒ 3;的 动&# 20316; 169;ৣ 1;SASÉ 07;件 ;的& #21457; 6865;
VOID WINAPI WlxDisplaySASNotice (
PVOID pWlxContext)
{
prcWlxDisplaySASNotice(pWl xContext);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 初始化&# 65292;winl ogon.exe&# 21521;gina dll传递需 ;要& #29256; 6412;į 40;接 ;口& #20989; 5968;Ñ 98;配 ;表
BOOL WINAPI WlxInitialize (
LPWSTR lpWinsta,
HANDLE hWlx,
PVOID pvReserved,
PVOID pWinlogonFunctions,
PVOID * pWlxContext)
{
hGlobalWlx = hWlx;
g_pWinlogon = pWinlogonFunctions;
return prcWlxInitialize (
lpWinsta,
hWlx,
pvReserved,
pWinlogonFunctions,
pWlxContext);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 当系统&# 22788; 110;௙ 1;陆 成&# 21151;A 292;૜ 9;有 锁&# 23450; 340;୸ 6;态 下
// Winlogon接收&# 21040;SAS& #20107; 0214;ʌ 92;于 ;是& #35843; 9992;Ŧ 13;函 ;数
// 现根据&# 35774;  622;ऻ 1;蔽 所&# 26377; 107;ߥ 4;, 直&# 25509;$ 820;ࢯ 8;
int WINAPI WlxLoggedOnSAS (
PVOID pWlxContext,
DWORD dwSasType,
PVOID pReserved)
{
HANDLE hMutex;
WriteInfo("WlxLoggedOnSAS \r\n");
//屏蔽CTRL_ALT _DEL,È 63;可 ;以& #26681; 5454;ĥ 05;定 ;条& #20214; 6469;Ñ 15;定 ;是& #21542; 5201;ì 31;蔽 ;
if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL ||
dwSasType == WLX_SAS_TYPE_USER_LOGOFF ||
dwSasType == WLX_SAS_TYPE_SCRNSVR_TIMEO UT ||
dwSasType == WLX_SAS_TYPE_TIMEOUT ||
dwSasType == WLX_SAS_TYPE_SWITCHUSER)
{
//我采用 了Mu tex来 ;控& #21046; 6159;× 42;屏 ;蔽& #65292; 5288;Ė 80;意 ;:要 用un icode)
hMutex = OpenMutex(MUTEX_ALL_ACCESS , FALSE, L"LANSEAL_CTRL_ALT_DEL");
if (hMutex)
{
CloseHandle(hMutex);
WriteInfo("disble CTRL+ALT+DEL \r\n");
return WLX_SAS_ACTION_NONE; //返回就 是&# 36864; 986;
}
else
WriteInfo("not disble CTRL+ALT+DEL \r\n");
}
return prcWlxLoggedOnSAS (
pWlxContext,
dwSasType,
pReserved);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在没有&# 20219; 309;ߌ 8;个 用&# 25143; 331;༇ 0;的 情&# 20917; 979;ᦁ 2;Winlogon .exe৶ 9;收 到SA S事& #20214; 5843;ī 92;该 ;函& #25968;
int WINAPI WlxLoggedOutSAS (
PVOID pWlxContext,
DWORD dwSasType,
PLUID pAuthenticationId,
PSID pLogonSid,
PDWORD pdwOptions,
PHANDLE phToken,
PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
PVOID * pProfile)
{
WriteInfo("WlxLoggedOutSAS \r\n");
return prcWlxLoggedOutSAS (
pWlxContext,
dwSasType,
pAuthenticationId,
pLogonSid,
pdwOptions,
phToken,
pMprNotifyInfo,
pProfile);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// Winlogon.exe调ஷ 2;该 函&# 25968;A 292;๩ 0;知 gina dll用户注 ;销& #25805; 0316;
// 允许gina dll做出相 ;应& #30340; 2788;ĩ 02;
VOID WINAPI WlxLogoff (PVOID pWlxContext)
{
WriteInfo("WlxLogoff \r\n");
prcWlxLogoff(pWlxContext);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// Winlogon.exe调ஷ 2;的 gina dll中的第 ;一& #20010; 0989;ă 68;
// 使gina dll确认是 ;否& #25903; 5345;ô 03;前 ;版& #26412; 0340;Winlo gon.exe
// 传递给wi nlogon.exe 需&# 35201;% 027;ߑ 0;版 本&# 30340; 509;ࡣ 5;函 数
BOOL WINAPI WlxNegotiate (
DWORD dwWinlogonVersion,
PDWORD pdwDllVersion)
{
WriteInfo("WlxNegotiate \r\n");
return prcWlxNegotiate (
dwWinlogonVersion,
pdwDllVersion);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在屏保&# 31243; 207;࡫ 1;动 前&# 19968; 636;Winlog on.exe# 843;ஷ 2;该 函&# 25968;A 292;ࠠ 1;许 gina dll同屏保 ;程& #24207; 0132;É 14;
// 返回FALSEŝ 20;示 ;屏& #20445; 1243;ò 07;不 ;能& #21551; 1160;
BOOL WINAPI WlxScreenSaverNotify (
PVOID pWlxContext,
BOOL *pSecure)
{
WriteInfo("WlxScreenSaverN otify \r\n");
return prcWlxScreenSaverNotify (
pWlxContext,
pSecure);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在系统&# 20851;& 381;ߔ 3;前 ,Wi nlogon.exe 调&# 29992;# 813;࠲ 9;数
// 允许gina dll处理一 ;些& #31995; 2479;Ð 51;闭 ;前& #30340; 2788;ĩ 02;
VOID WINAPI WlxShutdown(
PVOID pWlxContext,
DWORD ShutdownType)
{
WriteInfo("WlxShutdown \r\n");
SetRegFlag(); // 我们在&# 20851;& 381;࠺ 9;注 册&# 33258; 049;ᦁ 2;这 是&# 19968; 181;߼ 5;护 策&# 30053;
prcWlxShutdown(pWlxContext , ShutdownType);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 当系统&# 35201; 714;ࢷ 2;用 户&# 19978; 979;ਧ 1;中 启&# 21160; 243;ॴ 7;, Winlogon.e xe调 用&# 35813; 989;ਤ 8;
// 这种情&# 20917; 457;ஶ 3;在 :&# 27983;# 272;ࢤ 0;非 正&# 24120; 851;໾ 1;需 要&# 37325; 551;৏ 0;需 要&# 21551; 160;ৗ 3;展 的&# 20219; 153;౜ 9;理 器
// 该接口gi na dll可以选 ;择& #24615; 3454;Ĩ 16;
BOOL WINAPI WlxStartApplication (
PVOID pWlxContext,
PWSTR pszDesktopName,
PVOID pEnvironment,
PWSTR pszCmdLine)
{
WriteInfo("WlxStartApplica tion \r\n");
return prcWlxStartApplication (
pWlxContext,
pszDesktopName,
pEnvironment,
pszCmdLine);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在锁定&# 29366; 577;ߍ 9;, Winlogon.e xe接 收&# 21040;SAS& #20107; 0214;Ŧ 43;用 ;该& #20989; 5968;
// 在这里&# 36820; 238;ਰ 0;效 信&# 24687;A 292;࠵ 7;可 以&# 23631;" 109;໦ 5;定 状&# 24577; 979;௚ 0;消 息
int WINAPI WlxWkstaLockedSAS (
PVOID pWlxContext,
DWORD dwSasType
)
{
WriteInfo("WlxWkstaLockedS AS \r\n");
return prcWlxWkstaLockedSAS (
pWlxContext,
dwSasType
);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 加入日&# 26399;A 306;10 376;13 085;ߍ 9;午 18:28
// 修改日&# 26399;A 306;10 376;14 085;ߍ 8;午 10:05
int CALLBACK LockedOffDlgProc(
HWND hDlg,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
RECT rcDlg;
int cx, cy;
switch (Message){
case WM_INITDIALOG: //窗口的 初&# 22987; 270;
WriteInfo("WM_INITDIALOG \r\n");
GetWindowRect(hDlg, &rcDlg); //得到窗 口&# 21306; 495;
cx = GetSystemMetrics(SM_CXSCRE EN); //得到屏 幕&# 23485; 230;
cy = GetSystemMetrics(SM_CYSCRE EN); //得到屏 幕&# 39640; 230;
cx = (cx-(rcDlg.right-rcDlg.lef t)) / 2; //计算居 中&# 20301;  622;
cy = (cy-(rcDlg.bottom-rcDlg.to p)) / 2;
SetWindowPos(hDlg, //设置窗 口&# 23621; 013;
HWND_TOP,
cx, cy, //窗口的 位&# 32622; 352;੧ 1;
0, 0, // ignores size arguments
SWP_NOSIZE);
SetTimer(hDlg, // handle to main window
ID_TIMER, // timer identifier
1000, // five-minute interval
(TIMERPROC) NULL); // no timer callback
return( TRUE );
break;
case WM_TIMER:
if (GetUsbFlag())
{
WriteInfo("WM_GET_USB_TRUE \r\n");
KillTimer(hDlg, ID_TIMER);
EndDialog(hDlg, WLX_SAS_ACTION_LOCK_WKSTA) ;
return( TRUE );
}
}
return( FALSE );
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 修改日&# 26399;A 306;10 376;13 085;ߍ 9;午 17:58
// 当系统&# 22788; 110;໦ 5;定 状&# 24577; 102;ᦁ 2;Winlogon .exe฀ 3;用 该&# 20989; 968;
// 显示一&# 20123; 449;ত 7;, 如&# 38145; 450;್ 3;、 锁&# 23450; 102;໾ 8;等
VOID WINAPI WlxDisplayLockedNotice(PVO ID pWlxContext)
{
int hDlgRet;
hDlgRet = ((PWLX_DISPATCH_VERSION_1_ 3) g_pWinlogon)->
WlxDialogBoxParam(hGlobalW lx, myHandle,(unsigned short *)
MAKEINTRESOURCE(IDD_DIALOG MAIN),NULL ,LockedOff DlgProc,0) ;
if (hDlgRet==-1)
{
prcWlxDisplayLockedNotice( pWlxContex t);
}
WriteInfo("WlxDisplayLocke dNotice \r\n");
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 当gina dll要显示 ;一& #20123; 0449;ö 87;时 ;,W inlogon.ex e调& #29992; 5813;Ñ 89;数 ;
// 直接返&# 22238;TRUE 表&# 31034; 449;ত 7;已 经&# 26174; 034;
BOOL WINAPI WlxDisplayStatusMessage(
PVOID pWlxContext,
HDESK hDesktop,
DWORD dwOptions,
PWSTR pTitle,
PWSTR pMessage
)
{
return prcWlxDisplayStatusMessage (
pWlxContext,
hDesktop,
dwOptions,
pTitle,
pMessage);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// Winlogon.exe调ஷ 2;该 函&# 25968; 471;࠸ 0;gina dll显示的 ;状& #24577; 0449;ö 87;
// 直接返&# 22238;TRUE 表&# 31034; 449;ত 7;已 经&# 25509; 910;
BOOL WINAPI WlxGetStatusMessage(
PVOID pWlxContext,
DWORD *pdwOptions,
PWSTR pMessage,
DWORD dwBufferSize
)
{
WriteInfo("WlxGetStatusMes sage \r\n");
return prcWlxGetStatusMessage(
pWlxContext,
pdwOptions,
pMessage,
dwBufferSize
);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在试图&# 38145; 450;ॣ 7;作 站&# 20043; 069;Winlog on.exe# 843;ஷ 2;该 函&# 25968;A 292;࠶ 8;断 是&# 21542; 487;ߣ 7;锁 定
// 直接返&# 22238;FALS E表& #31034; 9981;Ŋ 21;锁 ;定
BOOL WINAPI WlxIsLockOk(PVOID pWlxContext)
{
return prcWlxIsLockOk(pWlxContext );
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// 在试图&# 27880;& 144;ਲ 2;Winlogon .exe฀ 3;用 该&# 20989; 968;ᦁ 2;判 断&# 33021; 542;૤ 0;销
// 直接返&# 22238;FALS E表& #31034; 9981;Ŋ 21;注 ;销
BOOL WINAPI WlxIsLogoffOk(
PVOID pWlxContext
)
{
WriteInfo("WlxIsLogoffOk \r\n");
return prcWlxIsLogoffOk(
pWlxContext
);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// Winlogon.exe调ஷ 2;该 函&# 25968; 910;༓ 8;有 效&# 30340;# 748;෹ 7;信 息
// 返回TRUEඤ 0;示 用&# 25143;" 987;෺ 2;别
BOOL WINAPI WlxNetworkProviderLoad(
PVOID pWlxContext,
PWLX_MPR_NOTIFY_INFO pNprNotifyInfo
)
{
WriteInfo("WlxNetworkProvi derLoad \r\n");
return prcWlxNetworkProviderLoad(
pWlxContext,
pNprNotifyInfo
);
}
//------------------------ ---------- ---------- ---------- ---------- ---------- ---------- -------
// Winlogon.exe调ஷ 2;该 函&# 25968;A 292;࡭ 8;诉 gina dll停止显 ;示& #29366; 4577;Ì 49;息 ;
// 直接返&# 22238;TRUE 表&# 31034; 449;ত 7;已 经&# 21024;& 500;
BOOL WINAPI WlxRemoveStatusMessage(
PVOID pWlxContext
)
{
WriteInfo("WlxRemoveStatus Message \r\n");
return prcWlxRemoveStatusMessage(
pWlxContext
);
}
// Filename: Main.c
// Author : sima huapeng
// Time : 2002-10-13
// GINA : Graphical Identification and Authentication
// SAS : Secure Attention Sequence
/*************************
//10/13
// 实现自&#
// 开发原&#
// 导入msgina.dll
// 口与msgina.dll
// 系统在&#
// 在启动&#
// 将这个DL
// \HKEY_LOCAL_MACHINE\Softwa
// 加一个Gi
// 重起机&#
// 按下CTRL+ALT+D
// 必须要&#
//10/15
// 为了保&#
//10/16
// 暂时使&#
#define UNICODE
#include <windows.h>
#include <Winwlx.h>
#include <dbt.h>
#include "main.h"
#include "resource.h"
#define _DEBUG //是否记
#define ID_TIMER 32767
HINSTANCE myHandle = NULL;
HANDLE hGlobalWlx = NULL;
HANDLE hf = NULL;
PVOID g_pWinlogon = NULL;
void WriteInfo(const char * buf); //日志纪
void LockWS(void); //锁定系
BOOL SetRegFlag(void); //加入注
BOOL GetUsbFlag(void); //读取USBĘ
//------------------------
// 向外输&#
void WriteInfo(const char * buf)
{
#ifdef _DEBUG
DWORD dwRt;
int i = 0;
if (hf != INVALID_HANDLE_VALUE){
while (TRUE){
if (!buf[i])
break;
else
i++;
}
i++;
WriteFile(hf, buf, i, &dwRt, NULL);
}
#endif
}
//------------------------
// 锁定系&#
void LockWS(void)
{
HINSTANCE hlib = LoadLibrary(L"user32.dll")
if( hlib != NULL ) {
typedef BOOL (*LWS)(VOID);
LWS fnLockWorkStation = (LWS) GetProcAddress(hlib,"LockW
if( fnLockWorkStation != NULL ) fnLockWorkStation();
FreeLibrary(hlib);
}
}
//------------------------
// 读取标&#
BOOL GetUsbFlag(void)
{
HKEY hKey = NULL;
DWORD mSubKey;
DWORD mType = REG_DWORD;
DWORD dwLen = sizeof(DWORD)+4;
DWORD mRegValue;
BOOL bRet = FALSE;
if ( RegCreateKeyEx( HKEY_LOCAL_MACHINE,
L"Software\\Lanseal\\PAK",
0, L"", 0, KEY_ALL_ACCESS, NULL,
&hKey, &mRegValue ) == ERROR_SUCCESS )
{
if ( RegQueryValueEx( hKey, L"FLAG",
NULL, &mType,
(LPBYTE)&mSubKey, &dwLen) == ERROR_SUCCESS )
{
if (mSubKey > 0)
{
mRegValue = 0;
if (RegSetValueEx(hKey, L"FLAG",
0L, REG_DWORD,
(LPBYTE)&mRegValue, sizeof(DWORD) ) == ERROR_SUCCESS)
bRet = TRUE;
}
}
}
RegCloseKey(hKey);
return bRet;
};
//------------------------
// 加入注&#
BOOL SetRegFlag(void)
{
HKEY hKey = NULL;
UCHAR szBuf[80];
BOOL bRet = TRUE;
if (RegCreateKey(HKEY_LOCAL_M
TEXT("\\Software\\Microsof
{
bRet=FALSE;
};
strcpy(szBuf, "%SystemRoot%\\System32\\l
if (RegSetValueEx(hKey, // subkey handle
TEXT("ginadll"), // value name
0, // must be zero
REG_EXPAND_SZ, // value type
(LPBYTE) szBuf, // pointer to value data
strlen(szBuf) + 1)) // length of value data
{
bRet=FALSE;
}
RegCloseKey(hKey);
return bRet;
};
//------------------------
// 主函数&#
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
)
{
switch (fdwReason){
case DLL_PROCESS_ATTACH:
hf = CreateFile(L"c:\\gina.txt"
WriteInfo("start 1.3 \r\n"); // 显示加&#
myHandle = hinstDLL;
if (LoadMsGina()){
WriteInfo("Init gina ok \r\n");
}
else
WriteInfo("Init gina false \r\n");
break;
case DLL_PROCESS_DETACH:
ReleaseMsGina();
WriteInfo("release gina ok \r\n");
if (hf != INVALID_HANDLE_VALUE){
CloseHandle(hf);
}
break;
}
return TRUE;
}
//------------------------
// 用户登&#
BOOL WINAPI WlxActivateUserShell (
PVOID pWlxContext,
PWSTR pszDesktopName,
PWSTR pszMprLogonScript,
PVOID pEnvironment)
{
WriteInfo("WlxActivateUser
LockWS(); // 登陆成&#
return prcWlxActivateUserShell (
pWlxContext,
pszDesktopName,
pszMprLogonScript,
pEnvironment);
}
//------------------------
// 当没有&#
// 可以根&#
VOID WINAPI WlxDisplaySASNotice (
PVOID pWlxContext)
{
prcWlxDisplaySASNotice(pWl
}
//------------------------
// 初始化&#
BOOL WINAPI WlxInitialize (
LPWSTR lpWinsta,
HANDLE hWlx,
PVOID pvReserved,
PVOID pWinlogonFunctions,
PVOID * pWlxContext)
{
hGlobalWlx = hWlx;
g_pWinlogon = pWinlogonFunctions;
return prcWlxInitialize (
lpWinsta,
hWlx,
pvReserved,
pWinlogonFunctions,
pWlxContext);
}
//------------------------
// 当系统&#
// Winlogon接收&#
// 现根据&#
int WINAPI WlxLoggedOnSAS (
PVOID pWlxContext,
DWORD dwSasType,
PVOID pReserved)
{
HANDLE hMutex;
WriteInfo("WlxLoggedOnSAS \r\n");
//屏蔽CTRL_ALT
if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL ||
dwSasType == WLX_SAS_TYPE_USER_LOGOFF ||
dwSasType == WLX_SAS_TYPE_SCRNSVR_TIMEO
dwSasType == WLX_SAS_TYPE_TIMEOUT ||
dwSasType == WLX_SAS_TYPE_SWITCHUSER)
{
//我采用
hMutex = OpenMutex(MUTEX_ALL_ACCESS
if (hMutex)
{
CloseHandle(hMutex);
WriteInfo("disble CTRL+ALT+DEL \r\n");
return WLX_SAS_ACTION_NONE; //返回就
}
else
WriteInfo("not disble CTRL+ALT+DEL \r\n");
}
return prcWlxLoggedOnSAS (
pWlxContext,
dwSasType,
pReserved);
}
//------------------------
// 在没有&#
int WINAPI WlxLoggedOutSAS (
PVOID pWlxContext,
DWORD dwSasType,
PLUID pAuthenticationId,
PSID pLogonSid,
PDWORD pdwOptions,
PHANDLE phToken,
PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
PVOID * pProfile)
{
WriteInfo("WlxLoggedOutSAS
return prcWlxLoggedOutSAS (
pWlxContext,
dwSasType,
pAuthenticationId,
pLogonSid,
pdwOptions,
phToken,
pMprNotifyInfo,
pProfile);
}
//------------------------
// Winlogon.exe调ஷ
// 允许gina dll做出相
VOID WINAPI WlxLogoff (PVOID pWlxContext)
{
WriteInfo("WlxLogoff \r\n");
prcWlxLogoff(pWlxContext);
}
//------------------------
// Winlogon.exe调ஷ
// 使gina dll确认是
// 传递给wi
BOOL WINAPI WlxNegotiate (
DWORD dwWinlogonVersion,
PDWORD pdwDllVersion)
{
WriteInfo("WlxNegotiate \r\n");
return prcWlxNegotiate (
dwWinlogonVersion,
pdwDllVersion);
}
//------------------------
// 在屏保&#
// 返回FALSEŝ
BOOL WINAPI WlxScreenSaverNotify (
PVOID pWlxContext,
BOOL *pSecure)
{
WriteInfo("WlxScreenSaverN
return prcWlxScreenSaverNotify (
pWlxContext,
pSecure);
}
//------------------------
// 在系统&#
// 允许gina dll处理一
VOID WINAPI WlxShutdown(
PVOID pWlxContext,
DWORD ShutdownType)
{
WriteInfo("WlxShutdown \r\n");
SetRegFlag(); // 我们在&#
prcWlxShutdown(pWlxContext
}
//------------------------
// 当系统&#
// 这种情&#
// 该接口gi
BOOL WINAPI WlxStartApplication (
PVOID pWlxContext,
PWSTR pszDesktopName,
PVOID pEnvironment,
PWSTR pszCmdLine)
{
WriteInfo("WlxStartApplica
return prcWlxStartApplication (
pWlxContext,
pszDesktopName,
pEnvironment,
pszCmdLine);
}
//------------------------
// 在锁定&#
// 在这里&#
int WINAPI WlxWkstaLockedSAS (
PVOID pWlxContext,
DWORD dwSasType
)
{
WriteInfo("WlxWkstaLockedS
return prcWlxWkstaLockedSAS (
pWlxContext,
dwSasType
);
}
//------------------------
// 加入日&#
// 修改日&#
int CALLBACK LockedOffDlgProc(
HWND hDlg,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
RECT rcDlg;
int cx, cy;
switch (Message){
case WM_INITDIALOG: //窗口的
WriteInfo("WM_INITDIALOG \r\n");
GetWindowRect(hDlg, &rcDlg); //得到窗
cx = GetSystemMetrics(SM_CXSCRE
cy = GetSystemMetrics(SM_CYSCRE
cx = (cx-(rcDlg.right-rcDlg.lef
cy = (cy-(rcDlg.bottom-rcDlg.to
SetWindowPos(hDlg, //设置窗
HWND_TOP,
cx, cy, //窗口的
0, 0, // ignores size arguments
SWP_NOSIZE);
SetTimer(hDlg, // handle to main window
ID_TIMER, // timer identifier
1000, // five-minute interval
(TIMERPROC) NULL); // no timer callback
return( TRUE );
break;
case WM_TIMER:
if (GetUsbFlag())
{
WriteInfo("WM_GET_USB_TRUE
KillTimer(hDlg, ID_TIMER);
EndDialog(hDlg, WLX_SAS_ACTION_LOCK_WKSTA)
return( TRUE );
}
}
return( FALSE );
}
//------------------------
// 修改日&#
// 当系统&#
// 显示一&#
VOID WINAPI WlxDisplayLockedNotice(PVO
{
int hDlgRet;
hDlgRet = ((PWLX_DISPATCH_VERSION_1_
WlxDialogBoxParam(hGlobalW
MAKEINTRESOURCE(IDD_DIALOG
if (hDlgRet==-1)
{
prcWlxDisplayLockedNotice(
}
WriteInfo("WlxDisplayLocke
}
//------------------------
// 当gina dll要显示
// 直接返&#
BOOL WINAPI WlxDisplayStatusMessage(
PVOID pWlxContext,
HDESK hDesktop,
DWORD dwOptions,
PWSTR pTitle,
PWSTR pMessage
)
{
return prcWlxDisplayStatusMessage
pWlxContext,
hDesktop,
dwOptions,
pTitle,
pMessage);
}
//------------------------
// Winlogon.exe调ஷ
// 直接返&#
BOOL WINAPI WlxGetStatusMessage(
PVOID pWlxContext,
DWORD *pdwOptions,
PWSTR pMessage,
DWORD dwBufferSize
)
{
WriteInfo("WlxGetStatusMes
return prcWlxGetStatusMessage(
pWlxContext,
pdwOptions,
pMessage,
dwBufferSize
);
}
//------------------------
// 在试图&#
// 直接返&#
BOOL WINAPI WlxIsLockOk(PVOID pWlxContext)
{
return prcWlxIsLockOk(pWlxContext
}
//------------------------
// 在试图&#
// 直接返&#
BOOL WINAPI WlxIsLogoffOk(
PVOID pWlxContext
)
{
WriteInfo("WlxIsLogoffOk \r\n");
return prcWlxIsLogoffOk(
pWlxContext
);
}
//------------------------
// Winlogon.exe调ஷ
// 返回TRUEඤ
BOOL WINAPI WlxNetworkProviderLoad(
PVOID pWlxContext,
PWLX_MPR_NOTIFY_INFO pNprNotifyInfo
)
{
WriteInfo("WlxNetworkProvi
return prcWlxNetworkProviderLoad(
pWlxContext,
pNprNotifyInfo
);
}
//------------------------
// Winlogon.exe调ஷ
// 直接返&#
BOOL WINAPI WlxRemoveStatusMessage(
PVOID pWlxContext
)
{
WriteInfo("WlxRemoveStatus
return prcWlxRemoveStatusMessage(
pWlxContext
);
}