aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/KernelWatchdog.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-01 17:02:02 -0400
committerMichael <[email protected]>2017-05-01 17:02:02 -0400
commita41f947d8a7794e7756f8571cdd6d71f00d6ec32 (patch)
tree0d621745399df60ce2db9ec89978072ef5895091 /ShiftOS_TheReturn/KernelWatchdog.cs
parentf26bab83109fec93d51fb845094c21b874971490 (diff)
downloadshiftos_thereturn-a41f947d8a7794e7756f8571cdd6d71f00d6ec32.tar.gz
shiftos_thereturn-a41f947d8a7794e7756f8571cdd6d71f00d6ec32.tar.bz2
shiftos_thereturn-a41f947d8a7794e7756f8571cdd6d71f00d6ec32.zip
my hands are typing words\
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)