Exemple #1
0
        private int Given_Ilt32(params object [] import)
        {
            var rvaTable = writer.Position;

            writer.WriteBytes(0, (uint)(1 + import.Length) * 4); // Reserve space for uints and terminating zero.
            var strWriter = writer.Clone();                      // write strings after

            writer.Position = rvaTable;                          // rewind to beginning of table.
            foreach (object imp in import)
            {
                var s = imp as string;
                if (s != null)
                {
                    writer.WriteLeInt32((int)strWriter.Position);
                    strWriter.WriteLeInt16(0);
                    strWriter.WriteString(s, Encoding.UTF8);
                    strWriter.WriteByte(0);
                }
                else if (imp is uint)
                {
                    if ((uint)imp != 0)
                    {
                        writer.WriteLeUInt32((uint)imp | 0x80000000);
                    }
                    else
                    {
                        writer.WriteLeUInt32((uint)imp);
                    }
                }
            }
            writer.WriteLeInt32(0);
            writer.Position = strWriter.Position;
            return((int)rvaTable);
        }