public byte[] Serializer(NashaSettings settings, NashaInstruction instruction) { var buf = new byte[8]; buf[0] = (byte)NashaOpcodes.Stsfld.ShuffledID; var(referenceId, field, isGeneric) = (Tuple <short, IField, bool>)instruction.Operand; Array.Copy(BitConverter.GetBytes(isGeneric), 0, buf, 1, 1); Array.Copy(BitConverter.GetBytes(referenceId), 0, buf, 2, 2); Array.Copy(BitConverter.GetBytes(TokenGetter.GetFieldToken(field)), 0, buf, 4, 4); return(buf); }
private NashaInstruction DisassembleInstruction() { byte code = InstructionReader.ReadByte(); if (!Disassembler.Context.DeoxysOpCodes.TryGetValue(code, out var opCode)) { return(new NashaInstruction(new NashaOpCode(NashaCode.Nop, 0), null)); } var instruction = new NashaInstruction(opCode); instruction.Operand = DisassembleOperand(opCode); Disassembler.Context.Logger.Info($"Disassembled Instruction {instruction}"); return(instruction); }
public byte[] Serializer(NashaSettings settings, NashaInstruction instruction) { return(new[] { (byte)NashaOpcodes.Mul.ShuffledID }); }
public byte[] Serializer(NashaSettings body, NashaInstruction instruction) { return(new[] { (byte)NashaOpcode.Ret }); }
public byte[] Serializer(NashaSettings settings, NashaInstruction instruction) { return(new[] { (byte)NashaOpcode.Nop }); }
private CilInstruction RecompileInstruction(NashaInstruction instruction) { switch (instruction.OpCode.Code) { case NashaCode.Nop: return(new CilInstruction(CilOpCodes.Nop)); case NashaCode.Ret: return(new CilInstruction(CilOpCodes.Ret)); case NashaCode.Ldstr: return(new CilInstruction(CilOpCodes.Ldstr, instruction.Operand)); case NashaCode.Ldarg: return(new CilInstruction(CilOpCodes.Ldarg, instruction.Operand)); case NashaCode.Call: return(new CilInstruction(CilOpCodes.Call, instruction.Operand)); case NashaCode.Br: return(new CilInstruction(CilOpCodes.Br, instruction.Operand)); case NashaCode.LdcI4: return(new CilInstruction(CilOpCodes.Ldc_I4, instruction.Operand)); case NashaCode.Ldloc: return(new CilInstruction(CilOpCodes.Ldloc, instruction.Operand)); case NashaCode.Stloc: return(new CilInstruction(CilOpCodes.Stloc, instruction.Operand)); case NashaCode.BrFalse: return(new CilInstruction(CilOpCodes.Brfalse, instruction.Operand)); case NashaCode.BrTrue: return(new CilInstruction(CilOpCodes.Brtrue, instruction.Operand)); case NashaCode.Pop: return(new CilInstruction(CilOpCodes.Pop)); case NashaCode.Newobj: return(new CilInstruction(CilOpCodes.Newobj, instruction.Operand)); case NashaCode.Castclass: return(new CilInstruction(CilOpCodes.Castclass, instruction.Operand)); case NashaCode.Ldftn: return(new CilInstruction(CilOpCodes.Ldftn, instruction.Operand)); case NashaCode.Dup: return(new CilInstruction(CilOpCodes.Dup)); case NashaCode.Ldfld: return(new CilInstruction(CilOpCodes.Ldfld, instruction.Operand)); case NashaCode.Stfld: return(new CilInstruction(CilOpCodes.Stfld, instruction.Operand)); case NashaCode.Newarr: return(new CilInstruction(CilOpCodes.Newarr, instruction.Operand)); } return(new CilInstruction(CilOpCodes.Nop)); }