コード例 #1
0
ファイル: monodiet.c プロジェクト: ANahr/mono
static void
handle_cattrs (MonoCustomAttrInfo* cattrs)
{
	int i;
	if (!cattrs)
		return;
	for (i = 0; i < cattrs->num_attrs; ++i) {
		add_types_from_method (cattrs->attrs [i].ctor);
	}
	mono_custom_attrs_free (cattrs);
}
コード例 #2
0
ファイル: gd_mono_class.cpp プロジェクト: UgisBrekis/godot
GDMonoClass::~GDMonoClass() {

	if (attributes) {
		mono_custom_attrs_free(attributes);
	}

	for (Map<StringName, GDMonoField *>::Element *E = fields.front(); E; E = E->next()) {
		memdelete(E->value());
	}

	for (Map<StringName, GDMonoProperty *>::Element *E = properties.front(); E; E = E->next()) {
		memdelete(E->value());
	}

	{
		// Ugly workaround...
		// We may have duplicated values, because we redirect snake_case methods to PascalCasel (only Godot API methods).
		// This way, we end with both the snake_case name and the PascalCasel name paired with the same method.
		// Therefore, we must avoid deleting the same pointer twice.

		int offset = 0;
		Vector<GDMonoMethod *> deleted_methods;
		deleted_methods.resize(methods.size());

		const MethodKey *k = NULL;
		while ((k = methods.next(k))) {
			GDMonoMethod *method = methods.get(*k);

			if (method) {
				for (int i = 0; i < offset; i++) {
					if (deleted_methods[i] == method) {
						// Already deleted
						goto already_deleted;
					}
				}

				deleted_methods.write[offset] = method;
				++offset;

				memdelete(method);
			}

		already_deleted:;
		}

		methods.clear();
	}

	for (int i = 0; i < method_list.size(); ++i) {
		memdelete(method_list[i]);
	}
}
コード例 #3
0
	bool MonoMethod::hasAttribute(MonoClass* monoClass) const
	{
		// TODO - Consider caching custom attributes or just initializing them all at load

		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_method(mMethod);
		if (attrInfo == nullptr)
			return false;

		bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->_getInternalClass()) != 0;

		mono_custom_attrs_free(attrInfo);

		return hasAttr;
	}
コード例 #4
0
	MonoObject* MonoMethod::getAttribute(MonoClass* monoClass) const
	{
		// TODO - Consider caching custom attributes or just initializing them all at load

		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_method(mMethod);
		if (attrInfo == nullptr)
			return nullptr;

		MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->_getInternalClass());

		mono_custom_attrs_free(attrInfo);

		return foundAttr;
	}
コード例 #5
0
ファイル: declsec.c プロジェクト: Adamcbrz/mono
/*
 * Ensure that the restrictions for partially trusted code are satisfied.
 *
 * @domain	The current application domain
 * @caller	The method calling
 * @callee	The called method
 * return value: TRUE if a security violation is detected, FALSE otherwise.
 *
 * If callee's assembly is strongnamed and doesn't have an 
 * [AllowPartiallyTrustedCallers] attribute then we must enforce a LinkDemand
 * for FullTrust on all public/protected methods on public class.
 *
 * Note: APTC is only effective on stongnamed assemblies.
 */
static gboolean
mono_declsec_linkdemand_aptc (MonoDomain *domain, MonoMethod *caller, MonoMethod *callee)
{
	MonoSecurityManager* secman = NULL;
	MonoAssembly *assembly;
	guint32 size = 0;

	InterlockedIncrement (&mono_jit_stats.cas_linkdemand_aptc);

	/* A - Applicable only if we're calling into *another* assembly */
	if (caller->klass->image == callee->klass->image)
		return FALSE;

	/* B - Applicable if we're calling a public/protected method from a public class */
	if (!(callee->klass->flags & TYPE_ATTRIBUTE_PUBLIC) || !(callee->flags & FIELD_ATTRIBUTE_PUBLIC))
		return FALSE;

	/* C - Applicable if the callee's assembly is strongnamed */
	if ((mono_image_get_public_key (callee->klass->image, &size) == NULL) || (size < MONO_ECMA_KEY_LENGTH))
		return FALSE;

	/* D - the callee's assembly must have [AllowPartiallyTrustedCallers] */
	assembly = mono_image_get_assembly (callee->klass->image);
	if (!MONO_SECMAN_FLAG_INIT (assembly->aptc)) {
		MonoCustomAttrInfo* cinfo = mono_custom_attrs_from_assembly (assembly);
		gboolean result = FALSE;
		secman = mono_security_manager_get_methods ();
		if (secman && cinfo) {
			/* look for AllowPartiallyTrustedCallersAttribute */
			result = mono_custom_attrs_has_attr (cinfo, secman->allowpartiallytrustedcallers);
		}
		if (cinfo)
			mono_custom_attrs_free (cinfo);
		MONO_SECMAN_FLAG_SET_VALUE (assembly->aptc, result);
	}

	if (MONO_SECMAN_FLAG_GET_VALUE (assembly->aptc))
		return FALSE;

	/* E - the caller's assembly must have full trust permissions */
	assembly = mono_image_get_assembly (caller->klass->image);
	if (mono_declsec_is_assembly_fulltrust (domain, assembly))
		return FALSE;

	/* g_warning ("FAILURE *** JIT LinkDemand APTC check *** %s.%s calls into %s.%s",
		caller->klass->name, caller->name, callee->klass->name, callee->name); */

	return TRUE;	/* i.e. throw new SecurityException(); */
}
コード例 #6
0
ファイル: BsMonoField.cpp プロジェクト: AlfHub/BansheeEngine
	MonoObject* MonoField::getAttribute(MonoClass* monoClass)
	{
		// TODO - Consider caching custom attributes or just initializing them all at load

		::MonoClass* parentClass = mono_field_get_parent(mField);
		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, mField);
		if(attrInfo == nullptr)
			return nullptr;

		MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->_getInternalClass());

		mono_custom_attrs_free(attrInfo);

		return foundAttr;
	}
コード例 #7
0
ファイル: BsMonoField.cpp プロジェクト: AlfHub/BansheeEngine
	bool MonoField::hasAttribute(MonoClass* monoClass)
	{
		// TODO - Consider caching custom attributes or just initializing them all at load

		::MonoClass* parentClass = mono_field_get_parent(mField);
		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, mField);
		if(attrInfo == nullptr)
			return false;

		bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->_getInternalClass()) != 0;
		
		mono_custom_attrs_free(attrInfo);

		return hasAttr;
	}
コード例 #8
0
ファイル: gd_mono_field.cpp プロジェクト: n-pigeon/godot
GDMonoField::~GDMonoField() {
	if (attributes) {
		mono_custom_attrs_free(attributes);
	}
}
コード例 #9
0
ファイル: gd_mono_method.cpp プロジェクト: brakhane/godot
GDMonoMethod::~GDMonoMethod() {
	if (attributes) {
		mono_custom_attrs_free(attributes);
	}
}
コード例 #10
0
ファイル: gd_mono_property.cpp プロジェクト: Ranakhamis/godot
GDMonoProperty::~GDMonoProperty() {
	if (attributes) {
		mono_custom_attrs_free(attributes);
	}
}