📄 user_dlg.cpp
字号:
/************************************************************************
* blockbox *
* - this is the dialog which just shows the extents of the current *
* block *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
bool FAR PASCAL blockbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static char s1[30],s2[30],s3[40];
switch(message)
{ case WM_COMMAND:
{ switch(wParam)
{ case IDOK:
EndDialog(hdwnd,NULL);
return true;
default:
break;
}
}
break;
case WM_INITDIALOG:
CenterWindow(hdwnd);
wsprintf(s1,"%04x:%08lxh",blk.top.segm,blk.top.offs);
wsprintf(s2,"%04x:%08lxh",blk.bottom.segm,blk.bottom.offs);
SendDlgItemMessage(hdwnd,Text_Top,WM_SETTEXT,0,(LPARAM)(LPCTSTR)s1);
SendDlgItemMessage(hdwnd,Text_Bottom,WM_SETTEXT,0,(LPARAM)(LPCTSTR)s2);
if(blk.top==nlptr)
strcpy(s3,"Top not set");
else if(blk.bottom==nlptr)
strcpy(s3,"Bottom not set");
else if(blk.top>blk.bottom)
strcpy(s3,"Range is empty");
else
strcpy(s3,"Range set");
SendDlgItemMessage(hdwnd,Text_Status,WM_SETTEXT,0,(LPARAM)(LPCTSTR)s3);
return false;
default:
break;
}
return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif
/************************************************************************
* the xrefs viewer - stops the thread and continues it after *
* displaying the dialog box *
************************************************************************/
void xrefsviewer(void)
{ xrefitem *findit,xtmp;
scheduler.stopthread();
dio.findcurrentaddr(&xtmp.addr);
xtmp.refby=nlptr;
findit=xrefs.findnext(&xtmp);
if(findit==NULL)
{ MessageBox(mainwindow,"Unable to find any xrefs for the location","Borg Message",MB_OK);
}
else if(findit->addr!=xtmp.addr)
{ MessageBox(mainwindow,"There are no xrefs for the current location in the list","Borg Message",MB_OK);
}
else
{ DialogBox((struct HINSTANCE__ *)hInst,MAKEINTRESOURCE(Xrefs_Viewer),mainwindow,(DLGPROC)xrefsbox);
}
scheduler.continuethread();
}
/************************************************************************
* dialog box controls and workings - most message processing is *
* standardised across Borg (colorchanges, etc) *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
bool FAR PASCAL xrefsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static char nseg[20],noffs[20];
static xrefitem *currentsel,xtmp,*vt;
static int numberofitems;
dword st;
dword i;
switch(message)
{ case WM_COMMAND:
{ switch(wParam)
{ case IDC_OKBUTTON:
EndDialog(hdwnd,NULL);
return true;
case IDC_JUMPTOBUTTON:
scheduler.addtask(user_jumptoaddr,priority_userrequest,currentsel->refby,NULL);
EndDialog(hdwnd,NULL);
return true;
case XREFS_DELETE:
scheduler.addtask(user_delxref,priority_userrequest,currentsel->refby,NULL);
scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
if(numberofitems>1)
scheduler.addtask(user_repeatxrefview,priority_userrequest,nlptr,NULL);
EndDialog(hdwnd,NULL);
return true;
default:
break;
}
switch(HIWORD(wParam))
{ case LBN_SELCHANGE:
i=SendDlgItemMessage(hdwnd,IDC_XREFSLISTBOX,LB_GETCURSEL,0,0)+1;
xrefs.findnext(&xtmp);
while(i)
{ vt=xrefs.nextiterator();
i--;
}
currentsel=vt;
return true;
default:
break;
}
}
break;
case WM_INITDIALOG:
CenterWindow(hdwnd);
dio.findcurrentaddr(&xtmp.addr);
xtmp.refby=nlptr;
xrefs.findnext(&xtmp);
vt=xrefs.nextiterator();
currentsel=vt;
numberofitems=0;
if(vt!=NULL)
{ while(vt->addr==xtmp.addr)
{ st=vt->refby.segm;
wsprintf(nseg,"0x%lx",st);
wsprintf(noffs,"0x%lx",vt->refby.offs);
strcat(nseg,":");
strcat(nseg,noffs);
numberofitems++;
SendDlgItemMessage(hdwnd,IDC_XREFSLISTBOX,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)nseg);
vt=xrefs.nextiterator();
if(vt==NULL)
break;
}
}
SendDlgItemMessage(hdwnd,IDC_XREFSLISTBOX,LB_SETCURSEL,0,0);
SetFocus(GetDlgItem(hdwnd,IDC_OKBUTTON));
return false;
default:
break;
}
return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif
/************************************************************************
* segviewer *
* - stops the secondary thread, and calls the dialog box for viewing *
* the segments, then restarts the thread when the dialog box is done. *
************************************************************************/
void segviewer(void)
{ scheduler.stopthread();
DialogBox(hInst,MAKEINTRESOURCE(Seg_Viewer),mainwindow,(DLGPROC)segbox);
scheduler.continuethread();
}
/************************************************************************
* segbox *
* - this is the segment viewer dialog box which shows the segments, and *
* details of them as they are clicked on. It allows jumping to the *
* segments as well. Background analysis is halted when calling this *
* particularly because iterators are used, and they there is only one *
* iterator for the segment list *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
bool FAR PASCAL segbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static string *segt;
static char sstart[20],send[20],ssize[20],stype[20];
static dsegitem *t;
dword st;
dword i;
switch(message)
{ case WM_COMMAND:
{ switch(wParam)
{ case IDC_OKBUTTON:
EndDialog(hdwnd,NULL);
return true;
case IDC_JUMPTOBUTTON:
scheduler.addtask(user_jumptoaddr,priority_userrequest,t->addr,NULL);
EndDialog(hdwnd,NULL);
return true;
default:
break;
}
switch(HIWORD(wParam))
{ case LBN_SELCHANGE:
i=SendDlgItemMessage(hdwnd,IDC_SEGLISTBOX,LB_GETCURSEL,0,0);
dta.resetiterator();
t=dta.nextiterator();
while(i)
{ t=dta.nextiterator();
i--;
}
wsprintf(sstart,"0x%lx",t->addr.offs);
st=t->addr.offs+t->size-1;
wsprintf(send,"0x%lx",st);
wsprintf(ssize,"0x%lx",t->size);
switch(t->typ)
{ case code16:
strcpy(stype,"16-bit Code");
break;
case code32:
strcpy(stype,"32-bit Code");
break;
case data16:
strcpy(stype,"16-bit Data");
break;
case data32:
strcpy(stype,"32-bit Data");
break;
case uninitdata:
strcpy(stype,"Uninit Data");
break;
case debugdata:
strcpy(stype,"Debug Data");
break;
case resourcedata:
strcpy(stype,"Resource Data");
break;
default:
strcpy(stype,"Unknown");
break;
}
SendDlgItemMessage(hdwnd,SEG_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)sstart);
SendDlgItemMessage(hdwnd,SEG_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)send);
SendDlgItemMessage(hdwnd,SEG_TEXTSIZE,WM_SETTEXT,0,(LPARAM)(LPCTSTR)ssize);
SendDlgItemMessage(hdwnd,SEG_TEXTTYPE,WM_SETTEXT,0,(LPARAM)(LPCTSTR)stype);
SendDlgItemMessage(hdwnd,IDC_SEGNAMETEXT,WM_SETTEXT,0,(LPARAM)(LPCTSTR)t->name);
return true;
default:
break;
}
}
break;
case WM_INITDIALOG:
CenterWindow(hdwnd);
segt=new string[dta.numlistitems()];
dta.resetiterator();
for(i=0;i<dta.numlistitems();i++)
{ segt[i]=new char[20];
t=dta.nextiterator();
st=t->addr.segm;
wsprintf(segt[i],"0x%x",st);
st=t->addr.offs;
wsprintf(segt[i]+strlen(segt[i]),":0x%04lx",st);
SendDlgItemMessage(hdwnd,IDC_SEGLISTBOX,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)segt[i]);
}
SendDlgItemMessage(hdwnd,IDC_SEGLISTBOX,LB_SETCURSEL,0,0);
dta.resetiterator();
t=dta.nextiterator();
wsprintf(sstart,"0x%lx",t->addr.offs);
st=t->addr.offs+t->size-1;
wsprintf(send,"0x%lx",st);
wsprintf(ssize,"0x%lx",t->size);
switch(t->typ)
{ case code16:
strcpy(stype,"16-bit Code");
break;
case code32:
strcpy(stype,"32-bit Code");
break;
case data16:
strcpy(stype,"16-bit Data");
break;
case data32:
strcpy(stype,"32-bit Data");
break;
case uninitdata:
strcpy(stype,"Uninit Data");
break;
case debugdata:
strcpy(stype,"Debug Data");
break;
case resourcedata:
strcpy(stype,"Resource Data");
break;
default:
strcpy(stype,"Unknown");
break;
}
SendDlgItemMessage(hdwnd,SEG_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)sstart);
SendDlgItemMessage(hdwnd,SEG_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)send);
SendDlgItemMessage(hdwnd,SEG_TEXTSIZE,WM_SETTEXT,0,(LPARAM)(LPCTSTR)ssize);
SendDlgItemMessage(hdwnd,SEG_TEXTTYPE,WM_SETTEXT,0,(LPARAM)(LPCTSTR)stype);
SendDlgItemMessage(hdwnd,IDC_SEGNAMETEXT,WM_SETTEXT,0,(LPARAM)(LPCTSTR)t->name);
SetFocus(GetDlgItem(hdwnd,IDC_OKBUTTON));
return false;
case WM_DESTROY:
for(i=0;i<dta.numlistitems();i++)
{ SendDlgItemMessage(hdwnd,IDC_SEGLISTBOX,LB_DELETESTRING,(WPARAM)(dta.numlistitems()-i-1),0);
delete segt[dta.numlistitems()-i-1];
}
delete segt;
return true;
default:
break;
}
return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif
/************************************************************************
* getcomment *
* - stops the thread and gets a comment from the user to be added to *
* the disassembly database, and posts a windowupdate request. *
************************************************************************/
void getcomment(void)
{ scheduler.stopthread();
DialogBox(hInst,MAKEINTRESOURCE(Comment_Editor),mainwindow,(DLGPROC)getcommentbox);
scheduler.continuethread();
}
/************************************************************************
* getcommentbox *
* - this is the small dialog box for getting a comment from the user. *
* - it determines the current address, and obtains a comment, adding it *
* to the database, and deleting any previous comment. *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
bool FAR PASCAL getcommentbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static lptr loc;
dsmitem titem,*tblock;
char *newcomment;
switch(message)
{ case WM_COMMAND:
{ switch(wParam)
{ case IDOK:
EndDialog(hdwnd,NULL);
newcomment= new char[80];
SendDlgItemMessage(hdwnd,IDC_COMMENTEDIT,WM_GETTEXT,(WPARAM)80,(LPARAM)newcomment);
scheduler.addtask(user_delcomment,priority_userrequest,loc,NULL);
if(strlen((char *)newcomment))
scheduler.addtask(user_addcomment,priority_userrequest,loc,newcomment);
return true;
case IDCANCEL:
EndDialog(hdwnd,NULL);
return true;
default:
break;
}
}
break;
case WM_INITDIALOG:
CenterWindow(hdwnd);
// need to get any initial comments and stuff into edit box.
dio.findcurrentaddr(&loc);
titem.addr=loc;
titem.type=dsmnull;
dsm.findnext(&titem);
tblock=dsm.nextiterator();
if(tblock!=NULL)
while(tblock->addr==loc)
{ if(tblock->type==dsmcomment)
{ SendDlgItemMessage(hdwnd,IDC_COMMENTEDIT,WM_SETTEXT,(WPARAM)0,(LPARAM)tblock->tptr);
break;
}
tblock=dsm.nextiterator();
if(tblock==NULL)
break;
}
SetFocus(GetDlgItem(hdwnd,IDC_COMMENTEDIT));
return false;
default:
break;
}
return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -