Ejemplo n.º 1
0
        public void loadfile()
        {
            Natives = new Dictionary <uint, Tuple <Stack.DataType, Stack.DataType[]> >();
            string file = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                                       "nativeinfo.dat");

            if (!File.Exists(file))
            {
                return;
            }
            Stream natfile = File.OpenRead(file);

            IO.Reader reader = new IO.Reader(natfile, true);
            while (natfile.Position < natfile.Length)
            {
                uint             native     = reader.ReadUInt32();
                Stack.DataType   returntype = Types.getatindex(reader.ReadByte());
                byte             count      = reader.ReadByte();
                Stack.DataType[] param      = new Stack.DataType[count];
                for (byte i = 0; i < count; i++)
                {
                    param[i] = Types.getatindex(reader.ReadByte());
                }
                Natives.Add(native, new Tuple <Stack.DataType, Stack.DataType[]>(returntype, param));
            }
        }
Ejemplo n.º 2
0
        public void loadfile()
        {
            Natives = new Dictionary <ulong, Tuple <Stack.DataType, Stack.DataType[]> >();
            Stream natfile;
            string file = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                                       "x64nativeinfo.dat");

            if (File.Exists(file))
            {
                natfile = File.OpenRead(file);
            }
            else
            {
                natfile = new MemoryStream(Properties.Resources.x64nativeinfo);
            }
            IO.Reader reader = new IO.Reader(natfile, false);
            while (natfile.Position < natfile.Length)
            {
                ulong            native     = reader.ReadUInt64();
                Stack.DataType   returntype = Types.getatindex(reader.ReadByte());
                byte             count      = reader.ReadByte();
                Stack.DataType[] param      = new Stack.DataType[count];
                for (byte i = 0; i < count; i++)
                {
                    param[i] = Types.getatindex(reader.ReadByte());
                }
                Natives.Add(native, new Tuple <Stack.DataType, Stack.DataType[]>(returntype, param));
            }
        }
Ejemplo n.º 3
0
        public Native UpdateNative(ulong hash, Stack.DataType returns, params Stack.DataType[] param)
        {
            Native native = null;

            lock (Program.ThreadLock)
            {
                if (!TryGetValue(hash, out native))
                {
                    throw new Exception("Unknown Native: " + hash.ToString("X"));
                }

                native.Return = returns.LongName();
                for (int i = 0; i < param.Length; ++i)
                {
                    if (native.Params[i].Vardiac)
                    {
                        break;
                    }
                    if (native.Params[i].StackType.IsUnknown())
                    {
                        native.Params[i].Type = param[i].LongName();
                    }
                }
            }
            return(native);
        }
Ejemplo n.º 4
0
        public void updatenative(uint hash, Stack.DataType returns, params Stack.DataType[] param)
        {
            lock (Program.ThreadLock)
            {
                if (!Natives.ContainsKey(hash))
                {
                    Natives.Add(hash, new Tuple <Stack.DataType, Stack.DataType[]>(returns, param));
                    return;
                }
            }

            Stack.DataType   curret = Natives[hash].Item1;
            Stack.DataType[] curpar = Natives[hash].Item2;

            if (Types.gettype(curret).precedence < Types.gettype(returns).precedence)
            {
                curret = returns;
            }
            for (int i = 0; i < curpar.Length; i++)
            {
                if (Types.gettype(curpar[i]).precedence < Types.gettype(param[i]).precedence)
                {
                    curpar[i] = param[i];
                }
            }
            Natives[hash] = new Tuple <Stack.DataType, Stack.DataType[]>(curret, curpar);
        }
 public bool SetTypeAtIndex(uint index, Stack.DataType type)
 {
     Stack.DataType prev = Vars[(int)index].DataType;
     if (!type.IsUnknown() && (prev.IsUnknown() || prev.LessThan(type)))
     {
         Vars[(int)index].DataType = type;
         return(true);
     }
     return(false);
 }
 public void UpdateNativeReturnType(ulong hash, Stack.DataType datatype)
 {
     if (Program.X64npi.UpdateRetType(hash, datatype) && NativeXRef.ContainsKey(hash))
     {
         foreach (Function f in NativeXRef[hash])
         {
             f.Dirty = true;
         }
     }
 }
Ejemplo n.º 7
0
 public void UpdateNativeParameter(ulong hash, Stack.DataType type, int index)
 {
     if (Program.X64Npi.UpdateParam(hash, type, index))
     {
         foreach (var f in _nativeXRef[hash])
         {
             f.Dirty = true;
         }
     }
 }
Ejemplo n.º 8
0
 public void UpdateNativeReturnType(ulong hash, Stack.DataType dataType)
 {
     if (Program.X64Npi.UpdateRetType(hash, dataType) && _nativeXRef.ContainsKey(hash))
     {
         foreach (var f in _nativeXRef[hash])
         {
             f.Dirty = true;
         }
     }
 }
 public void UpdateStaticType(uint index, Stack.DataType dataType)
 {
     Stack.DataType prev = Statics.GetTypeAtIndex(index);
     if (Statics.SetTypeAtIndex(index, dataType))
     {
         foreach (Function f in Functions)
         {
             f.Dirty = true;
         }
     }
 }
Ejemplo n.º 10
0
 public void updaterettype(uint hash, Stack.DataType returns, bool over = false)
 {
     if (!Natives.ContainsKey(hash))
     {
         return;
     }
     if (Types.gettype(Natives[hash].Item1).precedence < Types.gettype(returns).precedence || over)
     {
         Natives[hash] = new Tuple <Stack.DataType, Stack.DataType[]>(returns, Natives[hash].Item2);
     }
 }
Ejemplo n.º 11
0
 public bool updateparam(uint hash, Stack.DataType type, int paramindex)
 {
     if (!Natives.ContainsKey(hash))
     {
         return(false);
     }
     Stack.DataType[] paramslist = Natives[hash].Item2;
     paramslist[paramindex] = type;
     Natives[hash]          = new Tuple <Stack.DataType, Stack.DataType[]>(Natives[hash].Item1, paramslist);
     return(true);
 }
Ejemplo n.º 12
0
        public bool SetTypeAtIndex(uint index, Stack.DataType type)
        {
            var prev = _vars[(int)index].DataType;

            if (!type.IsUnknown() && (prev.IsUnknown() || prev.Precedence() < type.Precedence()))
            {
                _vars[(int)index].DataType = type;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 13
0
 public bool UpdateRetType(ulong hash, Stack.DataType returns, bool over = false)
 {
     lock (Program.ThreadLock)
     {
         Native native;
         if (TryGetValue(hash, out native) && !native.ReturnParam.FixedType)
         {
             if (native.ReturnParam.StackType.Precedence() < returns.Precedence())
             {
                 native.ReturnParam.Type = returns.LongName();
                 return(true);
             }
         }
         return(false);
     }
 }
Ejemplo n.º 14
0
 public bool UpdateParam(ulong hash, Stack.DataType type, int index)
 {
     lock (Program.ThreadLock)
     {
         Native native;
         if (TryGetValue(hash, out native) && !native.Vardiac && index < native.Params.Count)
         {
             Param p = native.Params[index];
             if (p.StackType.Precedence() < type.Precedence() && !p.FixedType)
             {
                 p.Type = type.LongName();
                 return(true);
             }
         }
         return(false);
     }
 }
Ejemplo n.º 15
0
        public static string Represent(int value, Stack.DataType type)
        {
            switch (type)
            {
            case Stack.DataType.Float:
                return(BitConverter.ToSingle(BitConverter.GetBytes(value), 0).ToString() + "f");

            case Stack.DataType.Bool:
                break;                        //return value == 0 ? "false" : "true";				//still need to fix bools

            case Stack.DataType.FloatPtr:
            case Stack.DataType.IntPtr:
            case Stack.DataType.StringPtr:
            case Stack.DataType.UnkPtr:
                return("NULL");
            }
            return(value.ToString());
        }
Ejemplo n.º 16
0
 public void updateparam(ulong hash, Stack.DataType type, int paramindex)
 {
     if (!Natives.ContainsKey(hash))
     {
         return;
     }
     Stack.DataType[] paramslist = Natives[hash].Item2;
     if (paramindex >= paramslist.Length)
     {
         Stack.DataType[] Old = paramslist;
         paramslist = new Stack.DataType[paramindex + 1];
         for (int i = 0; i < Old.Length; i++)
         {
             paramslist[i] = Old[i];
         }
     }
     paramslist[paramindex] = type;
     Natives[hash]          = new Tuple <Stack.DataType, Stack.DataType[]>(Natives[hash].Item1, paramslist);
 }
Ejemplo n.º 17
0
        public static string Represent(long value, Stack.DataType type)
        {
            switch (type)
            {
            case Stack.DataType.Float:
                return(BitConverter.ToSingle(BitConverter.GetBytes(value), 0).ToString() + "f");

            case Stack.DataType.Bool:
                return(value == 0 ? "false" : "true");    // still need to fix bools

            case Stack.DataType.FloatPtr:
            case Stack.DataType.IntPtr:
            case Stack.DataType.StringPtr:
            case Stack.DataType.UnkPtr:
                return("NULL");
            }
            if (value > Int32.MaxValue && value <= UInt32.MaxValue)
            {
                return(((int)((uint)value)).ToString());
            }
            return(value.ToString());
        }
Ejemplo n.º 18
0
 public string TypeToString(Stack.DataType type)
 {
     return(Types.gettype(type).singlename);
 }
Ejemplo n.º 19
0
 public void SetTypeAtIndex(uint index, Stack.DataType type)
 {
     Vars[(int)index].DataType = type;
 }