⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_dlg.cpp

📁 十分经典的开源反编译工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/************************************************************************
* dlg_view.cpp                                                          *
* - the functions here are viewers for various lists within Borg, for   *
*   example exports,imports and xrefs Dialog box viewers, along with    *
*   any calling functions which stop/start the secondary thread.        *
* - Extracted from various classes v2.22                                *
* - All routines in here when entered from outside should stop the      *
*   secondary thread and restart it on exit.                            *
************************************************************************/

#include <windows.h>
#include <stdio.h>

#include "resource.h"
#include "dasm.h"
#include "schedule.h"
#include "xref.h"
#include "range.h"
#include "gname.h"
#include "disio.h"
#include "data.h"
#include "disasm.h"
#include "debug.h"
#include "exeload.h"

/************************************************************************
* global variables                                                      *
* nme is used to hold a name entered in a dialog                        *
************************************************************************/
char *nme;

/************************************************************************
* forward declarations                                                  *
************************************************************************/
BOOL CALLBACK exportsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK importsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK namesbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK getnamebox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK blockbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK xrefsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK segbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK getcommentbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK getjaddrbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK getoepbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);

/************************************************************************
* exportsviewer                                                         *
* - stops the thread and displays the exports viewer dialog.            *
************************************************************************/
void exportsviewer(void)
{ scheduler.stopthread();
  if(!expt.numlistitems())
  { MessageBox(mainwindow,"There are no exports in the list","Borg Message",MB_OK);
  }
  else
  { DialogBox(hInst,MAKEINTRESOURCE(Exports_Viewer),mainwindow,(DLGPROC)exportsbox);
  }
  scheduler.continuethread();
}

/************************************************************************
* exportsbox                                                            *
* - this is the exports viewer dialog box. It is simpler than the names *
*   class dialog box, featuring only a jump to option. As for the names *
*   class a request is added to the scheduler for any jump and the      *
*   dialog box exits. the main code is for filling the initial list box *
*   and for displaying a new address when the selection is changed      *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
BOOL CALLBACK exportsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static char nseg[20],noffs[20];
  static gnameitem *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_EXPORTSLISTBOX,LB_GETCURSEL,0,0)+1;
				expt.resetiterator();
				while(i)
				{ t=expt.nextiterator();
				  i--;
				}
				st=t->addr.segm;
				wsprintf(nseg,"0x%lx",st);
				wsprintf(noffs,"0x%lx",t->addr.offs);
				SendDlgItemMessage(hdwnd,EXPORTS_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)nseg);
				SendDlgItemMessage(hdwnd,EXPORTS_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)noffs);
            return true;
			 default:
				break;
		  }
		}
		break;
	 case WM_INITDIALOG:
      CenterWindow(hdwnd);
		expt.resetiterator();
		for(i=0;i<expt.numlistitems();i++)
		{ t=expt.nextiterator();
		  SendDlgItemMessage(hdwnd,IDC_EXPORTSLISTBOX,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)t->name);
		}
		SendDlgItemMessage(hdwnd,IDC_EXPORTSLISTBOX,LB_SETCURSEL,0,0);
		expt.resetiterator();
		t=expt.nextiterator();
		st=t->addr.segm;
		wsprintf(nseg,"0x%lx",st);
		wsprintf(noffs,"0x%lx",t->addr.offs);
		SendDlgItemMessage(hdwnd,EXPORTS_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)nseg);
		SendDlgItemMessage(hdwnd,EXPORTS_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)noffs);
		SetFocus(GetDlgItem(hdwnd,IDC_OKBUTTON));
		return false;
    default:
      break;
  }
  return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif

/************************************************************************
* importsviewer                                                         *
* - stops the thread and displays the imports viewer dialog.            *
************************************************************************/
void importsviewer(void)
{ scheduler.stopthread();
  if(!import.numlistitems())
  { MessageBox(mainwindow,"There are no imports in the list","Borg Message",MB_OK);
  }
  else
  { DialogBox(hInst,MAKEINTRESOURCE(Imports_Viewer),mainwindow,(DLGPROC)importsbox);
  }
  scheduler.continuethread();
}

/************************************************************************
* importsbox                                                            *
* - this is the imports viewer dialog box, it is similar to the exports *
*   and names dialog, although simpler since there is only an ok button *
*   Most of the code is for filling the list box and displaying info    *
*   when an item is selected                                            *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
BOOL CALLBACK importsbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static char nseg[20],noffs[20];
  static gnameitem *t;
  dword st;
  dword i;
  switch(message)
  { case WM_COMMAND:
		{	switch(wParam)
		  { case IDC_OKBUTTON:
				EndDialog(hdwnd,NULL);
				return true;
			 default:
				break;
		  }
		  switch(HIWORD(wParam))
		  { case LBN_SELCHANGE:
				i=SendDlgItemMessage(hdwnd,IDC_IMPORTSLISTBOX,LB_GETCURSEL,0,0)+1;
				import.resetiterator();
				while(i)
				{ t=import.nextiterator();
				  i--;
				}
				st=t->addr.segm;
				wsprintf(nseg,"0x%lx",st);
				wsprintf(noffs,"0x%lx",t->addr.offs);
				SendDlgItemMessage(hdwnd,IMPORTS_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)nseg);
				SendDlgItemMessage(hdwnd,IMPORTS_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)noffs);
				return true;
			 default:
				break;
		  }
		}
		break;
	 case WM_INITDIALOG:
      CenterWindow(hdwnd);
		import.resetiterator();
		for(i=0;i<import.numlistitems();i++)
		{ t=import.nextiterator();
		  SendDlgItemMessage(hdwnd,IDC_IMPORTSLISTBOX,LB_ADDSTRING,0,(LPARAM) (LPCTSTR)t->name);
		}
		SendDlgItemMessage(hdwnd,IDC_IMPORTSLISTBOX,LB_SETCURSEL,0,0);
		import.resetiterator();
		t=import.nextiterator();
		st=t->addr.segm;
		wsprintf(nseg,"0x%lx",st);
		wsprintf(noffs,"0x%lx",t->addr.offs);
		SendDlgItemMessage(hdwnd,IMPORTS_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)nseg);
		SendDlgItemMessage(hdwnd,IMPORTS_TEXTEND,WM_SETTEXT,0,(LPARAM)(LPCTSTR)noffs);
		SetFocus(GetDlgItem(hdwnd,IDC_OKBUTTON));
		return false;
    default:
      break;
  }
  return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif

/************************************************************************
* namelocation                                                          *
* - this calls the user dialog for a name to be entered for the current *
*   location, and names it                                              *
************************************************************************/
void namelocation(void)
{ lptr loc;
  scheduler.stopthread();
  nme=NULL;
  DialogBox(hInst,MAKEINTRESOURCE(Get_Name),mainwindow,(DLGPROC)getnamebox);
  if(nme!=NULL)
  { dio.findcurrentaddr(&loc);
    scheduler.addtask(namecurloc,priority_userrequest,loc,nme);
  }
  scheduler.continuethread();
}

/************************************************************************
* namesviewer                                                           *
* - this controls the display of the names viewer dialog box. names are *
*   viewed in the dialog box in location order.                         *
************************************************************************/
void namesviewer(void)
{ scheduler.stopthread();
  if(!name.numlistitems())
  { MessageBox(mainwindow,"There are no names in the list","Borg Message",MB_OK);
  }
  else
  { DialogBox(hInst,MAKEINTRESOURCE(Names_Viewer),mainwindow,(DLGPROC)namesbox);
  }
  scheduler.continuethread();
}

/************************************************************************
* namesbox                                                              *
* - the dialog box for the names list.                                  *
* - the list is a simple location order of names, which is the same as  *
*   the underlying list class ordering                                  *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
BOOL CALLBACK namesbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static char nseg[20],noffs[20];
  static gnameitem *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;
			 case NAMES_DELETE:
				name.delname(t->addr);
            scheduler.addtask(user_repeatnameview,priority_userrequest,nlptr,NULL);
				EndDialog(hdwnd,NULL);
				return true;
			 case NAMES_RENAME:
				nme=NULL;
				DialogBox(hInst,MAKEINTRESOURCE(Get_Name),hdwnd,(DLGPROC)getnamebox);
				if(nme!=NULL)
              scheduler.addtask(namecurloc,priority_userrequest,t->addr,nme);
            scheduler.addtask(user_repeatnameview,priority_userrequest,nlptr,NULL);
				EndDialog(hdwnd,NULL);
            return true;
			 default:
				break;
		  }
		  switch(HIWORD(wParam))
		  { case LBN_SELCHANGE:
				i=SendDlgItemMessage(hdwnd,IDC_NAMESLISTBOX,LB_GETCURSEL,0,0)+1;
				name.resetiterator();
				while(i)
				{ t=name.nextiterator();
				  i--;
				}
				st=t->addr.segm;
				wsprintf(nseg,"0x%lx",st);
				wsprintf(noffs,"0x%lx",t->addr.offs);
				SendDlgItemMessage(hdwnd,NAMES_TEXTSTART,WM_SETTEXT,0,(LPARAM)(LPCTSTR)nseg);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -