Implemented WMVCore mod; TODO fix UnauthorizedAccessException

This commit is contained in:
Joshua Askharoun
2021-04-26 05:09:48 -05:00
parent 7161797d74
commit ff14cee068
6 changed files with 42 additions and 15 deletions
-6
View File
@@ -47,11 +47,5 @@ namespace ZuneModCore
} }
public abstract IReadOnlyList<Type>? DependentMods { get; } public abstract IReadOnlyList<Type>? DependentMods { get; }
internal FileStream OpenFileInStorageDirectory(string filename)
{
FileInfo info = new(Path.Combine(StorageDirectory, filename));
return File.Create(info.FullName);
}
} }
} }
+18 -5
View File
@@ -8,6 +8,8 @@ namespace ZuneModCore.Mods
{ {
public class VideoSyncMod : Mod public class VideoSyncMod : Mod
{ {
private const string WMVCORE_PATH = @"C:\Windows\System32\WMVCORE.dll";
public override string Title => "Fix Video Sync"; public override string Title => "Fix Video Sync";
public override string Description => public override string Description =>
@@ -19,16 +21,27 @@ namespace ZuneModCore.Mods
public override Task<string?> Apply() public override Task<string?> Apply()
{ {
var writer = new StreamWriter(OpenFileInStorageDirectory("1.log")); try
writer.WriteLine("Hello world"); {
writer.Flush(); // Make a backup of the file
writer.Close(); File.Copy(WMVCORE_PATH, Path.Combine(StorageDirectory, "WMVCORE.original.dll"), true);
return Task.FromResult<string?>(null); // Copy the pre-Anniversary Update WMVCORE.dll
File.Copy("Resources\\WMVCORE.dll", WMVCORE_PATH, true);
return Task.FromResult<string?>(null);
}
catch (Exception ex)
{
return Task.FromResult(ex.Message)!;
}
} }
public override Task<string?> Reset() public override Task<string?> Reset()
{ {
// Copy backup to application folder
File.Copy(Path.Combine(StorageDirectory, "WMVCORE.original.dll"), WMVCORE_PATH, true);
return Task.FromResult<string?>(null); return Task.FromResult<string?>(null);
} }
+15 -1
View File
@@ -92,7 +92,21 @@ namespace ZuneModCore.Mods
public override Task<string?> Reset() public override Task<string?> Reset()
{ {
throw new NotImplementedException(); // Copy backup to application folder
File.Copy(Path.Combine(StorageDirectory, "ZuneService.original.dll"), Path.Combine(ZuneInstallDir, "ZuneService.dll"), true);
// Disable all feature overrides affected by new servers
SetFeatureOverride("Apps", false);
SetFeatureOverride("Channels", false);
SetFeatureOverride("Games", false);
SetFeatureOverride("Marketplace", false);
SetFeatureOverride("Music", false);
SetFeatureOverride("MusicVideos", false);
SetFeatureOverride("Podcasts", false);
SetFeatureOverride("Social", false);
SetFeatureOverride("Videos", false);
return Task.FromResult<string?>(null);
} }
} }
} }
Binary file not shown.
+6
View File
@@ -11,4 +11,10 @@
<PackageReference Include="OwlCore" Version="0.0.1" /> <PackageReference Include="OwlCore" Version="0.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="Resources\WMVCORE.DLL">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>
+3 -3
View File
@@ -59,10 +59,10 @@
<Border x:Name="ProgressBorder" Padding="8" Margin="8" Background="White" Visibility="Collapsed" Grid.RowSpan="2"> <Border x:Name="ProgressBorder" Padding="8" Margin="8" Background="White" Visibility="Collapsed" Grid.RowSpan="2">
<Grid> <Grid>
<StackPanel Margin="8" VerticalAlignment="Center" HorizontalAlignment="Center"> <StackPanel Margin="50,8,50,8" VerticalAlignment="Center" HorizontalAlignment="Stretch">
<TextBlock x:Name="ProgressDesc" Text="Preparing..." FontSize="14" FontWeight="SemiBold" <TextBlock x:Name="ProgressDesc" Text="Preparing..." FontSize="14" FontWeight="SemiBold"
HorizontalAlignment="Center" TextAlignment="Center"/> HorizontalAlignment="Stretch" TextAlignment="Center"/>
<mah:MetroProgressBar x:Name="Progress" Value="0" MinWidth="200"/> <mah:MetroProgressBar x:Name="Progress" Value="0" HorizontalAlignment="Stretch"/>
</StackPanel> </StackPanel>
<Button x:Name="ProgressCloseButton" Content="Close" Visibility="Collapsed" Click="ProgressCloseButton_Click" <Button x:Name="ProgressCloseButton" Content="Close" Visibility="Collapsed" Click="ProgressCloseButton_Click"