Make sure correct integer value arg is boxed for string decrypter
This commit is contained in:
parent
115641fc6b
commit
8d57bf741e
|
@ -163,6 +163,10 @@ namespace de4dot.code {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected MethodDefinition Method {
|
||||||
|
get { return blocks.Method; }
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void inlineAllCalls();
|
protected abstract void inlineAllCalls();
|
||||||
|
|
||||||
// Returns null if method is not a method we should inline
|
// Returns null if method is not a method we should inline
|
||||||
|
@ -222,13 +226,18 @@ namespace de4dot.code {
|
||||||
bool findArgs(CallResult callResult) {
|
bool findArgs(CallResult callResult) {
|
||||||
var block = callResult.block;
|
var block = callResult.block;
|
||||||
var method = callResult.getMethodReference();
|
var method = callResult.getMethodReference();
|
||||||
int numArgs = method.Parameters.Count + (method.HasThis ? 1 : 0);
|
var methodArgs = DotNetUtils.getParameters(method);
|
||||||
|
int numArgs = methodArgs.Count;
|
||||||
var args = new object[numArgs];
|
var args = new object[numArgs];
|
||||||
|
|
||||||
int instrIndex = callResult.callEndIndex - 1;
|
int instrIndex = callResult.callEndIndex - 1;
|
||||||
for (int i = numArgs - 1; i >= 0; i--) {
|
for (int i = numArgs - 1; i >= 0; i--) {
|
||||||
if (!getArg(method, block, ref args[i], ref instrIndex))
|
object arg = null;
|
||||||
|
if (!getArg(method, block, ref arg, ref instrIndex))
|
||||||
return false;
|
return false;
|
||||||
|
if (arg is int)
|
||||||
|
arg = fixIntArg(methodArgs[i].ParameterType, (int)arg);
|
||||||
|
args[i] = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
callResult.args = args;
|
callResult.args = args;
|
||||||
|
@ -236,6 +245,22 @@ namespace de4dot.code {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object fixIntArg(TypeReference type, int value) {
|
||||||
|
if (type.IsPrimitive) {
|
||||||
|
switch (type.FullName) {
|
||||||
|
case "System.Boolean": return value != 0;
|
||||||
|
case "System.Char": return (char)value;
|
||||||
|
case "System.Byte": return (byte)value;
|
||||||
|
case "System.SByte": return (sbyte)value;
|
||||||
|
case "System.Int16": return (short)value;
|
||||||
|
case "System.UInt16": return (ushort)value;
|
||||||
|
case "System.Int32": return (int)value;
|
||||||
|
case "System.UInt32": return (uint)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ApplicationException(string.Format("Wrong type {0}", type));
|
||||||
|
}
|
||||||
|
|
||||||
bool getArg(MethodReference method, Block block, ref object arg, ref int instrIndex) {
|
bool getArg(MethodReference method, Block block, ref object arg, ref int instrIndex) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (instrIndex < 0) {
|
if (instrIndex < 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user