📄 getcodedlg.cpp
字号:
return true;
}
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
if (!IsWindowVisible(hwnd)) return true;
char szTemp[128]="\0";
DWORD dwStyle;
switch((long)lParam)
{case INPUTDIALOGID:
if(!m_bPasswordStyle)
{
dwStyle=(DWORD)GetWindowLong(hwnd,GWL_STYLE);
if((dwStyle & ES_PASSWORD)== ES_PASSWORD)
{
EnumPasswordString();
::SendDlgItemMessage(::GetParent(hwnd),GetWindowLong(hwnd,GWL_ID),WM_SETTEXT,0,(LPARAM)(LPCTSTR)lpszPassword);
m_bPasswordStyle=true;
if (hButton1!=NULL)
{::SendMessage(::GetParent(hButton1),WM_COMMAND,(WPARAM)::GetWindowLong(hButton1,GWL_ID),(LPARAM)hButton1);
bFetched=true;
hButton1=NULL;
m_bPasswordStyle=false;
return false;
}
return true;
}
}
if(hButton1==NULL)
{::GetWindowText(hwnd,(LPSTR) szTemp,sizeof(szTemp));
if(strstr(szTemp,(const char *)lpszButtonConfirmCaption)!=NULL)
{hButton1=hwnd;
if (m_bPasswordStyle)
{::SendMessage(::GetParent(hButton1),WM_COMMAND,(WPARAM)::GetWindowLong(hButton1,GWL_ID),(LPARAM)hButton1);
bFetched=true;
hButton1=NULL;
m_bPasswordStyle=false;
return false;
}
return true;
}
return true;
}
return true;
break;
case INPUTRETRYDIALOGID:
::GetWindowText(hwnd,(LPSTR) szTemp,sizeof(szTemp));
if(strstr(szTemp,(const char *)lpszButtonRetryCaption)!=NULL)
{hButton2=hwnd;
::SendMessage(::GetParent(hButton2),WM_COMMAND,(WPARAM)GetWindowLong(hButton2,GWL_ID),(LPARAM)hButton2);
hButton2=NULL;
return false;
}
return true;
break;
default:return true;
}
return false;
}
void CGetCodeDlg::OnCANCEL()
{
m_bEnum=FALSE;
CDialog::OnCancel();
// TODO: Add your control notification handler code here
}
void CGetCodeDlg::OnPause()
{
UINT i;
for(i=1;i<=this->m_nThreadCount;i++)
{
m_pEnumThread[i].pThread->SuspendThread ();
}
m_Pause.EnableWindow(FALSE);
m_OK.EnableWindow(TRUE);
m_Quit.EnableWindow(TRUE);
m_OK.SetFocus();
}
void EnumPasswordString(void)
{ if(!bFetched) return;
bFetched=false;
CString lpszCharSet;
char lpszCurrentPassword[30]="\0";
CString lpszTmpCurrentPassword;
GetPrivateProfileString("设置","穷举方法","数字",lpszMethod,sizeof(lpszMethod),"Setup.ini");
if(strstr(lpszMethod,"数字")!=NULL)
{lpszCharSet.Format ("%s","0123456789");
GetPrivateProfileString("数字","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod,"小写字母")!=NULL)
{lpszCharSet.Format("%s","abcdefghijklmnopqrstuvwxyz" );
GetPrivateProfileString("小写字母","当前密码","a",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod,"大写字母")!=NULL)
{lpszCharSet.Format("%s","ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
GetPrivateProfileString("大写字母","当前密码","A",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod, "大小写字母组合")!=NULL)
{lpszCharSet.Format("%s","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
GetPrivateProfileString("大小写字母组合","当前密码","a",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod, "数字字母组合")!=NULL)
{lpszCharSet.Format("%s","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
GetPrivateProfileString("数字字母组合","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod, "所有字符")!=NULL)
{ lpszCharSet.Format("%s","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+`-=,./';[]\\{}|:\"<>?" );
GetPrivateProfileString("所有字符","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini");
}
if(strstr(lpszMethod, "数据字典")!=NULL)
{unsigned long nFilePos=GetPrivateProfileInt(lpszPath,"文件指针",0,"Setup.ini");
CFile m_file;
m_file.Open (lpszPath,0,NULL);
if(nFilePos==m_file.GetLength())
{ m_file.Close ();
m_bEnum=false;
::EnableWindow(::GetDlgItem(m_hwnd,IDOK),TRUE);
::EnableWindow(::GetDlgItem(m_hwnd,IDCANCEL),TRUE);
::EnableWindow(::GetDlgItem(m_hwnd,IDPause),FALSE);
::SetFocus(::GetDlgItem(m_hwnd,IDOK));
return ;
}
m_file.Seek (nFilePos,0);
int i=0;
for(;;)
{m_file.Read(lpszPassword+i,1);
if ((char)lpszPassword[i]!=0x0d)
{nFilePos++;
i++;
m_file.Seek (nFilePos,0);
continue;
}
else
{ m_file.Close ();
TCHAR lpszFilePos[10];
lpszPassword[i]='\0';
nFilePos++;
nFilePos++;
_stprintf(lpszFilePos,"%d",nFilePos);
WritePrivateProfileString(lpszPath,"文件指针",lpszFilePos,"Setup.ini");
WritePrivateProfileString(lpszPath,"当前穷举密码",lpszPassword,"Setup.ini");
break;
}
}
return;
}
bool bSetOk=false;
lpszTmpCurrentPassword.Format("%s",lpszCurrentPassword);
int nStrLen=lpszTmpCurrentPassword.GetLength ();
int i=nStrLen;
while (i>0)
{
CString CharCode=lpszTmpCurrentPassword.Mid(i-1,1);
if (CharCode!=lpszCharSet.Right(1))
{int nIndex=lpszCharSet.Find(CharCode,0);
CharCode=lpszCharSet.Mid (nIndex+1,1);
if(i!=nStrLen)lpszTmpCurrentPassword.Format("%s%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode,lpszTmpCurrentPassword.Right(nStrLen-i));
else lpszTmpCurrentPassword.Format("%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode);
WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini");
lpszTmpCurrentPassword.Format ("%s",lpszCurrentPassword);
lstrcpyn(lpszPassword,lpszTmpCurrentPassword,lpszTmpCurrentPassword.GetLength ()+1);
bSetOk=true;
break;
}
else
{ CharCode=lpszCharSet.Left(1);
if(i!=nStrLen)lpszTmpCurrentPassword.Format("%s%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode,lpszTmpCurrentPassword.Right(nStrLen-i));
else lpszTmpCurrentPassword.Format("%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode); // WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini");
i--;
}
}
if(bSetOk)
{
return;
}
lpszTmpCurrentPassword.Insert(0,lpszCharSet.Left(1));
WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini");
lpszTmpCurrentPassword.Format ("%s",lpszCurrentPassword);
lstrcpyn(lpszPassword,lpszTmpCurrentPassword,lpszTmpCurrentPassword.GetLength ()+1);
return;
}
void CGetCodeDlg::OnBrowse()
{CFileDialog m_FileOpen(TRUE,"*.txt","*.txt",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,NULL,NULL);
TCHAR lpBuffer[MAX_PATH];
LPTSTR *lpFilePart=NULL;
GetFullPathName(lpszPath,sizeof(lpBuffer),lpBuffer,lpFilePart);
m_FileOpen.m_ofn.lpstrInitialDir =lpBuffer;
m_FileOpen.DoModal();
m_EditPath.SetWindowText(m_FileOpen.GetPathName());
}
void CGetCodeDlg::OnRadio7()
{ m_EditPath.EnableWindow(TRUE);
m_BtnBrowser.EnableWindow(TRUE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO7);
}
void CGetCodeDlg::OnRadio1()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO1);
}
void CGetCodeDlg::OnRadio2()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO2);
}
void CGetCodeDlg::OnRadio3()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO3);
}
void CGetCodeDlg::OnRadio4()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO4);
}
void CGetCodeDlg::OnRadio5()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO5);
}
void CGetCodeDlg::OnRadio6()
{ m_EditPath.EnableWindow(FALSE);
m_BtnBrowser.EnableWindow(FALSE);
CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO6);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -