Expand description
Helpers for accessing vtables (primary and secondary) of server-owned C++ objects.
In C++ with multiple inheritance, each base class with virtuals results in a
distinct vtable. The primary lies at offset 0 of the object; secondaries at
offsets that depend on the sizeof of the preceding bases. The offsets are
fixed per class and known at compile time (after layout analysis via disasm).
This module centralizes the repeated pattern of:
- Adjust the object pointer to point to a subobject (
obj + offset). - Read the secondary vtable (
*subobject). - Load the slot N pointer (
*(vtable + N * sizeof(usize))).
Each specific caller still performs the final transmute to the correct
function type, because the calling convention varies (extern "C",
extern "thiscall", variadic vs fixed arity).
§Example usage
// ILogger at offset 56 inside ICore; logLn at slot [2].
let (this, f_ptr) = unsafe {
vtable::secondary_call_target(core, 56, 2)?
};
let f: LogLnFn = unsafe { std::mem::transmute(f_ptr) };
unsafe { f(this, level, fmt, arg) };Functions§
- secondary_
call_ ⚠target - Combines
subobject_ptr+vtable_slotin a single helper. - subobject_
ptr ⚠ - Returns the subobject pointer at
offsetbytes fromobj. - vtable_
slot ⚠ - Reads the slot
slotpointer from the vtable pointed to bysubobject.