public unsafe int read(DeviceHandle handle, DataBuffer data, int bytesToRead) { int num4; byte* numPtr = stackalloc byte[0x100]; uint regData = 0; int num3 = -1; if (handle.isInvalid()) { GlobalServices.ErrMsg("DDI_EZLinkDongle.read()", "called with INVALID handle"); return -1; } switch (data.ddi_getProtocol()) { case Protocol.ReadRegister: uint num; data.ddi_getCommand_ReadRegister(out num); data.ddi_setReply_ReadRegister(num, regData); return num3; case Protocol.ReadStatus: data.NumItems = 14; num4 = 0; while (num4 < data.NumItems) { data.Buf[num4] = numPtr[num4]; num4++; } return num3; case Protocol.Read: if (num3 == 0) { data.NumItems = numPtr[4]; for (num4 = 0; num4 < data.NumItems; num4++) { data.Buf[num4] = numPtr[num4 + 5]; } } return num3; } GlobalServices.ErrMsg("DDI_EZLinkDongle.read()", "Unexpected protocol received"); return num3; }