Skip to content

Commit

Permalink
Fix VALORANT chat presence, add alert for missing perms
Browse files Browse the repository at this point in the history
  • Loading branch information
molenzwiebel committed Jun 2, 2024
1 parent 6300294 commit 2e2b6e1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Deceive/Deceive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>
<AssemblyVersion>1.13.0.0</AssemblyVersion>
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<ApplicationIcon>Resources\deceive.ico</ApplicationIcon>
<LangVersion>default</LangVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
11 changes: 6 additions & 5 deletions Deceive/ProxiedConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ private async Task OutgoingLoopAsync()
"<item jid='41c322a1-b328-495b-a004-5ccd3e45eae8@eu1.pvp.net' name='&#9;Deceive Active!' subscription='both' puuid='41c322a1-b328-495b-a004-5ccd3e45eae8'>" +
"<group priority='9999'>Deceive</group>" +
"<state>online</state>" +
"<id name='Deceive Active!' tagline='...'/>" +
"<id name='&#9;Deceive Active!' tagline='...'/>" +
"<lol name='&#9;Deceive Active!'/>" +
"<platforms><riot name='Deceive Active' tagline='...'/></platforms>" +
"<platforms><riot name='&#9;Deceive Active' tagline='...'/></platforms>" +
"</item>");
var contentBytes = Encoding.UTF8.GetBytes(content);
await Incoming.WriteAsync(contentBytes, 0, contentBytes.Length);
Expand Down Expand Up @@ -240,13 +240,14 @@ private async Task SendFakePlayerPresenceAsync()
var presenceMessage =
$"<presence from='41c322a1-b328-495b-a004-5ccd3e45eae8@eu1.pvp.net/RC-Deceive' id='b-{randomStanzaId}'>" +
"<games>" +
$"<keystone><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>keystone</s.p></keystone>" +
$"<league_of_legends><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>league_of_legends</s.p><p>{{&quot;pty&quot;:true}}</p></league_of_legends>" + // No Region s.r keeps it in the main "League" category rather than "Other Servers" in every region with "Group Games & Servers" active
$"<valorant><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>valorant</s.p><p>{valorantPresence}</p></valorant>" +
$"<keystone><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>keystone</s.p><pty/></keystone>" +
$"<league_of_legends><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>league_of_legends</s.p><s.c>live</s.c><p>{{&quot;pty&quot;:true}}</p></league_of_legends>" + // No Region s.r keeps it in the main "League" category rather than "Other Servers" in every region with "Group Games & Servers" active
$"<valorant><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.p>valorant</s.p><s.r>PC</s.r><p>{valorantPresence}</p><pty/></valorant>" +
$"<bacon><st>chat</st><s.t>{unixTimeMilliseconds}</s.t><s.l>bacon_availability_online</s.l><s.p>bacon</s.p></bacon>" +
"</games>" +
"<show>chat</show>" +
"<platform>riot</platform>" +
"<status/>" +
"</presence>";

var bytes = Encoding.UTF8.GetBytes(presenceMessage);
Expand Down
33 changes: 27 additions & 6 deletions Deceive/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -101,13 +102,33 @@ private static IEnumerable<Process> GetProcesses()
// Kills the running LCU/LoR/VALORANT/RC or Deceive instance, if applicable.
public static void KillProcesses()
{
foreach (var process in GetProcesses())
try
{
foreach (var process in GetProcesses())
{
process.Refresh();
if (process.HasExited)
continue;
process.Kill();
process.WaitForExit();
}
} catch (Win32Exception ex)
{
process.Refresh();
if (process.HasExited)
continue;
process.Kill();
process.WaitForExit();
// thank you C# and your horrible win32 ecosystem integration, I have no clue if this is correct
if (ex.NativeErrorCode == -2147467259 || ex.ErrorCode == -2147467259 || ex.ErrorCode == 5 || ex.NativeErrorCode == 5)
{
// ERROR_ACCESS_DENIED
MessageBox.Show(
"Deceive could not stop existing Riot processes because it does not have the right permissions. Please relaunch this application as an administrator and try again.",
StartupHandler.DeceiveTitle,
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1
);
Environment.Exit(0);
}

throw ex;
}
}

Expand Down

0 comments on commit 2e2b6e1

Please sign in to comment.