diff options
| author | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
|---|---|---|
| committer | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
| commit | b20d77edd1227b2ce53b65b0752972bd65a36e84 (patch) | |
| tree | b15615591e009c9aa472ba5d95374a064c50e8b1 /ShiftOS_TheReturn/KernelWatchdog.cs | |
| parent | 4989356d6797335b44060ae94c9af34404773506 (diff) | |
| parent | 449d43d22c1d12ce6aa0243fbb4ea94481ff8f4c (diff) | |
| download | shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.gz shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.bz2 shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.zip | |
Merge branch 'master' of https://github.com/shiftos-game/ShiftOS
Diffstat (limited to 'ShiftOS_TheReturn/KernelWatchdog.cs')
| -rw-r--r-- | ShiftOS_TheReturn/KernelWatchdog.cs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs new file mode 100644 index 0000000..1b59b25 --- /dev/null +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using static ShiftOS.Objects.ShiftFS.Utils; + +namespace ShiftOS.Engine +{ + public static class KernelWatchdog + { + public static void Log(string e, string desc) + { + string line = $"[{DateTime.Now}] <{e}> {desc}"; + if (FileExists("0:/system/data/kernel.log")) + { + string contents = ReadAllText("0:/system/data/kernel.log"); + contents += Environment.NewLine + line; + WriteAllText("0:/system/data/kernel.log", contents); + } + else + { + WriteAllText("0:/system/data/kernel.log", line); + } + } + + public static bool InKernelMode { get; private set; } + public static bool MudConnected { get; set; } + + public static bool IsSafe(Type type) + { + if (InKernelMode == true) + return true; + + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is KernelModeAttribute) + return false; + } + return true; + } + + public static bool IsSafe(MethodInfo type) + { + if (InKernelMode == true) + return true; + + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is KernelModeAttribute) + return false; + } + return true; + } + + + public static void EnterKernelMode() + { + InKernelMode = true; + Console.WriteLine("<kernel> Watchdog deactivated, system-level access granted."); + } + + public static void LeaveKernelMode() + { + InKernelMode = false; + Console.WriteLine("<kernel> Kernel mode disabled."); + } + } +} |
