From a41f947d8a7794e7756f8571cdd6d71f00d6ec32 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2017 17:02:02 -0400 Subject: my hands are typing words\ --- ShiftOS_TheReturn/KernelWatchdog.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'ShiftOS_TheReturn/KernelWatchdog.cs') 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(" 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 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) -- cgit v1.2.3