Can an assembly with "unsafe" methods start from a "safe" context?

I would like to write some optimized “unsafe” code, but provide a secondary “safe” version that can be used in sandboxes such as web pages. Is it possible to place both in the same assembly, or are there any unsafe methods to prevent the assembly from loading?

If I can put them in one assembly, how can I check if the quick version can be launched?

And by the way, how can I run .exe with increased security so that I can check it myself?

+4
source share
1 answer

Drag carefully here. Assemblies containing unsafe code are marked as "unsafe" and require full trust to load and run.

Question: Is an increase in performance expected to risk exposing the underlying OS, machine, data, etc. malware using a vulnerability in your (insecure) code?

I would strongly recommend that you carefully analyze, profile, measure and test your code - and several alternative implementations, if you can - before introducing unsafe code. I experienced several scenarios where unsafe code was really needed, and when it was, I had to go through extensive reviews and security analyzes because of the potentially dangerous nature of the code.

You might want to read the following: http://social.msdn.microsoft.com/Forums/en-US/clr/thread/596ab254-87ab-4f13-847d-4b15e9170475

+2
source

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


All Articles