Skip to main content

write_field

Function write_field 

Source
pub unsafe fn write_field<T: Copy>(obj: *mut c_void, offset: u32, value: T)
Expand description

Writes a value of type T into a field of a Mono object at the given byte offset.

The mirror of read_field. Use MonoClassField::offset to obtain the correct offset.

ยงSafety

Same requirements as read_field. Additionally, writing a reference-type field (e.g. a field whose TypeKind is Class or Object) bypasses the GC write barrier and will cause memory corruption if the GC uses a generational or incremental collection scheme. For reference fields, prefer invoking a managed setter via MonoMethod::invoke.