public OfpFlowStats(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out Length); br.Parse(out TableId); br.ReadBytes(1); Match = new OfpMatch(stream); br.Parse(out DurationSec); br.Parse(out DurationNsec); br.Parse(out Priority); br.Parse(out IdleTimeout); br.Parse(out HardTimeout); br.ReadBytes(6); br.Parse(out Cookie); br.Parse(out PacketCount); br.Parse(out ByteCount); IOfpAction action = OfpActionHeader.ParseAction(stream); while (action != null) { Actions[action.Header.Type] = action; action = OfpActionHeader.ParseAction(stream); } }
/// <summary> /// Read a string in unicode, no matter what encode <paramref name="reader">BeBinaryReader</paramref> is. /// </summary> /// <param name="reader"></param> /// <returns></returns> public static string ReadUnicodeString(this BeBinaryReader reader) { StringBuilder sb = new StringBuilder(); long startPos = reader.BaseStream.Position; var s = Encoding.Unicode.GetString(reader.ReadBytes(2)); while (s != "\0") { sb.Append(s); s = Encoding.Unicode.GetString(reader.ReadBytes(2)); } return(sb.ToString()); }
public PlayerDef(BeBinaryReader br) { ID = br.ReadInt32(); MatchIndex = br.ReadInt32(); HiddenName = br.ReadInt32(); ShortName = br.ReadInt32(); FullName = br.ReadInt32(); Name = Encoding.ASCII.GetString(br.ReadBytes(24)); Gender = (Gender)br.ReadInt32(); IdleAnimation = br.ReadInt32(); Unk_34 = br.ReadInt32(); Description = br.ReadInt32(); Bodytype = (Bodytype)br.ReadInt32(); Scale = br.ReadInt32(); ShadowSize = br.ReadInt32(); TacticalAction = (TacticalAction)br.ReadInt32(); CourseAnimation = br.ReadInt32(); Team = br.ReadInt32(); Emblem = br.ReadInt32(); TeamPortrait = br.ReadInt32(); Position = br.ReadInt32(); MatchFaceModel = br.ReadInt32(); Facemodel = br.ReadInt32(); Facemodel2 = br.ReadInt32(); Bodymodel = br.ReadInt32(); Bodymodel2 = br.ReadInt32(); Unk_74 = br.ReadInt32(); Portrait = br.ReadInt32(); Unk_7C = br.ReadInt32(); LeftPortrait = br.ReadInt32(); RightPortrait = br.ReadInt32(); Equip = new string[2]; Equip[0] = Encoding.ASCII.GetString(br.ReadBytes(24)); Equip[1] = Encoding.ASCII.GetString(br.ReadBytes(24)); Unk_B8 = br.ReadBytes(48); SkinColor1 = Color.FromArgb(br.ReadInt32()); SkinColor2 = Color.FromArgb(br.ReadInt32()); Unk_F0 = br.ReadInt32(); Element = (Element)br.ReadInt32(); ChargeProfile = br.ReadInt32(); Unk_FC = br.ReadInt32(); Unk_100 = br.ReadInt32(); Voice = br.ReadInt32(); ArmedAttribution = br.ReadInt32(); Unk_10C = br.ReadInt32(); Price = br.ReadInt16(); ListPosition = br.ReadInt16(); TeamListPosition = br.ReadInt32(); Unk25 = br.ReadInt32(); Pad2 = br.ReadBytes(44); }
public Save(string name, int slot) { filename = name; BaseOffset = (uint)(0x2590 + slot * 0x68548); var file = File.OpenRead(filename); using (var br = new BeBinaryReader(file)) { br.BaseStream.Position = ONLINE_PROFILE; OnlineName = sjis.GetString(br.ReadBytes(16)); OnlineProfile = br.ReadUInt32(); br.BaseStream.Position = BaseOffset + 8; CreationDate = br.ReadUInt32(); CreationTime = br.ReadUInt32(); HoursPlayed = br.ReadUInt32(); MinutesPlayed = br.ReadUInt32(); br.BaseStream.Position = BaseOffset + INAZUMA_POINT_OFFSET; InazumaPoints = br.ReadUInt32(); br.BaseStream.Position = BaseOffset + PROFILENAME_OFFSET; ProfileName = sjis.GetString(br.ReadBytes(16)); for (var i = 0; i < 412; i++) { // Stats var player = new Player(); br.BaseStream.Position = BaseOffset + STATS_OFFSET + i * 0x3c; player.Stats = new Stats(br); // Moves br.BaseStream.Position = BaseOffset + WAZA_OFFSET + i * 0x22; player.MoveList = new MoveList(br); Players[i] = player; } br.BaseStream.Position = BaseOffset + TEAM_OFFSET; Team = new Team(br); br.BaseStream.Position = BaseOffset + PROFILENAME_OFFSET + 18; Team.Name = sjis.GetString(br.ReadBytes(16)); br.BaseStream.Position = BaseOffset + TEAM_EMBLEM_OFFSET; Team.Emblem = br.ReadInt16(); br.BaseStream.Position = BaseOffset + PROFILE_OFFSET; Profile = br.ReadUInt32(); } }
public OfpPacketIn(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); br.Parse(out BufferId); br.Parse(out TotalLen); br.Parse(out InPort); br.Parse(out Reason); br.ReadBytes(1); int length = (int)(Header.Length - Size + 2); //FIXED: Data = br.ReadBytes(length); }
private void ParsePlayerFile(Stream input) { PlayerNames = Names.GetTextFile("Strikers2013Editor.Common.playerNames.txt"); using (var br = new BeBinaryReader(input)) { DataBackup = br.ReadBytes(0xFA4); br.BaseStream.Position = 0x10; var count = br.ReadInt32(); br.BaseStream.Position = 0xFA4; Players = new List <PlayerDef>(); for (var i = 1; i < count; i++) { if (br.BaseStream.Position > br.BaseStream.Length - 0x148) { break; } var player = new PlayerDef(br); Players.Add(player); if (i < PlayerNames.Length) { cmbPlayers.Items.Add(PlayerNames[i]); } else { cmbPlayers.Items.Add(player.Name); } } } }
public Stats(BeBinaryReader br) { var pos = br.BaseStream.Position; Flag = br.ReadInt32(); Unknown = br.ReadInt32(); TP = br.ReadByte(); MaxTP = br.ReadByte(); Kick = br.ReadByte(); MaxKick = br.ReadByte(); Catch = br.ReadByte(); MaxCatch = br.ReadByte(); Body = br.ReadByte(); MaxBody = br.ReadByte(); Guard = br.ReadByte(); MaxGuard = br.ReadByte(); Control = br.ReadByte(); MaxControl = br.ReadByte(); Speed = br.ReadByte(); MaxSpeed = br.ReadByte(); Unk = br.ReadBytes(0xE); Kakusei = br.ReadInt32(); XP = br.ReadInt32(); MoveUnk = br.ReadInt16(); MoveKakusei2 = br.ReadInt16(); MoveKakusei2_2 = br.ReadInt16(); MoveKakusei2_3 = br.ReadInt16(); MoveKakusei3 = br.ReadInt16(); MoveKakusei3_2 = br.ReadInt16(); MoveKakusei3_3 = br.ReadInt16(); Unk2 = br.ReadInt16(); }
public OfpPortStatsRequest(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out PortNo); br.ReadBytes(6); }
public OfpActionDlAddr(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = new OfpActionHeader(stream); br.Parse(out DlAddr, OFP_MAX_ETH_ALEN); br.ReadBytes(6); }
public OfpFlowRemoved(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); Match = new OfpMatch(stream); br.Parse(out Cookie); br.Parse(out Priority); br.Parse(out Reason); br.ReadBytes(1); br.Parse(out DurationSec); br.Parse(out DurationNsec); br.Parse(out IdleTimeout); br.ReadBytes(2); br.Parse(out PacketCount); br.Parse(out ByteCount); }
public OfpActionNwTos(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = new OfpActionHeader(stream); br.Parse(out NwTos); br.ReadBytes(3); }
public OfpQueuePropHeader(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out Property); br.Parse(out Len); br.ReadBytes(4); }
public OfpPacketQueue(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out QueueId); br.Parse(out Len); br.ReadBytes(2); //PAD }
public OfpActionTpPort(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = new OfpActionHeader(stream); br.Parse(out TpPort); br.ReadBytes(2); //PAD 2 }
public OfpQueueGetConfigRequest(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); br.Parse(out Port); br.ReadBytes(2); }
public OfpPortStatus(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); br.Parse(out Reason); br.ReadBytes(7); Desc = new OfpPhyPort(stream); }
public OfpActionEnqueue(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = new OfpActionHeader(stream); br.Parse(out Port); br.ReadBytes(6); //PAD 6 br.Parse(out QueueId); }
public OfpAggregateStatsRequest(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Match = new OfpMatch(stream); br.Parse(out TableId); br.ReadBytes(1); br.Parse(out OutPort); }
public OfpActionHeader(Stream stream, int padding) { _pad = padding; BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out Type); br.Parse(out Len); br.ReadBytes(_pad); //PAD 4 }
public OfpAggregateStats(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out PacketCount); br.Parse(out ByteCount); br.Parse(out FlowCount); br.ReadBytes(4); }
public static byte[] DeSerializeLongString(byte[] buf) { BeBinaryReader br = new BeBinaryReader(new MemoryStream(buf)); uint size = br.ReadUInt32(); byte[] data = br.ReadBytes((int)size); br.Close(); return(data); }
public OfpMatch(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out Wildcards); br.Parse(out InPort); br.Parse(out DlSrc, OFP_MAX_ETH_ALEN); br.Parse(out DlDst, OFP_MAX_ETH_ALEN); br.Parse(out DlVlan); br.Parse(out DlVlanPcp); br.ReadBytes(1); //PAD 1 br.Parse(out DlType); br.Parse(out NwTos); br.Parse(out NwProto); br.ReadBytes(2); //PAD 2 br.Parse(out NwSrc); br.Parse(out NwDst); br.Parse(out TpSrc); br.Parse(out TpDst); }
public OfpQueueStats(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out PortNo); br.ReadBytes(2); //PAD 2 br.Parse(out QueueId); br.Parse(out TxBytes); br.Parse(out TxPackets); br.Parse(out TxErrors); }
private void rebuildAw(int num) { var awTemp = File.OpenWrite("awBuild.temp"); var grp = root.currentWSYS.Groups[num]; var grpFile = grp.awFile; var awOriginal = File.OpenRead(grpFile); var wss = root.currentWSYSStream; var wsysWrite = new BeBinaryWriter(wss); var awWrite = new BeBinaryWriter(awTemp); var awRead = new BeBinaryReader(awOriginal); var awOffset = 0; if (!rebuildData.ContainsKey(num)) { return; } Console.WriteLine("Rebuild request found."); var rbdWaves = rebuildData[num]; for (int i = 0; i < grp.Waves.Length; i++) { var originalWave = grp.Waves[i]; byte[] awBuff; if (rbdWaves.ContainsKey(i)) { awBuff = rbdWaves[i]; Console.WriteLine("Injecting custom wave..."); } else { awRead.BaseStream.Position = originalWave.wsys_start; awBuff = awRead.ReadBytes(originalWave.wsys_size); } awTemp.Write(awBuff, 0, awBuff.Length); wsysWrite.BaseStream.Position = originalWave.mOffset; wsysWrite.Seek(0x04, SeekOrigin.Current); wsysWrite.Write((float)originalWave.sampleRate); wsysWrite.Write(awOffset); wsysWrite.Write(awBuff.Length); originalWave.wsys_start = awOffset; // update in-memory copies originalWave.wsys_size = awBuff.Length; // update in-memory copies awOffset += awBuff.Length; wsysWrite.Flush(); awTemp.Flush(); } Console.WriteLine($"Rebuilt {grpFile}"); awTemp.Close(); awRead.Close(); awOriginal.Close(); File.Delete(grpFile); File.Move("awBuild.temp", grpFile); }
public OfpEcho(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); var length = Header.Length - Size; if (length > 0) { Data = br.ReadBytes((int)length); } }
public OfpTableStats(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out TableId); br.ReadBytes(3); //PAD 3 br.Parse(out Name, OFP_MAX_TABLE_NAME_LEN); Wildcards = new OfpWildcards(stream); br.Parse(out MaxEntries); br.Parse(out ActiveCount); br.Parse(out LookupCount); br.Parse(out MatchedCount); }
public OfpQueueGetConfig(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); br.Parse(out Port); br.ReadBytes(6); //PAD 6 var count = (Header.Length - Size) / OfpPacketQueue.Size; for (int i = 0; i < count; i++) { Queues.Add(new OfpPacketQueue(stream)); } }
public static void unpack_baa(JAIInitSection[] data, BeBinaryReader br, string projDir, string initName) { try { Directory.CreateDirectory(projDir); Directory.CreateDirectory(projDir + "/include"); } catch (Exception e) { cmdarg.assert("Could not create project directory: {0}", e.Message); } var pFile = new jBAAProjectFile(); pFile.originalFile = initName; pFile.projectName = projDir; pFile.includes = new jBAAIncludeRecord[data.Length]; Console.WriteLine("Unpack BAA"); var fileIndex = 0; for (int i = 0; i < data.Length; i++) { var cSect = data[i]; var size = baa_GetSectionSize(cSect, br); // load section size from function (because BAA omits data for a lot of this :) ) br.BaseStream.Position = cSect.start; var sectionData = br.ReadBytes(size); var extension = util.GetFileExtension(cSect); File.WriteAllBytes($"{projDir}/include/{fileIndex}{extension}", sectionData); Console.WriteLine($"->\tWrote {fileIndex}{extension}"); pFile.includes[i] = new jBAAIncludeRecord() { hash = cSect.raw_header, path = $"include/{fileIndex}{extension}", type = cSect.type.ToString(), uid = cSect.number, flags = cSect.flags, }; fileIndex++; } var convertedData = JsonConvert.SerializeObject(pFile, Formatting.Indented); File.WriteAllText($"{projDir}/project.json", convertedData); }
public OfpSwitchFeatures(Stream stream, OfpHeader header = null) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); Header = header ?? new OfpHeader(stream); br.Parse(out DatapathId); br.Parse(out NBuffers); br.Parse(out NTables); br.ReadBytes(3); //PAD 3 br.Parse(out Capabilities); br.Parse(out Actions); var portCount = (Header.Length - Size) / OfpPhyPort.Size; for (int i = 0; i < portCount; i++) { OfpPhyPort port = new OfpPhyPort(stream); Ports.Add(port); } }
public OfpPortStats(Stream stream) { BeBinaryReader br = new BeBinaryReader(stream, Encoding.ASCII, true); br.Parse(out PortNo); br.ReadBytes(6); br.Parse(out RxPackets); br.Parse(out TxPackets); br.Parse(out RxBytes); br.Parse(out TxBytes); br.Parse(out RxDropped); br.Parse(out TxDropped); br.Parse(out RxErrors); br.Parse(out TxErrors); br.Parse(out RxFrameErr); br.Parse(out RxOverErr); br.Parse(out RxCrcErr); br.Parse(out Collisions); }