Skip to content

Commit

Permalink
Added UserLibs folder as Native Library Search Directory #185
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Oct 11, 2024
1 parent e239e7a commit 950f092
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion MelonLoader/MelonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ internal static void Setup(AppDomain domain)

if (!Directory.Exists(MelonEnvironment.UserLibsDirectory))
Directory.CreateDirectory(MelonEnvironment.UserLibsDirectory);
AddNativeDLLDirectory(MelonEnvironment.UserLibsDirectory);

MelonHandler.Setup();
UnityInformationHandler.Setup();
Expand Down Expand Up @@ -485,6 +486,21 @@ public static string GetFileProductName(string filepath)
return null;
}

public static void AddNativeDLLDirectory(string path)
{
if (!IsWindows && !IsUnix)
return;

path = Path.GetFullPath(path);
if (!Directory.Exists(path))
return;

string envName = IsWindows ? "PATH" : "LD_LIBRARY_PATH";
string envSep = IsWindows ? ";" : ":";
string envPaths = Environment.GetEnvironmentVariable(envName);
Environment.SetEnvironmentVariable(envName, $"{envPaths}{envSep}{path}");
}

internal static void SetupWineCheck()
{
if (IsUnix || IsMac)
Expand All @@ -504,7 +520,6 @@ internal static void SetupWineCheck()
);
}


[DllImport("ntdll.dll", SetLastError = true)]
internal static extern uint RtlGetVersion(out OsVersionInfo versionInformation); // return type should be the NtStatus enum

Expand Down

0 comments on commit 950f092

Please sign in to comment.