internal static void Run(string il2cppRoot, string[] searchDirs, string[] convertDirs) { var output = Path.Combine(Environment.CurrentDirectory, "output").ToNPath(); var data = Path.Combine(Environment.CurrentDirectory, "data").ToNPath(); var symbols = Path.Combine(Environment.CurrentDirectory, "symbols").ToNPath(); var execs = Path.Combine(Environment.CurrentDirectory, "execs").ToNPath(); var mono = Path.Combine(il2cppRoot, "..", "MonoBleedingEdge"); var etc = Path.Combine(mono, "etc").ToNPath(); var lib = Path.Combine(mono, "lib").ToNPath(); var monoSearch = Path.Combine(mono, "lib", "mono", "4.5").ToNPath(); CodeGenOptions.SetToDefaults(); CodeGenOptions.Dotnetprofile = Profile.Net45.Name; CodeGenOptions.EmitMethodMap = true; CodeGenOptions.EmitNullChecks = true; CodeGenOptions.EmitSourceMapping = true; CodeGenOptions.EnableArrayBoundsCheck = true; CodeGenOptions.EnableDivideByZeroCheck = true; CodeGenOptions.EnablePrimitiveValueTypeGenericSharing = true; CodeGenOptions.EnableStacktrace = true; CodeGenOptions.MonoRuntime = false; NPath[] asms; using (Globals.Use()) // needed for il2cpp to behave { //Globals.Naming = new CustomNameService(); asms = AssemblyConverter.ConvertAssemblies(convertDirs, new NPath[0], output, data, symbols, execs, lib, etc, searchDirs.Select(s => s.ToNPath()).Append(monoSearch).ToArray(), null, new NPath[0]).ToArray(); } }
public void Bla() { string file = "C:/Users/Wesley/Desktop/New folder (3)/rt.jar"; using ZipArchive archive = ZipFile.OpenRead(file); AssemblyConverter converter = new AssemblyConverter("Rt"); foreach (ZipArchiveEntry entry in archive.Entries) { using Stream stream = entry.Open(); JavaClass jc = JavaClass.Create(stream); converter.Include(jc); } byte[] bytes = converter.Convert(); Assembly assembly = Assembly.Load(bytes); StringBuilder sb = new StringBuilder(); sb.AppendLine(); foreach (Type t in assembly.GetTypes()) { sb.AppendLine($"Type: {t.FullName}"); } throw new Exception(sb.ToString()); }
private static void AddFile(AssemblyConverter converter, Stream stream) { JavaClass jc = JavaClass.Create(stream); Console.WriteLine($"Finished parsing '{jc.GetName()}'"); converter.Include(jc); }
public static void Main() { string dir = "C:/Users/Wesley/Desktop/New folder (4)/"; AssemblyConverter converter = new AssemblyConverter("Rt"); foreach (string file in Directory.GetFiles(dir)) { if (Path.GetExtension(file) == ".jar") { using ZipArchive archive = ZipFile.OpenRead(file); foreach (ZipArchiveEntry entry in archive.Entries) { if (Path.GetExtension(entry.Name) == ".class") { using Stream stream = entry.Open(); AddFile(converter, stream); } } } else if (Path.GetExtension(file) == ".class") { using Stream stream = File.OpenRead(file); AddFile(converter, stream); } } byte[] bytes = converter.Convert(); File.WriteAllBytes("rt.dll", bytes); foreach (Type type in Assembly.Load(bytes).GetTypes()) { Console.WriteLine($"Type: {type.FullName}"); } }
public void OneOperandTest() { var converter = new AssemblyConverter(); string firstInstruction = "INC R5"; string machineCode = converter.AssemblyConvert(firstInstruction); Assert.NotEmpty(machineCode); Assert.Equal(16, machineCode.Length); Assert.Equal("1110010100000000", machineCode); }
public void TestOneLine() { var converter = new AssemblyConverter(); string firstInstruction = "PUSH R6"; string machineCode = converter.AssemblyConvert(firstInstruction); Assert.NotEmpty(machineCode); Assert.Equal(16, machineCode.Length); Assert.Equal("0000011000000000", machineCode); }
public void TestMov() { var converter = new AssemblyConverter(); string firstInstruction = "MOV R0, R7"; string machineCode = converter.AssemblyConvert(firstInstruction, true); Assert.NotEmpty(machineCode); Assert.Equal(4, machineCode.Length); Assert.Equal("80E0", machineCode); }
public void JumpTest() { var converter = new AssemblyConverter(); string firstInstruction = "JZ R7"; string machineCode = converter.AssemblyConvert(firstInstruction); Assert.NotEmpty(machineCode); Assert.Equal(16, machineCode.Length); Assert.Equal("0100111100000000", machineCode); }
public void TestShift() { var converter = new AssemblyConverter(); string instruction = "SHL R3, A"; string machineCode = converter.AssemblyConvert(instruction, hex: true); Assert.NotEmpty(machineCode); Assert.Equal(4, machineCode.Length); Assert.Equal("B314", machineCode); }
public void EATest() { var converter = new AssemblyConverter(); string firstInstruction = "LDD R1, 0128F"; string machineCode = converter.AssemblyConvert(firstInstruction); Assert.NotEmpty(machineCode); Assert.Contains("\n", machineCode); var lines = machineCode.Split('\n'); string part1 = machineCode.Substring(0, machineCode.IndexOf('\n')); Assert.Equal(16, part1.Length); //Assert.Equal("0011100100000001", part1); //Assert.Equal("1001010001111000", lines[1]); }
public void Loading() { AssemblyConverter converter = new AssemblyConverter("HelloWorld"); foreach (string file in Resource.GetNames("MultipleTypes")) { using Stream stream = Resource.Get(file); JavaClass jc = JavaClass.Create(stream); converter.Include(jc); } byte[] bytes = converter.Convert(); Assembly assembly = Assembly.Load(bytes); StringBuilder sb = new StringBuilder(); sb.AppendLine(); foreach (Type t in assembly.GetTypes()) { sb.AppendLine($"Type: {t.FullName}"); } throw new Exception(sb.ToString()); }