void ReadSetup() { //ConnSetupFailedRep frep = new ConnSetupFailedRep (); //setup = new ConnSetupSuccessRep (); xrr.ReadSetupResponse(); setup = xrr.succ; }
public object MarshalNativeToManaged(IntPtr pNativeData) { ConnSetupSuccessRep rep = new ConnSetupSuccessRep(); Trace.WriteLine("m"); GCHandle gch; gch = GCHandle.Alloc(rep); IntPtr startPtr = gch.AddrOfPinnedObject(); int sz = Marshal.SizeOf(rep); Trace.WriteLine(sz); for (int i = 0; i != sz; i++) { Marshal.WriteByte(startPtr, i, Marshal.ReadByte(pNativeData, i)); } gch.Free(); Trace.WriteLine("vendorlen: " + rep.VendorLen); /* * IntPtr newSz = new IntPtr (sz + rep.VendorLen); * Marshal.ReAllocHGlobal (startPtr, newSz); */ //IntPtr nu = Marshal.AllocHGlobal (new IntPtr (rep.VendorLen)); //for (int i = 0 ; i != rep.VendorLen ; i++) { // Marshal.WriteByte (nu, i, Marshal.ReadByte (pNativeData, i)); //} IntPtr nu = new IntPtr((int)pNativeData + 40); string str = Marshal.PtrToStringAnsi(nu, rep.VendorLen); Trace.WriteLine("str: " + str); //rep.Vendor = str; //Marshal.PtrToStructure(ptr, typeof() //Marshal.ReAllocCoTaskMem (pNativeData, sz + 40); //Marshal.ReAllocHGlobal (pNativeData, new IntPtr (sz + 40)); return(rep); }
public object MarshalNativeToManaged (IntPtr pNativeData) { ConnSetupSuccessRep rep = new ConnSetupSuccessRep (); Trace.WriteLine ("m"); GCHandle gch; gch = GCHandle.Alloc (rep); IntPtr startPtr = gch.AddrOfPinnedObject (); int sz = Marshal.SizeOf (rep); Trace.WriteLine (sz); for (int i = 0 ; i != sz ; i++) { Marshal.WriteByte (startPtr, i, Marshal.ReadByte (pNativeData, i)); } gch.Free (); Trace.WriteLine ("vendorlen: " + rep.VendorLen); /* IntPtr newSz = new IntPtr (sz + rep.VendorLen); Marshal.ReAllocHGlobal (startPtr, newSz); */ //IntPtr nu = Marshal.AllocHGlobal (new IntPtr (rep.VendorLen)); //for (int i = 0 ; i != rep.VendorLen ; i++) { // Marshal.WriteByte (nu, i, Marshal.ReadByte (pNativeData, i)); //} IntPtr nu = new IntPtr ((int)pNativeData + 40); string str = Marshal.PtrToStringAnsi (nu, rep.VendorLen); Trace.WriteLine ("str: " + str); //rep.Vendor = str; //Marshal.PtrToStructure(ptr, typeof() //Marshal.ReAllocCoTaskMem (pNativeData, sz + 40); //Marshal.ReAllocHGlobal (pNativeData, new IntPtr (sz + 40)); return rep; }
void ReadSetup () { //ConnSetupFailedRep frep = new ConnSetupFailedRep (); //setup = new ConnSetupSuccessRep (); xrr.ReadSetupResponse (); setup = xrr.succ; }