Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project are documented here.
This project adheres to [Semantic Versioning](https://semver.org/).

## [2.3.3] — 2026-10-18

### Fixed
- **Hidden apps no longer lag or glitch.** HideMyWindows used to reach into
every hidden app once a second to re-check its protection. It now checks
only when the app's windows change (or every 15 seconds), and the helper
inside hidden apps does far less work per window event.

### Added
- **Settings: turn off the protection checker** if you don't need it.
- **Settings: Quick Launch only** — hide only apps started from Quick Launch;
rules are paused while it is on.

## [2.3.2] — 2026-10-14

**Save your work before updating.** The update to 2.3.1 could close other
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["hmw-core", "hmw-release", "payload", "src-tauri"]

[workspace.package]
version = "2.3.2"
version = "2.3.3"
edition = "2021"
license = "MIT"
repository = "https://github.com/mehdimamas/hidemywindows"
Expand Down
29 changes: 29 additions & 0 deletions hmw-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ pub struct Config {

#[serde(default)]
pub quick_launch: Vec<QuickLaunchEntry>,

/// Periodically re-verify capture exclusion on already-hidden processes.
/// Off means hiding still happens (at launch and via the in-process
/// payload worker), but the controller stops re-checking from outside.
#[serde(default = "default_true")]
pub protection_checker: bool,

/// When on, the window-rule watcher does no listing, no rule passes and
/// no injection; only Quick Launch entries are hidden at launch.
#[serde(default)]
pub quick_launch_only: bool,
}

impl Default for Config {
Expand All @@ -100,6 +111,8 @@ impl Default for Config {
tour_completed: false,
window_rules: Vec::new(),
quick_launch: Vec::new(),
protection_checker: true,
quick_launch_only: false,
}
}
}
Expand Down Expand Up @@ -176,6 +189,22 @@ mod tests {
assert_eq!(cfg.normal_launch_pause_until_ms, 0);
}

#[test]
fn new_fields_default_on_old_config() {
// An old config file, saved before these fields existed, must load
// with the checker on and Quick Launch only off.
let cfg: Config = serde_json::from_str(r#"{"hideSelf":true}"#).unwrap();
assert!(cfg.protection_checker);
assert!(!cfg.quick_launch_only);
}

#[test]
fn defaults_match_documented_behavior() {
let cfg = Config::default();
assert!(cfg.protection_checker);
assert!(!cfg.quick_launch_only);
}

#[test]
fn timed_pause_survives_serialization_and_resumes_at_deadline() {
let cfg = Config {
Expand Down
49 changes: 49 additions & 0 deletions hmw-core/src/hider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,52 @@ pub fn check_protection(pid: u32, payload_path: &str) -> Result<()> {
))
})
}

/// How long a steady target goes without a protection health check.
pub const PROTECTION_RECHECK: std::time::Duration = std::time::Duration::from_secs(15);

/// Decides when `check_protection` is worth a remote thread. A target is
/// checked when its visible window set changed since the last check, or when
/// the last check is older than `PROTECTION_RECHECK`.
#[derive(Debug, Default)]
pub struct ProtectionThrottle {
seen: std::collections::HashMap<u32, (u64, std::time::Instant)>,
}

impl ProtectionThrottle {
/// True when `pid` should be checked now; records the check when it is.
pub fn due(&mut self, pid: u32, signature: u64, now: std::time::Instant) -> bool {
match self.seen.get(&pid) {
Some(&(last, at))
if last == signature && now.duration_since(at) < PROTECTION_RECHECK =>
{
false
}
_ => {
self.seen.insert(pid, (signature, now));
true
}
}
}

/// Forget a pid, so its next check is immediate.
pub fn forget(&mut self, pid: u32) {
self.seen.remove(&pid);
}

/// Drop entries for pids no longer being tracked.
pub fn retain(&mut self, keep: impl Fn(u32) -> bool) {
self.seen.retain(|&pid, _| keep(pid));
}
}

/// Order-independent fingerprint of a set of window handles.
pub fn window_signature(hwnds: impl IntoIterator<Item = isize>) -> u64 {
hwnds.into_iter().fold(0u64, |acc, h| {
acc.wrapping_add(
(h as u64)
.wrapping_mul(0x9E37_79B9_7F4A_7C15)
.rotate_left(17),
)
})
}
43 changes: 42 additions & 1 deletion hmw-core/src/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,49 @@ pub fn call_export(pid: u32, payload_path: &str, export: &str, hwnd: isize) -> R
}
}

// A loaded payload keeps its base for the life of the process. Remember it
// per (pid, start time, path) so steady targets skip the module snapshot.
let started = crate::process::process_started_at(pid);
if let Some(started) = started {
if let Some(base) = cached_base(pid, started, payload_path) {
match run_export(&handle, base, export, hwnd) {
Ok(()) => return Ok(()),
Err(_) => forget_base(pid),
}
}
}
let base = ensure_loaded(&handle, pid, payload_path)?;
run_export(&handle, base, export, hwnd)
let result = run_export(&handle, base, export, hwnd);
match (&result, started) {
(Ok(()), Some(started)) => remember_base(pid, started, payload_path, base),
_ => forget_base(pid),
}
result
}

type BaseCache = std::collections::HashMap<u32, (u64, String, isize)>;

fn base_cache() -> std::sync::MutexGuard<'static, BaseCache> {
static CACHE: std::sync::OnceLock<std::sync::Mutex<BaseCache>> = std::sync::OnceLock::new();
CACHE
.get_or_init(Default::default)
.lock()
.unwrap_or_else(|p| p.into_inner())
}

fn cached_base(pid: u32, started: u64, payload_path: &str) -> Option<isize> {
match base_cache().get(&pid) {
Some((s, path, base)) if *s == started && path == payload_path => Some(*base),
_ => None,
}
}

fn remember_base(pid: u32, started: u64, payload_path: &str, base: isize) {
base_cache().insert(pid, (started, payload_path.to_string(), base));
}

fn forget_base(pid: u32) {
base_cache().remove(&pid);
}

/// Start `export` of the payload at `base` in the target and wait for it.
Expand Down
43 changes: 43 additions & 0 deletions hmw-core/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ fn staged_payload(payload_path: &str) -> Result<String> {
if dest.parent().is_none_or(|dir| !dir.is_dir()) {
return Ok(payload_path.to_string());
}
// Steady state: the staged copy is current, so leave the file alone.
if let (Ok(src), Ok(dst)) = (std::fs::metadata(payload_path), std::fs::metadata(&dest)) {
if src.len() == dst.len() && src.modified().ok() == dst.modified().ok() {
return Ok(dest.to_string_lossy().into_owned());
}
}
match std::fs::copy(payload_path, &dest) {
Ok(_) => Ok(dest.to_string_lossy().into_owned()),
Err(_) if dest.is_file() => Ok(dest.to_string_lossy().into_owned()),
Expand Down Expand Up @@ -80,9 +86,46 @@ pub fn apply_notification_toasts(hidden: bool, payload_path: &str) -> Vec<String

let mut errors = Vec::new();
for pid in pids {
// The payload keeps toast exclusion on by itself. Re-send "hide" only
// when the host is new (pid or start time) or on the health interval.
let started = crate::process::process_started_at(pid).unwrap_or(0);
if hidden && !toast_send_due(pid, started) {
continue;
}
if let Err(e) = call_export(pid, &payload_path, export, 0) {
toast_sent().remove(&pid);
errors.push(format!("Notifications: {e}"));
}
}
if !hidden {
toast_sent().clear();
}
errors
}

type ToastSent = std::collections::HashMap<u32, (u64, std::time::Instant)>;

fn toast_sent() -> std::sync::MutexGuard<'static, ToastSent> {
static SENT: std::sync::OnceLock<std::sync::Mutex<ToastSent>> = std::sync::OnceLock::new();
SENT.get_or_init(Default::default)
.lock()
.unwrap_or_else(|p| p.into_inner())
}

/// True, and recorded, when `pid` has not been sent "hide" for this process
/// instance within `PROTECTION_RECHECK`.
fn toast_send_due(pid: u32, started: u64) -> bool {
let now = std::time::Instant::now();
let mut sent = toast_sent();
match sent.get(&pid) {
Some(&(s, at))
if s == started && now.duration_since(at) < crate::hider::PROTECTION_RECHECK =>
{
false
}
_ => {
sent.insert(pid, (started, now));
true
}
}
}
23 changes: 19 additions & 4 deletions hmw-core/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum UnhideOp {
#[derive(Debug, Default)]
pub struct RuleSession {
applied: HideSet,
throttle: crate::hider::ProtectionThrottle,
}

impl RuleSession {
Expand Down Expand Up @@ -65,6 +66,7 @@ impl RuleSession {
pub fn new() -> Self {
Self {
applied: HideSet::default(),
throttle: Default::default(),
}
}

Expand All @@ -83,6 +85,7 @@ impl RuleSession {
rules: &[WindowRule],
payload_path: &str,
persistent_only: bool,
protection_checker: bool,
) -> Vec<String> {
let windows = match list_top_windows(true) {
Ok(w) => w,
Expand Down Expand Up @@ -114,10 +117,22 @@ impl RuleSession {
let outcome = apply_hides(&desired, &self.applied, payload_path);
errors.extend(outcome.errors);
self.applied = outcome.kept;
for &pid in &self.applied.processes {
if let Err(error) = crate::hider::check_protection(pid, payload_path) {
if process_is_alive(pid) {
errors.push(format!("Process {pid}: {}", error.0));
if protection_checker {
let now = std::time::Instant::now();
let processes = &self.applied.processes;
self.throttle.retain(|pid| processes.contains(&pid));
for &pid in processes {
let signature = crate::hider::window_signature(
windows.iter().filter(|w| w.pid == pid).map(|w| w.hwnd),
);
if !self.throttle.due(pid, signature, now) {
continue;
}
if let Err(error) = crate::hider::check_protection(pid, payload_path) {
self.throttle.forget(pid);
if process_is_alive(pid) {
errors.push(format!("Process {pid}: {}", error.0));
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions hmw-core/tests/wow64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn x64_controller_hides_and_restores_x86_windows_and_rules_cover_later_windows()
};
let mut session = hmw_core::watcher::RuleSession::new();
assert!(session
.apply(std::slice::from_ref(&rule), &own_payload, false)
.apply(std::slice::from_ref(&rule), &own_payload, false, true)
.is_empty());
eventually(target.hwnd, true);
let later = target.new_window();
Expand All @@ -170,7 +170,7 @@ fn x64_controller_hides_and_restores_x86_windows_and_rules_cover_later_windows()
),
(2, 2, 0)
);
assert!(session.apply(&[], &own_payload, false).is_empty());
assert!(session.apply(&[], &own_payload, false, true).is_empty());
eventually(target.hwnd, false);
eventually(later, false);
std::thread::sleep(Duration::from_millis(400));
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hidemywindows",
"version": "2.3.2",
"version": "2.3.3",
"description": "Hide your windows from screen capture, screenshots and recordings.",
"license": "MIT",
"type": "module",
Expand Down
Loading
Loading