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

📄 user_dlg.cpp

📁 十分经典的开源反编译工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
					 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

/************************************************************************
* changeoep                                                             *
* - stops the thread and gets an address from the user for the new oep  *
************************************************************************/
void changeoep(void)
{ if(floader.exetype!=PE_EXE)
  { MessageBox(mainwindow,"Can only change the oep for PE files","Borg",MB_OK);
    return;
  }
  scheduler.stopthread();
  DialogBox(hInst,MAKEINTRESOURCE(OEP_Editor),mainwindow,(DLGPROC)getoepbox);
  scheduler.continuethread();
}

/************************************************************************
* getoepbox                                                             *
* - this is the small dialog box for getting an address from the user.  *
* - it will change the program entry point to that address and patch    *
*   the program if necessary. The current viewing address is also       *
*   changed to the new address.                                         *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
BOOL CALLBACK getoepbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static lptr loc;
  char newaddr[80];
  bool patchit;
  switch(message)
  { case WM_COMMAND:
	  switch(wParam)
	  { case IDOK:
		  EndDialog(hdwnd,NULL);
          SendDlgItemMessage(hdwnd,IDC_OEPEDIT,WM_GETTEXT,(WPARAM)80,(LPARAM)newaddr);
		  dio.findcurrentaddr(&loc);
          if(strlen(newaddr))
          { if(sscanf(newaddr,"%x",&loc.offs)==1)
		      if(dta.findseg(loc)!=NULL)
		      { dio.savecuraddr();
			    dio.setcuraddr(loc);
			    scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
		      }
		  }
		  /* apply new start point */
          scheduler.addtask(nameloc,priority_userrequest,options.oep,"");
		  options.oep=loc;
		  scheduler.addtask(nameloc,priority_userrequest,options.oep,"start");
		  if(SendDlgItemMessage(hdwnd,IDC_PATCHOEP,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
		    patchit=true;
		  else 
		    patchit=false;
		  if(options.readonly&&patchit)
		  { MessageBox(hdwnd,"Program is opened read only, can't patch it, sorry",
		       "Borg - Change OEP",MB_OK);
		    patchit=false;
		  }
  		  if(patchit)
		  { /* and patch executable */
		    floader.patchoep();
		  }
		  return true;
		case IDCANCEL:
		  EndDialog(hdwnd,NULL);
		  return true;
        default:
          break;
	  }
	  break;
	case WM_INITDIALOG:
      CenterWindow(hdwnd);
      SetFocus(GetDlgItem(hdwnd,IDC_OEPEDIT));
	  if(!options.readonly)
        SendDlgItemMessage(hdwnd,IDC_PATCHOEP,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
	  return false;
    default:
      break;
  }
  return false;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif

/************************************************************************
* jumpto                                                                *
* - stops the thread and gets an address from the user to be jumped to  *
************************************************************************/
void jumpto(void)
{ scheduler.stopthread();
  DialogBox(hInst,MAKEINTRESOURCE(Jaddr_Editor),mainwindow,(DLGPROC)getjaddrbox);
  scheduler.continuethread();
}

/************************************************************************
* getjaddrbox                                                           *
* - this is the small dialog box for getting an address from the user.  *
* - it changes the current viewing location to that address.            *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
BOOL CALLBACK getjaddrbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static lptr loc;
  char newaddr[80];
  switch(message)
  { case WM_COMMAND:
	  switch(wParam)
	  { case IDOK:
		  EndDialog(hdwnd,NULL);
          SendDlgItemMessage(hdwnd,IDC_JADDREDIT,WM_GETTEXT,(WPARAM)80,(LPARAM)newaddr);
		  dio.findcurrentaddr(&loc);
          if(strlen(newaddr))
          { if(sscanf(newaddr,"%x",&loc.offs)==1)
		      if(dta.findseg(loc)!=NULL)
		      { dio.savecuraddr();
			    dio.setcuraddr(loc);
			    scheduler.addtask(windowupdate,priority_window,nlptr,NULL);
		      }
		  }
		  return true;
		case IDCANCEL:
		  EndDialog(hdwnd,NULL);
		  return true;
        default:
          break;
	  }
	  break;
	case WM_INITDIALOG:
      CenterWindow(hdwnd);
      SetFocus(GetDlgItem(hdwnd,IDC_JADDREDIT));
	  return false;
    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 CALLBACK getcommentbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ static lptr loc;
  dsmitem titem,*tblock;
  char newcomment[80];
  switch(message)
  { case WM_COMMAND:
		{	switch(wParam)
		  { case IDOK:
				EndDialog(hdwnd,NULL);
            	SendDlgItemMessage(hdwnd,IDC_COMMENTEDIT,WM_GETTEXT,(WPARAM)80,(LPARAM)newcomment);
            scheduler.addtask(user_delcomment,priority_userrequest,loc,NULL);
            if(strlen(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 + -