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

Commit

Permalink
1.4 WIP4
Browse files Browse the repository at this point in the history
  • Loading branch information
felikcat committed Dec 8, 2024
1 parent c683bd0 commit f379b7c
Show file tree
Hide file tree
Showing 10 changed files with 717 additions and 464 deletions.
Binary file modified Images/W11Boost_GUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,30 @@ Although, the default checkbox selection is safe for most users as it is as clos

. Open the Command Prompt as administrator.
. `cscript.exe %windir%\system32\slmgr.vbs /upk`
. `cscript.exe %windir%\system32\slmgr.vbs /ipk NW6C2-QMPVW-D7KKK-3GKT6-VCFB2`
. `changepk.exe /ProductKey YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY`
. Use https://github.com/massgravel/Microsoft-Activation-Scripts?tab=readme-ov-file#method-1---powershell-windows-8-and-later-%EF%B8%8F[MAS] or https://github.com/abbodi1406/KMS_VL_ALL_AIO/releases[KMS_VL_ALL_AIO] to activate Windows by installing its auto-renewal.
- To open a .7z archive on Windows, you need https://www.7-zip.org/[7-Zip].

== 2. Installing W11Boost

. Download and run the https://github.com/felikcat/W11Boost/releases[latest release of W11Boost]. +
Only Windows 10 version 1803 and newer are officially supported.
- The near guarantee of breaking no program or app is only for the default checkbox (option) selection.
. Install the latest https://aka.ms/vs/17/release/vc_redist.x64.exe[Visual Studio Redistributable].

. Download and run the https://github.com/felikcat/W11Boost/releases[latest release of W11Boost].

. W11Boost usage:
- Only Windows 10 version 1803 and newer are officially supported.
- The near guarantee of breaking no program or app is only for the default selection of checkboxes.

- "Reduce local data collection" is very aggressive, it compromises security for ultimate privacy. It will make forensics on your computer difficult.
- "Reduce online data collection" will change how you use Windows; this does not affect the security of Windows.

- "Reduce online data collection" will change how you use Windows; this also affects the security of Windows.

- Installing the Microsoft Store and .appx support is generally for LTSC builds of Windows, but works on any edition regardless.

- "Disable Defender and Smartscreen" is a replacement for Sordum's Defender Control v2.1.

- "Disable Virtualization Based Security" is meant to boost FPS in games and especially make VMs (VirtualBox & VMWare) run faster.

. Install https://winaerotweaker.com/[Winaero Tweaker] to set personal preferences.

. Download https://github.com/beatcracker/toptout/archive/refs/heads/master.zip[toptout] and open PowerShell as administrator:
Expand Down
104 changes: 87 additions & 17 deletions src/common.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
use chrono::{Datelike, Timelike, Utc};
use fltk::app;
use windows::core::{PCWSTR, PWSTR};
use windows::Win32::Foundation::ERROR_SUCCESS;
use windows::Win32::System::Registry::{RegCloseKey, RegCreateKeyW, RegSetValueExW, REG_DWORD, REG_SZ};
use std::error::Error;
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::PathBuf;
use windows::Win32::Foundation::ERROR_SUCCESS;
use windows::Win32::System::Registry::{REG_DWORD, REG_SZ, RegCreateKeyW, RegSetValueExW};
use windows::core::PCWSTR;
use windows::{
Win32::System::{
Com::{CLSCTX_INPROC_SERVER, COINIT_APARTMENTTHREADED, CoCreateInstance, CoInitializeEx},
GroupPolicy::{
CLSID_GroupPolicyObject, GPO_OPEN_LOAD_REGISTRY, GPO_SECTION_MACHINE,
IGroupPolicyObject, REGISTRY_EXTENSION_GUID,
},
Registry::RegCloseKey,
},
core::GUID,
};
use winsafe::{
self as w, HKEY, RegistryValue,
co::{self, KNOWNFOLDERID},
Expand All @@ -26,43 +37,55 @@ pub fn set_dword_gpo(
) -> Result<(), Box<dyn Error>> {
unsafe {
let mut new_key: windows::Win32::System::Registry::HKEY = hkey;

let result = RegCreateKeyW(new_key, subkey, &mut new_key);
if result != ERROR_SUCCESS {
return Err(format!("Failed to create key: {:?}", result).into());
return Err(format!("[set_dword_gpo] Failed to create key: {:?}", result).into());
}

let bytes = value.to_ne_bytes();
let set_result = RegSetValueExW(new_key, value_name, 0, REG_DWORD, Some(&bytes));

let close_result = RegCloseKey(new_key);

if set_result != ERROR_SUCCESS {
return Err(format!("Failed to set key value: {:?}", set_result).into());

let result = RegSetValueExW(new_key, value_name, 0, REG_DWORD, Some(&bytes));
if result != ERROR_SUCCESS {
return Err(format!("[set_dword_gpo] Failed to set key value: {:?}", result).into());
}
if close_result != ERROR_SUCCESS {
return Err(format!("Failed to close key: {:?}", close_result).into());

let result = RegCloseKey(new_key);
if result != ERROR_SUCCESS {
return Err(format!("[set_dword_gpo] Failed to close key: {:?}", result).into());
}
}
Ok(())
}

pub fn set_string_gpo(
hkey: &mut windows::Win32::System::Registry::HKEY,
hkey: windows::Win32::System::Registry::HKEY,
subkey: PCWSTR,
value_name: PCWSTR,
value: PCWSTR,
) -> Result<(), Box<dyn Error>> {
unsafe {
RegCreateKeyW(*hkey, subkey, hkey);

let mut new_key: windows::Win32::System::Registry::HKEY = hkey;

let result = RegCreateKeyW(new_key, subkey, &mut new_key);
if result != ERROR_SUCCESS {
return Err(format!("[set_string_gpo] Failed to create key: {:?}", result).into());
}

let bytes = value.as_wide();
let length = bytes.len().checked_mul(2).unwrap();
let bytes_cast: *const u8 = bytes.as_ptr().cast();
let slice = std::slice::from_raw_parts(bytes_cast, length);

RegSetValueExW(*hkey, value_name, 0, REG_SZ, Some(slice));
let result = RegSetValueExW(new_key, value_name, 0, REG_SZ, Some(slice));
if result.is_err() {
return Err(format!("[set_string_gpo] Failed to set key: {:?}", result).into());
}

RegCloseKey(*hkey);
let result = RegCloseKey(new_key);
if result.is_err() {
return Err(format!("[set_string_gpo] Failed to close key: {:?}", result).into());
}
}
Ok(())
}
Expand Down Expand Up @@ -275,3 +298,50 @@ pub fn center() -> (i32, i32) {
(app::screen_size().1 / 2.0) as i32,
)
}

pub fn init_registry_gpo(
hkey: windows::Win32::System::Registry::HKEY,
) -> Result<(windows::Win32::System::Registry::HKEY, IGroupPolicyObject), Box<dyn Error>> {
unsafe {
// The apartment thread model is required for GPOs.
let result = CoInitializeEx(None, COINIT_APARTMENTTHREADED);
if result.is_err() {
return Err(format!("Failed to run CoInitalizeEx: {:?}", result).into());
}
let gpo: IGroupPolicyObject =
CoCreateInstance(&CLSID_GroupPolicyObject, None, CLSCTX_INPROC_SERVER)
.expect("Failed to create GPO object");

gpo.OpenLocalMachineGPO(GPO_OPEN_LOAD_REGISTRY)
.expect("Failed to open local machine GPO");

gpo.GetRegistryKey(GPO_SECTION_MACHINE, &mut hkey)
.expect("GetRegistryKey failed");

Ok((hkey, gpo))
}
}

pub fn save_registry_gpo(
hkey: windows::Win32::System::Registry::HKEY,
gpo: IGroupPolicyObject,
) -> Result<(), Box<dyn Error>> {
let mut snap_guid = GUID::from_u128(0x0f6b957e_509e_11d1_a7cc_0000f87571e3);
let mut registry_guid = REGISTRY_EXTENSION_GUID;
unsafe {
gpo.Save::<bool, bool>(
true.into(),
false.into(),
&mut registry_guid,
&mut snap_guid,
)
.expect("Failed to save GPO changes");
}

let result = unsafe { RegCloseKey(hkey) };
if result.is_err() {
eprintln!("RegCloseKey failed");
}

Ok(())
}
45 changes: 38 additions & 7 deletions src/gui.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
pub mod appx_support;
mod appx_support;
mod create_system_restore_point;
mod defaults;
mod disable_sleep;
mod reduce_forensics;
mod reduce_online_data_collection;
mod disable_defender_and_smartscreen;
mod disable_vbs;

use fltk::{
app::{self, Screen}, button::{Button, CheckButton}, 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::{
Expand All @@ -21,15 +22,17 @@ use windows::Win32::{
HWND_TOPMOST, SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE, SWP_SHOWWINDOW, SetWindowPos,
},
};
type MyCheckboxes = [CheckButton; 7];

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

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, 420)
.with_size(480, 480)
.center_screen();

wind.set_border(false);
Expand All @@ -50,7 +53,7 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
0,
0,
wind.width() - 2,
wind.height() / 10 * 2,
(wind.height() * 14) / 100,
"Apply W11Boost",
)
.center_of(&wind);
Expand Down Expand Up @@ -115,14 +118,29 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
checkbox_height,
"Disable sleep and hibernate",
),
CheckButton::new(
0,
titlebar.height() + checkbox_height * 7 + 14,
wind.width(),
checkbox_height,
"Disable Virtualization Based Security",
),
CheckButton::new(
0,
titlebar.height() + checkbox_height * 8 + 16,
wind.width(),
checkbox_height,
"Add in non-intrusive tweaks",
),
];

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

let hklm_safe = HKEY::HKEY_LOCAL_MACHINE
my_checkboxes[2].set_value(true);
my_checkboxes[8].set_value(true);

let mut frame0 = Widget::default()
.with_size(wind.width(), wind.height() - titlebar.height())
Expand Down Expand Up @@ -237,7 +255,20 @@ pub fn draw_gui() -> Result<(), Box<dyn Error>> {
if my_checkboxes[6].is_checked() {
disable_sleep::run().expect("disable_sleep::run failed");
}
defaults::run().expect("defaults::run failed");

if my_checkboxes[7].is_checked() {
disable_vbs::run().expect("disable_vbs::run failed");
}

if my_checkboxes[8].is_checked() {
defaults::run().expect("defaults::run failed");
}

if my_checkboxes.iter().all(|checkbox| !checkbox.is_checked()) {
dialog::message(center().0, center().1, "No options were selected, therefore nothing has changed.");
} else {
dialog::message(center().0, center().1, "W11Boost applied your preferences successfully, please reboot.");
}

// Does not require a manual redraw.
frame0.hide();
Expand Down
Loading

0 comments on commit f379b7c

Please sign in to comment.