Coffeehouse Post

Single Post Permalink

View Thread: Hacking Redhawk: Call Windows Class Libraries from C++
  • User profile image

    I'm not familiar with Redhawk but I assume you mean "Reverse P/Invoke"? If so, yes the .Net framework supports being called from C. Unfortunately this functionality is not plumbed all the way through to say, C#. Ideally there should be a "DllExport" attribute that allows a .Net assembly to have that method exported and be able to be called purely from C (while initializing the .Net framework during the 1st C call).

    I needed this exact same functionality when I wrote some managed VST plugins. VST plugins are audio plugins for audio applications that uses a purely C interface. In my project, I created a DllExport attribute, and a post-build step would decompile to IL, then parses and sets the correct flags and does some other "things", and then recompiles the IL. At that point those methods marked with DllExport shows up as C entry points. This works quite well, and the unmanaged audio applications can see and call into the managed DLL as if it was purely C/C++ code. The .Net runtime is fired up automatically as part of any initial C call into the DLL.

    See this thread that contains a more detailed explanation and code for an early version of my parser. I feel it is a hack, and wish MS would just plumb this stuff all the way though, as it's 98% all there already.

    If this was not what you were referring to, just ignore my post...