-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fix to failing to disassemble at the end of a memory region. #186
Conversation
Hmm this is interesting, you can see from the return code I attempted to handle this case by checking for the partial copy error already. To confirm what is occurring you are saying that when attempting to read a larger size of memory that is partially inacessible, rpm fails to copy the data even partially but does return the partial copy error (rather than another error)? |
Rpm fails to copy the first bytes of memory and returns ERROR_PARTIAL_COPY regardless. You can see by the variable "read" that is 0 after calling rpm indicating 0 bytes were read. |
Interesting, I did not realize it behaved this way. In that case, could you please update this pr to instead extend the normal safe_mem_read to detect when this happens by checking the read size field and error status, and then doing a second read with adjusted size like you do with virtual query. (So two calls to RPM would occur in this error case) The intent of safe_mem_read is to always read as much as possible so there is no need for a separate ex variant |
Yeah, I can fix the PR. Also give me some minutes to make an example program to test RPM's behavior on your system as well. |
You might consider adding that reproduction as a unit test for the mem read utilities |
And my console output is:
|
That's too bad they designed the API like that, it would be nice if it actually did the copying of the data it was able to read |
I've fixed one bug (ChatGPT trolled me) in the example provided and also made a proper read size after to see it's exactly the size parameter the problem. I'll see about also coding a unit test, I haven't messed with those yet. |
I've tested this new commit on my end and it seems to work. See if it's something like this that you'd want as final. Not trying to be annoying, but I personally didn't like the current Unit Test structure, so I might end up not messing with it. |
I'm mobile so I can't do a proper GitHub style review, so I will just comment here the parts to change. Make || read > 0 an and please. We want both the return value to be true and the read size to be non zero. And do please add the error value check so the retry only happens if it's a partial copy, we know partial copy is this particular scenario, it may filter out some other error cases where reads fail but we do not want to try again because it wouldn't work. Don't worry about the unit test then, I can add alter in a few weeks. Thanks for working on this. |
Retested with the provided fixes, seems ok to me. |
Check #184 to see my comment on what this is attempting to fix.