weixin_39814369
weixin_39814369
2020-11-28 07:36

MASM Support

Is MASM support a coming feature? In the code it is mentioned but currently unsupported.

This would be a great feature since many universities use the "Assembly Language for x86 Processors, 7th edition" textbook which is written for MASM syntax.

With this support many great education tools could exist (in combination with Unicorn) to benefit students.

该提问来源于开源项目:keystone-engine/keystone

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39630735 weixin_39630735 5月前

    I created a while ago some include files for use with masm x86 and for jwasm/uasm x64 assemblers. Ive updated them and done a pull request to include bindings/masm folder with them inside it, hopefully that will help.

    Additionally I couldnt see a way of compiling the keystone dll to x64, maybe needs an additional target under the llvm to support that. In the past I took the x86 and x64 dll and lib files for keystone from the x64dbg snapshots and used them.

    点赞 评论 复制链接分享
  • weixin_39814369 weixin_39814369 5月前

    I’m still new to this project. Barely stumbled upon it recently.

    Is your PR adding bindings so that the keystone engine can be called from MASM and other assemblers?

    What I was wondering about initially was whether the engine supported compilation of assembly (with MASM syntax)?

    Sorry if my terminology isn’t very clear (new to this software).

    点赞 评论 复制链接分享
  • weixin_39630735 weixin_39630735 5月前

    Yes , the include files will allow you to use the keystone with masm and other assemblers, here is a basic example of usage using the ks_version function:

    
    Include keystone_x86.inc ; keystone include file
    Includelib keystone_x86.lib ; keystone library file (requires keystone.dll)
    
    Invoke ks_version, NULL, NULL ; returns version in eax
    
    点赞 评论 复制链接分享
  • weixin_39630735 weixin_39630735 5月前

    I found an issue with using the masm x86 binding with keystone.

    I was getting an access violation with some sample code using ks_asm. I found that if the address parameter is changed to size_t instead of unit64_t for ks_asm and recompiled (changing the keystone.h definition and the ks_priv.cpp paramters) then calling ks_asm with x86 assembler (masm) worked fine. Not sure the correct way of handling that to accommodate both x86 and x64 as c/c++ isnt my main language.

    点赞 评论 复制链接分享
  • weixin_39630735 weixin_39630735 5月前

    I have updated the keystone_x86.inc to handle the third parameter of ks_asm as a qword sized parameter now, and updated KSExample_x86 to show how this is handled.

    点赞 评论 复制链接分享