Commit Graph

6 Commits

Author SHA1 Message Date
Benoist
6439769d50
Introduce Virtual Address (#2226)
Some checks failed
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang, clang++, ubuntu-latest, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang-14, clang++-14, ubuntu-22.04, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (msvc, windows-latest, win) (push) Has been cancelled
hl2sdk-mock tests / mock (push) Has been cancelled
SourcePawn scripting / build (ubuntu-latest, linux) (push) Has been cancelled
SourcePawn scripting / build (windows-latest, win) (push) Has been cancelled
In the current ongoing effort for sourcemod to fully support 64 bits, we are introducing "virtual address".

# Explanation

Because SourcePawn does not yet support a 64 bits-wide type it's been impossible for any plugins to hold addresses in regular 32-bits wide variable.

A first attempt at solving this issue was made in commit ce1a4dcac0 therein dubbed "PseudoAddress", however this turned out to be an unsatisfactory solution, as any 'high' address if offsetted could turn invalid (or outright be impossible to map).

This leaves us with three alternatives :
- New type
- Convert Address into a handle
- Virtual Address

A new type is the most destructive solution, as it entails breaking every single Address related method. While that solution is still not off the table, we're reserving it as the last attempt should this commit fail.

Converting into a handle type is a good compromise between a brand new type whilst also preserving the Address methods. However, this comes with two issues: the first being that you can no longer offset Address, the second is that we would require authors to free the handle type which will be very confusing. This will likely not be implemented.

# Virtual address

Under a reasonable assumption, we've noted that the average plugin is unlikely to play with more than 4 GB of memory; this shouldn't be too surprising as all valve games were once 32bits and therefore limited to 4GB. Assuming this stays mostly true and a plugin isn't interested with the mapped memory of lesser known modules (like soundlib or matlib), it is fair to assume plugins are unlikely to access more than 4GB of mapped memory. Working with this in mind, we map the memory the plugins are likely to access to our custom virtual address ranges (from 0 to 4Gb, the values of which can fit on 32bits variable). If any memory was missed and plugins were to try an access it later those ranges will be late-mapped to our virtual address ranges until we run out of them.

In order to use virtual addressing, whether on 32 bits or 64 bits. Plugins must now "#include <virtual_address>", as well as use the new SDKCall_VirtualAddress, SDKType_VirtualAddress, LoadAddressFromAddress & StoreAddressToAddress where it's appropriate to.
2025-11-13 13:23:13 +01:00
Benoist
2382453d50
Manifest updates and compilation fixes for css, tf2, dods, hl2dm (#2268)
* Initial attempt at compiling against tf2_sdk2013

* compilation fix for css

* Switch to AMTL platform arch defines

* Add CBasePlayer forward decl for dods and hl2dm as well

* Update hl2sdk-manifests

* Add dods to CI

* Actually include am-platform.h

---------

Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
Co-authored-by: Nicholas Hastings <nshastings@gmail.com>
2025-02-20 00:51:38 +00:00
Benoist
6b6dbc6c06
Dhooks safetyhook (#2205)
* remove libudis86

* switch to safetyhook

* Don't leak memory

* fix issue with the trampoline

* Add x86_64 detour support (windows)

* Allow to differentiate platforms

---------

Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
2024-10-20 16:45:19 +00:00
Benoist
4e15a92984
Add x64 Windows support to DHooks (#2154)
* Add x64 Windows support

* undo changes of hook.cpp

* undo changes of hook.h

* undo changes of extension.cpp

* undo changes of listeners.cpp

* undo changes of signatures.cpp

* fix dhooks on x86

* Fix-up dhooks buildscript

---------

Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
2024-09-10 23:26:30 +00:00
Peace-Maker
581068c09b Add copyright headers 2021-11-17 13:17:39 +01:00
Peace-Maker
0f5f1a814e Import DHooks + Dynamic Detouring
This is the latest DHooks version from 1314f2d1b4
2021-11-17 13:17:39 +01:00