Skip to content

Commit d89f56a

Browse files
authored
Bump windows crate to .59 (#6)
* Bump windows crate to .58, replace HINSTANCE(0) with HMODULE::default() * Bump windows crate to .59, replace HMODULE::default() with none * Build on windows
1 parent a56978e commit d89f56a

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
build:
1414

15-
runs-on: ubuntu-latest
15+
runs-on: windows-latest
1616

1717
steps:
1818
- uses: actions/checkout@v4

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ categories = ["memory-management", "games", "development-tools"]
2727
description = "pattern scanning and abstraction for pointers in memory of running processes"
2828

2929
[dependencies.windows]
30-
version = "0.56.0"
30+
version = "0.59.0"
3131
features = [
3232
"Win32_Foundation",
3333
"Win32_System_Memory",

src/process/process_modules.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ impl Process
3636
let size = (required_size / size_of::<HINSTANCE>() as u32) as u32;
3737

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

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

46-
if K32GetModuleFileNameExW(process_handle, modules[i as usize], &mut mod_name) != 0
46+
if K32GetModuleFileNameExW(Some(process_handle), Some(modules[i as usize]), &mut mod_name) != 0
4747
{
4848
let file_path = w32str_to_string(&mod_name.to_vec());
4949
let file_name = get_file_name_from_string(&file_path);

src/process/process_name.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use std::mem::size_of;
18-
use windows::Win32::Foundation::{CloseHandle, HINSTANCE, MAX_PATH};
18+
use windows::Win32::Foundation::{CloseHandle, MAX_PATH};
1919
use windows::Win32::System::ProcessStatus::{K32EnumProcesses, K32GetModuleFileNameExW};
2020
use windows::Win32::System::Threading::{GetCurrentProcess, OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE};
2121
use crate::helpers::{get_file_name_from_string, w32str_to_string};
@@ -39,7 +39,7 @@ impl Process
3939
{
4040
let handle = GetCurrentProcess();
4141
let mut mod_name = [0; MAX_PATH as usize];
42-
if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
42+
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
4343
{
4444
let file_path = w32str_to_string(&mod_name.to_vec());
4545
let file_name = get_file_name_from_string(&file_path);
@@ -83,7 +83,7 @@ impl Process
8383
pid,
8484
)
8585
{
86-
if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
86+
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
8787
{
8888
let file_path = w32str_to_string(&mod_name.to_vec());
8989
let file_name = get_file_name_from_string(&file_path);

src/process/refresh.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use std::mem::size_of;
18-
use windows::Win32::Foundation::{BOOL, CloseHandle, HANDLE, HINSTANCE};
18+
use windows::Win32::Foundation::{CloseHandle, HANDLE};
1919
use windows::Win32::System::ProcessStatus::{K32EnumProcesses, K32GetModuleFileNameExW};
2020
use windows::Win32::System::Threading::{GetExitCodeProcess, OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_READ, PROCESS_VM_WRITE};
2121
use crate::helpers::{get_file_name_from_string, w32str_to_string};
@@ -82,15 +82,15 @@ impl Process
8282
| PROCESS_VM_READ
8383
| PROCESS_VM_WRITE
8484
| PROCESS_VM_OPERATION,
85-
BOOL(0),
85+
false,
8686
pid,
8787
)
8888
{
8989
Ok(handle) =>
9090
{
9191
let mut mod_name = [0; windows::Win32::Foundation::MAX_PATH as usize];
9292

93-
if K32GetModuleFileNameExW(handle, HINSTANCE(0), &mut mod_name) != 0
93+
if K32GetModuleFileNameExW(Some(handle), None, &mut mod_name) != 0
9494
{
9595
let file_path = w32str_to_string(&mod_name.to_vec());
9696
let file_name = get_file_name_from_string(&file_path);

0 commit comments

Comments
 (0)