Hi,

That should be pretty easy. A FieldDefinition has a byte[] InitialValue
property that you need to set.

Jb

On Mon, Apr 1, 2019 at 10:05 AM Azengar <[email protected]> wrote:

> I've been struggling with this problem for a while. What I'm trying to do
> is generate a rather large array of constant bytes using mono-cecil
> and I understand that I cannot use the FieldDefinition.Constant and
> FieldDefinition.InitialValue fields because the byte[] type is not a value
> type,
> but I've peeked at some .net code with ildasm and it seems to do the
> following:
>
> .class private auto ansi sealed '<PrivateImplementationDetails>'
>        extends [mscorlib]System.Object
> {
>   .custom instance void
> [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()
> = ( 01 00 00 00 )
>   .field static assembly initonly int32
> BD346A9E43DFFF4439275DD65DC7D20506F6FDD9 at I_00003E84
> } // end of class '<PrivateImplementationDetails>'
>
>
> // =============================================================
>
> .data cil I_00003E84 = bytearray (
>                  00 15 21 06)
>
> Basically it creates a custom class containing a field with a reference to
> some .data that contains the constant bytes and then use this field every
> time this particular sequence of bytes is used.
>
> I would like to imitate this behavior, how should I go about it? More
> specifically, how could I create some bytes in the .data section and then
> reference them as the value of my field.
> Thanks to anyone taking the time to look at this, and if this has already
> been answered I apologize.
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to