| shuai 的个人资料娱乐精神照片日志 | 帮助 |
|
2007/12/14 强暴.Net程序集 之十三 (反汇编之反汇编输出)警告:本系列文章为本人原创,只作技术研究之用,您可以引用链接传播,禁止其它的转载方式,禁止用于商业或非法目的, 对于造成的一切后果本人概不负责
首先, 得到当前的指令, 注意处理双字节的情况(以0xFE开始的字节)
BYTE b = source[index]; index++; if(IsPrefix(b)) { b = source[index]; index++; current = (opcode)twoByteOpcodes[b]; } else { current = (opcode)oneByteOpcodes[b]; } 直接输出current的Instruction成员就是当前指令的字符串表示
然后, 根据类型, 得到操作数
switch(current.Type()) { case Switch: switchCount = *((DWORD*)&source[index]); index += 4; operand = &source[index]; index += switchCount * sizeof(DWORD); break; case Token: operand = &source[index]; break; case Branch: operand = &source[index]; index += current.OperandSize(); break; case Index: operand = &source[index]; index += current.OperandSize(); break; case Value: operand = &source[index]; index += current.OperandSize(); break; } 对于 Token和Value类型的操作数应该以16进制字符串形式输出, 可能引用了其它表比如MethodRef中的方法Token, 或是字符串流的Token
对于Branch类型它是方法内的指令相对地址, 在ildasm以IL_000000X形式输出 最后, 不断移动index, 得到下一条指令, 这样就可以完成整个方法的反汇编输出
引用通告此日志的引用通告 URL 是: http://iauhsgnay.spaces.live.com/blog/cns!C7C5DB6D46321CDD!452.trak 引用此项的网络日志
|
|
|