我如何从C#编写汇编代码? [英] how do i write assembly code from c#?

查看:333
本文介绍了我如何从C#编写汇编代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用c#编写一串汇编代码,然后将其发送到某些win32 api进行编译和执行,并返回结果.

i want to write a string of assembly code in c# and have it sent to some win32 api to compile and execute it and get the results back.

示例:

string str = "MOV 1,2;XOR EBP,EBP"...

听起来很难,但任何建议都会有所帮助.

sounds like hard to do but any suggestion would be helpful.

推荐答案

我怀疑是否有Win API可以编译&执行程序集. 您可能要做的最好的事情就是编写一个文件,执行MASM(或如今所谓的任何事情),链接它,然后执行生成的程序. 我无法想象您要做什么,但这几乎是我尝试解决几乎所有问题的最后一种方法!

I doubt there's a win API to compile & execute assembly. Probably the best you could do is write a file, execute MASM (or whatever it's called these days), link it then execute the resulting program. I can't imagine what you are trying to do but this would be pretty much the last way I would try to solve almost any problem!

如果要比较本机&托管代码,只需编写两个或多或少做同一件事的程序.没有理由从.NET生成程序集.您可以为此使用任何合适的工具. MASM,调试等.

If you want to compare native & managed code, just write two programs that do more or less the same thing. There is no reason to generate the assembly from .NET. You can use any suitable tool for this. MASM, debug etc.

这篇关于我如何从C#编写汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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