I'm able to collect all the types from the current domain calling this:
var types = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(x => x.GetTypes())
.ToList();
Assume no exception is thrown. Nevertheless I'd like to simulate ReflectionTypeLoadException
to be thrown during that process.
How to corrupt any existing type in my code for this exception to occur?
Alternatively, if above cannot be achieved, how can I dynamically create an artificial assembly with some corrupted type to infect the domain (current or new)? In particular I'm looking for some clues regarding the implementation of the Infect()
method below:
Infect(AppDomain.CurrentDomain); // inject corrupted type
try
{
var types = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(x => x.GetTypes())
.ToList();
}
catch (ReflectionTypeLoadException e)
{
// done
}
Aucun commentaire:
Enregistrer un commentaire