Skip to content

Conversation

Kiiyya
Copy link

@Kiiyya Kiiyya commented Jan 22, 2021

Since the requested changes on #4 would have required me to undo a lot of stuff, I decided to make some new pull requests.

The GetLibraryInfo trait now also returns an iterator, in case someone is interested in listing what modules are loaded at all. Sadly it returns a Vec<LibraryInfo>, not an Iterator directly, because... Box<dyn Iterator<Item = LibraryInfo>> would be too ugly I think? I don't know, I'm still new to rust and have chosen this project to be a bit of my victim for me to learn it :D.

Copy link
Owner

@tommoa tommoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments. If you want, once you've got a proper design down for the trait, I can try to implement the Linux and macOS equivalents (although I still need to research how best to do it for them).

/// Returns other error when closing the handle fails.
///
/// [`set_offset`]: trait.Memory.html#tymethod.set_offset
fn libs_iter(&self) -> std::io::Result<Vec<LibraryInfo>>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potential option instead of returning Result<Vec<LibraryInfo>> would be creating an iterating class (say LibraryIter<'a>, which implements Iterator<Item=LibraryInfo>) and implementing it for each OS. That's probably the most "rust-like" method of doing what you want.


let snapshot: winapi::um::winnt::HANDLE;
unsafe {
snapshot = tlhelp32::CreateToolhelp32Snapshot(tlhelp32::TH32CS_SNAPPROCESS, 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked how this deals with processes with unicode in them? The impression I get from https://docs.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes is that the ...W functions should be used, and then converted to utf-8 using std::os::windows::ffi::OsStringExt::from_wide().

@tommoa tommoa force-pushed the master branch 3 times, most recently from 5573198 to bf01b32 Compare October 9, 2022 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants