コード例 #1
0
ファイル: NETMethodReader.cs プロジェクト: Rex-Hays/GNIDA2
        internal MethodBodySection ReadFatSection(byte flag)
        {
            MethodBodySection section = new MethodBodySection(flag);
            peImage.SetOffset(peImage.Stream.Position - 1);
            int count = (BitConverter.ToInt32(peImage.ReadBytes(4),0) >> 8) / 0x18;

            for (int i = 0; i < count; i++)
            {
               ExceptionHandler handler = new ExceptionHandler((ExceptionHandlerType)(BitConverter.ToInt32(peImage.ReadBytes(4),0) & 7),
                        BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                        BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                        BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                        BitConverter.ToInt32(peImage.ReadBytes(4), 0));

                if (handler.Type == ExceptionHandlerType.Catch)
                    try
                    {
                        handler.CatchType = (TypeReference)methodbody.Method._netheader.TokenResolver.ResolveMember(BitConverter.ToUInt32(peImage.ReadBytes(4), 0));
                    }
                    catch { handler.CatchType = methodbody.Method._netheader.TypeSystem.Object; }

                else if (handler.Type == ExceptionHandlerType.Filter)
                    handler.FilterStart = BitConverter.ToInt32(peImage.ReadBytes(4), 0);
                else
                    peImage.ReadBytes(4);
                section._handlers.Add(handler);
            }
            return section;
        }
コード例 #2
0
ファイル: NETMethodReader.cs プロジェクト: Rex-Hays/GNIDA2
        internal MethodBodySection ReadSmallSection(byte flag)
        {
            MethodBodySection section = new MethodBodySection(flag);

            int count = peImage.Reader.ReadByte() / 12;

            peImage.ReadBytes(2);

            for (int i = 0; i < count; i++)
            {
                ExceptionHandler handler = new ExceptionHandler((ExceptionHandlerType)(BitConverter.ToInt16(peImage.ReadBytes(2), 0) & 7),
                                                                BitConverter.ToInt16(peImage.ReadBytes(2), 0),
                                                                peImage.Reader.ReadByte(),
                                                                BitConverter.ToInt16(peImage.ReadBytes(2), 0),
                                                                peImage.Reader.ReadByte());

                if (handler.Type == ExceptionHandlerType.Catch)
                {
                    handler.CatchType = (TypeReference)methodbody.Method._netheader.TokenResolver.ResolveMember(BitConverter.ToUInt32(peImage.ReadBytes(4), 0));
                }
                else if (handler.Type == ExceptionHandlerType.Filter)
                {
                    handler.FilterStart = BitConverter.ToInt32(peImage.ReadBytes(4), 0);
                }
                else
                {
                    peImage.ReadBytes(4);
                }
                section._handlers.Add(handler);
            }
            return(section);
        }
コード例 #3
0
ファイル: NETMethodReader.cs プロジェクト: Rex-Hays/GNIDA2
        internal void ReadSections()
        {
            peImage.SetOffset(rawoffset + methodbody.HeaderSize + methodbody.CodeSize);


            List <MethodBodySection> sections = new List <MethodBodySection>();
            MethodBodySection        section  = ReadSection();

            sections.Add(section);

            while (section.HasMoreSections)
            {
                section = ReadSection();
                sections.Add(section);
            }

            this.sections = sections.ToArray();
        }
コード例 #4
0
ファイル: NETMethodReader.cs プロジェクト: Rex-Hays/GNIDA2
        internal MethodBodySection ReadFatSection(byte flag)
        {
            MethodBodySection section = new MethodBodySection(flag);

            peImage.SetOffset(peImage.Stream.Position - 1);
            int count = (BitConverter.ToInt32(peImage.ReadBytes(4), 0) >> 8) / 0x18;

            for (int i = 0; i < count; i++)
            {
                ExceptionHandler handler = new ExceptionHandler((ExceptionHandlerType)(BitConverter.ToInt32(peImage.ReadBytes(4), 0) & 7),
                                                                BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                                                                BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                                                                BitConverter.ToInt32(peImage.ReadBytes(4), 0),
                                                                BitConverter.ToInt32(peImage.ReadBytes(4), 0));

                if (handler.Type == ExceptionHandlerType.Catch)
                {
                    try
                    {
                        handler.CatchType = (TypeReference)methodbody.Method._netheader.TokenResolver.ResolveMember(BitConverter.ToUInt32(peImage.ReadBytes(4), 0));
                    }
                    catch { handler.CatchType = methodbody.Method._netheader.TypeSystem.Object; }
                }

                else if (handler.Type == ExceptionHandlerType.Filter)
                {
                    handler.FilterStart = BitConverter.ToInt32(peImage.ReadBytes(4), 0);
                }
                else
                {
                    peImage.ReadBytes(4);
                }
                section._handlers.Add(handler);
            }
            return(section);
        }
コード例 #5
0
ファイル: NETMethodReader.cs プロジェクト: Rex-Hays/GNIDA2
        internal MethodBodySection ReadSmallSection(byte flag)
        {
            MethodBodySection section = new MethodBodySection(flag);

            int count = peImage.Reader.ReadByte() / 12;
            peImage.ReadBytes(2);

            for (int i = 0; i < count; i++)
            {
                ExceptionHandler handler = new ExceptionHandler((ExceptionHandlerType)(BitConverter.ToInt16(peImage.ReadBytes(2), 0) & 7),
                        BitConverter.ToInt16(peImage.ReadBytes(2), 0),
                        peImage.Reader.ReadByte(),
                        BitConverter.ToInt16(peImage.ReadBytes(2), 0),
                        peImage.Reader.ReadByte());

                if (handler.Type == ExceptionHandlerType.Catch)
                    handler.CatchType = (TypeReference)methodbody.Method._netheader.TokenResolver.ResolveMember(BitConverter.ToUInt32(peImage.ReadBytes(4), 0));
                else if (handler.Type == ExceptionHandlerType.Filter)
                    handler.FilterStart = BitConverter.ToInt32(peImage.ReadBytes(4), 0);
                else
                    peImage.ReadBytes(4);
                section._handlers.Add(handler);

            }
            return section;
        }