Visual C ++ Wrap in C #

I need to inject the process using C ++, but I would prefer to use C # for everything except low-level stuff. I heard about "wrapping functions" and "marshaling" and did quite a lot of searching on Google and found some information here, but I still lack.

Things I read in order of utility;
http://msdn.microsoft.com/en-us/library/ms235281(VS.80).aspx
http://www.drdobbs.com/cpp/184401742
http://geeklit.blogspot.com/2006/08 /calling-c-lib-from-c.html

How can I wrap all the elements of a lower level (native C ++) in C # so that I can easily manage these functions in a language I prefer, C #?

Any information on this topic is greatly appreciated.

+3
source share
3 answers

I think P / Invoke is the easiest approach:

  • Create a DLL in unmanaged C ++ that contains all the functions needed to complete the injection.
  • In C # code, declare some methods static externand use the attribute DllImportto point them to your C ++ dll. For more information, see the Link provided by arul in his answer .

Please note that P / Invoke is not limited to “Windows API functions” - you can call functions open by any native DLL.

P/Invoke , ++, , . COM- "" DLL COM interop #.

+5

P/Invoke, . MSDN.

+2

Pinvoking - , , ++. ++ . ++ .NET- . #.

+1

Source: https://habr.com/ru/post/1699601/


All Articles