C# Class Statman.Util.Injection.CustomMarshal

显示文件 Open project: OrfeasZ/Statman Class Usage Examples

Public Methods

Method Description
IsCustomMarshalObject ( object o ) : bool

Determines whether a specific object is CustomMarshalable

IsCustomMarshalType ( Type t ) : bool

Determines if a given type is CustomMarshalable (i.e. contains any fields with CustomMarshalAsAttribute)

PtrToStructure ( IntPtr ptr, Type structureType ) : object

Marshal an unmanaged to pointer to a managed object. If structureType is not CustomMarshalable, this function is the same as Marshal.StructureToPtr.

RebaseUnmanagedStructure ( IntPtr baseAddress, IntPtr targetAddress, Type structureType ) : void

Rebases all pointers in a CustomMarshalable structure to be valid pointers in a target address space. If structureType is not CustomMarshalable, this function does nothing.

SizeOf ( Type t ) : int
SizeOf ( object o ) : int

Returns the runtime size of a CustomMarshalable object. If object is not CustomMarshalable, this function is the same as Marshal.SizeOf

StructureToPtr ( object structure, IntPtr ptr, bool fDeleteOld ) : void

Marshal a managed object to an unmanaged chunk of memory. If structure is not CustomMarshalable this function is the same as Marshal.StructureToPtr.

Method Details

IsCustomMarshalObject() public static method

Determines whether a specific object is CustomMarshalable
public static IsCustomMarshalObject ( object o ) : bool
o object Object to check
return bool

IsCustomMarshalType() public static method

Determines if a given type is CustomMarshalable (i.e. contains any fields with CustomMarshalAsAttribute)
public static IsCustomMarshalType ( Type t ) : bool
t System.Type Type to check
return bool

PtrToStructure() public static method

Marshal an unmanaged to pointer to a managed object. If structureType is not CustomMarshalable, this function is the same as Marshal.StructureToPtr.
public static PtrToStructure ( IntPtr ptr, Type structureType ) : object
ptr System.IntPtr Pointer to unmanaged memory
structureType System.Type Type of managed object to instantiate
return object

RebaseUnmanagedStructure() public static method

Rebases all pointers in a CustomMarshalable structure to be valid pointers in a target address space. If structureType is not CustomMarshalable, this function does nothing.
public static RebaseUnmanagedStructure ( IntPtr baseAddress, IntPtr targetAddress, Type structureType ) : void
baseAddress System.IntPtr Pointer to unmanaged structure in this process
targetAddress System.IntPtr Base address of structure in target process
structureType System.Type Type of structure
return void

SizeOf() public static method

public static SizeOf ( Type t ) : int
t System.Type
return int

SizeOf() public static method

Returns the runtime size of a CustomMarshalable object. If object is not CustomMarshalable, this function is the same as Marshal.SizeOf
public static SizeOf ( object o ) : int
o object Object to calculate runtime size of
return int

StructureToPtr() public static method

Marshal a managed object to an unmanaged chunk of memory. If structure is not CustomMarshalable this function is the same as Marshal.StructureToPtr.
public static StructureToPtr ( object structure, IntPtr ptr, bool fDeleteOld ) : void
structure object A managed object to marshal to unmanaged memory.
ptr System.IntPtr Pointer to unmanaged memory. This must be allocated before call
fDeleteOld bool Indicates whether to delete old memory first
return void