Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add evtx file association and handle open with #105

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/EventLogExpert/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ public MainPage(IDispatcher fluxorDispatcher, IEventResolver resolver)
PopulateOtherLogsMenu();

ListenForResolverStatus();

var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
OpenEventLogFile(args[1]);
}
}

private void OpenEventLogFile(string fileName)
{
_fluxorDispatcher.Dispatch(
new EventLogAction.OpenLog(
new EventLogState.LogSpecifier(
fileName,
EventLogState.LogType.File)));


Utils.UpdateAppTitle(fileName);
}

public async void OpenFile_Clicked(object sender, EventArgs e)
Expand All @@ -42,14 +60,8 @@ public async void OpenFile_Clicked(object sender, EventArgs e)

if (result != null)
{
_fluxorDispatcher.Dispatch(
new EventLogAction.OpenLog(
new EventLogState.LogSpecifier(
result.FullPath,
EventLogState.LogType.File)));
OpenEventLogFile(result.FullPath);
}

Utils.UpdateAppTitle(result?.FullPath);
}

private void CheckForUpdates_Clicked(object? sender, EventArgs e) =>
Expand Down
10 changes: 10 additions & 0 deletions src/EventLogExpert/Platforms/Windows/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="windowseventlog">
<uap:SupportedFileTypes>
<uap:FileType>.evtx</uap:FileType>
</uap:SupportedFileTypes>
<uap:DisplayName>Windows Event Log</uap:DisplayName>
</uap:FileTypeAssociation>
</uap:Extension>
</Extensions>
</Application>
</Applications>

Expand Down
14 changes: 13 additions & 1 deletion src/EventLogExpert/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,22 @@ internal static void InitTracing()
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(LoggingPath, "myListener"));
System.Diagnostics.Trace.AutoFlush = true;

var firstChanceSemaphore = new SemaphoreSlim(1);

// Trace all exceptions
AppDomain.CurrentDomain.FirstChanceException += (o, args) =>
{
Trace($"{args.Exception}");
// Unless we're already tracing one.
//
// When an instance of EventLogExpert is launched by double-clicking an evtx file
// and no databases are present, we get into a condition where we're trying to trace
// a first-chance exception, and the act of tracing causes another first-chance
// exception, which we then try to trace, until we hit a stack overflow.
if (firstChanceSemaphore.Wait(100))
{
Trace($"{args.Exception}");
firstChanceSemaphore.Release();
}
};
}

Expand Down