1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2007 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): David "BAILOPAN" Anderson
8 * ============================
12 * @brief Implements OS-dependant functions from oslink.h
16 #include "metamod_oslink.h"
23 #if defined __WIN32__ || defined _WIN32 || defined WIN32
26 static char buf[1024];
27 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
29 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
30 (LPTSTR) &buf, 0, NULL);
41 extern "C" void __cxa_guard_acquire(void)
45 extern "C" void __cxa_guard_release(void)
50 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
52 #if defined WIN32 || defined _WIN32
53 MEMORY_BASIC_INFORMATION mem;
54 if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
56 if (mem.AllocationBase == NULL)
58 HMODULE dll = (HMODULE)mem.AllocationBase;
59 GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
60 #elif defined __linux__
62 if (!dladdr(pAddr, &info))
64 if (!info.dli_fbase || !info.dli_fname)
66 const char *dllpath = info.dli_fname;
67 snprintf(buffer, maxlength, "%s", dllpath);
72 #if defined __GNUC__ && (__GNUC__ == 3 || __GNUC__ == 4)
73 void * operator new(size_t size) {
77 void * operator new[](size_t size) {
81 void operator delete(void * ptr) {
85 void operator delete[](void * ptr) {