Skip to content

Commit

Permalink
Use bash always
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Nov 18, 2024
1 parent dc45399 commit efa390f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- name: cargo test build
run: cargo build --tests --release
- name: cargo test
shell: bash
run: cargo test --release
- name: detects powershell
if: ${{ matrix.os != 'macos-14' }}
Expand Down
24 changes: 12 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ pub fn is_powershell_parent() -> bool {
while let Some(ph) = handle {
let mut basic_info = std::mem::MaybeUninit::<ProcessBasicInformation>::uninit();
let mut length = 0;
if dbg!(nt_query_information_process(
if nt_query_information_process(
ph.handle,
Processinfoclass::ProcessBasicInformation,
basic_info.as_mut_ptr().cast(),
std::mem::size_of::<ProcessBasicInformation>() as _,
&mut length,
)) != StatusSuccess
) != StatusSuccess
{
break;
}
Expand All @@ -331,12 +331,12 @@ pub fn is_powershell_parent() -> bool {
unique_process: ppid,
unique_thread: 0,
};
if dbg!(nt_open_process(
if nt_open_process(
&mut parent_handle,
ProcessAccessRights::ProcessQueryInformation,
&obj_attr,
&client_id
)) != StatusSuccess
&client_id,
) != StatusSuccess
{
break;
}
Expand All @@ -345,13 +345,13 @@ pub fn is_powershell_parent() -> bool {
handle: parent_handle,
});

if dbg!(nt_query_information_process(
if nt_query_information_process(
parent_handle,
Processinfoclass::ProcessImageFileName,
file_name.as_mut_ptr().cast(),
(file_name.len() * 2) as _,
&mut length,
)) != StatusSuccess
) != StatusSuccess
{
break;
}
Expand All @@ -362,11 +362,11 @@ pub fn is_powershell_parent() -> bool {
(ustr.length >> 1) as usize,
));

let path = os.to_string_lossy();
eprintln!("{path}");
let p = std::path::Path::new(path.as_ref());
if p.file_stem() == Some(std::ffi::OsStr::new("pwsh")) {
return true;
let path = std::path::Path::new(&os);
if let Some(stem) = path.file_stem().and_then(|stem| stem.to_str()) {
if stem == "pwsh" || stem == "powershell" {
return true;
}
}
}

Expand Down

0 comments on commit efa390f

Please sign in to comment.