Rewrote user message caching code to always use IServerGameDLL::GetUserMessageInfo (
bug 4117, r=dvander).
Games where the above function can crash are handled by detouring tier0's Error() function and jumping back to our own code. So in theory this should work on all games now.
3 * ======================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
29 #include "metamod_oslink.h"
36 #if defined __WIN32__ || defined _WIN32 || defined WIN32
39 static char buf[1024];
44 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
47 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
53 _snprintf(buf, sizeof(buf), "unknown error %x", num);
66 extern "C" void __cxa_guard_acquire(void)
70 extern "C" void __cxa_guard_release(void)
75 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
77 #if defined WIN32 || defined _WIN32
78 MEMORY_BASIC_INFORMATION mem;
79 if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
81 if (mem.AllocationBase == NULL)
83 HMODULE dll = (HMODULE)mem.AllocationBase;
84 GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
85 #elif defined __linux__
87 if (!dladdr(pAddr, &info))
89 if (!info.dli_fbase || !info.dli_fname)
91 const char *dllpath = info.dli_fname;
92 snprintf(buffer, maxlength, "%s", dllpath);
97 #if defined __GNUC__ && (__GNUC__ == 3 || __GNUC__ == 4)
98 void * operator new(size_t size) {
102 void * operator new[](size_t size) {
106 void operator delete(void * ptr) {
110 void operator delete[](void * ptr) {