[loader] Pass predicate callback to mono_assembly_load_from_full
authorAleksey Kliger <aleksey@xamarin.com>
Mon, 27 Feb 2017 22:34:51 +0000 (17:34 -0500)
committerAleksey Kliger <aleksey@xamarin.com>
Tue, 14 Mar 2017 15:39:03 +0000 (11:39 -0400)
commitae1822075d7c697ec4d96f9be96e9b62a7adf386
tree95d863d961ce0349ca7b06b60003e28b6c8120b6
parenta21fae83b7054bf29a5524ffc84364f2f2f4e5b5
[loader] Pass predicate callback to mono_assembly_load_from_full

Actually create a new mono_assembly_load_from_predicate () and call that from
the old mono_assembly_load_from_full ().

This function is responsible for creating brand new MonoAssembly* values and
then committing them by calling mono_assembly_invoke_load_hook().  So if we
would like to have a chance to reject a candidate assembly from loading for
some reason, this is the only place we can do it:

* anywhere before the call to mono_assembly_load_from_predicate there is no
  MonoAssembly* yet.
* anywhere after mono_assembly_load_from_predicate returns, the load hook was
  already called (in a plain vanilla Mono, there's an installed load hook
  called mono_domain_fire_assembly_load () which caches the MonoAssembly* in
  the domain that requested the load - after that point we cannot possibly
  consider another MonoImage* for the same MonoAssemblyName - the appdomain
  will always return the cached one).

The next commit will use this predicate to reject some strongly named
assemblies when the candidate assembly doesn't exactly match the wanted
MonoAssemblyName.  (Note that load_from doesn't have the MonoAssemblyName that
was requested, so we'd have to thread /something/ down here - might as well be
a predicate function.)
mono/dis/main.c
mono/metadata/appdomain.c
mono/metadata/assembly-internals.h
mono/metadata/assembly.c