Skip to content
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

64bit process reading from 32bit process copies too large addresses. #5

Open
Kiiyya opened this issue Jan 18, 2021 · 3 comments
Open

Comments

@Kiiyya
Copy link

Kiiyya commented Jan 18, 2021

I was debugging why something isn't working, and then I realized CopyAddress::get_offset() is copying too many bytes. My program is 64bit, whereas the game I read from is 32bit.

I believe the culprit is this:

Ok((handle, Architecture::from_native()))
Why are we using from_native() here? I thought the whole point of having Architecture was to support reading from 32bit processes? Gonna work on a fix while waiting for replies.

If I miss something, sorry, I'm new to rust :).

@Kiiyya
Copy link
Author

Kiiyya commented Jan 18, 2021

A fix (for Windows only. Issue remains on Linux/macOS) is here: Kiiyya@707eae2

But since it's based on #4 I won't open a PR yet.

@Tommoa
Copy link
Owner

Tommoa commented Jan 19, 2021 via email

@Kiiyya
Copy link
Author

Kiiyya commented Jan 19, 2021

I think a functionality to get the architecture of an executable/process would be super convenient. Setting it to native by default creates issues like I ran into, debugging things which are difficult to debug, since most of the time copying 8 byte pointers instead of 4 bytes pointers will work just fine (if there's an extra few zeros just by chance), but then some other times it will fail. And it's not obvious what causes that. Imagine users just assuming the library knows what it's doing. Also, at least trying to consult IsWow64Process is better than just blindly choosing native architecture. I'll have a look into whether determining arch will be possible on Linux on the weekend.

I'd suggest something like my_raw_handle.try_into_arch(), which returns a Option<Architecture> (or Result), which then has to be used with .try_into_process_handle. I would remove .set_arch then, since an architecture doens't just change during runtime, heh. Though this is just a first wild suggestion, maybe something more fancy with traits can be thought of.

As far as I know, there exists IsWow64Process2 which had something mentioned about ARM, but I'll look into that on the weekend.

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

No branches or pull requests

2 participants