aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/KernelWatchdog.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-03-07 14:56:48 -0500
committerMichael <[email protected]>2017-03-07 14:56:57 -0500
commit2a747334bd926d79537b9e8d4f38c79a815752e5 (patch)
tree0691439372e8584890a429c78591a0e8d7681573 /ShiftOS_TheReturn/KernelWatchdog.cs
parentc64333d0f57c50a2519b5c631d44243ff41ca815 (diff)
downloadshiftos_thereturn-2a747334bd926d79537b9e8d4f38c79a815752e5.tar.gz
shiftos_thereturn-2a747334bd926d79537b9e8d4f38c79a815752e5.tar.bz2
shiftos_thereturn-2a747334bd926d79537b9e8d4f38c79a815752e5.zip
WHOA HACKING
Diffstat (limited to 'ShiftOS_TheReturn/KernelWatchdog.cs')
-rw-r--r--ShiftOS_TheReturn/KernelWatchdog.cs70
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.");
+ }
+ }
+}