Skip to content

Commit

Permalink
feat: ✨ Make exectuable a PathBuf and add basic path checking
Browse files Browse the repository at this point in the history
  • Loading branch information
AntwortEinesLebens committed Oct 20, 2024
1 parent d99f8a8 commit b9b19f9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/actions/processes/spoofing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use crate::{actions::Runnable, windows::processes::get_pid};
use clap::Parser;
use std::{error::Error, ffi::OsString, iter::once, mem::size_of, os::windows::ffi::OsStrExt};
use std::{
error::Error, ffi::OsString, iter::once, mem::size_of, os::windows::ffi::OsStrExt,
path::PathBuf,
};
use windows::{
core::{Owned, PWSTR},
Win32::{
Expand All @@ -21,13 +24,17 @@ use windows::{
#[derive(Debug, Parser)]
pub struct Spoofing {
#[clap(required = true, help = "Path to the executable")]
executable: String,
executable: PathBuf,
#[clap(required = true, help = "Name of the parent executable")]
parent_executable: String,
}

impl Runnable for Spoofing {
fn run(&self) -> Result<(), Box<dyn Error>> {
if !self.executable.try_exists()? || !self.executable.is_file() {
return Ok(());
}

let mut required_size: usize = 0;

unsafe {
Expand Down Expand Up @@ -79,7 +86,7 @@ impl Runnable for Spoofing {
CreateProcessW(
None,
PWSTR(
OsString::from(self.executable.as_str())
OsString::from(self.executable.as_os_str())
.encode_wide()
.chain(once(0))
.collect::<Vec<_>>()
Expand Down

0 comments on commit b9b19f9

Please sign in to comment.