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

📄 dasm.cpp

📁 十分经典的开源反编译工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/************************************************************************
*                  Dasm.cpp                                             *
*                                                                       *
*              Borg Disassembler                                        *
*                    v2.28                                              *
*                 by Cronos                                             *
*                                                                       *
* Contributors:                                                         *
* Thanks to Mark Ogden for many bugfixes and mods for assembly under    *
* VC++, in its early stages (v2 beta builds). Also changes from         *
* wvsprintf to wsprintf to allow compilation under VC++.                *
* Thanks to Eugen Polukhin for some interesting alternate code and      *
* ideas around v2.11 and feedback on fonts, etc.                        *
* Thanks to Pawe3 Kunio for a lot of coding ideas and advice re C++     *
* usage around v2.22                                                    *
* Thanks to Howard Chu for some coding additions on default names, and  *
* more block functions                                                  *
************************************************************************/

/************************************************************************
* dasm.cpp                                                              *
* - this whole file is a declaration and global routine dumping area    *
* - it includes winmain and the main message callback routine, along    *
*   with initialisation code and the registry read/write code, odd      *
*   dialog boxes and helper functions for the main routines. The whole  *
*   file is a bit of a mish-mash of stuff which hasnt found its way     *
*   elsewhere.                                                          *
* - a lot of the code in here has grown, and i mean grown from the      *
*   ground up, and at some point it will require reorganisation, or     *
*   maybe that point was long ago....                                   *
************************************************************************/

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

#include "resource.h"
#include "exeload.h"
#include "data.h"
#include "schedule.h"
#include "proctab.h"
#include "disasm.h"
#include "dasm.h"
#include "mainwind.h"
#include "gname.h"
#include "xref.h"
#include "relocs.h"
#include "srch.h"
#include "disio.h"
#include "range.h"
#include "decrypt.h"
#include "registry.h"
#include "help.h"
#include "user_dlg.h"
#include "database.h"
#include "dlg_ldop.h"
#include "user_fn.h"

/************************************************************************
* decaration dumping ground........                                     *
************************************************************************/
CRITICAL_SECTION cs;
volatile bool KillThread;
volatile bool InThread;
globaloptions options;

fileloader floader;
dataseg dta;
schedule scheduler;
disasm dsm;
disio dio;
xref xrefs;
gname import;
gname expt;
gname name;
relocs reloc;
range blk;
decrypt decrypter;

LRESULT CALLBACK dasm(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK shutbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam);
bool TestThread(void);
void optionsinit(void);
bool savefile_text(HWND hwnd,bool printaddrs,bool block);
void setupfont(void);
HFONT cf=NULL;

char winname[300];
HINSTANCE hInst;
HWND hwndStatusBar;
HANDLE ThreadHandle;
HWND mainwindow;
DWORD ThreadId;
RECT mainwnd,mainwndsize,StatusWindowSize;
int cxChar,cyChar;
HMENU rmenu;
bool charinputenabled=false;

char szWinName[]="Dasm";
char program_name[]="Borg Disassembler";
char current_exe_name[MAX_PATH*2];

/************************************************************************
* WinMain..... it all starts here                                       *
************************************************************************/
#ifdef __BORLANDC__
#pragma warn -par
#endif
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst,LPSTR lpszArgs,int nWinMode)
{ HWND hwnd;
  MSG msg;
  WNDCLASSEX wcl;
  int cx,cy;
  INITCOMMONCONTROLSEX icc;

  icc.dwSize=sizeof(INITCOMMONCONTROLSEX);
  icc.dwICC=ICC_BAR_CLASSES;

  InitCommonControlsEx(&icc);

  cx=GetSystemMetrics(SM_CXFULLSCREEN);
  cy=GetSystemMetrics(SM_CYFULLSCREEN);
  /* Define window class */
  wcl.hInstance=hThisInst;
  wcl.lpszClassName=szWinName;
  wcl.lpfnWndProc=dasm;
  wcl.style=CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;

  wcl.cbSize=sizeof(WNDCLASSEX);

  wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
  wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO);

  wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
  wcl.lpszMenuName=MAKEINTRESOURCE(main_menu);

  wcl.cbClsExtra=0;
  wcl.cbWndExtra=0;
  // this was causing the flickering.........damn thing
  wcl.hbrBackground=NULL;//(HBRUSH)(COLOR_APPWORKSPACE+1);

  hInst=hThisInst;

  /* Register window class */
  if(!RegisterClassEx(&wcl))
    return 0;

  /* Create window */
  sprintf(winname,"Borg Disassembler v%0d.%2d",(int)BORG_VER/100,BORG_VER%100);
  hwnd=CreateWindow(szWinName,winname,WS_OVERLAPPEDWINDOW,
			 cx/2-320,cy/2-230,640,480,
			 NULL,NULL,hThisInst,NULL);

  mainwndsize.top=0;
  mainwndsize.bottom=cy-1;
  mainwndsize.left=0;
  mainwndsize.right=cx-1;

  /* Display window */
  ShowWindow(hwnd,nWinMode);
  UpdateWindow(hwnd);

  /* Message Loop */
  while(GetMessage(&msg,NULL,0,0))
  { TranslateMessage(&msg);
	 DispatchMessage(&msg);
  }

  return msg.wParam;
}
#ifdef __BORLANDC__
#pragma warn +par
#endif

/************************************************************************
* dasm                                                                  *
* - dasm is the application main window.                                *
* - everything the main window does is in this routine (for now) and    *
*   where a response is quick it appears in one of its helper functions *
*   later in this file, otherwise it has been substantial enough to     *
*   warrant its own file and routines........                           *
* - this is long                                                        *
************************************************************************/
LRESULT CALLBACK dasm(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{ HDC hdc;
  TEXTMETRIC tm;
  POINT point;
  lptr scrll;
  int killcount;
  mainwindow=hwnd;
  RECT tmp_rect;
  switch(message)
  { case WM_COMMAND:
	  switch(LOWORD(wParam))
	  { case file_exit:
		  SendMessage(mainwindow,WM_CLOSE,0,0);
		  break;
		case file_save:
		  savefile_text(hwnd,true,false);
		  break;
        case get_comment:
          getcomment();
          break;
		case jump_to:
		  jumpto();
		  break;
		case change_oep:
		  changeoep();
		  break;
		case save_database:
		  savedb();
		  break;
		case load_database:
		  loaddb();
		  break;
		case save_asm:
		  savefile_text(hwnd,false,false);
		  break;
        case block_saveasm:
		  savefile_text(hwnd,false,true);
		  break;
        case block_savetext:
		  savefile_text(hwnd,true,true);
		  break;
        case cm_decrypt:
          decrypterdialog();
          break;
		case file_open:
		  newfile();
		  break;
		case view_segment:
		  segviewer();
		  break;
		case view_names:
		  namesviewer();
		  break;
		case view_imports:
		  importsviewer();
		  break;
		case view_exports:
		  exportsviewer();
		  break;
	    case view_xrefs:
		  xrefsviewer();
		  break;
		case make_code:
		  scheduler.addtask(user_makecode,priority_userrequest,nlptr,NULL);
		  break;
		case make_dword:
		  scheduler.addtask(user_makedword,priority_userrequest,nlptr,NULL);
		  break;
        case float_single:
		  scheduler.addtask(user_makesingle,priority_userrequest,nlptr,NULL);
		  break;
        case float_double:
		  scheduler.addtask(user_makedouble,priority_userrequest,nlptr,NULL);
		  break;
        case float_longdouble:
		  scheduler.addtask(user_makelongdouble,priority_userrequest,nlptr,NULL);
		  break;
		case make_word:
		  scheduler.addtask(user_makeword,priority_userrequest,nlptr,NULL);
		  break;
		case make_string:
		  scheduler.addtask(user_makestring,priority_userrequest,nlptr,NULL);
		  break;
		case pascal_string:
		  scheduler.addtask(user_pascalstring,priority_userrequest,nlptr,NULL);
		  break;
		case uc_string:
		  scheduler.addtask(user_ucstring,priority_userrequest,nlptr,NULL);
		  break;
		case up_string:
		  scheduler.addtask(user_upstring,priority_userrequest,nlptr,NULL);
		  break;
		case dos_string:
		  scheduler.addtask(user_dosstring,priority_userrequest,nlptr,NULL);
		  break;
		case general_string:
		  scheduler.addtask(user_generalstring,priority_userrequest,nlptr,NULL);
		  break;
		case argover_dec:
		  scheduler.addtask(user_argoverdec,priority_userrequest,nlptr,NULL);
		  break;
		case arg_single:
		  scheduler.addtask(user_argsingle,priority_userrequest,nlptr,NULL);
		  break;
		case argover_hex:
		  scheduler.addtask(user_argoverhex,priority_userrequest,nlptr,NULL);
		  break;
        case argnegate:
          scheduler.addtask(user_argnegate,priority_userrequest,nlptr,NULL);
          break;
		case offset_dseg:
		  scheduler.addtask(user_argoveroffsetdseg,priority_userrequest,nlptr,NULL);
		  break;
		case argover_char:
		  scheduler.addtask(user_argoverchar,priority_userrequest,nlptr,NULL);
		  break;
		case undefine_line:
		  scheduler.addtask(user_undefineline,priority_userrequest,nlptr,NULL);
		  break;
		case undefine_lines:
		  scheduler.addtask(user_undefinelines,priority_userrequest,nlptr,NULL);
		  break;
		case undefine_lines_long:
		  scheduler.addtask(user_undefinelines_long,priority_userrequest,nlptr,NULL);

⌨️ 快捷键说明

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