summaryrefslogtreecommitdiff
path: root/src/vm/securitydeclarative.inl
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/securitydeclarative.inl
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/securitydeclarative.inl')
-rw-r--r--src/vm/securitydeclarative.inl135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/vm/securitydeclarative.inl b/src/vm/securitydeclarative.inl
new file mode 100644
index 0000000000..3a56bb2fa0
--- /dev/null
+++ b/src/vm/securitydeclarative.inl
@@ -0,0 +1,135 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+//
+
+//
+
+
+#ifndef __SECURITYDECLARATIVE_INL__
+#define __SECURITYDECLARATIVE_INL__
+
+#include "security.h"
+
+inline LinktimeCheckReason operator|(LinktimeCheckReason lhs, LinktimeCheckReason rhs)
+{
+ LIMITED_METHOD_CONTRACT;
+ return static_cast<LinktimeCheckReason>(static_cast<DWORD>(lhs) | static_cast<DWORD>(rhs));
+}
+
+inline LinktimeCheckReason operator|=(LinktimeCheckReason &lhs, LinktimeCheckReason rhs)
+{
+ LIMITED_METHOD_CONTRACT;
+ lhs = lhs | rhs;
+ return lhs;
+}
+
+inline LinktimeCheckReason operator&(LinktimeCheckReason lhs, LinktimeCheckReason rhs)
+{
+ LIMITED_METHOD_CONTRACT;
+ return static_cast<LinktimeCheckReason>(static_cast<DWORD>(lhs) & static_cast<DWORD>(rhs));
+}
+
+
+inline LinktimeCheckReason operator&=(LinktimeCheckReason &lhs, LinktimeCheckReason rhs)
+{
+ LIMITED_METHOD_CONTRACT;
+ lhs = lhs & rhs;
+ return lhs;
+}
+
+inline void SecurityDeclarative::GetPermissionInstance(OBJECTREF *perm, int index)
+{
+ WRAPPER_NO_CONTRACT;
+ _GetSharedPermissionInstance(perm, index);
+}
+
+inline BOOL SecurityDeclarative::FullTrustCheckForLinkOrInheritanceDemand(Assembly *pAssembly)
+{
+ WRAPPER_NO_CONTRACT;
+#ifndef DACCESS_COMPILE
+ IAssemblySecurityDescriptor* pSecDesc = pAssembly->GetSecurityDescriptor();
+ if (pSecDesc->IsSystem())
+ return TRUE;
+
+ if (pSecDesc->IsFullyTrusted())
+ return TRUE;
+#endif
+ return FALSE;
+
+}
+
+inline BOOL SecurityDeclarative::MethodIsVisibleOutsideItsAssembly(DWORD dwMethodAttr)
+{
+ LIMITED_METHOD_CONTRACT;
+ return ( IsMdPublic(dwMethodAttr) ||
+ IsMdFamORAssem(dwMethodAttr)||
+ IsMdFamily(dwMethodAttr) );
+}
+
+inline BOOL SecurityDeclarative::MethodIsVisibleOutsideItsAssembly(
+ MethodDesc * pMD)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ MethodTable * pMT = pMD->GetMethodTable();
+
+ if (!ClassIsVisibleOutsideItsAssembly(pMT->GetAttrClass(), pMT->IsGlobalClass()))
+ return FALSE;
+
+ return MethodIsVisibleOutsideItsAssembly(pMD->GetAttrs());
+}
+
+inline BOOL SecurityDeclarative::MethodIsVisibleOutsideItsAssembly(DWORD dwMethodAttr, DWORD dwClassAttr, BOOL fIsGlobalClass)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ if (!ClassIsVisibleOutsideItsAssembly(dwClassAttr, fIsGlobalClass))
+ return FALSE;
+
+ return MethodIsVisibleOutsideItsAssembly(dwMethodAttr);
+}
+
+inline BOOL SecurityDeclarative::ClassIsVisibleOutsideItsAssembly(DWORD dwClassAttr, BOOL fIsGlobalClass)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ if (fIsGlobalClass)
+ {
+ return TRUE;
+ }
+
+ return ( IsTdPublic(dwClassAttr) ||
+ IsTdNestedPublic(dwClassAttr)||
+ IsTdNestedFamily(dwClassAttr)||
+ IsTdNestedFamORAssem(dwClassAttr));
+}
+
+#ifndef DACCESS_COMPILE
+inline void SecurityDeclarative::DoDeclarativeSecurityAtStackWalk(MethodDesc* pFunc, AppDomain* pAppDomain, OBJECTREF* pFrameObjectSlot)
+{
+ CONTRACTL {
+ THROWS;
+ GC_TRIGGERS;
+ MODE_COOPERATIVE;
+ } CONTRACTL_END;
+
+
+ BOOL hasDeclarativeStackModifier = (pFunc->IsInterceptedForDeclSecurity() && !pFunc->IsInterceptedForDeclSecurityCASDemandsOnly());
+ if (hasDeclarativeStackModifier)
+ {
+
+ _ASSERTE(pFrameObjectSlot != NULL);
+ if (*pFrameObjectSlot == NULL || !( ((FRAMESECDESCREF)(*pFrameObjectSlot))->IsDeclSecComputed()) )
+ {
+ // Populate the FSD with declarative assert/deny/PO
+ SecurityDeclarative::DoDeclarativeStackModifiers(pFunc, pAppDomain, pFrameObjectSlot);
+ }
+ }
+}
+#endif
+
+
+
+#endif // __SECURITYDECLARATIVE_INL__