-
-
Notifications
You must be signed in to change notification settings - Fork 429
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 Address
methodmap
#1841
base: master
Are you sure you want to change the base?
Add Address
methodmap
#1841
Conversation
Everything works from the first tests
|
Added
methodmap_address_speedtests.zip If one of the methods worked incorrectly, the server would crash when |
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.
This is desired, but the implementations should match underneath. If we want to change end-user aspects that's fine.
|
||
if (!IsAddressValidRange(addr)) | ||
{ | ||
#ifdef _DEBUG |
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.
This should be printed regardless. What's the harm?
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.
This should be printed regardless. What's the harm?
An ordinary server holder will be scared.
And from a SourceMod, there are usually not so many error written in message.
} | ||
|
||
#ifdef _DEBUG | ||
if (!HasAddressAccess<SH_MEM_READ>(addr)) |
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.
Safety is preferred, but I'm not sure this is necessary in either context. Address should be "trusted", and this can be a very hot path.
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.
Safety is preferred
I put the debug build into safe operation, because direct memory take a long time with many calls. I can make a cache for quick ranges checks of allowed memory
{ | ||
void *addr = GetAddress(caddr, coffset); | ||
|
||
if (!IsAddressValidRange(addr)) |
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.
Why isn't this patching memory pages like in the old implementation?
|
||
if (!IsAddressValidRange(addr)) | ||
{ | ||
#ifdef _DEBUG |
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.
same printing comment
} | ||
|
||
#ifdef _DEBUG | ||
if (!HasAddressAccess<SH_MEM_READ /* Old value is being read */ | SH_MEM_WRITE>(addr)) |
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.
write the page bits regardless.
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.
write the page bits regardless.
From a viewpoint of dynamic memory hierarchy and a native call cost, it would be advantageous of speed and functionality to read a old value, returning it, instead of void (zero)
@@ -1114,6 +1251,15 @@ REGISTER_NATIVES(coreNatives) | |||
{"IsNullVector", IsNullVector}, | |||
{"IsNullString", IsNullString}, | |||
{"LogStackTrace", LogStackTrace}, | |||
|
|||
{"Address.ReadInt8", Address_ReadInt8}, |
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.
the existing natives should be updated to use the new functions.
@@ -697,6 +697,10 @@ native FeatureStatus GetFeatureStatus(FeatureType type, const char[] name); | |||
native void RequireFeature(FeatureType type, const char[] name, | |||
const char[] fmt="", any ...); | |||
|
|||
#define SH_MEM_READ (1 << 0) // Memory block can be read. |
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.
These are implementation specific, and likely shouldn't have the SourceHook prefix. Changing them to something on the address map would likely be better.
So far, draft.
Need tests