public override void Write(UInt16 val) { val = Utilities.SwapBytes(val); base.Write(val); if (AutoFlush) Flush(); }
private void OnPort(IPeerWireClient client, UInt16 port) { if (Port != null) { Port(client, port); } }
public static byte[] UInt16(UInt16 i, Endianness e = Endianness.Machine) { byte[] bytes = BitConverter.GetBytes(i); if (NeedsFlipping(e)) Array.Reverse(bytes); return bytes; }
public SystemBootEventArgs(UInt16 major, UInt16 minor, UInt16 patch, UInt16 build, UInt16 ll_version, Byte protocol_version, Byte hw) { this.major = major; this.minor = minor; this.patch = patch; this.build = build; this.ll_version = ll_version; this.protocol_version = protocol_version; this.hw = hw; }
public static void Write(this BinaryWriter writer, UInt16 value, bool invertEndian = false) { if (invertEndian) { writer.WriteInvertedBytes(BitConverter.GetBytes(value)); } else { writer.Write(value); } }
public void WriteFixedString(string data, UInt16 fixedCount) { FWriter.Write((UInt16)data.Length); byte[] str = UnicodeEncoding.Unicode.GetBytes(data); FWriter.Write(str); for (int i = 0; i < (fixedCount - data.Length); ++i) { FWriter.Write((UInt16)0); } }
public byte[] data; //twp.app.EDef.LIMIT_LOGIN_DATA_LENGTH 300 public ReqLogin() { header = kMSGIDX_REQ_LOGIN; signiture = new byte[3]; signiture[0] = System.Convert.ToByte('t'); signiture[1] = System.Convert.ToByte('w'); signiture[2] = System.Convert.ToByte('p'); version = twp.protocol.c2fep.MAKE_PAIR32((uint)EVersion.PROTOCOL_VERSION_MAJOR, (uint)EVersion.PROTOCOL_VERSION_MINOR);//(uint)((uint)EVersion.PROTOCOL_VERSION_MAJOR | (uint)EVersion.PROTOCOL_VERSION_MINOR << 16);//MAKE_PAIR32(PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR); client_version = new byte[32 + 1]; client_version[32] = System.Convert.ToByte('\0'); data_len = 0; data = new byte[(uint)twp.app.EDef.LIMIT_LOGIN_DATA_LENGTH]; // memset(&data, 0, sizeof(data)); }
private static bool FindImplSlotForCurrentType(EEType* pTgtType, EEType* pItfType, UInt16 itfSlotNumber, UInt16* pImplSlotNumber) { bool fRes = false; // If making a call and doing virtual resolution don't look into the dispatch map, // take the slot number directly. if (!pItfType->IsInterface) { *pImplSlotNumber = itfSlotNumber; // Only notice matches if the target type and search types are the same // This will make dispatch to sealed slots work correctly return pTgtType == pItfType; } if (pTgtType->HasDispatchMap) { // For variant interface dispatch, the algorithm is to walk the parent hierarchy, and at each level // attempt to dispatch exactly first, and then if that fails attempt to dispatch variantly. This can // result in interesting behavior such as a derived type only overriding one particular instantiation // and funneling all the dispatches to it, but its the algorithm. bool fDoVariantLookup = false; // do not check variance for first scan of dispatch map fRes = FindImplSlotInSimpleMap( pTgtType, pItfType, itfSlotNumber, pImplSlotNumber, fDoVariantLookup); if (!fRes) { fDoVariantLookup = true; // check variance for second scan of dispatch map fRes = FindImplSlotInSimpleMap( pTgtType, pItfType, itfSlotNumber, pImplSlotNumber, fDoVariantLookup); } } return fRes; }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Returns true if position points to a word break in the supplied // char array. position is an inter-character offset -- 0 points // to the space preceeding the first char, 1 points between the // first and second char, etc. // // insideWordDirection specifies whether we're looking for a word start // or word end. If insideWordDirection == LogicalDirection.Forward, then // text = "abc def", position = 4 will return true, but if the direction is // backward, no word boundary will be found (looking backward position is // at the edge of whitespace, not a word). // // This method requires at least MinContextLength chars ahead of and // following position to give accurate results, but no more. internal static bool IsAtWordBoundary(char[] text, int position, LogicalDirection insideWordDirection) { CharClass[] classes = GetClasses(text); // If the inside text is blank, it's not a word boundary. if (insideWordDirection == LogicalDirection.Backward) { if (position == text.Length) { return true; } if (position == 0 || IsWhiteSpace(text[position - 1], classes[position - 1])) { return false; } } else { if (position == 0) { return true; } if (position == text.Length || IsWhiteSpace(text[position], classes[position])) { return false; } } UInt16[] charType3 = new UInt16[2]; SafeNativeMethods.GetStringTypeEx(0 /* ignored */, SafeNativeMethods.CT_CTYPE3, new char[] { text[position - 1], text[position] }, 2, charType3); // Otherwise we're at a word boundary if the classes of the surrounding text differ. return IsWordBoundary(text[position - 1], text[position]) || ( !IsSameClass(charType3[0], classes[position - 1], charType3[1], classes[position]) && !IsMidLetter(text, position - 1, classes) && !IsMidLetter(text, position, classes) ); }
public ExecuteWriteEventArgs(Byte connection, UInt16 result) { this.connection = connection; this.result = result; }
public void setDefinedProptertyByUType(UInt16 utype, object val) { iddefpropertys_[utype].val = val; }
/// <summary> /// Rotates 1 bit right. /// </summary> /// <param name="v">The v.</param> /// <returns></returns> public static UInt16 RotateRight(this UInt16 v) { return (UInt16)((v << 15) | (v >> 1)); }
public static string ToString(UInt16 value) { return value.ToString(); }
public SetAdvDataEventArgs(UInt16 result) { this.result = result; }
public ConnectSelectiveEventArgs(UInt16 result, Byte connection_handle) { this.result = result; this.connection_handle = connection_handle; }
public WhitelistBondsEventArgs(UInt16 result, Byte count) { this.result = result; this.count = count; }
/// <summary> /// 将一组形状以指定的值定位在Chart的某一坐标轴中。 /// </summary> /// <param name="ShapesToLocate">要进行定位的形状</param> /// <param name="Ax">此形状将要定位的轴</param> /// <param name="Values">此形状在Chart中所处的值</param> /// <param name="percents">将形状按指定的百分比的宽度或者高度的部位定位到坐标轴的指定值的位置。 /// 如果其值设定为0,则表示此形状的左端(或上端)定位在设定的位置处, /// 如果其值为100,则表示此形状的右端(或下端)定位在设置的位置处。</param> /// <remarks></remarks> public static void setPositionInChart(Axis Ax, Shape[] ShapesToLocate, double[] Values, double[] Percents = null) { // ------------------------------------------------------ //检查输入的数组中的元素个数是否相同 int Count = ShapesToLocate.Length; if (Values.Length != Count) { MessageBox.Show("输入数组中的元素个数不相同。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Percents != null) { if (Percents.Count() != 1 & Percents.Length != Count) { MessageBox.Show("输入数组中的元素个数不相同。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // ------------------------------------------------------ Chart cht = (Chart)Ax.Parent; // double max = Ax.MaximumScale; double min = Ax.MinimumScale; // PlotArea PlotA = cht.PlotArea; // ------------------------------------------------------ Shape shp = default(Shape); double Value = 0; double Percent = Percents[0]; double PositionInChartByValue = 0; // ------------------------------------------------------ switch (Ax.Type) { case XlAxisType.xlCategory: //横向X轴 break; case XlAxisType.xlValue: //竖向Y轴 if (Ax.ReversePlotOrder == false) //顺序刻度值,说明Y轴数据为下边小上边大 { for (UInt16 i = 0; i <= Count - 1; i++) { shp = ShapesToLocate[i]; Value = Values[i]; if (Percents.Count() > 1) { Percent = Percents[i]; } PositionInChartByValue = PlotA.InsideTop + PlotA.InsideHeight * (max - Value) / (max - min); shp.Top = (float)(PositionInChartByValue - Percent * shp.Width); } } else //逆序刻度值,说明Y轴数据为上边小下边大 { for (UInt16 i = 0; i <= Count - 1; i++) { shp = ShapesToLocate[i]; Value = Values[i]; if (Percents.Count() > 1) { Percent = Percents[i]; } PositionInChartByValue = PlotA.InsideTop + PlotA.InsideHeight * (Value - min) / (max - min); shp.Top = (float)(PositionInChartByValue - Percent * shp.Width); } } break; case XlAxisType.xlSeriesAxis: MessageBox.Show("暂时不知道这是什么坐标轴", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } }
public override void Write(UInt16 value) { var bytes = BitConverter.GetBytes(value); WriteBigEndian(bytes); }
public static void zsend_line(UInt16 c) { byte[] data = { (byte)c }; serialPort.Write(data, 0, 1); }
/// <summary> /// 将一个 16位整数转换成2位的BYTE[] /// </summary> /// <param name="data"></param> /// <returns></returns> public static Byte[] GetSocketBytes(UInt16 data) { return(BitConverter.GetBytes(data)); }
/// <summary> /// 添加一个2字节的整数 /// </summary> /// <param name="data"></param> public virtual void AddItem(UInt16 data) { buffList.Write(data); }
private static byte[] getWAV(AudioClip clip) { byte[] bytes = null; using (var memoryStream = new System.IO.MemoryStream()) { memoryStream.Write(new byte[44], 0, 44);//预留44字节头部信息 byte[] bytesData = GetData16(clip); memoryStream.Write(bytesData, 0, bytesData.Length); memoryStream.Seek(0, System.IO.SeekOrigin.Begin); byte[] riff = System.Text.Encoding.UTF8.GetBytes("RIFF"); memoryStream.Write(riff, 0, 4); byte[] chunkSize = BitConverter.GetBytes(memoryStream.Length - 8); memoryStream.Write(chunkSize, 0, 4); byte[] wave = System.Text.Encoding.UTF8.GetBytes("WAVE"); memoryStream.Write(wave, 0, 4); byte[] fmt = System.Text.Encoding.UTF8.GetBytes("fmt "); memoryStream.Write(fmt, 0, 4); byte[] subChunk1 = BitConverter.GetBytes(16); memoryStream.Write(subChunk1, 0, 4); UInt16 two = 2; UInt16 one = 1; byte[] audioFormat = BitConverter.GetBytes(one); memoryStream.Write(audioFormat, 0, 2); byte[] numChannels = BitConverter.GetBytes(clip.channels); memoryStream.Write(numChannels, 0, 2); byte[] sampleRate = BitConverter.GetBytes(clip.frequency); memoryStream.Write(sampleRate, 0, 4); byte[] byteRate = BitConverter.GetBytes(clip.frequency * clip.channels * 2); // sampleRate * bytesPerSample*number of channels memoryStream.Write(byteRate, 0, 4); UInt16 blockAlign = (ushort)(clip.channels * 2); memoryStream.Write(BitConverter.GetBytes(blockAlign), 0, 2); UInt16 bps = 16; byte[] bitsPerSample = BitConverter.GetBytes(bps); memoryStream.Write(bitsPerSample, 0, 2); byte[] datastring = System.Text.Encoding.UTF8.GetBytes("data"); memoryStream.Write(datastring, 0, 4); byte[] subChunk2 = BitConverter.GetBytes(clip.samples * clip.channels * 2); memoryStream.Write(subChunk2, 0, 4); bytes = memoryStream.ToArray(); } return(bytes); }
public GameSprite(UInt16 id) { this.id = id; }
public EncryptStartEventArgs(Byte handle, UInt16 result) { this.handle = handle; this.result = result; }
public PasskeyEntryEventArgs(UInt16 result) { this.result = result; }
/// <summary> /// Gets the amount of cubes in any type of Enumerable ItemBase /// </summary> /// <param name="items"></param> /// <param name="cubeId"></param> /// <param name="cubeValue"></param> /// <returns>The amount of Cubes</returns> public static Int32 GetItemCount(this IEnumerable <ItemBase> items, UInt16 cubeId, UInt16 cubeValue) { return(items.Where(item => { var cube = item.As <ItemCubeStack>(); if (cube == null) { return false; } return cube.mCubeType == cubeId && cube.mCubeValue == cubeValue; }).Sum(item => item.GetAmount())); }
public DiscoverEventArgs(UInt16 result) { this.result = result; }
ICell IRow.this[UInt16 columnIndex] { get { return(this[columnIndex]); } }
public RegReadEventArgs(UInt16 address, Byte value) { this.address = address; this.value = value; }
UInt16 ReverseByte(UInt16 data) { return((UInt16)((data & 0xFF00U) >> 8 | (data & 0x00FFU) << 8)); }
public IOPortConfigIrqEventArgs(UInt16 result) { this.result = result; }
public Crc16(UInt16 polinominal, UInt16 init) { this.polinominal = polinominal; this.init = init; this.table = GenerateTable(this.polinominal); }
public void Refresh() { WmiProcessorCount = SystemInfoHelper.GetWmiPhysicalProcessorCount(); WmiGlobalCoreCount = SystemInfoHelper.GetWmiCoreCount(); WmiLogicalProcessorCount = SystemInfoHelper.GetWmiGlobalLogicalProcessorCount(); NumaHighestNodeNumber = SystemInfoHelper.GetNumaHighestNodeNumber(); ActiveProcessorGroupCount = SystemInfoHelper.GetActiveProcessorGroupCount(); var sb = new StringBuilder(); for (UInt16 groupIndex = 0; groupIndex < ActiveProcessorGroupCount; groupIndex++) { if (sb.Length > 0) { sb.AppendLine(); } sb.AppendFormat("Group '{0}' as ", groupIndex); UInt32 processorCount = SystemInfoHelper.GetActiveProcessorCount(groupIndex); if (processorCount == 0) { sb.AppendFormat("Error reading GetActiveProcessorCount: {0}", Marshal.GetLastWin32Error()); } else { sb.AppendFormat("{0} Logical Processors", processorCount); } } LogicalProcessorCountPerGroup = sb.ToString(); MaximumProcessorGroupCount = SystemInfoHelper.GetMaximumProcessorGroupCount(); CSharpEnvironmentLogicalProcessorCount = Environment.ProcessorCount; UInt64 processAffinityMask; UInt64 systemAffinityMask; bool isResultOk = SystemInfoHelper.GetProcessAffinityMask( System.Diagnostics.Process.GetCurrentProcess().Handle, out processAffinityMask, out systemAffinityMask); if (isResultOk) { ProcessAffinityMask = processAffinityMask; ProcessAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", processAffinityMask, GetBitCount(processAffinityMask), GetBitString(processAffinityMask)); SystemAffinityMask = systemAffinityMask; SystemAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", systemAffinityMask, GetBitCount(processAffinityMask), GetBitString(systemAffinityMask)); } else { int error = Marshal.GetLastWin32Error(); ProcessAffinityMaskString = "GetProcessAffinityMask() error = " + error; SystemAffinityMaskString = "GetProcessAffinityMask() error = " + error; } sb.Clear(); for (int nodeIndex = 0; nodeIndex <= NumaHighestNodeNumber; nodeIndex++) { UInt64 numaNodeProcessorMask; SystemInfoHelper.GetNumaNodeProcessorMask((byte)nodeIndex, out numaNodeProcessorMask); sb.Append(String.Format("Node: {0} Processor Mask: {1} (bit count: {2})", nodeIndex, numaNodeProcessorMask, GetBitCount(numaNodeProcessorMask))); sb.Append(Environment.NewLine); sb.Append(GetBitString(numaNodeProcessorMask)); sb.Append(Environment.NewLine); } NumaNodeAndTheirAffinityMask = sb.ToString(); var structLogProcInfo = SystemInfoHelper.GetLogicalProcessorInformation(); }
public WriteCommandEventArgs(Byte connection, UInt16 result) { this.connection = connection; this.result = result; }
snprint_nfc_iso14443a_info(out string dst, NFC.nfc_iso14443a_info pnai, bool verbose) { dst = ""; dst += " ATQA (SENS_RES): "; dst += snprint_hex(pnai.abtAtqa, 2); if (verbose) { dst += "* UID size: "; switch ((pnai.abtAtqa[1] & 0xc0) >> 6) { case 0: dst += "single\r\n"; break; case 1: dst += "double\r\n"; break; case 2: dst += "triple\r\n"; break; case 3: dst += "RFU\r\n"; break; } dst += "* bit frame anticollision "; switch (pnai.abtAtqa[1] & 0x1f) { case 0x01: case 0x02: case 0x04: case 0x08: case 0x10: dst += "supported\r\n"; break; default: dst += "not supported\r\n"; break; } } dst += " UID (NFCID" + (pnai.abtUid[0] == 0x08 ? '3' : '1') + "): "; dst += snprint_hex(pnai.abtUid, pnai.szUidLen); if (verbose) { if (pnai.abtUid[0] == 0x08) { dst += "* Random UID\r\n"; } } dst += " SAK (SEL_RES): "; dst += pnai.btSak.ToString("2X"); if (verbose) { if (0 != (pnai.btSak & SAK_UID_NOT_COMPLETE)) { dst += "* Warning! Cascade bit set: UID not complete\r\n"; } if (0 != (pnai.btSak & SAK_ISO14443_4_COMPLIANT)) { dst += "* Compliant with ISO/IEC 14443-4\r\n"; } else { dst += "* Not compliant with ISO/IEC 14443-4\r\n"; } if (0 != (pnai.btSak & SAK_ISO18092_COMPLIANT)) { dst += "* Compliant with ISO/IEC 18092\r\n"; } else { dst += "* Not compliant with ISO/IEC 18092\r\n"; } } if (0 != pnai.szAtsLen) { dst += " ATS: "; dst += snprint_hex(pnai.abtAts, pnai.szAtsLen); } if (0 != pnai.szAtsLen && verbose) { // Decode ATS according to ISO/IEC 14443-4 (5.2 Answer to select) int[] iMaxFrameSizes = new int[9] { 16, 24, 32, 40, 48, 64, 96, 128, 256 }; dst += "* Max Frame Size accepted by PICC: " + iMaxFrameSizes[pnai.abtAts[0] & 0x0F] + " bytes\r\n"; int offset = 1; if (0 != (pnai.abtAts[0] & 0x10)) { // TA(1) present byte TA = pnai.abtAts[offset]; offset++; dst += "* Bit Rate Capability:\r\n"; if (TA == 0) { dst += " * PICC supports only 106 kbits/s in both directions\r\n"; } if (0 != (TA & 1 << 7)) { dst += " * Same bitrate in both directions mandatory\r\n"; } if (0 != (TA & 1 << 4)) { dst += " * PICC to PCD, DS=2, bitrate 212 kbits/s supported\r\n"; } if (0 != (TA & 1 << 5)) { dst += " * PICC to PCD, DS=4, bitrate 424 kbits/s supported\r\n"; } if (0 != (TA & 1 << 6)) { dst += " * PICC to PCD, DS=8, bitrate 847 kbits/s supported\r\n"; } if (0 != (TA & 1 << 0)) { dst += " * PCD to PICC, DR=2, bitrate 212 kbits/s supported\r\n"; } if (0 != (TA & 1 << 1)) { dst += " * PCD to PICC, DR=4, bitrate 424 kbits/s supported\r\n"; } if (0 != (TA & 1 << 2)) { dst += " * PCD to PICC, DR=8, bitrate 847 kbits/s supported\r\n"; } if (0 != (TA & 1 << 3)) { dst += " * ERROR unknown value\r\n"; } } if (0 != (pnai.abtAts[0] & 0x20)) { // TB(1) present byte TB = pnai.abtAts[offset]; offset++; dst += "* Frame Waiting Time:" + 256.0 * 16.0 * (1 << ((TB & 0xf0) >> 4)) / 13560.0 + " ms\r\n"; if ((TB & 0x0f) == 0) { dst += "* No Start-up Frame Guard Time required\r\n"; } else { dst += "* Start-up Frame Guard Time: " + 256.0 * 16.0 * (1 << (TB & 0x0f)) / 13560.0 + " ms\r\n"; } } if (0 != (pnai.abtAts[0] & 0x40)) { // TC(1) present byte TC = pnai.abtAts[offset]; offset++; if (0 != (TC & 0x1)) { dst += "* Node Address supported\r\n"; } else { dst += "* Node Address not supported\r\n"; } if (0 != (TC & 0x2)) { dst += "* Card IDentifier supported\r\n"; } else { dst += "* Card IDentifier not supported\r\n"; } } if (pnai.szAtsLen > offset) { dst += "* Historical bytes Tk: "; dst += snprint_hex(pnai.abtAts, offset, (pnai.szAtsLen - offset)); byte CIB = pnai.abtAts[offset]; offset++; if (CIB != 0x00 && CIB != 0x10 && (CIB & 0xf0) != 0x80) { dst += " * Proprietary format\r\n"; if (CIB == 0xc1) { dst += " * Tag byte: Mifare or virtual cards of various types\r\n"; byte L = pnai.abtAts[offset]; offset++; if (L != (pnai.szAtsLen - offset)) { dst += " * Warning: Type Identification Coding length (" + (int)L + ")"; dst += " not matching Tk length (%" + (pnai.szAtsLen - offset) + ")\r\n"; } if ((pnai.szAtsLen - offset - 2) > 0) { // Omit 2 CRC bytes byte CTC = pnai.abtAts[offset]; offset++; dst += " * Chip Type: "; switch (CTC & 0xf0) { case 0x00: dst += "(Multiple) Virtual Cards\r\n"; break; case 0x10: dst += "Mifare DESFire\r\n"; break; case 0x20: dst += "Mifare Plus\r\n"; break; default: dst += "RFU\r\n"; break; } dst += " * Memory size: "; switch (CTC & 0x0f) { case 0x00: dst += "<1 kbyte\r\n"; break; case 0x01: dst += "1 kbyte\r\n"; break; case 0x02: dst += "2 kbyte\r\n"; break; case 0x03: dst += "4 kbyte\r\n"; break; case 0x04: dst += "8 kbyte\r\n"; break; case 0x0f: dst += "Unspecified\r\n"; break; default: dst += "RFU\r\n"; break; } } if ((pnai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes byte CVC = pnai.abtAts[offset]; offset++; dst += " * Chip Status: "; switch (CVC & 0xf0) { case 0x00: dst += "Engineering sample\r\n"; break; case 0x20: dst += "Released\r\n"; break; default: dst += "RFU\r\n"; break; } dst += " * Chip Generation: "; switch (CVC & 0x0f) { case 0x00: dst += "Generation 1\r\n"; break; case 0x01: dst += "Generation 2\r\n"; break; case 0x02: dst += "Generation 3\r\n"; break; case 0x0f: dst += "Unspecified\r\n"; break; default: dst += "RFU\r\n"; break; } } if ((pnai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes byte VCS = pnai.abtAts[offset]; offset++; dst += " * Specifics (Virtual Card Selection):\r\n"; if ((VCS & 0x09) == 0x00) { dst += " * Only VCSL supported\r\n"; } else if ((VCS & 0x09) == 0x01) { dst += " * VCS, VCSL and SVC supported\r\n"; } if ((VCS & 0x0e) == 0x00) { dst += " * SL1, SL2(?), SL3 supported\r\n"; } else if ((VCS & 0x0e) == 0x02) { dst += " * SL3 only card\r\n"; } else if ((VCS & 0x0f) == 0x0e) { dst += " * No VCS command supported\r\n"; } else if ((VCS & 0x0f) == 0x0f) { dst += " * Unspecified\r\n"; } else { dst += " * RFU\r\n"; } } } } else { if (CIB == 0x00) { dst += " * Tk after 0x00 consist of optional consecutive COMPACT-TLV data objects\r\n"; dst += " followed by a mandatory status indicator (the last three bytes, not in TLV)\r\n"; dst += " See ISO/IEC 7816-4 8.1.1.3 for more info\r\n"; } if (CIB == 0x10) { dst += " * DIR data reference: " + pnai.abtAts[offset].ToString("X2") + "\r\n"; } if (CIB == 0x80) { if (pnai.szAtsLen == offset) { dst += " * No COMPACT-TLV objects found, no status found\r\n"; } else { dst += " * Tk after 0x80 consist of optional consecutive COMPACT-TLV data objects;\r\n"; dst += " the last data object may carry a status indicator of one, two or three bytes.\r\n"; dst += " See ISO/IEC 7816-4 8.1.1.3 for more info\r\n"; } } } } } if (verbose) { dst += "\r\nFingerprinting based on MIFARE type Identification Procedure:\r\n"; // AN10833 UInt16 atqa = 0; byte sak = 0; byte i, j; bool found_possible_match = false; atqa = (UInt16)((((UInt16)pnai.abtAtqa[0] & 0xff) << 8)); atqa += (UInt16)((((UInt16)pnai.abtAtqa[1] & 0xff))); sak = (byte)(((byte)pnai.btSak & 0xff)); for (i = 0; i < const_ca.Count; i++) { if ((atqa & const_ca[i].mask) == const_ca[i].atqa) { for (j = 0; (j < const_ca[i].saklist.Length) && (const_ca[i].saklist[j] >= 0); j++) { int sakindex = const_ca[i].saklist[j]; if ((sak & const_cs[sakindex].mask) == const_cs[sakindex].sak) { dst += "* " + const_ca[i].type + const_cs[sakindex].type + "\r\n"; found_possible_match = true; } } } } // Other matches not described in // AN10833 MIFARE Type Identification Procedure // but seen in the field: dst += "Other possible matches based on ATQA & SAK values:\r\n"; UInt32 atqasak = 0; atqasak += (((UInt32)pnai.abtAtqa[0] & 0xff) << 16); atqasak += (((UInt32)pnai.abtAtqa[1] & 0xff) << 8); atqasak += ((UInt32)pnai.btSak & 0xff); switch (atqasak) { case 0x000488: dst += "* Mifare Classic 1K Infineon\r\n"; found_possible_match = true; break; case 0x000298: dst += "* Gemplus MPCOS\r\n"; found_possible_match = true; break; case 0x030428: dst += "* JCOP31\r\n"; found_possible_match = true; break; case 0x004820: dst += "* JCOP31 v2.4.1\r\n"; dst += "* JCOP31 v2.2\r\n"; found_possible_match = true; break; case 0x000428: dst += "* JCOP31 v2.3.1\r\n"; found_possible_match = true; break; case 0x000453: dst += "* Fudan FM1208SH01\r\n"; found_possible_match = true; break; case 0x000820: dst += "* Fudan FM1208\r\n"; found_possible_match = true; break; case 0x000238: dst += "* MFC 4K emulated by Nokia 6212 Classic\r\n"; found_possible_match = true; break; case 0x000838: dst += "* MFC 4K emulated by Nokia 6131 NFC\r\n"; found_possible_match = true; break; } if (!found_possible_match) { dst += "* Unknown card, sorry\r\n"; } } }
private bool ImportAgr7(UInt16 Offset, ref byte[] Data) { String msg = ""; int i = 0; UInt16 ItemPosition = 0; UInt16 DataPosition = 0; if (Offset > 6) { DataPosition = (UInt16)(Offset - 6); // block header = 6 abziehen } else { return(false); } mData = Data; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("TaskCfg->uiCRC", TaskDataType.type_hex_16, DataPosition); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("TaskCfg->uiExpire", TaskDataType.type_uint_16, DataPosition); mItem[ItemPosition].SetPlausibilityMin(100); mItem[ItemPosition].SetPlausibilityMax(100); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("TaskCfg->uiStacksize", TaskDataType.type_uint_16, DataPosition); mItem[ItemPosition].SetPlausibilityMin(512); mItem[ItemPosition].SetPlausibilityMax(512); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("TaskCfg->ucPrio", TaskDataType.type_uint_8, DataPosition); mItem[ItemPosition].SetPlausibilityMin(80); mItem[ItemPosition].SetPlausibilityMax(80); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("TaskCfg->ucTimeout", TaskDataType.type_uint_8, DataPosition); mItem[ItemPosition].SetPlausibilityMin(2); mItem[ItemPosition].SetPlausibilityMax(5); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("ucAgrType", TaskDataType.type_uint_8, DataPosition); mItem[ItemPosition].SetPlausibilityMax(3); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("ucLMMdaempf", TaskDataType.type_uint_8, DataPosition); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("ucLMMstart", TaskDataType.type_uint_8, DataPosition); mItem[ItemPosition].SetPlausibilityMax(15); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("ucLMMlimit", TaskDataType.type_uint_8, DataPosition); mItem[ItemPosition].SetPlausibilityMax(15); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("uiPWMmin", TaskDataType.type_uint_16, DataPosition); mItem[ItemPosition].SetPlausibilityMax(1000); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("uiPWMmax", TaskDataType.type_uint_16, DataPosition); mItem[ItemPosition].SetPlausibilityMax(1000); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; for (i = 1; i < 6; i++) { Array.Resize(ref mItem, ItemPosition + 1); msg = String.Format("uiLimit{0}", i); mItem[ItemPosition] = new TaskConfigurationItem(msg, TaskDataType.type_uint_16, DataPosition); DataPosition = (UInt16)(DataPosition + 2); ItemPosition++; Array.Resize(ref mItem, ItemPosition + 1); msg = String.Format("ucGain{0}", i); mItem[ItemPosition] = new TaskConfigurationItem(msg, TaskDataType.type_uint_8, DataPosition); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; } Array.Resize(ref mItem, ItemPosition + 1); mItem[ItemPosition] = new TaskConfigurationItem("ucGainMax", TaskDataType.type_uint_8, DataPosition); DataPosition = (UInt16)(DataPosition + 1); ItemPosition++; return((DataPosition + 6) == (Offset + SizeAgr7())); }
static public void F_PLAYER_STATE2(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (cclient.Plr == null || !cclient.Plr.IsInWorld()) return; Player Plr = cclient.Plr; try { long Pos = packet.Position; PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_STATE2); Out.Write(packet.ToArray(), (int)packet.Position, (int)packet.Size); Out.WriteByte(0); Plr.DispatchPacket(Out, false); packet.Position = Pos; } catch (Exception e) { Log.Error("F_PLAYER_STATE2", e.ToString()); } if (packet.Size < 17) { Plr.IsMoving = false; return; } UInt16 Key = packet.GetUint16(); byte MoveByte = packet.GetUint8(); byte UnkByte = packet.GetUint8(); byte CombatByte = packet.GetUint8(); byte RotateByte = packet.GetUint8(); UInt16 Heading = packet.GetUint16R(); UInt16 X = packet.GetUint16R(); UInt16 Y = packet.GetUint16R(); byte Unk1 = packet.GetUint8(); UInt16 Z = packet.GetUint16R(); //byte Unk2 = packet.GetUint8(); Heading /= 8; X /= 2; Y /= 2; Z /= 2; if (CombatByte >= 50 && CombatByte < 0x92 || CombatByte == 0xDF) { if (Plr.LastCX != 0 && Plr.LastCY != 0) { if (Plr.LastCX > 12288 && X < 4096) Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset); else if (X > 12288 && Plr.LastCX < 4096) Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset); if (Plr.LastCY > 24576 && Y < 8192) Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1)); else if (Y > 24576 && Plr.LastCY < 8192) Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1)); } Plr.LastCX = X; Plr.LastCY = Y; X = Plr.Zone.CalculCombat(X, Plr.XOffset, true); Y = Plr.Zone.CalculCombat(Y, Plr.YOffset, false); Heading /= 2; Z += 32768; Z /= 4; } else { if (Plr.LastX != 0 && Plr.LastY != 0) { if (Plr.LastX > 24576 && X < 4096) Plr.SetOffset((ushort)(Plr.XOffset + 1), Plr.YOffset); else if (Plr.LastX < 4096 && X > 24576) Plr.SetOffset((ushort)(Plr.XOffset - 1), Plr.YOffset); if (Plr.LastY > 24576 && Y < 4096) Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset + 1)); else if (Plr.LastY < 4096 && Y > 24576) Plr.SetOffset(Plr.XOffset, (ushort)(Plr.YOffset - 1)); } Plr.LastX = X; Plr.LastY = Y; X = Plr.Zone.CalculPin(X, Plr.XOffset, true); Y = Plr.Zone.CalculPin(Y, Plr.YOffset, false); } Plr.SetPosition(X, Y, Z, Heading); }
protected override void ECB(byte[] input, byte[] output) { // unrolled loop, eliminated mul R0 = (UInt16)(input [0] | (input [1] << 8)); R1 = (UInt16)(input [2] | (input [3] << 8)); R2 = (UInt16)(input [4] | (input [5] << 8)); R3 = (UInt16)(input [6] | (input [7] << 8)); if (encrypt) { j = 0; // inline, but looped, Mix(); Mix(); Mix(); Mix(); Mix(); while (j <= 16) { R0 += (UInt16)(K[j++] + (R3 & R2) + ((~R3) & R1)); R0 = (UInt16)((R0 << 1) | (R0 >> 15)); R1 += (UInt16)(K[j++] + (R0 & R3) + ((~R0) & R2)); R1 = (UInt16)((R1 << 2) | (R1 >> 14)); R2 += (UInt16)(K[j++] + (R1 & R0) + ((~R1) & R3)); R2 = (UInt16)((R2 << 3) | (R2 >> 13)); R3 += (UInt16)(K[j++] + (R2 & R1) + ((~R2) & R0)); R3 = (UInt16)((R3 << 5) | (R3 >> 11)); } // inline Mash(); j == 20 R0 += K [R3 & 63]; R1 += K [R0 & 63]; R2 += K [R1 & 63]; R3 += K [R2 & 63]; // inline, but looped, Mix(); Mix(); Mix(); Mix(); Mix(); Mix(); while (j <= 40) { R0 += (UInt16)(K[j++] + (R3 & R2) + ((~R3) & R1)); R0 = (UInt16)((R0 << 1) | (R0 >> 15)); R1 += (UInt16)(K[j++] + (R0 & R3) + ((~R0) & R2)); R1 = (UInt16)((R1 << 2) | (R1 >> 14)); R2 += (UInt16)(K[j++] + (R1 & R0) + ((~R1) & R3)); R2 = (UInt16)((R2 << 3) | (R2 >> 13)); R3 += (UInt16)(K[j++] + (R2 & R1) + ((~R2) & R0)); R3 = (UInt16)((R3 << 5) | (R3 >> 11)); } // inline Mash(); j == 44 R0 += K [R3 & 63]; R1 += K [R0 & 63]; R2 += K [R1 & 63]; R3 += K [R2 & 63]; // inline, but looped, Mix(); Mix(); Mix(); Mix(); Mix(); while (j < 64) { R0 += (UInt16)(K[j++] + (R3 & R2) + ((~R3) & R1)); R0 = (UInt16)((R0 << 1) | (R0 >> 15)); R1 += (UInt16)(K[j++] + (R0 & R3) + ((~R0) & R2)); R1 = (UInt16)((R1 << 2) | (R1 >> 14)); R2 += (UInt16)(K[j++] + (R1 & R0) + ((~R1) & R3)); R2 = (UInt16)((R2 << 3) | (R2 >> 13)); R3 += (UInt16)(K[j++] + (R2 & R1) + ((~R2) & R0)); R3 = (UInt16)((R3 << 5) | (R3 >> 11)); } } else { j = 63; // inline, but looped, RMix(); RMix(); RMix(); RMix(); RMix(); while (j >= 44) { R3 = (UInt16)((R3 >> 5) | (R3 << 11)); R3 -= (UInt16)(K[j--] + (R2 & R1) + ((~R2) & R0)); R2 = (UInt16)((R2 >> 3) | (R2 << 13)); R2 -= (UInt16)(K[j--] + (R1 & R0) + ((~R1) & R3)); R1 = (UInt16)((R1 >> 2) | (R1 << 14)); R1 -= (UInt16)(K[j--] + (R0 & R3) + ((~R0) & R2)); R0 = (UInt16)((R0 >> 1) | (R0 << 15)); R0 -= (UInt16)(K[j--] + (R3 & R2) + ((~R3) & R1)); } // inline RMash(); R3 -= K [R2 & 63]; R2 -= K [R1 & 63]; R1 -= K [R0 & 63]; R0 -= K [R3 & 63]; // inline, but looped, RMix(); RMix(); RMix(); RMix(); RMix(); RMix(); while (j >= 20) { R3 = (UInt16)((R3 >> 5) | (R3 << 11)); R3 -= (UInt16)(K[j--] + (R2 & R1) + ((~R2) & R0)); R2 = (UInt16)((R2 >> 3) | (R2 << 13)); R2 -= (UInt16)(K[j--] + (R1 & R0) + ((~R1) & R3)); R1 = (UInt16)((R1 >> 2) | (R1 << 14)); R1 -= (UInt16)(K[j--] + (R0 & R3) + ((~R0) & R2)); R0 = (UInt16)((R0 >> 1) | (R0 << 15)); R0 -= (UInt16)(K[j--] + (R3 & R2) + ((~R3) & R1)); } // inline RMash(); R3 -= K [R2 & 63]; R2 -= K [R1 & 63]; R1 -= K [R0 & 63]; R0 -= K [R3 & 63]; // inline, but looped, RMix(); RMix(); RMix(); RMix(); RMix(); while (j >= 0) { R3 = (UInt16)((R3 >> 5) | (R3 << 11)); R3 -= (UInt16)(K[j--] + (R2 & R1) + ((~R2) & R0)); R2 = (UInt16)((R2 >> 3) | (R2 << 13)); R2 -= (UInt16)(K[j--] + (R1 & R0) + ((~R1) & R3)); R1 = (UInt16)((R1 >> 2) | (R1 << 14)); R1 -= (UInt16)(K[j--] + (R0 & R3) + ((~R0) & R2)); R0 = (UInt16)((R0 >> 1) | (R0 << 15)); R0 -= (UInt16)(K[j--] + (R3 & R2) + ((~R3) & R1)); } } // unrolled loop output[0] = (byte)R0; output[1] = (byte)(R0 >> 8); output[2] = (byte)R1; output[3] = (byte)(R1 >> 8); output[4] = (byte)R2; output[5] = (byte)(R2 >> 8); output[6] = (byte)R3; output[7] = (byte)(R3 >> 8); }
public IndicateConfirmEventArgs(UInt16 result) { this.result = result; }
public static int GetSerializedLength(UInt16 v) { return(2); }
public ReadMultipleEventArgs(Byte connection, UInt16 result) { this.connection = connection; this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenWritePropertyHeader(BinaryReader BinaryStream) { PropertyNameIndex = TokenHelper.LoadPackedInt(BinaryStream); NumBits = BinaryStream.ReadUInt16(); }
public DeleteBondingEventArgs(UInt16 result) { this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenExportBunch(BinaryReader BinaryStream) { NumBits = BinaryStream.ReadUInt16(); }
public RegWriteEventArgs(UInt16 result) { this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenMustBeMappedGuids(BinaryReader BinaryStream) { NumGuids = BinaryStream.ReadUInt16(); NumBits = BinaryStream.ReadUInt16(); }
public SetModeEventArgs(UInt16 result) { this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenEndContentBlock(BinaryReader BinaryStream) { ObjectNameIndex = TokenHelper.LoadPackedInt(BinaryStream); NumBits = BinaryStream.ReadUInt16(); }
public EndProcedureEventArgs(UInt16 result) { this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenWritePropertyHandle(BinaryReader BinaryStream) { NumBits = BinaryStream.ReadUInt16(); }
public SetFilteringEventArgs(UInt16 result) { this.result = result; }
/** Constructor, serializing members from passed in stream. */ public TokenSendAck(BinaryReader BinaryStream) { NumBits = BinaryStream.ReadUInt16(); }
public SetAdvParametersEventArgs(UInt16 result) { this.result = result; }
/// <summary> /// Creates a new text position. /// </summary> /// <param name="line">The line of the character.</param> /// <param name="column">The column of the character.</param> /// <param name="position">The index of the character.</param> public TextPosition(UInt16 line, UInt16 column, Int32 position) { _line = line; _column = column; _position = position; }
public SetDirectedConnectableModeEventArgs(UInt16 result) { this.result = result; }
public unsafe static void WriteUInt16BE(byte *buff, int offset, UInt16 value) { Unsafe.WriteUnaligned <UInt16>(ref buff[offset], SwapEndianess(value)); }
public static string ToString(UInt16 value) { return value.ToString(null, NumberFormatInfo.InvariantInfo); }
public static UInt16 ReverseEndian16(UInt16 x) { //little to big or vice versa return((UInt16)((x & 0xff00) >> 8 | (x & 0x00ff) << 8)); }
/// <summary> /// writeGPIOAB /// writes a 16-bit value to the A and B gpio registers /// </summary> /// <param name="ba"></param> public void writeGPIOAB(UInt16 ba) { byte[] writeBuffer; writeBuffer = new byte[] { MCP23017_GPIOA, (byte)(ba & 0xFF), (byte)(ba >> 8) }; Write(writeBuffer); }
public unsafe static void WriteUInt16LE(byte *buff, int offset, UInt16 value) { Unsafe.WriteUnaligned <UInt16>(ref buff[offset], value); }