Skip to content

Commit 6286184

Browse files
committed
handle trace control not being found
1 parent f29c8ed commit 6286184

6 files changed

Lines changed: 56 additions & 40 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayer.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\build\Microsoft.Diagnostics.Tracing.TraceEvent.props" Condition="Exists('..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\build\Microsoft.Diagnostics.Tracing.TraceEvent.props')" />
3+
<Import Project="..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\build\Microsoft.Diagnostics.Tracing.TraceEvent.props" Condition="Exists('..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\build\Microsoft.Diagnostics.Tracing.TraceEvent.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -46,17 +46,17 @@
4646
</PropertyGroup>
4747
<ItemGroup>
4848
<Reference Include="Dia2Lib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
49-
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\lib\net45\Dia2Lib.dll</HintPath>
49+
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\lib\net45\Dia2Lib.dll</HintPath>
5050
<EmbedInteropTypes>True</EmbedInteropTypes>
5151
</Reference>
5252
<Reference Include="Microsoft.Diagnostics.FastSerialization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
53-
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\lib\net45\Microsoft.Diagnostics.FastSerialization.dll</HintPath>
53+
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\lib\net45\Microsoft.Diagnostics.FastSerialization.dll</HintPath>
5454
</Reference>
55-
<Reference Include="Microsoft.Diagnostics.Tracing.TraceEvent, Version=2.0.77.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
56-
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\lib\net45\Microsoft.Diagnostics.Tracing.TraceEvent.dll</HintPath>
55+
<Reference Include="Microsoft.Diagnostics.Tracing.TraceEvent, Version=2.0.74.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
56+
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\lib\net45\Microsoft.Diagnostics.Tracing.TraceEvent.dll</HintPath>
5757
</Reference>
5858
<Reference Include="OSExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
59-
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\lib\net45\OSExtensions.dll</HintPath>
59+
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\lib\net45\OSExtensions.dll</HintPath>
6060
</Reference>
6161
<Reference Include="System" />
6262
<Reference Include="System.Configuration" />
@@ -74,7 +74,7 @@
7474
<Reference Include="System.Windows.Forms" />
7575
<Reference Include="System.Xml" />
7676
<Reference Include="TraceReloggerLib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
77-
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\lib\net45\TraceReloggerLib.dll</HintPath>
77+
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\lib\net45\TraceReloggerLib.dll</HintPath>
7878
<EmbedInteropTypes>True</EmbedInteropTypes>
7979
</Reference>
8080
</ItemGroup>
@@ -178,6 +178,6 @@ editbin.exe /NXCOMPAT:NO "$(TargetPath)"</PostBuildEvent>
178178
<PropertyGroup>
179179
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
180180
</PropertyGroup>
181-
<Error Condition="!Exists('..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\build\Microsoft.Diagnostics.Tracing.TraceEvent.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.77\build\Microsoft.Diagnostics.Tracing.TraceEvent.props'))" />
181+
<Error Condition="!Exists('..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\build\Microsoft.Diagnostics.Tracing.TraceEvent.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.74\build\Microsoft.Diagnostics.Tracing.TraceEvent.props'))" />
182182
</Target>
183183
</Project>

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private async Task ImportActiveXAsync(ErrorDelegate errorDelegate) {
393393
fullPath = Path.GetFullPath(TemplateName);
394394
} catch (Exception ex) {
395395
LogExceptionToLauncher(ex);
396-
errorDelegate(String.Format(Properties.Resources.GameIsMissingFile, TemplateName));
396+
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, TemplateName));
397397
throw new ActiveXImportFailedException("The ActiveX Import failed because getting the Full Path failed.");
398398
}
399399

@@ -415,7 +415,7 @@ private async Task ImportActiveXAsync(ErrorDelegate errorDelegate) {
415415
throw new ActiveXImportFailedException("The ActiveX Import failed because the DLL is not an ActiveX Control.");
416416
} catch (Exception ex) {
417417
LogExceptionToLauncher(ex);
418-
errorDelegate(String.Format(Properties.Resources.GameIsMissingFile, fullPath));
418+
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, fullPath));
419419
throw new ActiveXImportFailedException("The ActiveX Import failed because the DLL was not found.");
420420
}
421421

@@ -490,10 +490,18 @@ private async Task ImportActiveXAsync(ErrorDelegate errorDelegate) {
490490
LogExceptionToLauncher(ex);
491491
errorDelegate(Properties.Resources.GameNotCuratedCorrectly);
492492
throw new ActiveXImportFailedException("The ActiveX Import failed because the Modification is invalid.");
493+
} catch (InvalidTemplateException ex) {
494+
LogExceptionToLauncher(ex);
495+
errorDelegate(Properties.Resources.CurationMissingTemplateName);
496+
throw;
493497
} catch (InvalidOperationException ex) {
494498
LogExceptionToLauncher(ex);
495499
errorDelegate(Properties.Resources.RegistryStateAlreadyInProgress);
496500
throw new ActiveXImportFailedException("The ActiveX Import failed because a Registry State is already in progress.");
501+
} catch (ArgumentException ex) {
502+
LogExceptionToLauncher(ex);
503+
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, TemplateName));
504+
throw new ActiveXImportFailedException("The ActiveX Import failed because getting the Full Path failed.");
497505
}
498506

499507
ProgressManager.CurrentGoal.Steps++;
@@ -928,7 +936,7 @@ private async Task ActivateModificationsAsync(TemplateElement templateElement, E
928936
await downloadsBefore.ActivateAsync(TemplateName, DownloadsBeforeModificationNames).ConfigureAwait(true);
929937
} catch (DownloadFailedException ex) {
930938
LogExceptionToLauncher(ex);
931-
errorDelegate(String.Format(Properties.Resources.GameIsMissingFile, String.Join(", ", DownloadsBeforeModificationNames)));
939+
errorDelegate(String.Format(Properties.Resources.GameIsMissingFiles, String.Join(", ", DownloadsBeforeModificationNames)));
932940
} catch (ConfigurationErrorsException ex) {
933941
LogExceptionToLauncher(ex);
934942
errorDelegate(Properties.Resources.ConfigurationUnableToLoad);
@@ -1360,8 +1368,10 @@ await ImportActiveXAsync(delegate (string text) {
13601368

13611369
throw new ActiveXImportFailedException("An error occured while activating the ActiveX Import.");
13621370
});
1363-
} catch (InvalidModificationException ex) {
1371+
} catch (InvalidTemplateException ex) {
13641372
LogExceptionToLauncher(ex);
1373+
// no need to exit here, error shown in interface
1374+
//Application.Exit();
13651375
} catch (ActiveXImportFailedException ex) {
13661376
LogExceptionToLauncher(ex);
13671377
// no need to exit here, error shown in interface

FlashpointSecurePlayer/Properties/Resources.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlashpointSecurePlayer/Properties/Resources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ Please ensure Flashpoint is not corrupted, was extracted correctly, and is not r
158158
<data name="GameDownloading" xml:space="preserve">
159159
<value>The game is downloading.</value>
160160
</data>
161-
<data name="GameIsMissingFile" xml:space="preserve">
162-
<value>The game file "{0}" is missing.
161+
<data name="GameIsMissingFiles" xml:space="preserve">
162+
<value>The game files "{0}" are missing.
163163
Please ensure Flashpoint is not corrupted, was extracted correctly, and is not running from OneDrive or a network drive.</value>
164164
</data>
165165
<data name="GameNotActiveXControl" xml:space="preserve">

FlashpointSecurePlayer/RegistryStates.cs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Configuration;
45
using System.Diagnostics;
56
using System.IO;
@@ -792,6 +793,7 @@ public async Task StartImportAsync(string templateName, BINARY_TYPE binaryType)
792793

793794
try {
794795
modificationsElement.RegistryStates.BinaryType = binaryType;
796+
795797
pathNames = new PathNames();
796798

797799
resumeEventWaitHandle.Reset();
@@ -800,33 +802,39 @@ public async Task StartImportAsync(string templateName, BINARY_TYPE binaryType)
800802
kcbModificationKeyNames = new Dictionary<ulong, string>();
801803

802804
kernelSession = new TraceEventSession(KernelTraceEventParser.KernelSessionName);
803-
kernelSession.EnableKernelProvider(KernelTraceEventParser.Keywords.Registry);
804805

805-
kernelSession.Source.Kernel.RegistryQueryValue += GotValue;
806+
try {
807+
try {
808+
kernelSession.EnableKernelProvider(KernelTraceEventParser.Keywords.Registry);
809+
} catch (Win32Exception ex) {
810+
LogExceptionToLauncher(ex);
811+
throw new InvalidRegistryStateException("The Kernel Trace Control could not be found.");
812+
}
806813

807-
kernelSession.Source.Kernel.RegistryCreate += ModificationAdded;
808-
kernelSession.Source.Kernel.RegistrySetValue += ModificationAdded;
809-
kernelSession.Source.Kernel.RegistrySetInformation += ModificationAdded;
814+
kernelSession.Source.Kernel.RegistryQueryValue += GotValue;
810815

811-
kernelSession.Source.Kernel.RegistryDelete += ModificationRemoved;
812-
kernelSession.Source.Kernel.RegistryDeleteValue += ModificationRemoved;
816+
kernelSession.Source.Kernel.RegistryCreate += ModificationAdded;
817+
kernelSession.Source.Kernel.RegistrySetValue += ModificationAdded;
818+
kernelSession.Source.Kernel.RegistrySetInformation += ModificationAdded;
813819

814-
//kernelSession.Source.Kernel.RegistryFlush += RegistryModified;
820+
kernelSession.Source.Kernel.RegistryDelete += ModificationRemoved;
821+
kernelSession.Source.Kernel.RegistryDeleteValue += ModificationRemoved;
815822

816-
// http://social.msdn.microsoft.com/Forums/en-US/ff07fc25-31e3-4b6f-810e-7a1ee458084b/etw-registry-monitoring?forum=etw
817-
kernelSession.Source.Kernel.RegistryKCBCreate += KCBStarted;
818-
kernelSession.Source.Kernel.RegistryKCBRundownBegin += KCBStarted;
823+
//kernelSession.Source.Kernel.RegistryFlush += RegistryModified;
819824

820-
kernelSession.Source.Kernel.RegistryKCBDelete += KCBStopped;
821-
kernelSession.Source.Kernel.RegistryKCBRundownEnd += KCBStopped;
825+
// http://social.msdn.microsoft.com/Forums/en-US/ff07fc25-31e3-4b6f-810e-7a1ee458084b/etw-registry-monitoring?forum=etw
826+
kernelSession.Source.Kernel.RegistryKCBCreate += KCBStarted;
827+
kernelSession.Source.Kernel.RegistryKCBRundownBegin += KCBStarted;
822828

823-
Thread processThread = new Thread(delegate () {
824-
kernelSession.Source.Process();
825-
});
829+
kernelSession.Source.Kernel.RegistryKCBDelete += KCBStopped;
830+
kernelSession.Source.Kernel.RegistryKCBRundownEnd += KCBStopped;
826831

827-
processThread.Start();
832+
Thread processThread = new Thread(delegate () {
833+
kernelSession.Source.Process();
834+
});
835+
836+
processThread.Start();
828837

829-
try {
830838
// ensure the kernel session is actually processing
831839
for (int i = 0; i < IMPORT_TIMEOUT; i++) {
832840
// we just ping this value so it gets detected we tried to read it
@@ -846,13 +854,11 @@ public async Task StartImportAsync(string templateName, BINARY_TYPE binaryType)
846854
if (ImportPaused) {
847855
throw new InvalidRegistryStateException("A timeout occured while starting the Import.");
848856
}
849-
} catch {
857+
} finally {
850858
kernelSession.Dispose();
851859
kernelSession = null;
852-
pathNames = null;
853-
ImportStarted = false;
854860
}
855-
} catch {
861+
} finally {
856862
pathNames = null;
857863
ImportStarted = false;
858864
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Diagnostics.Tracing.TraceEvent" version="2.0.77" targetFramework="net45" />
3+
<package id="Microsoft.Diagnostics.Tracing.TraceEvent" version="2.0.74" targetFramework="net45" />
44
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net45" />
55
</packages>

0 commit comments

Comments
 (0)