惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
V2EX - 技术
V2EX - 技术
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
S
Schneier on Security
I
InfoQ
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The GitHub Blog
The GitHub Blog
S
Security @ Cisco Blogs
O
OpenAI News
W
WeLiveSecurity
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
Cloudbric
Cloudbric
The Last Watchdog
The Last Watchdog
The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
NISL@THU
NISL@THU
T
Tailwind CSS Blog
V
Visual Studio Blog
PCI Perspectives
PCI Perspectives
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
D
DataBreaches.Net
B
Blog RSS Feed
N
News and Events Feed by Topic
N
News and Events Feed by Topic
H
Heimdal Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
Latest news
Latest news
V
Vulnerabilities – Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
V
V2EX
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Register - Security
The Register - Security
Help Net Security
Help Net Security

博客园 - catlog

曲终人不散 在Windows2000/XP的安全模式下,替换Gina 如何再Win2000/XP下,加入自己的认证? 是走的时候了 VC++ FAQ--VC和MFC的未来,还有Whidbey 如何在Win2000/xp下禁止某些硬件?比如说网卡,CD-ROM.. 明华的EKey 头晕,出个题目考考你 - catlog - 博客园 基于pkcs11的MS CSP的OpenSource实现 生活就是混下去。 用 WB Editor 连接 博客园 的全攻略 取得当前用户的权限(privileges) 一首词 如何用IPHelp取得网卡的详细信息 令人吃惊的完成端口Copy速度! 如何订阅OSR的新闻组? 1:0中国胜科威特 故土难离 Windows 2000的引导过程
win98下如何控制登陆?
catlog · 2004-02-26 · via 博客园 - catlog

假设用户的登陆方式为网络登陆,那么我们可以安以下的步骤,来实现保存密码和防止ESC键:

1.在RunService处(HKLM\)填上一个服务程序,可保证在登陆框出现前启动。

2.在Service的程序中用FindWindow,FindWindowEx找到窗口和Edit,Button的Handle,便可控制。

代码如下:

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <winuser.h>
#include <process.h>
#include "UsbEkey.h"

//-----------------------------------------------------------------------
//       G L O B A L S
//-----------------------------------------------------------------------
const LPCSTR DLGTTLE = "请输入网络密码";
const LPCSTR CHKTTLE = "保存密码";
const LPSTR CHK_APP_NAME = "ChkBox.exe";

const UINT RSP_SIMPLE_SERVICE = 1;
const UINT RSP_UNREGISTER_SERVICE = 0;


typedef DWORD (WINAPI * pRegFunction)(
           DWORD dwProcessId, 
           DWORD dwType);

HWND hDlg = NULL;
HWND hUserName = NULL;
HWND hPwd = NULL;
HWND hDomain = NULL;
HWND hBtnOk = NULL;
HWND hBtnCancel = NULL;
HWND hChkBox = NULL;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ACCOUNT g_Account,g_NewAccount;


//-----------------------------------------------------------------------
// Find The Application CreateCheckBox Contrl's
//-----------------------------------------------------------------------
HWND GetMyChkBox(HWND hDlg)
{
 HWND hTmp = NULL,hChk = NULL;
 bool b1 = false,b2 = false;
 
 hTmp =FindWindowEx(hDlg,NULL,"button",NULL);
 hChk = hTmp;
 while (!b1 && !b2)
 {  
  hChk = GetNextDlgGroupItem(hDlg,hChk,FALSE);
  
  char buf[255];
  GetWindowText(hChk,buf,255);
  if (strcmp(buf,CHKTTLE) == 0 )
  {
   b1 = true;  
  }
  if (hTmp == hChk)
  {
   b2 = true; 
   OutputDebugString("Not Find The CheckBox\n");
  }  
 }

 return hChk;
}
//-----------------------------------------------------------------------
// Get The UserName/Pwd/Domain And Save To The UsbEkey Thread
//-----------------------------------------------------------------------
void GetTextFunProc(PVOID parg)
{
 while (NULL != hDlg )
 { 
  SendMessage(hUserName,WM_GETTEXT,255,(LPARAM)g_NewAccount.UserName);
  SendMessage(hPwd,WM_GETTEXT,255,(LPARAM)g_NewAccount.PassWord);
  SendMessage(hDomain,WM_GETTEXT,255,(LPARAM)g_NewAccount.Domain);  
  
  hChkBox = GetMyChkBox(hDlg);
  if (NULL == hChkBox) {
   break;
  }
  int iRet = SendMessage(hChkBox,BM_GETCHECK ,0,0);
  if (BST_CHECKED == iRet){
   g_NewAccount.Flag = FLAG_SAVE_PWD;  
  }
  
  if (BST_UNCHECKED == iRet){
   g_NewAccount.Flag = FLAG_NOT_SAVE_PWD;
  }  
  
  char buf[255];
  sprintf(buf,"GetText:\t UserName=%s;Pwd=%s;Domain=%s\;Flag=%d\n",
   g_NewAccount.UserName,g_NewAccount.PassWord,g_NewAccount.Domain,
   g_NewAccount.Flag);
  OutputDebugString(buf);

  hDlg = FindWindow(NULL,DLGTTLE);
  
  Sleep(100);  
 }
 
 //
 // On There Save UserName/Pwd/Domain to UsbEkey
 //
 if (g_NewAccount.Flag != g_Account.Flag
  || g_NewAccount.Flag == FLAG_SAVE_PWD)
 {
  if (0 == WriteAccount(g_NewAccount))
  {
   memcpy(&g_Account,&g_NewAccount,sizeof(ACCOUNT));
  }
  
 } 
 
 //
 // Close CreaeChkBox Application
 // 
 TerminateProcess(pi.hProcess,0); 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
 return;
}

//-----------------------------------------------------------------------
// Set The UserName/Pwd/Domain Thread
//-----------------------------------------------------------------------
void SetTextFunProc(PVOID parg)

 //DWORD dwStartTime;

 //dwStartTime = GetTickCount();
 
 while (true)
 {
  if (strlen(g_Account.PassWord) <= 0
   && strlen(g_Account.UserName) <= 0
   && strlen(g_Account.Domain) <= 0)
  {
   OutputDebugString("ReadAccount Start....\n"); 
   ReadAccount(g_Account);   
  }  
  

  hDlg = FindWindow(NULL,DLGTTLE);
  if (NULL != hDlg)
  {
   OutputDebugString("Find The Login Dlg\n");

   hUserName = FindWindowEx(hDlg,NULL,"edit",NULL);
   if (hUserName == NULL)
   {
    OutputDebugString("Can Not Find The Edit_UserName\n");
    return;
   }

   hPwd = GetNextDlgTabItem(hDlg,hUserName,FALSE);
   if (hPwd == NULL)
   {
    OutputDebugString("Can Not Find The Edit_PassWord\n");
    return;
   }

   hDomain = GetNextDlgTabItem(hDlg,hPwd,FALSE);
   if (hDomain == NULL)
   {
    OutputDebugString("Can Not Find The Edit_Domain\n");
    return;
   }   

   hBtnOk = GetNextDlgTabItem(hDlg,hDomain,FALSE);
   if (hDomain == NULL)
   {
    OutputDebugString("Can Not Find The Btn_OK\n");
    return;
   }   

   hBtnCancel = GetNextDlgTabItem(hDlg,hBtnOk,FALSE);
   if (hDomain == NULL)
   {
    OutputDebugString("Can Not Find The Btn_Cancel\n");
    return;
   } 
   
   //
   // Exec CreateChkBox Application
   //    
   OutputDebugString("CreateProcess CreateCheckBox\n");
   CreateProcess(NULL,CHK_APP_NAME,NULL,            
     NULL, FALSE,0,NULL,NULL,&si,&pi );   

   Sleep(500);
   hChkBox = GetMyChkBox(hDlg);
   if (g_Account.Flag == FLAG_SAVE_PWD){  
    SendMessage(hChkBox,BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
   }

   //
   // Set Pwd/UserName/Domain
   // 
   if (g_Account.Flag == FLAG_SAVE_PWD) { 
    if (strlen(g_Account.UserName) > 0) {
     SendMessage(hUserName,WM_SETTEXT,255,(LPARAM)g_Account.UserName);
    }
    
    if (strlen(g_Account.PassWord) > 0) {
     SendMessage(hPwd,WM_SETTEXT,255,(LPARAM)g_Account.PassWord);
    }
    
    if (strlen(g_Account.Domain) > 0) {
     SendMessage(hDomain,WM_SETTEXT,255,(LPARAM)g_Account.Domain);
    }
    
    //
    //  Disable The "ESC" and "Cancel" Buttton
    //                 
    char szBuf[255];
    GetWindowText(hBtnCancel,szBuf,255);
    if (strcmp("取消",szBuf) == 0)
    {
     EnableWindow(hBtnCancel,FALSE);
    }    
    //keybd_event( VK_RETURN,0x45,KEYEVENTF_EXTENDEDKEY | 0,0 );    
   }   

   GetTextFunProc(NULL);
   OutputDebugString("Create The GetTextFunProc Thread!\n");
  }
  
  Sleep(1000*3);
  
  //
  // After Half Hour Application Exit
  //  
  //if ((GetTickCount() - dwStartTime)/(1000*60) >=30) {
  // break;
  //}
  OutputDebugString("SetText Thread Is Runing...\n");
 }
 
 return ;
}

//-----------------------------------------------------------------------
// InitlizeFuntions
//-----------------------------------------------------------------------
bool Initlize()
{
 //bool pOld;
 //SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,true,&pOld,SPIF_UPDATEINIFILE);
 
 //
 //  RegisterServiceProcess then TaskMgr Can't Find It
 // 
 HINSTANCE hKernelLib;
 pRegFunction RegisterServiceProcess; 
 
 hKernelLib = LoadLibrary("kernel32.dll");
 if(hKernelLib)
 {
  RegisterServiceProcess =
   (pRegFunction)GetProcAddress(hKernelLib,"RegisterServiceProcess");
  if(RegisterServiceProcess){
    RegisterServiceProcess(GetCurrentProcessId(),RSP_SIMPLE_SERVICE);
  }
  
 }
 
 memset(&g_Account,0,sizeof(ACCOUNT));
 memset(&g_NewAccount,0,sizeof(ACCOUNT));
 ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );


 return true;
}


//-----------------------------------------------------------------------
// UnInitlizeFuntions
//-----------------------------------------------------------------------
bool UnInitlize()
{
 DestoryEKey();
// FreeEKeyFuns();
 return true;
}
//------------------------------------------------------------------------
//  WinMain Entry
//-----------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 HANDLE hThead;
 Initlize(); 
 
 hThead = (HANDLE)_beginthread(SetTextFunProc,NULL,NULL);
 OutputDebugString("Create The SetTextFunProc Thread!\n");
 
 WaitForSingleObject(hThead,INFINITE);
 CloseHandle(hThead);

 OutputDebugString("Application End!\n"); 
 UnInitlize();

 return 0;
}

完整的VC工程可来信索取.

borland@163.com