all groups > dotnet clr > july 2007 >
You're in the

dotnet clr

group:

Windows API in SAFE code.


Windows API in SAFE code. Ziangi Jones
7/19/2007 11:30:06 AM
dotnet clr:
Hi All,

I guess Windows API calls are unmanaged. Then how does CLR manage when a
such a call is made in a safe code block?
Plz. throw some light on this topic...(may be a good link)
--
Re: Windows API in SAFE code. Ben Voigt [C++ MVP]
7/22/2007 5:11:43 PM

[quoted text, click to view]

The permissions for each assembly are granted based on its load location
(the directory where the .dll file is). Assemblies in the global assembly
cache run with FullTrust, so they can call unmanaged code. If the trusted
assembly is marked with AllowPartiallyTrustedCallersAttribute then untrusted
code can call the unmanaged code in whatever way the trusted assembly
allows.

None of this has anything to do with "safe" or "unsafe" though. "unsafe"
only applies to pointer arithmetic, where you could overrun the bounds of an
array or cast to a different pointer type. I believe it's actually an error
in the .NET specification that unsafe blocks are required for other pointer
operations, but clearly someone at Microsoft really doesn't like pointers.

[quoted text, click to view]
AddThis Social Bookmark Button