Browse Source

Do not virtualize compiler-generated stuff

pull/94/head
Meivyn 1 year ago
parent
commit
8c45728c11
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      IPA.Injector/Virtualizer.cs

+ 12
- 1
IPA.Injector/Virtualizer.cs View File

@ -3,6 +3,7 @@ using Mono.Cecil.Rocks;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
namespace IPA.Injector namespace IPA.Injector
@ -69,11 +70,20 @@ namespace IPA.Injector
} }
} }
private TypeReference compilerGeneratedAttributeRef;
private TypeReference inModreqRef; private TypeReference inModreqRef;
// private TypeReference outModreqRef; // private TypeReference outModreqRef;
private bool IsCompilerGenerated(Mono.Cecil.ICustomAttributeProvider customAttributeProvider)
{
compilerGeneratedAttributeRef ??= module.ImportReference(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute));
return customAttributeProvider.CustomAttributes.Any(ca => ca.AttributeType.FullName == compilerGeneratedAttributeRef.FullName);
}
private void VirtualizeType(TypeDefinition type) private void VirtualizeType(TypeDefinition type)
{ {
if (IsCompilerGenerated(type)) return;
if(type.IsSealed) if(type.IsSealed)
{ {
// Unseal // Unseal
@ -108,7 +118,8 @@ namespace IPA.Injector
&& !method.IsConstructor && !method.IsConstructor
&& !method.IsSpecialName && !method.IsSpecialName
&& !method.IsGenericInstance && !method.IsGenericInstance
&& !method.HasOverrides)
&& !method.HasOverrides
&& !IsCompilerGenerated(method))
{ {
if (!method.IsStatic) if (!method.IsStatic)
{ {


Loading…
Cancel
Save