Skip to content
Open
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
235 changes: 235 additions & 0 deletions README.es.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Rust で書かれた Windows シェル: 標準のものより高速で軽量です。** Windows の一部を置き換える小さなネイティブ プログラム群 (.NET も Electron も不要): タスクバー、エクスプローラー、ファイル検索、タスク マネージャー、さらにディスク クリーナー、ディスク マップ、フォト ビューアー。インストーラー 1 つで導入でき、ボタン 1 つですべて元に戻せます。

[English](README.md) | [Русский](README.ru.md) | 日本語 | [Português (Brasil)](README.pt-BR.md) | [简体中文](README.zh.md)
[English](README.md) | [Русский](README.ru.md) | 日本語 | [Português (Brasil)](README.pt-BR.md) | [简体中文](README.zh.md) | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a href="https://discord.gg/5H4r7kBsxP">Discord</a>
</p>

<p align="center">English | <a href="README.ru.md">Русский</a> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a></p>
<p align="center">English | <a href="README.ru.md">Русский</a> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a> | <a href="README.es.md">Español</a></p>

![The WinRust bar with its settings menu, Ruby theme](docs/screenshots/taskbar.webp)

Expand All @@ -43,7 +43,7 @@
</tr>
<tr>
<td width="33%" valign="top">↩️ <b>Reversible</b><br>Every value is saved before it is changed and put back on uninstall. One button removes everything.</td>
<td width="33%" valign="top">🎨 <b>Yours</b><br>Eight styles (Ruby, Terminal, Floating dock, Windows 98 and more), any colour, the bar on any edge, English, Русский, 日本語 or Português.</td>
<td width="33%" valign="top">🎨 <b>Yours</b><br>Eight styles (Ruby, Terminal, Floating dock, Windows 98 and more), any colour, the bar on any edge, English, Русский, 日本語, Português, 简体中文 or Español.</td>
<td width="33%" valign="top">💬 <b>Together</b><br>Help, ideas and setups in English and Russian on <a href="https://discord.gg/5H4r7kBsxP">Discord</a>.</td>
</tr>
</table>
Expand Down Expand Up @@ -74,7 +74,7 @@ If UAC asks for **another administrator's** password, the per-user settings (sta

**Manual update:** download the new `WinRust.exe` from the releases page, run it as administrator and press **Update** on the Express card (it reinstalls what is installed and adds what is missing), or use Custom. An existing `rust-explorer` stays ticked. Your settings and the saved original Windows values stay.

The installer is in English. Its corner holds a language drop-down — English, Русский, 日本語, Português (Brasil), 简体中文; the same list sits behind the gear on the bar (**Bar settings → Language**), and rust-settings has it on its Personalization page (**Interface language**). The choice is stored in `%ProgramData%\WinRust\lang.txt` (`en`, `ru`, `ja`, `pt`, `zh`); every running WinRust program switches within a second, no restart needed (a window that builds some texts when it opens, such as menus or column headers, shows those in the new language the next time it opens).
The installer is in English. Its corner holds a language drop-down — English, Русский, 日本語, Português (Brasil), 简体中文, Español; the same list sits behind the gear on the bar (**Bar settings → Language**), and rust-settings has it on its Personalization page (**Interface language**). The choice is stored in `%ProgramData%\WinRust\lang.txt` (`en`, `ru`, `ja`, `pt`, `zh`, `es`); every running WinRust program switches within a second, no restart needed (a window that builds some texts when it opens, such as menus or column headers, shows those in the new language the next time it opens).

## Remove

Expand Down Expand Up @@ -174,7 +174,7 @@ src/ the installer (plugin-launcher.exe)
main.rs the plugin table PLUGINS: name, texts, install/uninstall pair, icon
install/ what each plugin changes and how it is undone (one file per plugin)
cli.rs, ui.rs the command line and the window; both call the same install functions
common/ winrust-common: language switch (t!/tf!: English, Russian, Japanese, Brazilian Portuguese), UI styles and palettes, reg.exe output parser, NTFS MFT reader
common/ winrust-common: language switch (t!/tf!: English, Russian, Japanese, Brazilian Portuguese, Simplified Chinese, Spanish), UI styles and palettes, reg.exe output parser, NTFS MFT reader
plugins/ sources of every plugin, each its own crate
ReShell/ reshell (desktop hotkeys, topbar safety net), ships with topbar
payload.txt the exes embedded into the installer, and where the build puts them
Expand All @@ -184,7 +184,7 @@ scripts/ build, update, release
Everything is one cargo workspace (one `Cargo.lock`, every exe in `target\release`). `plugins/rust-search` and `plugins/chrome-rs` build separately because they need `panic = "unwind"` (see `Cargo.toml`).

### Adding a language
`t!("русский", "english", ja: "日本語", pt: "português", zh: "中文")` and `tf!(…)` return each text in the current language (without `ja:`/`pt:`/`zh:` those languages show the English one). The languages are the `Lang` enum in `common/src/lib.rs`.
`t!("русский", "english", ja: "日本語", pt: "português", zh: "中文", es: "español")` and `tf!(…)` return each text in the current language (without `ja:`/`pt:`/`zh:`/`es:` those languages show the English one). The languages are the `Lang` enum in `common/src/lib.rs`.

### Build
Needs Windows x64, Rust stable (1.85+) with the MSVC toolchain.
Expand Down
2 changes: 1 addition & 1 deletion README.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Um shell do Windows escrito em Rust: mais rápido e mais leve que o original.** Programas nativos pequenos (sem .NET, sem Electron) que substituem partes do Windows: a barra de tarefas, o Explorador de Arquivos, a pesquisa de arquivos, o Gerenciador de Tarefas, além de um limpador de disco, um mapa de disco e um visualizador de fotos. Um instalador coloca tudo, um botão tira tudo.

[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | Português (Brasil) | [简体中文](README.zh.md)
[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | Português (Brasil) | [简体中文](README.zh.md) | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a href="https://discord.gg/5H4r7kBsxP">Discord</a>
</p>

<p align="center"><a href="README.md">English</a> | <b>Русский</b> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a></p>
<p align="center"><a href="README.md">English</a> | <b>Русский</b> | <a href="README.ja.md">日本語</a> | <a href="README.pt-BR.md">Português (Brasil)</a> | <a href="README.zh.md">简体中文</a> | <a href="README.es.md">Español</a></p>

![Панель WinRust с меню настроек, тема «Рубин»](docs/screenshots/taskbar.webp)

Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**用 Rust 编写的 Windows 外壳:比系统自带的更快、更轻。** 一批原生小程序(不用 .NET,不用 Electron)替换掉 Windows 的部件:任务栏、资源管理器、文件搜索、任务管理器,另外还有磁盘清理、磁盘占用图和图片查看器。一个安装程序全部装好,一个按钮全部卸掉。

[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | [Português (Brasil)](README.pt-BR.md) | **简体中文**
[English](README.md) | [Русский](README.ru.md) | [日本語](README.ja.md) | [Português (Brasil)](README.pt-BR.md) | **简体中文** | [Español](README.es.md)

<p align="center">
<a href="https://github.com/Lemxy/WinRust/releases/latest"><img src="https://img.shields.io/github/v/release/Lemxy/WinRust?style=for-the-badge&logo=github&label=release&color=B7410E" alt="Latest release"></a>
Expand Down
31 changes: 27 additions & 4 deletions common/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn program(target: &str) -> bool {
return false;
}
if matches!(ext_of(target).as_str(), "exe" | "com" | "scr") {
if elevated() && as_session_user(&format!("\"{target}\"")) {
if elevated() && as_session_user(&format!("\"{target}\""), 0) {
return true;
}
if Command::new("runas").args(["/trustlevel:0x20000", target]).creation_flags(NO_WINDOW).spawn().is_ok() {
Expand All @@ -69,6 +69,25 @@ pub fn program(target: &str) -> bool {
shell_execute(target)
}

/// Runs an executable with command-line arguments under the desktop session user's normal token,
/// waiting briefly so short-lived setup tasks (like importing Quick Access pins) finish cleanly.
pub fn program_args(target: &str, args: &str) -> bool {
use std::os::windows::process::CommandExt;
let target = target.trim().trim_matches('"');
if target.is_empty() {
return false;
}
let cmd = format!("\"{target}\" {args}");
if elevated() && as_session_user(&cmd, 5000) {
return true;
}
Command::new(target)
.args(args.split_whitespace())
.creation_flags(NO_WINDOW)
.status()
.is_ok_and(|s| s.success())
}

/// This process really has admin rights: the Administrators group is on. The "basic user" token says it is elevated too
/// (High integrity), but there the group is deny-only.
fn elevated() -> bool {
Expand All @@ -78,17 +97,18 @@ fn elevated() -> bool {
/// Starts `cmdline` with the token of the session's own shell host (sihost.exe, always there and never elevated; Explorer
/// when it is missing): the token a program started from the desktop gets. Needs an elevated caller (CreateProcessWithTokenW
/// wants SeImpersonatePrivilege). False when nothing was started.
fn as_session_user(cmdline: &str) -> bool {
fn as_session_user(cmdline: &str, wait_ms: u32) -> bool {
use windows_sys::Win32::{
Foundation::{CloseHandle, HANDLE},
Security::{DuplicateTokenEx, SecurityImpersonation, TOKEN_ASSIGN_PRIMARY, TOKEN_DUPLICATE, TOKEN_QUERY, TokenPrimary},
System::{
Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, PROCESSENTRY32W, Process32FirstW, Process32NextW, TH32CS_SNAPPROCESS},
RemoteDesktop::ProcessIdToSessionId,
Threading::{CREATE_UNICODE_ENVIRONMENT, CreateProcessWithTokenW, OpenProcess, OpenProcessToken, PROCESS_INFORMATION, PROCESS_QUERY_LIMITED_INFORMATION, STARTUPINFOW},
Threading::{CREATE_UNICODE_ENVIRONMENT, CreateProcessWithTokenW, OpenProcess, OpenProcessToken, PROCESS_INFORMATION, PROCESS_QUERY_LIMITED_INFORMATION, STARTUPINFOW, WaitForSingleObject},
},
};
const MAXIMUM_ALLOWED: u32 = 0x0200_0000;
const LOGON_WITH_PROFILE: u32 = 1;
let wide = |s: &str| s.encode_utf16().chain([0]).collect::<Vec<u16>>();
unsafe {
let mut mine = 0u32;
Expand Down Expand Up @@ -141,9 +161,12 @@ fn as_session_user(cmdline: &str) -> bool {
si.cb = size_of::<STARTUPINFOW>() as u32;
let mut pi: PROCESS_INFORMATION = std::mem::zeroed();
let mut cmd = wide(cmdline);
let ok = CreateProcessWithTokenW(prim, 0, std::ptr::null(), cmd.as_mut_ptr(), CREATE_UNICODE_ENVIRONMENT, std::ptr::null(), dir.as_ptr(), &si, &mut pi) != 0;
let ok = CreateProcessWithTokenW(prim, LOGON_WITH_PROFILE, std::ptr::null(), cmd.as_mut_ptr(), CREATE_UNICODE_ENVIRONMENT, std::ptr::null(), dir.as_ptr(), &si, &mut pi) != 0;
CloseHandle(prim);
if ok {
if wait_ms > 0 {
WaitForSingleObject(pi.hProcess, wait_ms);
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return true;
Expand Down
Loading