opdis.c

来自「Fenris是一个检测并把高层次的语言结构做成文档的多功能故障检测器、调试器、代」· C语言 代码 · 共 60 行

C
60
字号
/*   fenris - program execution path analysis tool   ---------------------------------------------   Copyright (C) 2001, 2002 by Bindview Corporation   Portions copyright (C) 2001, 2002 by their respective contributors   Developed and maintained by Michal Zalewski <lcamtuf@coredump.cx>   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   This code is taken from cxmon utility, http://www.uni-mainz.de/~bauec002/,   written by Christian Bauer and Marc Hellwig. Most of their code was   taken from GNU binutils libopcode for i386, which is probably   authored mostly by Pace Willisson. I made several changes, changed   the notation a bit and removed some code, but I'm not the one to take   credit for the functionality of this code (or lack of thereof ;-).*/#include <stdarg.h>#include <stdio.h>#include "nasm/disasm.h"#include "nasm/insns.h" // for pref cpuextern char* describe_address(unsigned int addr);int disass_x86(FILE *f, unsigned int adr) {  char outbuf[256];  long lendis;  char* x;    lendis = disasm((unsigned char*) adr, outbuf, 32, adr, 0 /*FALSE*/, IF_PENT);    fprintf(f,"%08x",adr);  x=describe_address(adr);  if (strlen(x)) fprintf(f," [%s]",x);  fprintf(f, ": \t%s\n", outbuf);    return lendis;}void disass (const char* buf,unsigned int addr,unsigned int len) {  int add=addr;  while (add <= addr+len)    add+=disass_x86(stderr,add);}

⌨️ 快捷键说明

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