Skip to content

Commit

Permalink
Bump windows crate to .59 (#6)
Browse files Browse the repository at this point in the history
* Bump windows crate to .58, replace HINSTANCE(0) with HMODULE::default()

* Bump windows crate to .59, replace HMODULE::default() with none

* Build on windows
  • Loading branch information
FrankvdStam authored Jan 27, 2025
1 parent a56978e commit d89f56a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
jobs:
build:

runs-on: ubuntu-latest
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ categories = ["memory-management", "games", "development-tools"]
description = "pattern scanning and abstraction for pointers in memory of running processes"

[dependencies.windows]
version = "0.56.0"
version = "0.59.0"
features = [
"Win32_Foundation",
"Win32_System_Memory",
Expand Down
4 changes: 2 additions & 2 deletions src/process/process_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ impl Process
let size = (required_size / size_of::<HINSTANCE>() as u32) as u32;

//Get modules
let mut modules: Vec<HMODULE> = vec![HMODULE(0); size as usize];
let mut modules: Vec<HMODULE> = vec![HMODULE::default(); size as usize];
let _ = K32EnumProcessModules(process_handle, modules.as_mut_ptr(), required_size.clone(), &mut required_size).unwrap();

for i in 0..modules.len()
{
let mut mod_name = [0; MAX_PATH as usize];

if K32GetModuleFileNameExW(process_handle, modules[i as usize], &mut mod_name) != 0
if K32GetModuleFileNameExW(Some(process_handle), Some(modules[i as usize]), &mut mod_name) != 0
{
let file_path = w32str_to_string(&mod_name.to_vec());
let file_name = get_file_name_from_string(&file_path);
Expand Down
6 changes: 3 additions & 3 deletions src/process/process_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::mem::size_of;
use windows::Win32::Foundation::{CloseHandle, HINSTANCE, MAX_PATH};
use windows::Win32::Foundation::{CloseHandle, MAX_PATH};
use windows::Win32::System::ProcessStatus::{K32EnumProcesses, K32GetModuleFileNameExW};
use windows::Win32::System::Threading::{GetCurrentProcess, OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE};
use crate::helpers::{get_file_name_from_string, w32str_to_string};
Expand All @@ -39,7 +39,7 @@ impl Process
{
let handle = GetCurrentProcess();
let mut mod_name = [0; MAX_PATH as usize];
if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
{
let file_path = w32str_to_string(&mod_name.to_vec());
let file_name = get_file_name_from_string(&file_path);
Expand Down Expand Up @@ -83,7 +83,7 @@ impl Process
pid,
)
{
if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
{
let file_path = w32str_to_string(&mod_name.to_vec());
let file_name = get_file_name_from_string(&file_path);
Expand Down
6 changes: 3 additions & 3 deletions src/process/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::mem::size_of;
use windows::Win32::Foundation::{BOOL, CloseHandle, HANDLE, HINSTANCE};
use windows::Win32::Foundation::{CloseHandle, HANDLE};
use windows::Win32::System::ProcessStatus::{K32EnumProcesses, K32GetModuleFileNameExW};
use windows::Win32::System::Threading::{GetExitCodeProcess, OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE};
use crate::helpers::{get_file_name_from_string, w32str_to_string};
Expand Down Expand Up @@ -82,15 +82,15 @@ impl Process
| PROCESS_VM_READ
| PROCESS_VM_WRITE
| PROCESS_VM_OPERATION,
BOOL(0),
false,
pid,
)
{
Ok(handle) =>
{
let mut mod_name = [0; windows::Win32::Foundation::MAX_PATH as usize];

if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
{
let file_path = w32str_to_string(&mod_name.to_vec());
let file_name = get_file_name_from_string(&file_path);
Expand Down

0 comments on commit d89f56a

Please sign in to comment.