Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
little things
Browse files Browse the repository at this point in the history
  • Loading branch information
felikcat committed Dec 10, 2024
1 parent 484878c commit de3c621
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 52 deletions.
103 changes: 57 additions & 46 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,17 @@ mod disable_vbs;
mod reduce_forensics;
mod reduce_online_data_collection;
mod remove_w11boost;
mod disable_recall;

use fltk::{
app::{self, Screen},
button::{Button, CheckButton},
dialog,
draw::{self},
enums::{self, Color},
frame::{self},
prelude::*,
widget::Widget,
window::Window,
app::{self, Screen}, button::{Button, CheckButton}, dialog, draw::{self}, enums::{self, Color}, frame::{self}, prelude::*, widget::Widget, window::Window
};
use fltk_theme::{ColorTheme, color_themes};
use std::{
borrow::{Borrow, BorrowMut},
cell::{Ref, RefCell},
borrow::BorrowMut,
cell::RefCell,
error::Error,
mem,
ops::DerefMut,
process::{exit, Command},
rc::Rc,
};
Expand All @@ -35,30 +27,30 @@ use windows::Win32::{
HWND_TOPMOST, SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE, SWP_SHOWWINDOW, SetWindowPos,
},
};

use crate::common::center;
type MyCheckboxes = [RefCell<CheckButton>; 9];

type MyCheckboxes = Vec<RefCell<CheckButton>>;

pub fn draw_gui() -> Result<(), Box<dyn Error>> {
let app = app::App::default().with_scheme(app::Scheme::Gtk);
let font = app.load_font("C:\\Windows\\Fonts\\segoeui.ttf").unwrap();

let mut wind = Window::default()
.with_label("W11Boost")
.with_size(480, 480)
.with_size(640, 480)
.center_screen();

wind.set_border(false);

let widget_theme = ColorTheme::new(color_themes::BLACK_THEME);
widget_theme.apply();

let mut titlebar = frame::Frame::new(0, 0, 480, 32, None);
let mut titlebar = frame::Frame::new(0, 0, wind.width(), 32, None);

titlebar.set_frame(enums::FrameType::FlatBox);
titlebar.set_color(Color::from_rgb(22, 22, 22));

let mut titlebar_close = Button::new(wind.width() - 32, 0, 32, 32, "X");

titlebar_close.set_frame(enums::FrameType::NoBox);
titlebar_close.set_callback(move |_| exit(0));

Expand All @@ -69,13 +61,6 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
(wind.height() * 14) / 100,
"Apply W11Boost",
).center_of(&wind)));

let apply = Rc::clone(&apply);

let mut apply_mut = (*apply).borrow_mut();

let apply_height = apply_mut.clone().height();
apply_mut.set_pos(2, wind.height() - apply_height - 2); // Put button at the bottom

let remove = Rc::new(RefCell::new(Button::new(
wind.width() / 2,
Expand All @@ -84,6 +69,12 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
(wind.height() * 14) / 100,
"Remove W11Boost",
)));

let apply = Rc::clone(&apply);
let mut apply_mut = (*apply).borrow_mut();

let apply_height = apply_mut.clone().height();
apply_mut.set_pos(2, wind.height() - apply_height - 2); // Put the apply button at the bottom; wow!

let remove = Rc::clone(&remove);
let mut remove_mut = (*remove).borrow_mut();
Expand All @@ -105,82 +96,94 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {

let checkbox_height = wind.height() / 12;

let mut my_checkboxes: MyCheckboxes = [
let my_checkboxes: MyCheckboxes = [
RefCell::new(CheckButton::new(
0,
titlebar.height(),
wind.width(),
wind.width() / 2,
checkbox_height,
"Reduce local data / forensics to a minimum",
"Minimize local data / forensics",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height + 2,
wind.width(),
wind.width() / 2,
checkbox_height,
"Reduce online activity to a minimum",
"Minimize Microsoft online data",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 2 + 4,
wind.width(),
wind.width() / 2,
checkbox_height,
"Create a system restore point",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 3 + 6,
wind.width(),
wind.width() / 2,
checkbox_height,
"Install the Microsoft Store",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 4 + 8,
wind.width(),
wind.width() / 2,
checkbox_height,
"Install support for .appx/.appxbundle and WinGet",
"Install support for UWP and WinGet",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 5 + 10,
wind.width(),
wind.width() / 2,
checkbox_height,
"Disable Defender and SmartScreen",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 6 + 12,
wind.width(),
wind.width() / 2,
checkbox_height,
"Disable sleep and hibernate",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 7 + 14,
wind.width(),
wind.width() / 2,
checkbox_height,
"Disable Virtualization Based Security",
)),
RefCell::new(CheckButton::new(
0,
titlebar.height() + checkbox_height * 8 + 16,
wind.width(),
wind.width() / 2,
checkbox_height,
"Add in non-intrusive tweaks",
)),
];

let my_checkboxes = my_checkboxes.clone();
RefCell::new(CheckButton::new(
wind.width() / 2,
titlebar.height(),
wind.width() / 2,
checkbox_height,
"Disable Windows Recall",
)),
RefCell::new(CheckButton::new(
wind.width() / 2,
titlebar.height() + checkbox_height,
wind.width() / 2,
checkbox_height,
"Disable Windows Copilot",
)),
].to_vec();

for checkbox in &my_checkboxes {
let mut checkbox = checkbox.borrow_mut();
checkbox.set_label_font(enums::Font::by_name(&font));
checkbox.set_label_size(16);
}

my_checkboxes[2].borrow_mut().set_value(true);
my_checkboxes[8].borrow_mut().set_value(true);
my_checkboxes[2].borrow_mut().set_value(true); // "Create a system restore point"
my_checkboxes[8].borrow_mut().set_value(true); // "Add in non-intrusive tweaks"

let frame0 = RefCell::new(
Widget::default()
Expand Down Expand Up @@ -294,6 +297,7 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
checkbox.borrow_mut().show();
}
}

(*apply_mut).set_callback({
let frame0 = frame0.clone();
let apply = apply.clone();
Expand Down Expand Up @@ -354,25 +358,31 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
}
}

if let Ok(mut checkbox) = my_checkboxes[6].try_borrow_mut() {
if let Ok(checkbox) = my_checkboxes[6].try_borrow_mut() {
if checkbox.is_checked() {
disable_sleep::run().expect("disable_sleep::run failed");
}
}

if let Ok(mut checkbox) = my_checkboxes[7].try_borrow_mut() {
if let Ok(checkbox) = my_checkboxes[7].try_borrow_mut() {
if checkbox.is_checked() {
disable_vbs::run().expect("disable_vbs::run failed");
}
}

if let Ok(mut checkbox) = my_checkboxes[8].try_borrow_mut() {
if let Ok(checkbox) = my_checkboxes[8].try_borrow_mut() {
if checkbox.is_checked() {
defaults::run().expect("defaults::run failed");
}
}

if my_checkboxes.iter().all(|checkbox| checkbox.try_borrow_mut().map_or(false, |mut cb| !cb.is_checked())) {
if let Ok(checkbox) = my_checkboxes[9].try_borrow_mut() {
if checkbox.is_checked() {
disable_recall::run().expect("disable_recall::run failed");
}
}

if my_checkboxes.iter().all(|checkbox| checkbox.try_borrow_mut().map_or(false, | cb| !cb.is_checked())) {
dialog::message(
center().0,
center().1,
Expand Down Expand Up @@ -438,5 +448,6 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
});

app.run().unwrap();

Ok(())
}
8 changes: 4 additions & 4 deletions src/gui/disable_defender_and_smartscreen.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::common::*;
//use fltk::dialog;
use fltk::dialog;
use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_LOCAL_MACHINE}}};
use std::error::Error;
//use winsafe::{HKEY as HKEY_SAFE, prelude::advapi_Hkey};
use winsafe::{HKEY as HKEY_SAFE, prelude::advapi_Hkey};

pub fn run() -> Result<(), Box<dyn Error>> {
let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?;
/* Not necessary, for now.

let hklm_safe = HKEY_SAFE::LOCAL_MACHINE;
let tamper_disabled = check_dword(
&hklm_safe,
Expand All @@ -21,14 +21,14 @@ pub fn run() -> Result<(), Box<dyn Error>> {
1,
)?;

// Not necessary, but it will be later.
if !tamper_disabled || !realtime_disabled {
dialog::alert(
center().0,
center().1,
"Windows Defender's \"Tamper Protection\" or \"Real-time protection\" is enabled.\nDisable both now, then close this dialog.",
);
}
*/

// Diasble anti-tamper.
set_dword_gpo(
Expand Down
18 changes: 18 additions & 0 deletions src/gui/disable_recall.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::error::Error;
use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_LOCAL_MACHINE}}};
use crate::common::*;

pub fn run() -> Result<(), Box<dyn Error>>{
let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?;

set_dword_gpo(
hklm,
w!(r"SOFTWARE\Policies\Microsoft\Windows\WindowsAI"),
w!("AllowRecallEnablement"),
0,
)?;

save_registry_gpo(hklm, gpo_hklm)?;

Ok(())
}
1 change: 0 additions & 1 deletion src/gui/disable_vbs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::error::Error;
use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_LOCAL_MACHINE}}};

use crate::common::*;

pub fn run() -> Result<(), Box<dyn Error>> {
Expand Down
10 changes: 9 additions & 1 deletion src/gui/reduce_online_data_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn run() -> Result<(), Box<dyn Error>> {
// Don't automatically download a new speech model.
set_dword(
&hklm,
r"Machine\SOFTWARE\Policies\Microsoft\Speech",
r"SOFTWARE\Policies\Microsoft\Speech",
"AllowSpeechModelUpdate",
0,
)?;
Expand All @@ -172,6 +172,14 @@ pub fn run() -> Result<(), Box<dyn Error>> {
"AllowNewsAndInterests",
0,
)?;

// Disable an extra lockscreen that is mainly served to put widgets on.
set_dword(
&hklm,
r"Software\Policies\Microsoft\Windows\Personalization",
"NoLockScreen",
1,
)?;

Ok(())
}

0 comments on commit de3c621

Please sign in to comment.