This is the brand hot new release (hence the very sober web page) of C-Function Pointer.NET or CFctPtr.NET for a short official name.

It's purpose is to go beyond the limitation of DllImportAttribute and make available (understand: usable in .NET code) most of the function pointer deliver in your legacy library.

How does it work ?


    IntPtr pfct = GetC_DisplayArray_CallbackFct();
    CFunctionPointer p = CFunctionPointer.Create(pfct, // function pointer
                                                 typeof(void), // return type
                                                 typeof(int[]), typeof(int)); // param type
    p.Invoke(new int[]{1,2,3,4}, 4);

It has the following type support
Type Supported
value (int, double, etc..) YES
pointer (int*, ...) NO use array
ref / out NO use array
array ([], [,], ..) YES/NO array of value type only
struct YES of course, it's a value type
class NO

In its current state the Emit code is quite good but the marshalling need to be improved.

Go ahead try it and give me your feedback

SourceForge