Exemplo n.º 1
0
        public override void SetValue(StringToken tkn, string val)
        {
            MetadataStream strs = this.Stream;
            uint           idx  = tkn.Token.Index;
            uint           c    = 0;

            while (strs.Data[idx + c] != 0)
            {
                c++;
            }
            c++;

            byte[]         dat = Encoding.UTF8.GetBytes(val);
            MetadataWriter wtr = new MetadataWriter(strs);

            if (c == dat.Length + 1)
            {
                strs.Position = tkn.Token.Index;
                wtr.Write(dat);
            }
            else
            {
                ResizeChild(tkn, (uint)dat.Length + 1);
                strs.Position = tkn.Token.Index;
                wtr.Write(dat);
                wtr.Write((byte)0);
            }
        }
Exemplo n.º 2
0
        public override void SetValue(USToken tkn, string val)
        {
            MetadataStream strs = this.Stream;

            strs.Position = tkn.Token.Index;
            MetadataReader rdr = new MetadataReader(strs);
            uint           len = rdr.ReadCompressedUInt();

            MetadataWriter wtr = new MetadataWriter(strs);

            byte[] b = Encoding.Unicode.GetBytes(val);
            if (len == b.Length)
            {
                strs.Position = tkn.Token.Index;
                wtr.WriteCompressedUInt(len);
                wtr.Write(b);
            }
            else
            {
                ResizeChild(tkn, (uint)b.Length);
                strs.Position = tkn.Token.Index;
                wtr.WriteCompressedInt(b.Length);
                wtr.Write(b);
            }
        }
Exemplo n.º 3
0
        private void SendGpsData(ref double gpsAltitiude)
        {
            gpsAltitiude += 0.01;

            var metadata = new MetadataStream
            {
                NavigationalData = new NavigationalData
                {
                    Altitude  = gpsAltitiude,
                    Latitude  = _random.Next(-90, 90),
                    Longitude = _random.Next(-180, 180)
                }
            };

            var result = _gpsProviderChannel.QueueMetadata(metadata, DateTime.UtcNow);

            if (result == false)
            {
                Trace.WriteLine(string.Format("{0}: Failed to write to GPS channel", DateTime.UtcNow));
            }
            else
            {
                BeginInvoke(new MethodInvoker(() =>
                {
                    if (sourceComboBox.SelectedIndex == 1)
                    {
                        DisplayMetadata(metadata);
                    }
                }));
            }
        }
Exemplo n.º 4
0
        private static MethodSpec GetVirtualMethod(TypeSpec impl_ts, MethodSpec decl_ms,
                                                   target.Target t, bool allow_non_virtual = false)
        {
            /* Iterate through methods looking for virtual ones */
            var first_mdef = impl_ts.m.GetIntEntry(MetadataStream.tid_TypeDef,
                                                   impl_ts.tdrow, 5);
            var last_mdef = impl_ts.m.GetLastMethodDef(impl_ts.tdrow);

            for (uint mdef_row = first_mdef; mdef_row < last_mdef; mdef_row++)
            {
                var flags = impl_ts.m.GetIntEntry(MetadataStream.tid_MethodDef,
                                                  (int)mdef_row, 2);

                if (allow_non_virtual || (flags & 0x40) == 0x40)
                {
                    MethodSpec impl_ms;
                    impl_ts.m.GetMethodDefRow(MetadataStream.tid_MethodDef,
                                              (int)mdef_row, out impl_ms, impl_ts.gtparams, null);
                    impl_ms.type = impl_ts;

                    if ((flags & 0x400) != 0x400)
                    {
                        // Not marked abstract
                        if (MetadataStream.CompareString(impl_ms.m,
                                                         impl_ms.m.GetIntEntry(MetadataStream.tid_MethodDef, (int)mdef_row, 3),
                                                         decl_ms.m,
                                                         decl_ms.m.GetIntEntry(MetadataStream.tid_MethodDef, (int)decl_ms.mdrow, 3)))
                        {
                            if (MetadataStream.CompareSignature(impl_ms.m, impl_ms.msig,
                                                                impl_ts.gtparams, null,
                                                                decl_ms.m, decl_ms.msig, impl_ts.gtparams, null))
                            {
                                // this is the correct one
                                return(impl_ms);
                            }
                            if (MetadataStream.CompareSignature(impl_ms.m, impl_ms.msig,
                                                                impl_ts.gtparams, null,
                                                                decl_ms.m, decl_ms.msig, decl_ms.gtparams, null))
                            {
                                // this is the correct one
                                return(impl_ms);
                            }
                        }
                    }
                }
            }

            // if not found, look to base classes
            var bc = impl_ts.GetExtends();

            if (bc != null)
            {
                return(GetVirtualMethod(bc, decl_ms, t, allow_non_virtual));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 public StandAloneSigMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <StandAloneSigEntry>();
     foreach (StandAloneSigMetadataTableRow current in methods)
     {
         this.Items.Add(new StandAloneSigEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public FieldLayoutMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <FieldLayoutEntry>();
     foreach (FieldLayoutMetadataTableRow current in methods)
     {
         this.Items.Add(new FieldLayoutEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public CustomAttributeMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <CustomAttributeEntry>();
     foreach (CustomAttributeMetadataTableRow current in methods)
     {
         this.Items.Add(new CustomAttributeEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public NestedClassMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <NestedClassEntry>();
     foreach (NestedClassMetadataTableRow current in methods)
     {
         this.Items.Add(new NestedClassEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
Exemplo n.º 9
0
 public EventMapMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <EventMapEntry>();
     foreach (EventMapMetadataTableRow current in methods)
     {
         this.Items.Add(new EventMapEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
Exemplo n.º 10
0
 public AssemblyRefMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <AssemblyRefEntry>();
     foreach (AssemblyRefMetadataTableRow current in methods)
     {
         this.Items.Add(new AssemblyRefEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initialises a new instance of the MethodDefMetadataWrapper.
 /// </summary>
 /// <param name="file">The file the metadata was loaded from</param>
 /// <param name="types">The methods to wrap.</param>
 public TypeDefMetadataWrapper(MetadataStream file, List <MetadataRow> types)
 {
     this.Items = new List <TypeDefEntry>();
     foreach (TypeDefMetadataTableRow current in types)
     {
         this.Items.Add(new TypeDefEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public DeclSecurityMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <DeclSecurityEntry>();
     foreach (DeclSecurityMetadataTableRow current in methods)
     {
         this.Items.Add(new DeclSecurityEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public GenericParamMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <GenricParamEntry>();
     foreach (GenericParamMetadataTableRow current in methods)
     {
         this.Items.Add(new GenricParamEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public ManifestResourceMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <ManifestResourceEntry>();
     foreach (ManifestResourceMetadataTableRow current in methods)
     {
         this.Items.Add(new ManifestResourceEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
 public ModuleMetadataWrapper(MetadataStream file, List <MetadataRow> modules)
 {
     this.Items = new List <ModuleEntry>();
     foreach (ModuleMetadataTableRow current in modules)
     {
         this.Items.Add(new ModuleEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
Exemplo n.º 16
0
 public InterfaceImplMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
 {
     this.Items = new List <InerfaceImplEntry>();
     foreach (InterfaceImplMetadataTableRow current in methods)
     {
         this.Items.Add(new InerfaceImplEntry(file.OwningFile.GetMetadataDirectory(), current));
     }
 }
Exemplo n.º 17
0
            public void AddStream(MetadataStream stream)
            {
                var buffer = stream.CanCreateBuffer
                    ? ((IBufferProvider)stream).CreateBuffer()
                    : stream;

                _streams.Add(stream, buffer);
                Segments.Add(buffer);
            }
Exemplo n.º 18
0
        private static void LayoutString(Code c)
        {
            corlib = c.ms.m.al.GetAssembly("mscorlib");

            var ts = corlib.GetSimpleTypeSpec(0x0e);

            length = GetFieldOffset(ts, "length", c.t, out var is_tls);
            sc     = GetFieldOffset(ts, "start_char", c.t, out is_tls);
        }
Exemplo n.º 19
0
        public ParamMetadataWrapper(MetadataStream file, List <MetadataRow> methods)
        {
            this.Items = new List <ParamEntry>();
            int counter = 1;

            foreach (ParamMetadataTableRow current in methods)
            {
                this.Items.Add(new ParamEntry(counter++, file.OwningFile.GetMetadataDirectory(), current));
            }
        }
Exemplo n.º 20
0
            public TypeDefBuilder(BuildReferences references, TypeDefMetadataTableRow fromRow)
            {
                _references = references;

                _assembly       = references.Assembly;
                _fromRow        = fromRow;
                _metadata       = references.Metadata;
                _map            = references.Map;
                _metadataStream = _metadata.GetMetadataStream();
            }
Exemplo n.º 21
0
        public static ConstantInfo CreateFromMetadata(AssemblyDef assembly, MetadataStream stream, ConstantMetadataTableRow row)
        {
            // we are not doing anything with this at the moment but it stores the details of constants
            // indirectly via the BlobIndex, it's parent is obtainable via a HasConstant CodedIndex in
            // the metadata row.
            // The values here are for fields and parameters, so we can say that the default values for
            // parameters are accessible via these records.

            return(new ConstantInfo());
        }
Exemplo n.º 22
0
        public override byte[] GetValue(BlobToken tkn)
        {
            MetadataStream strs = this.Stream;
            MetadataReader rdr  = new MetadataReader(strs);

            rdr.BaseStream.Position = tkn.Token.Index;

            int c = rdr.ReadCompressedInt();

            return(rdr.ReadBytes(c));
        }
Exemplo n.º 23
0
        public override void SetValue(GUIDToken tkn, Guid val)
        {
            if (tkn.Token.Index == 0)
            {
                return;
            }
            MetadataStream strs = this.Stream;
            MetadataWriter wtr  = new MetadataWriter(strs);

            strs.Position = (tkn.Token.Index - 1) * 16;
            wtr.Write(val.ToByteArray());
        }
Exemplo n.º 24
0
            public MethodDefBuilder(BuildReferences references, TypeDef container, MethodMetadataTableRow fromRow)
            {
                _metadata       = references.Metadata;
                _map            = references.Map;
                _assembly       = references.Assembly;
                _container      = container;
                _fromRow        = fromRow;
                _metadataStream = _metadata.Streams[Streams.MetadataStream] as MetadataStream;
                _blobStream     = _metadata.Streams[Streams.BlobStream] as BlobStream;

                _references = references;
            }
Exemplo n.º 25
0
        private void SendBoundingBoxData(Rectangle boundingBox, Vector dummyCenterOfGravity)
        {
            const int objectId = 1;

            var metadata = new MetadataStream
            {
                VideoAnalyticsItems =
                {
                    new VideoAnalytics
                    {
                        Frames =
                        {
                            new Frame(DateTime.UtcNow)
                            {
                                Objects =
                                {
                                    new OnvifObject(objectId)
                                    {
                                        Appearance = new Appearance
                                        {
                                            Shape = new Shape
                                            {
                                                BoundingBox     = boundingBox,
                                                CenterOfGravity = dummyCenterOfGravity
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var result = _boundingBoxProviderChannel.QueueMetadata(metadata, DateTime.UtcNow);

            if (result == false)
            {
                Trace.WriteLine(string.Format("{0}: Failed to write to bounding box channel", DateTime.UtcNow));
            }
            else
            {
                MoveBoundingBox(boundingBox);
                BeginInvoke(new MethodInvoker(() =>
                {
                    if (sourceComboBox.SelectedIndex == 0)
                    {
                        DisplayMetadata(metadata);
                    }
                }));
            }
        }
Exemplo n.º 26
0
        public override uint GetValueLen(StringToken tkn)
        {
            MetadataStream strs = this.Stream;
            uint           idx  = tkn.Token.Index;
            uint           c    = 0;

            do
            {
                c++;
            } while (strs.Data[idx + c] != 0);

            return(c + 1);
        }
Exemplo n.º 27
0
        public CachingRequestor(MetadataStream mstream = null)
        {
            m  = new CachingIndividualRequestor <layout.Layout.MethodSpecWithEhdr>(mstream);
            eh = new CachingIndividualRequestor <layout.Layout.MethodSpecWithEhdr>(mstream);
            bm = new CachingIndividualRequestor <layout.Layout.MethodSpecWithEhdr>(mstream);
            vt = new CachingIndividualRequestor <TypeSpec>(mstream);
            sf = new CachingIndividualRequestor <TypeSpec>(mstream);
            d  = new CachingIndividualRequestor <TypeSpec>(mstream);

#if DEBUG
            d.DebugCheck = CheckInstatiated;
            m.DebugCheck = CheckGMInstantiated;
#endif
        }
Exemplo n.º 28
0
        public override Guid GetValue(GUIDToken tkn)
        {
            MetadataStream strs = this.Stream;

            if (tkn.Token.Index == 0)
            {
                return(new Guid());
            }
            MetadataReader rdr = new MetadataReader(strs);

            rdr.BaseStream.Position = (tkn.Token.Index - 1) * 16;

            return(new Guid(rdr.ReadBytes(16)));
        }
        public MetadataStreamEntry(MetadataStream metadataStream)
            : base(metadataStream.Name)
        {
            Entry tables = new Entry("Tables");

            foreach (KeyValuePair <MetadataTables, MetadataRow[]> o in metadataStream.Tables)
            {
                string name       = o.Key.ToString() + " (" + o.Value.Length + ")";
                Entry  tableEntry = Entry.Create(name);
                tableEntry.Data = this.ConvertTable(metadataStream, o.Key.ToString(), o.Value.ToList());
                tables.Children.Add(tableEntry);
            }
            this.Children.Add(tables);
        }
Exemplo n.º 30
0
 private static int GetVTableIndex(MethodSpec ms, List <VTableItem> list)
 {
     for (int idx = 0; idx < list.Count; idx++)
     {
         var i = list[idx];
         if (MetadataStream.CompareString(ms.m, ms.m.GetIntEntry(MetadataStream.tid_MethodDef, ms.mdrow, 3),
                                          i.unimpl_meth.m, i.unimpl_meth.m.GetIntEntry(MetadataStream.tid_MethodDef, i.unimpl_meth.mdrow, 3)))
         {
             if (MetadataStream.CompareSignature(ms, i.unimpl_meth))
             {
                 return(idx);
             }
         }
     }
     return(-1);
 }
Exemplo n.º 31
0
 public virtual void VisitMetadataStreamHeader(MetadataStream.MetadataStreamHeader header)
 {
 }
Exemplo n.º 32
0
 public virtual void VisitMetadataStream(MetadataStream stream)
 {
 }
Exemplo n.º 33
0
 internal MetadataStreamHeader(MetadataStream stream)
 {
     m_stream = stream;
 }