-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Add new address natives #2112
Add new address natives #2112
Conversation
As someone that has needed to manipulate addresses in their plugins, this sort of thing is definitely needed as part of the architectural transition. I haven't had the time to confirm how the pseudo addresses work when it comes to heap allocations and the like so I've yet to confirm how this works in practice. I gave my feedback in another channel, but I'll also comment on it here in case other people had their thoughts:
|
Two short comments. I don't have a strong opinion on unstructured memory access. However, it should be a last resort. It's inherently less maintainable and more susceptible to breakage. Having structured access is vastly better, even if 99% of the way there is structured, and the very last thing is the memory poke. That's why stuff like SDKCall and bintools and gamedata exist. But clearly the unstructured stuff is needed, and serves an important role, so it shouldn't be rejected or stuck in design hell. As to int64 - my dance card got very full, very quickly and I had to take a step away from SP again. My bar for changes right now is "can I get it done in a night or two". int64 - probably not. Even if I could, I can't start on it right this moment. Don't wait for int64. Use enumstructs:
It is MUCH easier to design syntactic sugar around these, so if you have an issue with them or have an idea that would make them easier to use, please file a bug. |
IMO this should just be a new pawn type, something like Address64, that is maybe bcompat with 32 bit Address, where the low32 is populated and high32 is null? |
Such a solution would definitively eliminate the need for But If we are to assume an enum struct is defined for |
Would a native like GetPseudoAddress(int hi, int low) be accepted? I have a use case where I can't put the address in gamedata as it doesn't have a symbol. Or at least a clone of LoadFromAddress that takes 2 Address values. |
This could be okay, however PeusdoAddresses are currently inherently broken, very high address numbers cannot be mapped to pseudoaddresses. We're currently investigating alternatives. One thing is sure, introducing new API that's gonna be replaced right after doesn't make much sense. That's why this PR has remained in limbo for so long. |
Closing in favor of #2196 & alliedmodders/sourcepawn#983 . The core of this PR is to address the lack of arithmetic ability over |
With TF2 64bits release looming on the horizon, its high time Sourcemod is updated with some very much needed natives for addresses. Otherwise we're going to have a lot of upset plugin authors !
Here's a list of a new natives I think could alleviate the issues :
Added offset parameter to
LoadFromAddress
andStoreToAddress
For instance plugins often retrieve C++ objects addresses and read member properties from them. So the need of offsetting address values is quite common and needs to be addressed, as it would be risky to perform within a plugin environment (overflowing the address value).
AddedOffsetAddress
With loading and reading covered, manual offsetting still isn't (e.g setting up a manual SDKCall). A native like this one would be required.Added
LoadAddressFromAddress
andStoreAddressToAddress
Addresses can be pointer variables. And while plugins could get away with it by treating
Address
type asNumberType_Int32
to store at a given address, they cannot anymore. An helper function for this scenario is required.AddedLoadSpanFromAddress
andStoreSpanToAddress
,LoadBytesFromAddress
andStoreBytesToAddress
For every other types that aren't covered by our natives. Let's allow plugins to store and load abritrary chunk of bytes. Useful for big types likeint64/int128
. Or other obscure scenarios, like maybe reading a string in memory.