Marshal. Copy cannot copy data from the offset of the unmanaged pointer. You need to recalculate the value of the unmanaged pointer.
///
/// Read data
///
/// Data
/// Start address
/// Number
///
Public int read (ref byte [] bytdata, int lngaddr, int lngsize)
{
If (lngaddr + lngsize> m_memsize) return 2; // exceeds the data Zone
If (m_binit)
{
Int ptrvalue = (INT) m_pwdata; // marshal. Copy cannot copy data from the offset of the unmanaged pointer. You need to recalculate the value of the unmanaged pointer.
// Marshal. Copy (m_pwdata, bytdata, lngaddr, lngsize );
Marshal. Copy (intptr) (ptrvalue + lngaddr), bytdata, 0, lngsize );
// Replace the index at the starting position (starting from scratch) in the startindex target array with the 3rd parameter ). // That is to say, the starting copy point of m_pwdata cannot be changed [unless the intptr value corresponding to m_pwdata is changed]
}
Else
{
Return 1; // the shared memory is not initialized.
}
Return 0; // read Successful
}