aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/KernelWatchdog.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS_TheReturn/KernelWatchdog.cs')
-rw-r--r--ShiftOS_TheReturn/KernelWatchdog.cs25
1 files changed, 19 insertions, 6 deletions
diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs
index cc03f5a..430d36a 100644
--- a/ShiftOS_TheReturn/KernelWatchdog.cs
+++ b/ShiftOS_TheReturn/KernelWatchdog.cs
@@ -66,41 +66,54 @@ namespace ShiftOS.Engine
public static bool IsSafe(Type type)
{
- if (InKernelMode == true)
+ if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
return true;
foreach (var attrib in type.GetCustomAttributes(false))
{
if (attrib is KernelModeAttribute)
+ {
+ if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
+ return true;
return false;
+ }
}
return true;
}
public static bool IsSafe(MethodInfo type)
{
- if (InKernelMode == true)
+ if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
return true;
foreach (var attrib in type.GetCustomAttributes(false))
{
if (attrib is KernelModeAttribute)
+ {
+ if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
+ return true;
return false;
+ }
}
return true;
}
+ static string regularUsername = "";
+
public static void EnterKernelMode()
{
- InKernelMode = true;
- Console.WriteLine("<kernel> Watchdog deactivated, system-level access granted.");
+ regularUsername = SaveSystem.CurrentUser.Username;
+ SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == "root");
+
}
public static void LeaveKernelMode()
{
- InKernelMode = false;
- Console.WriteLine("<kernel> Kernel mode disabled.");
+ var user = SaveSystem.Users.FirstOrDefault(x => x.Username == regularUsername);
+ if (user == null)
+ throw new Exception("User not in root mode.");
+ SaveSystem.CurrentUser = user;
}
internal static bool CanRunOffline(Type method)