C# Class Net.Pkcs11Interop.Common.UnmanagedMemory

Utility class that helps to manage unmanaged memory
ファイルを表示 Open project: Pkcs11Interop/Pkcs11Interop

Public Methods

Method Description
Allocate ( int size ) : IntPtr

Allocates unmanaged zero-filled memory

Free ( IntPtr &memory ) : void

Frees previously allocated unmanaged memory

Read ( IntPtr memory, int size ) : byte[]

Creates copy of unmanaged memory contet

Read ( IntPtr memory, Type structureType ) : object

Copies content of unmanaged memory to the newly allocated managed structure

Read ( IntPtr memory, object structure ) : void

Copies content of unmanaged memory to the existing managed structure

SizeOf ( Type structureType ) : int

Returns the unmanaged size of the structure in bytes

Write ( IntPtr memory, byte content ) : void

Copies content of byte array to unmanaged memory

Write ( IntPtr memory, object structure ) : void

Copies content of structure to unmanaged memory

Method Details

Allocate() public static method

Allocates unmanaged zero-filled memory
public static Allocate ( int size ) : IntPtr
size int Number of bytes required
return System.IntPtr

Free() public static method

Frees previously allocated unmanaged memory
public static Free ( IntPtr &memory ) : void
memory System.IntPtr Pointer to the previously allocated unmanaged memory
return void

Read() public static method

Creates copy of unmanaged memory contet
public static Read ( IntPtr memory, int size ) : byte[]
memory System.IntPtr Memory that should be copied
size int Number of bytes that should be copied
return byte[]

Read() public static method

Copies content of unmanaged memory to the newly allocated managed structure
public static Read ( IntPtr memory, Type structureType ) : object
memory System.IntPtr Memory that should be copied
structureType System.Type Type of structure that should be created
return object

Read() public static method

Copies content of unmanaged memory to the existing managed structure
public static Read ( IntPtr memory, object structure ) : void
memory System.IntPtr Memory that should be copied
structure object Object to which data should be copied
return void

SizeOf() public static method

Returns the unmanaged size of the structure in bytes
public static SizeOf ( Type structureType ) : int
structureType System.Type Type of structure whose size should be determined
return int

Write() public static method

Copies content of byte array to unmanaged memory
public static Write ( IntPtr memory, byte content ) : void
memory System.IntPtr Previously allocated unmanaged memory to copy to
content byte Byte array to copy from
return void

Write() public static method

Copies content of structure to unmanaged memory
public static Write ( IntPtr memory, object structure ) : void
memory System.IntPtr Previously allocated unmanaged memory to copy to
structure object Structure to copy from
return void