Exemplo n.º 1
0
        protected static void HandleNumberSizes(LineBuffer Buffer, Object Data)
        {
            String str = Buffer.GetKey(true);

            if (str.Equals("NUMBER"))
            {
                //TODO assert
                HavokScript.Header.NumSize = (int)Buffer.GetValue().NumVal;
                HandleNumberSizes(Buffer, Data);
                return;
            }
            if (str.Equals("SIZE_T"))
            {
                //TODO assert
                HavokScript.Header.SizeSize = (int)Buffer.GetValue().NumVal;
                HandleNumberSizes(Buffer, Data);
                return;
            }
            if (str.Equals("INSTRUCTION"))
            {
                //TODO assert
                HavokScript.Header.AltSize = (int)Buffer.GetValue().NumVal;
                HandleNumberSizes(Buffer, Data);
                return;
            }
            if (str.Equals("INTEGER"))
            {
                //TODO assert
                HavokScript.Header.IntSize = (int)Buffer.GetValue().NumVal;
                HandleNumberSizes(Buffer, Data);
                return;
            }
        }
Exemplo n.º 2
0
        protected static void HandleHeader(LineBuffer Buffer, Object Data)
        {
            if (Buffer.GetKey(true).Equals("START_NUMBER_SIZES"))
            {
                ReadBlock(Buffer, "NUMBER_SIZES", HandleNumberSizes, null);
                HandleHeader(Buffer, Data);
                return;
            }


            if (Buffer.GetKey(true).Equals("VERSION"))
            {
                //TODO assert
                HavokScript.Header.Version = (int)Buffer.GetValue().NumVal;
                HandleHeader(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("LENDIAN"))
            {
                //TODO assert
                HavokScript.Header.IsLE = Buffer.GetValue().BoolVal;
                HandleHeader(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("UNK"))
            {
                HandleHeader(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("FLAGS"))
            {
                //TODO assert
                HavokScript.Header.Flags = (int)Buffer.GetValue().NumVal;
                HandleHeader(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TYPES"))
            {
                //TODO assert
                HavokScript.Header.Types = (int)Buffer.GetValue().NumVal;
                HandleHeader(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("SHARE"))
            {
                //TODO assert
                HavokScript.Header.Share = Buffer.GetValue().BoolVal;
                HandleHeader(Buffer, Data);
                return;
            }
        }
Exemplo n.º 3
0
        protected static void HandleConstants(LineBuffer Buffer, Object Data)
        {
            Stub Current = (Stub)Data;

            if (Buffer.GetKey(true).Equals("END_CONSTANTS"))
            {
                return;
            }


            if (Buffer.GetKey(true).Equals("TSTRING"))
            {
                LineData[] data = Buffer.Next(false);
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(data.Length == 1 ? "" : data[1].Raw));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TNUMBER"))
            {
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(Buffer.GetValue().NumVal));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TBOOLEAN"))
            {
                Current.Constants.Constants.Add(ConstantIndex++, new Constant(Buffer.GetValue().BoolVal));
                HandleConstants(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("TNIL"))
            {
                Buffer.GetValue();
                Current.Constants.Constants.Add(ConstantIndex++, new Constant());
                HandleConstants(Buffer, Data);
                return;
            }
        }
Exemplo n.º 4
0
        protected static void HandleMethod(LineBuffer Buffer, Object Data)
        {
            Stub Current = (Stub)Data;

            if (Buffer.GetKey(true).Equals("START_DBG"))
            {
                if (!ReadBlock(Buffer, "DBG", HandleDebug, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("START_CONSTANTS"))
            {
                ConstantIndex = 0;
                if (!ReadBlock(Buffer, "CONSTANTS", HandleConstants, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }


            if (Buffer.GetKey(true).Equals("START_CODE"))
            {
                if (!ReadBlock(Buffer, "CODE", HandleCodes, Data))
                {
                    return;
                }
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("START_CLOSURE"))
            {
                if (!ReadBlock(Buffer, "CLOSURE", HandleClosure, new Stub(Current, (int)Buffer.Next(true)[1].NumVal)))
                {
                    return;
                }

                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("FLAGS"))
            {
                //TODO assert
                Current.Flags = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("PARAMS"))
            {
                //TODO assert
                Current.Parameters = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("UPVALS"))
            {
                //TODO assert
                Current.UpVals = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }

            if (Buffer.GetKey(true).Equals("REGCNT"))
            {
                //TODO assert
                Current.Registers = (int)Buffer.GetValue().NumVal;
                HandleMethod(Buffer, Data);
                return;
            }
        }