Skip to content

Commit

Permalink
added truncated data indicator (ETW max 64KB buffer issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
okieselbach committed Sep 20, 2022
1 parent a2c33aa commit bd80d80
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions SyncMLViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@
<Label x:Name="LabelDeviceName" Content="DeviceName" Margin="0,0,22.6,11.4" HorizontalAlignment="Right" Width="190" Height="34" VerticalAlignment="Bottom" FontSize="18" ToolTip="The name of the device."/>
<Button x:Name="ButtonRestartUpdate" Content="_Update to version [0.0.0]" Margin="0,0,224.6,12.4" Click="ButtonRestartUpdate_Click" HorizontalAlignment="Right" Width="159" Height="29" VerticalAlignment="Bottom" Visibility="Visible"/>
<Label x:Name="LabelUpdateIndicator" Content="Update [0.0.0] available." Margin="0,0,212.6,13.4" HorizontalAlignment="Right" Width="153" Height="26" VerticalAlignment="Bottom" Visibility="Hidden"/>
<Label x:Name="LabelTruncatedDataIndicator" Content="Received data truncated (ETW can capture max 64KB)" Margin="268,0,438,13" Height="26" VerticalAlignment="Bottom" Visibility="Visible"/>
</Grid>
</Window>
26 changes: 26 additions & 0 deletions SyncMLViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Xml.XPath;
using SyncMLViewer.Properties;
using Path = System.IO.Path;
using System.Xml;

namespace SyncMLViewer
{
Expand Down Expand Up @@ -78,6 +79,7 @@ public MainWindow()
LabelStatus.Visibility = Visibility.Hidden;
LabelStatusTop.Visibility = Visibility.Hidden;
ButtonRestartUpdate.Visibility = Visibility.Hidden;
LabelTruncatedDataIndicator.Visibility = Visibility.Hidden;
var version = Assembly.GetExecutingAssembly().GetName().Version;
_version = $"{version.Major}.{version.Minor}.{version.Build}";
this.Title += $" - {_version}";
Expand Down Expand Up @@ -229,6 +231,10 @@ private static void WorkerTraceEvents(object sender, DoWorkEventArgs e)
traceEventSession.EnableProvider(OmaDmClient);
traceEventSession.EnableProvider(OmaDmClientProvider);

// https://docs.microsoft.com/en-us/windows/win32/api/evntrace/ns-evntrace-event_trace_properties
// !!! Regardless of buffer size, ETW cannot collect events larger than 64KB.
// This results in truncated policies... :-( unaware how to deal with this to get the full event data then...

new RegisteredTraceEventParser(traceEventSource).All += (data =>
(sender as BackgroundWorker)?.ReportProgress(0, data.Clone()));
traceEventSource.Process();
Expand Down Expand Up @@ -500,6 +506,26 @@ private void ListBoxMessages_SelectionChanged(object sender, SelectionChangedEve
if (!(ListBoxMessages.SelectedItem is SyncMlMessage selectedItem))
return;
TextEditorMessages.Text = selectedItem.Xml;

bool wellFormatedXml = true;
try
{
XElement.Parse(selectedItem.Xml);
}
catch (Exception)
{
wellFormatedXml = false;
}

if (selectedItem.Xml.Length > 60 * 1000 && !wellFormatedXml)
{
LabelTruncatedDataIndicator.Visibility = Visibility.Visible;
}
else
{
LabelTruncatedDataIndicator.Visibility = Visibility.Hidden;
}

_foldingStrategy.UpdateFoldings(_foldingManager, TextEditorMessages.Document);

CheckBoxHtmlDecode.IsChecked = false;
Expand Down
6 changes: 3 additions & 3 deletions SyncMLViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("oliverkieselbach.com")]
[assembly: AssemblyProduct("SyncMLViewer")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
2 changes: 1 addition & 1 deletion SyncMLViewer/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions SyncMLViewer/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ https://gist.github.com/mattifestation/04e8299d8bc97ef825affe733310f7bd/
More MDM ETW Provider details
https://docs.microsoft.com/en-us/windows/client-management/mdm/diagnose-mdm-failures-in-windows-10

Regardless of buffer size, ETW cannot collect events larger than 64KB. :-(
https://docs.microsoft.com/en-us/windows/win32/api/evntrace/ns-evntrace-event_trace_properties

[MS-MDM]: Mobile Device Management Protocol
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-mdm/

Expand Down
Binary file added SyncMLViewer/dist/SyncMLViewer-v108.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions SyncMLViewer/dist/update.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<LatestVersion>
<VersionNumber>1.0.7</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v107.zip</DownloadURL>
<VersionNumber>1.0.8</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v108.zip</DownloadURL>
</LatestVersion>
4 changes: 2 additions & 2 deletions SyncMLViewer/dist/update2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<LatestVersion>
<VersionNumber>1.0.7</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v107.zip</DownloadURL>
<VersionNumber>1.0.8</VersionNumber>
<DownloadURL>https://github.com/okieselbach/SyncMLViewer/raw/master/SyncMLViewer/dist/SyncMLViewer-v108.zip</DownloadURL>
</LatestVersion>

0 comments on commit bd80d80

Please sign in to comment.