public override ProcedureSignature Deserialize(SerializedSignature ss, Core.Frame frame)
        {
            if (ss == null)
                return null;
            var argser = new ArgumentSerializer(this, Architecture, frame, ss.Convention);
            Identifier ret = null;

            if (ss.ReturnValue != null)
            {
                ret = argser.DeserializeReturnValue(ss.ReturnValue);
            }

            var args = new List<Identifier>();
            this.gr = 0;
            if (ss.Arguments != null)
            {
                for (int iArg = 0; iArg < ss.Arguments.Length; ++iArg)
                {
                    var sArg = ss.Arguments[iArg];
                    Identifier arg = DeserializeArgument(argser, sArg);
                    args.Add(arg);
                }
            }

            var sig = new ProcedureSignature(ret, args.ToArray());
            return sig;
        }
        public override ProcedureSignature Deserialize(SerializedSignature ss, Frame frame)
        {
            if (ss == null)
                return null;
            this.argser = new ArgumentSerializer(this, Architecture, frame, ss.Convention);
            Identifier ret = null;
            int fpuDelta = FpuStackOffset;

            FpuStackOffset = 0;
            if (ss.ReturnValue != null)
            {
                ret = argser.DeserializeReturnValue(ss.ReturnValue);
                fpuDelta += FpuStackOffset;
            }

            FpuStackOffset = 0;
            var args = new List<Identifier>();
            if (ss.Arguments != null)
            {
                for (int iArg = 0; iArg < ss.Arguments.Length; ++iArg)
                {
                    var sArg = ss.Arguments[iArg];
                    var arg = DeserializeArgument(sArg, iArg, ss.Convention);
                    args.Add(arg);
                }
                fpuDelta -= FpuStackOffset;
            }
            FpuStackOffset = fpuDelta;

            var sig = new ProcedureSignature(ret, args.ToArray());
            ApplyConvention(ss, sig);
            return sig;
        }
        private Identifier DeserializeArgument(ArgumentSerializer argser, Argument_v1 sArg)
        {
            Identifier arg;
            if (sArg.Kind != null)
                return sArg.Kind.Accept(argser);

            var dtArg = sArg.Type.Accept(TypeLoader);
            var prim = dtArg as PrimitiveType;
            //if (prim != null && prim.Domain == Domain.Real)
            //{
            //    if (this.fr > 8)
            //    {
            //        arg = argser.Deserialize(sArg, new StackVariable_v1());
            //    }
            //    else
            //    {
            //        arg = argser.Deserialize(sArg, new Register_v1("f" + this.fr));
            //        ++this.fr;
            //    }
            //    return arg;
            //}
            if (dtArg.Size <= 4)
            {
                if (this.gr > 3)
                {
                    arg = argser.Deserialize(sArg, new StackVariable_v1());
                }
                else
                {
                    arg = argser.Deserialize(sArg, new Register_v1("r" + gr));
                    ++this.gr;
                }
                return arg;
            }
            if (dtArg.Size <= 8)
            {
                if (this.gr > 9)
                {
                    arg = argser.Deserialize(sArg, new StackVariable_v1());
                }
                else
                {
                    if ((gr & 1) == 0)
                        ++gr;
                    arg = argser.Deserialize(sArg, new SerializedSequence
                    {
                        Registers = new Register_v1[] { 
                            new Register_v1("r" + gr), 
                            new Register_v1("r" + (gr+1))
                        }
                    });
                    gr += 2;
                }
                return arg;
            }
            throw new NotImplementedException();
        }
		public void Setup()
		{
			svc = new SerializedService();
			svc.Name = "msdos_ioctl_get_device_info";
			svc.SyscallInfo = new SerializedSyscallInfo();
			svc.SyscallInfo.Vector = "21";
			svc.SyscallInfo.RegisterValues = new SerializedRegValue[2];
			svc.SyscallInfo.RegisterValues[0] = new SerializedRegValue("ah", "44");
			svc.SyscallInfo.RegisterValues[1] = new SerializedRegValue("al", "00");
			svc.Signature = new SerializedSignature();
            ArgumentSerializer argSer = new ArgumentSerializer(null, arch, null, null);
            svc.Signature.ReturnValue = argSer.Serialize(new Identifier("C", PrimitiveType.Bool, 
                new FlagGroupStorage((uint) FlagM.CF, "C", PrimitiveType.Byte)));
		}
 public SerializedSignature Serialize(ProcedureSignature sig)
 {
     SerializedSignature ssig = new SerializedSignature();
     if (!sig.ParametersValid)
         return ssig;
     ArgumentSerializer argSer = new ArgumentSerializer(this, Architecture, null, null);
     ssig.ReturnValue = argSer.Serialize(sig.ReturnValue);
     ssig.Arguments = new Argument_v1[sig.Parameters.Length];
     for (int i = 0; i < sig.Parameters.Length; ++i)
     {
         Identifier formal = sig.Parameters[i];
         ssig.Arguments[i] = argSer.Serialize(formal);
     }
     ssig.StackDelta = sig.StackDelta;
     ssig.FpuStackDelta = sig.FpuStackDelta;
     return ssig;
 }
		public ProcedureSignature Deserialize(SerializedSignature ss, Frame frame)
		{
			ArgumentSerializer argser = new ArgumentSerializer(this, arch, frame);
			Identifier ret = null;
			if (ss.ReturnValue != null)
			{
				ret = argser.Deserialize(ss.ReturnValue);
			}
			ArrayList args = new ArrayList();
			if (ss.Arguments != null)
			{
				foreach (SerializedArgument arg in ss.Arguments)
				{
					args.Add(argser.Deserialize(arg));
				}
			}
			ProcedureSignature sig = new ProcedureSignature(
				ret, (Identifier [])args.ToArray(typeof(Identifier)));
			
			ApplyConvention(ss, sig);

			return sig;
		}
Exemple #7
0
		public override Identifier Accept(ArgumentSerializer sser)
		{
			return sser.Deserialize(this);
		}
Exemple #8
0
		public abstract Identifier Accept(ArgumentSerializer sser);
		public void Setup()
		{
			arch = new IntelArchitecture(ProcessorMode.Real);
			sigser = new X86ProcedureSerializer(arch, new TypeLibraryLoader(arch, true), "stdapi");
            argser = new ArgumentSerializer(sigser, arch, arch.CreateFrame(), null);
		}