I have the following class:
[StructLayout(LayoutKind.Sequential)] class Class { public int Field1; public byte Field2; public short? Field3;
With some tricks around TypedReference.MakeTypedReference, it is possible to obtain the reference to the field, and to the start of the object's data, then just subtract. The method can be found in SharpUtils.
TypedReference.MakeTypedReference