Example #1
0
        private static void Exmp()
        {
            const string c  = "mov [ebp+0x0000000],12;mov [ebp+0x0000004],11;mov [ebp+0x0000008],1;mov [ebp+0x000000c],1;mov [ebp+0x0000010],2;mov [ebp+0x0000014],6;add [ebp+0x0000000],[ebp+0x0000004];mov [ebp+0x0000018],eax;mul [ebp+0x0000008],[ebp+0x000000c];mov [ebp+0x000001c],eax;add [ebp+0x0000018],[ebp+0x000001c];mov [ebp+0x0000018],eax;sub [ebp+0x0000018],2;mov [ebp+0x0000018],eax;mul [ebp+0x0000010],[ebp+0x0000014];mov [ebp+0x000001c],eax;add [ebp+0x0000018],[ebp+0x000001c];mov [ebp+0x0000018],eax;add 0,1;mov [ebp+0x0000020],eax;add [ebp+0x0000020],2;mov [ebp+0x0000020],eax;add [ebp+0x0000020],3;mov [ebp+0x0000020],eax;add [ebp+0x0000020],4;mov [ebp+0x0000020],eax;add [ebp+0x0000020],5;mov [ebp+0x0000020],eax;add [ebp+0x0000020],6;mov [ebp+0x0000020],eax;add [ebp+0x0000020],7;mov [ebp+0x0000020],eax;add [ebp+0x0000020],8;mov [ebp+0x0000020],eax;add [ebp+0x0000020],9;mov [ebp+0x0000020],eax;inf [ebp+0x0000020],0;mov eax,eax;jmp [ebp+0x0000024];neg [ebp+0x0000028];mov [ebp+0x000002c],eax;mov [ebp+0x0000030],[ebp+0x000002c]";
            var          cc = c.Split(";\r\n".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);

            var MRT = new Component.Component(0xFFFFF);

            foreach (var d in cc)
            {
                Instruct.Parse(d).Push(MRT.Cache.Stream);
            }
            var e = 65635;

            MRT.Process.Execute(new VM.Global.InitialProcessData(0, e, e * 3, e * 2, e * 4, 0));
        }
Example #2
0
        public void Call(MethodInfo t)
        {
            if (IsFromCurrentAssembly(t))
            {
                /*  Value: shifset of method from Current address of instruction  (><)0
                 * call 0xXXXXXX                todo: Becarful 0xXXXXXX Is the Offset
                 */
                var instruct = new Instruct();
                instruct.Function = (byte)UAL.NameInstructions.IndexOf(Const.call);
                this.CurrentMethod.Calls.Add(new Label <MethodInfo> {
                    index = this.StreamWriter.Offset, Value = t
                });
                instruct.Desdestination.OperandType = OperandType.imm;
                instruct.Desdestination.DataType    = DataType.Word;
                instruct.Desdestination.Value       = t.Offset - this.StreamWriter.Offset;
                instruct.Push(this.StreamWriter);
            }
            else
            {
                #region

                /*  <loc_Assembly> contain the address of assembly by afect it by the variable assembly
                 *  Offset:Point   shifset of method in assembly >=0
                 *
                 *  eax=<loc_Assembly>+Offset
                 *  Value= eax
                 *
                 * mov eax,[assI]
                 * add eax,offset
                 * call eax
                 */

                #endregion

                Instruct.Parse("mov eax,[esi+" + AssemblyList.IndexOf(t.Return.Space.FullName) + "]").Push(this.StreamWriter);
                this.CurrentMethod.Calls.Add(new Label <MethodInfo> {
                    index = this.StreamWriter.Offset, Value = t
                });
                Instruct.Parse("add eax,0x" + t.Offset.ToString("x4")).Push(this.StreamWriter);
                Instruct.Parse("call eax").Push(this.StreamWriter);
            }
        }
Example #3
0
        private void CallManager(Assembler t, ref Instruct instruct)
        {
            instruct.Desdestination.OperandType = OperandType.Mem;
            Type       Class;
            MethodInfo mi = GetInfoInvokation(t, out Class);

            this.CurrentMethod.Calls.Add(new Label <MethodInfo> {
                index = this.StreamWriter.Offset, Value = mi
            });
            if (IsFromCurrentAssembly(mi))
            {
                /*  Value: shifset of method from Current address of instruction  (><)0
                 * call 0xXXXXXX                todo: Becarful 0xXXXXXX Is the Offset
                 */
                instruct.Desdestination.OperandType = OperandType.imm;
                instruct.Desdestination.DataType    = DataType.Word;
            }
            else
            {
                #region

                /*  <loc_Assembly> contain the address of assembly by afect it by the variable assembly
                 *  Offset:Point   shifset of method in assembly >=0
                 *
                 *  eax=<loc_Assembly>+Offset
                 *  Value= eax
                 *
                 * mov eax,[assI]
                 * add eax,offset
                 * call eax
                 */

                #endregion

                Instruct.Parse("mov eax,[esi+" + AssemblyList.IndexOf(Class.Space.FullName) + "]").Push(this.StreamWriter);
                Instruct.Parse("add eax,0x0000");
                Instruct.Parse("call eax");
                instruct.Desdestination.OperandType = OperandType.Reg;
                instruct.Desdestination.Value       = 0; /*eax*/
            }
        }