Skip to content

Commit

Permalink
Fixed #369
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Jul 7, 2024
1 parent 12f4f7f commit 4c6fd5b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
8 changes: 6 additions & 2 deletions setup/InstallScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ public static ActionResult InstallDrivers(Session session)
session.Log($"driversDir = {driversDir}");
string nefconDir = Path.Combine(installDir.FullName, "nefcon");
session.Log($"nefconDir = {nefconDir}");
string archShortName = RuntimeInformation.OSArchitecture.ToString();
string archShortName = ArchitectureInfo.IsArm64
? "arm64"
: RuntimeInformation.OSArchitecture.ToString();
session.Log($"archShortName = {archShortName}");

string nefconcPath = Path.Combine(nefconDir, archShortName, "nefconc.exe");
Expand Down Expand Up @@ -288,7 +290,9 @@ public static ActionResult InstallBthPS3(Session session)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

using WebClient client = new();
client.Headers.Add("X-Vicius-OS-Architecture", RuntimeInformation.OSArchitecture.ToString());
client.Headers.Add("X-Vicius-OS-Architecture", ArchitectureInfo.IsArm64
? "arm64"
: RuntimeInformation.OSArchitecture.ToString());

string json = client.DownloadString("https://vicius.api.nefarius.systems/api/nefarius/BthPS3/updates.json");
UpdateResponse? response = JsonConvert.DeserializeObject<UpdateResponse>(json);
Expand Down
26 changes: 26 additions & 0 deletions setup/Util/ArchitectureInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace Nefarius.DsHidMini.Setup.Util;

public static class ArchitectureInfo
{
public static bool IsArm64
{
get
{
IntPtr handle = Process.GetCurrentProcess().Handle;
IsWow64Process2(handle, out ushort processMachine, out ushort nativeMachine);

return nativeMachine == 0xaa64;
}
}

[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool IsWow64Process2(
IntPtr process,
out ushort processMachine,
out ushort nativeMachine
);
}

0 comments on commit 4c6fd5b

Please sign in to comment.