Skip to content

Commit

Permalink
Merge pull request #1039 from xPaw/nha-info
Browse files Browse the repository at this point in the history
Simplify info in nethook analyzer
  • Loading branch information
yaakov-h authored Oct 24, 2021
2 parents d4eb8b6 + 2905b40 commit 5d8b917
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 39 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Resources/NetHookAnalyzer2/NetHookAnalyzer2/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void RepopulateTreeView()
}

itemExplorerTreeView.Nodes.Clear();
itemExplorerTreeView.Nodes.AddRange(BuildTree(item).Nodes.Cast<TreeNode>().ToArray());
itemExplorerTreeView.Nodes.Add(BuildTree(item));
itemExplorerTreeView.Nodes[0].EnsureVisible(); // Scroll to top
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,64 +55,61 @@ TreeNode CreateTreeNodeCore(bool displayUnsetFields)
{
var configuration = new TreeNodeObjectExplorerConfiguration { ShowUnsetFields = displayUnsetFields };

var node = new TreeNode();
using var stream = item.OpenStream();

using (var stream = item.OpenStream())
{
var rawEMsg = PeekUInt(stream);
var rawEMsg = PeekUInt(stream);
var node = BuildInfoNode(rawEMsg);
node.Expand();

node.Nodes.Add(BuildInfoNode(rawEMsg, configuration));
var header = ReadHeader(rawEMsg, stream);
node.Nodes.Add(new TreeNodeObjectExplorer("Header", header, configuration).TreeNode);

var header = ReadHeader(rawEMsg, stream);
node.Nodes.Add(new TreeNodeObjectExplorer("Header", header, configuration).TreeNode);
var body = ReadBody(rawEMsg, stream, header);
var bodyNode = new TreeNodeObjectExplorer("Body", body, configuration).TreeNode;
node.Nodes.Add(bodyNode);

var body = ReadBody(rawEMsg, stream, header);
var bodyNode = new TreeNodeObjectExplorer("Body", body, configuration).TreeNode;
node.Nodes.Add(bodyNode);
var payload = ReadPayload(stream);
if (payload != null && payload.Length > 0)
{
node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode);
}

var payload = ReadPayload(stream);
if (payload != null && payload.Length > 0)
if (Specializations != null)
{
var objectsToSpecialize = new[] { body };
while (objectsToSpecialize.Any())
{
node.Nodes.Add(new TreeNodeObjectExplorer("Payload", payload, configuration).TreeNode);
}
var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o)));

if (Specializations != null)
{
var objectsToSpecialize = new[] { body };
while (objectsToSpecialize.Any())
if (!specializations.Any())
{
var specializations = objectsToSpecialize.SelectMany(o => Specializations.SelectMany(x => x.ReadExtraObjects(o)));

if (!specializations.Any())
{
break;
}
break;
}

bodyNode.Collapse(ignoreChildren: true);
bodyNode.Collapse(ignoreChildren: true);

var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value, configuration).TreeNode).ToArray();
node.Nodes.AddRange(extraNodes);
var extraNodes = specializations.Select(x => new TreeNodeObjectExplorer(x.Key, x.Value, configuration).TreeNode).ToArray();
node.Nodes.AddRange(extraNodes);

// Let the specializers examine any new message objects.
objectsToSpecialize = specializations.Select(x => x.Value).ToArray();
}
// Let the specializers examine any new message objects.
objectsToSpecialize = specializations.Select(x => x.Value).ToArray();
}
}

return node;
}

static TreeNode BuildInfoNode(uint rawEMsg, TreeNodeObjectExplorerConfiguration configuration)
static TreeNode BuildInfoNode(uint rawEMsg)
{
var eMsg = MsgUtil.GetMsg(rawEMsg);
var eMsg = MsgUtil.GetMsg( rawEMsg );
var eMsgName = $"EMsg {eMsg:G} ({eMsg:D})";

var eMsgExplorer = new TreeNodeObjectExplorer("EMsg", eMsg, configuration);

return new TreeNode("Info", new[]
if( MsgUtil.IsProtoBuf( rawEMsg ) )
{
eMsgExplorer.TreeNode,
new TreeNodeObjectExplorer("Is Protobuf", MsgUtil.IsProtoBuf(rawEMsg), configuration).TreeNode
});
return new TreeNode( eMsgName );
}

return new TreeNode( $"{eMsgName} (Non-Protobuf)" );
}
}
}

0 comments on commit 5d8b917

Please sign in to comment.