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

Commit

Permalink
Test DETACHED_PROCESS instead of CREATE_NEW_CONSOLE Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
C0D3-M4513R committed Oct 14, 2023
1 parent 51acc30 commit e8d0cf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions inject-lib/src/platforms/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,7 @@ pub mod test {
use winapi::um::libloaderapi::{FreeLibrary, LoadLibraryA};
use winapi::um::tlhelp32::MODULEENTRY32W;
use winapi::um::winbase::{CREATE_NEW_CONSOLE, DETACHED_PROCESS};
use winapi::um::winnt::{
PROCESS_ALL_ACCESS, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_OPERATION,
PROCESS_VM_READ, PROCESS_VM_WRITE, SYNCHRONIZE,
};
use winapi::um::winnt::{PROCESS_ALL_ACCESS, PROCESS_CREATE_THREAD, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE, SYNCHRONIZE};

std::thread_local! {
pub(in super) static FNS_M:FNS=FNS::default();
Expand Down Expand Up @@ -859,7 +856,7 @@ pub mod test {
};

let c = std::process::Command::new(path)
.creation_flags(CREATE_NEW_CONSOLE)
.creation_flags(DETACHED_PROCESS)
.spawn()
.unwrap();
sleep(Duration::from_millis(100)); //Let the process init.
Expand All @@ -872,6 +869,7 @@ pub mod test {
| PROCESS_VM_WRITE
| PROCESS_VM_READ
| PROCESS_QUERY_INFORMATION
| PROCESS_CREATE_THREAD
| PROCESS_TERMINATE,
)
};
Expand Down
4 changes: 4 additions & 0 deletions inject-lib/src/platforms/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Process {
}
///Checks, if this process has real handle
#[must_use]
#[inline]
#[cfg_attr(not(any(feature = "ntdll", test)), allow(unused))]
pub fn has_real_handle(&self) -> bool {
self.get_proc() != unsafe { GetCurrentProcess() }
Expand Down Expand Up @@ -106,16 +107,19 @@ impl Process {
}
///Get the contained process Handle
#[must_use]
#[inline]
pub fn get_proc(&self) -> HANDLE {
self.proc as HANDLE
}
///Get the pid, the process Handle represents
#[must_use]
#[inline]
pub fn get_pid(&self) -> u32 {
self.pid
}
///Checks if the process handle has a specific permission.
#[must_use]
#[inline]
pub fn has_perm(&self, perm: DWORD) -> bool {
return self.perms & perm == perm;
}
Expand Down

0 comments on commit e8d0cf8

Please sign in to comment.