-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
57 lines (49 loc) · 2.11 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using ProtoBuf;
namespace SteamAutoStarter
{
static class Program
{
private const int STEAM_IHS_PORT = 27036;
private const ulong STEAM_IHS_SIGNATURE = 0xA05F4C21FFFFFFFF;
[STAThread]
static void Main()
{
var listener = new UdpClient(STEAM_IHS_PORT, AddressFamily.InterNetwork);
Console.WriteLine("SteamAutoStarter running, waiting for Steam IHS discovery messages");
while(true)
{
var endpoint = new IPEndPoint(IPAddress.Any, STEAM_IHS_PORT);
byte[] data = listener.Receive(ref endpoint);
int position = 0;
Console.WriteLine($"Got data from {endpoint.Address}!");
//check signature
ulong signature = BitConverter.ToUInt64(data, position);
position += 8;
if (signature != STEAM_IHS_SIGNATURE) {
Console.WriteLine("Packet has no Steam IHS signature, ignoring");
continue;
}
//check header
int headerLength = (int)BitConverter.ToUInt32(data, position);
position += 4;
var headerMsg = Serializer.Deserialize<CMsgRemoteClientBroadcastHeader>(data.AsSpan(position, headerLength));
if (headerMsg.MsgType != ERemoteClientBroadcastMsg.kERemoteClientBroadcastMsgDiscovery) {
Console.WriteLine("This is not a discovery message, ignoring");
continue;
}
Console.WriteLine($"Got a discovery message from {endpoint.Address} (clientId {headerMsg.ClientId})!");
//use the Steam browser protocol to launch steam regardless of installation location
Console.WriteLine("Starting steam...");
System.Diagnostics.Process.Start("steam:");
Console.WriteLine("Exiting...");
Environment.Exit(0);
}
}
}
}