Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Upload v2 draft
Browse files Browse the repository at this point in the history
  • Loading branch information
RealNickk committed Oct 28, 2022
1 parent 15449da commit e9f8478
Show file tree
Hide file tree
Showing 76 changed files with 3,307 additions and 2,369 deletions.
8 changes: 8 additions & 0 deletions ArbitraryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

public class Class1
{
public Class1()
{
}
}
6 changes: 0 additions & 6 deletions Starlight.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starlight.Cli", "src\Starli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starlight.Launcher", "src\Starlight.Launcher\Starlight.Launcher.csproj", "{B92B746F-1372-4321-B55D-405993DF30C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Starlight.Rbx", "src\Starlight.Rbx\Starlight.Rbx.csproj", "{79C73613-663B-4C7E-9504-DEDFA488BAE5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Submodules", "Submodules", "{5325689B-2D92-4055-A93D-43CC70B72B46}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HackerFramework", "submodules\HackerFramework\src\HackerFramework\HackerFramework.csproj", "{E47F58ED-1BBE-47F4-9FA9-FACD2317FE90}"
Expand All @@ -35,10 +33,6 @@ Global
{B92B746F-1372-4321-B55D-405993DF30C7}.Debug|x86.Build.0 = Debug|x86
{B92B746F-1372-4321-B55D-405993DF30C7}.Release|x86.ActiveCfg = Release|x86
{B92B746F-1372-4321-B55D-405993DF30C7}.Release|x86.Build.0 = Release|x86
{79C73613-663B-4C7E-9504-DEDFA488BAE5}.Debug|x86.ActiveCfg = Debug|x86
{79C73613-663B-4C7E-9504-DEDFA488BAE5}.Debug|x86.Build.0 = Debug|x86
{79C73613-663B-4C7E-9504-DEDFA488BAE5}.Release|x86.ActiveCfg = Release|x86
{79C73613-663B-4C7E-9504-DEDFA488BAE5}.Release|x86.Build.0 = Release|x86
{E47F58ED-1BBE-47F4-9FA9-FACD2317FE90}.Debug|x86.ActiveCfg = Debug|Any CPU
{E47F58ED-1BBE-47F4-9FA9-FACD2317FE90}.Debug|x86.Build.0 = Debug|Any CPU
{E47F58ED-1BBE-47F4-9FA9-FACD2317FE90}.Release|x86.ActiveCfg = Release|Any CPU
Expand Down
31 changes: 16 additions & 15 deletions src/Starlight.Cli/App.config
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
1 change: 1 addition & 0 deletions src/Starlight.Cli/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura>
<ExcludeAssemblies>
Expand Down
53 changes: 26 additions & 27 deletions src/Starlight.Cli/Native.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
using System.Runtime.InteropServices;

namespace Starlight.Cli
namespace Starlight.Cli;

internal class Native
{
internal class Native
{
#if DEBUG
[DllImport("kernel32.dll")]
public static extern bool IsDebuggerPresent();
#endif

[DllImport("user32.dll")]
public static extern bool ShowWindow(int hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool ShowWindow(int hWnd, int nCmdShow);

[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);

[DllImport("kernel32.dll")]
public static extern int GetConsoleWindow();

[DllImport("user32.dll")]
public static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId);
[DllImport("kernel32.dll")]
public static extern int GetConsoleWindow();

public const uint STD_OUTPUT_HANDLE = 0xFFFFFFF5;

[DllImport("kernel32.dll")]
public static extern uint GetStdHandle(uint nStdHandle);

[DllImport("kernel32.dll")]
public static extern void SetStdHandle(uint nStdHandle, uint handle);

[DllImport("kernel32.dll")]
public static extern bool AllocConsole();
[DllImport("user32.dll")]
public static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId);

[DllImport("kernel32.dll")]
public static extern bool FreeConsole();
public const uint STD_OUTPUT_HANDLE = 0xFFFFFFF5;

[DllImport("kernel32.dll")]
public static extern uint GetStdHandle(uint nStdHandle);

[DllImport("kernel32.dll")]
public static extern void SetStdHandle(uint nStdHandle, uint handle);

[DllImport("kernel32.dll")]
public static extern bool AllocConsole();

[DllImport("kernel32.dll")]
public static extern bool FreeConsole();

public const int SW_HIDE = 0;
}
}
public const int SW_HIDE = 0;
}
49 changes: 23 additions & 26 deletions src/Starlight.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using System.Linq;
using System.Threading;
using CommandLine;
using Starlight.Cli.Verbs;
using Starlight.Misc;
using static Starlight.Cli.Native;

namespace Starlight.Cli
namespace Starlight.Cli;

internal class Program
{
internal class Program
static int Main(string[] args)
{
static int Main(string[] args)
{
Console.Title = "Starlight CLI";
Console.Title = "Starlight CLI";

#if DEBUG
// In Debug mode: Starlight.Cli.exe [nodebug] <verb> [options], skips requirement to attach debugger.
Expand All @@ -31,31 +29,30 @@ static int Main(string[] args)
else
args = args.Skip(1).ToArray();
#else
if (args.Length > 0 && args[0] == "debug")
{
Logger.Init(true);
args = args.Skip(1).ToArray();
}
if (args.Length > 0 && args[0] == "debug")
{
Logger.Init(true);
args = args.Skip(1).ToArray();
}
#endif

// I do not like how this is done, but it works.
var code = Parser.Default.ParseArguments<Hook, Install, RawLaunch, Launch, Unhook, Uninstall, Unlock>(args)
.MapResult(
(Hook x) => x.Invoke(),
(Install x) => x.Invoke(),
(Launch x) => x.Invoke(),
(RawLaunch x) => x.Invoke(),
(Unhook x) => x.Invoke(),
(Uninstall x) => x.Invoke(),
(Unlock x) => x.Invoke(),
_ => 1);
// I do not like how this is done, but it works.
var code = Parser.Default.ParseArguments<Hook, Install, RawLaunch, Verbs.Launch, Unhook, Uninstall, Unlock>(args)
.MapResult(
(Hook x) => x.Invoke(),
(Install x) => x.Invoke(),
(Verbs.Launch x) => x.Invoke(),
(RawLaunch x) => x.Invoke(),
(Unhook x) => x.Invoke(),
(Uninstall x) => x.Invoke(),
(Unlock x) => x.Invoke(),
_ => 1);

#if DEBUG
Console.WriteLine($"Exit code: 0x{code:X}. Press any key to exit...");
Console.ReadKey();
#endif

return code;
}
return code;
}
}
}
53 changes: 26 additions & 27 deletions src/Starlight.Cli/Verbs/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
using CommandLine;
using Starlight.Core;
using System;
using System.Reflection;
using System;
using System.IO;
using System.Reflection;
using CommandLine;
using Starlight.SchemeLaunch;

namespace Starlight.Cli.Verbs;

namespace Starlight.Cli.Verbs
[Verb("hook", HelpText = "Hook Roblox's scheme.")]
public class Hook : VerbBase
{
[Verb("hook", HelpText = "Hook Roblox's scheme.")]
public class Hook : VerbBase
protected override int Init()
{
return 0;
}

protected override int InternalInvoke()
{
protected override int Init()
var binDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (binDir is null)
{
return 0;
Console.WriteLine("Failed to get current assembly directory.");
return 1;
}

protected override int InternalInvoke()
var launcherBin = Path.Combine(binDir, "Starlight.Launcher.exe");
if (Scheme.Hook(launcherBin))
{
var binDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (binDir is null)
{
Console.WriteLine("Failed to get current assembly directory.");
return 1;
}

var launcherBin = Path.Combine(binDir, "Starlight.Launcher.exe");
if (Scheme.Hook(launcherBin))
{
Console.WriteLine("Hooked scheme. You can now launch with Starlight from the browser.");
return 0;
}

Console.WriteLine("Failed to hook scheme.");
return 1;
Console.WriteLine("Hooked scheme. You can now launch with Starlight from the browser.");
return 0;
}

Console.WriteLine("Failed to hook scheme.");
return 1;
}
}
}
65 changes: 34 additions & 31 deletions src/Starlight.Cli/Verbs/Install.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
using CommandLine;
using System;
using Starlight.Core;
using System;
using CommandLine;
using Starlight.Bootstrap;
using Starlight.Except;

namespace Starlight.Cli.Verbs
namespace Starlight.Cli.Verbs;

[Verb("install", HelpText = "Install a Roblox client.")]
public class Install : VerbBase
{
[Verb("install", HelpText = "Install a Roblox client.")]
public class Install : VerbBase
[Option('h', "hash", Required = false, Default = null, HelpText = "The hash of the client to install.")]
public string Hash { get; set; }

protected override int Init()
{
[Option('h', "hash", Required = false, Default = null, HelpText = "The hash of the client to install.")]
public string Hash { get; set; }
if (string.IsNullOrEmpty(Hash))
Hash = Bootstrapper.GetLatestHash();

protected override int Init()
try
{
if (string.IsNullOrEmpty(Hash))
Hash = Bootstrapper.GetLatestHash();

var client = Bootstrapper.QueryClient(Hash);
if (client is null)
return 0;

Bootstrapper.QueryClient(Hash);
Console.WriteLine($"Roblox version-{Hash} is already installed.");
return 1;

}
catch (ClientNotFoundException)
{
return 0;
}
}

protected override int InternalInvoke()
protected override int InternalInvoke()
{
Console.WriteLine($"Installing Roblox version-{Hash}...");
try
{
Console.WriteLine($"Installing Roblox version-{Hash}...");
try
{
Bootstrapper.Install(Hash);
Console.WriteLine("Roblox has been installed successfully.");
return 0;
}
catch (BootstrapException ex)
{
Console.WriteLine($"Failed to install Roblox: {ex.Message}");
return 1;
}
Bootstrapper.Install(Hash);
Console.WriteLine("Roblox has been installed successfully.");
return 0;
}
catch (BadIntegrityException ex)
{
Console.WriteLine($"Failed to install Roblox: {ex.Message}");
return 1;
}
}
}
}
Loading

1 comment on commit e9f8478

@reversed-coffee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failed because sxlib does not exist on the CI server.
TODO: AppVeyor

Please sign in to comment.