Skip to content

Commit

Permalink
Submodule was updated. Fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Dec 19, 2012
1 parent ab8e548 commit 35849b0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions AssemblyData/methodsrewriter/TypeInstanceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public FieldInfo resolve(IField fieldRef) {
if (!fields.TryGetValue(fieldRef.Name.String, out list))
return null;

fieldRef = GenericArgsSubstitutor.create(fieldRef, fieldRef.DeclaringType.ToGenericInstSig());
fieldRef = GenericArgsSubstitutor.create(fieldRef, fieldRef.DeclaringType.TryGetGenericInstSig());

foreach (var field in list) {
if (ResolverUtils.compareFields(field, fieldRef))
Expand Down Expand Up @@ -71,7 +71,7 @@ public MethodBase resolve(IMethod methodRef) {
if (!methods.TryGetValue(methodRef.Name.String, out list))
return null;

methodRef = GenericArgsSubstitutor.create(methodRef, methodRef.DeclaringType.ToGenericInstSig());
methodRef = GenericArgsSubstitutor.create(methodRef, methodRef.DeclaringType.TryGetGenericInstSig());

foreach (var method in list) {
if (ResolverUtils.compareMethods(method, methodRef))
Expand Down
2 changes: 1 addition & 1 deletion blocks/DotNetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static MethodDef getMethod2(ModuleDefMD module, IMethod method) {
return null;
if (method is MethodDef)
return (MethodDef)method;
var git = method.DeclaringType.ToGenericInstSig();
var git = method.DeclaringType.TryGetGenericInstSig();
var dt = git == null ? method.DeclaringType : git.GenericType.TypeDefOrRef;
return getMethod(module, method, dt);
}
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/DeobfuscatorContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static ITypeDefOrRef getNonGenericTypeRef(ITypeDefOrRef typeRef) {
var ts = typeRef as TypeSpec;
if (ts == null)
return typeRef;
var gis = ts.ToGenericInstSig();
var gis = ts.TryGetGenericInstSig();
if (gis == null || gis.GenericType == null)
return typeRef;
return gis.GenericType.TypeDefOrRef;
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/Babel_NET/ConstantsDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void deobfuscate(Blocks blocks) {
var castclass = instrs[index++];
if (castclass.OpCode.Code != Code.Castclass)
continue;
var arrayType = (castclass.Operand as ITypeDefOrRef).ToSZArraySig();
var arrayType = (castclass.Operand as ITypeDefOrRef).TryGetSZArraySig();
if (arrayType == null)
continue;
if (arrayType.Next.ElementType.GetPrimitiveSize() == -1) {
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/TypesRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ bool deobfuscateFields() {
continue;

IList<TypeSig> calledMethodArgs = DotNetUtils.getArgs(calledMethodDefOrRef);
calledMethodArgs = DotNetUtils.replaceGenericParameters(calledMethodDefOrRef.DeclaringType.ToGenericInstSig(), calledMethodSpec, calledMethodArgs);
calledMethodArgs = DotNetUtils.replaceGenericParameters(calledMethodDefOrRef.DeclaringType.TryGetGenericInstSig(), calledMethodSpec, calledMethodArgs);
for (int j = 0; j < pushedArgs.NumValidArgs; j++) {
var pushInstr = pushedArgs.getEnd(j);
if (pushInstr.OpCode.Code != Code.Ldfld && pushInstr.OpCode.Code != Code.Ldsfld)
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/renamer/asmmodules/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static ITypeDefOrRef getNonGenericTypeRef(ITypeDefOrRef typeRef) {
var ts = typeRef as TypeSpec;
if (ts == null)
return typeRef;
var gis = ts.ToGenericInstSig();
var gis = ts.TryGetGenericInstSig();
if (gis == null || gis.GenericType == null)
return typeRef;
return gis.GenericType.TypeDefOrRef;
Expand Down
10 changes: 5 additions & 5 deletions de4dot.code/renamer/asmmodules/TypeDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void initializeAllInterfaces() {
}

void initializeInterfaces(TypeInfo typeInfo) {
var git = typeInfo.typeRef.ToGenericInstSig();
var git = typeInfo.typeRef.TryGetGenericInstSig();
interfaceMethodInfos.initializeFrom(typeInfo.typeDef.interfaceMethodInfos, git);
foreach (var info in typeInfo.typeDef.allImplementedInterfaces.Keys) {
var newTypeInfo = new TypeInfo(info, git);
Expand Down Expand Up @@ -540,7 +540,7 @@ void initializeInterfaceMethods(MethodNameGroups groups) {
var ifaceMethod = methodInst.origMethodDef;
if (!ifaceMethod.isVirtual())
continue;
var ifaceMethodRef = GenericArgsSubstitutor.create(methodInst.methodRef, ifaceInfo.typeRef.ToGenericInstSig());
var ifaceMethodRef = GenericArgsSubstitutor.create(methodInst.methodRef, ifaceInfo.typeRef.TryGetGenericInstSig());
MMethodDef classMethod;
if (!methodsDict.TryGetValue(ifaceMethodRef, out classMethod))
continue;
Expand Down Expand Up @@ -574,7 +574,7 @@ void initializeInterfaceMethods(MethodNameGroups groups) {
var ifaceMethod = methodsList[0].origMethodDef;
if (!ifaceMethod.isVirtual())
continue;
var ifaceMethodRef = GenericArgsSubstitutor.create(ifaceMethod.MethodDef, ifaceInfo.typeRef.ToGenericInstSig());
var ifaceMethodRef = GenericArgsSubstitutor.create(ifaceMethod.MethodDef, ifaceInfo.typeRef.TryGetGenericInstSig());
MMethodDef classMethod;
if (!methodsDict.TryGetValue(ifaceMethodRef, out classMethod))
continue;
Expand All @@ -588,7 +588,7 @@ void initializeInterfaceMethods(MethodNameGroups groups) {
methodsDict.Clear();
var ifaceMethodsDict = new Dictionary<IMethodDefOrRef, MMethodDef>(MethodEqualityComparer.CompareDeclaringTypes);
foreach (var ifaceInfo in allImplementedInterfaces.Keys) {
var git = ifaceInfo.typeRef.ToGenericInstSig();
var git = ifaceInfo.typeRef.TryGetGenericInstSig();
foreach (var ifaceMethod in ifaceInfo.typeDef.methods.getValues()) {
IMethodDefOrRef ifaceMethodRef = ifaceMethod.MethodDef;
if (git != null)
Expand Down Expand Up @@ -699,7 +699,7 @@ MemberRef simpleClone(MethodDef methodRef, ITypeDefOrRef declaringType) {
void instantiateVirtualMembers(MethodNameGroups groups) {
if (!TypeDef.IsInterface) {
if (baseType != null)
virtualMethodInstances.initializeFrom(baseType.typeDef.virtualMethodInstances, baseType.typeRef.ToGenericInstSig());
virtualMethodInstances.initializeFrom(baseType.typeDef.virtualMethodInstances, baseType.typeRef.TryGetGenericInstSig());

// Figure out which methods we override in the base class
foreach (var methodDef in methods.getValues()) {
Expand Down
2 changes: 1 addition & 1 deletion dot10
Submodule dot10 updated from 8be6ce to ef5ba0

0 comments on commit 35849b0

Please sign in to comment.