如何将汇编代码片段转换为二进制机器代码片段? [英] How to translate assembly code snippet into binary machine code snippet?

查看:138
本文介绍了如何将汇编代码片段转换为二进制机器代码片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将x86汇编代码段(不是完整程序)自动转换为相应的二进制机器代码段?

Is it possible to automatically translate x86 assembly code snippet (not full program) to corresponding binary machine code snippet?

例如:

xor eax, eax
mov [ebx + 12], eax

进入:

31 c0
89 43 0c

我真的只需要相应的字节集.通常,我必须查看一些指令集参考并手动翻译它,但是我很确定有一些程序可以自动执行它.

I really need only corresponding set of bytes. Normally I would have to look into some instructions set reference and translate it manually, but I'm quite sure that there is some program that does it automatically.

如果您知道这样的工具,请告诉我它的名称或分享链接.

If you know such tool, please tell me its name or share a link.

推荐答案

我针对此问题进行了变通.它可以在Windows平台上运行,并使用Visual Studio附带的ML64汇编器. 我使用以下模板创建了template.asm文件:

I did a workaround to my problem. It works on Windows platforms and uses ML64 assembler that goes with Visual Studio. I created a template.asm file with this template:

    .code

main proc
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop

; -------------------------------------------
; enter assembly code here
; -------------------------------------------

    mov [ebx + 12], eax
    xor eax, eax

; -------------------------------------------

    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
main endp

end

然后我将其编译为:

ml64 /c template.asm

知道nop指令已转换为0x90后,我可以编写一个程序来搜索两个10 x 0x90字节块之间的字节.

Knowing that nop instruction is translated to 0x90 I can write a program that searches for bytes between two blocks of 10 x 0x90 bytes.

这篇关于如何将汇编代码片段转换为二进制机器代码片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆