I may have figured this out but I'm not sure this is correct. The
logic I'm using is:
if(fieldRef.Resolve().RVA == 0) {
... it's a managed pointer ...
} else {
... it's an unmanaged pointer ...
}
Thanks, Keith
On Sat, Sep 24, 2011 at 12:33 AM, Keith Sheppard <[email protected]> wrote:
> Hello,
>
> I'm writing code that will infer the basic stack types that should be
> present at each instruction during execution. These are: int32, int64,
> native int (unmanaged pointer), F (floating point), O (object
> reference), and & (managed pointer). I guess first off, is this some
> functionality I missed that cecil already will do for me? The rest of
> this email assumes not...
>
> One instruction that I'm having trouble figuring out is ldsflda. EMCA-335
> says:
> "The ldsflda instruction pushes the address (a managed pointer, type
> &, if field refers to a type whose memory is managed; otherwise an
> unmanaged pointer, type native int) of a static field on the stack.
> field is a metadatatoken (a fieldref or fielddef; see Partition II)
> referring to a static fieldmember. (Note that field can be a static
> global with assigned RVA, in which case its memory is unmanaged; where
> RVA stands for Relative Virtual Address, the offset of the field from
> the base address at which its containing PE file is loaded into
> memory)"
>
> Does anyone have hints on how this translates to the cecil API. i.e.,
> Given an ldsflda instruction along with its FieldReference how do I
> determine if a managed or unmanaged pointer will be pushed on the
> stack?
>
> Thanks, Keith
>
> --
> keithsheppard.name
>
--
--
mono-cecil