mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Get rid of namespaces in commands.
This commit is contained in:
parent
eb4b032b35
commit
79fe2101ae
22 changed files with 67 additions and 1640 deletions
|
@ -32,7 +32,6 @@ using ShiftOS.Engine;
|
|||
|
||||
namespace ModLauncher
|
||||
{
|
||||
[Namespace("modlauncher")]
|
||||
public static class Program
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -43,15 +42,5 @@ namespace ModLauncher
|
|||
{
|
||||
ShiftOS.WinForms.Program.Main();
|
||||
}
|
||||
|
||||
[Command("throwcrash")]
|
||||
public static bool ThrowCrash()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
throw new Exception("User triggered crash using modlauncher.throwcrash command.");
|
||||
}).Start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ Module Module1
|
|||
|
||||
End Module
|
||||
|
||||
<ShiftOS.Engine.Namespace("skinning")>
|
||||
Public Class SkinConverterCommands
|
||||
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@ namespace ShiftOS.Modding.VirtualMachine
|
|||
}
|
||||
}
|
||||
|
||||
[Namespace("svm")]
|
||||
public static class Compiler
|
||||
{
|
||||
public static byte[] Compile(string prg)
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
partial class CoherenceOverlay
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ShiftOS.Engine;
|
||||
using System.Threading;
|
||||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
public partial class CoherenceOverlay : UserControl, IShiftOSWindow
|
||||
{
|
||||
public CoherenceOverlay(IntPtr handle, CoherenceCommands.RECT rect)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Load += (o, a) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int left = this.ParentForm.Left;
|
||||
int top = this.ParentForm.Top;
|
||||
int oldwidth = this.ParentForm.Width;
|
||||
int oldheight = this.ParentForm.Height;
|
||||
|
||||
var t = new Thread(new ThreadStart(() =>
|
||||
{
|
||||
while (CoherenceCommands.GetWindowRect(handle, ref rect))
|
||||
{
|
||||
|
||||
if (left != rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.ParentForm.Left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth;
|
||||
left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth;
|
||||
}));
|
||||
}
|
||||
if (top != rect.Top - SkinEngine.LoadedSkin.TitlebarHeight)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
|
||||
this.ParentForm.Top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight;
|
||||
top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight;
|
||||
}));
|
||||
}
|
||||
int width = (rect.Right - rect.Left) + 1;
|
||||
int height = (rect.Bottom - rect.Top) + 1;
|
||||
|
||||
if (oldheight != SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.ParentForm.Height = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth;
|
||||
oldheight = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth;
|
||||
}));
|
||||
}
|
||||
if (oldwidth != SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.ParentForm.Width = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth;
|
||||
oldwidth = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}));
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSkinLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public bool OnUnload()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnUpgrade()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -216,7 +216,6 @@ namespace ShiftOS.WinForms.Applications
|
|||
public int Progress { get; set; }
|
||||
}
|
||||
|
||||
[Namespace("dev")]
|
||||
public static class DownloaderDebugCommands
|
||||
{
|
||||
[Command("setsubscription", description ="Use to set the current shiftnet subscription.", usage ="{value:int32}")]
|
||||
|
|
|
@ -42,6 +42,15 @@ namespace ShiftOS.WinForms.Applications
|
|||
LevelComplete();
|
||||
}
|
||||
};
|
||||
#if DEBUG
|
||||
this.KeyDown += (o, a) =>
|
||||
{
|
||||
if(a.KeyCode == Keys.D)
|
||||
{
|
||||
drawAiBall = !drawAiBall;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
private double ballX = 0.0f;
|
||||
|
@ -266,11 +275,14 @@ namespace ShiftOS.WinForms.Applications
|
|||
ballX = 0;
|
||||
ballY = 0;
|
||||
opponentY = 0;
|
||||
xVel = 1;
|
||||
aiBallX = 0;
|
||||
aiBallY = 0;
|
||||
doAi = true;
|
||||
}
|
||||
|
||||
private bool drawAiBall = false;
|
||||
|
||||
private void pnlcanvas_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
|
@ -281,11 +293,22 @@ namespace ShiftOS.WinForms.Applications
|
|||
ballXLocal -= ((double)paddleWidth / 2);
|
||||
ballYLocal -= ((double)paddleWidth / 2);
|
||||
|
||||
double aiballXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width);
|
||||
double aiballYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height);
|
||||
|
||||
aiballXLocal -= ((double)paddleWidth / 2);
|
||||
aiballYLocal -= ((double)paddleWidth / 2);
|
||||
|
||||
|
||||
e.Graphics.Clear(pnlcanvas.BackColor);
|
||||
|
||||
//draw the ai ball
|
||||
if (drawAiBall)
|
||||
e.Graphics.FillEllipse(new SolidBrush(Color.Gray), new RectangleF((float)aiballXLocal, (float)aiballYLocal, (float)paddleWidth, (float)paddleWidth));
|
||||
|
||||
|
||||
//draw the ball
|
||||
if(doBallCalc)
|
||||
if (doBallCalc)
|
||||
e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth));
|
||||
|
||||
double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height);
|
||||
|
|
|
@ -1,299 +0,0 @@
|
|||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShiftOS.Engine;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
/// <summary>
|
||||
/// Coherence commands.
|
||||
/// </summary>
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("trm")]
|
||||
public static class TerminalExtensions
|
||||
{
|
||||
[Command("exit")]
|
||||
public static bool StopRemoting()
|
||||
{
|
||||
if(TerminalBackend.IsForwardingConsoleWrites == true)
|
||||
{
|
||||
ServerManager.SendMessage("trm_handshake_stop", $@"{{
|
||||
guid: ""{TerminalBackend.ForwardGUID}""
|
||||
}}");
|
||||
Console.WriteLine("Goodbye!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
[Command("setpass", true)]
|
||||
[RequiresArgument("pass")]
|
||||
public static bool setPass(Dictionary<string, object> args)
|
||||
{
|
||||
SaveSystem.CurrentSave.Password = args["pass"] as string;
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("remote", "username:,sysname:,password:", "Allows you to control a remote system on the multi-user domain given a username, password and system name.")]
|
||||
[RequiresArgument("username")]
|
||||
[RequiresArgument("sysname")]
|
||||
[RequiresArgument("password")]
|
||||
public static bool RemoteControl(Dictionary<string, object> args)
|
||||
{
|
||||
ServerManager.SendMessage("trm_handshake_request", JsonConvert.SerializeObject(args));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[Namespace("coherence")]
|
||||
[RequiresUpgrade("kernel_coherence")]
|
||||
public static class CoherenceCommands
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the window position.
|
||||
/// </summary>
|
||||
/// <returns>The window position.</returns>
|
||||
/// <param name="hWnd">H window.</param>
|
||||
/// <param name="hWndInsertAfter">H window insert after.</param>
|
||||
/// <param name="X">X.</param>
|
||||
/// <param name="Y">Y.</param>
|
||||
/// <param name="cx">Cx.</param>
|
||||
/// <param name="cy">Cy.</param>
|
||||
/// <param name="uFlags">U flags.</param>
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
|
||||
/// <summary>
|
||||
/// The HWN d TOPMOS.
|
||||
/// </summary>
|
||||
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
|
||||
/// <summary>
|
||||
/// The SW p SHOWWINDO.
|
||||
/// </summary>
|
||||
const UInt32 SWP_SHOWWINDOW = 0x0040;
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
/// <summary>
|
||||
/// Gets the window rect.
|
||||
/// </summary>
|
||||
/// <returns>The window rect.</returns>
|
||||
/// <param name="hWnd">H window.</param>
|
||||
/// <param name="lpRect">Lp rect.</param>
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
|
||||
|
||||
/// <summary>
|
||||
/// REC.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left; // x position of upper-left corner
|
||||
public int Top; // y position of upper-left corner
|
||||
public int Right; // x position of lower-right corner
|
||||
public int Bottom; // y position of lower-right corner
|
||||
}
|
||||
|
||||
[Command("launch", "process: \"C:\\path\\to\\process\" - The process path to launch.", "Launch a process inside kernel coherence.")]
|
||||
[RequiresArgument("process")]
|
||||
/// <summary>
|
||||
/// Launchs the app.
|
||||
/// </summary>
|
||||
/// <returns>The app.</returns>
|
||||
/// <param name="args">Arguments.</param>
|
||||
public static bool LaunchApp(Dictionary<string, object> args)
|
||||
{
|
||||
string process = args["process"].ToString();
|
||||
var prc = Process.Start(process);
|
||||
StartCoherence(prc);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the coherence.
|
||||
/// </summary>
|
||||
/// <returns>The coherence.</returns>
|
||||
/// <param name="prc">Prc.</param>
|
||||
private static void StartCoherence(Process prc)
|
||||
{
|
||||
RECT rct = new RECT();
|
||||
|
||||
|
||||
while (!GetWindowRect(prc.MainWindowHandle, ref rct))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
AppearanceManager.Invoke(new Action(() =>
|
||||
{
|
||||
IShiftOSWindow coherenceWindow = new Applications.CoherenceOverlay(prc.MainWindowHandle, rct);
|
||||
|
||||
AppearanceManager.SetupWindow(coherenceWindow);
|
||||
SetWindowPos(prc.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
//MakeExternalWindowBorderless(prc.MainWindowHandle);
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The W s BORDE.
|
||||
/// </summary>
|
||||
const int WS_BORDER = 8388608;
|
||||
|
||||
/// <summary>
|
||||
/// The W s DLGFRAM.
|
||||
/// </summary>
|
||||
const int WS_DLGFRAME = 4194304;
|
||||
|
||||
/// <summary>
|
||||
/// The W s CAPTIO.
|
||||
/// </summary>
|
||||
const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
|
||||
|
||||
/// <summary>
|
||||
/// The W s SYSMEN.
|
||||
/// </summary>
|
||||
const int WS_SYSMENU = 524288;
|
||||
|
||||
/// <summary>
|
||||
/// The W s THICKFRAM.
|
||||
/// </summary>
|
||||
const int WS_THICKFRAME = 262144;
|
||||
|
||||
/// <summary>
|
||||
/// The W s MINIMIZ.
|
||||
/// </summary>
|
||||
const int WS_MINIMIZE = 536870912;
|
||||
|
||||
/// <summary>
|
||||
/// The W s MAXIMIZEBO.
|
||||
/// </summary>
|
||||
const int WS_MAXIMIZEBOX = 65536;
|
||||
|
||||
/// <summary>
|
||||
/// The GW l STYL.
|
||||
/// </summary>
|
||||
const int GWL_STYLE = -16;
|
||||
|
||||
/// <summary>
|
||||
/// The GW l EXSTYL.
|
||||
/// </summary>
|
||||
const int GWL_EXSTYLE = -20;
|
||||
|
||||
/// <summary>
|
||||
/// The W s E x DLGMODALFRAM.
|
||||
/// </summary>
|
||||
const int WS_EX_DLGMODALFRAME = 0x1;
|
||||
|
||||
/// <summary>
|
||||
/// The SW p NOMOV.
|
||||
/// </summary>
|
||||
const int SWP_NOMOVE = 0x2;
|
||||
|
||||
/// <summary>
|
||||
/// The SW p NOSIZ.
|
||||
/// </summary>
|
||||
const int SWP_NOSIZE = 0x1;
|
||||
|
||||
/// <summary>
|
||||
/// The SW p FRAMECHANGE.
|
||||
/// </summary>
|
||||
const int SWP_FRAMECHANGED = 0x20;
|
||||
|
||||
/// <summary>
|
||||
/// The M f BYPOSITIO.
|
||||
/// </summary>
|
||||
const uint MF_BYPOSITION = 0x400;
|
||||
|
||||
/// <summary>
|
||||
/// The M f REMOV.
|
||||
/// </summary>
|
||||
const uint MF_REMOVE = 0x1000;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window long.
|
||||
/// </summary>
|
||||
/// <returns>The window long.</returns>
|
||||
/// <param name="hWnd">H window.</param>
|
||||
/// <param name="nIndex">N index.</param>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the window long.
|
||||
/// </summary>
|
||||
/// <returns>The window long.</returns>
|
||||
/// <param name="hWnd">H window.</param>
|
||||
/// <param name="nIndex">N index.</param>
|
||||
/// <param name="dwNewLong">Dw new long.</param>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the window position.
|
||||
/// </summary>
|
||||
/// <returns>The window position.</returns>
|
||||
/// <param name="hWnd">H window.</param>
|
||||
/// <param name="hWndInsertAfter">H window insert after.</param>
|
||||
/// <param name="X">X.</param>
|
||||
/// <param name="Y">Y.</param>
|
||||
/// <param name="cx">Cx.</param>
|
||||
/// <param name="cy">Cy.</param>
|
||||
/// <param name="uFlags">U flags.</param>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
public static void MakeExternalWindowBorderless(IntPtr MainWindowHandle)
|
||||
{
|
||||
int Style = 0;
|
||||
Style = GetWindowLong(MainWindowHandle, GWL_STYLE);
|
||||
Style = Style & ~WS_CAPTION;
|
||||
Style = Style & ~WS_SYSMENU;
|
||||
Style = Style & ~WS_THICKFRAME;
|
||||
Style = Style & ~WS_MINIMIZE;
|
||||
Style = Style & ~WS_MAXIMIZEBOX;
|
||||
SetWindowLong(MainWindowHandle, GWL_STYLE, Style);
|
||||
Style = GetWindowLong(MainWindowHandle, GWL_EXSTYLE);
|
||||
SetWindowLong(MainWindowHandle, GWL_EXSTYLE, Style | WS_EX_DLGMODALFRAME);
|
||||
SetWindowPos(MainWindowHandle, new IntPtr(0), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,722 +1 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using ShiftOS.Engine;
|
||||
using ShiftOS.Objects;
|
||||
using ShiftOS.Objects.ShiftFS;
|
||||
using ShiftOS.WinForms.Applications;
|
||||
using static ShiftOS.Objects.ShiftFS.Utils;
|
||||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("puppy")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
[KernelMode]
|
||||
public static class KernelPuppyCommands
|
||||
{
|
||||
[Command("clear", true)]
|
||||
public static bool ClearLogs()
|
||||
{
|
||||
WriteAllText("0:/system/data/kernel.log", "");
|
||||
Console.WriteLine("<watchdog> logs cleared successfully.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[Namespace("krnl")]
|
||||
public static class KernelCommands
|
||||
{
|
||||
[Command("control", true)]
|
||||
[RequiresArgument("pass")]
|
||||
public static bool Control(Dictionary<string, object> args)
|
||||
{
|
||||
if(args["pass"].ToString() == ServerManager.thisGuid.ToString())
|
||||
{
|
||||
KernelWatchdog.Log("warn", "User has breached the kernel.");
|
||||
KernelWatchdog.EnterKernelMode();
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("lock_session")]
|
||||
[KernelMode]
|
||||
public static bool LeaveControl()
|
||||
{
|
||||
KernelWatchdog.Log("inf", "User has left the kernel-mode session.");
|
||||
KernelWatchdog.LeaveKernelMode();
|
||||
KernelWatchdog.MudConnected = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[Namespace("hacker101")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static class HackerCommands
|
||||
{
|
||||
private static void writeSlow(string text)
|
||||
{
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.Italic = false;
|
||||
Console.Write("[");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.Magenta;
|
||||
ConsoleEx.Bold = true;
|
||||
Console.Write("hacker101");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
ConsoleEx.Italic = true;
|
||||
Console.Write("@");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.White;
|
||||
Console.Write("undisclosed");
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.Italic = false;
|
||||
Console.Write("]: ");
|
||||
Thread.Sleep(850);
|
||||
Console.WriteLine(text);
|
||||
Thread.Sleep(4000);
|
||||
}
|
||||
|
||||
[Story("hacker101_deadaccts")]
|
||||
public static void DeadAccountsStory()
|
||||
{
|
||||
if (!terminalIsOpen())
|
||||
{
|
||||
AppearanceManager.SetupWindow(new Terminal());
|
||||
}
|
||||
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
Console.WriteLine("[sys@mud]: Warning: User connecting to system...");
|
||||
Thread.Sleep(75);
|
||||
Console.WriteLine("[sys@mud]: UBROADCAST: Username: hacker101 - Sysname: undisclosed");
|
||||
Thread.Sleep(50);
|
||||
Console.Write("--locking mud connection resources...");
|
||||
Thread.Sleep(50);
|
||||
Console.WriteLine("...done.");
|
||||
Console.Write("--locking user input... ");
|
||||
Thread.Sleep(75);
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
TerminalBackend.InStory = true;
|
||||
Console.WriteLine("...done.");
|
||||
|
||||
Thread.Sleep(2000);
|
||||
writeSlow($"Hello there, fellow multi-user domain user.");
|
||||
writeSlow("My name, as you can tell, is hacker101.");
|
||||
writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?");
|
||||
writeSlow("Of course it is.");
|
||||
writeSlow("And I bet you 10,000 Codepoints that you have... " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints.");
|
||||
writeSlow("Oh, and how much upgrades have you installed since you first started using ShiftOS?");
|
||||
writeSlow("That would be... uhh... " + SaveSystem.CurrentSave.CountUpgrades().ToString() + ".");
|
||||
writeSlow("I'm probably freaking you out right now. You are probably thinking that you're unsafe and need to lock yourself down.");
|
||||
writeSlow("But, don't worry, I mean no harm.");
|
||||
writeSlow("In fact, I am a multi-user domain safety activist and security professional.");
|
||||
writeSlow("I need your help with something.");
|
||||
writeSlow("Inside the multi-user domain, every now and then these 'dead' user accounts pop up.");
|
||||
writeSlow("They're infesting everything. They're in every legion, they infest chatrooms, and they take up precious hard drive space.");
|
||||
writeSlow("Eventually there's going to be tons of them just sitting there taking over the MUD. We can't have that.");
|
||||
writeSlow("It sounds like a conspiracy theory indeed, but it's true, in fact, these dead accounts hold some valuable treasures.");
|
||||
writeSlow("I'm talking Codepoints, skins, documents, the possibilities are endless.");
|
||||
writeSlow("I'm going to execute a quick sys-script that will show you how you can help get rid of these accounts, and also gain some valuable resources to help you on your digital frontier.");
|
||||
writeSlow("This script will also show you the fundamentals of security exploitation and theft of resources - which if you want to survive in the multi-user domain is paramount.");
|
||||
writeSlow("Good luck.");
|
||||
Thread.Sleep(1000);
|
||||
Console.WriteLine("--user disconnected");
|
||||
Thread.Sleep(75);
|
||||
Console.WriteLine("--commands unlocked - check sos.help.");
|
||||
Thread.Sleep(45);
|
||||
SaveSystem.SaveGame();
|
||||
Console.Write("--unlocking user input...");
|
||||
Thread.Sleep(75);
|
||||
Console.Write(" ..done");
|
||||
TerminalBackend.InStory = false;
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
|
||||
StartHackerTutorial();
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
TerminalBackend.PrintPrompt();
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
}
|
||||
|
||||
internal static void StartHackerTutorial()
|
||||
{
|
||||
Desktop.InvokeOnWorkerThread(() =>
|
||||
{
|
||||
var tut = new TutorialBox();
|
||||
AppearanceManager.SetupWindow(tut);
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
|
||||
|
||||
int tutPos = 0;
|
||||
Action ondec = () =>
|
||||
{
|
||||
tutPos++;
|
||||
};
|
||||
TerminalBackend.CommandProcessed += (o, a) =>
|
||||
{
|
||||
switch (tutPos)
|
||||
{
|
||||
|
||||
case 0:
|
||||
case 10:
|
||||
if (o.ToLower().StartsWith("mud.disconnect"))
|
||||
{
|
||||
tutPos++;
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (o.ToLower().StartsWith("krnl.lock_session"))
|
||||
tutPos++;
|
||||
break;
|
||||
case 1:
|
||||
if (o.ToLower().StartsWith("hacker101.brute_decrypt"))
|
||||
{
|
||||
if (a.Contains("0:/system/data/kernel.log"))
|
||||
{
|
||||
tutPos++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (o.ToLower().StartsWith("krnl.control"))
|
||||
{
|
||||
tutPos++;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (o.ToLower().StartsWith("puppy.clear"))
|
||||
tutPos++;
|
||||
break;
|
||||
case 5:
|
||||
if (o.ToLower().StartsWith("mud.reconnect"))
|
||||
tutPos++;
|
||||
break;
|
||||
case 6:
|
||||
if (o.ToLower().StartsWith("mud.sendmsg"))
|
||||
{
|
||||
var msg = JsonConvert.DeserializeObject<dynamic>(a);
|
||||
try
|
||||
{
|
||||
if (msg.header == "getusers" && msg.body == "dead")
|
||||
tutPos++;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (o.ToLower().StartsWith("hacker101.breach_user_password"))
|
||||
tutPos++;
|
||||
break;
|
||||
case 8:
|
||||
if (o.ToLower().StartsWith("hacker101.print_user_info"))
|
||||
tutPos++;
|
||||
break;
|
||||
case 9:
|
||||
if (o.ToLower().StartsWith("hacker101.steal_codepoints"))
|
||||
tutPos++;
|
||||
break;
|
||||
}
|
||||
};
|
||||
tut.SetObjective("Welcome to the dead account exploitation tutorial. In this tutorial you will learn the basics of hacking within the multi-user domain.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("We will start with a simple system exploit - gaining kernel-level access to ShiftOS. This can help you perform actions not ever possible in the user level.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("To gain root access, you will first need to breach the system watchdog to keep it from dialing home to DevX.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("The watchdog can only function when it has a successful connection to the multi-user domain. You will need to use the MUD Control Centre to disconnect yourself from the MUD. This will lock you out of most features. To disconnect from the multi-user domain, simply run the 'mud.disconnect' command.");
|
||||
while(tutPos == 0)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("As you can see, the kernel watchdog has shut down temporarily, however before the disconnect it was able to tell DevX that it has gone offline.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("You'll also notice that commands like the shiftorium, MUD control centre and various applications that utilize these system components no longer function.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("The watchdog, however, is still watching. DevX was smart and programmed the kernel to log all events to a local file in 0:/system/data/kernel.log.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("You will need to empty out this file before you can connect to the multi-user domain, as the watchdog will send the contents of this file straight to DevX.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("Or, you can do what we're about to do and attempt to decrypt the log and sniff out the kernel-mode access password.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("This will allow us to gain kernel-level access to our system using the krnl.control{pass:} command.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("Let's start decrypting the log file using the hacker101.brute_decrypt{file:} script. The file: argument is a string and should point to a .log file. When the script succeeds, you will see a TextPad open with the decrypted contents.");
|
||||
while(tutPos == 1)
|
||||
{
|
||||
|
||||
}
|
||||
onCompleteDecrypt += ondec;
|
||||
tut.SetObjective("This script isn't the most agile script ever, but it'll get the job done.");
|
||||
tutPos = 3; // For some reason, it refuses to go to part 3.
|
||||
while(tutPos == 2)
|
||||
{
|
||||
|
||||
}
|
||||
onCompleteDecrypt -= ondec;
|
||||
tut.SetObjective("Alright - it's done. Here's how it's laid out. In each log entry, you have the timestamp, then the event name, then the event description.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("Look for the most recent 'mudhandshake' event. This contains the kernel access code.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("Once you have it, run 'krnl.control{pass:\"the-kernel-code-here\"}. This will allow you to gain access to the kernel.");
|
||||
while(tutPos == 3)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("You are now in kernel mode. Every command you enter will run on the kernel. Now, let's clear the watchdog's logfile and reconnect to the multi-user domain.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("To clear the log, simply run 'puppy.clear'.");
|
||||
while(tutPos == 4)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("Who's a good dog... You are, ShiftOS. Now, we can connect back to the MUD using 'mud.reconnect'.");
|
||||
Thread.Sleep(1000);
|
||||
while(tutPos == 5)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("We have now snuck by the watchdog and DevX has no idea. With kernel-level access, everything you do is not logged, however if you perform too much in one shot, you'll get kicked off and locked out of the multi-user domain temporarily.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("So, let's focus on the job. You want to get into one of those fancy dead accounts, don't ya? Well, first, we need to talk with the MUD to get a list of these accounts.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("Simply run the `mud.sendmsg` command, specifying a 'header' of \"getusers\", and a body of \"dead\".");
|
||||
while(tutPos == 6)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("Great. We now have the usernames and sysnames of all dead accounts on the MUD. Now let's use the hacker101.breach_user_password{user:,sys:} command to breach one of these accounts' passwords.");
|
||||
while(tutPos == 7)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("There - you now have access to that account. Use its password, username and sysname and run the hacker101.print_user_info{user:,pass:,sys:} command to print the entirety of this user's information.");
|
||||
while(tutPos == 8)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("Now you can see a list of the user's Codepoints among other things. Now you can steal their codepoints by using the hacker101.steal_codepoints{user:,pass:,sys;,amount:} command. Be careful. This may alert DevX.");
|
||||
while(tutPos == 9)
|
||||
{
|
||||
|
||||
}
|
||||
if(devx_alerted == true)
|
||||
{
|
||||
tut.SetObjective("Alright... enough fun and games. DevX just found out we were doing this.");
|
||||
Thread.Sleep(500);
|
||||
tut.SetObjective("Quick! Disconnect from the MUD!!");
|
||||
while(tutPos == 10)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("Now, get out of kernel mode! To do that, run krnl.lock_session.");
|
||||
while(tutPos == 11)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tut.SetObjective("OK, that was risky, but we pulled it off. Treat yourself! But first, let's get you out of kernel mode.");
|
||||
Thread.Sleep(500);
|
||||
tut.SetObjective("First we need to get you off the MUD. Simply run mud.disconnect again.");
|
||||
while (tutPos == 10)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("Now, let's run krnl.lock_session. This will lock you back into the user mode, and reconnect you to the MUD.");
|
||||
while (tutPos == 11)
|
||||
{
|
||||
|
||||
}
|
||||
tut.SetObjective("If, for some reason, DevX DOES find out, you have to be QUICK to get off of kernel mode. You don't want to make him mad.");
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("So that's all for now. Whenever you're in kernel mode again, and you have access to a user account, try breaching their filesystem next time. You can use sos.help{ns:} to show commands from a specific namespace to help you find more commands easily.");
|
||||
Thread.Sleep(1000);
|
||||
tut.SetObjective("You can now close this window.");
|
||||
tut.IsComplete = true;
|
||||
|
||||
}).Start();
|
||||
});
|
||||
}
|
||||
|
||||
private static bool devx_alerted = false;
|
||||
|
||||
private static event Action onCompleteDecrypt;
|
||||
|
||||
private static bool terminalIsOpen()
|
||||
{
|
||||
foreach(var win in AppearanceManager.OpenForms)
|
||||
{
|
||||
if (win.ParentWindow is Terminal)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("breach_user_password")]
|
||||
[KernelMode]
|
||||
[RequiresArgument("user")]
|
||||
[RequiresArgument("sys")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool BreachUserPassword(Dictionary<string, object> args)
|
||||
{
|
||||
string usr = args["user"].ToString();
|
||||
string sys = args["sys"].ToString();
|
||||
ServerMessageReceived msgReceived = null;
|
||||
|
||||
Console.WriteLine("--hooking system thread...");
|
||||
|
||||
msgReceived = (msg) =>
|
||||
{
|
||||
if(msg.Name == "user_data")
|
||||
{
|
||||
var sve = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
var rnd = new Random();
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
Thread.Sleep(2000);
|
||||
if(rnd.Next(0, 100) >= 75)
|
||||
{
|
||||
Console.WriteLine("--operation took too long - failed.");
|
||||
ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve));
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
return;
|
||||
}
|
||||
sw.Stop();
|
||||
Console.WriteLine(sve.Password);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds.");
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
else if(msg.Name == "user_data_not_found")
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
};
|
||||
|
||||
Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "...");
|
||||
ServerManager.MessageReceived += msgReceived;
|
||||
|
||||
ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new
|
||||
{
|
||||
user = usr,
|
||||
sysname = sys
|
||||
}));
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
Thread.Sleep(500);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("print_user_info")]
|
||||
[KernelMode]
|
||||
[RequiresArgument("pass")]
|
||||
[RequiresArgument("user")]
|
||||
[RequiresArgument("sys")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool PrintUserInfo(Dictionary<string, object> args)
|
||||
{
|
||||
string usr = args["user"].ToString();
|
||||
string sys = args["sys"].ToString();
|
||||
string pass = args["pass"].ToString();
|
||||
ServerMessageReceived msgReceived = null;
|
||||
|
||||
Console.WriteLine("--hooking multi-user domain response call...");
|
||||
|
||||
msgReceived = (msg) =>
|
||||
{
|
||||
if (msg.Name == "user_data")
|
||||
{
|
||||
var sve = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
if(sve.Password == pass)
|
||||
{
|
||||
Console.WriteLine("Username: " + SaveSystem.CurrentUser.Username);
|
||||
Console.WriteLine("Password: " + sve.Password);
|
||||
Console.WriteLine("System name: " + sve.SystemName);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Codepoints: " + sve.Codepoints.ToString());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
}
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
|
||||
}
|
||||
else if (msg.Name == "user_data_not_found")
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
};
|
||||
|
||||
Console.WriteLine("--contacting multi-user domain...");
|
||||
ServerManager.MessageReceived += msgReceived;
|
||||
|
||||
ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new
|
||||
{
|
||||
user = usr,
|
||||
sysname = sys
|
||||
}));
|
||||
Thread.Sleep(500);
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("steal_codepoints")]
|
||||
[KernelMode]
|
||||
[RequiresArgument("amount")]
|
||||
[RequiresArgument("pass")]
|
||||
[RequiresArgument("user")]
|
||||
[RequiresArgument("sys")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool StealCodepoints(Dictionary<string, object> args)
|
||||
{
|
||||
string usr = args["user"].ToString();
|
||||
string sys = args["sys"].ToString();
|
||||
string pass = args["pass"].ToString();
|
||||
ulong amount = (ulong)args["amount"];
|
||||
if(amount < 0)
|
||||
{
|
||||
Console.WriteLine("--invalid codepoint amount - halting...");
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerMessageReceived msgReceived = null;
|
||||
|
||||
Console.WriteLine("--hooking multi-user domain response call...");
|
||||
|
||||
msgReceived = (msg) =>
|
||||
{
|
||||
if (msg.Name == "user_data")
|
||||
{
|
||||
var sve = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
if (sve.Password == pass)
|
||||
{
|
||||
if(amount > sve.Codepoints)
|
||||
{
|
||||
Console.WriteLine("--can't steal this many codepoints from user.");
|
||||
ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve));
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
sve.Codepoints -= amount;
|
||||
SaveSystem.TransferCodepointsFrom(SaveSystem.CurrentUser.Username, amount);
|
||||
ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve));
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
}
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
else if (msg.Name == "user_data_not_found")
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
TerminalBackend.PrintPrompt();
|
||||
}
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
};
|
||||
|
||||
Console.WriteLine("--contacting multi-user domain...");
|
||||
Thread.Sleep(500);
|
||||
ServerManager.MessageReceived += msgReceived;
|
||||
|
||||
ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new
|
||||
{
|
||||
user = usr,
|
||||
sysname = sys
|
||||
}));
|
||||
Thread.Sleep(500);
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("purge_user")]
|
||||
[KernelMode]
|
||||
[RequiresArgument("pass")]
|
||||
[RequiresArgument("user")]
|
||||
[RequiresArgument("sys")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool PurgeUser(Dictionary<string, object> args)
|
||||
{
|
||||
string usr = args["user"].ToString();
|
||||
string sys = args["sys"].ToString();
|
||||
string pass = args["pass"].ToString();
|
||||
ServerMessageReceived msgReceived = null;
|
||||
|
||||
Console.WriteLine("--hooking multi-user domain response call...");
|
||||
|
||||
msgReceived = (msg) =>
|
||||
{
|
||||
if (msg.Name == "user_data")
|
||||
{
|
||||
var sve = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
if (sve.Password == pass)
|
||||
{
|
||||
ServerManager.SendMessage("delete_dead_save", JsonConvert.SerializeObject(sve));
|
||||
Console.WriteLine("<mud> User purged successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
}
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
}
|
||||
else if (msg.Name == "user_data_not_found")
|
||||
{
|
||||
Console.WriteLine("--access denied.");
|
||||
ServerManager.MessageReceived -= msgReceived;
|
||||
}
|
||||
TerminalBackend.PrintPrompt();
|
||||
TerminalBackend.PrefixEnabled = true;
|
||||
};
|
||||
|
||||
Console.WriteLine("--contacting multi-user domain...");
|
||||
Thread.Sleep(500);
|
||||
ServerManager.MessageReceived += msgReceived;
|
||||
|
||||
ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new
|
||||
{
|
||||
user = usr,
|
||||
sysname = sys
|
||||
}));
|
||||
Thread.Sleep(500);
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
[Command("brute_decrypt", true)]
|
||||
[RequiresArgument("file")]
|
||||
public static bool BruteDecrypt(Dictionary<string, object> args)
|
||||
{
|
||||
if (FileExists(args["file"].ToString()))
|
||||
{
|
||||
string pass = new Random().Next(1000, 10000).ToString();
|
||||
string fake = "";
|
||||
Console.WriteLine("Beginning brute-force attack on password.");
|
||||
var s = new Stopwatch();
|
||||
s.Start();
|
||||
for(int i = 0; i < pass.Length; i++)
|
||||
{
|
||||
for(int num = 0; num < 10; num++)
|
||||
{
|
||||
if(pass[i].ToString() == num.ToString())
|
||||
{
|
||||
fake += num.ToString();
|
||||
Console.Write(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Stop();
|
||||
|
||||
Console.WriteLine("...password cracked - operation took " + s.ElapsedMilliseconds + " milliseconds.");
|
||||
var tp = new TextPad();
|
||||
AppearanceManager.SetupWindow(tp);
|
||||
WriteAllText("0:/temp.txt", ReadAllText(args["file"].ToString()));
|
||||
tp.LoadFile("0:/temp.txt");
|
||||
Delete("0:/temp.txt");
|
||||
onCompleteDecrypt?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("brute_decrypt: file not found");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Namespace("storydev")]
|
||||
public static class StoryDevCommands
|
||||
{
|
||||
[Command("start", description = "Starts a story plot.", usage ="id:string")]
|
||||
[RequiresArgument("id")]
|
||||
[RemoteLock]
|
||||
public static bool StartStory(Dictionary<string, object> args)
|
||||
{
|
||||
Story.Start(args["id"].ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("list", description ="Lists all story IDs.")]
|
||||
public static bool ListIds()
|
||||
{
|
||||
foreach(var type in ReflectMan.Types)
|
||||
foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute);
|
||||
if (attr != null)
|
||||
Console.WriteLine(" - " + (attr as StoryAttribute).StoryID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("unexperience", description = "Marks a story plot as not-experienced yet.", usage ="id:string")]
|
||||
[RemoteLock]
|
||||
[RequiresArgument("id")]
|
||||
public static bool Unexperience(Dictionary<string, object> args)
|
||||
{
|
||||
string id = args["id"].ToString();
|
||||
if (SaveSystem.CurrentSave.StoriesExperienced.Contains(id))
|
||||
{
|
||||
Console.WriteLine("Unexperiencing " + id + ".");
|
||||
SaveSystem.CurrentSave.StoriesExperienced.Remove(id);
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Story ID not found.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")]
|
||||
[RequiresArgument("id")]
|
||||
[RemoteLock]
|
||||
public static bool Experience(Dictionary<string, object> args)
|
||||
{
|
||||
SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString());
|
||||
SaveSystem.SaveGame();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@ using ShiftOS.Objects;
|
|||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("test")]
|
||||
public class OobeStory
|
||||
{
|
||||
[Command("test")]
|
||||
|
|
|
@ -10,7 +10,6 @@ using ShiftOS.Objects;
|
|||
|
||||
namespace ShiftOS.WinForms.Servers
|
||||
{
|
||||
[Namespace("rts")]
|
||||
[Server("Remote Terminal Server", 21)]
|
||||
//[RequiresUpgrade("story_hacker101_breakingthebonds")] //Uncomment when story is implemented.
|
||||
public class RemoteTerminalServer : Server
|
||||
|
|
|
@ -131,12 +131,6 @@
|
|||
<Compile Include="Applications\Chat.Designer.cs">
|
||||
<DependentUpon>Chat.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Applications\CoherenceOverlay.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Applications\CoherenceOverlay.Designer.cs">
|
||||
<DependentUpon>CoherenceOverlay.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Applications\ColorPicker.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -9,7 +9,6 @@ using ShiftOS.Objects.ShiftFS;
|
|||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("skins")]
|
||||
public static class SkinCommands
|
||||
{
|
||||
[Command("reset")]
|
||||
|
|
|
@ -1,21 +1 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShiftOS.Engine;
|
||||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("test")]
|
||||
public static class TestCommandsForUpgrades
|
||||
{
|
||||
[Command("simpletest")]
|
||||
public static bool Simple()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#define TRAILER
|
||||
#if TRAILER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShiftOS.Engine;
|
||||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
[Namespace("trailer")]
|
||||
public static class TrailerCommands
|
||||
{
|
||||
[Command("init")]
|
||||
public static bool TrailerInit()
|
||||
{
|
||||
var oobe = new Oobe();
|
||||
oobe.StartTrailer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -47,7 +47,6 @@ namespace ShiftOS.WinForms
|
|||
/// <summary>
|
||||
/// Winforms desktop.
|
||||
/// </summary>
|
||||
[Namespace("desktop")]
|
||||
public partial class WinformsDesktop : Form, IDesktop
|
||||
{
|
||||
public MainMenu.MainMenu ParentMenu = null;
|
||||
|
|
|
@ -135,42 +135,6 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Denotes a Terminal command namespace.
|
||||
/// </summary>
|
||||
public class Namespace : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The namespace's name.
|
||||
/// </summary>
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// Whether the namespace should be hidden from the help system. Overrides all child <see cref="Command"/>s' hide values.
|
||||
/// </summary>
|
||||
public bool hide;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Namespace"/>.
|
||||
/// </summary>
|
||||
/// <param name="n">The name of the namespace.</param>
|
||||
public Namespace(string n)
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Namespace"/>.
|
||||
/// </summary>
|
||||
/// <param name="n">The name of the namespace.</param>
|
||||
/// <param name="hide">Whether this namespace should be hidden from the user.</param>
|
||||
public Namespace(string n, bool hide)
|
||||
{
|
||||
name = n;
|
||||
this.hide = hide;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks a Terminal command as obsolete.
|
||||
/// </summary>
|
||||
|
|
|
@ -44,7 +44,6 @@ using ShiftOS.Objects.ShiftFS;
|
|||
|
||||
namespace ShiftOS.Engine
|
||||
{
|
||||
[Namespace("infobox", hide = true)]
|
||||
[RequiresUpgrade("desktop;wm_free_placement")]
|
||||
public static class InfoboxDebugCommands
|
||||
{
|
||||
|
@ -107,7 +106,6 @@ namespace ShiftOS.Engine
|
|||
|
||||
}
|
||||
|
||||
[Namespace("audio")]
|
||||
public static class AudioCommands
|
||||
{
|
||||
[Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")]
|
||||
|
@ -129,79 +127,7 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
}
|
||||
|
||||
[RequiresUpgrade("mud_fundamentals")]
|
||||
[Namespace("mud")]
|
||||
public static class MUDCommands
|
||||
{
|
||||
[MultiplayerOnly]
|
||||
[Command("status")]
|
||||
public static bool Status()
|
||||
{
|
||||
ServerManager.PrintDiagnostics();
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("connect")]
|
||||
public static bool Connect(Dictionary<string, object> args)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me";
|
||||
int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370;
|
||||
try
|
||||
{
|
||||
ServerManager.Initiate(ip, port);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("{ERROR}: " + ex.Message);
|
||||
}
|
||||
|
||||
TerminalBackend.PrefixEnabled = false;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error running script:" + ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Command("reconnect")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool Reconnect()
|
||||
{
|
||||
Console.WriteLine("--reconnecting to multi-user domain...");
|
||||
KernelWatchdog.MudConnected = true;
|
||||
Console.WriteLine("--done.");
|
||||
return true;
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("disconnect")]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
public static bool Disconnect()
|
||||
{
|
||||
Console.WriteLine("--connection to multi-user domain severed...");
|
||||
KernelWatchdog.MudConnected = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Command("sendmsg")]
|
||||
[KernelMode]
|
||||
[RequiresUpgrade("hacker101_deadaccts")]
|
||||
[RequiresArgument("header")]
|
||||
[RequiresArgument("body")]
|
||||
public static bool SendMessage(Dictionary<string, object> args)
|
||||
{
|
||||
ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[TutorialLock]
|
||||
[Namespace("trm")]
|
||||
public static class TerminalCommands
|
||||
{
|
||||
[Command("clear")]
|
||||
|
@ -220,167 +146,6 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
}
|
||||
|
||||
#if DEVEL
|
||||
internal class Rock : Exception
|
||||
{
|
||||
internal Rock() : base("Someone threw a rock at the window, and the Terminal shattered.")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Namespace("dev")]
|
||||
public static class ShiftOSDevCommands
|
||||
{
|
||||
[Command("buy")]
|
||||
public static bool UnlockUpgrade(Dictionary<string, object> args)
|
||||
{
|
||||
string upg = args["id"].ToString();
|
||||
try
|
||||
{
|
||||
SaveSystem.CurrentSave.Upgrades[upg] = true;
|
||||
Shiftorium.InvokeUpgradeInstalled();
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Upgrade not found.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("rock", description = "A little surprise for unstable builds...")]
|
||||
public static bool ThrowASandwichingRock()
|
||||
{
|
||||
Infobox.Show("He who lives in a glass house shouldn't throw stones...", new Rock().Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[Command("unbuy")]
|
||||
[RequiresArgument("upgrade")]
|
||||
public static bool UnbuyUpgrade(Dictionary<string, object> args)
|
||||
{
|
||||
try
|
||||
{
|
||||
SaveSystem.CurrentSave.Upgrades[args["upgrade"].ToString()] = false;
|
||||
SaveSystem.SaveGame();
|
||||
Desktop.PopulateAppLauncher();
|
||||
Desktop.CurrentDesktop.SetupDesktop();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Upgrade not found.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("getallupgrades")]
|
||||
public static bool GetAllUpgrades()
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(SaveSystem.CurrentSave.Upgrades, Formatting.Indented));
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("multarg")]
|
||||
[RequiresArgument("id")]
|
||||
[RequiresArgument("name")]
|
||||
[RequiresArgument("type")]
|
||||
public static bool MultArg(Dictionary<string, object> args)
|
||||
{
|
||||
Console.WriteLine("Success! "+args.ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("restart")]
|
||||
public static bool Restart()
|
||||
{
|
||||
SaveSystem.CurrentSave.Upgrades = new Dictionary<string, bool>();
|
||||
SaveSystem.CurrentSave.Codepoints = 0;
|
||||
SaveSystem.CurrentSave.StoriesExperienced.Clear();
|
||||
SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals");
|
||||
SaveSystem.SaveGame();
|
||||
Shiftorium.InvokeUpgradeInstalled();
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("freecp")]
|
||||
public static bool FreeCodepoints(Dictionary<string, object> args)
|
||||
{
|
||||
if (args.ContainsKey("amount"))
|
||||
try
|
||||
{
|
||||
ulong codepointsToAdd = Convert.ToUInt64(args["amount"].ToString());
|
||||
SaveSystem.CurrentSave.Codepoints += codepointsToAdd;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("{ERROR}: " + ex.Message);
|
||||
return true;
|
||||
}
|
||||
|
||||
SaveSystem.CurrentSave.Codepoints += 1000;
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("unlockeverything")]
|
||||
public static bool UnlockAllUpgrades()
|
||||
{
|
||||
foreach (var upg in Shiftorium.GetDefaults())
|
||||
{
|
||||
if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.ID))
|
||||
SaveSystem.CurrentSave.Upgrades.Add(upg.ID, true);
|
||||
else
|
||||
SaveSystem.CurrentSave.Upgrades[upg.ID] = true;
|
||||
}
|
||||
Shiftorium.InvokeUpgradeInstalled();
|
||||
SkinEngine.LoadSkin();
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("info")]
|
||||
public static bool DevInformation()
|
||||
{
|
||||
Console.WriteLine("{SHIFTOS_PLUS_MOTTO}");
|
||||
Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version);
|
||||
return true;
|
||||
}
|
||||
[Command("pullfile")]
|
||||
public static bool PullFile(Dictionary<string, object> args)
|
||||
{
|
||||
if (args.ContainsKey("physical") && args.ContainsKey("virtual"))
|
||||
{
|
||||
string file = (string)args["physical"];
|
||||
string dest = (string)args["virtual"];
|
||||
if (System.IO.File.Exists(file))
|
||||
{
|
||||
Console.WriteLine("Pulling physical file to virtual drive...");
|
||||
byte[] filebytes = System.IO.File.ReadAllBytes(file);
|
||||
ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("The specified file does not exist on the physical drive.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("You must supply a physical path.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
[Command("crash")]
|
||||
public static bool CrashInstantly()
|
||||
{
|
||||
CrashHandler.Start(new Exception("ShiftOS was sent a command to forcefully crash."));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Namespace("sos")]
|
||||
public static class ShiftOSCommands
|
||||
{
|
||||
|
||||
|
@ -478,38 +243,17 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
|
||||
[Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")]
|
||||
public static bool Help(Dictionary<string, object> args)
|
||||
public static bool Help()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("Retrieving help data.");
|
||||
|
||||
if (args.ContainsKey("ns"))
|
||||
//print all unique namespaces.
|
||||
foreach (var n in TerminalBackend.Commands.Select(x => x.CommandInfo).Distinct().OrderBy(x=>x.name))
|
||||
{
|
||||
string ns = args["ns"].ToString();
|
||||
//First let's check for a command that has this namespace.
|
||||
var cmdtest = TerminalBackend.Commands.FirstOrDefault(x => x.NamespaceInfo.name == ns);
|
||||
if (cmdtest == null) //Namespace not found.
|
||||
sb.AppendLine("Error retrieving help for namespace \"" + ns + "\". Namespace not found.");
|
||||
else
|
||||
{
|
||||
//Now do the actual scan.
|
||||
sb.AppendLine("Namespace: " + ns);
|
||||
foreach(var cmd in TerminalBackend.Commands.Where(x => x.NamespaceInfo.name == ns))
|
||||
{
|
||||
string str = cmd.ToString();
|
||||
str = str.Replace(str.Substring(str.LastIndexOf("|")), "");
|
||||
sb.AppendLine(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//print all unique namespaces.
|
||||
foreach(var n in TerminalBackend.Commands.Select(x => x.NamespaceInfo.name).Distinct())
|
||||
{
|
||||
sb.AppendLine("sos.help{ns:\"" + n + "\"}");
|
||||
}
|
||||
sb.Append(n.name);
|
||||
if (Shiftorium.UpgradeInstalled("help_descriptions"))
|
||||
sb.Append(" - " + n.description);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
Console.WriteLine(sb.ToString());
|
||||
|
@ -565,7 +309,6 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed,
|
|||
}
|
||||
|
||||
[MultiplayerOnly]
|
||||
[Namespace("shiftorium")]
|
||||
public static class ShiftoriumCommands
|
||||
{
|
||||
[Command("buy")]
|
||||
|
@ -668,7 +411,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
|
|||
return true;
|
||||
}
|
||||
|
||||
[Command("list")]
|
||||
[Command("shiftorium", description ="Lists all available Shiftorium upgrades.")]
|
||||
public static bool ListAll(Dictionary<string, object> args)
|
||||
{
|
||||
try
|
||||
|
@ -742,7 +485,6 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}");
|
|||
}
|
||||
}
|
||||
|
||||
[Namespace("win")]
|
||||
public static class WindowCommands
|
||||
{
|
||||
|
||||
|
|
|
@ -291,7 +291,6 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
[Namespace("dev")]
|
||||
public static class PythonCmds
|
||||
{
|
||||
[Command("runpystring", description = "Run some Python code. (Only present in DEBUG builds of ShiftOS)")]
|
||||
|
|
|
@ -104,7 +104,6 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
[Namespace("dev")]
|
||||
public static class ReflectDebug
|
||||
{
|
||||
[Command("listalltypes", description = "List all types that were found by ReflectMan. Only present in DEBUG builds of ShiftOS.")]
|
||||
|
|
|
@ -148,7 +148,6 @@ namespace ShiftOS.Engine
|
|||
return hash;
|
||||
}
|
||||
|
||||
public Namespace NamespaceInfo { get; set; }
|
||||
public Command CommandInfo { get; set; }
|
||||
|
||||
public List<string> RequiredArguments { get; set; }
|
||||
|
@ -161,16 +160,14 @@ namespace ShiftOS.Engine
|
|||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(this.NamespaceInfo.name);
|
||||
sb.Append(".");
|
||||
sb.Append(this.CommandInfo.name);
|
||||
if (this.RequiredArguments.Count > 0)
|
||||
{
|
||||
sb.Append("{");
|
||||
sb.Append(" ");
|
||||
foreach (var arg in RequiredArguments)
|
||||
{
|
||||
sb.Append(arg);
|
||||
sb.Append(":");
|
||||
sb.Append("--" + arg);
|
||||
sb.Append(" ");
|
||||
if (RequiredArguments.IndexOf(arg) < RequiredArguments.Count - 1)
|
||||
sb.Append(',');
|
||||
}
|
||||
|
@ -295,41 +292,42 @@ namespace ShiftOS.Engine
|
|||
public static void PopulateTerminalCommands()
|
||||
{
|
||||
Commands = new List<TerminalCommand>();
|
||||
foreach(var type in ReflectMan.Types)
|
||||
foreach (var type in ReflectMan.Types)
|
||||
{
|
||||
var ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace;
|
||||
if(ns != null)
|
||||
foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command);
|
||||
if (cmd != null)
|
||||
{
|
||||
var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command);
|
||||
if(cmd != null)
|
||||
var tc = new TerminalCommand();
|
||||
tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null);
|
||||
|
||||
|
||||
tc.CommandInfo = cmd as Command;
|
||||
tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null);
|
||||
tc.RequiredArguments = new List<string>();
|
||||
foreach (var arg in mth.GetCustomAttributes(false).Where(x => x is RequiresArgument))
|
||||
{
|
||||
var tc = new TerminalCommand();
|
||||
tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null);
|
||||
|
||||
tc.NamespaceInfo = ns;
|
||||
|
||||
tc.CommandInfo = cmd as Command;
|
||||
tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null);
|
||||
tc.RequiredArguments = new List<string>();
|
||||
foreach (var arg in mth.GetCustomAttributes(false).Where(x=>x is RequiresArgument))
|
||||
{
|
||||
var rarg = arg as RequiresArgument;
|
||||
tc.RequiredArguments.Add(rarg.argument);
|
||||
}
|
||||
var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute;
|
||||
if (rupg != null)
|
||||
tc.Dependencies = rupg.Upgrade;
|
||||
else
|
||||
tc.Dependencies = "";
|
||||
tc.CommandType = type;
|
||||
tc.CommandHandler = mth;
|
||||
if (!Commands.Contains(tc))
|
||||
Commands.Add(tc);
|
||||
var rarg = arg as RequiresArgument;
|
||||
tc.RequiredArguments.Add(rarg.argument);
|
||||
}
|
||||
var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute;
|
||||
if (rupg != null)
|
||||
tc.Dependencies = rupg.Upgrade;
|
||||
else
|
||||
tc.Dependencies = "";
|
||||
tc.CommandType = type;
|
||||
tc.CommandHandler = mth;
|
||||
|
||||
var ambiguity = Commands.FirstOrDefault(x => x.CommandInfo.name == tc.CommandInfo.name);
|
||||
if (ambiguity != null)
|
||||
throw new Exception("Command ambiguity error. You can't have two commands with the same name: " + $"{tc} == {ambiguity}");
|
||||
|
||||
if (!Commands.Contains(tc))
|
||||
Commands.Add(tc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Console.WriteLine("[termdb] " + Commands.Count + " commands found.");
|
||||
}
|
||||
|
@ -465,7 +463,7 @@ namespace ShiftOS.Engine
|
|||
|
||||
|
||||
string[] split = text.Split('.');
|
||||
var cmd = Commands.FirstOrDefault(x => x.NamespaceInfo.name == split[0] && x.CommandInfo.name == split[1]);
|
||||
var cmd = Commands.FirstOrDefault(x => x.CommandInfo.name == text);
|
||||
if (cmd == null)
|
||||
return false;
|
||||
if (!Shiftorium.UpgradeInstalled(cmd.Dependencies))
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace ShiftOS.Engine
|
|||
/// <summary>
|
||||
/// Administrative user management terminal commands.
|
||||
/// </summary>
|
||||
[Namespace("admin")]
|
||||
[KernelMode]
|
||||
[RequiresUpgrade("mud_fundamentals")]
|
||||
public static class AdminUserManagementCommands
|
||||
|
@ -173,7 +172,6 @@ namespace ShiftOS.Engine
|
|||
/// <summary>
|
||||
/// Non-administrative user management terminal commands.
|
||||
/// </summary>
|
||||
[Namespace("user")]
|
||||
[RequiresUpgrade("mud_fundamentals")]
|
||||
public static class UserManagementCommands
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue