Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

3F/UnmanagedEmitCalli

Open more actions menu

Repository files navigation

A tiny hack of the System.Private.CoreLib to provide missed Unmanaged EmitCalli implementation at the .NET Standard 2.0 layer.

Build status release-src License NuGet package

Why UnmanagedEmitCalli ?

An Unmanaged EmitCalli is available only with .NET Core 2.1+ [?] That turns into a quest when you need .NET Standard 2.0 targeting.

This, however, does not require a full reimplementing or a huge dependencies like Cecil etc.

Because you can simply use the same techniques as we do 3F/Conari#13 (comment)

UnmanagedEmitCalli provides most common implementation that can be used either through dependencies or copy-paste of a bit of source code. Enjoy!

Where ?

This was used initially for 🧬 Conari - Platform for working with unmanaged memory, pe-modules, related PInvoke features, and more for: Libraries, Executable Modules, enjoying of the unmanaged native C/C++ in .NET world, and other raw binary data. Even accessing to complex types like structures without their declaration at all.

Example

Same for .NET Framework and .NET Core

ILGenerator il = dyn.GetILGenerator();

for(int i = 0; i < mParams.Length; ++i) {
    il.Emit(OpCodes.Ldarg, i);
}

if(IntPtr.Size == sizeof(Int64)) {
    il.Emit(OpCodes.Ldc_I8, ptr.ToInt64());
}
else {
    il.Emit(OpCodes.Ldc_I4, ptr.ToInt32());
}

il.EmitCalliStd(CallingConvention.Cdecl, tret, mParams);
il.Emit(OpCodes.Ret);

🍰 Open and Free

Open Source project; MIT License, Yes! Enjoy!

🗸 License

The MIT License (MIT)

Copyright (c) 2019-2021  Denis Kuzmin <x-3F@outlook.com> github/3F

[ ☕ Donate ]

UnmanagedEmitCalli contributors https://github.com/3F/UnmanagedEmitCalli/graphs/contributors

Make your amazing contribution!

About

A tiny hack of the System.Private.CoreLib to provide an Unmanaged EmitCalli implementation at the .NET Standard 2.0 layer.

Topics

Resources

License

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.