Skip to content

Commit

Permalink
[gui] Give a -depth option to the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasg committed Nov 11, 2021
1 parent 2f42353 commit 1997a40
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 52 deletions.
23 changes: 16 additions & 7 deletions DependenciesGui/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
<setting name="FullPath" serializeAs="String">
<value>True</value>
</setting>
<setting name="RecentFilesIndex" serializeAs="String">
<value>0</value>
</setting>
<setting name="PeViewerPath" serializeAs="String">
<value>peview.exe</value>
</setting>
<setting name="TreeBuildBehaviour" serializeAs="String">
<value>ChildOnly</value>
</setting>
<setting name="Font" serializeAs="String">
<value>Courier New</value>
</setting>
<setting name="RecentFiles" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -36,14 +48,11 @@
</ArrayOfString>
</value>
</setting>
<setting name="PeViewerPath" serializeAs="String">
<value>peview.exe</value>
<setting name="TreeDepth" serializeAs="String">
<value>2</value>
</setting>
<setting name="TreeBuildBehaviour" serializeAs="String">
<value>ChildOnly</value>
</setting>
<setting name="Font" serializeAs="String">
<value>Courier New</value>
<setting name="BinaryCacheOptionValue" serializeAs="String">
<value>True</value>
</setting>
</Dependencies.Properties.Settings>
</userSettings>
Expand Down
9 changes: 7 additions & 2 deletions DependenciesGui/DependencyWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,13 @@ private void ConstructDependencyTree(ModuleTreeViewItem RootNode, PE CurrentPE,
}


// Process next batch of dll imports
if (SettingTreeBehaviour != TreeBuildingBehaviour.DependencyTreeBehaviour.ChildOnly)
// Process next batch of dll imports only if :
// 1. Recursive tree building has been activated
// 2. Recursion is not hitting the max depth level
bool doProcessNextLevel = (SettingTreeBehaviour != TreeBuildingBehaviour.DependencyTreeBehaviour.ChildOnly) &&
(RecursionLevel < Dependencies.Properties.Settings.Default.TreeDepth);

if (doProcessNextLevel)
{
foreach (var ImportNode in PEProcessingBacklog)
{
Expand Down
78 changes: 48 additions & 30 deletions DependenciesGui/Properties/Settings.Designer.cs

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

25 changes: 18 additions & 7 deletions DependenciesGui/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
<Setting Name="RecentFilesIndex" Type="System.Byte" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="PeViewerPath" Type="System.String" Scope="User">
<Value Profile="(Default)">peview.exe</Value>
</Setting>
<Setting Name="TreeBuildBehaviour" Type="System.String" Scope="User">
<Value Profile="(Default)">ChildOnly</Value>
</Setting>
<Setting Name="Font" Type="System.String" Scope="User">
<Value Profile="(Default)">Courier New</Value>
</Setting>
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
Expand All @@ -22,16 +31,18 @@
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;string /&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="PeViewerPath" Type="System.String" Scope="User">
<Value Profile="(Default)">peview.exe</Value>
<Setting Name="TreeDepth" Type="System.Int32" Scope="User">
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="TreeBuildBehaviour" Type="System.String" Scope="User">
<Value Profile="(Default)">ChildOnly</Value>
</Setting>
<Setting Name="Font" Type="System.String" Scope="User">
<Value Profile="(Default)">Courier New</Value>
<Setting Name="BinaryCacheOptionValue" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
26 changes: 22 additions & 4 deletions DependenciesGui/UserSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
Expand Down Expand Up @@ -86,23 +87,40 @@
SelectedItem="{Binding Source={x:Static properties:Settings.Default}, Path=TreeBuildBehaviour, Mode=OneWay, Converter={StaticResource TreeBuildingBehaviourConverter}}"
/>


<!-- Tree depth -->
<Label Margin="5"
Grid.Row="3"
Grid.Column="0"
Content="Tree depth:"
HorizontalAlignment="Left"
VerticalAlignment="Center" />

<TextBox Name="TreeDepthValue"
PreviewTextInput="NumericOnly"
Grid.Row="3"
Grid.Column="1"
Margin="5"
Text="{Binding Source={x:Static properties:Settings.Default}, Path=TreeDepth, Mode=OneWay}"
TextWrapping="Wrap"
VerticalContentAlignment="Center" />


<!-- Font family selection -->
<Label Margin="5"
Grid.Row="3"
Grid.Row="4"
Grid.Column="0"
Content="Font family:"
HorizontalAlignment="Left"
VerticalAlignment="Top" />

<ListBox Name="FontFamilyList"
Margin="5"
Grid.Row="3"
Grid.Row="4"
Grid.Column="1" />


<!-- Buttons -->
<StackPanel Grid.Row="4" Grid.Column="1"
<StackPanel Grid.Row="5" Grid.Column="1"
Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Cancel"
Height="20"
Expand Down
24 changes: 22 additions & 2 deletions DependenciesGui/UserSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ private void OnValidate(object sender, RoutedEventArgs e)
// Update defaults
Dependencies.Properties.Settings.Default.PeViewerPath = PeviewerPath;

if (TreeBuildCombo.SelectedItem != null)
int TreeDepth = Dependencies.Properties.Settings.Default.TreeDepth;
if (Int32.TryParse(TreeDepthValue.Text, out TreeDepth))
{
Dependencies.Properties.Settings.Default.TreeDepth = TreeDepth;
}


if (TreeBuildCombo.SelectedItem != null)
{
Dependencies.Properties.Settings.Default.TreeBuildBehaviour = TreeBuildCombo.SelectedItem.ToString();
}
Expand All @@ -227,6 +234,7 @@ private void OnValidate(object sender, RoutedEventArgs e)
Dependencies.Properties.Settings.Default.BinaryCacheOptionValue = newValue;
}


Dependencies.Properties.Settings.Default.Font = FontFamilyListItem.GetDisplayName(SelectedFontFamily);
this.Close();
}
Expand Down Expand Up @@ -342,6 +350,18 @@ private void OnPeviewerPathSettingChange(object sender, RoutedEventArgs e)
PeviewerPath = InputFileNameDlg.FileName;
}

}
private void NumericOnly(System.Object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = IsTextNumeric(e.Text);

}

private static bool IsTextNumeric(string str)
{
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[^0-9]+");
return reg.IsMatch(str);

}
}

}

0 comments on commit 1997a40

Please sign in to comment.