Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 368 Bytes

README.md

File metadata and controls

15 lines (13 loc) · 368 Bytes

ExecutableMemory.NET

A sample project for writing and executing assembly in C#

var add = (delegate* unmanaged[SuppressGCTransition]<int, int, int>)ExecutableMemory.Allocate(static asm =>
{
    if (OperatingSystem.IsWindows())
        asm.lea(eax, rcx + rdx);
    else
        asm.lea(eax, rdi + rsi);
    asm.ret();
});

Console.WriteLine(add(2, 2));