Ejemplo n.º 1
0
        internal static Function FromBinaryReader(BinaryReader reader, AxData parent, int index)
        {
            Function ret = new Function(index);

            ret.dllIndex      = reader.ReadInt16();
            ret.functionIndex = reader.ReadInt16();

            int paramStart = reader.ReadInt32();
            int paramCount = reader.ReadInt32();

            if (paramCount != 0)
            {
                ret.functionParams = parent.FunctionParams.GetRange(paramStart, paramCount);
            }
            ret.strIndex = reader.ReadInt32();
            if (ret.strIndex >= 0)
            {
                ret.defaultName = parent.ReadStringLiteral(ret.strIndex);
            }
            ret.paramSizeSum = reader.ReadInt32();
            ret.labelIndex   = reader.ReadInt32();

            ret.int_0 = reader.ReadInt16();
            ret.flags = reader.ReadInt16();
            switch (ret.Type)
            {
            case FunctionType.defcfunc:
            case FunctionType.deffunc:
                Label label = parent.GetLabel(ret.labelIndex);
                if (label != null)
                {
                    label.SetFunction(ret);
                }
                ret.label = label;
                break;

            case FunctionType.func:
            case FunctionType.cfunc:
            case FunctionType.comfunc:
                Usedll dll = parent.GetUsedll(ret.dllIndex);
                if (dll != null)
                {
                    dll.AddFunction(ret);
                }
                ret.dll = dll;
                break;

            case FunctionType.module:
                parent.Modules.Add(ret);
                break;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        internal static Usedll FromBinaryReader(BinaryReader reader, AxData parent, int index)
        {
            Usedll ret = new Usedll(index);

            ret.type = reader.ReadInt32();
            int nameOffset = reader.ReadInt32();

            ret.int_2 = reader.ReadInt32();
            int clsNameOffset = reader.ReadInt32();

            switch (ret.Type)
            {
            case UsedllType.usecom:
                ret.name    = parent.ReadIidCodeLiteral(nameOffset);
                ret.clsName = parent.ReadStringLiteral(clsNameOffset);
                break;

            case UsedllType.uselib:
                ret.name = parent.ReadStringLiteral(nameOffset);
                break;
            }

            return(ret);
        }
Ejemplo n.º 3
0
        internal void ReadPreprocessor(Hsp3Dictionary dictionary)
        {
            if (!isStarted)
            {
                throw new InvalidOperationException("LoadStartが呼び出されていません");
            }
            if (header == null)
            {
                throw new InvalidOperationException("ヘッダーが読み込まれていません");
            }
            if (header.RuntimeStart != 0)
            {
                string runtimeName = ReadString((int)header.RuntimeStart, (int)(header.CodeStart - header.RuntimeStart));
                if (runtimeName != null)
                {
                    runtime = new Runtime(runtimeName);
                }
            }
            uint count = header.LabelCount;

            for (int i = 0; i < count; i++)
            {
                long offset = seekOrigin + header.LabelStart + ((int)HeaderDataSize.Label * i);
                reader.BaseStream.Seek(offset, SeekOrigin.Begin);
                labels.Add(Label.FromBinaryReader(reader, this, i));
            }

            count = header.DllCount;
            for (int i = 0; i < count; i++)
            {
                long offset = seekOrigin + header.DllStart + ((int)HeaderDataSize.Dll * i);
                reader.BaseStream.Seek(offset, SeekOrigin.Begin);
                dlls.Add(Usedll.FromBinaryReader(reader, this, i));
            }

            count = header.ParameterCount;
            for (int i = 0; i < count; i++)
            {
                long offset = seekOrigin + header.ParameterStart + ((int)HeaderDataSize.Parameter * i);
                reader.BaseStream.Seek(offset, SeekOrigin.Begin);
                functionParams.Add(Param.FromBinaryReader(reader, this, i));
            }

            count = header.FunctionCount;
            for (int i = 0; i < count; i++)
            {
                long offset = seekOrigin + header.FunctionStart + ((int)HeaderDataSize.Function * i);
                reader.BaseStream.Seek(offset, SeekOrigin.Begin);
                functions.Add(Function.FromBinaryReader(reader, this, i));
            }

            count = header.PluginCount;
            for (int i = 0; i < count; i++)
            {
                long offset = seekOrigin + header.PluginStart + ((int)HeaderDataSize.Plugin * i);
                reader.BaseStream.Seek(offset, SeekOrigin.Begin);
                plugIns.Add(PlugIn.FromBinaryReader(reader, this, i));
            }
            if ((count != 0) && (header.PluginParameterCount != 0))
            {
                plugIns[0].ExtendedTypeCount = (int)header.PluginParameterCount;
            }

            foreach (Param param in functionParams)
            {
                param.SetFunction(this);
            }
            RenameFunctions(dictionary);

            ReadDebugInfo();
        }