From 0c745590ec97340993352f5a5d239488e7c58242 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 6 Jan 2006 14:22:12 +0000 Subject: [PATCH] Added functions for smashing the stack and memory :) --- amxmodx/CLang.cpp | 7 +++++++ amxmodx/amxmodx.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/amxmodx/CLang.cpp b/amxmodx/CLang.cpp index 68ecff52..643ed712 100755 --- a/amxmodx/CLang.cpp +++ b/amxmodx/CLang.cpp @@ -395,6 +395,13 @@ size_t do_amx_format_parameter(AMX *amx, cell *params, const char **fmtstr, int return _snprintf(output, maxlen, fmtptr, *(REAL *)addr); break; } + case 'p': + { + FMTPM_NEXTPARAM(); + return _snprintf(output, maxlen, fmtptr, addr); + break; + } + case 'x': case 'i': case 'd': case 'c': diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 0d748b3f..472e078b 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -3661,9 +3661,35 @@ static cell AMX_NATIVE_CALL set_fail_state(AMX *amx, cell *params) return 0; } +static cell AMX_NATIVE_CALL amx_var_addr(AMX *amx, cell *params) +{ + if (params[0] / sizeof(cell) > 0) + { + return params[1]; + } + + return 0; +} + +static cell AMX_NATIVE_CALL amx_addr_val(AMX *amx, cell *params) +{ + cell *addr; + int err; + + if ( (err=amx_GetAddr(amx, params[1], &addr)) != AMX_ERR_NONE ) + { + LogError(amx, err, "Bad reference %d supplied", params[1]); + return 0; + } + + return addr ? *addr : 0; +} + AMX_NATIVE_INFO amxmodx_Natives[] = { {"abort", amx_abort}, + {"amx_addr_val", amx_addr_val}, + {"amx_var_addr", amx_var_addr}, {"callfunc_begin", callfunc_begin}, {"callfunc_begin_i", callfunc_begin_i}, {"callfunc_end", callfunc_end},