Skip to main content

PCodeMethod

Struct PCodeMethod 

Source
pub struct PCodeMethod<'a> { /* private fields */ }
Expand description

A single P-Code method/procedure within a VB6 object.

Provides access to the procedure’s metadata (frame size, proc size) and a streaming iterator over its decoded P-Code instructions.

Implementations§

Source§

impl<'a> PCodeMethod<'a>

Source

pub fn parse( map: &AddressMap<'a>, methods_va: u32, index: u16, ) -> Result<Self, Error>

Parses a P-Code method from a method table entry.

The method table at methods_va contains 4-byte VA entries. For P-Code methods the VA points to a call stub (mov edx, <rtmi_addr>; call ProcCallEngine); this function detects the stub, extracts the RTMI address, parses the ProcDscInfo, and locates the P-Code byte stream.

§Arguments
  • map - Address map for VA-to-offset resolution.
  • methods_va - Base VA of the method dispatch table.
  • index - Zero-based slot within the table.
§Returns

A PCodeMethod with the parsed procedure descriptor, the raw P-Code bytes, and the constant pool base VA.

§Errors

Returns an error if any VA in the resolution chain (method table entry, stub, ProcDscInfo, ObjectInfo, or P-Code region) cannot be resolved to valid file offsets.

Source

pub fn proc_dsc(&self) -> &ProcDscInfo<'a>

Returns the ProcDscInfo (RTMI) for this method.

Source

pub fn frame_size(&self) -> u16

Stack frame size for local variables.

Source

pub fn proc_size(&self) -> u16

Size of the P-Code byte stream in bytes.

Source

pub fn pcode_bytes(&self) -> &'a [u8]

Raw P-Code bytes for this method (slice into the file buffer).

Source

pub fn data_const_va(&self) -> u32

Constant pool base VA for resolving string/API references.

Source

pub fn pcode_va(&self) -> u32

VA of the first P-Code byte in the PE image.

This is the address where the P-Code instruction stream begins, computed as proc_dsc_va - proc_size.

Source

pub fn proc_dsc_va(&self) -> u32

VA of the ProcDscInfo (RTMI) structure in the PE image.

The ProcDscInfo immediately follows the P-Code byte stream.

Source

pub fn stub_va(&self) -> u32

VA of the call stub or direct ProcDscInfo pointer.

This is the raw VA from the method dispatch table entry — the native stub code (mov edx, <RTMI>; call ProcCallEngine) that launches the P-Code interpreter for this method.

Source

pub fn instructions(&self) -> InstructionIterator<'a>

Returns a streaming iterator over decoded P-Code instructions.

Source

pub fn constant_pool<'m>(&self, map: &'m AddressMap<'a>) -> ConstantPool<'m>
where 'a: 'm,

Creates a ConstantPool reader for this method’s constant pool.

The constant pool is shared by all methods in the same object and is used to resolve %s operands (string literals, API stubs, etc.).

Trait Implementations§

Source§

impl<'a> Debug for PCodeMethod<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PCodeMethod<'a>

§

impl<'a> RefUnwindSafe for PCodeMethod<'a>

§

impl<'a> Send for PCodeMethod<'a>

§

impl<'a> Sync for PCodeMethod<'a>

§

impl<'a> Unpin for PCodeMethod<'a>

§

impl<'a> UnsafeUnpin for PCodeMethod<'a>

§

impl<'a> UnwindSafe for PCodeMethod<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.