📄 protelcryptodlg.cpp
字号:
it=CCpry.Find(fileData,flieLength,true);
//type=CCpry.FileType(fileData,flieLength);
free( fileData);
if(it<flieLength)
{
//exeFile.Close();
fileName2=fileName+".bak";
if (!CopyFile(fileName,fileName2,true))
{
MessageBox("Backup false! ",MB_OK);
return;
};
//exeFile.Open( fileName,CFile::modeReadWrite|CFile::typeBinary|CFile::shareDenyRead, &fileException );
//exeFile.Seek(0x2E234C,CFile::begin);
exeFile.Seek(it,CFile::begin);
exeFile.Write(CCpryto::KeyBlobPubIWESUNcon,0x114);
exeFile.Close();
//MessageBox(fileName+" 密钥修改成功! ",MB_OK);
MessageBox("Replace key Succeed and backup to .bak ",MB_OK);
}
/*else if(type==2)
{
MessageBox("This file is IWESUN2004 DXP.exe,not need Replace key.",MB_OK);
}else if(type==3)
{
//exeFile.Close();
fileName2=fileName+".bak";
if(!CopyFile(fileName,fileName2,true))
{
MessageBox("Backup false! ",MB_OK);
return;
};
//exeFile.Open( fileName,CFile::modeReadWrite|CFile::typeBinary|CFile::shareDenyRead, &fileException );
exeFile.Seek(0x170330,CFile::begin);
exeFile.Write(CCpryto::KeyBlobPubIWESUNcon,0x114);
exeFile.Close();
//MessageBox(fileName+" 密钥修改成功! ",MB_OK);
MessageBox("This file is Altium2004 DXPSecurityService.exe.Replace key Succeed and backup to .bak",MB_OK);
}else if(type==4)
{
MessageBox("This File is IWESUN2004 DXPSecurityService.exe.not need Replace key.",MB_OK);
}*/
else
{
MessageBox("This File is unknown files.",MB_OK);
}
}else
{
MessageBox("This File is empty!","Error",MB_OK|MB_ICONERROR);
return ;
}
}else
{
MessageBox("Not enough Memory !","Error",MB_OK|MB_ICONERROR);
}
}else
{
MessageBox(fileName+" open error! ","Error",MB_OK|MB_ICONERROR);
TRACE( "Can't open file %s, error = %u\n",fileName, fileException.m_cause );
}
//Change the window's title to the opened file's title.
//SetWindowText(fileName);
}
}
void CProtelCryptoDlg::OnBnClickedButton5()
{
// TODO: 在此添加控件通知处理程序代码
char szFilters[]= "Protel License ini Files (*.ini)|*.ini|All Files (*.*)|*.*||";
int i;
CFile LicenseFile;
BYTE txtBuffer[4096];
CFileException fileException;
// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg (TRUE, "Protel2004", "*.ini", OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if( fileDlg.DoModal ()==IDOK )
{
//CString pathName = fileDlg.GetPathName();
CString fileName = fileDlg.GetFileName () ;
// Implement opening and reading file in here.
//...
if ( LicenseFile.Open( fileName,CFile::modeRead, &fileException ))
{
if(LicenseFile.GetLength()>0)
{
i= LicenseFile.Read(txtBuffer, 4096);txtBuffer[i]=0;
LicenseFile.Close();
mCEdit.SetWindowText(CString(txtBuffer));
}
}else
{
TRACE( "Can't open file %s, error = %u\n",
fileName, fileException.m_cause );
}
//Change the window's title to the opened file's title.
SetWindowText(fileName);
}
}
void CProtelCryptoDlg::OnBnClickedRadio2()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
SetLanguage(language);
}
void CProtelCryptoDlg::OnBnClickedRadio1()
{
// TODO: 在此添加控件通知处理程序代码
//cbtEnglish.
UpdateData(true);
SetLanguage(language);
}
void CProtelCryptoDlg::SetLanguage(int language)
{
if(language)
{
strAltiumVerify.LoadString(IDS_AltiumVerifyEn);
strBye.LoadString(IDS_ByeEn);
strChinese.LoadString(IDS_ChineseEn);
strBye.LoadString(IDS_ByeEn);
strExport.LoadString(IDS_ExportEn);
strFlieVerify.LoadString(IDS_FlieVerifyEn);
strGoodLuck.LoadString(IDS_GoodLuckEn);
strImport.LoadString(IDS_ImportEn);
strIWESUNVerify.LoadString(IDS_IWESUNVerifyEn);
strKeyComeback.LoadString(IDS_KeyComebackEn);
strKeyManager.LoadString(IDS_KeyManagerEn);
strKeyReplace.LoadString(IDS_KeyReplaceEn);
strLanBoMovement.LoadString(IDS_LanBoMovementEn);
strLanguage.LoadString(IDS_LanguageEn);
strProducte.LoadString(IDS_ProducteEn);
strVerifySignature.LoadString(IDS_VerifySignatureEn);
strProduceLicense.LoadString(IDS_ProduceLicenseEn);
}else
{
strAltiumVerify.LoadString(IDS_AltiumVerify);
strBye.LoadString(IDS_Bye);
strChinese.LoadString(IDS_Chinese);
strBye.LoadString(IDS_Bye);
strExport.LoadString(IDS_Export);
strFlieVerify.LoadString(IDS_FlieVerify);
strGoodLuck.LoadString(IDS_GoodLuck);
strImport.LoadString(IDS_Import);
strIWESUNVerify.LoadString(IDS_IWESUNVerify);
strKeyComeback.LoadString(IDS_KeyComeback);
strKeyManager.LoadString(IDS_KeyManager);
strKeyReplace.LoadString(IDS_KeyReplace);
strLanBoMovement.LoadString(IDS_LanBoMovement);
strLanguage.LoadString(IDS_Language);
strProducte.LoadString(IDS_Producte);
strVerifySignature.LoadString(IDS_VerifySignature);
strProduceLicense.LoadString(IDS_ProduceLicense);
}
strVer.LoadString(IDS_Version);
strProducte+=strVer;
SetWindowText(strProducte);
cbtChinese.SetWindowText(strChinese);
gboxLanguage.SetWindowText(strLanguage);
gboxLicenseVerify.SetWindowText(strVerifySignature);
butVerifySignature.SetWindowText(strAltiumVerify);
butIwesunLicense.SetWindowText(strIWESUNVerify);
gboxProduceLicense.SetWindowText(strProduceLicense);
butImport.SetWindowText(strImport);
butExport.SetWindowText(strExport);
gboxKeyManage.SetWindowText(strKeyManager);
butFlieVerify.SetWindowText(strFlieVerify);
butKeyReplace.SetWindowText(strKeyReplace);
butKeyComeback.SetWindowText(strKeyComeback);
butGoodLuck.SetWindowText(strGoodLuck);
butBye.SetWindowText(strBye);
txtboxProducteName.SetWindowText(strProducte);
txtboxLanBo.SetWindowText(strLanBoMovement);
SetReadme(language);
}
void CProtelCryptoDlg::SetReadme(int language)
{
CFile readmeFile;
CFileException fileException;
BYTE strFile[8192];
int nBytesRead=0;
CString txt;
if(language==0)
{
if ( readmeFile.Open("ReadmeCn.txt",CFile::modeReadWrite, &fileException ) )
{
nBytesRead =readmeFile.Read(strFile,8192);strFile[nBytesRead]=0;
if(nBytesRead>0) txt=strFile;
}
if(nBytesRead==0)
{
txt=(
CString("警告:\r\n 本程序仅用于对密码学的研究和实践,不得用于其他商业用途,否则,一切后果由使用者承担!\r\n\r\n"))+
CString("使用方法:(使用方法由Aforce提供,感谢!)\r\n\r\n")+
CString("一. 运行本程序后,点击“导入模版”,先导入一个ini文件模版(如果要生成单机版的License选择Unified Nexar-Protel \r\n License.ini;要生成网络版的License选择Unified Nexar-Protel Network License.ini),然后修改里面的参数:\r\n\r\n")+
CString(" 1) ransactorName=Your Name(将“Your Name”替换为你想要注册的用户名)\r\n\r\n"+
CString(" 2) SerialNumber=0000000(如果你只有一台计算机,那么这个可以不用修改,如果有两台以上的计算机且连成\r\n 局域网,那么请保证每个License文件中的SerialNumber=为不同的值,例如:SerialNumber=0000001;\r\n SerialNumber=0000002...\r\n\r\n")+
CString(" 3) UserCount=x(要生成单机版的License不用修改;要生成网络版的License请修改x为需要受权的用户数量,默\r\n 认为1000用户)\r\n\r\n")+
CString(" 其它参数普通用户不必修改。\r\n\r\n")+
CString(" 修改完成后点击“生成协议文件”,任意输入一个文件名(文件后缀为.alf)保存,程序会在相应目录中生成1个\r\n License文件。\r\n\r\n")+
CString("二. 点击“替换密钥”,选取DXP.exe(在DXP 2004安装目录里,默认路径为C:\\Program Files\\Altium2004\\),程序会\r\n\ 自动替换文件中的公开密钥。如果要使用网络版的License,还必须同时替换DXPSecurityService.exe\r\n (在DXP 2004安装目录里,默认路径为C:\\Program Files\\Altium2004\\)文件中的公开密钥,操作步骤同上。\r\n (对文件修改前请手工做好备份,以防万一。)\r\n\r\n")+
CString("三. 将第一步生成的License文件拷贝至DXP 2004安装目录里(默认路径为C:\\Program Files\\Altium2004\\)\r\n 或者在DXP的使用许可管理中添加生成的License文件,网络版的License文件在\r\n Altium DXP Security Service中添加。\r\n\r\n")+
CString(" 授权完成。\r\n\r\n")+
CString("注:“原版验证”:查看和验证Altium原版的License文件内容;\r\n\r\n")+
CString(" “我版效验”:查看和验证由本注册机生成的License文件内容。\r\n\r\n"));
}
}else
{
if ( readmeFile.Open("ReadmeEn.txt",CFile::modeReadWrite, &fileException ) )
{
nBytesRead =readmeFile.Read(strFile,8192);strFile[nBytesRead]=0;
if(nBytesRead>0)txt=strFile;
}
if(nBytesRead==0)
{
txt="Warning:\r\n\r\n This programs is Research and Examination for Cryptology ,not be used for any business!\r\n\r\n";
}
}
//mCEdit.SetWindowText("ddddddddddddd" );
mCEdit.SetWindowText(txt );
}
void CProtelCryptoDlg::OnBnClickedButton9()
{
// TODO: 在此添加控件通知处理程序代码
char szFilters[]= "Protel DXP Exe Files Or DXPSecurityService.exe(*.exe)|*.exe|All Files (*.*)|*.*||";
CFile exeFile;
CFile sgnFile;
CFileException fileException;
CString strFile;
BYTE *fileData;
CString buffer;
int fileType=0;
int i,j,type;
ULONGLONG flieLength=0;
BYTE pbSignature[2048];
DWORD sgLen;
bool flag;
DWORD address;
// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg (TRUE, "C:\\Program Files\\Altium2004\\DXP.exe", "*.exe", OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if( fileDlg.DoModal ()==IDOK)
{
//CString pathName = fileDlg.GetPathName();
CString fileName = fileDlg.GetFileName () ;
// Implement opening and reading file in here.
//...
if ( exeFile.Open( fileName,CFile::modeRead|CFile::typeBinary , &fileException ) )
{
flieLength=exeFile.GetLength();
if(flieLength!=0)
{
//--------------------------------------------------------------------
// 检查 fileData 空间.
if(fileData = (BYTE*)malloc(flieLength))
{
TRACE("fileData 空间允许. \n");
flieLength =exeFile.Read(fileData,flieLength);
/*
if(CCpry.CreateFileSign(fileData,flieLength,pbSignature,&sgLen))
{
fileName+=".iws";
sgnFile.Open( fileName,CFile::modeWrite|CFile::typeBinary|CFile::modeCreate , &fileException );
buffer=CCpry.Bin2HexText(pbSignature,sgLen);
sgnFile.Write(buffer,buffer.GetLength());
sgnFile.Close();
sgnFile.Open( "256Ascii.txt",CFile::modeWrite|CFile::typeBinary|CFile::modeCreate , &fileException );
for(i=0;i<256;i++)pbSignature[i]=i;
buffer=CCpry.Bin2HexText(pbSignature,256);
sgnFile.Write(buffer,buffer.GetLength());
sgnFile.Close();
sgnFile.Open( "IWESUNpri.txt",CFile::modeWrite|CFile::typeBinary|CFile::modeCreate , &fileException );
j=0;
for(i=0;i<1172;i++)
{
pbSignature[i]=CCpryto::KeyBlobPriIWESUNcon[i]^CCpryto::KeyBlobPubIWESUNcon[j];
j++;if(j>0x100)j=0;
}
buffer=CCpry.Bin2HexText(pbSignature,1172);
sgnFile.Write(buffer,buffer.GetLength());
sgnFile.Close();
}else
{
TRACE("签名失败. \n");
}*/
type=CCpry.FileType(fileData,flieLength);free( fileData);
if(type==1)
{
MessageBox("This file is Altium2004 DXP.exe",MB_OK);
}else if(type==2)
{
MessageBox("This file is IWESUN2004 DXP.exe",MB_OK);
}else if(type==3)
{
MessageBox("This file is Altium2004 DXPSecurityService.exe.",MB_OK);
}else if(type==4)
{
MessageBox("This File is IWESUN2004 DXPSecurityService.exe.",MB_OK);
}
else
{
MessageBox("This File is unknown files.",MB_OK);
}
}else
{
MessageBox("This File is empty!","Error",MB_OK|MB_ICONERROR);
return ;
}
}else
{
MessageBox("Not enough Memory !","Error",MB_OK|MB_ICONERROR);
}
exeFile.Close();
}else
{
MessageBox(fileName+"Open Error ","Error",MB_OK|MB_ICONERROR);
//Change the window's title to the opened file's title.
SetWindowText(fileName);
}
}
}
void CProtelCryptoDlg::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
// TODO: 在此添加控件通知处理程序代码
// TODO: 在此添加控件通知处理程序代码
// TODO: 在此添加控件通知处理程序代码
// szFilters is a text string that includes two file name filters:
// "*.my" for "MyType Files" and "*.*' for "All Files."
char szFilters[]= "Protel DXP Exe Files (*.exe)|*.exe|All Files (*.*)|*.*||";
CFile exeFile;
CFileException fileException;
CString strFile;
BYTE *fileData;
DWORD flieLength;
int i,type;
bool flag;
DWORD address;
CString fileName;
CString fileName2;
DWORD it;
// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg (TRUE, "C:\\Program Files\\Altium2004\\DXP.exe", "*.exe", OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if( fileDlg.DoModal ()==IDOK )
{
//CString pathName = fileDlg.GetPathName();
fileName = fileDlg.GetFileName () ;
// Implement opening and reading file in here.
//...
if ( exeFile.Open( fileName,CFile::modeReadWrite|CFile::typeBinary , &fileException ) )
{
flieLength=exeFile.GetLength();
if(flieLength!=0)
{
//--------------------------------------------------------------------
// 检查 fileData 空间.
if(fileData = (BYTE*)malloc(flieLength))
{
TRACE("fileData 空间允许. \n");
flieLength =exeFile.Read(fileData,flieLength);
it=CCpry.Find(fileData,flieLength,false);
//type=CCpry.FileType(fileData,flieLength);free( fileData);
if(it<flieLength)
{
//exeFile.Seek(0x2E234C,CFile::begin);
exeFile.Seek(it,CFile::begin);
exeFile.Write(CCpryto::KeyBlobPubProtel,0x114);
MessageBox("This file is IWESUN2004 DXP.exe,comeback succeed.",MB_OK);
}
else
{
MessageBox("This File is unknown files.",MB_OK);
}
}else
{
MessageBox("This File is empty!","Error",MB_OK|MB_ICONERROR);
return ;
}
}else
{
MessageBox("Not enough Memory !","Error",MB_OK|MB_ICONERROR);
}
exeFile.Close();
}else
{
MessageBox(fileName+" file open error ","error",MB_OK|MB_ICONERROR);
TRACE( "Can't open file %s, error = %u\n",fileName, fileException.m_cause );
}
//Change the window's title to the opened file's title.
//SetWindowText(fileName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -