首页
社区
课程
招聘
[求助]关于OD的汇编引擎assemble函数
发表于: 2009-6-8 14:56 4315

[求助]关于OD的汇编引擎assemble函数

2009-6-8 14:56
4315
最近因为想用用OD的反汇编引擎源码,但对其中的汇编函数的第二个参数使用目的和用法不是很明确,请高人指点下,应该写过OD插件的达人是知道的,下面是它的英语原文说明:

Function Assemble, as expected, converts command in ASCII form to binary 32-bit code. It shares command table with Disasm, so if some command can be disassembled, it can be assembled back too, with one exception: Assemble doesn't support 16-bit addresses. Some commands have more than one encoding. By calling Assemble with parameter attempt=0,1... and constsize=0,1,2,3 one can get alternative variants and then select the shortest possible form (this is how OllyDbg implements assembling). However, only one address form is generated in each case ([EAX*2] but not [EAX+EAX]; [EBX+EAX] but not [EAX+EBX]; [EAX] will not use SIB byte; no DS: prefix and so on). 

Assemble compiles imprecise commands (where, for example, R32 replaces any general-purpose 32-bit register). This allows to generate imprecise search patterns, where mask contains zeros at the position occupied in code by register). Returns number of bytes in assembled code or non-positive number in case of detected error or when variant selected by combination of attempt and constsize doesn't exist. This number is the negative position of error in the input command.

int Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt,int constsize,char *errtext);

Parameters:

cmd - pointer to zero-terminated ASCII command;

ip - address of the generated binary code in memory;

model - pointer to structure that receives machine code and mask;

attempt - index of alternative verison of the command. Call Assemble with attempt=0,1,2... to obtain all possible versions of the command. Stop this sequence when Assemble reports error;

constsize - requested size of address constant and immediate data. Call Assemble with constsize=0,1,2,3 to obtain all possible variants of the version selected by attempt;

errtext - pointer to text buffer of length at least TEXTLEN that receives description of detected error.

See also: Disasm

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//