Fix compressor dependency name matching

This commit is contained in:
yck1509 2015-02-25 20:36:26 +08:00
Родитель 9e0397dab6
Коммит 4ae5b68787
2 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -83,7 +83,7 @@ namespace Confuser.Protections {
}
}
static string GetFullName(byte[] module) {
static string GetName(byte[] module) {
var md = MetaDataCreator.CreateMetaData(new PEImage(module));
var assemblyRow = md.TablesStream.ReadAssemblyRow(1);
var assembly = new AssemblyNameInfo();
@ -93,7 +93,7 @@ namespace Confuser.Protections {
assembly.HashAlgId = (AssemblyHashAlgorithm)assemblyRow.HashAlgId;
assembly.Version = new Version(assemblyRow.MajorVersion, assemblyRow.MinorVersion, assemblyRow.BuildNumber, assemblyRow.RevisionNumber);
assembly.Attributes = (AssemblyAttributes)assemblyRow.Flags;
return assembly.FullName;
return assembly.Name;
}
void PackModules(ConfuserContext context, CompressorContext compCtx, ModuleDef stubModule, ICompressionService comp, RandomGenerator random) {
@ -103,18 +103,18 @@ namespace Confuser.Protections {
if (i == compCtx.ModuleIndex)
continue;
string fullName = context.Modules[i].Assembly.FullName;
modules.Add(fullName, context.OutputModules[i]);
string name = context.Modules[i].Assembly.Name.ToUpperInvariant();
modules.Add(name, context.OutputModules[i]);
int strLen = Encoding.UTF8.GetByteCount(fullName);
int strLen = Encoding.UTF8.GetByteCount(name);
if (strLen > maxLen)
maxLen = strLen;
}
foreach (var extModule in context.ExternalModules) {
var fullName = GetFullName(extModule);
modules.Add(fullName, extModule);
var name = GetName(extModule).ToUpperInvariant();
modules.Add(name, extModule);
int strLen = Encoding.UTF8.GetByteCount(fullName);
int strLen = Encoding.UTF8.GetByteCount(name);
if (strLen > maxLen)
maxLen = strLen;
}

Просмотреть файл

@ -76,10 +76,10 @@ namespace Confuser.Runtime {
}
static Assembly Resolve(object sender, ResolveEventArgs e) {
byte[] b = Encoding.UTF8.GetBytes(e.Name);
byte[] b = Encoding.UTF8.GetBytes(new AssemblyName(e.Name).Name.ToUpperInvariant());
Stream m = null;
if (b.Length + 4 < key.Length) {
if (b.Length + 4 <= key.Length) {
for (int i = 0; i < b.Length; i++)
b[i] *= key[i + 4];
string n = Convert.ToBase64String(b);