public KeepAliveHeader(string rawString) { HeaderKey = "Keep-Alive"; CommonHeader cHeader = new CommonHeader(rawString); string[] paras = ((string)cHeader.Value).Split(','); foreach (string s in paras) { string res = ""; bool flag = false; for (int i = 0; i < s.Length; i++) { if (flag) { res += s[i]; } else { if (String.IsNullOrWhiteSpace(s)) { } else { flag = true; res += s[i]; } } } string[] sPara = res.Split('='); HeaderValue.Add(new KeyValuePair(sPara[0], Convert.ToInt32(sPara[1]))); } }
public InstallShieldCABExtractor(FileSystem context, string hdrFilename) { var fileGroups = new List <FileGroup>(); var fileGroupOffsets = new List <uint>(); hdrFile = context.Open(hdrFilename); this.context = context; // Strips archive number AND file extension Name = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", ""); var signature = hdrFile.ReadUInt32(); if (signature != 0x28635349) { throw new InvalidDataException("Not an Installshield CAB package"); } commonHeader = new CommonHeader(hdrFile); cabDescriptor = new CabDescriptor(hdrFile, commonHeader); /* unknown */ hdrFile.ReadBytes(14); for (var i = 0U; i < MaxFileGroupCount; ++i) { fileGroupOffsets.Add(hdrFile.ReadUInt32()); } hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset, SeekOrigin.Begin); directoryTable = new List <uint>(); for (var i = 0U; i < cabDescriptor.DirectoryCount; ++i) { directoryTable.Add(hdrFile.ReadUInt32()); } foreach (var offset in fileGroupOffsets) { var nextOffset = offset; while (nextOffset != 0) { hdrFile.Seek((long)nextOffset + 4 + commonHeader.CabDescriptorOffset, SeekOrigin.Begin); var descriptorOffset = hdrFile.ReadUInt32(); nextOffset = hdrFile.ReadUInt32(); hdrFile.Seek(descriptorOffset + commonHeader.CabDescriptorOffset, SeekOrigin.Begin); fileGroups.Add(new FileGroup(hdrFile, commonHeader.CabDescriptorOffset)); } } hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset + cabDescriptor.FileTableOffset2, SeekOrigin.Begin); foreach (var fileGroup in fileGroups) { for (var i = fileGroup.FirstFile; i <= fileGroup.LastFile; ++i) { AddFileDescriptorToList(i); var fileDescriptor = fileDescriptors[i]; var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName(fileDescriptor.DirectoryIndex), fileDescriptor.Filename); index.Add(fullFilePath, i); } } }
public ConnectionHeader(CommonHeader header) { HeaderKey = "Connection"; string[] rawValue = header.GetValueString().Split(','); HeaderValue = new List <string>(); foreach (string s in rawValue) { HeaderValue.Add(s); } }
public InstallShieldCABExtractor(FileSystem context, string hdrFilename) { var fileGroups = new List<FileGroup>(); var fileGroupOffsets = new List<uint>(); hdrFile = context.Open(hdrFilename); this.context = context; // Strips archive number AND file extension Name = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", ""); var signature = hdrFile.ReadUInt32(); if (signature != 0x28635349) throw new InvalidDataException("Not an Installshield CAB package"); commonHeader = new CommonHeader(hdrFile); cabDescriptor = new CabDescriptor(hdrFile, commonHeader); /* unknown */ hdrFile.ReadBytes(14); for (var i = 0U; i < MaxFileGroupCount; ++i) fileGroupOffsets.Add(hdrFile.ReadUInt32()); hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset, SeekOrigin.Begin); directoryTable = new List<uint>(); for (var i = 0U; i < cabDescriptor.DirectoryCount; ++i) directoryTable.Add(hdrFile.ReadUInt32()); foreach (var offset in fileGroupOffsets) { var nextOffset = offset; while (nextOffset != 0) { hdrFile.Seek((long)nextOffset + 4 + commonHeader.CabDescriptorOffset, SeekOrigin.Begin); var descriptorOffset = hdrFile.ReadUInt32(); nextOffset = hdrFile.ReadUInt32(); hdrFile.Seek(descriptorOffset + commonHeader.CabDescriptorOffset, SeekOrigin.Begin); fileGroups.Add(new FileGroup(hdrFile, commonHeader.CabDescriptorOffset)); } } hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset + cabDescriptor.FileTableOffset2, SeekOrigin.Begin); foreach (var fileGroup in fileGroups) { for (var i = fileGroup.FirstFile; i <= fileGroup.LastFile; ++i) { AddFileDescriptorToList(i); var fileDescriptor = fileDescriptors[i]; var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName(fileDescriptor.DirectoryIndex), fileDescriptor.Filename); index.Add(fullFilePath, i); } } }
public SubmitFeedRequest(string documentVersion, string messageType = null) { Header = new CommonHeader() { DocumentVersion = documentVersion }; if (!string.IsNullOrEmpty(messageType)) { MessageType = messageType; } }
public unsafe void Connect() { CommonHeader head = new CommonHeader(); head.DstPort = 10000; head.SrcPort = 10001; head.VerTag = 1000; head.Chksum = 100; var buff = MemoryPool <byte> .Shared.Rent(sizeof(CommonHeader)); head.ToBig(buff.Memory.Span); Device.Send(buff.Memory.Span); }
public CabDescriptor(Stream reader, CommonHeader commonHeader) { reader.Seek(commonHeader.CabDescriptorOffset + 12, SeekOrigin.Begin); FileTableOffset = reader.ReadUInt32(); /* unknown */ reader.ReadUInt32(); FileTableSize = reader.ReadUInt32(); FileTableSize2 = reader.ReadUInt32(); DirectoryCount = reader.ReadUInt32(); /* unknown */ reader.ReadBytes(8); FileCount = reader.ReadUInt32(); FileTableOffset2 = reader.ReadUInt32(); }
public static HTTPResponse ResolveHTTPResponse(byte[] rawBytes) { HTTPResponse result = new HTTPResponse(); List <string> rawHeaders = new List <string>(); int pos = 0; string ht = ""; while (pos < rawBytes.Length) { byte tb = rawBytes[pos]; if (tb == '\r') { if (rawBytes[pos + 1] == '\n') { if (ht == "") { break; } rawHeaders.Add(ht); ht = ""; pos += 2; continue; } } ht += (char)tb; pos += 1; } string[] firstline = rawHeaders[0].Split(' '); rawHeaders.Remove(rawHeaders[0]); result.Version = firstline[0]; result.StatusCode = new HTTPStatusCode(Convert.ToInt32(firstline[1]), firstline[2]); foreach (string s in rawHeaders) { CommonHeader t = new CommonHeader(s); result.AddHeader(t); } return(result); }
void _drvSocket_OnRecievePacket(CommonHeader sender, List <short> listdata) { switch ((WheelSorterTelegram.TELEGRAM)sender.TelegramNo) { case WheelSorterTelegram.TELEGRAM.HEARTBEAT: _heartbeatCounter = 0; break; case WheelSorterTelegram.TELEGRAM.DESTINATION_SEND: //여기서 부터 Simulator DestinationRecv(listdata); break; default: break; } }
public override void Parse(VoidPtr address) { hdr = *(CommonHeader *)address; bint *v = (bint *)address; int[] sizes = MovesetFile.CalculateSizes(_root._dataSize, v, 26, false); ParseScripts(v, sizes); //These ICs need to be sorted into int and float arrays //Right now they're just a mess of values //The indices in the IC variable storage class _globalICs = Parse <RawParamList>(v[0], 188); _globalsseICs = Parse <RawParamList>(v[1], 188); _ICs = Parse <RawParamList>(v[2], 2204); _sseICs = Parse <RawParamList>(v[3], 2204); //_unknown7 = Parse<EntryList<CommonUnk7Entry>>(v[7], 8); _legBones = Parse <CommonLegBones>(v[21]); _ppMul = Parse <PatternPowerMul>(v[17]); }
void drvSocket_OnRecievePacket(CommonHeader sender, List <short> listdata) { switch ((WheelSorterTelegram.TELEGRAM)sender.TelegramNo) { case WheelSorterTelegram.TELEGRAM.HEARTBEAT: heartbeatCounter = 0; break; case WheelSorterTelegram.TELEGRAM.ITEM_SORTEDCONFIRM: OnItemSortedConfirm(listdata); break; case WheelSorterTelegram.TELEGRAM.SET_CONFIG_ACK: OnConfigurationAck(listdata); break; default: break; } }
public MainWindowViewModel() { List <byte> bats = new List <byte> { 0x01, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0xF4, 0x01, 0x09, 0x19, 0xC8, 0xE5, 0x39, 0xD7, (byte)'C', (byte)'o', (byte)'n', (byte)'c', (byte)'u', (byte)'r', (byte)'r', (byte)'e', (byte)'n', (byte)'t', (byte)' ', (byte)'T', (byte)'e', (byte)'c', (byte)'h', (byte)'n', (byte)'o', (byte)'l', (byte)'o', (byte)'g', (byte)'i', (byte)'e', (byte)'s', 0xCA, (byte)'A', (byte)'M', (byte)' ', (byte)'C', (byte)'8', (byte)'x', (byte)'/', (byte)'m', (byte)'7', (byte)'1', 0xCA, (byte)'M', (byte)'0', (byte)'0', (byte)'0', (byte)'0', (byte)'0', (byte)'/', (byte)'0', (byte)'0', (byte)'0', 0xCB, (byte)'7', (byte)'8', (byte)'1', (byte)'-', (byte)'6', (byte)'0', (byte)'2', (byte)'0', (byte)'-', (byte)'0', (byte)'0', 0xC0, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xC0, 0x02, 0x06, 0x25, 0x13, 0x5A, 0x31, 0x00, 0x16, 0x00, 0x3A, 0xC0, 0x82, 0x52, 0x86, 0xe6, 0x5A, 0x31, 0x00, 0x19, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x06, 0xE0, 0xFF, 0xFF, 0xE1, 0xFF, 0xFF, 0xE2, 0xFF, 0xFF, 0xE3, 0xFF, 0xFF, 0xA4, 0x98, 0xF3, 0x28, 0xA9, 0xF5, 0x00, 0x51, 0x00, 0x00, 0xFC, 0x01, 0x51, 0x00, 0x00, 0xFC, 0x02, 0x71, 0x10, 0x00, 0xFE, 0x03, 0x71, 0x10, 0x00, 0xFE, 0x04, 0x6F, 0x20, 0x00, 0xFC, 0x04, 0x6F, 0x20, 0x00, 0xFC, 0x05, 0x6F, 0x20, 0x00, 0xFC, 0x05, 0x6F, 0x20, 0x00, 0xFC }; CommonHeader ch = new CommonHeader(bats); Content = new BoardAreaViewModel(new BoardArea(ch, bats)); }
internal static int TType(CommonHeader o) { return o.tt; }
internal static int TType(CommonHeader o) { return(o.tt); }
public CabDescriptor(Stream reader, CommonHeader commonHeader) { reader.Seek(commonHeader.CabDescriptorOffset + 12, SeekOrigin.Begin); FileTableOffset = (long)reader.ReadUInt32(); /* unknown */ reader.ReadUInt32(); FileTableSize = reader.ReadUInt32(); FileTableSize2 = reader.ReadUInt32(); DirectoryCount = reader.ReadUInt32(); /* unknown */ reader.ReadBytes(8); FileCount = reader.ReadUInt32(); FileTableOffset2 = (long)reader.ReadUInt32(); }
public static bool ttisthread(CommonHeader o) { return(ttype(o) == LUA_TTHREAD); } //FIXME:added
public static bool ttisuserdata(CommonHeader o) { return(ttype(o) == LUA_TUSERDATA); } //FIXME:added
private void OnGetResponse(IAsyncResult asyncResult) { // get the response HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState; try { HttpWebResponse resp = (HttpWebResponse)req.EndGetResponse(asyncResult); Stream s = resp.GetResponseStream(); while (true) { CommonHeader heder = new CommonHeader(); //ByteArrayToStructure(s, ref heder); var buff = ReadBytes(s, 8); heder.StartByte = buff[0]; heder.Type = buff[1]; heder.SequenceNo = BitConverter.ToInt16(buff, 2);; heder.TimeStamp = BitConverter.ToInt32(buff, 4);; PayloadHeader playload = new PayloadHeader(); //ByteArrayToStructure(s, ref playload); buff = ReadBytes(s, 128); playload.StartCode = BitConverter.ToInt32(buff, 0); playload.JpgDataSize = BitConverter.ToUInt16(new byte[] { buff[6], buff[5], buff[4], 0 }, 0); playload.PadingSize = buff[7]; if (((CommonHeader)heder).Type == 0x02) { if (playload.JpgDataSize > 0) { var data = ReadBytes(s, playload.JpgDataSize); _liveViewData.FocusX = BitConverter.ToInt16(new byte[] { data[1], data[0] }, 0); _liveViewData.FocusY = BitConverter.ToInt16(new byte[] { data[3], data[2] }, 0);; _liveViewData.FocusFrameXSize = BitConverter.ToInt16(new byte[] { data[5], data[4] }, 0) - _liveViewData.FocusX; _liveViewData.FocusFrameYSize = BitConverter.ToInt16(new byte[] { data[7], data[6] }, 0) - _liveViewData.FocusY; _liveViewData.HaveFocusData = true; _liveViewData.Focused = data[9] != 0; _liveViewData.ImageWidth = 10000; _liveViewData.ImageHeight = 10000; _liveViewData.IsLiveViewRunning = true; Console.WriteLine(playload.JpgDataSize); } } else { _liveViewData.ImageData = ReadBytes(s, playload.JpgDataSize); } if (playload.PadingSize > 0) { ReadBytes(s, playload.PadingSize); } if (_shoulStopLiveView) { break; } } resp.Close(); } catch (Exception ex) { Log.Error("Unable to download stream ", ex); } }
/** * 发送数据 * * @param data 需要发送的内容 */ public static MemoryStream Serialize <T>(T msg) where T : IMessage { byte[] bbody = msg.ToByteArray(); string stype = msg.GetType().ToString(); stype = SharpClass2ProtoTypeName(stype); int bodylen = bbody.Length; CommonHeader headdata = new CommonHeader(); headdata.BodyType = stype; byte[] bhead = headdata.ToByteArray(); int headlen = bhead.Length; int totallen = 8 + headlen + bodylen; byte[] bshead = Encoding.ASCII.GetBytes(HeadString); MemoryStream ms = new MemoryStream(); ms.Write(bshead, 0, 4); bool needEncrypt = true; if (needEncrypt) { ms.Write(intToBytesLittle(totallen + 10), 0, 4); ms.Write(intToBytesLittle(headlen + 5), 0, 4); byte[] bheadE = new byte[bhead.Length + 5]; if (Encrypt.Txt_Encrypt(bhead, bhead.Length, bheadE, bheadE.Length)) { ms.Write(bheadE, 0, bheadE.Length); } else { Debug.LogError("Txt_Encrypt Error"); } if (bbody.Length > 0) { byte[] bbodyE = new byte[bbody.Length + 5]; if (Encrypt.Txt_Encrypt(bbody, bbody.Length, bbodyE, bbodyE.Length)) { ms.Write(bbodyE, 0, bbodyE.Length); } else { Debug.LogError("Txt_Encrypt Error"); } } } else { ms.Write(intToBytesLittle(totallen), 0, 4); ms.Write(intToBytesLittle(headlen), 0, 4); ms.Write(bhead, 0, bhead.Length); ms.Write(bbody, 0, bbody.Length); } return(ms); }
public static HTTPRequest ResolveHTTPRequest(byte[] rawBytes) { HTTPRequest result = new HTTPRequest(); List <string> rawHeaders = new List <string>(); int pos = 0; string ht = ""; while (pos < rawBytes.Length) { byte tb = rawBytes[pos]; if (tb == '\r') { if (rawBytes[pos + 1] == '\n') { if (ht == "") { break; } rawHeaders.Add(ht); ht = ""; pos += 2; continue; } } ht += (char)tb; pos += 1; } string[] firstLine = rawHeaders[0].Split(' '); rawHeaders.Remove(rawHeaders[0]); result.Method = new HTTPMethod(firstLine[0]); bool bre = Uri.TryCreate(firstLine[1], UriKind.RelativeOrAbsolute, out result.Url); result.Version = firstLine[2]; if (rawBytes.Length >= pos + 1) { result.Content = new byte[rawBytes.Length - pos]; for (int i = pos; i < rawBytes.Length; i++) { result.Content[i - pos] = rawBytes[i]; } } else { result.Content = null; } foreach (string s in rawHeaders) { CommonHeader t = new CommonHeader(s); result.AddHeader(t); } return(result); }
public static IMessage Parse(byte[] buf) { MemoryStream ms = new MemoryStream(buf); byte[] head = new byte[4]; ms.Read(head, 0, 4); string shead = System.Text.Encoding.ASCII.GetString(head); if (shead == HeadString) { byte[] btotallen = new byte[4]; ms.Read(btotallen, 0, 4); int totallen = bytesToIntLittle(btotallen, 0); byte[] bheadlen = new byte[4]; ms.Read(bheadlen, 0, 4); int headlen = bytesToIntLittle(bheadlen, 0); byte[] bheaddata = new byte[headlen]; byte[] bbodydata = new byte[totallen - headlen - 8]; ms.Read(bheaddata, 0, bheaddata.Length); ms.Read(bbodydata, 0, bbodydata.Length); CommonHeader headdata = null; IMessage bodydatamsg = null; bool needEncrypt = true; if (needEncrypt) { byte[] bheaddataDE = new byte[bheaddata.Length - 5]; if (Encrypt.Txt_Decrypt(bheaddata, bheaddata.Length, bheaddataDE, bheaddataDE.Length)) { } else { Debug.LogError("Txt_Decrypt Error"); } headdata = CommonHeader.Parser.ParseFrom(bheaddataDE); if (bbodydata.Length > 5) { byte[] bbodydataDE = new byte[bbodydata.Length - 5]; if (Encrypt.Txt_Decrypt(bbodydata, bbodydata.Length, bbodydataDE, bbodydataDE.Length)) { bodydatamsg = parseDynamic(headdata.BodyType, bbodydataDE); } else { Debug.LogError("Txt_Decrypt Error"); } } else { bodydatamsg = parseDynamic(headdata.BodyType, null); } } else { headdata = CommonHeader.Parser.ParseFrom(bheaddata); bodydatamsg = parseDynamic(headdata.BodyType, bbodydata); } return(bodydatamsg); } else { } return(null); }
public static int ttype(CommonHeader o) { return o.tt; }
public static int ttype(CommonHeader o) { return(o.tt); }
public EltHeader(CommonHeader header) : base(header) { m_FuncName = header.getFuncName(); }