Skip to content

Commit

Permalink
Change command to program
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Jun 6, 2024
1 parent f2ae2a7 commit e892552
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A collection of NSIS plugins written in rust.

| Plugin | Description |
| -------------------------------------------------- | ------------------------------------------------------------------------ |
| [nsis-process](./crates/nsis-process/) | Find and Kill processes, and run command as unelevated user |
| [nsis-process](./crates/nsis-process/) | Find and Kill processes, and run program as unelevated user |
| [nsis-semvercompare](./crates/nsis-semvercompare/) | Compare two semantic versions |
| [nsis-tauri-utils](./crates/nsis-tauri-utils/) | A collection of all the above plugins into a single DLL for smaller size |

Expand Down
14 changes: 7 additions & 7 deletions crates/nsis-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ fn KillProcessCurrentUser() -> Result<(), Error> {
}
}

/// Run command as unelevated user
/// Run program as unelevated user
///
/// Needs 2 strings on the stack
/// $1: command
/// $1: program
/// $2: arguments
#[nsis_fn]
fn RunAsUser() -> Result<(), Error> {
let command = popstr()?;
let program = popstr()?;
let arguments = popstr()?;
if run_as_user(&command, &arguments) {
if run_as_user(&program, &arguments) {
push(ZERO)
} else {
push(ONE)
Expand Down Expand Up @@ -224,7 +224,7 @@ fn get_processes(name: &str) -> Vec<u32> {
/// Return true if success
///
/// Ported from https://devblogs.microsoft.com/oldnewthing/20190425-00/?p=102443
unsafe fn run_as_user(command: &str, arguments: &str) -> bool {
unsafe fn run_as_user(program: &str, arguments: &str) -> bool {
let hwnd = GetShellWindow();
if hwnd == 0 {
return false;
Expand Down Expand Up @@ -274,14 +274,14 @@ unsafe fn run_as_user(command: &str, arguments: &str) -> bool {
lpAttributeList: attribute_list,
};
let mut process_info: PROCESS_INFORMATION = mem::zeroed();
let mut command_line = command.to_owned();
let mut command_line = program.to_owned();
if !arguments.is_empty() {
command_line.push(' ');
command_line.push_str(arguments);
}

if CreateProcessW(
encode_utf16(command).as_ptr(),
encode_utf16(program).as_ptr(),
encode_utf16(&command_line).as_mut_ptr(),
ptr::null(),
ptr::null(),
Expand Down

0 comments on commit e892552

Please sign in to comment.