Add project files.

This commit is contained in:
Joshua Askharoun
2021-04-25 22:59:36 -05:00
parent b998a3a1f7
commit bd946f2700
50 changed files with 2166 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
using OwlCore.AbstractUI.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace ZuneModCore.Mods
{
public class FeaturesOverrideMod : Mod
{
private const string ZUNE_FEATURESOVERRIDE_REGKEY = RegEdit.ZUNE_REG_PATH + "FeaturesOverride";
public override string Id => nameof(FeaturesOverrideMod);
public override string Title => "Features Override";
public override string Description => "Re-enables access to some features disabled by Microsoft, such as the Social and Marketplace tabs.\r\n" +
"Does not restore functionality of those features, but shows them in the software.";
public override AbstractUIElementGroup OptionsUI => new(nameof(FeaturesOverrideMod))
{
Title = "Select features:",
Items =
{
// We don't know what some of these overrides do exactly, so hide them from the user.
// The ID is the name of the registry key, the label is the display name
new AbstractBooleanUIElement("Apps", "Apps"),
//new AbstractBooleanUIElement("Art", "Art"),
new AbstractBooleanUIElement("Channels", "Channels"),
//new AbstractBooleanUIElement("FirstLaunchIntroVideo", "First Launch Intro Video"),
new AbstractBooleanUIElement("Games", "Games"),
new AbstractBooleanUIElement("Marketplace", "Marketplace"),
//new AbstractBooleanUIElement("MBRPreview", "MBRPreview"),
//new AbstractBooleanUIElement("MBRPurchase", "MBRPurchase"),
//new AbstractBooleanUIElement("MBRRental", "MBRRental"),
new AbstractBooleanUIElement("Music", "Music"),
new AbstractBooleanUIElement("MusicVideos", "MusicVideos"),
new AbstractBooleanUIElement("Nowplaying", "Now Playing"),
//new AbstractBooleanUIElement("NowplayingArt", "Now Playing Art"),
new AbstractBooleanUIElement("Picks", "Picks"),
new AbstractBooleanUIElement("Podcasts", "Podcasts"),
new AbstractBooleanUIElement("QuickMixLocal", "Quick Mix (Local)"),
//new AbstractBooleanUIElement("QuickMixZMP", "Quick Mix (ZMP)"),
new AbstractBooleanUIElement("Quickplay", "Quickplay"),
//new AbstractBooleanUIElement("Sign In Available", "Sign In"),
new AbstractBooleanUIElement("Social", "Social"),
//new AbstractBooleanUIElement("SocialMarketplace", "Social Marketplace"),
//new AbstractBooleanUIElement("SubscriptionFreeTracks", "Subscription Free Tracks"),
new AbstractBooleanUIElement("Videos", "Videos"),
}
};
public override IReadOnlyList<Type>? DependentMods => null;
public override Task Init()
{
foreach (AbstractUIElement uiElem in OptionsUI.Items)
if (uiElem is AbstractBooleanUIElement boolElem)
boolElem.ChangeState(GetFeatureOverride(boolElem.Id));
return Task.CompletedTask;
}
public override Task<bool> Apply()
{
return Task.FromResult(true);
foreach (AbstractUIElement uiElem in OptionsUI.Items)
if (uiElem is AbstractBooleanUIElement boolElem && boolElem.State)
SetFeatureOverride(boolElem.Id, true);
return Task.FromResult(true);
}
public override Task<bool> Reset()
{
foreach (AbstractUIElement uiElem in OptionsUI.Items)
if (uiElem is AbstractBooleanUIElement boolElem)
ResetFeatureOverride(boolElem.Id);
return Task.FromResult(true);
}
public static void SetFeatureOverride(string feature, bool value) =>
RegEdit.CurrentUserSetBoolValue(ZUNE_FEATURESOVERRIDE_REGKEY, feature, value);
public static bool GetFeatureOverride(string feature) =>
RegEdit.CurrentUserGetBoolValue(ZUNE_FEATURESOVERRIDE_REGKEY, feature);
public static void ResetFeatureOverride(string feature) =>
RegEdit.CurrentUserDeleteValue(RegEdit.ZUNE_REG_PATH + "FeaturesOverride", feature);
}
}
+56
View File
@@ -0,0 +1,56 @@
using OwlCore.AbstractUI.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace ZuneModCore.Mods
{
public class VideoSyncMod : Mod
{
public VideoSyncMod()
{
testButton.Clicked += TestButton_Clicked;
}
private void TestButton_Clicked(object? sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Howdy, Zune! How are ya?");
}
public override string Title => "Fix Video Sync";
public override string Description =>
"Resolves \"Error C00D11CD\" when attempting to sync video to a Zune device using Windows 10 1607 (Anniversary Update) or newer";
public override string Id => nameof(VideoSyncMod);
public override AbstractUIElementGroup OptionsUI => new(nameof(VideoSyncMod))
{
Title = Title,
Items =
{
new AbstractBooleanUIElement("test", "Is this is test?"),
testButton
}
};
private readonly AbstractButton testButton = new(nameof(testButton), "Howdy Zune!", type: AbstractButtonType.Generic);
public override Task<bool> Apply()
{
var writer = File.CreateText(Path.Combine(StorageDirectory, "1.log"));
writer.WriteLine("Hello world");
writer.Flush();
writer.Close();
return Task.FromResult(true);
}
public override Task<bool> Reset()
{
return Task.FromResult(true);
}
public override IReadOnlyList<Type>? DependentMods => null;
}
}
+80
View File
@@ -0,0 +1,80 @@
using OwlCore.AbstractUI.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using static ZuneModCore.Mods.FeaturesOverrideMod;
#if DEBUG
using System.Diagnostics;
#endif
namespace ZuneModCore.Mods
{
public class WebservicesMod : Mod
{
private readonly byte[] ZUNE_4_8_VERSION_BYTES =
{
0x34, 0x2E, 0x38
};
private const int ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET = 0x14D60;
private const int ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH = 0x884;
public override string Id => nameof(WebservicesMod);
public override string Title => "Community Webservices";
public override string Description => "Partially restores online features such as the Marketplace by patching the Zune desktop software " +
"to use the community's recreation of Microsoft's Zune servers at zunes.tk (instead of zune.net).";
public override AbstractUIElementGroup? OptionsUI => null;
public override IReadOnlyList<Type>? DependentMods => null;
public override async Task<bool> Apply()
{
// Open ZuneServices.dll
FileInfo zsDllInfo = new(Path.Combine(ZuneInstallDir, "ZuneService.dll"));
if (!zsDllInfo.Exists)
return false;
using FileStream zsDll = zsDllInfo.Open(FileMode.Open);
using BinaryWriter zsDllWriter = new(zsDll);
using BinaryReader zsDllReader = new(zsDll);
// Verify that the DLL is from v4.8 (other versions not tested)
zsDllReader.BaseStream.Position = 0x12C824;
var versionBytes = zsDllReader.ReadBytes(ZUNE_4_8_VERSION_BYTES.Length * 2);
if (versionBytes[0] != '4' || versionBytes[2] != '.' || versionBytes[4] != '8')
return false;
// Patch ZuneServices.dll to use zunes.tk instead of zune.net
zsDllReader.BaseStream.Position = ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET;
string endpointBlock = System.Text.Encoding.Unicode.GetString(zsDllReader.ReadBytes(ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH));
endpointBlock = endpointBlock.Replace("zune.net", "zunes.tk");
byte[] endpointBytes = System.Text.Encoding.Unicode.GetBytes(endpointBlock);
if (endpointBytes.Length != ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH)
return false;
zsDllWriter.Seek(ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET, SeekOrigin.Begin);
zsDllWriter.Write(endpointBytes);
// Enable all feature overrides affected by new servers
SetFeatureOverride("Apps", true);
SetFeatureOverride("Channels", true);
SetFeatureOverride("Games", true);
SetFeatureOverride("Marketplace", true);
SetFeatureOverride("Music", true);
SetFeatureOverride("MusicVideos", true);
SetFeatureOverride("Podcasts", true);
SetFeatureOverride("Social", true);
SetFeatureOverride("Videos", true);
return true;
}
public override Task<bool> Reset()
{
throw new NotImplementedException();
}
}
}