unsafe public void DrawData() { uint byte_num = point_num * bytes_per_point; IntPtr variable_data; try { variable_data = Marshal.AllocHGlobal((IntPtr)byte_num); } catch (OutOfMemoryException e) { OutputMessage("Out Of Memory in AllocHGlobal"); return; } uint point_num_read = 0; OutputMessage("Reading memory: " + "0x" + addr.ToString("x8") + " point num: " + point_num); bool result = ReadProcessM(addr, point_num, bytes_per_point, variable_data, ref point_num_read); if (result == false) { Marshal.FreeHGlobal(variable_data); OutputMessage("Failed to read memory"); return; } point_num = (uint)point_num_read; GLOBAL.point_num = (int)point_num_read; ARRAY_DESCRIPTOR descriptor = new ARRAY_DESCRIPTOR(); descriptor.point_num = GLOBAL.point_num; descriptor.bytes_per_point = bytes_per_point; descriptor.type_int_float = int_float; descriptor.type_signed_unsigned = signed_unsigned; descriptor.y = (char *)variable_data; descriptor.ignore_x = true; PGE_IO.set_array(GLOBAL.plot_id, ref descriptor); Marshal.FreeHGlobal(variable_data); }
private static extern int dbg_set_struct(ref ARRAY_DESCRIPTOR desc);
public static extern int set_array(int plot_id, ref ARRAY_DESCRIPTOR desc);
public unsafe void DrawData() { uint byte_num = point_num * bytes_per_point; IntPtr variable_data; try { variable_data = Marshal.AllocHGlobal((IntPtr)byte_num); } catch (OutOfMemoryException e) { OutputMessage("Out Of Memory in AllocHGlobal"); return ; } uint point_num_read = 0; OutputMessage("Reading memory: " + "0x"+addr.ToString("x8") + " point num: " + point_num); bool result = ReadProcessM(addr, point_num, bytes_per_point, variable_data, ref point_num_read); if (result == false) { Marshal.FreeHGlobal(variable_data); OutputMessage("Failed to read memory"); return; } point_num = (uint)point_num_read; GLOBAL.point_num = (int)point_num_read; ARRAY_DESCRIPTOR descriptor = new ARRAY_DESCRIPTOR(); descriptor.point_num = GLOBAL.point_num; descriptor.bytes_per_point = bytes_per_point; descriptor.type_int_float = int_float; descriptor.type_signed_unsigned = signed_unsigned; descriptor.y = (char*)variable_data; descriptor.ignore_x = true; PGE_IO.set_array(GLOBAL.plot_id, ref descriptor); Marshal.FreeHGlobal(variable_data); }