提交 Virtualization代码
parent
c824891ace
commit
c52884d2d2
|
@ -16,7 +16,7 @@ namespace Obfuz
|
|||
{
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
internal class ObfuzProcess2021 : IPreprocessBuildWithReport, IPostprocessBuildWithReport
|
||||
internal class ObfuzProcess : IPreprocessBuildWithReport, IPostprocessBuildWithReport
|
||||
{
|
||||
private static bool s_obfuscated = false;
|
||||
|
|
@ -15,7 +15,7 @@ namespace Obfuz
|
|||
{
|
||||
if (log)
|
||||
{
|
||||
UnityEngine.Debug.Log($"[BashUtil] RemoveDir dir:{dir}");
|
||||
UnityEngine.Debug.Log($"removeDir dir:{dir}");
|
||||
}
|
||||
|
||||
int maxTryCount = 5;
|
||||
|
@ -41,7 +41,7 @@ namespace Obfuz
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"[BashUtil] RemoveDir:{dir} with exception:{e}. try count:{i}");
|
||||
UnityEngine.Debug.LogError($"removeDir:{dir} with exception:{e}. try count:{i}");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace Obfuz
|
|||
{
|
||||
if (log)
|
||||
{
|
||||
UnityEngine.Debug.Log($"[BashUtil] CopyDir {src} => {dst}");
|
||||
UnityEngine.Debug.Log($"copyDir {src} => {dst}");
|
||||
}
|
||||
RemoveDir(dst);
|
||||
Directory.CreateDirectory(dst);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class CompileContext
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstBytesDataNode : DataNodeAny
|
||||
{
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
|
||||
// create ldstr
|
||||
// RuntimeHelpers.InitializeArray(array, fieldHandle);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstExpression : DataNodeAny
|
||||
{
|
||||
public IFunction function;
|
||||
public readonly List<IDataNode> Inputs = new List<IDataNode>();
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstFieldDataNode : DataNodeAny
|
||||
{
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case DataNodeType.Byte:
|
||||
{
|
||||
// create ldloc.i4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Int32:
|
||||
{
|
||||
// create ldloc.i4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Int64:
|
||||
{
|
||||
// create ldloc.i8
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Float32:
|
||||
{
|
||||
// create ldloc.r4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Float64:
|
||||
{
|
||||
// create ldloc.r8
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Null:
|
||||
{
|
||||
// create ldnull
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new NotImplementedException($"Type:{Type} not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstFromBytesNode : DataNodeAny
|
||||
{
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstPrimitiveDataNode : DataNodeAny
|
||||
{
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case DataNodeType.Byte:
|
||||
{
|
||||
// create ldloc.i4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Int32:
|
||||
{
|
||||
// create ldloc.i4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Int64:
|
||||
{
|
||||
// create ldloc.i8
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Float32:
|
||||
{
|
||||
// create ldloc.r4
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Float64:
|
||||
{
|
||||
// create ldloc.r8
|
||||
break;
|
||||
}
|
||||
case DataNodeType.Null:
|
||||
{
|
||||
// create ldnull
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new NotImplementedException($"Type:{Type} not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class ConstStringDataNode : DataNodeBase<string>
|
||||
{
|
||||
|
||||
public override void Compile(CompileContext ctx)
|
||||
{
|
||||
|
||||
|
||||
// create ldstr
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public class CreateExpressionOptions
|
||||
{
|
||||
public IRandom random;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public abstract class DataNodeBase : IDataNode
|
||||
{
|
||||
public DataNodeType Type { get; protected set; }
|
||||
|
||||
public IDataNode Expr { get; protected set; }
|
||||
|
||||
public abstract object Value { get; protected set; }
|
||||
|
||||
public abstract void Compile(CompileContext ctx);
|
||||
}
|
||||
|
||||
|
||||
public abstract class DataNodeBase<T> : DataNodeBase
|
||||
{
|
||||
public T Value2 { get; protected set; }
|
||||
|
||||
public override object Value
|
||||
{
|
||||
get => Value2;
|
||||
protected set => Value2 = (T)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class DataNodeAny : DataNodeBase
|
||||
{
|
||||
private object _value;
|
||||
public override object Value
|
||||
{
|
||||
get => _value;
|
||||
protected set => _value = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public enum DataNodeType
|
||||
{
|
||||
Byte,
|
||||
Int32,
|
||||
Int64,
|
||||
Float32,
|
||||
Float64,
|
||||
String,
|
||||
Bytes,
|
||||
Null,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Obfuz.Virtualization
|
||||
{
|
||||
|
||||
public interface IDataNode
|
||||
{
|
||||
DataNodeType Type { get; }
|
||||
|
||||
object Value { get; }
|
||||
|
||||
IDataNode Expr { get; }
|
||||
|
||||
void Compile(CompileContext ctx);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public interface IFunction
|
||||
{
|
||||
ConstExpression CreateCallable(IDataNode result, CreateExpressionOptions options);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Obfuz.Virtualization
|
||||
{
|
||||
public interface IRandom
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue