资源简介
libdasm包含pydasm,是安装pydbg过程中必不可少的包,具体安装过程请访问我的博客,原地址:https://code.google.com/archive/p/libdasm/downloads
代码片段和文件信息
/*
* libdasm -- simple x86 disassembly library
* (c) 2004 - 2006 jt / nologin.org
*
* libdasm.c:
* This file contains most code of libdasm. Check out
* libdasm.h for function definitions.
*
*/
#include
#include
#include “libdasm.h“
#include “opcode_tables.h“
// Endianess conversion routines (thanks Ero)
__inline__ BYTE FETCH8(BYTE *addr) {
// So far byte cast seems to work on all tested platforms
return *(BYTE *)addr;
}
__inline__ WORD FETCH16(BYTE *addr) {
#if defined __X86__
// Direct cast only for x86
return *(WORD *)addr;
#else
// Revert to memcpy
WORD val;
memcpy(&val addr 2);
#if defined __LITTLE_ENDIAN__
return val;
#else
return ((val & 0xff00) >> 8) |
((val & 0x00ff) << 8);
#endif // __LITTLE_ENDIAN__
#endif // __X86__
}
__inline__ DWORD FETCH32(BYTE *addr) {
#if defined __X86__
return *(DWORD *)addr;
#else
DWORD val;
memcpy(&val addr 4);
#if defined __LITTLE_ENDIAN__
return val;
#else
return ((val & (0xff000000)) >> 24) |
((val & (0x00ff0000)) >> 8) |
((val & (0x0000ff00)) << 8) |
((val & (0x000000ff)) << 24);
#endif // __LITTLE_ENDIAN__
#endif // __X86__
}
// Check for address/operand size override
__inline__ enum Mode MODE_CHECK_ADDR(enum Mode mode int flags) {
if (((mode == MODE_32) && (MASK_PREFIX_ADDR(flags) == 0)) ||
((mode == MODE_16) && (MASK_PREFIX_ADDR(flags) == 1)))
return MODE_32;
else
return MODE_16;
}
__inline__ enum Mode MODE_CHECK_OPERAND(enum Mode mode int flags) {
if (((mode == MODE_32) && (MASK_PREFIX_OPERAND(flags) == 0)) ||
((mode == MODE_16) && (MASK_PREFIX_OPERAND(flags) == 1)))
return MODE_32;
else
return MODE_16;
}
// Parse 2 and 3-byte opcodes
int get_real_instruction2(BYTE *addr int *flags) {
switch (*addr) {
// opcode extensions for 2-byte opcodes
case 0x00:
// Clear extension
*flags &= 0xffffff00;
*flags |= EXT_G6;
break;
case 0x01:
*flags &= 0xffffff00;
*flags |= EXT_G7;
break;
case 0x71:
*flags &= 0xffffff00;
*flags |= EXT_GC;
break;
case 0x72:
*flags &= 0xffffff00;
*flags |= EXT_GD;
break;
case 0x73:
*flags &= 0xffffff00;
*flags |= EXT_GE;
break;
case 0xae:
*flags &= 0xffffff00;
*flags |= EXT_GF;
break;
case 0xba:
*flags &= 0xffffff00;
*flags |= EXT_G8;
break;
case 0xc7:
*flags &= 0xffffff00;
*flags |= EXT_G9;
break;
default:
break;
}
return 0;
}
// Parse instruction flags get opcode index
int get_real_instruction(BYTE *addr int *index int *flags) {
switch (*addr) {
// 2-byte opcode
case 0x0f:
*index += 1;
*flags |= EXT_T2;
break;
// Prefix group 2
case 0x2e:
*index += 1;
// Clear previous flags from same group (undefined effect)
*flags &= 0xff00ffff;
*flags |= PREFIX_CS_OVERRIDE;
get_real_instruction(addr + 1 index flags);
break;
case 0x36:
*index += 1;
*flags &= 0xff00ffff;
*flags |= PREFIX_SS_OVERRIDE;
get_real_instruction(addr + 1 ind
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-02-25 22:39 examples\
文件 3890 2009-05-08 05:50 examples\das.c
文件 284 2009-05-08 05:50 examples\Makefile
文件 413 2009-05-08 05:50 examples\README.txt
文件 753 2009-05-08 05:50 examples\simple.c
文件 130 2009-05-16 18:58 examples\test32.bin
目录 0 2010-02-25 22:39 pydasm\
文件 2567 2010-02-25 22:33 pydasm\das.py
文件 22002 2010-02-14 22:20 pydasm\pydasm.c
文件 1529 2009-05-08 05:50 pydasm\README.txt
文件 481 2009-05-08 05:50 pydasm\setup.py
目录 0 2010-02-25 22:39 rbdasm\
文件 27732 2009-05-08 05:50 rbdasm\dasm.c
文件 2190 2009-05-08 05:50 rbdasm\dasm.rb.ut.rb
文件 39 2009-05-08 05:50 rbdasm\extconf.rb
文件 2970 2009-05-08 05:50 rbdasm\Makefile
文件 5882 2010-02-25 22:33 HISTORY.txt
文件 293234 2009-05-17 11:03 opcode_tables.h
文件 785 2009-05-08 05:50 LIB.txt
文件 31201 2009-05-08 05:50 libdasm.c
文件 344 2009-05-08 05:50 libdasm.def
文件 17199 2009-05-08 05:50 libdasm.h
文件 605 2009-05-08 05:50 Makefile
文件 183 2009-05-08 05:50 Makefile.msvc
文件 14460 2009-05-08 05:50 README.txt
文件 161 2009-05-08 05:50 TODO.txt
- 上一篇:iText7——第五章源代码工程
- 下一篇:conf-directory.zip
评论
共有 条评论