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
Core/MMU: Add HostTryRead/HostTryWrite functions to allow specifying the desired address space, and return whether it succeeded. #9522
Core/MMU: Add HostTryRead/HostTryWrite functions to allow specifying the desired address space, and return whether it succeeded. #9522
Conversation
17534f0
to
cccdd99
Compare
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 checking, this looks like every place so far was just appended .value_or(N) and "good to go" - is this correct, or should there be places that check for std::nullopt returns instead (aside from ReadString for obvious reasons)?
|
Correct, that's all I did so far. There are definitely places here that should now check the return value and branch on it, but I didn't want to waste time thinking about it before I had an 'okay' that this is a good approach to the general issue. |
|
Speaking of the ReadString(), I was wondering how to deal with that one. For consistency it would make sense to also return a nullopt (instead of an empty string) when the address is invalid, but at the same time it might be possible (unlikely, to be fair) that there is a string that goes right up to a memory address boundary that you might want returned. Maybe return nullopt if the initial address is invalid, but return the built up string if we encounter an invalid address while advancing? |
|
No idea, I stared at it for a while, and I'm not entirely sure if it makes much ofa difference. |
ff03efb
to
ee87359
Compare
|
@AdmiralCurtiss
In some of the debugging stuff, like HLE or other widgets, the address (or range) is checked (using What do you think about adding to the interface your functions renamed as |
|
Mhm, yeah I understand what you mean. That probably is a better idea indeed, let's see... |
ee87359
to
b00ec88
Compare
|
So, like this? |
|
Yes like that. Is the |
|
It's for ensuring no one passes a nonsense enum value. I could go either way though. |
52bd380
to
4e2f02e
Compare
4e2f02e
to
3f1f019
Compare
3f1f019
to
e115219
Compare
e115219
to
c292351
Compare
|
This still looks fine to me. I guess you can add a 3rd commit regarding your use-case (Cheat Search) for these functions. |
Alright, let's give this another shot. I'll summarize here, but if you want the previous attempts, see #6913, #8310, #8682, and sorta #9361.
Basically, our Cheat Search has a big problem where your search results may break (usually completely disappear, but sometimes other weird stuff if you do comparisons with 0) because the code calling the
HostRead_*()functions cannot differentiate between them returning 0 because the actual value at that memory address is zero, or returning 0 because the address translation failed (eg. because the CPU is currently in an exception state).To help with this, I've added new
Tryvariants of the HostRead and HostWrite functions that allow specifying the expected address space of the given address and return whether the read or write succeeded or not.