-
Notifications
You must be signed in to change notification settings - Fork 10
LibraryInfo for easy library base address getting. #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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>>; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()
.
5573198
to
bf01b32
Compare
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 aVec<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.