diff --git a/NetEaseMusic-DiscordRPC.sln b/NetEaseMusic-DiscordRPC.sln
index 6249cac..0d6d2ff 100644
--- a/NetEaseMusic-DiscordRPC.sln
+++ b/NetEaseMusic-DiscordRPC.sln
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetEaseMusic-DiscordRPC", "NetEaseMusic-DiscordRPC\NetEaseMusic-DiscordRPC.csproj", "{8A5639C6-8083-4623-9234-D87878036C4E}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanessa", "Vanessa\Vanessa.csproj", "{5B2859C2-BCDE-46C2-A113-13E48AB0A7B0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordRPC", "submodule\discord-rpc-csharp\DiscordRPC\DiscordRPC.csproj", "{D3E3FE4A-F603-493B-8AE0-A402A91C914F}"
@@ -15,10 +13,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8A5639C6-8083-4623-9234-D87878036C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8A5639C6-8083-4623-9234-D87878036C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8A5639C6-8083-4623-9234-D87878036C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8A5639C6-8083-4623-9234-D87878036C4E}.Release|Any CPU.Build.0 = Release|Any CPU
{5B2859C2-BCDE-46C2-A113-13E48AB0A7B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B2859C2-BCDE-46C2-A113-13E48AB0A7B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B2859C2-BCDE-46C2-A113-13E48AB0A7B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/NetEaseMusic-DiscordRPC/App.config b/NetEaseMusic-DiscordRPC/App.config
deleted file mode 100644
index c600cd7..0000000
--- a/NetEaseMusic-DiscordRPC/App.config
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/NetEaseMusic-DiscordRPC/AutoStart.cs b/NetEaseMusic-DiscordRPC/AutoStart.cs
deleted file mode 100644
index 6310fa8..0000000
--- a/NetEaseMusic-DiscordRPC/AutoStart.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System;
-using System.Reflection;
-using Microsoft.Win32;
-
-namespace NetEaseMusic_DiscordRPC
-{
- static class AutoStart
- {
- public static void Set()
- {
- try
- {
- // Open Base Key.
- using var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64).OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
-
- if (baseKey == null)
- {
- // wtf?
- Console.WriteLine(@"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Run");
- return;
- }
-
- baseKey.SetValue("NCM-DiscordRpc", Assembly.GetEntryAssembly().Location);
- Console.WriteLine("AutoStartup has been set.");
- }
- catch (Exception e)
- {
- Console.WriteLine($"Failed to set autostartup: {e.Message}");
- }
- }
-
- public static void Remove()
- {
- try
- {
- // Open Base Key.
- using var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64).OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
-
- if (baseKey == null)
- {
- // wtf?
- Console.WriteLine(@"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Run");
- return;
- }
-
- baseKey.DeleteValue("NCM-DiscordRpc", false);
- Console.WriteLine("AutoStartup has been deleted.");
- }
- catch (Exception e)
- {
- Console.WriteLine($"Failed to set autostartup: {e.Message}");
- }
- }
-
- public static bool Check()
- {
- try
- {
- // Open Base Key.
- using var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64).OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
-
- if (baseKey == null)
- {
- // wtf?
- Console.WriteLine(@"Cannot find HKCU\Software\Microsoft\Windows\CurrentVersion\Run");
- return false;
- }
-
- var ace = baseKey.GetValue("NCM-DiscordRpc");
- var exe = Assembly.GetEntryAssembly().Location;
- return exe.Equals(ace);
- }
- catch (Exception e)
- {
- Console.WriteLine($"Failed to set autostartup: {e.Message}");
- }
-
- return false;
- }
- }
-}
diff --git a/NetEaseMusic-DiscordRPC/MemoryUtil.cs b/NetEaseMusic-DiscordRPC/MemoryUtil.cs
deleted file mode 100644
index 066e1f6..0000000
--- a/NetEaseMusic-DiscordRPC/MemoryUtil.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-
-namespace NetEaseMusic_DiscordRPC
-{
- static class MemoryUtil
- {
- private static int ProcessId;
- private static IntPtr EntryPoint;
- private static IntPtr BaseAddress;
- private static string Version;
-
- public static List Offsets;
-
- public static void LoadNetEaseMemory(int pid, ref double rate, ref double lens, ref string title, ref string album, ref string artists, ref string cover, ref string url, out bool extra)
- {
- extra = false;
-
- if (ProcessId != pid)
- {
- EntryPoint = OpenProcess(0x10, IntPtr.Zero, pid);
- BaseAddress = IntPtr.Zero;
-
- using var process = Process.GetProcessById(pid);
-
- foreach (ProcessModule module in process.Modules)
- {
- if ("cloudmusic.dll".Equals(module.ModuleName))
- {
- BaseAddress = module.BaseAddress;
- break;
- }
- }
-
- Version = process.MainModule?.FileVersionInfo.ProductVersion;
- }
-
- if (EntryPoint == IntPtr.Zero || BaseAddress == IntPtr.Zero || string.IsNullOrEmpty(Version))
- {
- return;
- }
-
- ProcessId = pid;
-
- var offset = Offsets.FirstOrDefault(x => x.Version == Version);
- if (offset == null)
- {
- return;
- }
-
- // create buffer
- var buffer = new byte[64];
-
- if (!ReadProcessMemory(EntryPoint, BaseAddress + offset.Offsets.Schedule, buffer, sizeof(double), IntPtr.Zero))
- {
- Debug.Print($"Failed to load memory at 0x{(BaseAddress + offset.Offsets.Schedule).ToString("X")}");
- return;
- }
- var current = BitConverter.ToDouble(buffer, 0);
-
- if (!ReadProcessMemory(EntryPoint, BaseAddress + offset.Offsets.Length, buffer, sizeof(double), IntPtr.Zero))
- {
- Debug.Print($"Failed to load memory at 0x{(BaseAddress + offset.Offsets.Length).ToString("X")}");
- return;
- }
- var length = BitConverter.ToDouble(buffer, 0);
-
- rate = current;
- lens = length;
-
- if (offset.Offsets.CachePointer > 0)
- {
- try
- {
- // offset +8 (28 8f 0b050043 04 88)
- // 28 8f 0b050043 04 88 31 00 39 00 39 00 38 00 36 00 39 00 36 00 34 00 34 00 33 00 5f 00 31 00 5f 00 38 00 34 00 33 00 35 00360039 00 36 00 31 00 37 00 33 00 00
- // op code
- // cloudmusic.dll+709868:
- // 7A1A985A - 0F82 68030000 - jb cloudmusic.dll + 709BC8
- // 7A1A9860 - 0FBA 25 284F547A 01 - bt[cloudmusic.dll + AA4F28],01
- // 7A1A9868 - 73 07 - jae cloudmusic.dll + 709871 <<
- // 7A1A986A - F3 A4 - repe movsb
- // 7A1A986C - E9 17030000 - jmp cloudmusic.dll + 709B88
- if (!ReadProcessMemory(EntryPoint, BaseAddress + offset.Offsets.CachePointer, buffer, sizeof(uint), IntPtr.Zero))
- {
- Debug.Print("Error read cache array pointer for %LocalAppData%/NetEase/CloudMusic/webdata/file");
- return;
- }
-
- var add = BitConverter.ToUInt32(buffer, 0);
- var ptr = new IntPtr(add);
- if (!ReadProcessMemory(EntryPoint, ptr, buffer, int.MaxValue.ToString().Length * 2, IntPtr.Zero))
- {
- Debug.Print("Error read pointer for %LocalAppData%/NetEase/CloudMusic/webdata/file");
- return;
- }
-
- /* {tid}_{fid}_{data} */
- var id = Encoding.Unicode.GetString(buffer).Trim().Split('_')[0];
-
- var sound = NetEaseCacheManager.GetSoundInfo(int.Parse(id));
- if (sound == null)
- {
- Debug.Print($"Sound {id} not found in cache");
- return;
- }
-
- title = sound.Track.Name;
- album = sound.Track.Album.Name;
- artists = string.Join(", ", sound.Track.Artists.Select(x => x.Name));
- cover = sound.Track.Album.Cover;
- lens = sound.Track.Duration * 0.001;
- url = $"https://music.163.com/song?id={sound.Id}";
- extra = true;
- }
- catch (Exception e)
- {
- Debug.Print(e.ToString());
- }
- }
- }
-
- [DllImport("kernel32", SetLastError = true)]
- static extern IntPtr OpenProcess(int dwDesiredAccess, IntPtr bInheritHandle, int dwProcessId);
-
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool ReadProcessMemory(IntPtr pHandle, IntPtr Address, byte[] Buffer, int Size, IntPtr NumberofBytesRead);
-
- }
-}
diff --git a/NetEaseMusic-DiscordRPC/NCM-DiscordRpc.nrproj b/NetEaseMusic-DiscordRPC/NCM-DiscordRpc.nrproj
deleted file mode 100644
index 3cecf2a..0000000
Binary files a/NetEaseMusic-DiscordRPC/NCM-DiscordRpc.nrproj and /dev/null differ
diff --git a/NetEaseMusic-DiscordRPC/NetEaseMusic-DiscordRPC.csproj b/NetEaseMusic-DiscordRPC/NetEaseMusic-DiscordRPC.csproj
deleted file mode 100644
index e3f63e3..0000000
--- a/NetEaseMusic-DiscordRPC/NetEaseMusic-DiscordRPC.csproj
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {8A5639C6-8083-4623-9234-D87878036C4E}
- WinExe
- NetEaseMusic_DiscordRPC
- NCM-DiscordRpc
- v4.8
- 512
- true
- false
-
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- true
-
-
- x86
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
- 8.0
-
-
- x86
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- Off
- 8.0
-
-
- Resources\icon.ico
-
-
- NetEaseMusic_DiscordRPC.Program
-
-
-
- ..\packages\DiscordRichPresence.1.1.3.18\lib\net45\DiscordRPC.dll
-
-
- ..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
- True
- True
- Settings.settings
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
- False
- Microsoft .NET Framework 4.7.1 %28x86 和 x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
- Always
-
-
-
-
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/Program.cs b/NetEaseMusic-DiscordRPC/Program.cs
deleted file mode 100644
index 25ba189..0000000
--- a/NetEaseMusic-DiscordRPC/Program.cs
+++ /dev/null
@@ -1,370 +0,0 @@
-using DiscordRPC;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using Button = DiscordRPC.Button;
-
-namespace NetEaseMusic_DiscordRPC
-{
- internal static class Program
- {
- private const string NeteaseAppId = "481562643958595594";
- private const string TencentAppId = "903485504899665990";
-
- private static async Task Main()
- {
- // check run once
- _ = new Mutex(true, "NetEase Cloud Music DiscordRPC", out var allow);
- if (!allow)
- {
- MessageBox.Show("NetEase Cloud Music DiscordRPC is already running.", "Error", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- Environment.Exit(-1);
- }
-
- // Auto Startup
- if (Properties.Settings.Default.IsFirstTime)
- {
- AutoStart.Set();
- Properties.Settings.Default.IsFirstTime = false;
- Properties.Settings.Default.Save();
- }
-
- await GetOffsetsAsync();
-
- var neteaseRpc = new DiscordRpcClient(NeteaseAppId);
- var tencentRpc = new DiscordRpcClient(TencentAppId);
- neteaseRpc.Initialize();
- tencentRpc.Initialize();
-
- if (!neteaseRpc.IsInitialized || !tencentRpc.IsInitialized)
- {
- MessageBox.Show("Failed to init rpc client.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- Environment.Exit(-1);
- }
-
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
-
- var notifyMenu = new ContextMenu();
- var exitButton = new MenuItem("Exit");
- var autoButton = new MenuItem("AutoStart" + " " + (AutoStart.Check() ? "√" : "✘"));
- notifyMenu.MenuItems.Add(0, autoButton);
- notifyMenu.MenuItems.Add(1, exitButton);
-
- var notifyIcon = new NotifyIcon()
- {
- BalloonTipIcon = ToolTipIcon.Info,
- ContextMenu = notifyMenu,
- Text = "NetEase Cloud Music DiscordRPC",
- Icon = Properties.Resources.icon,
- Visible = true,
- };
-
- exitButton.Click += (sender, args) =>
- {
- notifyIcon.Visible = false;
- Thread.Sleep(100);
- Environment.Exit(0);
- };
- autoButton.Click += (sender, args) =>
- {
- var x = AutoStart.Check();
- if (x)
- {
- AutoStart.Remove();
- }
- else
- {
- AutoStart.Set();
- }
-
- autoButton.Text = "AutoStart" + " " + (AutoStart.Check() ? "√" : "✘");
- };
-
- _ = Task.Run(async () => await UpdateThread(neteaseRpc, tencentRpc));
- Application.Run();
- }
-
- private static async Task UpdateThread(DiscordRpcClient neteaseRpc, DiscordRpcClient tencentRpc)
- {
- var playerState = false;
- var currentSong = string.Empty;
- var currentSing = string.Empty;
- var currentHash = string.Empty;
- var currentImgX = string.Empty;
- var currentKeyX = string.Empty;
- var currentCurl = string.Empty;
- var currentRate = 0.0;
- var maxSongLens = 0.0;
- var lastPlaying = -1;
-
- while (true)
- {
- try
- {
- var lastRate = currentRate;
- var lastLens = maxSongLens;
- var skipThis = false;
-
- if (!Win32Api.User32.GetWindowTitle("OrpheusBrowserHost", out var title, out var pid) &&
- !Win32Api.User32.GetWindowTitle("QQMusic_Daemon_Wnd", out title))
- {
- Debug.Print($"player is not running");
- playerState = false;
- goto update;
- }
-
- // NetEase
- if (pid > 0)
- {
- // load memory
- var artists = string.Empty;
- var album = string.Empty;
- var cover = string.Empty;
- var url = string.Empty;
- MemoryUtil.LoadNetEaseMemory(pid, ref currentRate, ref maxSongLens, ref title, ref album, ref artists,
- ref cover, ref url, out var extra);
-
- var diffRate = currentRate - lastRate;
-
- if (currentRate == 0.0 && maxSongLens == 0.0)
- {
- Debug.Print($"invalid? {currentRate} | {lastRate} | {diffRate}");
- playerState = false;
- }
- // magic hacks? //currentRate != 0.109 &&
- else if ((currentRate > 0.109 || currentRate == 0) && diffRate < 0.001 && diffRate >= 0 &&
- maxSongLens == lastLens) //currentRate.Equals(lastRate)
- {
- Debug.Print(
- $"Music pause? {currentRate} | {lastRate} | {maxSongLens} | {lastLens} | {diffRate}");
- playerState = false;
- }
- else if (!playerState || !maxSongLens.Equals(lastLens))
- {
- if (extra)
- {
- // force refresh if cache loaded
- var hash = $"{title}-{artists}-{cover}";
- if (hash != currentHash)
- {
- skipThis = false;
- }
-
- currentHash = hash;
-
- currentSong = title;
- currentSing = artists;
-
- currentImgX = cover;
- currentKeyX = album;
- currentCurl = url;
- }
- else
- {
- var match = title.Replace("\r", "").Replace("\n", "").Replace(" - ", "\t").Split('\t');
- if (match.Length > 1)
- {
- currentSong = match[0];
- currentSing = match[1]; // like spotify
- }
- else
- {
- currentSong = title;
- currentSing = string.Empty;
- }
-
- currentImgX = "timg";
- currentKeyX = "Netease Cloud Music";
- currentCurl = "https://music.163.com/#/search/m/?s=" + currentSong;
- }
-
- playerState = true;
- }
- // check
- else if (Math.Abs(diffRate) < 1.0 && neteaseRpc.CurrentPresence != null)
- {
- // skip playing
- Debug.Print($"Skip Rpc {currentRate} | {lastRate} | {Math.Abs(diffRate)}");
- skipThis = true;
- }
- }
- // Tencent
- else if (pid == 0)
- {
- // mark as playing and always update
- playerState = true;
- skipThis = false;
-
- // TODO
- // soundId = QQMusic.dll+B661C8
- // soundLen = QQMusic.dll+B661DC
- // soundInfo = ptr + 0x19B09528
- // https://y.qq.com/n/ryqq/songDetail/
-
- var match = title.Replace(" - ", "\t").Split('\t');
- if (match.Length > 1)
- {
- currentSong = match[0];
- currentSing = match[1]; // like spotify
- }
- else
- {
- currentSong = title;
- currentSing = string.Empty;
- }
- }
-
- Debug.Print($"playerState -> {playerState} | Equals {maxSongLens} | {lastLens}");
-
- if (lastPlaying != pid)
- {
- // player changed
- skipThis = false;
- }
-
- lastPlaying = pid;
-
- update:
- // update
-#if DEBUG
- if (!playerState)
-#else
- if (Win32Api.User32.IsFullscreenAppRunning() || Win32Api.User32.IsWhitelistAppRunning() ||
- !playerState)
-#endif
- {
- Debug.Print(
- $"Try clear Rpc {Win32Api.User32.IsFullscreenAppRunning()} | {Win32Api.User32.IsWhitelistAppRunning()}");
- if (neteaseRpc.CurrentPresence != null)
- {
- neteaseRpc.ClearPresence();
- Debug.Print("Clear netease rpc");
- }
-
- if (tencentRpc.CurrentPresence != null)
- {
- tencentRpc.ClearPresence();
- Debug.Print("Clear tencent rpc");
- }
-
- continue;
- }
-
- if (skipThis)
- // skip
- {
- continue;
- }
-
- if (pid > 0)
- {
- tencentRpc.ClearPresence();
- neteaseRpc.SetPresence(new RichPresence
- {
- Details = $"🎵 {currentSong}",
- State = $"🎤 {currentSing}",
-
- Timestamps = new Timestamps(
- DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(currentRate)),
- DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(currentRate))
- .Add(TimeSpan.FromSeconds(maxSongLens))),
-
- Assets = new Assets
- {
- LargeImageKey = currentImgX,
- LargeImageText = currentKeyX,
- SmallImageKey = "timg",
- SmallImageText = "Netease Cloud Music",
- },
-
- Buttons = new[]
- {
- new Button
- {
- Label = "🎧 Listen",
- Url = currentCurl,
- // Url = "https://music.163.com/"
- },
- },
- });
- }
- else if (pid == 0)
- {
- neteaseRpc.ClearPresence();
- tencentRpc.SetPresence(new RichPresence
- {
- Details = $"🎵 {currentSong}",
- State = $"🎤 {currentSing}",
-
- Assets = new Assets
- {
- LargeImageKey = "qimg",
- LargeImageText = "QQMusic",
- },
- });
- }
-
- Debug.Print("Update Rpc");
- }
- catch (Exception e)
- {
- Console.WriteLine($"Exception while listening: {e}");
- }
- finally
- {
- // 用户就喜欢超低内存占用
- // 但是实际上来说并没有什么卵用
- GC.Collect();
- GC.WaitForFullGCComplete();
-
- await Task.Delay(TimeSpan.FromMilliseconds(200));
- }
- }
- }
-
- private static async Task GetOffsetsAsync()
- {
- retry:
- try
- {
- using var client = new HttpClient()
- {
- Timeout = TimeSpan.FromMinutes(1),
- };
-
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
-
- var response =
- await client.GetAsync(
- "https://github.com/Kxnrl/NetEase-Cloud-Music-DiscordRPC/raw/master/offset/offset.json");
-
- response.EnsureSuccessStatusCode();
-
- var json = await response.Content.ReadAsStringAsync();
-
- MemoryUtil.Offsets = JsonConvert.DeserializeObject>(json);
- }
- catch (Exception e)
- {
- var r = MessageBox.Show(e.Message, "Failed to get offsets", MessageBoxButtons.RetryCancel,
- MessageBoxIcon.Error);
- if (r == DialogResult.Retry)
- {
- goto retry;
- }
-
-#if !DEBUG
- Environment.Exit(-1);
-#endif
- }
- }
- }
-}
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/Properties/AssemblyInfo.cs b/NetEaseMusic-DiscordRPC/Properties/AssemblyInfo.cs
deleted file mode 100644
index 4313b37..0000000
--- a/NetEaseMusic-DiscordRPC/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("Netease Music DiscordRpc")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("©2023 Kyle")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("8a5639c6-8083-4623-9234-d87878036c4e")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
-// 方法是按如下所示使用“*”: :
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.3.0")]
-[assembly: AssemblyFileVersion("2.3.0")]
diff --git a/NetEaseMusic-DiscordRPC/Properties/Resources.Designer.cs b/NetEaseMusic-DiscordRPC/Properties/Resources.Designer.cs
deleted file mode 100644
index 10a9e20..0000000
--- a/NetEaseMusic-DiscordRPC/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本:4.0.30319.42000
-//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
-//
-//------------------------------------------------------------------------------
-
-namespace NetEaseMusic_DiscordRPC.Properties {
- using System;
-
-
- ///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// 返回此类使用的缓存的 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NetEaseMusic_DiscordRPC.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 重写当前线程的 CurrentUICulture 属性
- /// 重写当前线程的 CurrentUICulture 属性。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
- ///
- internal static System.Drawing.Icon icon {
- get {
- object obj = ResourceManager.GetObject("icon", resourceCulture);
- return ((System.Drawing.Icon)(obj));
- }
- }
- }
-}
diff --git a/NetEaseMusic-DiscordRPC/Properties/Resources.resx b/NetEaseMusic-DiscordRPC/Properties/Resources.resx
deleted file mode 100644
index 95ac60c..0000000
--- a/NetEaseMusic-DiscordRPC/Properties/Resources.resx
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- ..\Resources\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/Properties/Settings.Designer.cs b/NetEaseMusic-DiscordRPC/Properties/Settings.Designer.cs
deleted file mode 100644
index a37358c..0000000
--- a/NetEaseMusic-DiscordRPC/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本:4.0.30319.42000
-//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
-//
-//------------------------------------------------------------------------------
-
-namespace NetEaseMusic_DiscordRPC.Properties {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default {
- get {
- return defaultInstance;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("True")]
- public bool IsFirstTime {
- get {
- return ((bool)(this["IsFirstTime"]));
- }
- set {
- this["IsFirstTime"] = value;
- }
- }
- }
-}
diff --git a/NetEaseMusic-DiscordRPC/Properties/Settings.settings b/NetEaseMusic-DiscordRPC/Properties/Settings.settings
deleted file mode 100644
index c210a8a..0000000
--- a/NetEaseMusic-DiscordRPC/Properties/Settings.settings
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
- True
-
-
-
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/Resources/icon.ico b/NetEaseMusic-DiscordRPC/Resources/icon.ico
deleted file mode 100644
index 361964d..0000000
Binary files a/NetEaseMusic-DiscordRPC/Resources/icon.ico and /dev/null differ
diff --git a/NetEaseMusic-DiscordRPC/json.cs b/NetEaseMusic-DiscordRPC/json.cs
deleted file mode 100644
index 8471b6d..0000000
--- a/NetEaseMusic-DiscordRPC/json.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace NetEaseMusic_DiscordRPC
-{
- public class MemoryOffset
- {
- [JsonProperty("version")]
- public string Version { get; set; }
- [JsonProperty("offsets")]
- public Offset Offsets { get; set; }
- }
-
- public struct Offset
- {
- [JsonProperty("length")]
- public int Length { get; set; }
- [JsonProperty("schedule")]
- public int Schedule { get; set; }
- [JsonProperty("pointer")]
- public int CachePointer { get; set; }
- }
-
- public class NetEaseBaseModel
- {
- [JsonProperty("id")]
- public uint Id { get; set; }
- [JsonProperty("name")]
- public string Name { get; set; }
- }
-
- public class NetEaseTrackModel : NetEaseBaseModel
- {
- public class NetEaseTrackAlbumModel : NetEaseBaseModel
- {
- [JsonProperty("picUrl")]
- public string Cover { get; set; }
- }
-
- public class NetEaseTrackArtists : NetEaseBaseModel
- {
-
- }
-
- [JsonProperty("album")]
- public NetEaseTrackAlbumModel Album { get; set; }
-
- [JsonProperty("artists")]
- public List Artists { get; set; }
-
- ///
- /// Duration in milliseconds
- ///
- [JsonProperty("duration")]
- public uint Duration { get; set; }
- }
-
- public class NetEaseSoundModel
- {
- [JsonProperty("track")]
- public NetEaseTrackModel Track { get; set; }
-
- [JsonProperty("tid")]
- public uint Id { get; set; }
- }
-
- public static class NetEaseCacheManager
- {
- private static string[] Files = { "queue", "queue_backup", "history" };
-
- public static NetEaseSoundModel GetSoundInfo(int tid)
- {
- foreach (var f in Files)
- {
- var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NetEase", "CloudMusic", "webdata", "file", f);
- if (!File.Exists(path))
- {
- continue;
- }
- var data = File.ReadAllText(path, Encoding.UTF8);
- var json = JsonConvert.DeserializeObject(data);
- var find = json.SingleOrDefault(x => x.Id == tid);
- if (find != null)
- {
- return find;
- }
- }
-
- return null;
- }
- }
-}
diff --git a/NetEaseMusic-DiscordRPC/packages.config b/NetEaseMusic-DiscordRPC/packages.config
deleted file mode 100644
index 4843af4..0000000
--- a/NetEaseMusic-DiscordRPC/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/win32Api.cs b/NetEaseMusic-DiscordRPC/win32Api.cs
deleted file mode 100644
index 41e6a71..0000000
--- a/NetEaseMusic-DiscordRPC/win32Api.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Windows.Forms;
-
-namespace NetEaseMusic_DiscordRPC.Win32Api
-{
- public class User32
- {
- [StructLayout(LayoutKind.Sequential)]
- private struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
- }
-
- [DllImport("user32.dll")]
- private static extern IntPtr GetForegroundWindow();
-
- [DllImport("user32.dll")]
- private static extern IntPtr GetDesktopWindow();
-
- [DllImport("user32.dll")]
- private static extern IntPtr GetShellWindow();
-
- [DllImport("user32.dll", SetLastError = true)]
- private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
-
- [DllImport("user32.dll", EntryPoint = "FindWindow")]
- private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
-
- private delegate bool EnumWindowsProc(IntPtr hWnd, int lParam);
-
- [DllImport("user32.dll")]
- private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
-
- [DllImport("user32.dll")]
- private static extern void GetClassName(IntPtr hwnd, StringBuilder sb, int nMaxCount);
-
- [DllImport("user32.dll", CharSet = CharSet.Unicode)]
- private static extern int GetWindowText(IntPtr hWnd, StringBuilder strText, int maxCount);
-
- [DllImport("user32.dll", CharSet = CharSet.Unicode)]
- private static extern int GetWindowTextLength(IntPtr hWnd);
-
- [DllImport("user32.dll")]
- private static extern int GetWindowThreadProcessId(IntPtr handle, out int pid);
-
- private static string GetClassName(IntPtr hwnd)
- {
- var sb = new StringBuilder(256);
- GetClassName(hwnd, sb, 256);
- return sb.ToString();
- }
-
- private static string GetWindowTitle(IntPtr hwnd)
- {
- var length = GetWindowTextLength(hwnd);
- var sb = new StringBuilder(256);
- GetWindowText(hwnd, sb, length + 1);
- return sb.ToString();
- }
-
- public static bool IsFullscreenAppRunning()
- {
- var desktopHandle = GetDesktopWindow();
- var shellHandle = GetShellWindow();
- var window = GetForegroundWindow();
-
- if (window != IntPtr.Zero)
- {
- if (!(window.Equals(desktopHandle) || window.Equals(shellHandle)))
- {
- GetWindowRect(window, out var appBounds);
- System.Drawing.Rectangle screenBounds = Screen.FromHandle(window).Bounds;
- if ((appBounds.Bottom - appBounds.Top) == screenBounds.Height && (appBounds.Right - appBounds.Left) == screenBounds.Width)
- {
- // In full screen.
- return true;
- }
- }
- }
-
- return false;
- }
-
- private static string window_name = null;
- public static bool IsWhitelistAppRunning()
- {
- // VisualStudioAppManagement
- // VSCodeCrashServiceWindow
- // Valve001
- // UnrealWindow
- // Rainbow Six
-
- if (!File.Exists(Application.StartupPath + "\\windows.txt"))
- {
- // Config file doesn't exits...
- return false;
- }
-
- using var sr = new StreamReader(Application.StartupPath + "\\windows.txt", Encoding.UTF8);
-
- while ((window_name = sr.ReadLine()) != null)
- {
- // TrimString
- window_name = window_name.Trim();
-
- if (window_name.StartsWith("//") || window_name.Length < 3)
- {
- // ignore comments or spacer
- continue;
- }
-
- if (window_name.EndsWith(".exe"))
- {
- return Process.GetProcessesByName(window_name.Replace(".exe", "")).Length > 0;
- }
- else
- {
- var window = FindWindow(window_name, null);
- if (window != IntPtr.Zero)
- {
- Debug.WriteLine($"FindWindow {window_name}");
- return true;
- }
- }
- }
-
- return false;
- }
-
- public static bool GetWindowTitle(string match, out string text)
- {
- text = null;
-
- var handle = FindWindow(match, null);
-
- if (handle == IntPtr.Zero)
- return false;
-
- text = GetWindowTitle(handle);
-
- return true;
- }
-
- public static bool GetWindowTitle(string match, out string text, out int pid)
- {
- var title = string.Empty;
- var processId = 0;
-
- EnumWindows
- (
- delegate (IntPtr handle, int param)
- {
- var classname = GetClassName(handle);
-
- if (match.Equals(classname) && GetWindowThreadProcessId(handle, out var xpid) != 0 && xpid != 0)
- {
- title = GetWindowTitle(handle);
- processId = xpid;
- }
-
- return true;
- },
- IntPtr.Zero
- );
-
- text = title;
- pid = processId;
- return !string.IsNullOrEmpty(title) && pid > 0;
- }
- }
-}
\ No newline at end of file
diff --git a/NetEaseMusic-DiscordRPC/windows.txt b/NetEaseMusic-DiscordRPC/windows.txt
deleted file mode 100644
index c9aca06..0000000
--- a/NetEaseMusic-DiscordRPC/windows.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-// Visual Studio
-VisualStudioAppManagement
-devenv.exe
-
-// Visual Studio Code
-Code.exe
-
-// SourceEngine Game
-Valve001
-
-// UnrealEngine Game
-UnrealWindow
-
-// Unity3D Game
-UnityWndClass
-
-// Shit Game
-Rainbow Six
\ No newline at end of file
diff --git a/offset/offset.json b/offset/offset.json
deleted file mode 100644
index 9648537..0000000
--- a/offset/offset.json
+++ /dev/null
@@ -1,66 +0,0 @@
-[
- {
- "version": "2.7.1.198277",
- "offsets": { "length": 9345688, "schedule": 9210616 }
- },
- {
- "version": "2.9.5.199424",
- "offsets": { "length": 9958792, "schedule": 9789280 }
- },
- {
- "version": "2.9.6.199543",
- "offsets": { "length": 10541176, "schedule": 9846704 }
- },
- {
- "version": "2.9.7.199711",
- "offsets": { "length": 10591048, "schedule": 9895888 }
- },
- {
- "version": "2.9.8.199750",
- "offsets": { "length": 10989816, "schedule": 10269480 }
- },
- {
- "version": "2.9.8.199759",
- "offsets": { "length": 10989816, "schedule": 10269488 }
- },
- {
- "version": "2.9.9.199909",
- "offsets": { "length": 11076056, "schedule": 10355536 }
- },
- {
- "version": "2.9.10.200061",
- "offsets": { "length": 11092440, "schedule": 10371920 }
- },
- {
- "version": "2.10.2.200154",
- "offsets": { "length": 11583864, "schedule": 10843496 }
- },
- {
- "version": "2.10.3.200198",
- "offsets": { "length": 11443528, "schedule": 10720592 }
- },
- {
- "version": "2.10.5.200537",
- "offsets": { "length": 11500936, "schedule": 10777928 }
- },
- {
- "version": "2.10.7.200791",
- "offsets": { "length": 11689328, "schedule": 10962280 }
- },
- {
- "version": "2.10.8.200945",
- "offsets": { "length": 11689240, "schedule": 10962288 }
- },
- {
- "version": "2.10.10.201197",
- "offsets": { "length": 11708952, "schedule": 10978688 }
- },
- {
- "version": "2.10.10.201297",
- "offsets": { "length": 11713272, "schedule": 10982784 }
- },
- {
- "version": "2.10.11.201538",
- "offsets": { "length": 11717272, "schedule": 10986880, "pointer": 11713712 }
- }
-]