5959#include < bridge/include/CoreProvider.h>
6060#include < bridge/include/IScriptManager.h>
6161#include < bridge/include/IExtensionBridge.h>
62- #include " PseudoAddrManager.h"
6362#include < sh_vector.h>
6463
6564using namespace SourceMod ;
@@ -865,8 +864,13 @@ enum NumberType
865864static cell_t LoadFromAddress (IPluginContext *pContext, const cell_t *params)
866865{
867866 void *addr = reinterpret_cast <void *>(params[1 ]);
868- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
869- addr = pseudoAddr.FromPseudoAddress (params[1 ]);
867+ if (pContext->GetRuntime ()->FindPubvarByName (" __Int64_Address__" , nullptr ) == SP_ERROR_NONE) {
868+ cell_t * sp_addr;
869+ if (int err = pContext->LocalToPhysAddr (params[1 ], &sp_addr); err != SP_ERROR_NONE) {
870+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
871+ }
872+ auto value = *reinterpret_cast <int64_t *>(sp_addr);
873+ addr = (void *)value;
870874 }
871875
872876 if (addr == NULL )
@@ -895,8 +899,13 @@ static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params)
895899static cell_t StoreToAddress (IPluginContext *pContext, const cell_t *params)
896900{
897901 void *addr = reinterpret_cast <void *>(params[1 ]);
898- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
899- addr = pseudoAddr.FromPseudoAddress (params[1 ]);
902+ if (pContext->GetRuntime ()->FindPubvarByName (" __Int64_Address__" , nullptr ) == SP_ERROR_NONE) {
903+ cell_t * sp_addr;
904+ if (int err = pContext->LocalToPhysAddr (params[1 ], &sp_addr); err != SP_ERROR_NONE) {
905+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
906+ }
907+ auto value = *reinterpret_cast <int64_t *>(sp_addr);
908+ addr = (void *)value;
900909 }
901910
902911 if (addr == NULL )
@@ -950,9 +959,19 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
950959
951960static cell_t LoadAddressFromAddress (IPluginContext *pContext, const cell_t *params)
952961{
953- void *addr = reinterpret_cast <void *>(params[1 ]);
954- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
955- addr = pseudoAddr.FromPseudoAddress (params[1 ]);
962+ cell_t shift_param = 0 ;
963+ if (pContext->GetRuntime ()->FindPubvarByName (" __Int64_Address__" , nullptr ) == SP_ERROR_NONE) {
964+ shift_param = 1 ;
965+ }
966+
967+ void *addr = reinterpret_cast <void *>(params[shift_param + 1 ]);
968+ if (shift_param != 0 ) {
969+ cell_t * sp_addr;
970+ if (int err = pContext->LocalToPhysAddr (params[shift_param + 1 ], &sp_addr); err != SP_ERROR_NONE) {
971+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
972+ }
973+ auto value = *reinterpret_cast <int64_t *>(sp_addr);
974+ addr = (void *)value;
956975 }
957976
958977 if (addr == NULL )
@@ -963,19 +982,28 @@ static cell_t LoadAddressFromAddress(IPluginContext *pContext, const cell_t *par
963982 {
964983 return pContext->ThrowNativeError (" Invalid address 0x%x is pointing to reserved memory." , addr);
965984 }
966-
967985 void * data = *reinterpret_cast <void **>(addr);
968- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
969- return pseudoAddr.ToPseudoAddress (data);
986+
987+ if (shift_param != 0 ) {
988+ cell_t * sp_addr;
989+ if (int err = pContext->LocalToPhysAddr (params[1 ], &sp_addr); err != SP_ERROR_NONE) {
990+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
991+ }
992+ *reinterpret_cast <int64_t *>(sp_addr) = reinterpret_cast <uintptr_t >(data);
970993 }
971994 return reinterpret_cast <uintptr_t >(data);
972995}
973996
974997static cell_t StoreAddressToAddress (IPluginContext *pContext, const cell_t *params)
975998{
976999 void *addr = reinterpret_cast <void *>(params[1 ]);
977- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
978- addr = pseudoAddr.FromPseudoAddress (params[1 ]);
1000+ if (pContext->GetRuntime ()->FindPubvarByName (" __Int64_Address__" , nullptr ) == SP_ERROR_NONE) {
1001+ cell_t * sp_addr;
1002+ if (int err = pContext->LocalToPhysAddr (params[1 ], &sp_addr); err != SP_ERROR_NONE) {
1003+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
1004+ }
1005+ auto value = *reinterpret_cast <int64_t *>(sp_addr);
1006+ addr = (void *)value;
9791007 }
9801008
9811009 if (addr == NULL )
@@ -988,8 +1016,13 @@ static cell_t StoreAddressToAddress(IPluginContext *pContext, const cell_t *para
9881016 }
9891017
9901018 void *data = reinterpret_cast <void *>(params[2 ]);
991- if (pContext->GetRuntime ()->FindPubvarByName (" __Virtual_Address__" , nullptr ) == SP_ERROR_NONE) {
992- data = pseudoAddr.FromPseudoAddress (params[2 ]);
1019+ if (pContext->GetRuntime ()->FindPubvarByName (" __Int64_Address__" , nullptr ) == SP_ERROR_NONE) {
1020+ cell_t * sp_addr;
1021+ if (int err = pContext->LocalToPhysAddr (params[2 ], &sp_addr); err != SP_ERROR_NONE) {
1022+ return pContext->ThrowNativeErrorEx (err, " Could not read argument" );
1023+ }
1024+ auto value = *reinterpret_cast <int64_t *>(sp_addr);
1025+ data = (void *)value;
9931026 }
9941027
9951028 bool updateMemAccess = params[3 ];
0 commit comments