zweigs Third party library for unmanaged machine code

  • Thread starter Thread starter zweigs schwangerschaft nochmal
  • Start date Start date
Z

zweigs schwangerschaft nochmal

Guest
What third party library can I use to make unmanaged machine code inside

my c# program that I would call from outside program and which would

load and initialize CLR common language runtime and call any managed

procedure from my program.

I am trying to have unmanaged machine code in my *.exe file which

would be seen in PE file export table and which I would call from outside

program to execute any managed code procedure from that unmanaged

machine code.

How to do this?


  • That's not how managed code works. You're trying to apply native import/export logic to managed code and it isn't correct. Managed code can move around so there is no export table where you can auto-magically call managed code from another process. If you need that kind of behavior you're going to have to go back to a native DLL in C++.

    The general approach to writing managed code that can be called by a separate process is to use COM. You could technically use any IPC mechanism but "calling functions" would generally be limited to COM. If you simply want to call managed functions from within native code running in the same process then you can do that via marshalling.

    None of this has any relation to how the PE file is storing stuff or how PE base addresses work. Again, you're apply native code logic to a managed DLL and they don't work the same.

  • A C# DLL never has exports in the PE sense. Remember that you can't just jump in to C# code arbitrarily. C# code compiled to an intermediate language that needs to be executed by the Common Language Runtime. If it were being called by a C++ program, the CLR would not be running, so there's no one that knows how to run the code.

  • There are third-party libraries that can provide exports. They work by adding new unmanaged functions that load and initialize the CLR and use the CLR facilities to find individual functions within the DLL.

  • What third party library would make unmanaged machine code as exports to load and initialize CLR and call managed code then?

Continue reading...
 
Back
Top