Fix problems decrypting strings when there's a missing assembly
This commit is contained in:
parent
04903f0f9b
commit
d278c29fa2
|
@ -83,12 +83,21 @@ namespace AssemblyData {
|
||||||
|
|
||||||
public object[] decryptStrings(int stringDecrypterMethod, object[] args, int callerToken) {
|
public object[] decryptStrings(int stringDecrypterMethod, object[] args, int callerToken) {
|
||||||
checkStringDecrypter();
|
checkStringDecrypter();
|
||||||
var caller = assembly.GetModules()[0].ResolveMethod(callerToken);
|
var caller = getCaller(callerToken);
|
||||||
foreach (var arg in args)
|
foreach (var arg in args)
|
||||||
SimpleData.unpack((object[])arg);
|
SimpleData.unpack((object[])arg);
|
||||||
return SimpleData.pack(stringDecrypter.decryptStrings(stringDecrypterMethod, args, caller));
|
return SimpleData.pack(stringDecrypter.decryptStrings(stringDecrypterMethod, args, caller));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MethodBase getCaller(int callerToken) {
|
||||||
|
try {
|
||||||
|
return assembly.GetModules()[0].ResolveMethod(callerToken);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
exitEvent.Set();
|
exitEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,17 +40,21 @@ namespace AssemblyData.methodsrewriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTokenToType() {
|
void initTokenToType() {
|
||||||
var tmpTokenToType = new Dictionary<int, Type>();
|
|
||||||
var tmpTokenToTypeDefinition = new Dictionary<int, TypeDefinition>();
|
|
||||||
foreach (var t in module.GetTypes())
|
|
||||||
tmpTokenToType[t.MetadataToken] = t;
|
|
||||||
foreach (var t in moduleDefinition.GetTypes())
|
|
||||||
tmpTokenToTypeDefinition[t.MetadataToken.ToInt32()] = t;
|
|
||||||
moduleType = DotNetUtils.getModuleType(moduleDefinition);
|
moduleType = DotNetUtils.getModuleType(moduleDefinition);
|
||||||
foreach (var token in tmpTokenToType.Keys) {
|
foreach (var typeDefinition in moduleDefinition.GetTypes()) {
|
||||||
var mtype = new MType(tmpTokenToType[token], tmpTokenToTypeDefinition[token]);
|
int token = typeDefinition.MetadataToken.ToInt32();
|
||||||
|
Type type;
|
||||||
|
try {
|
||||||
|
type = module.ResolveType(token);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
tokenToType[token] = null;
|
||||||
|
typeReferenceToType.add(typeDefinition, null);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var mtype = new MType(type, typeDefinition);
|
||||||
tokenToType[token] = mtype;
|
tokenToType[token] = mtype;
|
||||||
typeReferenceToType.add(mtype.typeDefinition, mtype);
|
typeReferenceToType.add(typeDefinition, mtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,8 @@ namespace AssemblyData.methodsrewriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCaller(RewrittenMethod rewrittenMethod, MethodBase caller) {
|
public void setCaller(RewrittenMethod rewrittenMethod, MethodBase caller) {
|
||||||
|
if (caller == null)
|
||||||
|
return;
|
||||||
var newMethodInfo = getNewMethodInfo(rewrittenMethod.Method.Name);
|
var newMethodInfo = getNewMethodInfo(rewrittenMethod.Method.Name);
|
||||||
newStackMethodDict[newMethodInfo] = caller;
|
newStackMethodDict[newMethodInfo] = caller;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user