Skip to content

Commit

Permalink
read root obj table
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Aug 25, 2024
1 parent 21e7502 commit 4f7e58f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>netstandard2.1;net461</TargetFrameworks>
<LangVersion>9</LangVersion>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>SHARPZIPLIB</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Enums
namespace DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Enums
{
public enum TiaFixedRootObjectInstanceIds : long
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using DotNetSiemensPLCToolBoxLibrary.DataTypes;
using DotNetSiemensPLCToolBoxLibrary.General;
using DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Enums;
using DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA.Structs;

namespace DotNetSiemensPLCToolBoxLibrary.Projectfiles.TIA
Expand Down Expand Up @@ -38,6 +40,38 @@ public void BinaryParseTIAFile()
{
var hd = TiaObjectHeader.Deserialize(rd);
TiaObjectsList.Add(hd);

if (hd.TypeId == 0x70000 + 14) //localization_table
{
var langs = new List<int>();
using var ms = new MemoryStream(hd.Data);
using var br = new BinaryReader(ms);
var maybe_length_including_itself = br.ReadInt32();

var count = br.ReadInt32();
for (int i = 0; i < count;i++)
{
var lng = br.ReadInt32();
langs.Add(lng);
var unkown_maybe_flags = br.ReadByte();
}
}
else if (hd.TypeId == 0x70000 + 9) //Root Object Table
{
var rootObjs = new List<int>();
using var ms = new MemoryStream(hd.Data);
using var br = new BinaryReader(ms);
var maybe_length_including_itself = br.ReadInt32();

var count = br.ReadInt32();
for (int i = 0; i < count; i++)
{
var id = br.ReadInt32();
var instId = br.ReadInt64();
var ln = br.ReadByte();
var nm = Encoding.UTF8.GetString(br.ReadBytes(ln));
}
}
}
}
catch (EndOfStreamException) // Zip File Stream has no length
Expand Down

0 comments on commit 4f7e58f

Please sign in to comment.