diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 6b8ab700..85670843 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -30,6 +30,9 @@ */ #include +#if defined WIN32 +#include +#endif #include "amxmodx.h" #include "fakemeta.h" #include "newmenus.h" @@ -1034,7 +1037,7 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_ g_NeedsP = true; #endif - } else if (mminor == 11) { + } else if (mminor >= 11) { g_IsNewMM = true; } else if (pminor > mminor) { LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin"); diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index aba209e1..5b466993 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -406,7 +406,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64 { //amx->base = (unsigned char FAR *)realloc( np, amx->code_size ); #ifndef __linux__ - amx->base = new unsigned char[ amx->code_size ]; + amx->base = (unsigned char *)VirtualAlloc(NULL, amx->code_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else //posix_memalign((void **)&(amx->base), sysconf(_SC_PAGESIZE), amx->code_size); amx->base = (unsigned char *)memalign(sysconf(_SC_PAGESIZE), amx->code_size); @@ -593,15 +593,29 @@ int set_amxnatives(AMX* amx,char error[128]) int unload_amxscript(AMX* amx, void** program) { + int flags = amx->flags; amxx_FreeDebug(amx); CList::iterator a = g_loadedscripts.find( amx ); if ( a ) a.remove(); char *prg = (char *)*program; -#if defined __linux__ && defined JIT && defined MEMORY_TEST + if (!prg) + return AMX_ERR_NONE; +#if defined JIT +#if defined __linux__ && defined MEMORY_TEST #undef free free(prg); #define free(ptr) m_deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr) +#elif defined WIN32 + if (flags & AMX_FLAG_DEBUG) + { + delete [] prg; + } else if (!VirtualFree((LPVOID)prg, 0, MEM_RELEASE)) { + AMXXLOG_Log("[AMXX] Could not free plugin memory, failure %d.", GetLastError()); + return AMX_ERR_PARAMS; + } +#endif //OS support #else + //delete normally delete[] prg; #endif *program = 0; diff --git a/amxmodx/msvc/amxmodx_mm.vcproj b/amxmodx/msvc/amxmodx_mm.vcproj index 69a11ad1..fb60a20d 100755 --- a/amxmodx/msvc/amxmodx_mm.vcproj +++ b/amxmodx/msvc/amxmodx_mm.vcproj @@ -112,11 +112,12 @@ @@ -250,11 +251,12 @@ + + + + + + + + + + + +