📄 unasmdlg.cpp
字号:
// UnAsmDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TEC2000.h"
#include "UnAsmDlg.h"
#include"AddressUasm.h"
#include"DwDlg.h"
#include<math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUnAsmDlg dialog
CUnAsmDlg::CUnAsmDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUnAsmDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnAsmDlg)
//}}AFX_DATA_INIT
}
void CUnAsmDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnAsmDlg)
DDX_Control(pDX, IDC_EDITPW, m_ctrlEditPw);
DDX_Control(pDX, IDC_EDITCOD, m_ctrlEditCod);
DDX_Control(pDX, IDC_EDITASM, m_ctrlEditAsm);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnAsmDlg, CDialog)
//{{AFX_MSG_MAP(CUnAsmDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnAsmDlg message handlers
BOOL CUnAsmDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN){
if(pMsg->wParam==VK_RETURN)
return TRUE;
if(pMsg->wParam==VK_ESCAPE)
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
/*
void CUnAsmDlg::OnLoadcod()
{
}
void CUnAsmDlg::OnRun()
{
char buffer[300];
strcpy(buffer,OpenFileName);
CString add=OpenFileName;
int length=OpenFileName.GetLength();
if(length!=0){
usm.uuasm(buffer);
// usm.uuuasm(buffer,(unsigned short)m_WordStart,(unsigned short)m_WordEnd);
CString add=OpenFileName;
UINT lengthadd=add.GetLength();
CString a;
a.Format("%d",lengthadd);
add.SetAt(lengthadd-4,'!');
add.SetAt(lengthadd-3,'.');
add.SetAt(lengthadd-2,'A');
add.SetAt(lengthadd-1,'S');
add+="M";
CString context;
char buffer2[100];
ifstream in_file(add,ios::in);
while(in_file.eof()==0){
in_file.getline(buffer2,100,'\n');
context+=buffer2;
context+="\r\n";
}
m_ctrlEditAsm.SetWindowText(context);
context.Empty();
lengthadd=add.GetLength();
add.SetAt(lengthadd-5,'#');
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'a');
add.SetAt(lengthadd-2,'s');
add.SetAt(lengthadd-1,'m');
char buffer1[300];
strcpy(buffer1,add);
ifstream in_file1(buffer1,ios::in);
while(in_file1.eof()==0){
in_file1.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
m_ctrlEditPw.SetWindowText(context);
}
else{
AfxMessageBox(" 没有载入.COD文件");
}
OpenFileName="";
}*/
/*
void CUnAsmDlg::OnLoad()
{
this->m_ctrlAddress.GetWindowText(m_strAddress);
int length1=m_strAddress.GetLength();
if(length1!=0){
OpenFileName=m_strAddress;
char buffer1[300];
strcpy(buffer1,OpenFileName);
usm.outcod(buffer1);
CString add=OpenFileName;
UINT lengthadd=add.GetLength();
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'t');
add.SetAt(lengthadd-2,'x');
add.SetAt(lengthadd-1,'t');
strcpy(buffer1,add);
CString context;
char buffer[256];
ifstream in_file(buffer1,ios::in);
while(in_file.eof()==0){
in_file.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
m_ctrlEditCod.SetWindowText(context);
add=OpenFileName;
lengthadd=add.GetLength();
add.SetAt(lengthadd-4,'#');
add.SetAt(lengthadd-3,'.');
add.SetAt(lengthadd-2,'a');
add.SetAt(lengthadd-1,'s');
add+="m";
strcpy(buffer1,add);
ifstream in_file1(buffer1,ios::in);
while(in_file1.eof()==0){
in_file1.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
m_ctrlEditPw.SetWindowText(context);
}
else{
AfxMessageBox("没有选择.COD文件");
}
}
*/
void CUnAsmDlg::Loadcod()
{
char *FilterStr = "COD Files (*.cod)|*.cod; *.cod|All Files (*.*)|*.*||";
CFileDialog OpenFile(TRUE, ".cod", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,FilterStr, NULL);
if (OpenFile.DoModal() == IDOK)
OpenFileName = OpenFile.GetPathName();
else return;
char buffer1[300];
strcpy(buffer1,OpenFileName);
usm.outcod(buffer1);
CString add=OpenFileName;
UINT lengthadd=add.GetLength();
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'t');
add.SetAt(lengthadd-2,'x');
add.SetAt(lengthadd-1,'t');
strcpy(buffer1,add);
// AfxMessageBox(buffer1);
CString context;
char buffer[256];
//
ifstream in_file(buffer1,ios::in);
while(in_file.eof()==0){
in_file.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
in_file.close();
m_ctrlEditCod.SetWindowText(context);
context.Empty();
add=OpenFileName;
lengthadd=add.GetLength();
add.SetAt(lengthadd-4,'#');
add.SetAt(lengthadd-3,'.');
add.SetAt(lengthadd-2,'a');
add.SetAt(lengthadd-1,'s');
add+="m";
strcpy(buffer1,add);
ifstream in_file1(buffer1,ios::in);
while(in_file1.eof()==0){
in_file1.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
in_file1.close();
m_ctrlEditPw.SetWindowText(context);
// usm.exe(buffer1,);
}
void CUnAsmDlg::Run()
{
if(OpenFileName==""){
AfxMessageBox("没有载入文件,请先载入文件!");
return;
}
CAddressUasm dlg;
dlg.DoModal();
UpdateData(TRUE);
CString address;
address=dlg.m_strAddress;
char addre[10];
strcpy(addre,address);
WORD addWord=TraCharToHex(addre);
char buffer[300];
char buffer1[300];
CString add=OpenFileName;
int lengthadd=add.GetLength();
// add.SetAt(lengthadd-4,'#');
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'c');
add.SetAt(lengthadd-2,'o');
add.SetAt(lengthadd-1,'d');
// add+="m";
strcpy(buffer1,add);
unsigned short addtemp=addWord;
usm.exe(buffer1,addtemp);
usm.uuasm(buffer1);
// CString temp1,temp2;
// temp1.Format("%04x",atail);
// temp2.Format("%04x",ahead);
// temp1+="\r\n";
// temp1+=temp2;
add=OpenFileName;
lengthadd=add.GetLength();
CString a;
a.Format("%d",lengthadd);
add.SetAt(lengthadd-4,'!');
add.SetAt(lengthadd-3,'.');
add.SetAt(lengthadd-2,'A');
add.SetAt(lengthadd-1,'S');
add+="M";
CString context;
char buffer2[100];
// AfxMessageBox(add);
ifstream in_file(add,ios::in);
while(in_file.eof()==0){
in_file.getline(buffer2,100,'\n');
context+=buffer2;
context+="\r\n";
}
m_ctrlEditAsm.SetWindowText(context);
context.Empty();
lengthadd=add.GetLength();
// add.SetAt(lengthadd-5,'#');
add.SetAt(lengthadd-5,'#');
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'a');
add.SetAt(lengthadd-2,'s');
add.SetAt(lengthadd-1,'m');
buffer1[300];
strcpy(buffer1,add);
ifstream in_file1(buffer1,ios::in);
while(in_file1.eof()==0){
in_file1.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
m_ctrlEditPw.SetWindowText(context);
// }
// else{
// AfxMessageBox(" 没有载入.COD文件");
// }
// OpenFileName="";
}
void CUnAsmDlg::Dwrun()
{
if(OpenFileName==""){
AfxMessageBox("没有载入文件,请先载入文件!");
return;
}
CDwDlg dlg;
dlg.DoModal();
UpdateData(TRUE);
CString start,end;
start=dlg.m_strStart;
end=dlg.m_strEnd;
char startch[10];
char endch[10];
strcpy(startch,start);
strcpy(endch,end);
WORD StartWord=TraCharToHex(startch);
WORD EndWord=TraCharToHex(endch);
char buffer[300];
char buffer1[300];
CString add=OpenFileName;
int lengthadd=add.GetLength();
// add.SetAt(lengthadd-4,'#');
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'c');
add.SetAt(lengthadd-2,'o');
add.SetAt(lengthadd-1,'d');
strcpy(buffer1,add);
unsigned short startint=StartWord;
unsigned short endint=EndWord;
usm.datadefine(buffer1,startint,endint);
usm.uuasm(buffer1);
add=OpenFileName;
lengthadd=add.GetLength();
CString a;
a.Format("%d",lengthadd);
add.SetAt(lengthadd-4,'!');
add.SetAt(lengthadd-3,'.');
add.SetAt(lengthadd-2,'A');
add.SetAt(lengthadd-1,'S');
add+="M";
CString context;
char buffer2[100];
// AfxMessageBox(add);
ifstream in_file(add,ios::in);
while(in_file.eof()==0){
in_file.getline(buffer2,100,'\n');
context+=buffer2;
context+="\r\n";
}
m_ctrlEditAsm.SetWindowText(context);
context.Empty();
lengthadd=add.GetLength();
// add.SetAt(lengthadd-5,'#');
add.SetAt(lengthadd-5,'#');
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'a');
add.SetAt(lengthadd-2,'s');
add.SetAt(lengthadd-1,'m');
buffer1[300];
strcpy(buffer1,add);
ifstream in_file1(buffer1,ios::in);
while(in_file1.eof()==0){
in_file1.getline(buffer,256,'\n');
context+=buffer;
context+="\r\n";
}
m_ctrlEditPw.SetWindowText(context);
}
WORD CUnAsmDlg::TraCharToHex(char *p){
char *buf;
int TEMP[5];
WORD DATA=0;
buf=p;
while(buf[0]==' '){buf=buf+1;}
if(buf[0]=='\0')
return 0;
else
{
int i,j=0;
for(i=0;i<4&&(buf[i]!=' ')&&(buf[i]!='\r')&&(buf[i]!='\0')&&(buf[i]!=',')&&(buf[i]!=']')&&(buf[i]!='[');i++)
{ if(buf[i]=='a'||buf[i]=='A'){TEMP[i]=10;}
if(buf[i]=='b'||buf[i]=='B'){TEMP[i]=11;}
if(buf[i]=='c'||buf[i]=='C'){TEMP[i]=12;}
if(buf[i]=='d'||buf[i]=='D'){TEMP[i]=13;}
if(buf[i]=='e'||buf[i]=='E'){TEMP[i]=14;}
if(buf[i]=='f'||buf[i]=='F'){TEMP[i]=15;}
if(buf[i]=='0'){TEMP[i]=0;}
if(buf[i]=='1'){TEMP[i]=1;}
if(buf[i]=='2'){TEMP[i]=2;}
if(buf[i]=='3'){TEMP[i]=3;}
if(buf[i]=='4'){TEMP[i]=4;}
if(buf[i]=='5'){TEMP[i]=5;}
if(buf[i]=='6'){TEMP[i]=6;}
if(buf[i]=='7'){TEMP[i]=7;}
if(buf[i]=='8'){TEMP[i]=8;}
if(buf[i]=='9'){TEMP[i]=9;}
}
while(i>0)
{
DATA+=TEMP[i-1]*(int)pow(16,j);
i--;j++;
}
}
return DATA;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -