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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - catlog

曲终人不散 - 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的新闻组? Windows 2000的引导过程 1:0中国胜科威特 故土难离
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