Is it possible to write assembly code in vb.net or C #?

I know how to write MSIL code, but out of curiosity I would like to know if there is a workaround for writing assembly code. I can think of a way to write code in a string and pass it to my own windows api file, which executes and returns the result, but I'm not sure if this is real or even possible.

I would like to hear your opinions / suggestions. thank

+5
source share
4 answers

You can compile it with C # and pass the generated machine code to a C function like this through P / Invoke.

int execute(char* machine_code)
{
     int(*fn)() = machine_code;
     return fn();
}

You will need to worry about the memory area being executable, but that is beyond the scope of this answer.

+2
source

, # VB.Net.

, DLL, C. PInvoke #/VB.Net.

- ++/CLI, ++/CLI.

+3

fasm.dll, Marshal.GetDelegateForFunctionPointer, .

+1

( .NET) IL ilasm, - MonoDevelop, IL.

+1

All Articles