Add Utils.compareInt32() and use it
This commit is contained in:
parent
1b0fbfc681
commit
d014835c7c
|
@ -304,10 +304,7 @@ namespace de4dot {
|
||||||
if (i1 < i2) return -1;
|
if (i1 < i2) return -1;
|
||||||
if (i1 > i2) return 1;
|
if (i1 > i2) return 1;
|
||||||
|
|
||||||
if (a.callStartIndex < b.callStartIndex) return -1;
|
return Utils.compareInt32(a.callStartIndex, b.callStartIndex);
|
||||||
if (a.callStartIndex > b.callStartIndex) return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
callResults.Reverse();
|
callResults.Reverse();
|
||||||
inlineReturnValues(callResults);
|
inlineReturnValues(callResults);
|
||||||
|
|
|
@ -591,11 +591,7 @@ namespace de4dot {
|
||||||
}
|
}
|
||||||
|
|
||||||
var sortedTargets = new List<Instruction>(targets.Keys);
|
var sortedTargets = new List<Instruction>(targets.Keys);
|
||||||
sortedTargets.Sort((a, b) => {
|
sortedTargets.Sort((a, b) => Utils.compareInt32(a.Offset, b.Offset));
|
||||||
if (a.Offset < b.Offset) return -1;
|
|
||||||
if (a.Offset > b.Offset) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
for (int i = 0; i < sortedTargets.Count; i++)
|
for (int i = 0; i < sortedTargets.Count; i++)
|
||||||
labels[sortedTargets[i]] = string.Format("label_{0}", i);
|
labels[sortedTargets[i]] = string.Format("label_{0}", i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,5 +230,11 @@ namespace de4dot {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int compareInt32(int a, int b) {
|
||||||
|
if (a < b) return -1;
|
||||||
|
if (a > b) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,7 @@ namespace de4dot.deobfuscators.SmartAssembly {
|
||||||
if (mainMethod == null || methods.Count < MIN_HELPER_METHODS)
|
if (mainMethod == null || methods.Count < MIN_HELPER_METHODS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
methods.Sort((a, b) => {
|
methods.Sort((a, b) => Utils.compareInt32(a.Parameters.Count, b.Parameters.Count));
|
||||||
if (a.Parameters.Count < b.Parameters.Count) return -1;
|
|
||||||
if (a.Parameters.Count > b.Parameters.Count) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (int i = 0; i < methods.Count; i++) {
|
for (int i = 0; i < methods.Count; i++) {
|
||||||
var method = methods[i];
|
var method = methods[i];
|
||||||
if (method.Parameters.Count != i + 1)
|
if (method.Parameters.Count != i + 1)
|
||||||
|
|
|
@ -154,11 +154,7 @@ namespace de4dot.deobfuscators {
|
||||||
var fields = new List<UpdatedField>(updatedFields.Values);
|
var fields = new List<UpdatedField>(updatedFields.Values);
|
||||||
if (fields.Count > 0) {
|
if (fields.Count > 0) {
|
||||||
Log.v("Changing field types from object -> real type");
|
Log.v("Changing field types from object -> real type");
|
||||||
fields.Sort((a, b) => {
|
fields.Sort((a, b) => Utils.compareInt32(a.token, b.token));
|
||||||
if (a.token < b.token) return -1;
|
|
||||||
if (a.token > b.token) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
Log.indent();
|
Log.indent();
|
||||||
foreach (var updatedField in fields)
|
foreach (var updatedField in fields)
|
||||||
Log.v("Field {0:X8}: type {1} ({2:X8})", updatedField.token, updatedField.newFieldType.FullName, updatedField.newFieldType.MetadataToken.ToInt32());
|
Log.v("Field {0:X8}: type {1} ({2:X8})", updatedField.token, updatedField.newFieldType.FullName, updatedField.newFieldType.MetadataToken.ToInt32());
|
||||||
|
@ -168,11 +164,7 @@ namespace de4dot.deobfuscators {
|
||||||
var methods = new List<UpdatedMethod>(updatedMethods.Values);
|
var methods = new List<UpdatedMethod>(updatedMethods.Values);
|
||||||
if (methods.Count > 0) {
|
if (methods.Count > 0) {
|
||||||
Log.v("Changing method args and return types from object -> real type");
|
Log.v("Changing method args and return types from object -> real type");
|
||||||
methods.Sort((a, b) => {
|
methods.Sort((a, b) => Utils.compareInt32(a.token, b.token));
|
||||||
if (a.token < b.token) return -1;
|
|
||||||
if (a.token > b.token) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
Log.indent();
|
Log.indent();
|
||||||
foreach (var updatedMethod in methods) {
|
foreach (var updatedMethod in methods) {
|
||||||
Log.v("Method {0:X8}", updatedMethod.token);
|
Log.v("Method {0:X8}", updatedMethod.token);
|
||||||
|
@ -218,10 +210,7 @@ namespace de4dot.deobfuscators {
|
||||||
if (a.arg.Method.MetadataToken.ToInt32() < b.arg.Method.MetadataToken.ToInt32()) return -1;
|
if (a.arg.Method.MetadataToken.ToInt32() < b.arg.Method.MetadataToken.ToInt32()) return -1;
|
||||||
if (a.arg.Method.MetadataToken.ToInt32() > b.arg.Method.MetadataToken.ToInt32()) return 1;
|
if (a.arg.Method.MetadataToken.ToInt32() > b.arg.Method.MetadataToken.ToInt32()) return 1;
|
||||||
|
|
||||||
if (a.arg.Index < b.arg.Index) return -1;
|
return Utils.compareInt32(a.arg.Index, b.arg.Index);
|
||||||
if (a.arg.Index < b.arg.Index) return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PushedArgs {
|
class PushedArgs {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user