forked from mkaring/ConfuserEx
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUtils.cs
More file actions
26 lines (24 loc) · 1.02 KB
/
Copy pathUtils.cs
File metadata and controls
26 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Confuser.Core;
using dnlib.DotNet;
namespace Confuser.Protections {
internal static class Utils {
public static IMethod Import(this ModuleDef module, ConfuserContext context, Type classType, string method) {
var corLib = context.Resolver.Resolve(context.CurrentModule?.CorLibTypes.AssemblyRef, context.CurrentModule);
var typeInfo = corLib?.ManifestModule.Find(classType.FullName, true);
if (typeInfo != null)
return module.Import(typeInfo.FindMethod(method));
// CX001: intentional last-resort fallback. When the target module's corlib type cannot be
// resolved through the context (rare), host reflection is the only available source for the
// member reference. New code must resolve through the context instead of copying this.
#pragma warning disable CX001
return module.Import(classType.GetMethod(method));
#pragma warning restore CX001
}
}
}